@mavogel/awscdk-rootmail 0.1.24 → 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 +3 -3
  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 +2 -2
  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
package/.jsii CHANGED
@@ -14,7 +14,7 @@
14
14
  "@aws-sdk/client-ses": "^3.1152.0",
15
15
  "@aws-sdk/client-ssm": "^3.1152.0",
16
16
  "cdk-nag": "^3.0.1",
17
- "mailparser": "^3.9.40",
17
+ "mailparser": "^3.9.46",
18
18
  "uuid": "^14.0.3"
19
19
  },
20
20
  "dependencies": {
@@ -9620,6 +9620,6 @@
9620
9620
  "symbolId": "src/ses-receive:SESReceiveProps"
9621
9621
  }
9622
9622
  },
9623
- "version": "0.1.24",
9624
- "fingerprint": "VsXTNX+CbDEHj6QL4Wk23mv6Fvtf5IcmZ+EaZ822B68="
9623
+ "version": "0.1.25",
9624
+ "fingerprint": "V07+5iN9P3qTtRjecyrSIsgSV/99qpcRilC+wyKH8FQ="
9625
9625
  }
package/lib/rootmail.js CHANGED
@@ -11,7 +11,7 @@ const ses_receive_1 = require("./ses-receive");
11
11
  * Rootmail construct
12
12
  */
