imapflow 1.0.130 → 1.0.132

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,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ - 1.0.131 - 2023-06-29
4
+
5
+ - Fixed issue with labels that start with tilde
6
+
3
7
  - 1.0.129 - 2023-06-12
4
8
 
5
9
  - Bumped deps for maintenance
@@ -14,6 +14,7 @@ module.exports = async connection => {
14
14
 
15
15
  let currentMailbox = connection.mailbox;
16
16
  connection.mailbox = false;
17
+ connection.mailboxOptions = false;
17
18
  connection.state = connection.states.AUTHENTICATED;
18
19
 
19
20
  if (currentMailbox) {
@@ -150,7 +150,17 @@ module.exports = async (connection, maxIdleTime) => {
150
150
  };
151
151
 
152
152
  let idleCheck = async () => {
153
- let response = await connection.exec('NOOP', false, { comment: 'IDLE not supported' });
153
+ let response;
154
+ switch (connection.missingIdleCommand) {
155
+ case 'SELECT':
156
+ connection.log.debug({ src: 'c', msg: `Running SELECT to detect changes in folder` });
157
+ response = await connection.exec('SELECT', connection.mailbox.path, connection.mailboxOptions);
158
+ break;
159
+ case 'NOOP':
160
+ default:
161
+ response = await connection.exec('NOOP', false, { comment: 'IDLE not supported' });
162
+ break;
163
+ }
154
164
  response.next();
155
165
  };
156
166
 
@@ -183,6 +183,7 @@ module.exports = async (connection, path, options) => {
183
183
  }
184
184
 
185
185
  connection.mailbox = map;
186
+ connection.mailboxOptions = options;
186
187
  connection.state = connection.states.SELECTED;
187
188
 
188
189
  if (!currentMailbox || currentMailbox.path !== path) {
@@ -204,6 +205,7 @@ module.exports = async (connection, path, options) => {
204
205
  let currentMailbox = connection.mailbox;
205
206
 
206
207
  connection.mailbox = false;
208
+ connection.mailboxOptions = false;
207
209
  connection.state = connection.states.AUTHENTICATED;
208
210
 
209
211
  if (currentMailbox) {
@@ -190,6 +190,15 @@ class TokenParser {
190
190
  case '~': {
191
191
  let nextChr = this.str.charAt(i + 1);
192
192
  if (nextChr !== '{') {
193
+ if (imapFormalSyntax['ATOM-CHAR']().indexOf(nextChr)) {
194
+ // treat as ATOM
195
+ this.currentNode = this.createNode(this.currentNode, this.pos + i);
196
+ this.currentNode.type = 'ATOM';
197
+ this.currentNode.value = chr;
198
+ this.state = 'ATOM';
199
+ break;
200
+ }
201
+
193
202
  throw new Error(`Unexpected literal8 marker at position ${this.pos + i} [E9]`);
194
203
  }
195
204
  this.expectedLiteralType = 'literal8';
package/lib/imap-flow.js CHANGED
@@ -130,6 +130,7 @@ class ImapFlow extends EventEmitter {
130
130
  * @param {String} [options.proxy] Optional proxy URL. Supports HTTP CONNECT (`http://`, `https://`) and SOCKS (`socks://`, `socks4://`, `socks5://`) proxies
131
131
  * @param {Boolean} [options.qresync=false] If true, then enables QRESYNC support. EXPUNGE notifications will include `uid` property instead of `seq`
132
132
  * @param {Number} [options.maxIdleTime] If set, then breaks and restarts IDLE every maxIdleTime ms
133
+ * @param {String} [options.missingIdleCommand="NOOP"] Which command to use if server does not support IDLE
133
134
  * @param {Boolean} [options.disableBinary=false] If true, then ignores the BINARY extension when making FETCH and APPEND calls
134
135
  * @param {Boolean} [options.disableAutoEnable] Do not enable supported extensions by default
135
136
  * @param {Number} [options.connectionTimeout=90000] how many milliseconds to wait for the connection to establish (default is 90 seconds)
@@ -247,6 +248,7 @@ class ImapFlow extends EventEmitter {
247
248
  * @type {MailboxObject|Boolean}
248
249
  */
249
250
  this.mailbox = false;
251
+ this.mailboxOptions = false;
250
252
 
251
253
  /**
252
254
  * Is current mailbox idling (`true`) or not (`false`)
@@ -275,6 +277,7 @@ class ImapFlow extends EventEmitter {
275
277
  this.idRequested = false;
276
278
 
277
279
  this.maxIdleTime = this.options.maxIdleTime || false;
280
+ this.missingIdleCommand = (this.options.missingIdleCommand || '').toString().toUpperCase().trim() || 'NOOP';
278
281
 
279
282
  this.disableBinary = !!this.options.disableBinary;
280
283
 
package/lib/tools.js CHANGED
@@ -354,6 +354,14 @@ module.exports = {
354
354
  return map;
355
355
  },
356
356
 
357
+ processName(name) {
358
+ name = (name || '').toString();
359
+ if (name.length > 2 && name.at(0) === '"' && name.at(-1) === '"') {
360
+ name = name.replace(/^"|"$/g, '');
361
+ }
362
+ return name;
363
+ },
364
+
357
365
  parseEnvelope(entry) {
358
366
  let getStrValue = obj => {
359
367
  if (!obj) {
@@ -370,7 +378,7 @@ module.exports = {
370
378
 
371
379
  let processAddresses = function (list) {
372
380
  return [].concat(list || []).map(addr => ({
373
- name: libmime.decodeWords(getStrValue(addr[0]) || ''),
381
+ name: module.exports.processName(libmime.decodeWords(getStrValue(addr[0]))),
374
382
  address: (getStrValue(addr[2]) || '') + '@' + (getStrValue(addr[3]) || '')
375
383
  }));
376
384
  },
package/lib/types.d.ts CHANGED
@@ -29,6 +29,7 @@ declare module "imapflow" {
29
29
  * @param [options.proxy] - Optional proxy URL. Supports HTTP CONNECT (`http://`, `https://`) and SOCKS (`socks://`, `socks4://`, `socks5://`) proxies
30
30
  * @param [options.qresync = false] - If true, then enables QRESYNC support. EXPUNGE notifications will include `uid` property instead of `seq`
31
31
  * @param [options.maxIdleTime] - If set, then breaks and restarts IDLE every maxIdleTime ms
32
+ * @param [options.missingIdleCommand = "NOOP"] - Which command to use if server does not support IDLE
32
33
  * @param [options.disableBinary = false] - If true, then ignores the BINARY extension when making FETCH and APPEND calls
33
34
  * @param [options.disableAutoEnable] - Do not enable supported extensions by default
34
35
  * @param [options.connectionTimeout = 90000] - how many milliseconds to wait for the connection to establish (default is 90 seconds)
@@ -61,6 +62,7 @@ declare module "imapflow" {
61
62
  proxy?: string;
62
63
  qresync?: boolean;
63
64
  maxIdleTime?: number;
65
+ missingIdleCommand?: string;
64
66
  disableBinary?: boolean;
65
67
  disableAutoEnable?: boolean;
66
68
  connectionTimeout?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imapflow",
3
- "version": "1.0.130",
3
+ "version": "1.0.132",
4
4
  "description": "IMAP Client for Node",
5
5
  "main": "./lib/imap-flow.js",
6
6
  "scripts": {
@@ -31,15 +31,15 @@
31
31
  "@babel/eslint-plugin": "7.22.5",
32
32
  "@babel/plugin-syntax-class-properties": "7.12.13",
33
33
  "@babel/preset-env": "7.22.5",
34
- "@types/node": "20.3.1",
34
+ "@types/node": "20.3.2",
35
35
  "braintree-jsdoc-template": "3.3.0",
36
- "eslint": "8.42.0",
36
+ "eslint": "8.43.0",
37
37
  "eslint-config-nodemailer": "1.2.0",
38
38
  "eslint-config-prettier": "8.8.0",
39
39
  "grunt": "1.6.1",
40
40
  "grunt-cli": "1.4.3",
41
41
  "grunt-contrib-nodeunit": "5.0.0",
42
- "grunt-eslint": "24.1.0",
42
+ "grunt-eslint": "24.2.0",
43
43
  "jsdoc": "3.6.11",
44
44
  "st": "3.0.0",
45
45
  "tsd-jsdoc": "2.5.0"