imapflow 1.0.125 → 1.0.127

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.127 - 2023-04-10
4
+
5
+ - Use default Node.js TLS settings
6
+
3
7
  - 1.0.123 - 2023-03-22
4
8
 
5
9
  - Do not throw if server responds with `tag BYE`
package/README.md CHANGED
@@ -10,7 +10,7 @@ ImapFlow is a modern and easy-to-use IMAP client library for Node.js.
10
10
 
11
11
  The focus for ImapFlow is to provide easy to use API over IMAP. Using ImapFlow does not expect knowledge about specific IMAP details. A general understanding is good enough.
12
12
 
13
- IMAP extensions are handled in the background, so, for example, you can always request `labels` value from a {@link FetchQueryObject|fetch()} call, but if the IMAP server does not support `X-GM-EXT1` extension, then `labels` value is not included in the response.
13
+ IMAP extensions are handled in the background, so, for example, you can always request `labels` value from a {@link FetchQueryObject|fetch()} call, but if the IMAP server does not support `X-GM-EXT-1` extension, then `labels` value is not included in the response.
14
14
 
15
15
  ## Source
16
16
 
package/lib/imap-flow.js CHANGED
@@ -121,7 +121,7 @@ class ImapFlow extends EventEmitter {
121
121
  * @param {Boolean} [options.disableAutoIdle=false] if `true` then IDLE is not started automatically. Useful if you only need to perform specific tasks over the connection
122
122
  * @param {Object} [options.tls] Additional TLS options (see [Node.js TLS connect](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback) for all available options)
123
123
  * @param {Boolean} [options.tls.rejectUnauthorized=true] if `false` then client accepts self-signed and expired certificates from the server
124
- * @param {String} [options.tls.minVersion=TLSv1] To improvde security you might need to use something newer, eg *'TLSv1.2'*
124
+ * @param {String} [options.tls.minVersion=TLSv1.2] To improvde security you might need to use something newer, eg *'TLSv1.2'*
125
125
  * @param {Number} [options.tls.minDHSize=1024] Minimum size of the DH parameter in bits to accept a TLS connection
126
126
  * @param {Object} [options.logger] Custom logger instance with `debug(obj)`, `info(obj)`, `warn(obj)` and `error(obj)` methods. If not provided then ImapFlow logs to console using pino format
127
127
  * @param {Boolean} [options.logRaw=false] If true then log data read from and written to socket encoded in base64
@@ -782,9 +782,7 @@ class ImapFlow extends EventEmitter {
782
782
  {
783
783
  socket: this.socket,
784
784
  servername: this.servername,
785
- port: this.port,
786
- minVersion: 'TLSv1',
787
- minDHSize: 1024
785
+ port: this.port
788
786
  },
789
787
  this.options.tls || {}
790
788
  );
@@ -1213,9 +1211,7 @@ class ImapFlow extends EventEmitter {
1213
1211
  {
1214
1212
  host: this.host,
1215
1213
  servername: this.servername,
1216
- port: this.port,
1217
- minVersion: 'TLSv1',
1218
- minDHSize: 1024
1214
+ port: this.port
1219
1215
  },
1220
1216
  this.options.tls || {}
1221
1217
  );
@@ -2224,7 +2220,7 @@ class ImapFlow extends EventEmitter {
2224
2220
  *
2225
2221
  * @example
2226
2222
  * let mailbox = await client.mailboxOpen('INBOX');
2227
- * // fetch UID for all messages in a mailbox
2223
+ * // fetch UID for the last email in the selected mailbox
2228
2224
  * let lastMsg = await client.fetchOne('*', {uid: true})
2229
2225
  * console.log(lastMsg.uid);
2230
2226
  */
@@ -2555,7 +2551,7 @@ class ImapFlow extends EventEmitter {
2555
2551
  *
2556
2552
  * @example
2557
2553
  * let mailbox = await client.mailboxOpen('INBOX');
2558
- * // download body part nr '1.2' from latest message
2554
+ * // download body parts '2', and '3' from all messages in the selected mailbox
2559
2555
  * let response = await client.downloadMany('*', ['2', '3]);
2560
2556
  * process.stdout.write(response[2].content)
2561
2557
  * process.stdout.write(response[3].content)
@@ -39,9 +39,18 @@ let processDateField = (attributes, term, value) => {
39
39
  setOpt(attributes, term, date);
40
40
  };
41
41
 
42
+ let isUnicodeString = str => {
43
+ if (!str || typeof str !== 'string') {
44
+ return false;
45
+ }
46
+
47
+ return Buffer.byteLength(str) !== str.length;
48
+ };
49
+
42
50
  module.exports.searchCompiler = (connection, query) => {
43
51
  const attributes = [];
44
52
 
53
+ let hasUnicode = false;
45
54
  const mailbox = connection.mailbox;
46
55
 
47
56
  const walk = params => {
@@ -82,16 +91,24 @@ module.exports.searchCompiler = (connection, query) => {
82
91
  }
83
92
  break;
84
93
 
94
+ case 'LARGER':
95
+ case 'SMALLER':
96
+ case 'MODSEQ':
97
+ if (params[term]) {
98
+ setOpt(attributes, term, params[term]);
99
+ }
100
+ break;
101
+
85
102
  case 'BCC':
86
103
  case 'BODY':
87
104
  case 'CC':
88
105
  case 'FROM':
89
- case 'LARGER':
90
- case 'SMALLER':
91
106
  case 'SUBJECT':
92
107
  case 'TEXT':
93
108
  case 'TO':
94
- case 'MODSEQ':
109
+ if (isUnicodeString(params[term])) {
110
+ hasUnicode = true;
111
+ }
95
112
  if (params[term]) {
96
113
  setOpt(attributes, term, params[term]);
97
114
  }
@@ -110,6 +127,7 @@ module.exports.searchCompiler = (connection, query) => {
110
127
  setOpt(attributes, 'X-GM-MSGID', params[term]);
111
128
  }
112
129
  break;
130
+
113
131
  case 'THREADID':
114
132
  if (connection.capabilities.has('OBJECTID')) {
115
133
  setOpt(attributes, 'THREADID', params[term]);
@@ -117,9 +135,13 @@ module.exports.searchCompiler = (connection, query) => {
117
135
  setOpt(attributes, 'X-GM-THRID', params[term]);
118
136
  }
119
137
  break;
138
+
120
139
  case 'GMRAW':
121
140
  case 'GMAILRAW': // alias for GMRAW
122
141
  if (connection.capabilities.has('X-GM-EXT-1')) {
142
+ if (isUnicodeString(params[term])) {
143
+ hasUnicode = true;
144
+ }
123
145
  setOpt(attributes, 'X-GM-RAW', params[term]);
124
146
  } else {
125
147
  let error = new Error('Server does not support X-GM-EXT-1 extension required for X-GM-RAW');
@@ -159,6 +181,10 @@ module.exports.searchCompiler = (connection, query) => {
159
181
  return;
160
182
  }
161
183
 
184
+ if (isUnicodeString(value)) {
185
+ hasUnicode = true;
186
+ }
187
+
162
188
  setOpt(attributes, term, [header.toUpperCase().trim(), value]);
163
189
  });
164
190
  }
@@ -233,5 +259,10 @@ module.exports.searchCompiler = (connection, query) => {
233
259
 
234
260
  walk(query);
235
261
 
262
+ if (hasUnicode) {
263
+ attributes.unshift({ type: 'ATOM', value: 'UTF-8' });
264
+ attributes.unshift({ type: 'ATOM', value: 'CHARSET' });
265
+ }
266
+
236
267
  return attributes;
237
268
  };
package/lib/types.d.ts CHANGED
@@ -20,7 +20,7 @@ declare module "imapflow" {
20
20
  * @param [options.disableAutoIdle = false] - if `true` then IDLE is not started automatically. Useful if you only need to perform specific tasks over the connection
21
21
  * @param [options.tls] - Additional TLS options (see [Node.js TLS connect](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback) for all available options)
22
22
  * @param [options.tls.rejectUnauthorized = true] - if `false` then client accepts self-signed and expired certificates from the server
23
- * @param [options.tls.minVersion = TLSv1] - To improvde security you might need to use something newer, eg *'TLSv1.2'*
23
+ * @param [options.tls.minVersion = TLSv1.2] - To improvde security you might need to use something newer, eg *'TLSv1.2'*
24
24
  * @param [options.tls.minDHSize = 1024] - Minimum size of the DH parameter in bits to accept a TLS connection
25
25
  * @param [options.logger] - Custom logger instance with `debug(obj)`, `info(obj)`, `warn(obj)` and `error(obj)` methods. If not provided then ImapFlow logs to console using pino format
26
26
  * @param [options.logRaw = false] - If true then log data read from and written to socket encoded in base64
@@ -461,7 +461,7 @@ declare module "imapflow" {
461
461
  * Fetch a single message from currently opened mailbox
462
462
  * @example
463
463
  * let mailbox = await client.mailboxOpen('INBOX');
464
- * // fetch UID for all messages in a mailbox
464
+ * // fetch UID for the last email in the selected mailbox
465
465
  * let lastMsg = await client.fetchOne('*', {uid: true})
466
466
  * console.log(lastMsg.uid);
467
467
  * @param seq - Single UID or sequence number of the message to fetch for
@@ -499,7 +499,7 @@ declare module "imapflow" {
499
499
  * Fetch multiple attachments as Buffer values
500
500
  * @example
501
501
  * let mailbox = await client.mailboxOpen('INBOX');
502
- * // download body part nr '1.2' from latest message
502
+ * // download body parts '2', and '3' from all messages in the selected mailbox
503
503
  * let response = await client.downloadMany('*', ['2', '3]);
504
504
  * process.stdout.write(response[2].content)
505
505
  * process.stdout.write(response[3].content)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imapflow",
3
- "version": "1.0.125",
3
+ "version": "1.0.127",
4
4
  "description": "IMAP Client for Node",
5
5
  "main": "./lib/imap-flow.js",
6
6
  "scripts": {
@@ -30,10 +30,10 @@
30
30
  "@babel/eslint-parser": "7.21.3",
31
31
  "@babel/eslint-plugin": "7.19.1",
32
32
  "@babel/plugin-syntax-class-properties": "7.12.13",
33
- "@babel/preset-env": "7.20.2",
34
- "@types/node": "18.15.10",
33
+ "@babel/preset-env": "7.21.4",
34
+ "@types/node": "18.15.11",
35
35
  "braintree-jsdoc-template": "3.3.0",
36
- "eslint": "8.36.0",
36
+ "eslint": "8.38.0",
37
37
  "eslint-config-nodemailer": "1.2.0",
38
38
  "eslint-config-prettier": "8.8.0",
39
39
  "grunt": "1.6.1",