imapflow 1.6.0 → 1.6.1
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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +7 -0
- package/lib/imap-flow.js +9 -1
- package/package.json +1 -1
- package/test/imap-flow-server-test.js +37 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.6.1](https://github.com/postalsys/imapflow/compare/v1.6.0...v1.6.1) (2026-07-27)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* keep the authentication result on a verifyOnly connection ([8665c64](https://github.com/postalsys/imapflow/commit/8665c642f16988c630a779fa796c5801532ffd4a))
|
|
9
|
+
|
|
3
10
|
## [1.6.0](https://github.com/postalsys/imapflow/compare/v1.5.0...v1.6.0) (2026-07-27)
|
|
4
11
|
|
|
5
12
|
|
package/lib/imap-flow.js
CHANGED
|
@@ -2292,12 +2292,20 @@ class ImapFlow extends EventEmitter {
|
|
|
2292
2292
|
// live server state. Cleared during the first close only, so repeated close() calls
|
|
2293
2293
|
// stay idempotent and cannot emit an event twice.
|
|
2294
2294
|
// `byeReason` is deliberately kept: it explains why the session ended.
|
|
2295
|
+
//
|
|
2296
|
+
// `authenticated` is kept for a verifyOnly connection, where it is the result rather
|
|
2297
|
+
// than live state. That mode authenticates, optionally lists, and logs out before
|
|
2298
|
+
// connect() resolves, so clearing it here left every caller reading `false` off a
|
|
2299
|
+
// connection that had just authenticated successfully - there is no later moment at
|
|
2300
|
+
// which the answer could be read, and such a client is never reconnected.
|
|
2295
2301
|
let closedMailbox = false;
|
|
2296
2302
|
if (!this.isClosed) {
|
|
2297
2303
|
closedMailbox = this.mailbox;
|
|
2298
2304
|
this.mailbox = false;
|
|
2299
2305
|
this.currentSelectCommand = false;
|
|
2300
|
-
this.
|
|
2306
|
+
if (!this.options.verifyOnly) {
|
|
2307
|
+
this.authenticated = false;
|
|
2308
|
+
}
|
|
2301
2309
|
this.preCheck = false;
|
|
2302
2310
|
}
|
|
2303
2311
|
|
package/package.json
CHANGED
|
@@ -615,6 +615,43 @@ module.exports['Server: verifyOnly connect lists mailboxes and logs out'] = asyn
|
|
|
615
615
|
test.done();
|
|
616
616
|
};
|
|
617
617
|
|
|
618
|
+
module.exports['Server: verifyOnly keeps the authentication result after logging out'] = async test => {
|
|
619
|
+
// The whole point of verifyOnly is to report whether the credentials work. The mode logs out
|
|
620
|
+
// before connect() resolves, so if close() cleared `authenticated` the caller would read false
|
|
621
|
+
// off a connection that had just authenticated, with no later moment to read the real answer.
|
|
622
|
+
let server = createServer();
|
|
623
|
+
let port = await listen(server);
|
|
624
|
+
let client = makeClient(port, { verifyOnly: true, includeMailboxes: true });
|
|
625
|
+
client.on('error', () => {});
|
|
626
|
+
|
|
627
|
+
await client.connect();
|
|
628
|
+
test.ok(client.authenticated, 'authentication result survives the verifyOnly logout');
|
|
629
|
+
|
|
630
|
+
client.close();
|
|
631
|
+
test.ok(client.authenticated, 'and survives an explicit close as well');
|
|
632
|
+
|
|
633
|
+
server.close();
|
|
634
|
+
test.done();
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
module.exports['Server: an ordinary session clears the authentication state on close'] = async test => {
|
|
638
|
+
// The counterpart: for a session that is not verifyOnly, `authenticated` describes live state
|
|
639
|
+
// and must not survive the connection, or reconnect logic reads it as still signed in.
|
|
640
|
+
let server = createServer();
|
|
641
|
+
let port = await listen(server);
|
|
642
|
+
let client = makeClient(port);
|
|
643
|
+
client.on('error', () => {});
|
|
644
|
+
|
|
645
|
+
await client.connect();
|
|
646
|
+
test.ok(client.authenticated, 'authenticated while the session is up');
|
|
647
|
+
|
|
648
|
+
client.close();
|
|
649
|
+
test.equal(client.authenticated, false, 'cleared once the session ends');
|
|
650
|
+
|
|
651
|
+
server.close();
|
|
652
|
+
test.done();
|
|
653
|
+
};
|
|
654
|
+
|
|
618
655
|
module.exports['Server: ID is re-requested after login when first response is sparse'] = async test => {
|
|
619
656
|
let idCalls = 0;
|
|
620
657
|
let server = createServer({
|