@mavogel/awscdk-rootmail 0.1.23 → 0.1.25

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.
Files changed (96) hide show
  1. package/.jsii +4 -4
  2. package/lib/rootmail.js +1 -1
  3. package/lib/ses-receive.js +1 -1
  4. package/node_modules/@zone-eu/mailsplit/README.md +1 -1
  5. package/node_modules/@zone-eu/mailsplit/lib/headers.js +10 -4
  6. package/node_modules/@zone-eu/mailsplit/lib/message-splitter.js +5 -4
  7. package/node_modules/@zone-eu/mailsplit/lib/mime-node.d.ts +4 -1
  8. package/node_modules/@zone-eu/mailsplit/lib/mime-node.js +23 -2
  9. package/node_modules/@zone-eu/mailsplit/lib/types.d.ts +3 -1
  10. package/node_modules/@zone-eu/mailsplit/package.json +4 -4
  11. package/node_modules/libbase64/CHANGELOG.md +20 -0
  12. package/node_modules/libbase64/README.md +40 -13
  13. package/node_modules/libbase64/dist/cjs/libbase64.d.ts +80 -0
  14. package/node_modules/libbase64/dist/cjs/libbase64.js +310 -0
  15. package/node_modules/libbase64/dist/cjs/package.json +3 -0
  16. package/node_modules/libbase64/dist/esm/libbase64.d.ts +80 -0
  17. package/node_modules/libbase64/{lib → dist/esm}/libbase64.js +74 -117
  18. package/node_modules/libbase64/dist/esm/package.json +3 -0
  19. package/node_modules/libbase64/package.json +59 -13
  20. package/node_modules/libmime/CHANGELOG.md +31 -0
  21. package/node_modules/libmime/README.md +55 -26
  22. package/node_modules/libmime/SECURITY.md +152 -0
  23. package/node_modules/libmime/dist/cjs/charset.d.ts +43 -0
  24. package/node_modules/libmime/dist/cjs/charset.js +135 -0
  25. package/node_modules/libmime/dist/cjs/charsets.d.ts +2 -0
  26. package/node_modules/libmime/dist/cjs/charsets.js +213 -0
  27. package/node_modules/libmime/dist/cjs/get-charset-name.d.ts +1 -0
  28. package/node_modules/libmime/dist/cjs/get-charset-name.js +224 -0
  29. package/node_modules/libmime/dist/cjs/libmime.d.ts +218 -0
  30. package/node_modules/libmime/dist/cjs/libmime.js +1013 -0
  31. package/node_modules/libmime/dist/cjs/mimetypes.d.ts +7 -0
  32. package/node_modules/libmime/dist/cjs/mimetypes.js +2072 -0
  33. package/node_modules/libmime/dist/cjs/package.json +3 -0
  34. package/node_modules/libmime/dist/cjs/types.d.ts +59 -0
  35. package/node_modules/libmime/dist/cjs/types.js +4 -0
  36. package/node_modules/libmime/dist/esm/charset.d.ts +43 -0
  37. package/node_modules/libmime/dist/esm/charset.js +125 -0
  38. package/node_modules/libmime/dist/esm/charsets.d.ts +2 -0
  39. package/node_modules/libmime/{lib → dist/esm}/charsets.js +3 -5
  40. package/node_modules/libmime/dist/esm/get-charset-name.d.ts +1 -0
  41. package/node_modules/libmime/{lib → dist/esm}/get-charset-name.js +1 -8
  42. package/node_modules/libmime/dist/esm/libmime.d.ts +219 -0
  43. package/node_modules/libmime/{lib → dist/esm}/libmime.js +256 -329
  44. package/node_modules/libmime/dist/esm/mimetypes.d.ts +7 -0
  45. package/node_modules/libmime/dist/esm/mimetypes.js +2068 -0
  46. package/node_modules/libmime/dist/esm/package.json +3 -0
  47. package/node_modules/libmime/dist/esm/types.d.ts +59 -0
  48. package/node_modules/libmime/dist/esm/types.js +3 -0
  49. package/node_modules/libmime/package.json +58 -15
  50. package/node_modules/libqp/CHANGELOG.md +18 -0
  51. package/node_modules/libqp/README.md +50 -19
  52. package/node_modules/libqp/dist/cjs/libqp.d.ts +74 -0
  53. package/node_modules/libqp/dist/cjs/libqp.js +378 -0
  54. package/node_modules/libqp/dist/cjs/package.json +3 -0
  55. package/node_modules/libqp/dist/esm/libqp.d.ts +74 -0
  56. package/node_modules/libqp/dist/esm/libqp.js +369 -0
  57. package/node_modules/libqp/dist/esm/package.json +3 -0
  58. package/node_modules/libqp/lib/libqp.js +4 -383
  59. package/node_modules/libqp/lib/package.json +3 -0
  60. package/node_modules/libqp/package.json +62 -6
  61. package/node_modules/mailparser/.release-please-manifest.json +1 -1
  62. package/node_modules/mailparser/CHANGELOG.md +42 -0
  63. package/node_modules/mailparser/package.json +5 -5
  64. package/node_modules/nodemailer/CHANGELOG.md +44 -0
  65. package/node_modules/nodemailer/dist/cjs/addressparser/index.js +695 -267
  66. package/node_modules/nodemailer/dist/cjs/mailer/mail-message.js +4 -1
  67. package/node_modules/nodemailer/dist/cjs/mime-funcs/index.js +8 -2
  68. package/node_modules/nodemailer/dist/cjs/mime-node/index.js +48 -16
  69. package/node_modules/nodemailer/dist/cjs/package-info.d.ts +1 -1
  70. package/node_modules/nodemailer/dist/cjs/package-info.js +1 -1
  71. package/node_modules/nodemailer/dist/cjs/shared/url.js +22 -5
  72. package/node_modules/nodemailer/dist/esm/addressparser/index.js +695 -267
  73. package/node_modules/nodemailer/dist/esm/mailer/mail-message.js +4 -1
  74. package/node_modules/nodemailer/dist/esm/mime-funcs/index.js +8 -2
  75. package/node_modules/nodemailer/dist/esm/mime-node/index.js +48 -16
  76. package/node_modules/nodemailer/dist/esm/package-info.d.ts +1 -1
  77. package/node_modules/nodemailer/dist/esm/package-info.js +1 -1
  78. package/node_modules/nodemailer/dist/esm/shared/url.js +22 -5
  79. package/node_modules/nodemailer/package.json +1 -1
  80. package/package.json +3 -3
  81. package/node_modules/libbase64/.eslintrc +0 -11
  82. package/node_modules/libbase64/.github/FUNDING.yml +0 -4
  83. package/node_modules/libbase64/.github/VULNERABILITY_REPORT.yml +0 -75
  84. package/node_modules/libbase64/.github/workflows/release.yaml +0 -39
  85. package/node_modules/libbase64/.github/workflows/test.yml +0 -21
  86. package/node_modules/libbase64/.ncurc.js +0 -13
  87. package/node_modules/libbase64/.prettierrc.js +0 -8
  88. package/node_modules/libmime/lib/charset.js +0 -131
  89. package/node_modules/libmime/lib/mimetypes.js +0 -2049
  90. package/node_modules/libqp/.eslintrc +0 -15
  91. package/node_modules/libqp/.github/FUNDING.yml +0 -4
  92. package/node_modules/libqp/.github/VULNERABILITY_REPORT.yml +0 -75
  93. package/node_modules/libqp/.github/workflows/release.yaml +0 -39
  94. package/node_modules/libqp/.github/workflows/test.yml +0 -21
  95. package/node_modules/libqp/.prettierrc.js +0 -8
  96. package/node_modules/libqp/test/libqp-test.js +0 -366
