imapflow 1.0.125 → 1.0.126
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/README.md +1 -1
- package/lib/imap-flow.js +2 -2
- package/lib/search-compiler.js +34 -3
- package/lib/types.d.ts +2 -2
- package/package.json +4 -4
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-
|
|
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
|
@@ -2224,7 +2224,7 @@ class ImapFlow extends EventEmitter {
|
|
|
2224
2224
|
*
|
|
2225
2225
|
* @example
|
|
2226
2226
|
* let mailbox = await client.mailboxOpen('INBOX');
|
|
2227
|
-
* // fetch UID for
|
|
2227
|
+
* // fetch UID for the last email in the selected mailbox
|
|
2228
2228
|
* let lastMsg = await client.fetchOne('*', {uid: true})
|
|
2229
2229
|
* console.log(lastMsg.uid);
|
|
2230
2230
|
*/
|
|
@@ -2555,7 +2555,7 @@ class ImapFlow extends EventEmitter {
|
|
|
2555
2555
|
*
|
|
2556
2556
|
* @example
|
|
2557
2557
|
* let mailbox = await client.mailboxOpen('INBOX');
|
|
2558
|
-
* // download body
|
|
2558
|
+
* // download body parts '2', and '3' from all messages in the selected mailbox
|
|
2559
2559
|
* let response = await client.downloadMany('*', ['2', '3]);
|
|
2560
2560
|
* process.stdout.write(response[2].content)
|
|
2561
2561
|
* process.stdout.write(response[3].content)
|
package/lib/search-compiler.js
CHANGED
|
@@ -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
|
-
|
|
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
|
@@ -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
|
|
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
|
|
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.
|
|
3
|
+
"version": "1.0.126",
|
|
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.
|
|
34
|
-
"@types/node": "18.15.
|
|
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
|
+
"eslint": "8.37.0",
|
|
37
37
|
"eslint-config-nodemailer": "1.2.0",
|
|
38
38
|
"eslint-config-prettier": "8.8.0",
|
|
39
39
|
"grunt": "1.6.1",
|