@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
|
@@ -0,0 +1,310 @@
|
|
|
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_buffer_1 = require("node:buffer");
|
|
8
|
+
const node_stream_1 = require("node:stream");
|
|
9
|
+
/**
|
|
10
|
+
* Encodes a Buffer into a base64 encoded string
|
|
11
|
+
*
|
|
12
|
+
* @param buffer Buffer or unicode string to convert
|
|
13
|
+
* @returns base64 encoded string
|
|
14
|
+
*/
|
|
15
|
+
function encode(buffer) {
|
|
16
|
+
if (typeof buffer === 'string') {
|
|
17
|
+
return node_buffer_1.Buffer.from(buffer, 'utf-8').toString('base64');
|
|
18
|
+
}
|
|
19
|
+
if (!node_buffer_1.Buffer.isBuffer(buffer)) {
|
|
20
|
+
// a plain Uint8Array has no base64 toString(), it would turn into a list of numbers
|
|
21
|
+
return node_buffer_1.Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength).toString('base64');
|
|
22
|
+
}
|
|
23
|
+
return buffer.toString('base64');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Decodes a base64 encoded string to a Buffer object
|
|
27
|
+
*
|
|
28
|
+
* @param str base64 encoded string
|
|
29
|
+
* @returns Decoded value
|
|
30
|
+
*/
|
|
31
|
+
function decode(str) {
|
|
32
|
+
str = str || '';
|
|
33
|
+
// Buffer.from() stops decoding at the first padding char, so input made of several
|
|
34
|
+
// padded segments (eg. every line padded on its own) is decoded segment by segment.
|
|
35
|
+
// Segments are found with indexOf and written into one buffer: splitting the input and
|
|
36
|
+
// keeping a Buffer per segment cost memory per segment, tens of times the input size
|
|
37
|
+
// for a body that pads every line.
|
|
38
|
+
if (typeof str === 'string') {
|
|
39
|
+
// Buffer reads only the low byte of a character, "Ł" (U+0141) would be decoded as "A".
|
|
40
|
+
// Characters outside of latin1 are not base64 characters, they are skipped like the rest
|
|
41
|
+
if (/[^\u0000-\u00ff]/.test(str)) {
|
|
42
|
+
str = str.replace(/[^\u0000-\u00ff]+/g, '');
|
|
43
|
+
}
|
|
44
|
+
let padPos = str.indexOf('=');
|
|
45
|
+
if (padPos >= 0 && /[a-zA-Z0-9+/\-_]/.test(str.slice(padPos))) {
|
|
46
|
+
// a segment of n characters decodes to at most n * 3 / 4 bytes
|
|
47
|
+
let output = node_buffer_1.Buffer.alloc(Math.floor((str.length * 3) / 4));
|
|
48
|
+
let length = 0;
|
|
49
|
+
let start = 0;
|
|
50
|
+
while (start <= str.length) {
|
|
51
|
+
let end = str.indexOf('=', start);
|
|
52
|
+
if (end < 0) {
|
|
53
|
+
end = str.length;
|
|
54
|
+
}
|
|
55
|
+
if (end > start) {
|
|
56
|
+
length += output.write(str.substring(start, end), length, 'base64');
|
|
57
|
+
}
|
|
58
|
+
start = end + 1;
|
|
59
|
+
}
|
|
60
|
+
// copied out so the result does not keep the oversized buffer alive
|
|
61
|
+
return node_buffer_1.Buffer.from(output.subarray(0, length));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// a Buffer is copied as it is, the encoding argument only applies to strings
|
|
65
|
+
return node_buffer_1.Buffer.from(str, 'base64');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Turns a line length option into a whole number of characters, the default for anything unusable
|
|
69
|
+
*/
|
|
70
|
+
function normalizeLineLength(lineLength) {
|
|
71
|
+
let length = Math.floor(Number(lineLength));
|
|
72
|
+
return Number.isFinite(length) && length >= 1 ? length : 76;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Splits the bytes of `src` into lines of `lineLength` bytes, each followed by a line break. With
|
|
76
|
+
* `final` set the last line, which may be shorter, gets no line break; otherwise only complete lines
|
|
77
|
+
* are taken and the rest is left for the caller
|
|
78
|
+
*
|
|
79
|
+
* @param src Bytes to wrap
|
|
80
|
+
* @param lineLength Line length
|
|
81
|
+
* @param final Whether `src` ends the output
|
|
82
|
+
* @returns The wrapped bytes and the number of trailing bytes not taken
|
|
83
|
+
*/
|
|
84
|
+
function wrapBuffer(src, lineLength, final) {
|
|
85
|
+
let lines = Math.ceil(src.length / lineLength);
|
|
86
|
+
// the last line waits for more data unless this is the end: whether it gets a line break depends on
|
|
87
|
+
// whether anything follows it
|
|
88
|
+
let complete = Math.max(lines - 1, 0);
|
|
89
|
+
let rest = src.length - complete * lineLength;
|
|
90
|
+
let output = node_buffer_1.Buffer.allocUnsafe(complete * (lineLength + 2) + (final ? rest : 0));
|
|
91
|
+
let to = 0;
|
|
92
|
+
for (let from = 0; from < complete * lineLength; from += lineLength) {
|
|
93
|
+
src.copy(output, to, from, from + lineLength);
|
|
94
|
+
to += lineLength;
|
|
95
|
+
output[to++] = 0x0d;
|
|
96
|
+
output[to++] = 0x0a;
|
|
97
|
+
}
|
|
98
|
+
if (final) {
|
|
99
|
+
to += src.copy(output, to, complete * lineLength);
|
|
100
|
+
rest = 0;
|
|
101
|
+
}
|
|
102
|
+
if (to !== output.length) {
|
|
103
|
+
// never hand out bytes of the unfilled allocation
|
|
104
|
+
throw new Error('Unexpected wrapped length');
|
|
105
|
+
}
|
|
106
|
+
return { output, rest };
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Adds soft line breaks to a base64 string
|
|
110
|
+
*
|
|
111
|
+
* @param str base64 encoded string that might need line wrapping
|
|
112
|
+
* @param [lineLength=76] Maximum allowed length for a line
|
|
113
|
+
* @returns Soft-wrapped base64 encoded string
|
|
114
|
+
*/
|
|
115
|
+
function wrap(str, lineLength) {
|
|
116
|
+
str = (str || '').toString();
|
|
117
|
+
let length = normalizeLineLength(lineLength);
|
|
118
|
+
if (str.length <= length) {
|
|
119
|
+
return str;
|
|
120
|
+
}
|
|
121
|
+
if (/[^\u0000-\u00ff]|[\r\n]/.test(str) || str.trim() !== str) {
|
|
122
|
+
// not a plain base64 string, keep the line based behaviour for whatever this is
|
|
123
|
+
return legacyWrap(str, length);
|
|
124
|
+
}
|
|
125
|
+
return wrapBuffer(node_buffer_1.Buffer.from(str, 'latin1'), length, true).output.toString('latin1');
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Line wrapping for input that is not a plain base64 string: line breaks already in the input end a
|
|
129
|
+
* line, and surrounding whitespace is trimmed
|
|
130
|
+
*/
|
|
131
|
+
function legacyWrap(str, lineLength) {
|
|
132
|
+
let result = [];
|
|
133
|
+
let pos = 0;
|
|
134
|
+
let chunkLength = lineLength * 1024;
|
|
135
|
+
let wrapRegex = new RegExp('.{' + lineLength + '}', 'g');
|
|
136
|
+
while (pos < str.length) {
|
|
137
|
+
let wrappedLines = str
|
|
138
|
+
.slice(pos, pos + chunkLength)
|
|
139
|
+
.replace(wrapRegex, '$&\r\n')
|
|
140
|
+
.trim();
|
|
141
|
+
result.push(wrappedLines);
|
|
142
|
+
pos += chunkLength;
|
|
143
|
+
}
|
|
144
|
+
return result.join('\r\n').trim();
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Creates a transform stream for encoding data to base64 encoding
|
|
148
|
+
*
|
|
149
|
+
* The output is the same as `wrap(encode(input), lineLength)` no matter how the input is split into
|
|
150
|
+
* chunks: every line but the last one ends with a line break, the last one does not
|
|
151
|
+
*/
|
|
152
|
+
class Encoder extends node_stream_1.Transform {
|
|
153
|
+
constructor(options) {
|
|
154
|
+
super();
|
|
155
|
+
this.options = options || {};
|
|
156
|
+
if (this.options.lineLength !== false) {
|
|
157
|
+
this.options.lineLength = normalizeLineLength(this.options.lineLength);
|
|
158
|
+
}
|
|
159
|
+
this.skipStartBytes = Number(this.options.skipStartBytes) || 0;
|
|
160
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
161
|
+
this.limitOutputBytes = Number(this.options.limitOutputBytes || this.options.limitOutbutBytes) || 0;
|
|
162
|
+
// startPadding can be used together with skipStartBytes
|
|
163
|
+
this._curLine = this.options.startPadding || '';
|
|
164
|
+
this._remainingBytes = null;
|
|
165
|
+
this.inputBytes = 0;
|
|
166
|
+
this.outputBytes = 0;
|
|
167
|
+
}
|
|
168
|
+
/** @internal */
|
|
169
|
+
_writeChunk(chunk) {
|
|
170
|
+
if (this.skipStartBytes) {
|
|
171
|
+
if (chunk.length <= this.skipStartBytes) {
|
|
172
|
+
this.skipStartBytes -= chunk.length;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
chunk = chunk.subarray(this.skipStartBytes);
|
|
176
|
+
this.skipStartBytes = 0;
|
|
177
|
+
}
|
|
178
|
+
if (this.limitOutputBytes) {
|
|
179
|
+
if (this.outputBytes >= this.limitOutputBytes) {
|
|
180
|
+
// chunks already processed
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (this.outputBytes + chunk.length > this.limitOutputBytes) {
|
|
184
|
+
// use partial chunk
|
|
185
|
+
chunk = chunk.subarray(0, this.limitOutputBytes - this.outputBytes);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
this.outputBytes += chunk.length;
|
|
189
|
+
this.push(chunk);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Emits the encoded characters `b64` that follow the current line, keeping what can not be emitted
|
|
193
|
+
* yet as the new current line
|
|
194
|
+
*
|
|
195
|
+
* @internal
|
|
196
|
+
*/
|
|
197
|
+
_emit(b64, final) {
|
|
198
|
+
let src = node_buffer_1.Buffer.from(this._curLine + b64, 'latin1');
|
|
199
|
+
if (!src.length) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (!this.options.lineLength) {
|
|
203
|
+
this._curLine = '';
|
|
204
|
+
return this._writeChunk(src);
|
|
205
|
+
}
|
|
206
|
+
let { output, rest } = wrapBuffer(src, this.options.lineLength, final);
|
|
207
|
+
this._curLine = rest ? src.toString('latin1', src.length - rest) : '';
|
|
208
|
+
if (output.length) {
|
|
209
|
+
this._writeChunk(output);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/** @internal */
|
|
213
|
+
_transform(chunk, encoding, done) {
|
|
214
|
+
let buf = encoding !== 'buffer' ? node_buffer_1.Buffer.from(chunk, encoding) : chunk;
|
|
215
|
+
if (!buf.length) {
|
|
216
|
+
return done();
|
|
217
|
+
}
|
|
218
|
+
this.inputBytes += buf.length;
|
|
219
|
+
if (this._remainingBytes) {
|
|
220
|
+
buf = node_buffer_1.Buffer.concat([this._remainingBytes, buf], this._remainingBytes.length + buf.length);
|
|
221
|
+
this._remainingBytes = null;
|
|
222
|
+
}
|
|
223
|
+
let extra = buf.length % 3;
|
|
224
|
+
if (extra) {
|
|
225
|
+
this._remainingBytes = buf.subarray(buf.length - extra);
|
|
226
|
+
buf = buf.subarray(0, buf.length - extra);
|
|
227
|
+
}
|
|
228
|
+
this._emit(encode(buf), false);
|
|
229
|
+
done();
|
|
230
|
+
}
|
|
231
|
+
/** @internal */
|
|
232
|
+
_flush(done) {
|
|
233
|
+
this._emit(this._remainingBytes ? encode(this._remainingBytes) : '', true);
|
|
234
|
+
this._remainingBytes = null;
|
|
235
|
+
done();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
exports.Encoder = Encoder;
|
|
239
|
+
/**
|
|
240
|
+
* Creates a transform stream for decoding base64 encoded strings
|
|
241
|
+
*/
|
|
242
|
+
class Decoder extends node_stream_1.Transform {
|
|
243
|
+
constructor(options) {
|
|
244
|
+
super();
|
|
245
|
+
this.options = options || {};
|
|
246
|
+
this._curLine = '';
|
|
247
|
+
this.inputBytes = 0;
|
|
248
|
+
this.outputBytes = 0;
|
|
249
|
+
}
|
|
250
|
+
/** @internal */
|
|
251
|
+
_transform(chunk, _encoding, done) {
|
|
252
|
+
if (!chunk || !chunk.length) {
|
|
253
|
+
return done();
|
|
254
|
+
}
|
|
255
|
+
this.inputBytes += chunk.length;
|
|
256
|
+
// latin1 maps every byte to one character. 'ascii' would clear the high bit of a byte, turning
|
|
257
|
+
// stray 8-bit bytes into base64 characters instead of skipping them as decode() does
|
|
258
|
+
let b64 = this._curLine + chunk.toString('latin1');
|
|
259
|
+
this._curLine = '';
|
|
260
|
+
if (/[^a-zA-Z0-9+/=]/.test(b64)) {
|
|
261
|
+
b64 = b64.replace(/[^a-zA-Z0-9+/=]/g, '');
|
|
262
|
+
}
|
|
263
|
+
// everything up to the last padding char ends in complete segments, quartets are
|
|
264
|
+
// only counted from there on as a padding run restarts the quartet alignment
|
|
265
|
+
let padded = '';
|
|
266
|
+
let lastPad = b64.lastIndexOf('=');
|
|
267
|
+
if (lastPad >= 0) {
|
|
268
|
+
padded = b64.slice(0, lastPad + 1);
|
|
269
|
+
b64 = b64.slice(lastPad + 1);
|
|
270
|
+
}
|
|
271
|
+
if (b64.length < 4) {
|
|
272
|
+
this._curLine = b64;
|
|
273
|
+
b64 = '';
|
|
274
|
+
}
|
|
275
|
+
else if (b64.length % 4) {
|
|
276
|
+
this._curLine = b64.slice(-(b64.length % 4));
|
|
277
|
+
b64 = b64.slice(0, b64.length - this._curLine.length);
|
|
278
|
+
}
|
|
279
|
+
b64 = padded + b64;
|
|
280
|
+
if (b64) {
|
|
281
|
+
let buf = decode(b64);
|
|
282
|
+
this.outputBytes += buf.length;
|
|
283
|
+
this.push(buf);
|
|
284
|
+
}
|
|
285
|
+
done();
|
|
286
|
+
}
|
|
287
|
+
/** @internal */
|
|
288
|
+
_flush(done) {
|
|
289
|
+
if (this._curLine) {
|
|
290
|
+
let buf = decode(this._curLine);
|
|
291
|
+
this.outputBytes += buf.length;
|
|
292
|
+
this.push(buf);
|
|
293
|
+
this._curLine = '';
|
|
294
|
+
}
|
|
295
|
+
done();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
exports.Decoder = Decoder;
|
|
299
|
+
// The default export is the same set of members as one object, for `import libbase64 from 'libbase64'`.
|
|
300
|
+
// In the CommonJS build `require('libbase64')` returns the exports object and its `.default` is that
|
|
301
|
+
// object itself, see scripts/build.js
|
|
302
|
+
const libbase64 = {
|
|
303
|
+
encode,
|
|
304
|
+
decode,
|
|
305
|
+
wrap,
|
|
306
|
+
Encoder,
|
|
307
|
+
Decoder
|
|
308
|
+
};
|
|
309
|
+
exports.default = libbase64;
|
|
310
|
+
Object.defineProperty(exports, 'default', { value: exports, enumerable: false, writable: true, configurable: true });
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
import { Transform } from 'node:stream';
|
|
3
|
+
/**
|
|
4
|
+
* Encodes a Buffer into a base64 encoded string
|
|
5
|
+
*
|
|
6
|
+
* @param buffer Buffer or unicode string to convert
|
|
7
|
+
* @returns base64 encoded string
|
|
8
|
+
*/
|
|
9
|
+
export declare function encode(buffer: Buffer | Uint8Array | string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Decodes a base64 encoded string to a Buffer object
|
|
12
|
+
*
|
|
13
|
+
* @param str base64 encoded string
|
|
14
|
+
* @returns Decoded value
|
|
15
|
+
*/
|
|
16
|
+
export declare function decode(str: string | Buffer | null | undefined): Buffer;
|
|
17
|
+
/**
|
|
18
|
+
* Adds soft line breaks to a base64 string
|
|
19
|
+
*
|
|
20
|
+
* @param str base64 encoded string that might need line wrapping
|
|
21
|
+
* @param [lineLength=76] Maximum allowed length for a line
|
|
22
|
+
* @returns Soft-wrapped base64 encoded string
|
|
23
|
+
*/
|
|
24
|
+
export declare function wrap(str: string | Buffer | null | undefined, lineLength?: number | string | null): string;
|
|
25
|
+
/**
|
|
26
|
+
* Options for the base64 encoder stream
|
|
27
|
+
*/
|
|
28
|
+
export interface EncoderOptions {
|
|
29
|
+
/** Maximum length for lines, 76 by default. Set to false to disable wrapping */
|
|
30
|
+
lineLength?: number | string | false | undefined;
|
|
31
|
+
/** Number of output bytes to drop from the start */
|
|
32
|
+
skipStartBytes?: number | undefined;
|
|
33
|
+
/** Maximum number of output bytes to emit */
|
|
34
|
+
limitOutputBytes?: number | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Misspelled name of `limitOutputBytes` that earlier versions read, still accepted
|
|
37
|
+
*
|
|
38
|
+
* @deprecated Use `limitOutputBytes`
|
|
39
|
+
*/
|
|
40
|
+
limitOutbutBytes?: number | undefined;
|
|
41
|
+
/** Characters to prepend to the first line before wrapping, usually used together with `skipStartBytes` */
|
|
42
|
+
startPadding?: string | undefined;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Options for the base64 decoder stream, none are used at the moment
|
|
46
|
+
*/
|
|
47
|
+
export interface DecoderOptions {
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Creates a transform stream for encoding data to base64 encoding
|
|
52
|
+
*
|
|
53
|
+
* The output is the same as `wrap(encode(input), lineLength)` no matter how the input is split into
|
|
54
|
+
* chunks: every line but the last one ends with a line break, the last one does not
|
|
55
|
+
*/
|
|
56
|
+
export declare class Encoder extends Transform {
|
|
57
|
+
options: EncoderOptions;
|
|
58
|
+
skipStartBytes: number;
|
|
59
|
+
limitOutputBytes: number;
|
|
60
|
+
inputBytes: number;
|
|
61
|
+
outputBytes: number;
|
|
62
|
+
constructor(options?: EncoderOptions);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Creates a transform stream for decoding base64 encoded strings
|
|
66
|
+
*/
|
|
67
|
+
export declare class Decoder extends Transform {
|
|
68
|
+
options: DecoderOptions;
|
|
69
|
+
inputBytes: number;
|
|
70
|
+
outputBytes: number;
|
|
71
|
+
constructor(options?: DecoderOptions);
|
|
72
|
+
}
|
|
73
|
+
declare const libbase64: {
|
|
74
|
+
encode: typeof encode;
|
|
75
|
+
decode: typeof decode;
|
|
76
|
+
wrap: typeof wrap;
|
|
77
|
+
Encoder: typeof Encoder;
|
|
78
|
+
Decoder: typeof Decoder;
|
|
79
|
+
};
|
|
80
|
+
export default libbase64;
|