@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.
- package/.jsii +4 -4
- package/lib/rootmail.js +1 -1
- package/lib/ses-receive.js +1 -1
- package/node_modules/@zone-eu/mailsplit/README.md +1 -1
- package/node_modules/@zone-eu/mailsplit/lib/headers.js +10 -4
- package/node_modules/@zone-eu/mailsplit/lib/message-splitter.js +5 -4
- package/node_modules/@zone-eu/mailsplit/lib/mime-node.d.ts +4 -1
- package/node_modules/@zone-eu/mailsplit/lib/mime-node.js +23 -2
- package/node_modules/@zone-eu/mailsplit/lib/types.d.ts +3 -1
- package/node_modules/@zone-eu/mailsplit/package.json +4 -4
- package/node_modules/libbase64/CHANGELOG.md +20 -0
- package/node_modules/libbase64/README.md +40 -13
- package/node_modules/libbase64/dist/cjs/libbase64.d.ts +80 -0
- package/node_modules/libbase64/dist/cjs/libbase64.js +310 -0
- package/node_modules/libbase64/dist/cjs/package.json +3 -0
- package/node_modules/libbase64/dist/esm/libbase64.d.ts +80 -0
- package/node_modules/libbase64/{lib → dist/esm}/libbase64.js +74 -117
- package/node_modules/libbase64/dist/esm/package.json +3 -0
- package/node_modules/libbase64/package.json +59 -13
- package/node_modules/libmime/CHANGELOG.md +31 -0
- package/node_modules/libmime/README.md +55 -26
- package/node_modules/libmime/SECURITY.md +152 -0
- package/node_modules/libmime/dist/cjs/charset.d.ts +43 -0
- package/node_modules/libmime/dist/cjs/charset.js +135 -0
- package/node_modules/libmime/dist/cjs/charsets.d.ts +2 -0
- package/node_modules/libmime/dist/cjs/charsets.js +213 -0
- package/node_modules/libmime/dist/cjs/get-charset-name.d.ts +1 -0
- package/node_modules/libmime/dist/cjs/get-charset-name.js +224 -0
- package/node_modules/libmime/dist/cjs/libmime.d.ts +218 -0
- package/node_modules/libmime/dist/cjs/libmime.js +1013 -0
- package/node_modules/libmime/dist/cjs/mimetypes.d.ts +7 -0
- package/node_modules/libmime/dist/cjs/mimetypes.js +2072 -0
- package/node_modules/libmime/dist/cjs/package.json +3 -0
- package/node_modules/libmime/dist/cjs/types.d.ts +59 -0
- package/node_modules/libmime/dist/cjs/types.js +4 -0
- package/node_modules/libmime/dist/esm/charset.d.ts +43 -0
- package/node_modules/libmime/dist/esm/charset.js +125 -0
- package/node_modules/libmime/dist/esm/charsets.d.ts +2 -0
- package/node_modules/libmime/{lib → dist/esm}/charsets.js +3 -5
- package/node_modules/libmime/dist/esm/get-charset-name.d.ts +1 -0
- package/node_modules/libmime/{lib → dist/esm}/get-charset-name.js +1 -8
- package/node_modules/libmime/dist/esm/libmime.d.ts +219 -0
- package/node_modules/libmime/{lib → dist/esm}/libmime.js +256 -329
- package/node_modules/libmime/dist/esm/mimetypes.d.ts +7 -0
- package/node_modules/libmime/dist/esm/mimetypes.js +2068 -0
- package/node_modules/libmime/dist/esm/package.json +3 -0
- package/node_modules/libmime/dist/esm/types.d.ts +59 -0
- package/node_modules/libmime/dist/esm/types.js +3 -0
- package/node_modules/libmime/package.json +58 -15
- package/node_modules/libqp/CHANGELOG.md +18 -0
- package/node_modules/libqp/README.md +50 -19
- package/node_modules/libqp/dist/cjs/libqp.d.ts +74 -0
- package/node_modules/libqp/dist/cjs/libqp.js +378 -0
- package/node_modules/libqp/dist/cjs/package.json +3 -0
- package/node_modules/libqp/dist/esm/libqp.d.ts +74 -0
- package/node_modules/libqp/dist/esm/libqp.js +369 -0
- package/node_modules/libqp/dist/esm/package.json +3 -0
- package/node_modules/libqp/lib/libqp.js +4 -383
- package/node_modules/libqp/lib/package.json +3 -0
- package/node_modules/libqp/package.json +62 -6
- package/node_modules/mailparser/.release-please-manifest.json +1 -1
- package/node_modules/mailparser/CHANGELOG.md +42 -0
- package/node_modules/mailparser/package.json +5 -5
- package/node_modules/nodemailer/CHANGELOG.md +44 -0
- package/node_modules/nodemailer/dist/cjs/addressparser/index.js +695 -267
- package/node_modules/nodemailer/dist/cjs/mailer/mail-message.js +4 -1
- package/node_modules/nodemailer/dist/cjs/mime-funcs/index.js +8 -2
- package/node_modules/nodemailer/dist/cjs/mime-node/index.js +48 -16
- package/node_modules/nodemailer/dist/cjs/package-info.d.ts +1 -1
- package/node_modules/nodemailer/dist/cjs/package-info.js +1 -1
- package/node_modules/nodemailer/dist/cjs/shared/url.js +22 -5
- package/node_modules/nodemailer/dist/esm/addressparser/index.js +695 -267
- package/node_modules/nodemailer/dist/esm/mailer/mail-message.js +4 -1
- package/node_modules/nodemailer/dist/esm/mime-funcs/index.js +8 -2
- package/node_modules/nodemailer/dist/esm/mime-node/index.js +48 -16
- package/node_modules/nodemailer/dist/esm/package-info.d.ts +1 -1
- package/node_modules/nodemailer/dist/esm/package-info.js +1 -1
- package/node_modules/nodemailer/dist/esm/shared/url.js +22 -5
- package/node_modules/nodemailer/package.json +1 -1
- package/package.json +3 -3
- package/node_modules/libbase64/.eslintrc +0 -11
- package/node_modules/libbase64/.github/FUNDING.yml +0 -4
- package/node_modules/libbase64/.github/VULNERABILITY_REPORT.yml +0 -75
- package/node_modules/libbase64/.github/workflows/release.yaml +0 -39
- package/node_modules/libbase64/.github/workflows/test.yml +0 -21
- package/node_modules/libbase64/.ncurc.js +0 -13
- package/node_modules/libbase64/.prettierrc.js +0 -8
- package/node_modules/libmime/lib/charset.js +0 -131
- package/node_modules/libmime/lib/mimetypes.js +0 -2049
- package/node_modules/libqp/.eslintrc +0 -15
- package/node_modules/libqp/.github/FUNDING.yml +0 -4
- package/node_modules/libqp/.github/VULNERABILITY_REPORT.yml +0 -75
- package/node_modules/libqp/.github/workflows/release.yaml +0 -39
- package/node_modules/libqp/.github/workflows/test.yml +0 -21
- package/node_modules/libqp/.prettierrc.js +0 -8
- package/node_modules/libqp/test/libqp-test.js +0 -366
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { Buffer } = require('node:buffer');
|
|
4
|
-
const stream = require('node:stream');
|
|
5
|
-
const Transform = stream.Transform;
|
|
6
|
-
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
import { Transform } from 'node:stream';
|
|
7
3
|
/**
|
|
8
4
|
* Encodes a Buffer into a base64 encoded string
|
|
9
5
|
*
|
|
10
|
-
* @param
|
|
11
|
-
* @returns
|
|
6
|
+
* @param buffer Buffer or unicode string to convert
|
|
7
|
+
* @returns base64 encoded string
|
|
12
8
|
*/
|
|
13
|
-
function encode(buffer) {
|
|
9
|
+
export function encode(buffer) {
|
|
14
10
|
if (typeof buffer === 'string') {
|
|
15
|
-
|
|
11
|
+
return Buffer.from(buffer, 'utf-8').toString('base64');
|
|
12
|
+
}
|
|
13
|
+
if (!Buffer.isBuffer(buffer)) {
|
|
14
|
+
// a plain Uint8Array has no base64 toString(), it would turn into a list of numbers
|
|
15
|
+
return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength).toString('base64');
|
|
16
16
|
}
|
|
17
|
-
|
|
18
17
|
return buffer.toString('base64');
|
|
19
18
|
}
|
|
20
|
-
|
|
21
19
|
/**
|
|
22
20
|
* Decodes a base64 encoded string to a Buffer object
|
|
23
21
|
*
|
|
24
|
-
* @param
|
|
25
|
-
* @returns
|
|
22
|
+
* @param str base64 encoded string
|
|
23
|
+
* @returns Decoded value
|
|
26
24
|
*/
|
|
27
|
-
function decode(str) {
|
|
25
|
+
export function decode(str) {
|
|
28
26
|
str = str || '';
|
|
29
|
-
|
|
30
27
|
// Buffer.from() stops decoding at the first padding char, so input made of several
|
|
31
28
|
// padded segments (eg. every line padded on its own) is decoded segment by segment.
|
|
32
29
|
// Segments are found with indexOf and written into one buffer: splitting the input and
|
|
33
30
|
// keeping a Buffer per segment cost memory per segment, tens of times the input size
|
|
34
31
|
// for a body that pads every line.
|
|
35
32
|
if (typeof str === 'string') {
|
|
33
|
+
// Buffer reads only the low byte of a character, "Ł" (U+0141) would be decoded as "A".
|
|
34
|
+
// Characters outside of latin1 are not base64 characters, they are skipped like the rest
|
|
35
|
+
if (/[^\u0000-\u00ff]/.test(str)) {
|
|
36
|
+
str = str.replace(/[^\u0000-\u00ff]+/g, '');
|
|
37
|
+
}
|
|
36
38
|
let padPos = str.indexOf('=');
|
|
37
39
|
if (padPos >= 0 && /[a-zA-Z0-9+/\-_]/.test(str.slice(padPos))) {
|
|
38
40
|
// a segment of n characters decodes to at most n * 3 / 4 bytes
|
|
@@ -53,27 +55,25 @@ function decode(str) {
|
|
|
53
55
|
return Buffer.from(output.subarray(0, length));
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
|
-
|
|
58
|
+
// a Buffer is copied as it is, the encoding argument only applies to strings
|
|
57
59
|
return Buffer.from(str, 'base64');
|
|
58
60
|
}
|
|
59
|
-
|
|
60
61
|
/**
|
|
61
62
|
* Turns a line length option into a whole number of characters, the default for anything unusable
|
|
62
63
|
*/
|
|
63
64
|
function normalizeLineLength(lineLength) {
|
|
64
|
-
|
|
65
|
-
return Number.isFinite(
|
|
65
|
+
let length = Math.floor(Number(lineLength));
|
|
66
|
+
return Number.isFinite(length) && length >= 1 ? length : 76;
|
|
66
67
|
}
|
|
67
|
-
|
|
68
68
|
/**
|
|
69
69
|
* Splits the bytes of `src` into lines of `lineLength` bytes, each followed by a line break. With
|
|
70
70
|
* `final` set the last line, which may be shorter, gets no line break; otherwise only complete lines
|
|
71
71
|
* are taken and the rest is left for the caller
|
|
72
72
|
*
|
|
73
|
-
* @param
|
|
74
|
-
* @param
|
|
75
|
-
* @param
|
|
76
|
-
* @returns
|
|
73
|
+
* @param src Bytes to wrap
|
|
74
|
+
* @param lineLength Line length
|
|
75
|
+
* @param final Whether `src` ends the output
|
|
76
|
+
* @returns The wrapped bytes and the number of trailing bytes not taken
|
|
77
77
|
*/
|
|
78
78
|
function wrapBuffer(src, lineLength, final) {
|
|
79
79
|
let lines = Math.ceil(src.length / lineLength);
|
|
@@ -81,7 +81,6 @@ function wrapBuffer(src, lineLength, final) {
|
|
|
81
81
|
// whether anything follows it
|
|
82
82
|
let complete = Math.max(lines - 1, 0);
|
|
83
83
|
let rest = src.length - complete * lineLength;
|
|
84
|
-
|
|
85
84
|
let output = Buffer.allocUnsafe(complete * (lineLength + 2) + (final ? rest : 0));
|
|
86
85
|
let to = 0;
|
|
87
86
|
for (let from = 0; from < complete * lineLength; from += lineLength) {
|
|
@@ -94,39 +93,31 @@ function wrapBuffer(src, lineLength, final) {
|
|
|
94
93
|
to += src.copy(output, to, complete * lineLength);
|
|
95
94
|
rest = 0;
|
|
96
95
|
}
|
|
97
|
-
|
|
98
96
|
if (to !== output.length) {
|
|
99
97
|
// never hand out bytes of the unfilled allocation
|
|
100
98
|
throw new Error('Unexpected wrapped length');
|
|
101
99
|
}
|
|
102
|
-
|
|
103
100
|
return { output, rest };
|
|
104
101
|
}
|
|
105
|
-
|
|
106
102
|
/**
|
|
107
103
|
* Adds soft line breaks to a base64 string
|
|
108
104
|
*
|
|
109
|
-
* @param
|
|
110
|
-
* @param
|
|
111
|
-
* @returns
|
|
105
|
+
* @param str base64 encoded string that might need line wrapping
|
|
106
|
+
* @param [lineLength=76] Maximum allowed length for a line
|
|
107
|
+
* @returns Soft-wrapped base64 encoded string
|
|
112
108
|
*/
|
|
113
|
-
function wrap(str, lineLength) {
|
|
109
|
+
export function wrap(str, lineLength) {
|
|
114
110
|
str = (str || '').toString();
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (str.length <= lineLength) {
|
|
111
|
+
let length = normalizeLineLength(lineLength);
|
|
112
|
+
if (str.length <= length) {
|
|
118
113
|
return str;
|
|
119
114
|
}
|
|
120
|
-
|
|
121
|
-
// eslint-disable-next-line no-control-regex
|
|
122
115
|
if (/[^\u0000-\u00ff]|[\r\n]/.test(str) || str.trim() !== str) {
|
|
123
116
|
// not a plain base64 string, keep the line based behaviour for whatever this is
|
|
124
|
-
return legacyWrap(str,
|
|
117
|
+
return legacyWrap(str, length);
|
|
125
118
|
}
|
|
126
|
-
|
|
127
|
-
return wrapBuffer(Buffer.from(str, 'latin1'), lineLength, true).output.toString('latin1');
|
|
119
|
+
return wrapBuffer(Buffer.from(str, 'latin1'), length, true).output.toString('latin1');
|
|
128
120
|
}
|
|
129
|
-
|
|
130
121
|
/**
|
|
131
122
|
* Line wrapping for input that is not a plain base64 string: line breaks already in the input end a
|
|
132
123
|
* line, and surrounding whitespace is trimmed
|
|
@@ -135,66 +126,49 @@ function legacyWrap(str, lineLength) {
|
|
|
135
126
|
let result = [];
|
|
136
127
|
let pos = 0;
|
|
137
128
|
let chunkLength = lineLength * 1024;
|
|
129
|
+
let wrapRegex = new RegExp('.{' + lineLength + '}', 'g');
|
|
138
130
|
while (pos < str.length) {
|
|
139
131
|
let wrappedLines = str
|
|
140
|
-
.
|
|
141
|
-
.replace(
|
|
132
|
+
.slice(pos, pos + chunkLength)
|
|
133
|
+
.replace(wrapRegex, '$&\r\n')
|
|
142
134
|
.trim();
|
|
143
135
|
result.push(wrappedLines);
|
|
144
136
|
pos += chunkLength;
|
|
145
137
|
}
|
|
146
|
-
|
|
147
138
|
return result.join('\r\n').trim();
|
|
148
139
|
}
|
|
149
|
-
|
|
150
140
|
/**
|
|
151
141
|
* Creates a transform stream for encoding data to base64 encoding
|
|
152
142
|
*
|
|
153
143
|
* The output is the same as `wrap(encode(input), lineLength)` no matter how the input is split into
|
|
154
144
|
* chunks: every line but the last one ends with a line break, the last one does not
|
|
155
|
-
*
|
|
156
|
-
* @constructor
|
|
157
|
-
* @param {Object} options Stream options
|
|
158
|
-
* @param {Number} [options.lineLength=76] Maximum lenght for lines, set to false to disable wrapping
|
|
159
|
-
* @param {Number} [options.skipStartBytes] Number of output bytes to drop from the start
|
|
160
|
-
* @param {Number} [options.limitOutputBytes] Maximum number of output bytes to emit
|
|
161
|
-
* @param {String} [options.startPadding] Characters to prepend to the first line before wrapping
|
|
162
145
|
*/
|
|
163
|
-
class Encoder extends Transform {
|
|
146
|
+
export class Encoder extends Transform {
|
|
164
147
|
constructor(options) {
|
|
165
148
|
super();
|
|
166
|
-
// init Transform
|
|
167
149
|
this.options = options || {};
|
|
168
|
-
|
|
169
150
|
if (this.options.lineLength !== false) {
|
|
170
151
|
this.options.lineLength = normalizeLineLength(this.options.lineLength);
|
|
171
152
|
}
|
|
172
|
-
|
|
173
153
|
this.skipStartBytes = Number(this.options.skipStartBytes) || 0;
|
|
174
|
-
//
|
|
154
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
175
155
|
this.limitOutputBytes = Number(this.options.limitOutputBytes || this.options.limitOutbutBytes) || 0;
|
|
176
|
-
|
|
177
|
-
// encoded characters of the line that is not complete yet. startPadding can be used together
|
|
178
|
-
// with skipStartBytes
|
|
156
|
+
// startPadding can be used together with skipStartBytes
|
|
179
157
|
this._curLine = this.options.startPadding || '';
|
|
180
|
-
// input bytes that do not make up a complete base64 group yet
|
|
181
158
|
this._remainingBytes = null;
|
|
182
|
-
|
|
183
159
|
this.inputBytes = 0;
|
|
184
160
|
this.outputBytes = 0;
|
|
185
161
|
}
|
|
186
|
-
|
|
162
|
+
/** @internal */
|
|
187
163
|
_writeChunk(chunk) {
|
|
188
164
|
if (this.skipStartBytes) {
|
|
189
165
|
if (chunk.length <= this.skipStartBytes) {
|
|
190
166
|
this.skipStartBytes -= chunk.length;
|
|
191
167
|
return;
|
|
192
168
|
}
|
|
193
|
-
|
|
194
169
|
chunk = chunk.subarray(this.skipStartBytes);
|
|
195
170
|
this.skipStartBytes = 0;
|
|
196
171
|
}
|
|
197
|
-
|
|
198
172
|
if (this.limitOutputBytes) {
|
|
199
173
|
if (this.outputBytes >= this.limitOutputBytes) {
|
|
200
174
|
// chunks already processed
|
|
@@ -205,124 +179,105 @@ class Encoder extends Transform {
|
|
|
205
179
|
chunk = chunk.subarray(0, this.limitOutputBytes - this.outputBytes);
|
|
206
180
|
}
|
|
207
181
|
}
|
|
208
|
-
|
|
209
182
|
this.outputBytes += chunk.length;
|
|
210
183
|
this.push(chunk);
|
|
211
184
|
}
|
|
212
|
-
|
|
213
185
|
/**
|
|
214
186
|
* Emits the encoded characters `b64` that follow the current line, keeping what can not be emitted
|
|
215
187
|
* yet as the new current line
|
|
188
|
+
*
|
|
189
|
+
* @internal
|
|
216
190
|
*/
|
|
217
191
|
_emit(b64, final) {
|
|
218
192
|
let src = Buffer.from(this._curLine + b64, 'latin1');
|
|
219
193
|
if (!src.length) {
|
|
220
194
|
return;
|
|
221
195
|
}
|
|
222
|
-
|
|
223
196
|
if (!this.options.lineLength) {
|
|
224
197
|
this._curLine = '';
|
|
225
198
|
return this._writeChunk(src);
|
|
226
199
|
}
|
|
227
|
-
|
|
228
200
|
let { output, rest } = wrapBuffer(src, this.options.lineLength, final);
|
|
229
201
|
this._curLine = rest ? src.toString('latin1', src.length - rest) : '';
|
|
230
202
|
if (output.length) {
|
|
231
203
|
this._writeChunk(output);
|
|
232
204
|
}
|
|
233
205
|
}
|
|
234
|
-
|
|
206
|
+
/** @internal */
|
|
235
207
|
_transform(chunk, encoding, done) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
if (!chunk || !chunk.length) {
|
|
208
|
+
let buf = encoding !== 'buffer' ? Buffer.from(chunk, encoding) : chunk;
|
|
209
|
+
if (!buf.length) {
|
|
241
210
|
return done();
|
|
242
211
|
}
|
|
243
|
-
|
|
244
|
-
this.inputBytes += chunk.length;
|
|
245
|
-
|
|
212
|
+
this.inputBytes += buf.length;
|
|
246
213
|
if (this._remainingBytes) {
|
|
247
|
-
|
|
214
|
+
buf = Buffer.concat([this._remainingBytes, buf], this._remainingBytes.length + buf.length);
|
|
248
215
|
this._remainingBytes = null;
|
|
249
216
|
}
|
|
250
|
-
|
|
251
|
-
let extra = chunk.length % 3;
|
|
217
|
+
let extra = buf.length % 3;
|
|
252
218
|
if (extra) {
|
|
253
|
-
this._remainingBytes =
|
|
254
|
-
|
|
219
|
+
this._remainingBytes = buf.subarray(buf.length - extra);
|
|
220
|
+
buf = buf.subarray(0, buf.length - extra);
|
|
255
221
|
}
|
|
256
|
-
|
|
257
|
-
this._emit(encode(chunk), false);
|
|
222
|
+
this._emit(encode(buf), false);
|
|
258
223
|
done();
|
|
259
224
|
}
|
|
260
|
-
|
|
225
|
+
/** @internal */
|
|
261
226
|
_flush(done) {
|
|
262
227
|
this._emit(this._remainingBytes ? encode(this._remainingBytes) : '', true);
|
|
228
|
+
this._remainingBytes = null;
|
|
263
229
|
done();
|
|
264
230
|
}
|
|
265
231
|
}
|
|
266
|
-
|
|
267
232
|
/**
|
|
268
233
|
* Creates a transform stream for decoding base64 encoded strings
|
|
269
|
-
*
|
|
270
|
-
* @constructor
|
|
271
|
-
* @param {Object} options Stream options
|
|
272
234
|
*/
|
|
273
|
-
class Decoder extends Transform {
|
|
235
|
+
export class Decoder extends Transform {
|
|
274
236
|
constructor(options) {
|
|
275
237
|
super();
|
|
276
|
-
// init Transform
|
|
277
238
|
this.options = options || {};
|
|
278
239
|
this._curLine = '';
|
|
279
|
-
|
|
280
240
|
this.inputBytes = 0;
|
|
281
241
|
this.outputBytes = 0;
|
|
282
242
|
}
|
|
283
|
-
|
|
284
|
-
_transform(chunk,
|
|
243
|
+
/** @internal */
|
|
244
|
+
_transform(chunk, _encoding, done) {
|
|
285
245
|
if (!chunk || !chunk.length) {
|
|
286
|
-
return
|
|
246
|
+
return done();
|
|
287
247
|
}
|
|
288
|
-
|
|
289
248
|
this.inputBytes += chunk.length;
|
|
290
|
-
|
|
291
|
-
|
|
249
|
+
// latin1 maps every byte to one character. 'ascii' would clear the high bit of a byte, turning
|
|
250
|
+
// stray 8-bit bytes into base64 characters instead of skipping them as decode() does
|
|
251
|
+
let b64 = this._curLine + chunk.toString('latin1');
|
|
292
252
|
this._curLine = '';
|
|
293
|
-
|
|
294
253
|
if (/[^a-zA-Z0-9+/=]/.test(b64)) {
|
|
295
254
|
b64 = b64.replace(/[^a-zA-Z0-9+/=]/g, '');
|
|
296
255
|
}
|
|
297
|
-
|
|
298
256
|
// everything up to the last padding char ends in complete segments, quartets are
|
|
299
257
|
// only counted from there on as a padding run restarts the quartet alignment
|
|
300
258
|
let padded = '';
|
|
301
259
|
let lastPad = b64.lastIndexOf('=');
|
|
302
260
|
if (lastPad >= 0) {
|
|
303
|
-
padded = b64.
|
|
304
|
-
b64 = b64.
|
|
261
|
+
padded = b64.slice(0, lastPad + 1);
|
|
262
|
+
b64 = b64.slice(lastPad + 1);
|
|
305
263
|
}
|
|
306
|
-
|
|
307
264
|
if (b64.length < 4) {
|
|
308
265
|
this._curLine = b64;
|
|
309
266
|
b64 = '';
|
|
310
|
-
} else if (b64.length % 4) {
|
|
311
|
-
this._curLine = b64.substr(-b64.length % 4);
|
|
312
|
-
b64 = b64.substr(0, b64.length - this._curLine.length);
|
|
313
267
|
}
|
|
314
|
-
|
|
268
|
+
else if (b64.length % 4) {
|
|
269
|
+
this._curLine = b64.slice(-(b64.length % 4));
|
|
270
|
+
b64 = b64.slice(0, b64.length - this._curLine.length);
|
|
271
|
+
}
|
|
315
272
|
b64 = padded + b64;
|
|
316
|
-
|
|
317
273
|
if (b64) {
|
|
318
274
|
let buf = decode(b64);
|
|
319
275
|
this.outputBytes += buf.length;
|
|
320
276
|
this.push(buf);
|
|
321
277
|
}
|
|
322
|
-
|
|
323
|
-
setImmediate(done);
|
|
278
|
+
done();
|
|
324
279
|
}
|
|
325
|
-
|
|
280
|
+
/** @internal */
|
|
326
281
|
_flush(done) {
|
|
327
282
|
if (this._curLine) {
|
|
328
283
|
let buf = decode(this._curLine);
|
|
@@ -330,15 +285,17 @@ class Decoder extends Transform {
|
|
|
330
285
|
this.push(buf);
|
|
331
286
|
this._curLine = '';
|
|
332
287
|
}
|
|
333
|
-
|
|
288
|
+
done();
|
|
334
289
|
}
|
|
335
290
|
}
|
|
336
|
-
|
|
337
|
-
//
|
|
338
|
-
|
|
291
|
+
// The default export is the same set of members as one object, for `import libbase64 from 'libbase64'`.
|
|
292
|
+
// In the CommonJS build `require('libbase64')` returns the exports object and its `.default` is that
|
|
293
|
+
// object itself, see scripts/build.js
|
|
294
|
+
const libbase64 = {
|
|
339
295
|
encode,
|
|
340
296
|
decode,
|
|
341
297
|
wrap,
|
|
342
298
|
Encoder,
|
|
343
299
|
Decoder
|
|
344
300
|
};
|
|
301
|
+
export default libbase64;
|
|
@@ -1,15 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libbase64",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Encode and decode base64 encoded strings",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/cjs/libbase64.js",
|
|
7
|
+
"types": "./dist/cjs/libbase64.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
"*": {
|
|
10
|
+
"lib/*": [
|
|
11
|
+
"dist/cjs/*.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": "./dist/esm/libbase64.js",
|
|
18
|
+
"require": "./dist/cjs/libbase64.js"
|
|
19
|
+
},
|
|
20
|
+
"./lib/*.js": {
|
|
21
|
+
"import": "./dist/esm/*.js",
|
|
22
|
+
"require": "./dist/cjs/*.js"
|
|
23
|
+
},
|
|
24
|
+
"./lib/*": {
|
|
25
|
+
"import": "./dist/esm/*.js",
|
|
26
|
+
"require": "./dist/cjs/*.js"
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"CHANGELOG.md",
|
|
33
|
+
"SECURITY.md"
|
|
34
|
+
],
|
|
6
35
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
36
|
+
"build": "node scripts/build.js",
|
|
37
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
38
|
+
"pretest": "npm run build",
|
|
39
|
+
"test": "node --import tsx --test --test-concurrency=1 $(find test -name \"*-test.ts\")",
|
|
40
|
+
"pretest:coverage": "npm run build",
|
|
41
|
+
"test:coverage": "c8 node --import tsx --test --test-concurrency=1 $(find test -name \"*-test.ts\")",
|
|
42
|
+
"format": "prettier --write \"**/*.{js,cjs,ts,json,md,yml,yaml}\"",
|
|
43
|
+
"format:check": "prettier --check \"**/*.{js,cjs,ts,json,md,yml,yaml}\"",
|
|
44
|
+
"lint": "npm run typecheck && eslint .",
|
|
45
|
+
"lint:fix": "eslint . --fix",
|
|
46
|
+
"prepare": "npm run build",
|
|
47
|
+
"update": "rm -rf node_modules package-lock.json && ncu -u && npm install",
|
|
48
|
+
"test:fuzz": "FC_NUM_RUNS=20000 node --import tsx --test test/libbase64-property-test.ts",
|
|
49
|
+
"pretest:bun": "npm run build",
|
|
50
|
+
"test:bun": "bun test --timeout 60000 $(find ./test -name \"*-test.ts\")"
|
|
9
51
|
},
|
|
10
52
|
"repository": {
|
|
11
53
|
"type": "git",
|
|
12
|
-
"url": "git://github.com/nodemailer/libbase64.git"
|
|
54
|
+
"url": "git+https://github.com/nodemailer/libbase64.git"
|
|
13
55
|
},
|
|
14
56
|
"keywords": [
|
|
15
57
|
"base64",
|
|
@@ -22,14 +64,18 @@
|
|
|
22
64
|
},
|
|
23
65
|
"homepage": "https://github.com/nodemailer/libbase64",
|
|
24
66
|
"devDependencies": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
67
|
+
"@types/node": "20.19.43",
|
|
68
|
+
"c8": "12.0.0",
|
|
69
|
+
"eslint": "10.13.0",
|
|
27
70
|
"eslint-config-prettier": "10.1.8",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
71
|
+
"fast-check": "4.10.2",
|
|
72
|
+
"globals": "17.13.0",
|
|
73
|
+
"prettier": "3.9.10",
|
|
74
|
+
"tsx": "4.23.15",
|
|
75
|
+
"typescript": "6.0.3",
|
|
76
|
+
"typescript-eslint": "8.71.2"
|
|
33
77
|
},
|
|
34
|
-
"
|
|
78
|
+
"engines": {
|
|
79
|
+
"node": ">=20.0.0"
|
|
80
|
+
}
|
|
35
81
|
}
|
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [5.5.1](https://github.com/nodemailer/libmime/compare/v5.5.0...v5.5.1) (2026-10-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **deps:** update libbase64 to 1.4.1 and libqp to 3.0.1 ([1d66699](https://github.com/nodemailer/libmime/commit/1d66699e80d953bd1f3279bd332684f4efeb4f71))
|
|
9
|
+
* encode parameter values that look like encoded words ([e85b3fb](https://github.com/nodemailer/libmime/commit/e85b3fbfde3cafc466f0eb93589df5f5c4de53fe))
|
|
10
|
+
|
|
11
|
+
## [5.5.0](https://github.com/nodemailer/libmime/compare/v5.4.9...v5.5.0) (2026-10-18)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* migrate to TypeScript with ES module and CommonJS builds ([a21884d](https://github.com/nodemailer/libmime/commit/a21884dfbcccc0a1a26300681275ea43fc93970c))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* base64 encode the chunks of a Buffer passed to encodeWord only once ([a21884d](https://github.com/nodemailer/libmime/commit/a21884dfbcccc0a1a26300681275ea43fc93970c))
|
|
22
|
+
* correct the pyc and ccxml entries of the mime type table and add common modern types ([a21884d](https://github.com/nodemailer/libmime/commit/a21884dfbcccc0a1a26300681275ea43fc93970c))
|
|
23
|
+
* drop control characters from header values and parameter names ([a21884d](https://github.com/nodemailer/libmime/commit/a21884dfbcccc0a1a26300681275ea43fc93970c))
|
|
24
|
+
* encode control characters and DEL in header parameter values ([a21884d](https://github.com/nodemailer/libmime/commit/a21884dfbcccc0a1a26300681275ea43fc93970c))
|
|
25
|
+
* encode unpaired surrogates in header parameters instead of leaving delimiters unencoded ([a21884d](https://github.com/nodemailer/libmime/commit/a21884dfbcccc0a1a26300681275ea43fc93970c))
|
|
26
|
+
* keep astral characters outside the emoji block whole in B encoded words ([a21884d](https://github.com/nodemailer/libmime/commit/a21884dfbcccc0a1a26300681275ea43fc93970c))
|
|
27
|
+
* mark every parameter continuation that holds percent escapes as encoded ([a21884d](https://github.com/nodemailer/libmime/commit/a21884dfbcccc0a1a26300681275ea43fc93970c))
|
|
28
|
+
* quote empty header parameter values ([a21884d](https://github.com/nodemailer/libmime/commit/a21884dfbcccc0a1a26300681275ea43fc93970c))
|
|
29
|
+
* refuse every iconv-lite alias of the utf-7, base64 and hex codecs as a charset ([a21884d](https://github.com/nodemailer/libmime/commit/a21884dfbcccc0a1a26300681275ea43fc93970c))
|
|
30
|
+
* remove the space stuffing of format=flowed continuation lines ([a21884d](https://github.com/nodemailer/libmime/commit/a21884dfbcccc0a1a26300681275ea43fc93970c))
|
|
31
|
+
* space-stuff the continuation lines encodeFlowed creates and trim spaces before hard line breaks ([a21884d](https://github.com/nodemailer/libmime/commit/a21884dfbcccc0a1a26300681275ea43fc93970c))
|
|
32
|
+
* stop splitMimeEncodedString from looping forever on malformed input ([a21884d](https://github.com/nodemailer/libmime/commit/a21884dfbcccc0a1a26300681275ea43fc93970c))
|
|
33
|
+
|
|
3
34
|
## [5.4.9](https://github.com/nodemailer/libmime/compare/v5.4.8...v5.4.9) (2026-10-16)
|
|
4
35
|
|
|
5
36
|
|