imapflow 1.7.8 → 2.0.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/CHANGELOG.md +27 -0
- package/README.md +8 -2
- package/dist/cjs/charsets.d.ts +1 -0
- package/dist/cjs/charsets.js +294 -0
- package/dist/cjs/commands/append.d.ts +22 -0
- package/dist/cjs/commands/append.js +151 -0
- package/dist/cjs/commands/authenticate.d.ts +24 -0
- package/dist/cjs/commands/authenticate.js +223 -0
- package/dist/cjs/commands/capability.d.ts +8 -0
- package/dist/cjs/commands/capability.js +32 -0
- package/dist/cjs/commands/close.d.ts +8 -0
- package/dist/cjs/commands/close.js +39 -0
- package/dist/cjs/commands/compress.d.ts +8 -0
- package/dist/cjs/commands/compress.js +56 -0
- package/dist/cjs/commands/copy.d.ts +13 -0
- package/dist/cjs/commands/copy.js +44 -0
- package/dist/cjs/commands/copyuid-parser.d.ts +11 -0
- package/dist/cjs/commands/copyuid-parser.js +32 -0
- package/dist/cjs/commands/create.d.ts +11 -0
- package/dist/cjs/commands/create.js +80 -0
- package/dist/cjs/commands/delete.d.ts +11 -0
- package/dist/cjs/commands/delete.js +40 -0
- package/dist/cjs/commands/enable.d.ts +9 -0
- package/dist/cjs/commands/enable.js +61 -0
- package/dist/cjs/commands/esearch-parser.d.ts +17 -0
- package/dist/cjs/commands/esearch-parser.js +91 -0
- package/dist/cjs/commands/expunge.d.ts +12 -0
- package/dist/cjs/commands/expunge.js +60 -0
- package/dist/cjs/commands/fetch.d.ts +30 -0
- package/dist/cjs/commands/fetch.js +241 -0
- package/dist/cjs/commands/id.d.ts +10 -0
- package/dist/cjs/commands/id.js +80 -0
- package/dist/cjs/commands/idle.d.ts +9 -0
- package/dist/cjs/commands/idle.js +347 -0
- package/dist/cjs/commands/list.d.ts +16 -0
- package/dist/cjs/commands/list.js +520 -0
- package/dist/cjs/commands/login.d.ts +11 -0
- package/dist/cjs/commands/login.js +42 -0
- package/dist/cjs/commands/logout.d.ts +8 -0
- package/dist/cjs/commands/logout.js +47 -0
- package/dist/cjs/commands/move.d.ts +13 -0
- package/dist/cjs/commands/move.js +57 -0
- package/dist/cjs/commands/namespace.d.ts +25 -0
- package/dist/cjs/commands/namespace.js +139 -0
- package/dist/cjs/commands/noop.d.ts +8 -0
- package/dist/cjs/commands/noop.js +22 -0
- package/dist/cjs/commands/quota.d.ts +10 -0
- package/dist/cjs/commands/quota.js +119 -0
- package/dist/cjs/commands/rename.d.ts +12 -0
- package/dist/cjs/commands/rename.js +48 -0
- package/dist/cjs/commands/search.d.ts +15 -0
- package/dist/cjs/commands/search.js +228 -0
- package/dist/cjs/commands/select.d.ts +25 -0
- package/dist/cjs/commands/select.js +250 -0
- package/dist/cjs/commands/starttls.d.ts +8 -0
- package/dist/cjs/commands/starttls.js +30 -0
- package/dist/cjs/commands/status-fields.d.ts +14 -0
- package/dist/cjs/commands/status-fields.js +61 -0
- package/dist/cjs/commands/status.d.ts +12 -0
- package/dist/cjs/commands/status.js +108 -0
- package/dist/cjs/commands/store.d.ts +19 -0
- package/dist/cjs/commands/store.js +93 -0
- package/dist/cjs/commands/subscribe.d.ts +9 -0
- package/dist/cjs/commands/subscribe.js +31 -0
- package/dist/cjs/commands/unsubscribe.d.ts +9 -0
- package/dist/cjs/commands/unsubscribe.js +31 -0
- package/dist/cjs/connection-deadline.d.ts +49 -0
- package/dist/cjs/connection-deadline.js +91 -0
- package/dist/cjs/errors.d.ts +83 -0
- package/dist/cjs/errors.js +13 -0
- package/dist/cjs/handler/imap-compiler.d.ts +24 -0
- package/dist/cjs/handler/imap-compiler.js +285 -0
- package/dist/cjs/handler/imap-formal-syntax.d.ts +28 -0
- package/dist/cjs/handler/imap-formal-syntax.js +121 -0
- package/dist/cjs/handler/imap-handler.d.ts +9 -0
- package/dist/cjs/handler/imap-handler.js +10 -0
- package/dist/cjs/handler/imap-parser.d.ts +16 -0
- package/dist/cjs/handler/imap-parser.js +90 -0
- package/dist/cjs/handler/imap-stream.d.ts +181 -0
- package/dist/cjs/handler/imap-stream.js +446 -0
- package/dist/cjs/handler/limits.d.ts +25 -0
- package/dist/cjs/handler/limits.js +51 -0
- package/dist/cjs/handler/parser-instance.d.ts +68 -0
- package/dist/cjs/handler/parser-instance.js +223 -0
- package/dist/cjs/handler/token-parser.d.ts +91 -0
- package/dist/cjs/handler/token-parser.js +673 -0
- package/dist/cjs/handler/types.d.ts +91 -0
- package/dist/cjs/handler/types.js +4 -0
- package/dist/cjs/imap-commands.d.ts +16 -0
- package/dist/cjs/imap-commands.js +74 -0
- package/dist/cjs/imap-flow.d.ts +676 -0
- package/dist/cjs/imap-flow.js +3956 -0
- package/dist/cjs/jp-decoder.d.ts +12 -0
- package/dist/cjs/jp-decoder.js +79 -0
- package/dist/cjs/limited-passthrough.d.ts +25 -0
- package/dist/cjs/limited-passthrough.js +54 -0
- package/dist/cjs/logger.d.ts +3 -0
- package/dist/cjs/logger.js +11 -0
- package/dist/cjs/package-info.d.ts +3 -0
- package/dist/cjs/package-info.js +7 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/proxy-connection.d.ts +33 -0
- package/dist/cjs/proxy-connection.js +392 -0
- package/dist/cjs/search-compiler.d.ts +34 -0
- package/dist/cjs/search-compiler.js +476 -0
- package/dist/cjs/special-use.d.ts +22 -0
- package/dist/cjs/special-use.js +911 -0
- package/dist/cjs/tools.d.ts +427 -0
- package/dist/cjs/tools.js +1496 -0
- package/{lib/imap-flow.d.ts → dist/cjs/types.d.ts} +387 -517
- package/dist/cjs/types.js +5 -0
- package/dist/esm/charsets.d.ts +1 -0
- package/{lib → dist/esm}/charsets.js +1 -6
- package/dist/esm/commands/append.d.ts +22 -0
- package/{lib → dist/esm}/commands/append.js +22 -52
- package/dist/esm/commands/authenticate.d.ts +24 -0
- package/{lib → dist/esm}/commands/authenticate.js +62 -87
- package/dist/esm/commands/capability.d.ts +8 -0
- package/{lib → dist/esm}/commands/capability.js +6 -9
- package/dist/esm/commands/close.d.ts +8 -0
- package/{lib → dist/esm}/commands/close.js +6 -10
- package/dist/esm/commands/compress.d.ts +8 -0
- package/{lib → dist/esm}/commands/compress.js +7 -11
- package/dist/esm/commands/copy.d.ts +13 -0
- package/{lib → dist/esm}/commands/copy.js +12 -20
- package/dist/esm/commands/copyuid-parser.d.ts +11 -0
- package/{lib → dist/esm}/commands/copyuid-parser.js +9 -15
- package/dist/esm/commands/create.d.ts +11 -0
- package/{lib → dist/esm}/commands/create.js +13 -27
- package/dist/esm/commands/delete.d.ts +11 -0
- package/{lib → dist/esm}/commands/delete.js +9 -14
- package/dist/esm/commands/enable.d.ts +9 -0
- package/{lib → dist/esm}/commands/enable.js +23 -30
- package/dist/esm/commands/esearch-parser.d.ts +17 -0
- package/dist/esm/commands/esearch-parser.js +88 -0
- package/dist/esm/commands/expunge.d.ts +12 -0
- package/{lib → dist/esm}/commands/expunge.js +17 -22
- package/dist/esm/commands/fetch.d.ts +30 -0
- package/{lib → dist/esm}/commands/fetch.js +32 -64
- package/dist/esm/commands/id.d.ts +10 -0
- package/{lib → dist/esm}/commands/id.js +17 -23
- package/dist/esm/commands/idle.d.ts +9 -0
- package/{lib → dist/esm}/commands/idle.js +47 -81
- package/dist/esm/commands/list.d.ts +16 -0
- package/{lib → dist/esm}/commands/list.js +60 -123
- package/dist/esm/commands/login.d.ts +11 -0
- package/{lib → dist/esm}/commands/login.js +10 -15
- package/dist/esm/commands/logout.d.ts +8 -0
- package/{lib → dist/esm}/commands/logout.js +9 -11
- package/dist/esm/commands/move.d.ts +13 -0
- package/{lib → dist/esm}/commands/move.js +13 -21
- package/dist/esm/commands/namespace.d.ts +25 -0
- package/{lib → dist/esm}/commands/namespace.js +34 -44
- package/dist/esm/commands/noop.d.ts +8 -0
- package/{lib → dist/esm}/commands/noop.js +6 -7
- package/dist/esm/commands/quota.d.ts +10 -0
- package/{lib → dist/esm}/commands/quota.js +18 -36
- package/dist/esm/commands/rename.d.ts +12 -0
- package/{lib → dist/esm}/commands/rename.js +10 -15
- package/dist/esm/commands/search.d.ts +15 -0
- package/{lib → dist/esm}/commands/search.js +36 -135
- package/dist/esm/commands/select.d.ts +25 -0
- package/{lib → dist/esm}/commands/select.js +33 -64
- package/dist/esm/commands/starttls.d.ts +8 -0
- package/{lib → dist/esm}/commands/starttls.js +6 -8
- package/dist/esm/commands/status-fields.d.ts +14 -0
- package/{lib → dist/esm}/commands/status-fields.js +5 -16
- package/dist/esm/commands/status.d.ts +12 -0
- package/{lib → dist/esm}/commands/status.js +18 -29
- package/dist/esm/commands/store.d.ts +19 -0
- package/{lib → dist/esm}/commands/store.js +24 -37
- package/dist/esm/commands/subscribe.d.ts +9 -0
- package/{lib → dist/esm}/commands/subscribe.js +8 -12
- package/dist/esm/commands/unsubscribe.d.ts +9 -0
- package/{lib → dist/esm}/commands/unsubscribe.js +8 -12
- package/dist/esm/connection-deadline.d.ts +49 -0
- package/{lib → dist/esm}/connection-deadline.js +14 -25
- package/dist/esm/errors.d.ts +83 -0
- package/dist/esm/errors.js +9 -0
- package/dist/esm/handler/imap-compiler.d.ts +24 -0
- package/{lib → dist/esm}/handler/imap-compiler.js +22 -80
- package/dist/esm/handler/imap-formal-syntax.d.ts +28 -0
- package/dist/esm/handler/imap-formal-syntax.js +117 -0
- package/dist/esm/handler/imap-handler.d.ts +9 -0
- package/dist/esm/handler/imap-handler.js +9 -0
- package/dist/esm/handler/imap-parser.d.ts +16 -0
- package/{lib → dist/esm}/handler/imap-parser.js +31 -44
- package/dist/esm/handler/imap-stream.d.ts +181 -0
- package/{lib → dist/esm}/handler/imap-stream.js +29 -121
- package/dist/esm/handler/limits.d.ts +25 -0
- package/{lib → dist/esm}/handler/limits.js +13 -22
- package/dist/esm/handler/parser-instance.d.ts +68 -0
- package/{lib → dist/esm}/handler/parser-instance.js +19 -47
- package/dist/esm/handler/token-parser.d.ts +91 -0
- package/{lib → dist/esm}/handler/token-parser.js +71 -155
- package/dist/esm/handler/types.d.ts +91 -0
- package/dist/esm/handler/types.js +3 -0
- package/dist/esm/imap-commands.d.ts +16 -0
- package/dist/esm/imap-commands.js +67 -0
- package/dist/esm/imap-flow.d.ts +676 -0
- package/{lib → dist/esm}/imap-flow.js +769 -1790
- package/dist/esm/jp-decoder.d.ts +12 -0
- package/{lib → dist/esm}/jp-decoder.js +6 -21
- package/dist/esm/limited-passthrough.d.ts +25 -0
- package/{lib → dist/esm}/limited-passthrough.js +7 -20
- package/dist/esm/logger.d.ts +3 -0
- package/dist/esm/logger.js +4 -0
- package/dist/esm/package-info.d.ts +3 -0
- package/dist/esm/package-info.js +4 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/proxy-connection.d.ts +33 -0
- package/{lib → dist/esm}/proxy-connection.js +56 -127
- package/dist/esm/search-compiler.d.ts +34 -0
- package/{lib → dist/esm}/search-compiler.js +54 -110
- package/dist/esm/special-use.d.ts +22 -0
- package/dist/esm/special-use.js +907 -0
- package/dist/esm/tools.d.ts +427 -0
- package/dist/esm/tools.js +1446 -0
- package/dist/esm/types.d.ts +828 -0
- package/dist/esm/types.js +4 -0
- package/package.json +60 -20
- package/.gitattributes +0 -1
- package/.github/CODE_OF_CONDUCT.md +0 -76
- package/.github/FUNDING.yml +0 -4
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -40
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -19
- package/.github/contributing.md +0 -17
- package/.github/workflows/release.yaml +0 -36
- package/.github/workflows/stale.yml +0 -29
- package/.github/workflows/test.yml +0 -51
- package/.ncurc.js +0 -4
- package/.prettierignore +0 -4
- package/.prettierrc.js +0 -8
- package/.release-please-manifest.json +0 -3
- package/CLAUDE.md +0 -104
- package/Gruntfile.js +0 -23
- package/eslint.config.js +0 -45
- package/lib/handler/imap-formal-syntax.js +0 -189
- package/lib/handler/imap-handler.js +0 -17
- package/lib/imap-commands.js +0 -45
- package/lib/logger.js +0 -5
- package/lib/special-use.js +0 -923
- package/lib/tools.js +0 -1612
- package/release-please-config.json +0 -10
- package/test/authentication-test.js +0 -101
- package/test/auto-idle-test.js +0 -470
- package/test/bodystructure-test.js +0 -899
- package/test/charsets-test.js +0 -161
- package/test/commands-branches-test.js +0 -1095
- package/test/commands-integration-test.js +0 -11124
- package/test/commands-test.js +0 -73
- package/test/connection-edge-cases-test.js +0 -1828
- package/test/connection-test.js +0 -162
- package/test/copyuid-parser-test.js +0 -173
- package/test/fetch-generator-test.js +0 -218
- package/test/fixtures/fake-timers.js +0 -115
- package/test/fixtures/serialized-mimetorture.js +0 -2738
- package/test/fixtures/test-client.js +0 -101
- package/test/fixtures/test-tls.js +0 -8
- package/test/handler-branches-test.js +0 -310
- package/test/idle-polling-test.js +0 -518
- package/test/imap-compiler-test.js +0 -809
- package/test/imap-flow-compress-test.js +0 -166
- package/test/imap-flow-coverage-test.js +0 -612
- package/test/imap-flow-fetch-download-test.js +0 -909
- package/test/imap-flow-internals-test.js +0 -725
- package/test/imap-flow-methods-test.js +0 -889
- package/test/imap-flow-proxy-paths-test.js +0 -366
- package/test/imap-flow-secure-test.js +0 -573
- package/test/imap-flow-server-test.js +0 -1474
- package/test/imap-formal-syntax-test.js +0 -293
- package/test/imap-parser-test.js +0 -1474
- package/test/imap-stream-edge-cases-test.js +0 -666
- package/test/imap-stream-test.js +0 -177
- package/test/imapflow-test.js +0 -258
- package/test/integration/README.md +0 -52
- package/test/integration/dovecot-test.conf +0 -27
- package/test/integration/rev2-live-test.js +0 -431
- package/test/integration/run-rev2-tests.sh +0 -75
- package/test/integration-test.js +0 -83
- package/test/jp-decoder-test.js +0 -304
- package/test/limited-passthrough-test.js +0 -299
- package/test/memory-cleanup-test.js +0 -144
- package/test/memory-leak-test.js +0 -667
- package/test/parser-limits-test.js +0 -292
- package/test/proxy-connection-test.js +0 -738
- package/test/reliability-improvements-test.js +0 -548
- package/test/search-compiler-test.js +0 -1300
- package/test/search-test.js +0 -329
- package/test/special-use-test.js +0 -418
- package/test/starttls-injection-test.js +0 -181
- package/test/tag-correlation-test.js +0 -333
- package/test/timer-policy-test.js +0 -227
- package/test/token-parser-test.js +0 -456
- package/test/tools-test.js +0 -2013
- package/test/unhandled-rejection-test.js +0 -661
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// End-to-end test of the DEFLATE compression path (RFC 4978). The mock server
|
|
4
|
-
// negotiates COMPRESS and then speaks raw-deflate in both directions, mirroring
|
|
5
|
-
// the client's inflate/deflate pipeline. This covers ImapFlow.compress() and the
|
|
6
|
-
// compression-stream cleanup inside close().
|
|
7
|
-
|
|
8
|
-
const net = require('net');
|
|
9
|
-
const zlib = require('zlib');
|
|
10
|
-
const { ImapFlow } = require('../lib/imap-flow');
|
|
11
|
-
|
|
12
|
-
const CAPS = 'IMAP4rev1 ID ENABLE NAMESPACE COMPRESS=DEFLATE';
|
|
13
|
-
|
|
14
|
-
const listen = server => new Promise(resolve => server.listen(0, '127.0.0.1', () => resolve(server.address().port)));
|
|
15
|
-
|
|
16
|
-
// IMAP session line responder shared before and after compression.
|
|
17
|
-
const respond = (write, line) => {
|
|
18
|
-
let parts = line.split(' ');
|
|
19
|
-
let tag = parts[0];
|
|
20
|
-
let cmd = (parts[1] || '').toUpperCase();
|
|
21
|
-
switch (cmd) {
|
|
22
|
-
case 'CAPABILITY':
|
|
23
|
-
write(`* CAPABILITY ${CAPS}\r\n${tag} OK done\r\n`);
|
|
24
|
-
break;
|
|
25
|
-
case 'ID':
|
|
26
|
-
write(`* ID ("name" "mock" "version" "1")\r\n${tag} OK done\r\n`);
|
|
27
|
-
break;
|
|
28
|
-
case 'LOGIN':
|
|
29
|
-
write(`${tag} OK LOGIN done\r\n`);
|
|
30
|
-
break;
|
|
31
|
-
case 'NAMESPACE':
|
|
32
|
-
write(`* NAMESPACE (("" "/")) NIL NIL\r\n${tag} OK done\r\n`);
|
|
33
|
-
break;
|
|
34
|
-
case 'ENABLE':
|
|
35
|
-
write(`${tag} OK done\r\n`);
|
|
36
|
-
break;
|
|
37
|
-
case 'NOOP':
|
|
38
|
-
write(`${tag} OK NOOP done\r\n`);
|
|
39
|
-
break;
|
|
40
|
-
case 'LOGOUT':
|
|
41
|
-
write(`* BYE bye\r\n${tag} OK done\r\n`);
|
|
42
|
-
break;
|
|
43
|
-
default:
|
|
44
|
-
write(`${tag} BAD unknown ${cmd}\r\n`);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
module.exports['Compress: session negotiates DEFLATE and runs commands'] = async test => {
|
|
49
|
-
let server = net.createServer(socket => {
|
|
50
|
-
socket.on('error', () => {});
|
|
51
|
-
|
|
52
|
-
let compressed = false;
|
|
53
|
-
let deflate = null;
|
|
54
|
-
let inflate = null;
|
|
55
|
-
let buf = '';
|
|
56
|
-
|
|
57
|
-
// Plain writer (pre-compression)
|
|
58
|
-
let writePlain = str => socket.write(str);
|
|
59
|
-
// Compressed writer: deflate + flush so the client receives complete frames
|
|
60
|
-
let writeDeflate = str => {
|
|
61
|
-
deflate.write(Buffer.from(str, 'binary'));
|
|
62
|
-
deflate.flush();
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// function declarations (hoisted) because feed() and onLine() are mutually recursive
|
|
66
|
-
let lineBuf = '';
|
|
67
|
-
function onLine(line) {
|
|
68
|
-
let parts = line.split(' ');
|
|
69
|
-
let tag = parts[0];
|
|
70
|
-
let cmd = (parts[1] || '').toUpperCase();
|
|
71
|
-
if (cmd === 'COMPRESS') {
|
|
72
|
-
// Acknowledge, then switch both directions to raw deflate
|
|
73
|
-
writePlain(`${tag} OK Begin compression\r\n`);
|
|
74
|
-
compressed = true;
|
|
75
|
-
deflate = zlib.createDeflateRaw();
|
|
76
|
-
inflate = zlib.createInflateRaw();
|
|
77
|
-
deflate.pipe(socket);
|
|
78
|
-
inflate.on('data', d => feed(d.toString('binary')));
|
|
79
|
-
inflate.on('error', () => {});
|
|
80
|
-
deflate.on('error', () => {});
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
respond(compressed ? writeDeflate : writePlain, line);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function feed(chunk) {
|
|
87
|
-
lineBuf += chunk;
|
|
88
|
-
let idx;
|
|
89
|
-
while ((idx = lineBuf.indexOf('\r\n')) >= 0) {
|
|
90
|
-
let line = lineBuf.slice(0, idx);
|
|
91
|
-
lineBuf = lineBuf.slice(idx + 2);
|
|
92
|
-
onLine(line);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
socket.on('data', data => {
|
|
97
|
-
if (compressed) {
|
|
98
|
-
// After COMPRESS negotiation, all inbound bytes are deflated
|
|
99
|
-
inflate.write(data);
|
|
100
|
-
} else {
|
|
101
|
-
buf += data.toString('binary');
|
|
102
|
-
let idx;
|
|
103
|
-
while ((idx = buf.indexOf('\r\n')) >= 0) {
|
|
104
|
-
let line = buf.slice(0, idx);
|
|
105
|
-
buf = buf.slice(idx + 2);
|
|
106
|
-
// hand off any already-buffered bytes after COMPRESS to inflate
|
|
107
|
-
onLine(line);
|
|
108
|
-
if (compressed && buf.length) {
|
|
109
|
-
inflate.write(Buffer.from(buf, 'binary'));
|
|
110
|
-
buf = '';
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
socket.write(`* OK [CAPABILITY ${CAPS}] ready\r\n`);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
let port = await listen(server);
|
|
120
|
-
let client = new ImapFlow({
|
|
121
|
-
host: '127.0.0.1',
|
|
122
|
-
port,
|
|
123
|
-
secure: false,
|
|
124
|
-
disableAutoIdle: true,
|
|
125
|
-
disableCompression: false, // enable COMPRESS negotiation
|
|
126
|
-
logger: false,
|
|
127
|
-
auth: { user: 'test', pass: 'secret' }
|
|
128
|
-
});
|
|
129
|
-
client.on('error', () => {});
|
|
130
|
-
|
|
131
|
-
await client.connect();
|
|
132
|
-
test.ok(client.usable);
|
|
133
|
-
test.ok(client._deflate, 'deflate pipeline established');
|
|
134
|
-
test.ok(client._inflate, 'inflate pipeline established');
|
|
135
|
-
|
|
136
|
-
// Run a command through the compressed channel
|
|
137
|
-
await client.noop();
|
|
138
|
-
|
|
139
|
-
// Push a buffer larger than the deflate writable highWaterMark (64KB) straight
|
|
140
|
-
// through the compression pump so its buffer overflows and readNext waits for 'drain'.
|
|
141
|
-
client.state = client.states.AUTHENTICATED;
|
|
142
|
-
client.commandParts = [];
|
|
143
|
-
client.write(Buffer.alloc(128 * 1024, 0x61));
|
|
144
|
-
await new Promise(r => setTimeout(r, 50));
|
|
145
|
-
|
|
146
|
-
// Each stream owns and reports its own lifecycle: the compression PassThrough used to proxy
|
|
147
|
-
// the raw socket's `destroyed` getter, which made close() skip destroying it.
|
|
148
|
-
let rawSocket = client.socket;
|
|
149
|
-
let passThrough = client.writeSocket;
|
|
150
|
-
test.notEqual(passThrough, rawSocket, 'compression replaced the write socket with a PassThrough');
|
|
151
|
-
test.equal(passThrough.destroyed, false, 'the PassThrough reports its own state while alive');
|
|
152
|
-
|
|
153
|
-
await client.logout();
|
|
154
|
-
client.close();
|
|
155
|
-
// close() must tear down the compression streams
|
|
156
|
-
test.ok(!client._deflate, 'deflate cleaned up after close');
|
|
157
|
-
test.ok(!client._inflate, 'inflate cleaned up after close');
|
|
158
|
-
test.ok(passThrough.destroyed, 'the compression PassThrough was destroyed');
|
|
159
|
-
test.ok(rawSocket.destroyed, 'the raw socket was destroyed');
|
|
160
|
-
|
|
161
|
-
// Repeated close() stays idempotent
|
|
162
|
-
test.doesNotThrow(() => client.close());
|
|
163
|
-
|
|
164
|
-
server.close();
|
|
165
|
-
test.done();
|
|
166
|
-
};
|