@nocobase/plugin-workflow-mailer 2.2.19 → 2.2.21
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/dist/externalVersion.js +6 -6
- package/dist/node_modules/joi/package.json +1 -1
- package/dist/node_modules/nodemailer/dist/cjs/addressparser/index.d.ts +59 -0
- package/dist/node_modules/nodemailer/dist/cjs/addressparser/index.js +790 -0
- package/dist/node_modules/nodemailer/dist/cjs/base64/index.d.ts +36 -0
- package/dist/node_modules/nodemailer/dist/cjs/base64/index.js +119 -0
- package/dist/node_modules/nodemailer/dist/cjs/dkim/index.d.ts +52 -0
- package/dist/node_modules/nodemailer/dist/cjs/dkim/index.js +228 -0
- package/dist/node_modules/nodemailer/dist/cjs/dkim/message-parser.d.ts +48 -0
- package/dist/node_modules/nodemailer/dist/cjs/dkim/message-parser.js +180 -0
- package/dist/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.d.ts +36 -0
- package/dist/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.js +148 -0
- package/dist/node_modules/nodemailer/dist/cjs/dkim/sign.d.ts +52 -0
- package/dist/node_modules/nodemailer/dist/cjs/dkim/sign.js +165 -0
- package/dist/node_modules/nodemailer/dist/cjs/errors.d.ts +96 -0
- package/dist/node_modules/nodemailer/dist/cjs/errors.js +70 -0
- package/dist/node_modules/nodemailer/dist/cjs/fetch/cookies.d.ts +107 -0
- package/dist/node_modules/nodemailer/dist/cjs/fetch/cookies.js +282 -0
- package/dist/node_modules/nodemailer/dist/cjs/fetch/index.d.ts +65 -0
- package/dist/node_modules/nodemailer/dist/cjs/fetch/index.js +384 -0
- package/dist/node_modules/nodemailer/dist/cjs/json-transport/index.d.ts +64 -0
- package/dist/node_modules/nodemailer/dist/cjs/json-transport/index.js +99 -0
- package/dist/node_modules/nodemailer/dist/cjs/mail-composer/index.d.ts +174 -0
- package/dist/node_modules/nodemailer/dist/cjs/mail-composer/index.js +613 -0
- package/dist/node_modules/nodemailer/dist/cjs/mailer/index.d.ts +237 -0
- package/dist/node_modules/nodemailer/dist/cjs/mailer/index.js +415 -0
- package/dist/node_modules/nodemailer/dist/cjs/mailer/mail-message.d.ts +97 -0
- package/dist/node_modules/nodemailer/dist/cjs/mailer/mail-message.js +342 -0
- package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/index.d.ts +161 -0
- package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/index.js +787 -0
- package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/mime-types.d.ts +2 -0
- package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/mime-types.js +2103 -0
- package/dist/node_modules/nodemailer/dist/cjs/mime-node/index.d.ts +333 -0
- package/dist/node_modules/nodemailer/dist/cjs/mime-node/index.js +1493 -0
- package/dist/node_modules/nodemailer/dist/cjs/mime-node/last-newline.d.ts +5 -0
- package/dist/node_modules/nodemailer/dist/cjs/mime-node/last-newline.js +32 -0
- package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-unix.d.ts +9 -0
- package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-unix.js +40 -0
- package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-windows.d.ts +10 -0
- package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-windows.js +47 -0
- package/dist/node_modules/nodemailer/dist/cjs/nodemailer.d.ts +124 -0
- package/dist/node_modules/nodemailer/dist/cjs/nodemailer.js +1 -0
- package/dist/node_modules/nodemailer/dist/cjs/package-info.d.ts +3 -0
- package/dist/node_modules/nodemailer/dist/cjs/package-info.js +7 -0
- package/dist/node_modules/nodemailer/dist/cjs/package.json +3 -0
- package/dist/node_modules/nodemailer/dist/cjs/punycode/index.d.ts +73 -0
- package/dist/node_modules/nodemailer/{lib → dist/cjs}/punycode/index.js +62 -111
- package/dist/node_modules/nodemailer/dist/cjs/qp/index.d.ts +32 -0
- package/dist/node_modules/nodemailer/dist/cjs/qp/index.js +207 -0
- package/dist/node_modules/nodemailer/dist/cjs/sendmail-transport/index.d.ts +69 -0
- package/dist/node_modules/nodemailer/dist/cjs/sendmail-transport/index.js +210 -0
- package/dist/node_modules/nodemailer/dist/cjs/ses-transport/index.d.ts +112 -0
- package/dist/node_modules/nodemailer/dist/cjs/ses-transport/index.js +252 -0
- package/dist/node_modules/nodemailer/dist/cjs/shared/index.d.ts +260 -0
- package/dist/node_modules/nodemailer/dist/cjs/shared/index.js +680 -0
- package/dist/node_modules/nodemailer/dist/cjs/shared/objects.d.ts +23 -0
- package/dist/node_modules/nodemailer/dist/cjs/shared/objects.js +43 -0
- package/dist/node_modules/nodemailer/dist/cjs/shared/url.d.ts +21 -0
- package/dist/node_modules/nodemailer/dist/cjs/shared/url.js +255 -0
- package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.d.ts +15 -0
- package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.js +108 -0
- package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.d.ts +47 -0
- package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.js +189 -0
- package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/index.d.ts +416 -0
- package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/index.js +1837 -0
- package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/index.d.ts +133 -0
- package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/index.js +569 -0
- package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.d.ts +62 -0
- package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.js +257 -0
- package/dist/node_modules/nodemailer/dist/cjs/smtp-transport/index.d.ts +156 -0
- package/dist/node_modules/nodemailer/dist/cjs/smtp-transport/index.js +371 -0
- package/dist/node_modules/nodemailer/dist/cjs/stream-transport/index.d.ts +65 -0
- package/dist/node_modules/nodemailer/dist/cjs/stream-transport/index.js +146 -0
- package/dist/node_modules/nodemailer/dist/cjs/well-known/index.d.ts +35 -0
- package/dist/node_modules/nodemailer/dist/cjs/well-known/index.js +41 -0
- package/dist/node_modules/nodemailer/dist/cjs/well-known/services.d.ts +2 -0
- package/dist/node_modules/nodemailer/dist/cjs/well-known/services.js +674 -0
- package/dist/node_modules/nodemailer/dist/cjs/xoauth2/index.d.ts +201 -0
- package/dist/node_modules/nodemailer/dist/cjs/xoauth2/index.js +426 -0
- package/dist/node_modules/nodemailer/dist/esm/addressparser/index.d.ts +59 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/addressparser/index.js +361 -131
- package/dist/node_modules/nodemailer/dist/esm/base64/index.d.ts +36 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/base64/index.js +31 -56
- package/dist/node_modules/nodemailer/dist/esm/dkim/index.d.ts +52 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/index.js +49 -78
- package/dist/node_modules/nodemailer/dist/esm/dkim/message-parser.d.ts +48 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/message-parser.js +64 -42
- package/dist/node_modules/nodemailer/dist/esm/dkim/relaxed-body.d.ts +36 -0
- package/dist/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js +141 -0
- package/dist/node_modules/nodemailer/dist/esm/dkim/sign.d.ts +52 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/sign.js +50 -46
- package/dist/node_modules/nodemailer/dist/esm/errors.d.ts +96 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/errors.js +26 -18
- package/dist/node_modules/nodemailer/dist/esm/fetch/cookies.d.ts +107 -0
- package/dist/node_modules/nodemailer/dist/esm/fetch/cookies.js +242 -0
- package/dist/node_modules/nodemailer/dist/esm/fetch/index.d.ts +65 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/fetch/index.js +80 -147
- package/dist/node_modules/nodemailer/dist/esm/json-transport/index.d.ts +64 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/json-transport/index.js +19 -39
- package/dist/node_modules/nodemailer/dist/esm/mail-composer/index.d.ts +174 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/mail-composer/index.js +199 -265
- package/dist/node_modules/nodemailer/dist/esm/mailer/index.d.ts +237 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/mailer/index.js +128 -234
- package/dist/node_modules/nodemailer/dist/esm/mailer/mail-message.d.ts +97 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/mailer/mail-message.js +62 -114
- package/dist/node_modules/nodemailer/dist/esm/mime-funcs/index.d.ts +161 -0
- package/dist/node_modules/nodemailer/dist/esm/mime-funcs/index.js +738 -0
- package/dist/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.d.ts +2 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-funcs/mime-types.js +29 -42
- package/dist/node_modules/nodemailer/dist/esm/mime-node/index.d.ts +333 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/index.js +259 -372
- package/dist/node_modules/nodemailer/dist/esm/mime-node/last-newline.d.ts +5 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/last-newline.js +4 -10
- package/dist/node_modules/nodemailer/dist/esm/mime-node/le-unix.d.ts +9 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/le-unix.js +6 -11
- package/dist/node_modules/nodemailer/dist/esm/mime-node/le-windows.d.ts +10 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/le-windows.js +6 -13
- package/dist/node_modules/nodemailer/dist/esm/nodemailer.d.ts +124 -0
- package/dist/node_modules/nodemailer/dist/esm/nodemailer.js +166 -0
- package/dist/node_modules/nodemailer/dist/esm/package-info.d.ts +3 -0
- package/dist/node_modules/nodemailer/dist/esm/package-info.js +4 -0
- package/dist/node_modules/nodemailer/dist/esm/package.json +3 -0
- package/dist/node_modules/nodemailer/dist/esm/punycode/index.d.ts +73 -0
- package/dist/node_modules/nodemailer/dist/esm/punycode/index.js +405 -0
- package/dist/node_modules/nodemailer/dist/esm/qp/index.d.ts +32 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/qp/index.js +38 -67
- package/dist/node_modules/nodemailer/dist/esm/sendmail-transport/index.d.ts +69 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/sendmail-transport/index.js +51 -101
- package/dist/node_modules/nodemailer/dist/esm/ses-transport/index.d.ts +112 -0
- package/dist/node_modules/nodemailer/dist/esm/ses-transport/index.js +212 -0
- package/dist/node_modules/nodemailer/dist/esm/shared/index.d.ts +260 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/shared/index.js +156 -272
- package/dist/node_modules/nodemailer/dist/esm/shared/objects.d.ts +23 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/shared/objects.js +13 -17
- package/dist/node_modules/nodemailer/dist/esm/shared/url.d.ts +21 -0
- package/dist/node_modules/nodemailer/dist/esm/shared/url.js +214 -0
- package/dist/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.d.ts +15 -0
- package/dist/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js +103 -0
- package/dist/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.d.ts +47 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-connection/http-proxy-client.js +49 -74
- package/dist/node_modules/nodemailer/dist/esm/smtp-connection/index.d.ts +416 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-connection/index.js +574 -794
- package/dist/node_modules/nodemailer/dist/esm/smtp-pool/index.d.ts +133 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-pool/index.js +172 -284
- package/dist/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.d.ts +62 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-pool/pool-resource.js +57 -97
- package/dist/node_modules/nodemailer/dist/esm/smtp-transport/index.d.ts +156 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-transport/index.js +81 -179
- package/dist/node_modules/nodemailer/dist/esm/stream-transport/index.d.ts +65 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/stream-transport/index.js +36 -74
- package/dist/node_modules/nodemailer/dist/esm/well-known/index.d.ts +35 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/well-known/index.js +5 -16
- package/dist/node_modules/nodemailer/dist/esm/well-known/services.d.ts +2 -0
- package/dist/node_modules/nodemailer/dist/esm/well-known/services.js +671 -0
- package/dist/node_modules/nodemailer/dist/esm/xoauth2/index.d.ts +201 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/xoauth2/index.js +125 -187
- package/dist/node_modules/nodemailer/{lib → dist}/well-known/services.json +9 -2
- package/dist/node_modules/nodemailer/package.json +1 -1
- package/package.json +3 -3
- package/dist/node_modules/nodemailer/.gitattributes +0 -6
- package/dist/node_modules/nodemailer/.ncurc.js +0 -9
- package/dist/node_modules/nodemailer/.prettierignore +0 -8
- package/dist/node_modules/nodemailer/.prettierrc +0 -12
- package/dist/node_modules/nodemailer/.prettierrc.js +0 -10
- package/dist/node_modules/nodemailer/.release-please-config.json +0 -9
- package/dist/node_modules/nodemailer/eslint.config.js +0 -88
- package/dist/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
- package/dist/node_modules/nodemailer/lib/fetch/cookies.js +0 -276
- package/dist/node_modules/nodemailer/lib/mime-funcs/index.js +0 -671
- package/dist/node_modules/nodemailer/lib/nodemailer.js +0 -1
- package/dist/node_modules/nodemailer/lib/ses-transport/index.js +0 -266
- package/dist/node_modules/nodemailer/lib/shared/url.js +0 -151
- package/dist/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -105
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
Copied from https://github.com/mathiasbynens/punycode.js/blob/ef3505c8abb5143a00d53ce59077c9f7f4b2ac47/punycode.js
|
|
4
|
+
|
|
5
|
+
Copyright Mathias Bynens <https://mathiasbynens.be/>
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
8
|
+
a copy of this software and associated documentation files (the
|
|
9
|
+
"Software"), to deal in the Software without restriction, including
|
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
12
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
13
|
+
the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be
|
|
16
|
+
included in all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
20
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
22
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
23
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
24
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
25
|
+
|
|
26
|
+
*/
|
|
27
|
+
/* eslint callback-return: 0, no-bitwise: 0, eqeqeq: 0, prefer-arrow-callback: 0 */
|
|
28
|
+
/** Highest positive signed 32-bit float value */
|
|
29
|
+
const maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
|
|
30
|
+
/** Bootstring parameters */
|
|
31
|
+
const base = 36;
|
|
32
|
+
const tMin = 1;
|
|
33
|
+
const tMax = 26;
|
|
34
|
+
const skew = 38;
|
|
35
|
+
const damp = 700;
|
|
36
|
+
const initialBias = 72;
|
|
37
|
+
const initialN = 128; // 0x80
|
|
38
|
+
const delimiter = '-'; // '\x2D'
|
|
39
|
+
/** Regular expressions */
|
|
40
|
+
const regexPunycode = /^xn--/;
|
|
41
|
+
const regexNonASCII = /[^\0-\x7F]/; // Note: U+007F DEL is excluded too.
|
|
42
|
+
const regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
|
|
43
|
+
/** Error messages */
|
|
44
|
+
const errors = {
|
|
45
|
+
overflow: 'Overflow: input needs wider integers to process',
|
|
46
|
+
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
|
|
47
|
+
'invalid-input': 'Invalid input'
|
|
48
|
+
};
|
|
49
|
+
/** Convenience shortcuts */
|
|
50
|
+
const baseMinusTMin = base - tMin;
|
|
51
|
+
const floor = Math.floor;
|
|
52
|
+
const stringFromCharCode = String.fromCharCode;
|
|
53
|
+
/*--------------------------------------------------------------------------*/
|
|
54
|
+
/**
|
|
55
|
+
* A generic error utility function.
|
|
56
|
+
* @private
|
|
57
|
+
* @param type The error type.
|
|
58
|
+
* @returns Throws a `RangeError` with the applicable error message.
|
|
59
|
+
*/
|
|
60
|
+
function error(type) {
|
|
61
|
+
throw new RangeError(errors[type]);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A generic `Array#map` utility function.
|
|
65
|
+
* @private
|
|
66
|
+
* @param array The array to iterate over.
|
|
67
|
+
* @param callback The function that gets called for every array
|
|
68
|
+
* item.
|
|
69
|
+
* @returns A new array of values returned by the callback function.
|
|
70
|
+
*/
|
|
71
|
+
function map(array, callback) {
|
|
72
|
+
const result = [];
|
|
73
|
+
let length = array.length;
|
|
74
|
+
while (length--) {
|
|
75
|
+
result[length] = callback(array[length]);
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A simple `Array#map`-like wrapper to work with domain name strings or email
|
|
81
|
+
* addresses.
|
|
82
|
+
* @private
|
|
83
|
+
* @param domain The domain name or email address.
|
|
84
|
+
* @param callback The function that gets called for every
|
|
85
|
+
* character.
|
|
86
|
+
* @returns A new string of characters returned by the callback
|
|
87
|
+
* function.
|
|
88
|
+
*/
|
|
89
|
+
function mapDomain(domain, callback) {
|
|
90
|
+
const parts = domain.split('@');
|
|
91
|
+
let result = '';
|
|
92
|
+
if (parts.length > 1) {
|
|
93
|
+
// In email addresses, only the domain name should be punycoded. Leave
|
|
94
|
+
// the local part (i.e. everything up to `@`) intact.
|
|
95
|
+
result = parts[0] + '@';
|
|
96
|
+
domain = parts[1];
|
|
97
|
+
}
|
|
98
|
+
// Avoid `split(regex)` for IE8 compatibility. See #17.
|
|
99
|
+
domain = domain.replace(regexSeparators, '\x2E');
|
|
100
|
+
const labels = domain.split('.');
|
|
101
|
+
const encoded = map(labels, callback).join('.');
|
|
102
|
+
return result + encoded;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Creates an array containing the numeric code points of each Unicode
|
|
106
|
+
* character in the string. While JavaScript uses UCS-2 internally,
|
|
107
|
+
* this function will convert a pair of surrogate halves (each of which
|
|
108
|
+
* UCS-2 exposes as separate characters) into a single code point,
|
|
109
|
+
* matching UTF-16.
|
|
110
|
+
* @see `punycode.ucs2.encode`
|
|
111
|
+
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
112
|
+
* @memberOf punycode.ucs2
|
|
113
|
+
* @name decode
|
|
114
|
+
* @param string The Unicode input string (UCS-2).
|
|
115
|
+
* @returns The new array of code points.
|
|
116
|
+
*/
|
|
117
|
+
function ucs2decode(string) {
|
|
118
|
+
const output = [];
|
|
119
|
+
let counter = 0;
|
|
120
|
+
const length = string.length;
|
|
121
|
+
while (counter < length) {
|
|
122
|
+
const value = string.charCodeAt(counter++);
|
|
123
|
+
if (value >= 0xd800 && value <= 0xdbff && counter < length) {
|
|
124
|
+
// It's a high surrogate, and there is a next character.
|
|
125
|
+
const extra = string.charCodeAt(counter++);
|
|
126
|
+
if ((extra & 0xfc00) == 0xdc00) {
|
|
127
|
+
// Low surrogate.
|
|
128
|
+
output.push(((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
// It's an unmatched surrogate; only append this code unit, in case the
|
|
132
|
+
// next code unit is the high surrogate of a surrogate pair.
|
|
133
|
+
output.push(value);
|
|
134
|
+
counter--;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
output.push(value);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return output;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Creates a string based on an array of numeric code points.
|
|
145
|
+
* @see `punycode.ucs2.decode`
|
|
146
|
+
* @memberOf punycode.ucs2
|
|
147
|
+
* @name encode
|
|
148
|
+
* @param codePoints The array of numeric code points.
|
|
149
|
+
* @returns The new Unicode string (UCS-2).
|
|
150
|
+
*/
|
|
151
|
+
const ucs2encode = (codePoints) => String.fromCodePoint(...codePoints);
|
|
152
|
+
/**
|
|
153
|
+
* Converts a basic code point into a digit/integer.
|
|
154
|
+
* @see `digitToBasic()`
|
|
155
|
+
* @private
|
|
156
|
+
* @param codePoint The basic numeric code point value.
|
|
157
|
+
* @returns The numeric value of a basic code point (for use in
|
|
158
|
+
* representing integers) in the range `0` to `base - 1`, or `base` if
|
|
159
|
+
* the code point does not represent a value.
|
|
160
|
+
*/
|
|
161
|
+
const basicToDigit = function (codePoint) {
|
|
162
|
+
if (codePoint >= 0x30 && codePoint < 0x3a) {
|
|
163
|
+
return 26 + (codePoint - 0x30);
|
|
164
|
+
}
|
|
165
|
+
if (codePoint >= 0x41 && codePoint < 0x5b) {
|
|
166
|
+
return codePoint - 0x41;
|
|
167
|
+
}
|
|
168
|
+
if (codePoint >= 0x61 && codePoint < 0x7b) {
|
|
169
|
+
return codePoint - 0x61;
|
|
170
|
+
}
|
|
171
|
+
return base;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Converts a digit/integer into a basic code point.
|
|
175
|
+
* @see `basicToDigit()`
|
|
176
|
+
* @private
|
|
177
|
+
* @param digit The numeric value of a basic code point.
|
|
178
|
+
* @param flag Non-zero to use the uppercase form of the code point.
|
|
179
|
+
* @returns The basic code point whose value (when used for
|
|
180
|
+
* representing integers) is `digit`, which needs to be in the range
|
|
181
|
+
* `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
|
|
182
|
+
* used; else, the lowercase form is used. The behavior is undefined
|
|
183
|
+
* if `flag` is non-zero and `digit` has no uppercase form.
|
|
184
|
+
*/
|
|
185
|
+
const digitToBasic = function (digit, flag) {
|
|
186
|
+
// 0..25 map to ASCII a..z or A..Z
|
|
187
|
+
// 26..35 map to ASCII 0..9
|
|
188
|
+
return digit + 22 + 75 * Number(digit < 26) - (Number(flag != 0) << 5);
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Bias adaptation function as per section 3.4 of RFC 3492.
|
|
192
|
+
* https://tools.ietf.org/html/rfc3492#section-3.4
|
|
193
|
+
* @private
|
|
194
|
+
*/
|
|
195
|
+
const adapt = function (delta, numPoints, firstTime) {
|
|
196
|
+
let k = 0;
|
|
197
|
+
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
198
|
+
delta += floor(delta / numPoints);
|
|
199
|
+
for (; /* no initialization */ delta > (baseMinusTMin * tMax) >> 1; k += base) {
|
|
200
|
+
delta = floor(delta / baseMinusTMin);
|
|
201
|
+
}
|
|
202
|
+
return floor(k + ((baseMinusTMin + 1) * delta) / (delta + skew));
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Converts a Punycode string of ASCII-only symbols to a string of Unicode
|
|
206
|
+
* symbols.
|
|
207
|
+
* @memberOf punycode
|
|
208
|
+
* @param input The Punycode string of ASCII-only symbols.
|
|
209
|
+
* @returns The resulting string of Unicode symbols.
|
|
210
|
+
*/
|
|
211
|
+
const decode = function (input) {
|
|
212
|
+
// Don't use UCS-2.
|
|
213
|
+
const output = [];
|
|
214
|
+
const inputLength = input.length;
|
|
215
|
+
let i = 0;
|
|
216
|
+
let n = initialN;
|
|
217
|
+
let bias = initialBias;
|
|
218
|
+
// Handle the basic code points: let `basic` be the number of input code
|
|
219
|
+
// points before the last delimiter, or `0` if there is none, then copy
|
|
220
|
+
// the first basic code points to the output.
|
|
221
|
+
let basic = input.lastIndexOf(delimiter);
|
|
222
|
+
if (basic < 0) {
|
|
223
|
+
basic = 0;
|
|
224
|
+
}
|
|
225
|
+
for (let j = 0; j < basic; ++j) {
|
|
226
|
+
// if it's not a basic code point
|
|
227
|
+
if (input.charCodeAt(j) >= 0x80) {
|
|
228
|
+
error('not-basic');
|
|
229
|
+
}
|
|
230
|
+
output.push(input.charCodeAt(j));
|
|
231
|
+
}
|
|
232
|
+
// Main decoding loop: start just after the last delimiter if any basic code
|
|
233
|
+
// points were copied; start at the beginning otherwise.
|
|
234
|
+
for (let index = basic > 0 ? basic + 1 : 0; index < inputLength /* no final expression */;) {
|
|
235
|
+
// `index` is the index of the next character to be consumed.
|
|
236
|
+
// Decode a generalized variable-length integer into `delta`,
|
|
237
|
+
// which gets added to `i`. The overflow checking is easier
|
|
238
|
+
// if we increase `i` as we go, then subtract off its starting
|
|
239
|
+
// value at the end to obtain `delta`.
|
|
240
|
+
const oldi = i;
|
|
241
|
+
for (let w = 1, k = base /* no condition */;; k += base) {
|
|
242
|
+
if (index >= inputLength) {
|
|
243
|
+
error('invalid-input');
|
|
244
|
+
}
|
|
245
|
+
const digit = basicToDigit(input.charCodeAt(index++));
|
|
246
|
+
if (digit >= base) {
|
|
247
|
+
error('invalid-input');
|
|
248
|
+
}
|
|
249
|
+
if (digit > floor((maxInt - i) / w)) {
|
|
250
|
+
error('overflow');
|
|
251
|
+
}
|
|
252
|
+
i += digit * w;
|
|
253
|
+
const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
|
|
254
|
+
if (digit < t) {
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
const baseMinusT = base - t;
|
|
258
|
+
if (w > floor(maxInt / baseMinusT)) {
|
|
259
|
+
error('overflow');
|
|
260
|
+
}
|
|
261
|
+
w *= baseMinusT;
|
|
262
|
+
}
|
|
263
|
+
const out = output.length + 1;
|
|
264
|
+
bias = adapt(i - oldi, out, oldi == 0);
|
|
265
|
+
// `i` was supposed to wrap around from `out` to `0`,
|
|
266
|
+
// incrementing `n` each time, so we'll fix that now:
|
|
267
|
+
if (floor(i / out) > maxInt - n) {
|
|
268
|
+
error('overflow');
|
|
269
|
+
}
|
|
270
|
+
n += floor(i / out);
|
|
271
|
+
i %= out;
|
|
272
|
+
// Insert `n` at position `i` of the output.
|
|
273
|
+
output.splice(i++, 0, n);
|
|
274
|
+
}
|
|
275
|
+
return String.fromCodePoint(...output);
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* Converts a string of Unicode symbols (e.g. a domain name label) to a
|
|
279
|
+
* Punycode string of ASCII-only symbols.
|
|
280
|
+
* @memberOf punycode
|
|
281
|
+
* @param input The string of Unicode symbols.
|
|
282
|
+
* @returns The resulting Punycode string of ASCII-only symbols.
|
|
283
|
+
*/
|
|
284
|
+
const encode = function (input) {
|
|
285
|
+
const output = [];
|
|
286
|
+
// Convert the input in UCS-2 to an array of Unicode code points.
|
|
287
|
+
const codePoints = ucs2decode(input);
|
|
288
|
+
// Cache the length.
|
|
289
|
+
const inputLength = codePoints.length;
|
|
290
|
+
// Initialize the state.
|
|
291
|
+
let n = initialN;
|
|
292
|
+
let delta = 0;
|
|
293
|
+
let bias = initialBias;
|
|
294
|
+
// Handle the basic code points.
|
|
295
|
+
for (const currentValue of codePoints) {
|
|
296
|
+
if (currentValue < 0x80) {
|
|
297
|
+
output.push(stringFromCharCode(currentValue));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
const basicLength = output.length;
|
|
301
|
+
let handledCPCount = basicLength;
|
|
302
|
+
// `handledCPCount` is the number of code points that have been handled;
|
|
303
|
+
// `basicLength` is the number of basic code points.
|
|
304
|
+
// Finish the basic string with a delimiter unless it's empty.
|
|
305
|
+
if (basicLength) {
|
|
306
|
+
output.push(delimiter);
|
|
307
|
+
}
|
|
308
|
+
// Main encoding loop:
|
|
309
|
+
while (handledCPCount < inputLength) {
|
|
310
|
+
// All non-basic code points < n have been handled already. Find the next
|
|
311
|
+
// larger one:
|
|
312
|
+
let m = maxInt;
|
|
313
|
+
for (const currentValue of codePoints) {
|
|
314
|
+
if (currentValue >= n && currentValue < m) {
|
|
315
|
+
m = currentValue;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
|
|
319
|
+
// but guard against overflow.
|
|
320
|
+
const handledCPCountPlusOne = handledCPCount + 1;
|
|
321
|
+
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
|
322
|
+
error('overflow');
|
|
323
|
+
}
|
|
324
|
+
delta += (m - n) * handledCPCountPlusOne;
|
|
325
|
+
n = m;
|
|
326
|
+
for (const currentValue of codePoints) {
|
|
327
|
+
if (currentValue < n && ++delta > maxInt) {
|
|
328
|
+
error('overflow');
|
|
329
|
+
}
|
|
330
|
+
if (currentValue === n) {
|
|
331
|
+
// Represent delta as a generalized variable-length integer.
|
|
332
|
+
let q = delta;
|
|
333
|
+
for (let k = base /* no condition */;; k += base) {
|
|
334
|
+
const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
|
|
335
|
+
if (q < t) {
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
const qMinusT = q - t;
|
|
339
|
+
const baseMinusT = base - t;
|
|
340
|
+
output.push(stringFromCharCode(digitToBasic(t + (qMinusT % baseMinusT), 0)));
|
|
341
|
+
q = floor(qMinusT / baseMinusT);
|
|
342
|
+
}
|
|
343
|
+
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
|
344
|
+
bias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength);
|
|
345
|
+
delta = 0;
|
|
346
|
+
++handledCPCount;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
++delta;
|
|
350
|
+
++n;
|
|
351
|
+
}
|
|
352
|
+
return output.join('');
|
|
353
|
+
};
|
|
354
|
+
/**
|
|
355
|
+
* Converts a Punycode string representing a domain name or an email address
|
|
356
|
+
* to Unicode. Only the Punycoded parts of the input will be converted, i.e.
|
|
357
|
+
* it doesn't matter if you call it on a string that has already been
|
|
358
|
+
* converted to Unicode.
|
|
359
|
+
* @memberOf punycode
|
|
360
|
+
* @param input The Punycoded domain name or email address to
|
|
361
|
+
* convert to Unicode.
|
|
362
|
+
* @returns The Unicode representation of the given Punycode
|
|
363
|
+
* string.
|
|
364
|
+
*/
|
|
365
|
+
const toUnicode = function (input) {
|
|
366
|
+
return mapDomain(input, function (string) {
|
|
367
|
+
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
|
|
368
|
+
});
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
371
|
+
* Converts a Unicode string representing a domain name or an email address to
|
|
372
|
+
* Punycode. Only the non-ASCII parts of the domain name will be converted,
|
|
373
|
+
* i.e. it doesn't matter if you call it with a domain that's already in
|
|
374
|
+
* ASCII.
|
|
375
|
+
* @memberOf punycode
|
|
376
|
+
* @param input The domain name or email address to convert, as a
|
|
377
|
+
* Unicode string.
|
|
378
|
+
* @returns The Punycode representation of the given domain name or
|
|
379
|
+
* email address.
|
|
380
|
+
*/
|
|
381
|
+
const toASCII = function (input) {
|
|
382
|
+
return mapDomain(input, function (string) {
|
|
383
|
+
return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
|
|
384
|
+
});
|
|
385
|
+
};
|
|
386
|
+
/*--------------------------------------------------------------------------*/
|
|
387
|
+
/** Define the public API */
|
|
388
|
+
/**
|
|
389
|
+
* A string representing the current Punycode.js version number.
|
|
390
|
+
* @memberOf punycode
|
|
391
|
+
* @type String
|
|
392
|
+
*/
|
|
393
|
+
export const version = '2.3.1';
|
|
394
|
+
/**
|
|
395
|
+
* An object of methods to convert from JavaScript's internal character
|
|
396
|
+
* representation (UCS-2) to Unicode code points, and back.
|
|
397
|
+
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
398
|
+
* @memberOf punycode
|
|
399
|
+
* @type Object
|
|
400
|
+
*/
|
|
401
|
+
export const ucs2 = {
|
|
402
|
+
decode: ucs2decode,
|
|
403
|
+
encode: ucs2encode
|
|
404
|
+
};
|
|
405
|
+
export { decode, encode, toASCII, toUnicode };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Transform } from 'node:stream';
|
|
2
|
+
export declare function encode(buffer: Buffer | string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Adds soft line breaks to a Quoted-Printable string
|
|
5
|
+
*
|
|
6
|
+
* @param str Quoted-Printable encoded string that might need line wrapping
|
|
7
|
+
* @param [lineLength=76] Maximum allowed length for a line
|
|
8
|
+
* @returns Soft-wrapped Quoted-Printable encoded string
|
|
9
|
+
*/
|
|
10
|
+
export declare function wrap(str: string, lineLength?: number): string;
|
|
11
|
+
/**
|
|
12
|
+
* Options for the Quoted-Printable encoder stream
|
|
13
|
+
*/
|
|
14
|
+
export interface QPEncoderOptions {
|
|
15
|
+
/** Maximum length for lines, set to false to disable wrapping */
|
|
16
|
+
lineLength?: number | false | undefined;
|
|
17
|
+
}
|
|
18
|
+
/** The name @types/nodemailer used for QPEncoderOptions */
|
|
19
|
+
export type EncoderOptions = QPEncoderOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a transform stream for encoding data to Quoted-Printable encoding
|
|
22
|
+
*
|
|
23
|
+
* @constructor
|
|
24
|
+
* @param options Stream options
|
|
25
|
+
* @param [options.lineLength=76] Maximum length for lines, set to false to disable wrapping
|
|
26
|
+
*/
|
|
27
|
+
export declare class Encoder extends Transform {
|
|
28
|
+
options: QPEncoderOptions;
|
|
29
|
+
inputBytes: number;
|
|
30
|
+
outputBytes: number;
|
|
31
|
+
constructor(options?: QPEncoderOptions);
|
|
32
|
+
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { Transform } = require('stream');
|
|
4
|
-
|
|
1
|
+
import { Transform } from 'node:stream';
|
|
5
2
|
/**
|
|
6
3
|
* Encodes a Buffer into a Quoted-Printable encoded string
|
|
7
4
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @returns
|
|
5
|
+
* @param buffer Buffer to convert
|
|
6
|
+
* @returns Quoted-Printable encoded string
|
|
10
7
|
*/
|
|
8
|
+
// the shortest line wrap() can make progress with: a complete =XX sequence and the soft break
|
|
9
|
+
const MIN_LINE_LENGTH = 4;
|
|
11
10
|
// usable characters that do not need encoding
|
|
12
11
|
// https://tools.ietf.org/html/rfc2045#section-6.7
|
|
13
12
|
const QP_RANGES = [
|
|
@@ -17,52 +16,44 @@ const QP_RANGES = [
|
|
|
17
16
|
[0x20, 0x3c], // <SP>!"#$%&'()*+,-./0123456789:;
|
|
18
17
|
[0x3e, 0x7e] // >?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}
|
|
19
18
|
];
|
|
20
|
-
|
|
21
|
-
function encode(buffer) {
|
|
19
|
+
export function encode(buffer) {
|
|
22
20
|
if (typeof buffer === 'string') {
|
|
23
21
|
buffer = Buffer.from(buffer, 'utf-8');
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
let result = '';
|
|
27
24
|
let ord;
|
|
28
|
-
|
|
29
25
|
for (let i = 0, len = buffer.length; i < len; i++) {
|
|
30
26
|
ord = buffer[i];
|
|
31
27
|
// if the char is in allowed range, then keep as is, unless it is a WS in the end of a line
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
!((ord === 0x20 || ord === 0x09) && (i === len - 1 || buffer[i + 1] === 0x0a || buffer[i + 1] === 0x0d))
|
|
35
|
-
) {
|
|
28
|
+
if (checkRanges(ord, QP_RANGES) &&
|
|
29
|
+
!((ord === 0x20 || ord === 0x09) && (i === len - 1 || buffer[i + 1] === 0x0a || buffer[i + 1] === 0x0d))) {
|
|
36
30
|
result += String.fromCharCode(ord);
|
|
37
31
|
continue;
|
|
38
32
|
}
|
|
39
33
|
result += '=' + (ord < 0x10 ? '0' : '') + ord.toString(16).toUpperCase();
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
return result;
|
|
43
36
|
}
|
|
44
|
-
|
|
45
37
|
/**
|
|
46
38
|
* Adds soft line breaks to a Quoted-Printable string
|
|
47
39
|
*
|
|
48
|
-
* @param
|
|
49
|
-
* @param
|
|
50
|
-
* @returns
|
|
40
|
+
* @param str Quoted-Printable encoded string that might need line wrapping
|
|
41
|
+
* @param [lineLength=76] Maximum allowed length for a line
|
|
42
|
+
* @returns Soft-wrapped Quoted-Printable encoded string
|
|
51
43
|
*/
|
|
52
|
-
function wrap(str, lineLength) {
|
|
44
|
+
export function wrap(str, lineLength) {
|
|
53
45
|
str = (str || '').toString();
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
// a line has to hold a complete =XX sequence plus the soft break, shorter lengths
|
|
47
|
+
// (or a negative one) would loop without consuming input
|
|
48
|
+
lineLength = Math.max(Number(lineLength) || 76, MIN_LINE_LENGTH);
|
|
56
49
|
if (str.length <= lineLength) {
|
|
57
50
|
return str;
|
|
58
51
|
}
|
|
59
|
-
|
|
60
52
|
let pos = 0;
|
|
61
53
|
const len = str.length;
|
|
62
54
|
let match, code, line;
|
|
63
55
|
const lineMargin = Math.floor(lineLength / 3);
|
|
64
56
|
let result = '';
|
|
65
|
-
|
|
66
57
|
// insert soft linebreaks where needed
|
|
67
58
|
while (pos < len) {
|
|
68
59
|
line = str.substr(pos, lineLength);
|
|
@@ -72,13 +63,11 @@ function wrap(str, lineLength) {
|
|
|
72
63
|
pos += line.length;
|
|
73
64
|
continue;
|
|
74
65
|
}
|
|
75
|
-
|
|
76
66
|
if (line.substr(-1) === '\n') {
|
|
77
67
|
result += line;
|
|
78
68
|
pos += line.length;
|
|
79
69
|
continue;
|
|
80
70
|
}
|
|
81
|
-
|
|
82
71
|
if ((match = line.substr(-lineMargin).match(/\n.*?$/))) {
|
|
83
72
|
// truncate to nearest line break
|
|
84
73
|
line = line.substr(0, line.length - (match[0].length - 1));
|
|
@@ -86,60 +75,58 @@ function wrap(str, lineLength) {
|
|
|
86
75
|
pos += line.length;
|
|
87
76
|
continue;
|
|
88
77
|
}
|
|
89
|
-
|
|
90
78
|
if (line.length > lineLength - lineMargin && (match = line.substr(-lineMargin).match(/[ \t.,!?][^ \t.,!?]*$/))) {
|
|
91
79
|
// truncate to nearest space
|
|
92
80
|
line = line.substr(0, line.length - (match[0].length - 1));
|
|
93
|
-
}
|
|
81
|
+
}
|
|
82
|
+
else if (line.match(/[=][\da-f]{0,2}$/i)) {
|
|
94
83
|
// push incomplete encoding sequences to the next line
|
|
95
84
|
if ((match = line.match(/[=][\da-f]{0,1}$/i))) {
|
|
96
85
|
line = line.substr(0, line.length - match[0].length);
|
|
97
86
|
}
|
|
98
|
-
|
|
99
87
|
// ensure that utf-8 sequences are not split
|
|
100
|
-
while (
|
|
101
|
-
line.length > 3 &&
|
|
88
|
+
while (line.length > 3 &&
|
|
102
89
|
line.length < len - pos &&
|
|
103
90
|
!line.match(/^(?:=[\da-f]{2}){1,4}$/i) &&
|
|
104
|
-
(match = line.match(/[=][\da-f]{2}$/gi))
|
|
105
|
-
) {
|
|
91
|
+
(match = line.match(/[=][\da-f]{2}$/gi))) {
|
|
106
92
|
code = parseInt(match[0].substr(1, 2), 16);
|
|
107
93
|
if (code < 128) {
|
|
108
94
|
break;
|
|
109
95
|
}
|
|
110
|
-
|
|
111
96
|
line = line.substr(0, line.length - 3);
|
|
112
|
-
|
|
113
97
|
if (code >= 0xc0) {
|
|
114
98
|
break;
|
|
115
99
|
}
|
|
116
100
|
}
|
|
117
101
|
}
|
|
118
|
-
|
|
102
|
+
if (!line.length) {
|
|
103
|
+
// the trimming above emptied the line, which only happens for an incomplete
|
|
104
|
+
// escape at the very end of the input. Take it as is rather than loop on it
|
|
105
|
+
line = str.substr(pos, lineLength);
|
|
106
|
+
}
|
|
119
107
|
if (pos + line.length < len && line.substr(-1) !== '\n') {
|
|
120
108
|
if (line.length === lineLength && line.match(/[=][\da-f]{2}$/i)) {
|
|
121
109
|
line = line.substr(0, line.length - 3);
|
|
122
|
-
}
|
|
110
|
+
}
|
|
111
|
+
else if (line.length === lineLength) {
|
|
123
112
|
line = line.substr(0, line.length - 1);
|
|
124
113
|
}
|
|
125
114
|
pos += line.length;
|
|
126
115
|
line += '=\r\n';
|
|
127
|
-
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
128
118
|
pos += line.length;
|
|
129
119
|
}
|
|
130
|
-
|
|
131
120
|
result += line;
|
|
132
121
|
}
|
|
133
|
-
|
|
134
122
|
return result;
|
|
135
123
|
}
|
|
136
|
-
|
|
137
124
|
/**
|
|
138
125
|
* Helper function to check if a number is inside provided ranges
|
|
139
126
|
*
|
|
140
|
-
* @param
|
|
141
|
-
* @param
|
|
142
|
-
* @returns
|
|
127
|
+
* @param nr Number to check for
|
|
128
|
+
* @param ranges An Array of allowed values
|
|
129
|
+
* @returns True if the value was found inside allowed ranges, false otherwise
|
|
143
130
|
*/
|
|
144
131
|
function checkRanges(nr, ranges) {
|
|
145
132
|
for (let i = ranges.length - 1; i >= 0; i--) {
|
|
@@ -156,43 +143,34 @@ function checkRanges(nr, ranges) {
|
|
|
156
143
|
}
|
|
157
144
|
return false;
|
|
158
145
|
}
|
|
159
|
-
|
|
160
146
|
/**
|
|
161
147
|
* Creates a transform stream for encoding data to Quoted-Printable encoding
|
|
162
148
|
*
|
|
163
149
|
* @constructor
|
|
164
|
-
* @param
|
|
165
|
-
* @param
|
|
150
|
+
* @param options Stream options
|
|
151
|
+
* @param [options.lineLength=76] Maximum length for lines, set to false to disable wrapping
|
|
166
152
|
*/
|
|
167
|
-
class Encoder extends Transform {
|
|
153
|
+
export class Encoder extends Transform {
|
|
168
154
|
constructor(options) {
|
|
169
155
|
super();
|
|
170
|
-
|
|
171
156
|
this.options = options || {};
|
|
172
|
-
|
|
173
157
|
if (this.options.lineLength !== false) {
|
|
174
158
|
this.options.lineLength = this.options.lineLength || 76;
|
|
175
159
|
}
|
|
176
|
-
|
|
177
160
|
this._curLine = '';
|
|
178
|
-
|
|
179
161
|
this.inputBytes = 0;
|
|
180
162
|
this.outputBytes = 0;
|
|
181
163
|
}
|
|
182
|
-
|
|
164
|
+
/** @internal */
|
|
183
165
|
_transform(chunk, encoding, done) {
|
|
184
166
|
let qp;
|
|
185
|
-
|
|
186
167
|
if (encoding !== 'buffer') {
|
|
187
168
|
chunk = Buffer.from(chunk, encoding);
|
|
188
169
|
}
|
|
189
|
-
|
|
190
170
|
if (!chunk || !chunk.length) {
|
|
191
171
|
return done();
|
|
192
172
|
}
|
|
193
|
-
|
|
194
173
|
this.inputBytes += chunk.length;
|
|
195
|
-
|
|
196
174
|
if (this.options.lineLength) {
|
|
197
175
|
qp = this._curLine + encode(chunk);
|
|
198
176
|
qp = wrap(qp, this.options.lineLength);
|
|
@@ -200,20 +178,19 @@ class Encoder extends Transform {
|
|
|
200
178
|
this._curLine = lastLine;
|
|
201
179
|
return lineBreak;
|
|
202
180
|
});
|
|
203
|
-
|
|
204
181
|
if (qp) {
|
|
205
182
|
this.outputBytes += qp.length;
|
|
206
183
|
this.push(qp);
|
|
207
184
|
}
|
|
208
|
-
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
209
187
|
qp = encode(chunk);
|
|
210
188
|
this.outputBytes += qp.length;
|
|
211
189
|
this.push(qp, 'ascii');
|
|
212
190
|
}
|
|
213
|
-
|
|
214
191
|
done();
|
|
215
192
|
}
|
|
216
|
-
|
|
193
|
+
/** @internal */
|
|
217
194
|
_flush(done) {
|
|
218
195
|
if (this._curLine) {
|
|
219
196
|
this.outputBytes += this._curLine.length;
|
|
@@ -222,9 +199,3 @@ class Encoder extends Transform {
|
|
|
222
199
|
done();
|
|
223
200
|
}
|
|
224
201
|
}
|
|
225
|
-
|
|
226
|
-
module.exports = {
|
|
227
|
-
encode,
|
|
228
|
-
wrap,
|
|
229
|
-
Encoder
|
|
230
|
-
};
|