13
13
  class Rootmail extends constructs_1.Construct {
14
- static [JSII_RTTI_SYMBOL_1] = { fqn: "@mavogel/awscdk-rootmail.Rootmail", version: "0.1.24" };
14
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@mavogel/awscdk-rootmail.Rootmail", version: "0.1.25" };
15
15
  /**
16
16
  * The name parameter in SSM to store the domain name server.
17
17
  */
@@ -11,7 +11,7 @@ const ses_receipt_ruleset_activation_1 = require("./ses-receipt-ruleset-activati
11
11
  * SES Receive construct
12
12
  */
13
13
  class SESReceive extends constructs_1.Construct {
14
- static [JSII_RTTI_SYMBOL_1] = { fqn: "@mavogel/awscdk-rootmail.SESReceive", version: "0.1.24" };
14
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "@mavogel/awscdk-rootmail.SESReceive", version: "0.1.25" };
15
15
  constructor(scope, id, props) {
16
16
  super(scope, id);
17
17
  const filteredEmailSubjects = props.filteredEmailSubjects || [];
@@ -31,7 +31,7 @@ Where
31
31
 
32
32
  - **options** is an optional options object
33
33
  - **options.ignoreEmbedded** (boolean, defaults to false) if true then treat message/rfc822 node as normal leaf node and do not try to parse it
34
- - **options.maxHeadSize** (number, defaults to Infinity) limits message header size in bytes
34
+ - **options.maxHeadSize** (number, defaults to 1 MiB) limits the header size of a MIME node in bytes, every header line counting for at least 64 bytes
35
35
 
36
36
  #### Events
37
37
 
@@ -365,10 +365,16 @@ class Headers {
365
365
  return;
366
366
  }
367
367
 
368
- let rawLines = this.headers
369
- .toString('binary')
370
- .replace(/[\r\n]+$/, '')
371
- .split(/\r?\n/);
368
+ let raw = this.headers.toString('binary');
369
+
370
+ // Trailing line breaks go with an index scan. /[\r\n]+$/ retried a run of carriage
371
+ // returns from every position in it, quadratic on a header line made of them
372
+ let end = raw.length;
373
+ while (end > 0 && (raw.charCodeAt(end - 1) === 0x0a || raw.charCodeAt(end - 1) === 0x0d)) {
374
+ end--;
375
+ }
376
+
377
+ let rawLines = raw.slice(0, end).split(/\r?\n/);
372
378
 
373
379
  // Single forward pass. Splicing folded lines out of the source array in place was
374
380
  // quadratic on a header block with many continuation lines.
@@ -488,13 +488,14 @@ class MessageSplitter extends Transform {
488
488
  }
489
489
 
490
490
  /**
491
- * Checks the header bytes collected for the current node against maxHeadSize.
491
+ * Checks the header bytes collected for the current node against maxHeadSize. See
492
+ * MimeNode#headerCost.
492
493
  *
493
494
  * @param {number} [extra] Bytes that belong to the header block but are not stored yet.
494
495
  * @returns {(Error & {code?: string}) | null} Error object if the limit was exceeded.
495
496
  */
496
497
  checkHeadSize(extra) {
497
- if (this.node._headerlen + (extra || 0) > this.maxHeadSize) {
498
+ if (this.node.headerCost(extra) > this.maxHeadSize) {
498
499
  return maxLenError('Max header size for a MIME node exceeded');
499
500
  }
500
501
  return null;
@@ -630,12 +631,12 @@ class MessageSplitter extends Transform {
630
631
 
631
632
  switch (this.state) {
632
633
  case HEAD: {
633
- this.node.addHeaderChunk(line);
634
+ let endsBlock = this.node.addHeaderChunk(line);
634
635
  let headSizeError = this.checkHeadSize();
635
636
  if (headSizeError) {
636
637
  return next(headSizeError);
637
638
  }
638
- if (final || (line.length === 1 && line[0] === 0x0a) || (line.length === 2 && line[0] === 0x0d && line[1] === 0x0a)) {
639
+ if (final || endsBlock) {
639
640
  let currentNode = this.node;
640
641
 
641
642
  currentNode.parseHeaders();
@@ -23,6 +23,7 @@ declare class MimeNode implements MimeNodeShape {
23
23
 
24
24
  /** Length, in bytes, of the raw header block collected for this node. */
25
25
  _headerlen: number;
26
+ _headerCost: number;
26
27
 
27
28
  /** Multipart subtype such as `mixed` or `alternative`, or `false` for leaf nodes. */
28
29
  multipart: string | false;
@@ -88,7 +89,9 @@ declare class MimeNode implements MimeNodeShape {
88
89
  * @param line Raw header line bytes; falsy values are ignored.
89
90
  * @returns Nothing.
90
91
  */
91
- addHeaderChunk(line?: Buffer | false): void;
92
+ addHeaderChunk(line?: Buffer | false): boolean;
93
+ /** What the header lines count for against maxHeadSize, every line at least 64 bytes */
94
+ headerCost(extra?: number): number;
92
95
 
93
96
  /**
94
97
  * Parses collected header bytes and populates MIME metadata fields.
@@ -18,6 +18,10 @@ const pathlib = require('path');
18
18
 
19
19
  const Libmime = /** @type {any} */ (libmime.Libmime);
20
20
 
21
+ // The least a header line counts for against maxHeadSize. A parsed line costs a fixed
22
+ // overhead on top of its bytes, so 1 MiB of header is at most 16k lines
23
+ const HEADER_LINE_MIN_COST = 64;
24
+
21
25
  /**
22
26
  * Removes everything from the first `(` to the last `)` of each line, the same result as
23
27
  * `value.replace(/\(.*\)/g, '')`, but in linear time. The regex backtracks quadratically
@@ -117,6 +121,7 @@ class MimeNode {
117
121
  /** @type {Buffer[]} */
118
122
  this._headersLines = [];
119
123
  this._headerlen = 0;
124
+ this._headerCost = 0;
120
125
 
121
126
  /** @type {StructuredHeader | false} */
122
127
  this._parsedContentType = false;
@@ -171,14 +176,28 @@ class MimeNode {
171
176
 
172
177
  /**
173
178
  * @param {Buffer | false} [line]
174
- * @returns {void}
179
+ * @returns {boolean} Whether the line is the empty line that ends the header block.
175
180
  */
176
181
  addHeaderChunk(line) {
177
182
  if (!line) {
178
- return;
183
+ return false;
179
184
  }
180
185
  this._headersLines.push(line);
181
186
  this._headerlen += line.length;
187
+ let endsBlock = (line.length === 1 && line[0] === 0x0a) || (line.length === 2 && line[0] === 0x0d && line[1] === 0x0a);
188
+ // the empty line that ends the block costs its bytes, every other line at least the floor
189
+ this._headerCost += endsBlock ? line.length : Math.max(line.length, HEADER_LINE_MIN_COST);
190
+ return endsBlock;
191
+ }
192
+
193
+ /**
194
+ * What the header lines of this node count for against maxHeadSize, see HEADER_LINE_MIN_COST.
195
+ *
196
+ * @param {number} [extra] Bytes of a header line that is not stored yet.
197
+ * @returns {number} The cost in bytes.
198
+ */
199
+ headerCost(extra) {
200
+ return this._headerCost + (extra ? Math.max(extra, HEADER_LINE_MIN_COST) : 0);
182
201
  }
183
202
 
184
203
  /**
@@ -189,6 +208,8 @@ class MimeNode {
189
208
  return;
190
209
  }
191
210
  this.headers = new Headers(Buffer.concat(this._headersLines, this._headerlen), this.config);
211
+ // the views held the input chunks alive, the block lives on in the copy
212
+ this._headersLines = [];
192
213
  let headers = this.headers;
193
214
 
194
215
  let dispositionHeader = headers.getFirst('Content-Disposition');
@@ -83,6 +83,8 @@ export interface MimeNode {
83
83
 
84
84
  /** Length, in bytes, of the raw header block collected for this node. */
85
85
  _headerlen: number;
86
+ _headerCost: number;
87
+ headerCost(extra?: number): number;
86
88
 
87
89
  /** Multipart subtype such as `mixed` or `alternative`, or `false` for leaf nodes. */
88
90
  multipart: string | false;
@@ -140,7 +142,7 @@ export interface MimeNode {
140
142
  * @param line Raw header line bytes; falsy values are ignored.
141
143
  * @returns Nothing.
142
144
  */
143
- addHeaderChunk(line?: Buffer | false): void;
145
+ addHeaderChunk(line?: Buffer | false): boolean;
144
146
 
145
147
  /**
146
148
  * Parses collected header bytes and populates MIME metadata fields.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zone-eu/mailsplit",
3
- "version": "5.4.23",
3
+ "version": "5.4.26",
4
4
  "description": "Split email messages into an object stream",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -15,9 +15,9 @@
15
15
  "author": "Andris Reinman",
16
16
  "license": "(MIT OR EUPL-1.1+)",
17
17
  "dependencies": {
18
- "libbase64": "1.3.3",
19
- "libmime": "5.4.9",
20
- "libqp": "2.1.3"
18
+ "libbase64": "1.4.1",
19
+ "libmime": "5.5.1",
20
+ "libqp": "3.0.1"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/eslint": "9.6.1",
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.4.1](https://github.com/nodemailer/libbase64/compare/v1.4.0...v1.4.1) (2026-10-18)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * skip characters outside of latin1 in decode() ([a46d7d0](https://github.com/nodemailer/libbase64/commit/a46d7d05306d5cb8c569135d1d80f90baf0cb66b))
9
+
10
+ ## [1.4.0](https://github.com/nodemailer/libbase64/compare/v1.3.3...v1.4.0) (2026-10-18)
11
+
12
+
13
+ ### Features
14
+
15
+ * rewrite in TypeScript with ES module and CommonJS builds ([27f40e1](https://github.com/nodemailer/libbase64/commit/27f40e19e994f44460800fa195c04f1172abe013))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **decoder:** skip 8-bit input bytes instead of reading them as base64 characters ([27f40e1](https://github.com/nodemailer/libbase64/commit/27f40e19e994f44460800fa195c04f1172abe013))
21
+ * **encoder:** encode a plain Uint8Array instead of its comma separated byte values ([27f40e1](https://github.com/nodemailer/libbase64/commit/27f40e19e994f44460800fa195c04f1172abe013))
22
+
3
23
  ## [1.3.3](https://github.com/nodemailer/libbase64/compare/v1.3.2...v1.3.3) (2026-10-14)
4
24
 
5
25
 
@@ -1,6 +1,6 @@
1
1
  # libbase64
2
2
 
3
- Encode and decode base64 strings.
3
+ Encode and decode base64 strings. Written in TypeScript, published with both ES module and CommonJS builds and type declarations. Requires Node.js 20 or newer.
4
4
 
5
5
  ## Usage
6
6
 
@@ -14,6 +14,14 @@ Require in your script
14
14
  const libbase64 = require('libbase64');
15
15
  ```
16
16
 
17
+ or import it as an ES module
18
+
19
+ ```javascript
20
+ import libbase64 from 'libbase64';
21
+ // or
22
+ import { encode, decode, wrap, Encoder, Decoder } from 'libbase64';
23
+ ```
24
+
17
25
  ### Encode values
18
26
 
19
27
  Encode Buffer objects or unicode strings with
@@ -22,7 +30,7 @@ Encode Buffer objects or unicode strings with
22
30
 
23
31
  Where
24
32
 
25
- - **val** is a Buffer or an unicode string
33
+ - **val** is a Buffer, an Uint8Array or an unicode string
26
34
 
27
35
  **Example**
28
36
 
@@ -31,6 +39,23 @@ libbase64.encode('jõgeva');
31
39
  // asO1Z2V2YQ==
32
40
  ```
33
41
 
42
+ ### Decode values
43
+
44
+ Decode base64 strings to a Buffer with
45
+
46
+ libbase64.decode(str) → Buffer
47
+
48
+ Where
49
+
50
+ - **str** is a base64 encoded string. Line breaks and other characters outside of the base64 alphabet are ignored. Input made of several separately padded segments (eg. every line padded on its own) is decoded segment by segment
51
+
52
+ **Example**
53
+
54
+ ```javascript
55
+ libbase64.decode('asO1Z2V2YQ==').toString();
56
+ // jõgeva
57
+ ```
58
+
34
59
  ### Wrap encoded values
35
60
 
36
61
  To enforce soft line breaks on lines longer than selected amount of characters, use `wrap`
@@ -39,8 +64,8 @@ To enforce soft line breaks on lines longer than selected amount of characters,
39
64
 
40
65
  Where
41
66
 
42
- - **str** is a base64 encoded string
43
- - **lineLength** (defaults to 76) is the maximum allowed line length
67
+ - **str** is a base64 encoded string
68
+ - **lineLength** (defaults to 76) is the maximum allowed line length
44
69
 
45
70
  **Example**
46
71
 
@@ -63,12 +88,14 @@ Create new Encoder Stream with
63
88
 
64
89
  Where
65
90
 
66
- - **options** is the optional stream options object
67
- - **options.lineLength** (Number) if you want to use any other line length than the default 76
68
- characters (or set to `false` to turn the soft wrapping off completely)
69
- - **options.skipStartBytes** (Number) Optional. How many bytes to skip from output (default to 0)
70
- - **options.limitOutbutBytes** (Number) Optional. How many bytes to return (defaults to all bytes)
71
- - **options.startPadding** (String) Optional. Fills first line with provided padding string. Usually goes together with skipStartBytes to get line folding correct.
91
+ - **options** is the optional stream options object
92
+ - **options.lineLength** (Number) if you want to use any other line length than the default 76
93
+ characters (or set to `false` to turn the soft wrapping off completely)
94
+ - **options.skipStartBytes** (Number) Optional. How many bytes to skip from output (default to 0)
95
+ - **options.limitOutputBytes** (Number) Optional. How many bytes to return (defaults to all bytes). The misspelled `limitOutbutBytes` that earlier versions documented is still accepted
96
+ - **options.startPadding** (String) Optional. Fills first line with provided padding string. Usually goes together with skipStartBytes to get line folding correct.
97
+
98
+ The output is the same as `libbase64.wrap(libbase64.encode(input), lineLength)`, no matter how the input is split into chunks.
72
99
 
73
100
  **Example**
74
101
 
@@ -78,7 +105,7 @@ The following example script reads in a file, encodes it to base64 and saves the
78
105
  const libbase64 = require('libbase64');
79
106
  const fs = require('fs');
80
107
  const source = fs.createReadStream('source.txt');
81
- const encoded = fs.createReadStream('encoded.txt');
108
+ const encoded = fs.createWriteStream('encoded.txt');
82
109
  const encoder = new libbase64.Encoder();
83
110
 
84
111
  source.pipe(encoder).pipe(encoded);
@@ -92,7 +119,7 @@ Create new Decoder Stream with
92
119
 
93
120
  Where
94
121
 
95
- - **options** is the optional stream options object
122
+ - **options** is the optional stream options object
96
123
 
97
124
  **Example**
98
125
 
@@ -102,7 +129,7 @@ The following example script reads in a file in base64 encoding, decodes it and
102
129
  const libbase64 = require('libbase64');
103
130
  const fs = require('fs');
104
131
  const encoded = fs.createReadStream('encoded.txt');
105
- const dest = fs.createReadStream('dest.txt');
132
+ const dest = fs.createWriteStream('dest.txt');
106
133
  const decoder = new libbase64.Decoder();
107
134
 
108
135
  encoded.pipe(decoder).pipe(dest);
@@ -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;