@mavogel/awscdk-rootmail 0.0.219 → 0.0.221
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/cdk-nag/.jsii +2 -2
- package/node_modules/cdk-nag/lib/ignore-suppression-conditions.js +5 -5
- package/node_modules/cdk-nag/lib/nag-logger.js +2 -2
- package/node_modules/cdk-nag/lib/nag-pack.js +1 -1
- package/node_modules/cdk-nag/lib/nag-rules.js +1 -1
- package/node_modules/cdk-nag/lib/nag-suppressions.js +1 -1
- package/node_modules/cdk-nag/lib/packs/aws-solutions.js +1 -1
- package/node_modules/cdk-nag/lib/packs/hipaa-security.js +1 -1
- package/node_modules/cdk-nag/lib/packs/nist-800-53-r4.js +1 -1
- package/node_modules/cdk-nag/lib/packs/nist-800-53-r5.js +1 -1
- package/node_modules/cdk-nag/lib/packs/pci-dss-321.js +1 -1
- package/node_modules/cdk-nag/package.json +1 -1
- package/node_modules/encoding-japanese/README.md +65 -13
- package/node_modules/encoding-japanese/encoding.js +7 -2
- package/node_modules/encoding-japanese/encoding.min.js +2 -2
- package/node_modules/encoding-japanese/package.json +2 -2
- package/node_modules/encoding-japanese/src/encoding-convert.js +5 -0
- package/node_modules/libbase64/.prettierrc.js +4 -1
- package/node_modules/libbase64/lib/libbase64.js +2 -1
- package/node_modules/libbase64/package.json +9 -8
- package/node_modules/libmime/CHANGELOG.md +7 -0
- package/node_modules/libmime/package.json +5 -5
- package/node_modules/libqp/CHANGELOG.md +15 -0
- package/node_modules/libqp/lib/libqp.js +13 -21
- package/node_modules/libqp/package.json +7 -6
- package/node_modules/libqp/test/libqp-test.js +161 -0
- package/node_modules/mailparser/CHANGELOG.md +7 -0
- package/node_modules/mailparser/package.json +8 -8
- package/node_modules/mailsplit/LICENSE.MIT +6 -1
- package/node_modules/mailsplit/README.md +2 -0
- package/node_modules/mailsplit/lib/headers.js +5 -1
- package/node_modules/mailsplit/package.json +10 -9
- package/node_modules/nodemailer/.ncurc.js +4 -1
- package/node_modules/nodemailer/CHANGELOG.md +25 -0
- package/node_modules/nodemailer/lib/addressparser/index.js +22 -8
- package/node_modules/nodemailer/lib/mime-funcs/mime-types.js +2 -0
- package/node_modules/nodemailer/lib/nodemailer.js +13 -6
- package/node_modules/nodemailer/lib/smtp-connection/index.js +9 -0
- package/node_modules/nodemailer/lib/well-known/services.json +14 -3
- package/node_modules/nodemailer/package.json +5 -5
- package/node_modules/tlds/index.json +0 -3
- package/node_modules/tlds/package.json +1 -1
- package/package.json +4 -4
- package/node_modules/libmime/node_modules/libbase64/.eslintrc +0 -11
- package/node_modules/libmime/node_modules/libbase64/.prettierrc.js +0 -8
- package/node_modules/libmime/node_modules/libbase64/LICENSE +0 -19
- package/node_modules/libmime/node_modules/libbase64/README.md +0 -113
- package/node_modules/libmime/node_modules/libbase64/lib/libbase64.js +0 -253
- package/node_modules/libmime/node_modules/libbase64/package.json +0 -35
- package/node_modules/libmime/node_modules/libqp/.eslintrc +0 -15
- package/node_modules/libmime/node_modules/libqp/.prettierrc.js +0 -8
- package/node_modules/libmime/node_modules/libqp/CHANGELOG.md +0 -8
- package/node_modules/libmime/node_modules/libqp/LICENSE +0 -19
- package/node_modules/libmime/node_modules/libqp/README.md +0 -119
- package/node_modules/libmime/node_modules/libqp/lib/libqp.js +0 -320
- package/node_modules/libmime/node_modules/libqp/package.json +0 -28
- package/node_modules/libmime/node_modules/libqp/test/libqp-test.js +0 -41
- package/node_modules/mailsplit/node_modules/encoding-japanese/LICENSE +0 -21
- package/node_modules/mailsplit/node_modules/encoding-japanese/README.md +0 -542
- package/node_modules/mailsplit/node_modules/encoding-japanese/encoding.js +0 -6077
- package/node_modules/mailsplit/node_modules/encoding-japanese/encoding.min.js +0 -8
- package/node_modules/mailsplit/node_modules/encoding-japanese/encoding.min.js.map +0 -1
- package/node_modules/mailsplit/node_modules/encoding-japanese/package.json +0 -70
- package/node_modules/mailsplit/node_modules/encoding-japanese/src/banner.js +0 -6
- package/node_modules/mailsplit/node_modules/encoding-japanese/src/config.js +0 -139
- package/node_modules/mailsplit/node_modules/encoding-japanese/src/encoding-convert.js +0 -1676
- package/node_modules/mailsplit/node_modules/encoding-japanese/src/encoding-detect.js +0 -502
- package/node_modules/mailsplit/node_modules/encoding-japanese/src/encoding-table.js +0 -4
- package/node_modules/mailsplit/node_modules/encoding-japanese/src/index.js +0 -593
- package/node_modules/mailsplit/node_modules/encoding-japanese/src/jis-to-utf8-table.js +0 -5
- package/node_modules/mailsplit/node_modules/encoding-japanese/src/jisx0212-to-utf8-table.js +0 -5
- package/node_modules/mailsplit/node_modules/encoding-japanese/src/kana-case-table.js +0 -41
- package/node_modules/mailsplit/node_modules/encoding-japanese/src/utf8-to-jis-table.js +0 -1493
- package/node_modules/mailsplit/node_modules/encoding-japanese/src/utf8-to-jisx0212-table.js +0 -1224
- package/node_modules/mailsplit/node_modules/encoding-japanese/src/util.js +0 -361
- package/node_modules/mailsplit/node_modules/libmime/.eslintrc +0 -7
- package/node_modules/mailsplit/node_modules/libmime/.gitattributes +0 -1
- package/node_modules/mailsplit/node_modules/libmime/.github/FUNDING.yml +0 -4
- package/node_modules/mailsplit/node_modules/libmime/.github/workflows/test.yml +0 -21
- package/node_modules/mailsplit/node_modules/libmime/.prettierrc.js +0 -8
- package/node_modules/mailsplit/node_modules/libmime/CHANGELOG.md +0 -110
- package/node_modules/mailsplit/node_modules/libmime/LICENSE +0 -19
- package/node_modules/mailsplit/node_modules/libmime/README.md +0 -207
- package/node_modules/mailsplit/node_modules/libmime/lib/charset.js +0 -117
- package/node_modules/mailsplit/node_modules/libmime/lib/charsets.js +0 -212
- package/node_modules/mailsplit/node_modules/libmime/lib/libmime.js +0 -903
- package/node_modules/mailsplit/node_modules/libmime/lib/mimetypes.js +0 -2049
- package/node_modules/mailsplit/node_modules/libmime/package.json +0 -37
- /package/node_modules/{libmime/node_modules/libbase64 → libbase64}/.github/FUNDING.yml +0 -0
- /package/node_modules/{libmime/node_modules/libbase64 → libbase64}/.github/workflows/release.yaml +0 -0
- /package/node_modules/{libmime/node_modules/libbase64 → libbase64}/.github/workflows/test.yml +0 -0
- /package/node_modules/{libmime/node_modules/libbase64 → libbase64}/.ncurc.js +0 -0
- /package/node_modules/{libmime/node_modules/libbase64 → libbase64}/CHANGELOG.md +0 -0
- /package/node_modules/{libmime/node_modules/libqp → libqp}/.github/FUNDING.yml +0 -0
- /package/node_modules/{libmime/node_modules/libqp → libqp}/.github/workflows/release.yaml +0 -0
- /package/node_modules/{libmime/node_modules/libqp → libqp}/.github/workflows/test.yml +0 -0
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "libbase64",
|
|
3
|
-
"version": "1.3.0",
|
|
4
|
-
"description": "Encode and decode base64 encoded strings",
|
|
5
|
-
"main": "lib/libbase64.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "grunt",
|
|
8
|
-
"update": "rm -rf node_modules package-lock.json && ncu -u && npm install"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git://github.com/nodemailer/libbase64.git"
|
|
13
|
-
},
|
|
14
|
-
"keywords": [
|
|
15
|
-
"base64",
|
|
16
|
-
"mime"
|
|
17
|
-
],
|
|
18
|
-
"author": "Andris Reinman",
|
|
19
|
-
"license": "MIT",
|
|
20
|
-
"bugs": {
|
|
21
|
-
"url": "https://github.com/nodemailer/libbase64/issues"
|
|
22
|
-
},
|
|
23
|
-
"homepage": "https://github.com/nodemailer/libbase64",
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"chai": "4.4.1",
|
|
26
|
-
"eslint-config-nodemailer": "1.2.0",
|
|
27
|
-
"eslint-config-prettier": "9.1.0",
|
|
28
|
-
"grunt": "1.6.1",
|
|
29
|
-
"grunt-cli": "1.4.3",
|
|
30
|
-
"grunt-eslint": "24.3.0",
|
|
31
|
-
"grunt-mocha-test": "0.13.3",
|
|
32
|
-
"mocha": "10.3.0"
|
|
33
|
-
},
|
|
34
|
-
"dependencies": {}
|
|
35
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2014-2022 Andris Reinman
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
in the Software without restriction, including without limitation the rights
|
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
furnished to do so, subject to the following conditions:
|
|
9
|
-
|
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
|
11
|
-
all copies or substantial portions of the Software.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
THE SOFTWARE.
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
# libqp
|
|
2
|
-
|
|
3
|
-
Encode and decode quoted-printable strings according to [RFC2045](http://tools.ietf.org/html/rfc2045#section-6.7).
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
Install with npm
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
npm install libqp
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Require in your script
|
|
14
|
-
|
|
15
|
-
```javascript
|
|
16
|
-
const libqp = require('libqp');
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Encode values
|
|
20
|
-
|
|
21
|
-
Encode Buffer objects or unicode strings with
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
libqp.encode(val) → String
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Where
|
|
28
|
-
|
|
29
|
-
- **val** is a Buffer or an unicode string
|
|
30
|
-
|
|
31
|
-
**Example**
|
|
32
|
-
|
|
33
|
-
```javascript
|
|
34
|
-
libqp.encode('jõgeva');
|
|
35
|
-
// j=C3=B5geva
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### Wrap encoded values
|
|
39
|
-
|
|
40
|
-
Quoted-Printable encoded lines are limited to 76 characters but `encode` method might return lines longer than the limit.
|
|
41
|
-
|
|
42
|
-
To enforce soft line breaks on lines longer than 76 (or any other length) characters, use `wrap`
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
libqp.wrap(str[, lineLength]) → String
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Where
|
|
49
|
-
|
|
50
|
-
- **str** is a Quoted-Printable encoded string
|
|
51
|
-
- **lineLength** (defaults to 76) is the maximum allowed line length. Any longer line will be soft wrapped
|
|
52
|
-
|
|
53
|
-
**Example**
|
|
54
|
-
|
|
55
|
-
```javascript
|
|
56
|
-
libqp.wrap('abc j=C3=B5geva', 10);
|
|
57
|
-
// abc j=\r\n
|
|
58
|
-
// =C3=B5geva
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### Transform Streams
|
|
62
|
-
|
|
63
|
-
`libqp` makes it possible to encode and decode streams with `libqp.Encoder` and `libqp.Decoder` constructors.
|
|
64
|
-
|
|
65
|
-
### Encoder Stream
|
|
66
|
-
|
|
67
|
-
Create new Encoder Stream with
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
const encoder = new libqp.Encoder([options])
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Where
|
|
74
|
-
|
|
75
|
-
- **options** is the optional stream options object with an additional option `lineLength` if you want to use any other line length than the default 76 characters (or set to `false` to turn the soft wrapping off completely)
|
|
76
|
-
|
|
77
|
-
**Example**
|
|
78
|
-
|
|
79
|
-
The following example script reads in a file, encodes it to Quoted-Printable and saves the output to a file.
|
|
80
|
-
|
|
81
|
-
```javascript
|
|
82
|
-
var libqp = require('libqp');
|
|
83
|
-
var fs = require('fs');
|
|
84
|
-
var source = fs.createReadStream('source.txt');
|
|
85
|
-
var encoded = fs.createReadStream('encoded.txt');
|
|
86
|
-
var encoder = new libqp.Encoder();
|
|
87
|
-
|
|
88
|
-
source.pipe(encoder).pipe(encoded);
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### Decoder Stream
|
|
92
|
-
|
|
93
|
-
Create new Decoder Stream with
|
|
94
|
-
|
|
95
|
-
```
|
|
96
|
-
const decoder = new libqp.Decoder([options])
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Where
|
|
100
|
-
|
|
101
|
-
- **options** is the optional stream options object
|
|
102
|
-
|
|
103
|
-
**Example**
|
|
104
|
-
|
|
105
|
-
The following example script reads in a file in Quoted-Printable encoding, decodes it and saves the output to a file.
|
|
106
|
-
|
|
107
|
-
```javascript
|
|
108
|
-
const libqp = require('libqp');
|
|
109
|
-
const fs = require('fs');
|
|
110
|
-
let encoded = fs.createReadStream('encoded.txt');
|
|
111
|
-
let dest = fs.createReadStream('dest.txt');
|
|
112
|
-
let decoder = new libqp.Decoder();
|
|
113
|
-
|
|
114
|
-
encoded.pipe(decoder).pipe(dest);
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## License
|
|
118
|
-
|
|
119
|
-
**MIT**
|
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
/* eslint no-useless-escape: 0 */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const { Buffer } = require('node:buffer');
|
|
6
|
-
const stream = require('node:stream');
|
|
7
|
-
const Transform = stream.Transform;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Encodes a Buffer into a Quoted-Printable encoded string
|
|
11
|
-
*
|
|
12
|
-
* @param {Buffer} buffer Buffer to convert
|
|
13
|
-
* @returns {String} Quoted-Printable encoded string
|
|
14
|
-
*/
|
|
15
|
-
function encode(buffer) {
|
|
16
|
-
if (typeof buffer === 'string') {
|
|
17
|
-
buffer = Buffer.from(buffer, 'utf-8');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// usable characters that do not need encoding
|
|
21
|
-
let ranges = [
|
|
22
|
-
// https://tools.ietf.org/html/rfc2045#section-6.7
|
|
23
|
-
[0x09], // <TAB>
|
|
24
|
-
[0x0a], // <LF>
|
|
25
|
-
[0x0d], // <CR>
|
|
26
|
-
[0x20, 0x3c], // <SP>!"#$%&'()*+,-./0123456789:;
|
|
27
|
-
[0x3e, 0x7e] // >?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}
|
|
28
|
-
];
|
|
29
|
-
let result = '';
|
|
30
|
-
let ord;
|
|
31
|
-
|
|
32
|
-
for (let i = 0, len = buffer.length; i < len; i++) {
|
|
33
|
-
ord = buffer[i];
|
|
34
|
-
// if the char is in allowed range, then keep as is, unless it is a ws in the end of a line
|
|
35
|
-
if (checkRanges(ord, ranges) && !((ord === 0x20 || ord === 0x09) && (i === len - 1 || buffer[i + 1] === 0x0a || buffer[i + 1] === 0x0d))) {
|
|
36
|
-
result += String.fromCharCode(ord);
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
result += '=' + (ord < 0x10 ? '0' : '') + ord.toString(16).toUpperCase();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Decodes a Quoted-Printable encoded string to a Buffer object
|
|
47
|
-
*
|
|
48
|
-
* @param {String} str Quoted-Printable encoded string
|
|
49
|
-
* @returns {Buffer} Decoded value
|
|
50
|
-
*/
|
|
51
|
-
function decode(str) {
|
|
52
|
-
str = (str || '')
|
|
53
|
-
.toString()
|
|
54
|
-
// remove invalid whitespace from the end of lines
|
|
55
|
-
.replace(/[\t ]+$/gm, '')
|
|
56
|
-
// remove soft line breaks
|
|
57
|
-
.replace(/\=(?:\r?\n|$)/g, '');
|
|
58
|
-
|
|
59
|
-
let encodedBytesCount = (str.match(/\=[\da-fA-F]{2}/g) || []).length,
|
|
60
|
-
bufferLength = str.length - encodedBytesCount * 2,
|
|
61
|
-
chr,
|
|
62
|
-
hex,
|
|
63
|
-
buffer = Buffer.alloc(bufferLength),
|
|
64
|
-
bufferPos = 0;
|
|
65
|
-
|
|
66
|
-
for (let i = 0, len = str.length; i < len; i++) {
|
|
67
|
-
chr = str.charAt(i);
|
|
68
|
-
if (chr === '=' && (hex = str.substr(i + 1, 2)) && /[\da-fA-F]{2}/.test(hex)) {
|
|
69
|
-
buffer[bufferPos++] = parseInt(hex, 16);
|
|
70
|
-
i += 2;
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
buffer[bufferPos++] = chr.charCodeAt(0);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return buffer;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Adds soft line breaks to a Quoted-Printable string
|
|
81
|
-
*
|
|
82
|
-
* @param {String} str Quoted-Printable encoded string that might need line wrapping
|
|
83
|
-
* @param {Number} [lineLength=76] Maximum allowed length for a line
|
|
84
|
-
* @returns {String} Soft-wrapped Quoted-Printable encoded string
|
|
85
|
-
*/
|
|
86
|
-
function wrap(str, lineLength) {
|
|
87
|
-
str = (str || '').toString();
|
|
88
|
-
lineLength = lineLength || 76;
|
|
89
|
-
|
|
90
|
-
if (str.length <= lineLength) {
|
|
91
|
-
return str;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
let pos = 0,
|
|
95
|
-
len = str.length,
|
|
96
|
-
match,
|
|
97
|
-
code,
|
|
98
|
-
line,
|
|
99
|
-
lineMargin = Math.floor(lineLength / 3),
|
|
100
|
-
result = '';
|
|
101
|
-
|
|
102
|
-
// insert soft linebreaks where needed
|
|
103
|
-
while (pos < len) {
|
|
104
|
-
line = str.substr(pos, lineLength);
|
|
105
|
-
if ((match = line.match(/\r\n/))) {
|
|
106
|
-
line = line.substr(0, match.index + match[0].length);
|
|
107
|
-
result += line;
|
|
108
|
-
pos += line.length;
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (line.substr(-1) === '\n') {
|
|
113
|
-
// nothing to change here
|
|
114
|
-
result += line;
|
|
115
|
-
pos += line.length;
|
|
116
|
-
continue;
|
|
117
|
-
} else if ((match = line.substr(-lineMargin).match(/\n.*?$/))) {
|
|
118
|
-
// truncate to nearest line break
|
|
119
|
-
line = line.substr(0, line.length - (match[0].length - 1));
|
|
120
|
-
result += line;
|
|
121
|
-
pos += line.length;
|
|
122
|
-
continue;
|
|
123
|
-
} else if (line.length > lineLength - lineMargin && (match = line.substr(-lineMargin).match(/[ \t\.,!\?][^ \t\.,!\?]*$/))) {
|
|
124
|
-
// truncate to nearest space
|
|
125
|
-
line = line.substr(0, line.length - (match[0].length - 1));
|
|
126
|
-
} else if (line.match(/\=[\da-f]{0,2}$/i)) {
|
|
127
|
-
// push incomplete encoding sequences to the next line
|
|
128
|
-
if ((match = line.match(/\=[\da-f]{0,1}$/i))) {
|
|
129
|
-
line = line.substr(0, line.length - match[0].length);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// ensure that utf-8 sequences are not split
|
|
133
|
-
while (line.length > 3 && line.length < len - pos && !line.match(/^(?:=[\da-f]{2}){1,4}$/i) && (match = line.match(/\=[\da-f]{2}$/gi))) {
|
|
134
|
-
code = parseInt(match[0].substr(1, 2), 16);
|
|
135
|
-
if (code < 128) {
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
line = line.substr(0, line.length - 3);
|
|
140
|
-
|
|
141
|
-
if (code >= 0xc0) {
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (pos + line.length < len && line.substr(-1) !== '\n') {
|
|
148
|
-
if (line.length === lineLength && line.match(/\=[\da-f]{2}$/i)) {
|
|
149
|
-
line = line.substr(0, line.length - 3);
|
|
150
|
-
} else if (line.length === lineLength) {
|
|
151
|
-
line = line.substr(0, line.length - 1);
|
|
152
|
-
}
|
|
153
|
-
pos += line.length;
|
|
154
|
-
line += '=\r\n';
|
|
155
|
-
} else {
|
|
156
|
-
pos += line.length;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
result += line;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return result;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Helper function to check if a number is inside provided ranges
|
|
167
|
-
*
|
|
168
|
-
* @param {Number} nr Number to check for
|
|
169
|
-
* @param {Array} ranges An Array of allowed values
|
|
170
|
-
* @returns {Boolean} True if the value was found inside allowed ranges, false otherwise
|
|
171
|
-
*/
|
|
172
|
-
function checkRanges(nr, ranges) {
|
|
173
|
-
for (let i = ranges.length - 1; i >= 0; i--) {
|
|
174
|
-
if (!ranges[i].length) {
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
if (ranges[i].length === 1 && nr === ranges[i][0]) {
|
|
178
|
-
return true;
|
|
179
|
-
}
|
|
180
|
-
if (ranges[i].length === 2 && nr >= ranges[i][0] && nr <= ranges[i][1]) {
|
|
181
|
-
return true;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return false;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Creates a transform stream for encoding data to Quoted-Printable encoding
|
|
189
|
-
*
|
|
190
|
-
* @constructor
|
|
191
|
-
* @param {Object} options Stream options
|
|
192
|
-
* @param {Number} [options.lineLength=76] Maximum lenght for lines, set to false to disable wrapping
|
|
193
|
-
*/
|
|
194
|
-
class Encoder extends Transform {
|
|
195
|
-
constructor(options) {
|
|
196
|
-
super();
|
|
197
|
-
|
|
198
|
-
// init Transform
|
|
199
|
-
this.options = options || {};
|
|
200
|
-
|
|
201
|
-
if (this.options.lineLength !== false) {
|
|
202
|
-
this.options.lineLength = this.options.lineLength || 76;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
this._curLine = '';
|
|
206
|
-
|
|
207
|
-
this.inputBytes = 0;
|
|
208
|
-
this.outputBytes = 0;
|
|
209
|
-
|
|
210
|
-
Transform.call(this, this.options);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
_transform(chunk, encoding, done) {
|
|
214
|
-
let qp;
|
|
215
|
-
|
|
216
|
-
if (encoding !== 'buffer') {
|
|
217
|
-
chunk = Buffer.from(chunk, encoding);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (!chunk || !chunk.length) {
|
|
221
|
-
return done();
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
this.inputBytes += chunk.length;
|
|
225
|
-
|
|
226
|
-
if (this.options.lineLength) {
|
|
227
|
-
qp = this._curLine + encode(chunk);
|
|
228
|
-
qp = wrap(qp, this.options.lineLength);
|
|
229
|
-
qp = qp.replace(/(^|\n)([^\n]*)$/, (match, lineBreak, lastLine) => {
|
|
230
|
-
this._curLine = lastLine;
|
|
231
|
-
return lineBreak;
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
if (qp) {
|
|
235
|
-
this.outputBytes += qp.length;
|
|
236
|
-
this.push(qp);
|
|
237
|
-
}
|
|
238
|
-
} else {
|
|
239
|
-
qp = encode(chunk);
|
|
240
|
-
this.outputBytes += qp.length;
|
|
241
|
-
this.push(qp, 'ascii');
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
done();
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
_flush(done) {
|
|
248
|
-
if (this._curLine) {
|
|
249
|
-
this.outputBytes += this._curLine.length;
|
|
250
|
-
this.push(this._curLine, 'ascii');
|
|
251
|
-
}
|
|
252
|
-
done();
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Creates a transform stream for decoding Quoted-Printable encoded strings
|
|
258
|
-
*
|
|
259
|
-
* @constructor
|
|
260
|
-
* @param {Object} options Stream options
|
|
261
|
-
*/
|
|
262
|
-
class Decoder extends Transform {
|
|
263
|
-
constructor(options) {
|
|
264
|
-
options = options || {};
|
|
265
|
-
super(options);
|
|
266
|
-
|
|
267
|
-
// init Transform
|
|
268
|
-
this.options = options;
|
|
269
|
-
this._curLine = '';
|
|
270
|
-
|
|
271
|
-
this.inputBytes = 0;
|
|
272
|
-
this.outputBytes = 0;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
_transform(chunk, encoding, done) {
|
|
276
|
-
let qp, buf;
|
|
277
|
-
|
|
278
|
-
chunk = chunk.toString('ascii');
|
|
279
|
-
|
|
280
|
-
if (!chunk || !chunk.length) {
|
|
281
|
-
return done();
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
this.inputBytes += chunk.length;
|
|
285
|
-
|
|
286
|
-
qp = this._curLine + chunk;
|
|
287
|
-
this._curLine = '';
|
|
288
|
-
qp = qp.replace(/\=[^\n]?$/, lastLine => {
|
|
289
|
-
this._curLine = lastLine;
|
|
290
|
-
return '';
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
if (qp) {
|
|
294
|
-
buf = decode(qp);
|
|
295
|
-
this.outputBytes += buf.length;
|
|
296
|
-
this.push(buf);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
done();
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
_flush(done) {
|
|
303
|
-
let buf;
|
|
304
|
-
if (this._curLine) {
|
|
305
|
-
buf = decode(this._curLine);
|
|
306
|
-
this.outputBytes += buf.length;
|
|
307
|
-
this.push(buf);
|
|
308
|
-
}
|
|
309
|
-
done();
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// expose to the world
|
|
314
|
-
module.exports = {
|
|
315
|
-
encode,
|
|
316
|
-
decode,
|
|
317
|
-
wrap,
|
|
318
|
-
Encoder,
|
|
319
|
-
Decoder
|
|
320
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "libqp",
|
|
3
|
-
"version": "2.1.0",
|
|
4
|
-
"description": "Encode and decode quoted-printable strings according to rfc2045",
|
|
5
|
-
"main": "lib/libqp.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "node --test",
|
|
8
|
-
"update": "rm -rf node_modules package-lock.json && ncu -u && npm install"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git://github.com/nodemailer/libqp.git"
|
|
13
|
-
},
|
|
14
|
-
"keywords": [
|
|
15
|
-
"quoted-printable",
|
|
16
|
-
"mime"
|
|
17
|
-
],
|
|
18
|
-
"author": "Andris Reinman",
|
|
19
|
-
"license": "MIT",
|
|
20
|
-
"bugs": {
|
|
21
|
-
"url": "https://github.com/nodemailer/libqp/issues"
|
|
22
|
-
},
|
|
23
|
-
"homepage": "https://github.com/nodemailer/libqp",
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"eslint-config-nodemailer": "1.2.0",
|
|
26
|
-
"eslint-config-prettier": "9.1.0"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { Buffer } = require('node:buffer');
|
|
4
|
-
const test = require('node:test');
|
|
5
|
-
const assert = require('node:assert').strict;
|
|
6
|
-
|
|
7
|
-
const libqp = require('../lib/libqp');
|
|
8
|
-
|
|
9
|
-
test('Encoding tests', async t => {
|
|
10
|
-
await t.test('simple string', async () => {
|
|
11
|
-
const encoded = libqp.encode('tere jõgeva');
|
|
12
|
-
|
|
13
|
-
assert.strictEqual(encoded, 'tere j=C3=B5geva');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
await t.test('stream', async () => {
|
|
17
|
-
let input = 'tere jõgeva';
|
|
18
|
-
let encoder = new libqp.Encoder();
|
|
19
|
-
|
|
20
|
-
let encoded = await new Promise((resolve, reject) => {
|
|
21
|
-
let chunks = [];
|
|
22
|
-
encoder.on('readable', () => {
|
|
23
|
-
let chunk;
|
|
24
|
-
|
|
25
|
-
while ((chunk = encoder.read()) !== null) {
|
|
26
|
-
chunks.push(chunk);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
encoder.on('end', () => {
|
|
30
|
-
resolve(Buffer.concat(chunks).toString());
|
|
31
|
-
});
|
|
32
|
-
encoder.on('Error', err => {
|
|
33
|
-
reject(err);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
encoder.end(Buffer.from(input));
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
assert.strictEqual(encoded, 'tere j=C3=B5geva');
|
|
40
|
-
});
|
|
41
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2012 polygonplanet
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|