@@ -0,0 +1,378 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Decoder = exports.Encoder = void 0;
4
+ exports.encode = encode;
5
+ exports.decode = decode;
6
+ exports.wrap = wrap;
7
+ const node_stream_1 = require("node:stream");
8
+ // the shortest line wrap() can make progress with: a complete =XX sequence and the soft break
9
+ const MIN_LINE_LENGTH = 4;
10
+ // 1 for every byte value that is written as is: <TAB>, <LF>, <CR> and the printable ASCII
11
+ // range except "=", https://tools.ietf.org/html/rfc2045#section-6.7
12
+ const QP_LITERAL = new Uint8Array(256);
13
+ for (let i = 0; i < 256; i++) {
14
+ QP_LITERAL[i] = i === 0x09 || i === 0x0a || i === 0x0d || (i >= 0x20 && i <= 0x7e && i !== 0x3d) ? 1 : 0;
15
+ }
16
+ const HEX_DIGITS = Buffer.from('0123456789ABCDEF', 'latin1');
17
+ const isWhitespace = (c) => c === 0x20 || c === 0x09;
18
+ /**
19
+ * Encodes a Buffer into a Quoted-Printable encoded string
20
+ *
21
+ * @param buffer Buffer to convert, a string is encoded as UTF-8
22
+ * @returns Quoted-Printable encoded string
23
+ */
24
+ function encode(buffer) {
25
+ return encodeBytes(typeof buffer === 'string' ? Buffer.from(buffer, 'utf-8') : buffer);
26
+ }
27
+ /**
28
+ * Encodes bytes that may be followed by more input
29
+ *
30
+ * @param buffer Bytes to encode
31
+ * @param [next] The byte that follows the buffer, whitespace before it is kept literal unless it
32
+ * is a line break. Without it the buffer ends the input and its trailing whitespace is encoded
33
+ * @param [binary] Keep only CRLF pairs literal. A lone CR or LF is data, not a line break, and
34
+ * anything that rewrites line endings on the way would change it
35
+ * @param [previous] The byte before the buffer. Without it the buffer starts a line
36
+ * @returns Quoted-Printable encoded string
37
+ */
38
+ function encodeBytes(buffer, next, binary, previous) {
39
+ const len = buffer.length;
40
+ // every byte takes three characters at most
41
+ const output = Buffer.allocUnsafe(len * 3);
42
+ let pos = 0;
43
+ for (let i = 0; i < len; i++) {
44
+ const ord = buffer[i];
45
+ const preceding = i > 0 ? buffer[i - 1] : previous;
46
+ const following = i + 1 < len ? buffer[i + 1] : next;
47
+ // in binary data only a CR followed by LF, or an LF that follows CR, is a line break
48
+ const loneLineBreak = binary && (ord === 0x0d ? following !== 0x0a : ord === 0x0a && preceding !== 0x0d);
49
+ // if the char is in allowed range, then keep as is, unless it is a ws in the end of a line
50
+ // or a hyphen in the start of a line. A line starting with two hyphens reads as a MIME
51
+ // boundary delimiter, so a decoded body that gets encoded again could inject a part. A lone
52
+ // CR counts as a line break here, a relay may turn it into CRLF
53
+ if (QP_LITERAL[ord] &&
54
+ !loneLineBreak &&
55
+ !(isWhitespace(ord) && (following === undefined || following === 0x0a || following === 0x0d)) &&
56
+ !(ord === 0x2d && (preceding === undefined || preceding === 0x0a || preceding === 0x0d))) {
57
+ output[pos++] = ord;
58
+ continue;
59
+ }
60
+ output[pos++] = 0x3d; // =
61
+ output[pos++] = HEX_DIGITS[Math.floor(ord / 16)];
62
+ output[pos++] = HEX_DIGITS[ord % 16];
63
+ }
64
+ return output.toString('latin1', 0, pos);
65
+ }
66
+ /**
67
+ * Decodes a Quoted-Printable encoded string to a Buffer object
68
+ *
69
+ * @param str Quoted-Printable encoded string. A Buffer is read byte for byte, so raw 8-bit bytes
70
+ * in the input are copied to the output unchanged. A char of a string is copied as the low
71
+ * byte of its char code, so a string should only hold chars below 256 ('binary')
72
+ * @returns Decoded value
73
+ */
74
+ function decode(str) {
75
+ // 'binary' maps every byte to one char code 0-255. A UTF-8 read would collapse raw
76
+ // multi-byte chars into one byte below and turn raw latin1 bytes into U+FFFD
77
+ let input;
78
+ if (str instanceof Uint8Array) {
79
+ input = (Buffer.isBuffer(str) ? str : Buffer.from(str.buffer, str.byteOffset, str.byteLength)).toString('binary');
80
+ }
81
+ else {
82
+ input = (str || '').toString();
83
+ }
84
+ input = input
85
+ // remove invalid whitespace from the end of lines. The leading group keeps this linear,
86
+ // a plain /[\t ]+$/gm rescans the rest of a whitespace run from every position inside it,
87
+ // which is quadratic. The lookahead lists the line terminators multiline $ matches before
88
+ .replace(/(^|[^ \t])[ \t]+(?=[\n\r\u2028\u2029]|$)/g, '$1')
89
+ // remove soft line breaks
90
+ .replace(/[=](?:\r?\n|$)/g, '');
91
+ // every =XX escape decodes into one byte, so count them to size the output.
92
+ // Counted with a loop, a match() would build an array with a string for every escape
93
+ const len = input.length;
94
+ let encodedBytesCount = 0;
95
+ for (let i = input.indexOf('='); i >= 0 && i < len - 2; i = input.indexOf('=', i + 1)) {
96
+ if (hexValue(input.charCodeAt(i + 1)) >= 0 && hexValue(input.charCodeAt(i + 2)) >= 0) {
97
+ encodedBytesCount++;
98
+ i += 2;
99
+ }
100
+ }
101
+ const buffer = Buffer.alloc(len - encodedBytesCount * 2);
102
+ let bufferPos = 0;
103
+ for (let i = 0; i < len; i++) {
104
+ const code = input.charCodeAt(i);
105
+ if (code === 0x3d /* = */ && i < len - 2) {
106
+ const hi = hexValue(input.charCodeAt(i + 1));
107
+ const lo = hexValue(input.charCodeAt(i + 2));
108
+ if (hi >= 0 && lo >= 0) {
109
+ buffer[bufferPos++] = hi * 16 + lo;
110
+ i += 2;
111
+ continue;
112
+ }
113
+ }
114
+ buffer[bufferPos++] = code;
115
+ }
116
+ return buffer;
117
+ }
118
+ /**
119
+ * Helper function to read the value of a hex digit
120
+ *
121
+ * @param code Char code
122
+ * @returns 0-15, or -1 if the char is not a hex digit
123
+ */
124
+ function hexValue(code) {
125
+ if (code >= 0x30 && code <= 0x39) {
126
+ return code - 0x30; // 0-9
127
+ }
128
+ if (code >= 0x41 && code <= 0x46) {
129
+ return code - 0x41 + 10; // A-F
130
+ }
131
+ if (code >= 0x61 && code <= 0x66) {
132
+ return code - 0x61 + 10; // a-f
133
+ }
134
+ return -1;
135
+ }
136
+ /**
137
+ * Adds soft line breaks to a Quoted-Printable string
138
+ *
139
+ * @param str Quoted-Printable encoded string that might need line wrapping
140
+ * @param [lineLength=76] Maximum allowed length for a line, at least 4
141
+ * @returns Soft-wrapped Quoted-Printable encoded string
142
+ */
143
+ function wrap(str, lineLength) {
144
+ str = (str || '').toString();
145
+ // a line has to hold a complete =XX sequence plus the soft break, shorter lengths
146
+ // (or a negative one) would loop without consuming input
147
+ lineLength = Math.max(Number(lineLength) || 76, MIN_LINE_LENGTH);
148
+ if (str.length <= lineLength) {
149
+ return str;
150
+ }
151
+ // every line is wrapped on its own, a line break does not count towards the line length
152
+ const parts = str.split(/(\r?\n)/);
153
+ for (let i = 0; i < parts.length; i += 2) {
154
+ parts[i] = wrapLine(parts[i], lineLength);
155
+ }
156
+ return parts.join('');
157
+ }
158
+ /**
159
+ * Adds soft line breaks to one line of a Quoted-Printable string
160
+ *
161
+ * @param str Quoted-Printable encoded line, without line breaks
162
+ * @param lineLength Maximum allowed length for a line, at least MIN_LINE_LENGTH
163
+ * @returns Soft-wrapped line
164
+ */
165
+ function wrapLine(str, lineLength) {
166
+ const len = str.length;
167
+ const lineMargin = Math.floor(lineLength / 3);
168
+ let pos = 0;
169
+ let result = '';
170
+ // every pass either ends with the rest of the line or consumes input
171
+ for (;;) {
172
+ // a line started by a soft break must not begin with a hyphen either, see encodeBytes().
173
+ // The escape takes the place of the hyphen, as if the input held it
174
+ const escapeHyphen = pos > 0 && str.charCodeAt(pos) === 0x2d;
175
+ if (len - pos + (escapeHyphen ? 2 : 0) <= lineLength) {
176
+ // the rest fits on a line
177
+ result += escapeHyphen ? '=2D' + str.substr(pos + 1) : str.substr(pos);
178
+ break;
179
+ }
180
+ let line = escapeHyphen ? '=2D' + str.substr(pos + 1, lineLength - 3) : str.substr(pos, lineLength);
181
+ let match;
182
+ if ((match = line.substr(-lineMargin).match(/[ \t.,!?][^ \t.,!?]*$/))) {
183
+ // truncate to nearest space
184
+ line = line.substr(0, line.length - (match[0].length - 1));
185
+ }
186
+ else if (/[=][\da-f]{0,2}$/i.test(line)) {
187
+ // push an incomplete encoding sequence to the next line and ensure that utf-8
188
+ // sequences are not split
189
+ line = trimUtf8Sequence(line.replace(/[=][\da-f]?$/i, ''));
190
+ }
191
+ // make room for the soft break, without splitting an encoding sequence
192
+ if (line.length === lineLength) {
193
+ line = line.substr(0, line.length - (/[=][\da-f]{2}$/i.test(line) ? 3 : 1));
194
+ }
195
+ // the escape stands for one char of the input
196
+ pos += escapeHyphen ? line.length - 2 : line.length;
197
+ result += line + '=\r\n';
198
+ }
199
+ return result;
200
+ }
201
+ /**
202
+ * Cuts the escapes of a trailing UTF-8 sequence off a line, so that a soft line break does not
203
+ * split the sequence. A line that holds nothing but the sequence, after the escape of a hyphen
204
+ * that starts the line, is kept whole
205
+ *
206
+ * @param line Quoted-Printable encoded line that ends with an escape
207
+ * @returns The line without the escapes of its last multi-byte sequence
208
+ */
209
+ function trimUtf8Sequence(line) {
210
+ let end = line.length;
211
+ while (end >= 3 && line.charCodeAt(end - 3) === 0x3d /* = */) {
212
+ const hi = hexValue(line.charCodeAt(end - 2));
213
+ const lo = hexValue(line.charCodeAt(end - 1));
214
+ if (hi < 0 || lo < 0) {
215
+ break;
216
+ }
217
+ const code = hi * 16 + lo;
218
+ if (code < 0x80) {
219
+ break;
220
+ }
221
+ end -= 3;
222
+ if (code >= 0xc0) {
223
+ // the lead byte of the sequence
224
+ break;
225
+ }
226
+ }
227
+ return end > (line.startsWith('=2D') ? 3 : 0) ? line.substr(0, end) : line;
228
+ }
229
+ // Converts a chunk of a stream to bytes. A stream only hands over a string when its decodeStrings
230
+ // option is off, and then the encoding is the one the chunk was written with
231
+ const toBuffer = (chunk, encoding) => typeof chunk === 'string' ? Buffer.from(chunk, encoding) : chunk;
232
+ // Input is encoded and wrapped this many bytes at a time. wrap() works on strings, and a large
233
+ // chunk handed over at once, such as a whole Buffer attachment, would be held several times over
234
+ // as intermediate strings
235
+ const ENCODE_SLICE_SIZE = 64 * 1024;
236
+ /**
237
+ * Creates a transform stream for encoding data to Quoted-Printable encoding
238
+ */
239
+ class Encoder extends node_stream_1.Transform {
240
+ /**
241
+ * @param [options] Stream options
242
+ * @param [options.lineLength=76] Maximum length for lines, set to false to disable wrapping
243
+ * @param [options.binary=false] Encode every CR or LF that is not part of a CRLF pair
244
+ */
245
+ constructor(options) {
246
+ const opts = options || {};
247
+ super(opts);
248
+ this.options = opts;
249
+ if (this.options.lineLength !== false) {
250
+ this.options.lineLength = this.options.lineLength || 76;
251
+ }
252
+ this._curLine = '';
253
+ this._heldByte = undefined;
254
+ this._lastByte = undefined;
255
+ this.inputBytes = 0;
256
+ this.outputBytes = 0;
257
+ }
258
+ /** @internal */
259
+ _transform(chunk, encoding, done) {
260
+ let buf = toBuffer(chunk, encoding);
261
+ if (!buf || !buf.length) {
262
+ return done();
263
+ }
264
+ this.inputBytes += buf.length;
265
+ if (this._heldByte !== undefined) {
266
+ this._encodeSlices(Buffer.of(this._heldByte), buf[0]);
267
+ this._heldByte = undefined;
268
+ }
269
+ // Whitespace is encoded when it ends a line, and the end of the input counts as one, and a
270
+ // binary CR is a line break only when LF follows. Hold back such a last byte until it is
271
+ // known what follows it, so the output does not depend on where the input was split. Every
272
+ // other byte depends only on its neighbours, which _encodeSlices passes on
273
+ const last = buf[buf.length - 1];
274
+ if (isWhitespace(last) || (this.options.binary && last === 0x0d)) {
275
+ this._heldByte = last;
276
+ buf = buf.subarray(0, buf.length - 1);
277
+ }
278
+ // the bytes before a held back one only need to know it follows them
279
+ this._encodeSlices(buf, this._heldByte);
280
+ done();
281
+ }
282
+ /** @internal */
283
+ _flush(done) {
284
+ if (this._heldByte !== undefined) {
285
+ this._encodeSlices(Buffer.of(this._heldByte), undefined);
286
+ this._heldByte = undefined;
287
+ }
288
+ if (this._curLine) {
289
+ // it can end with a CR that was not wrapped yet
290
+ const qp = wrap(this._curLine, this.options.lineLength);
291
+ this.outputBytes += qp.length;
292
+ this.push(qp, 'ascii');
293
+ this._curLine = '';
294
+ }
295
+ done();
296
+ }
297
+ /**
298
+ * Encodes the input in slices of ENCODE_SLICE_SIZE bytes. Each slice is told the bytes around
299
+ * it, so a slice is encoded as if the input was not split
300
+ *
301
+ * @param buf Bytes to encode
302
+ * @param next The byte that follows buf, undefined when it is not known
303
+ * @internal
304
+ */
305
+ _encodeSlices(buf, next) {
306
+ for (let start = 0; start < buf.length; start += ENCODE_SLICE_SIZE) {
307
+ const end = Math.min(start + ENCODE_SLICE_SIZE, buf.length);
308
+ let qp = encodeBytes(buf.subarray(start, end), end < buf.length ? buf[end] : next, this.options.binary, this._lastByte);
309
+ this._lastByte = buf[end - 1];
310
+ if (this.options.lineLength) {
311
+ qp = this._curLine + qp;
312
+ // a CR at the end is a line break if LF follows, so it is wrapped once that is known
313
+ const cr = qp.endsWith('\r') ? '\r' : '';
314
+ qp = wrap(cr ? qp.slice(0, -1) : qp, this.options.lineLength);
315
+ // the last line is kept until it is known whether it needs a soft break
316
+ const lastLF = qp.lastIndexOf('\n');
317
+ this._curLine = qp.substring(lastLF + 1) + cr;
318
+ qp = qp.substring(0, lastLF + 1);
319
+ }
320
+ if (qp) {
321
+ this.outputBytes += qp.length;
322
+ this.push(qp, 'ascii');
323
+ }
324
+ }
325
+ }
326
+ }
327
+ exports.Encoder = Encoder;
328
+ /**
329
+ * Creates a transform stream for decoding Quoted-Printable encoded strings.
330
+ * The input is not actually processed as a stream but concatted and processed as a single input,
331
+ * so escapes and soft line breaks split across chunks decode the same as unsplit input
332
+ */
333
+ class Decoder extends node_stream_1.Transform {
334
+ /**
335
+ * @param [options] Stream options
336
+ */
337
+ constructor(options) {
338
+ const opts = options || {};
339
+ super(opts);
340
+ this.options = opts;
341
+ this.inputBytes = 0;
342
+ this.outputBytes = 0;
343
+ this.qpChunks = [];
344
+ }
345
+ /** @internal */
346
+ _transform(chunk, encoding, done) {
347
+ if (!chunk || !chunk.length) {
348
+ return done();
349
+ }
350
+ const buf = toBuffer(chunk, encoding);
351
+ // kept as a binary string, so joining the chunks is the only copy made before decoding
352
+ this.qpChunks.push(buf.toString('binary'));
353
+ this.inputBytes += buf.length;
354
+ done();
355
+ }
356
+ /** @internal */
357
+ _flush(done) {
358
+ if (this.inputBytes) {
359
+ const input = this.qpChunks.join('');
360
+ // the chunks are not needed anymore, release them before decoding allocates more
361
+ this.qpChunks = [];
362
+ const buf = decode(input);
363
+ this.outputBytes += buf.length;
364
+ this.push(buf);
365
+ }
366
+ done();
367
+ }
368
+ }
369
+ exports.Decoder = Decoder;
370
+ const libqp = {
371
+ encode,
372
+ decode,
373
+ wrap,
374
+ Encoder,
375
+ Decoder
376
+ };
377
+ exports.default = libqp;
378
+ Object.defineProperty(exports, 'default', { value: exports, enumerable: false, writable: true, configurable: true });
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,74 @@
1
+ import { Transform, type TransformOptions } from 'node:stream';
2
+ /**
3
+ * Encodes a Buffer into a Quoted-Printable encoded string
4
+ *
5
+ * @param buffer Buffer to convert, a string is encoded as UTF-8
6
+ * @returns Quoted-Printable encoded string
7
+ */
8
+ export declare function encode(buffer: Buffer | Uint8Array | string): string;
9
+ /**
10
+ * Decodes a Quoted-Printable encoded string to a Buffer object
11
+ *
12
+ * @param str Quoted-Printable encoded string. A Buffer is read byte for byte, so raw 8-bit bytes
13
+ * in the input are copied to the output unchanged. A char of a string is copied as the low
14
+ * byte of its char code, so a string should only hold chars below 256 ('binary')
15
+ * @returns Decoded value
16
+ */
17
+ export declare function decode(str: string | Buffer | Uint8Array): Buffer;
18
+ /**
19
+ * Adds soft line breaks to a Quoted-Printable string
20
+ *
21
+ * @param str Quoted-Printable encoded string that might need line wrapping
22
+ * @param [lineLength=76] Maximum allowed length for a line, at least 4
23
+ * @returns Soft-wrapped Quoted-Printable encoded string
24
+ */
25
+ export declare function wrap(str: string, lineLength?: number): string;
26
+ /**
27
+ * Options for the Quoted-Printable encoder stream, on top of the Transform stream options
28
+ */
29
+ export interface EncoderOptions extends TransformOptions {
30
+ /** Maximum length for lines (76 by default), set to false to disable wrapping */
31
+ lineLength?: number | false | undefined;
32
+ /** The input is binary data: a CR or LF that is not part of a CRLF pair is encoded */
33
+ binary?: boolean | undefined;
34
+ }
35
+ /**
36
+ * Options for the Quoted-Printable decoder stream, the Transform stream options
37
+ */
38
+ export type DecoderOptions = TransformOptions;
39
+ /**
40
+ * Creates a transform stream for encoding data to Quoted-Printable encoding
41
+ */
42
+ export declare class Encoder extends Transform {
43
+ options: EncoderOptions;
44
+ inputBytes: number;
45
+ outputBytes: number;
46
+ /**
47
+ * @param [options] Stream options
48
+ * @param [options.lineLength=76] Maximum length for lines, set to false to disable wrapping
49
+ * @param [options.binary=false] Encode every CR or LF that is not part of a CRLF pair
50
+ */
51
+ constructor(options?: EncoderOptions);
52
+ }
53
+ /**
54
+ * Creates a transform stream for decoding Quoted-Printable encoded strings.
55
+ * The input is not actually processed as a stream but concatted and processed as a single input,
56
+ * so escapes and soft line breaks split across chunks decode the same as unsplit input
57
+ */
58
+ export declare class Decoder extends Transform {
59
+ options: DecoderOptions;
60
+ inputBytes: number;
61
+ outputBytes: number;
62
+ /**
63
+ * @param [options] Stream options
64
+ */
65
+ constructor(options?: DecoderOptions);
66
+ }
67
+ declare const libqp: {
68
+ encode: typeof encode;
69
+ decode: typeof decode;
70
+ wrap: typeof wrap;
71
+ Encoder: typeof Encoder;
72
+ Decoder: typeof Decoder;
73
+ };
74
+ export default libqp;