imapflow 1.0.153 → 1.0.154
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 +7 -0
- package/lib/commands/fetch.js +1 -1
- package/lib/imap-flow.js +74 -73
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.154](https://github.com/postalsys/imapflow/compare/v1.0.153...v1.0.154) (2024-03-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **FETCH:** throw on failing FETCH ([12f9a45](https://github.com/postalsys/imapflow/commit/12f9a45530c6f3a2f35ba2968819011eea9c32b2))
|
|
9
|
+
|
|
3
10
|
## [1.0.153](https://github.com/postalsys/imapflow/compare/v1.0.152...v1.0.153) (2024-02-29)
|
|
4
11
|
|
|
5
12
|
|
package/lib/commands/fetch.js
CHANGED
package/lib/imap-flow.js
CHANGED
|
@@ -2254,93 +2254,94 @@ class ImapFlow extends EventEmitter {
|
|
|
2254
2254
|
*/
|
|
2255
2255
|
async *fetch(range, query, options) {
|
|
2256
2256
|
options = options || {};
|
|
2257
|
-
try {
|
|
2258
|
-
if (!this.mailbox) {
|
|
2259
|
-
// no mailbox selected, nothing to do
|
|
2260
|
-
return;
|
|
2261
|
-
}
|
|
2262
2257
|
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2258
|
+
if (!this.mailbox) {
|
|
2259
|
+
// no mailbox selected, nothing to do
|
|
2260
|
+
return;
|
|
2261
|
+
}
|
|
2267
2262
|
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
new Promise((resolve, reject) => {
|
|
2273
|
-
let check = () => {
|
|
2274
|
-
if (rowQueue.length) {
|
|
2275
|
-
let entry = rowQueue.shift();
|
|
2276
|
-
if (entry.err) {
|
|
2277
|
-
return reject(entry.err);
|
|
2278
|
-
} else {
|
|
2279
|
-
return resolve(entry.value);
|
|
2280
|
-
}
|
|
2281
|
-
}
|
|
2282
|
-
if (finished) {
|
|
2283
|
-
return resolve(null);
|
|
2284
|
-
}
|
|
2263
|
+
range = await this.resolveRange(range, options);
|
|
2264
|
+
if (!range) {
|
|
2265
|
+
return false;
|
|
2266
|
+
}
|
|
2285
2267
|
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
check();
|
|
2290
|
-
};
|
|
2291
|
-
};
|
|
2292
|
-
check();
|
|
2293
|
-
});
|
|
2268
|
+
let finished = false;
|
|
2269
|
+
let push = false;
|
|
2270
|
+
let rowQueue = [];
|
|
2294
2271
|
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2272
|
+
let getNext = () =>
|
|
2273
|
+
new Promise((resolve, reject) => {
|
|
2274
|
+
let check = () => {
|
|
2275
|
+
if (rowQueue.length) {
|
|
2276
|
+
let entry = rowQueue.shift();
|
|
2277
|
+
if (entry.err) {
|
|
2278
|
+
return reject(entry.err);
|
|
2279
|
+
} else {
|
|
2280
|
+
return resolve(entry.value);
|
|
2304
2281
|
}
|
|
2305
|
-
});
|
|
2306
|
-
if (typeof push === 'function') {
|
|
2307
|
-
push();
|
|
2308
2282
|
}
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
finished = true;
|
|
2313
|
-
if (typeof push === 'function') {
|
|
2314
|
-
push();
|
|
2283
|
+
|
|
2284
|
+
if (finished) {
|
|
2285
|
+
return resolve(null);
|
|
2315
2286
|
}
|
|
2316
|
-
})
|
|
2317
|
-
.catch(err => {
|
|
2318
|
-
rowQueue.push({ err });
|
|
2319
|
-
});
|
|
2320
2287
|
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2288
|
+
// wait until data is pushed to queue and try again
|
|
2289
|
+
push = () => {
|
|
2290
|
+
push = false;
|
|
2291
|
+
check();
|
|
2292
|
+
};
|
|
2293
|
+
};
|
|
2294
|
+
check();
|
|
2295
|
+
});
|
|
2328
2296
|
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2297
|
+
this.run('FETCH', range, query, {
|
|
2298
|
+
uid: !!options.uid,
|
|
2299
|
+
binary: options.binary,
|
|
2300
|
+
changedSince: options.changedSince,
|
|
2301
|
+
onUntaggedFetch: (untagged, next) => {
|
|
2302
|
+
rowQueue.push({
|
|
2303
|
+
value: {
|
|
2304
|
+
response: untagged,
|
|
2305
|
+
next
|
|
2306
|
+
}
|
|
2307
|
+
});
|
|
2308
|
+
if (typeof push === 'function') {
|
|
2309
|
+
push();
|
|
2332
2310
|
}
|
|
2333
2311
|
}
|
|
2312
|
+
})
|
|
2313
|
+
.then(() => {
|
|
2314
|
+
finished = true;
|
|
2315
|
+
if (typeof push === 'function') {
|
|
2316
|
+
push();
|
|
2317
|
+
}
|
|
2318
|
+
})
|
|
2319
|
+
.catch(err => {
|
|
2320
|
+
rowQueue.push({ err });
|
|
2321
|
+
if (typeof push === 'function') {
|
|
2322
|
+
push();
|
|
2323
|
+
}
|
|
2324
|
+
});
|
|
2334
2325
|
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
error
|
|
2326
|
+
let res;
|
|
2327
|
+
while ((res = await getNext())) {
|
|
2328
|
+
if (this.isClosed || this.socket.destroyed) {
|
|
2329
|
+
let error = new Error('Connection closed');
|
|
2330
|
+
error.code = 'EConnectionClosed';
|
|
2339
2331
|
throw error;
|
|
2340
2332
|
}
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2333
|
+
|
|
2334
|
+
if (res !== null) {
|
|
2335
|
+
yield res.response;
|
|
2336
|
+
res.next();
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
if (!finished) {
|
|
2341
|
+
// FETCH never finished!
|
|
2342
|
+
let error = new Error('FETCH did not finish');
|
|
2343
|
+
error.code = 'ENotFinished';
|
|
2344
|
+
throw error;
|
|
2344
2345
|
}
|
|
2345
2346
|
}
|
|
2346
2347
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "imapflow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.154",
|
|
4
4
|
"description": "IMAP Client for Node",
|
|
5
5
|
"main": "./lib/imap-flow.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@babel/eslint-plugin": "7.23.5",
|
|
33
33
|
"@babel/plugin-syntax-class-properties": "7.12.13",
|
|
34
34
|
"@babel/preset-env": "7.24.0",
|
|
35
|
-
"@types/node": "20.11.
|
|
35
|
+
"@types/node": "20.11.24",
|
|
36
36
|
"eslint": "8.57.0",
|
|
37
37
|
"eslint-config-nodemailer": "1.2.0",
|
|
38
38
|
"eslint-config-prettier": "9.1.0",
|