@nocobase/plugin-workflow-mailer 2.3.0-beta.9 → 2.4.0-alpha.10
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/dist/joi-browser.min.js +1 -1
- package/dist/node_modules/joi/lib/index.js +1 -1
- package/dist/node_modules/joi/lib/messages.js +35 -6
- package/dist/node_modules/joi/lib/types/keys.js +18 -1
- package/dist/node_modules/joi/lib/types/link.js +18 -2
- package/dist/node_modules/joi/lib/types/string.js +2 -2
- 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 +63 -112
- 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/dist/esm/addressparser/index.js +786 -0
- package/dist/node_modules/nodemailer/dist/esm/base64/index.d.ts +36 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/base64/index.js +39 -68
- package/dist/node_modules/nodemailer/dist/esm/dkim/index.d.ts +52 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/index.js +62 -92
- package/dist/node_modules/nodemailer/dist/esm/dkim/message-parser.d.ts +48 -0
- package/dist/node_modules/nodemailer/dist/esm/dkim/message-parser.js +176 -0
- 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/dist/esm/dkim/sign.js +125 -0
- package/dist/node_modules/nodemailer/dist/esm/errors.d.ts +96 -0
- package/dist/node_modules/nodemailer/dist/esm/errors.js +67 -0
- 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/dist/esm/fetch/index.js +344 -0
- package/dist/node_modules/nodemailer/dist/esm/json-transport/index.d.ts +64 -0
- package/dist/node_modules/nodemailer/dist/esm/json-transport/index.js +62 -0
- 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 +283 -275
- package/dist/node_modules/nodemailer/dist/esm/mailer/index.d.ts +237 -0
- package/dist/node_modules/nodemailer/{lib → dist/esm}/mailer/index.js +151 -205
- 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 +111 -125
- 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 +43 -49
- 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 +576 -437
- 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 +7 -15
- 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 -16
- 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 +59 -77
- package/dist/node_modules/nodemailer/dist/esm/sendmail-transport/index.d.ts +69 -0
- package/dist/node_modules/nodemailer/dist/esm/sendmail-transport/index.js +170 -0
- 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/dist/esm/shared/index.js +631 -0
- package/dist/node_modules/nodemailer/dist/esm/shared/objects.d.ts +23 -0
- package/dist/node_modules/nodemailer/dist/esm/shared/objects.js +38 -0
- 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/dist/esm/smtp-connection/http-proxy-client.js +149 -0
- package/dist/node_modules/nodemailer/dist/esm/smtp-connection/index.d.ts +416 -0
- package/dist/node_modules/nodemailer/dist/esm/smtp-connection/index.js +1797 -0
- 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 +195 -314
- 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 +70 -107
- package/dist/node_modules/nodemailer/dist/esm/smtp-transport/index.d.ts +156 -0
- package/dist/node_modules/nodemailer/dist/esm/smtp-transport/index.js +331 -0
- package/dist/node_modules/nodemailer/dist/esm/stream-transport/index.d.ts +65 -0
- package/dist/node_modules/nodemailer/dist/esm/stream-transport/index.js +106 -0
- 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 +12 -23
- 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/dist/esm/xoauth2/index.js +386 -0
- package/dist/node_modules/nodemailer/dist/well-known/services.json +640 -0
- package/dist/node_modules/nodemailer/package.json +1 -1
- package/package.json +4 -4
- package/dist/node_modules/nodemailer/.gitattributes +0 -6
- package/dist/node_modules/nodemailer/.ncurc.js +0 -7
- package/dist/node_modules/nodemailer/.prettierrc.js +0 -8
- package/dist/node_modules/nodemailer/lib/addressparser/index.js +0 -313
- package/dist/node_modules/nodemailer/lib/dkim/message-parser.js +0 -155
- package/dist/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
- package/dist/node_modules/nodemailer/lib/dkim/sign.js +0 -117
- package/dist/node_modules/nodemailer/lib/fetch/cookies.js +0 -281
- package/dist/node_modules/nodemailer/lib/fetch/index.js +0 -274
- package/dist/node_modules/nodemailer/lib/json-transport/index.js +0 -82
- package/dist/node_modules/nodemailer/lib/mime-funcs/index.js +0 -625
- package/dist/node_modules/nodemailer/lib/nodemailer.js +0 -1
- package/dist/node_modules/nodemailer/lib/sendmail-transport/index.js +0 -210
- package/dist/node_modules/nodemailer/lib/ses-transport/index.js +0 -349
- package/dist/node_modules/nodemailer/lib/shared/index.js +0 -688
- package/dist/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -108
- package/dist/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +0 -143
- package/dist/node_modules/nodemailer/lib/smtp-connection/index.js +0 -1825
- package/dist/node_modules/nodemailer/lib/smtp-transport/index.js +0 -416
- package/dist/node_modules/nodemailer/lib/stream-transport/index.js +0 -135
- package/dist/node_modules/nodemailer/lib/well-known/services.json +0 -343
- package/dist/node_modules/nodemailer/lib/xoauth2/index.js +0 -376
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Transform } from 'node:stream';
|
|
2
|
+
/**
|
|
3
|
+
* Encodes a Buffer into a base64 encoded string
|
|
4
|
+
*
|
|
5
|
+
* @param buffer Buffer to convert
|
|
6
|
+
* @returns base64 encoded string
|
|
7
|
+
*/
|
|
8
|
+
export declare function encode(buffer: Buffer | string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Adds soft line breaks to a base64 string
|
|
11
|
+
*
|
|
12
|
+
* @param str base64 encoded string that might need line wrapping
|
|
13
|
+
* @param [lineLength=76] Maximum allowed length for a line
|
|
14
|
+
* @returns Soft-wrapped base64 encoded string
|
|
15
|
+
*/
|
|
16
|
+
export declare function wrap(str: string, lineLength?: number | false): string;
|
|
17
|
+
/**
|
|
18
|
+
* Options for the base64 encoder stream
|
|
19
|
+
*/
|
|
20
|
+
export interface EncoderOptions {
|
|
21
|
+
/** Maximum length for lines, set to false to disable wrapping */
|
|
22
|
+
lineLength?: number | false | undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a transform stream for encoding data to base64 encoding
|
|
26
|
+
*
|
|
27
|
+
* @constructor
|
|
28
|
+
* @param options Stream options
|
|
29
|
+
* @param [options.lineLength=76] Maximum length for lines, set to false to disable wrapping
|
|
30
|
+
*/
|
|
31
|
+
export declare class Encoder extends Transform {
|
|
32
|
+
options: EncoderOptions;
|
|
33
|
+
inputBytes: number;
|
|
34
|
+
outputBytes: number;
|
|
35
|
+
constructor(options?: EncoderOptions);
|
|
36
|
+
}
|
|
@@ -1,142 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const Transform = require('stream').Transform;
|
|
4
|
-
|
|
1
|
+
import { Transform } from 'node:stream';
|
|
5
2
|
/**
|
|
6
3
|
* Encodes a Buffer into a base64 encoded string
|
|
7
4
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @returns
|
|
5
|
+
* @param buffer Buffer to convert
|
|
6
|
+
* @returns base64 encoded string
|
|
10
7
|
*/
|
|
11
|
-
function encode(buffer) {
|
|
8
|
+
export function encode(buffer) {
|
|
12
9
|
if (typeof buffer === 'string') {
|
|
13
10
|
buffer = Buffer.from(buffer, 'utf-8');
|
|
14
11
|
}
|
|
15
|
-
|
|
16
12
|
return buffer.toString('base64');
|
|
17
13
|
}
|
|
18
|
-
|
|
19
14
|
/**
|
|
20
15
|
* Adds soft line breaks to a base64 string
|
|
21
16
|
*
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
24
|
-
* @returns
|
|
17
|
+
* @param str base64 encoded string that might need line wrapping
|
|
18
|
+
* @param [lineLength=76] Maximum allowed length for a line
|
|
19
|
+
* @returns Soft-wrapped base64 encoded string
|
|
25
20
|
*/
|
|
26
|
-
function wrap(str, lineLength) {
|
|
21
|
+
export function wrap(str, lineLength) {
|
|
27
22
|
str = (str || '').toString();
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
// a negative length would step backwards through the input and never finish
|
|
24
|
+
lineLength = Math.max(Number(lineLength) || 76, 1);
|
|
30
25
|
if (str.length <= lineLength) {
|
|
31
26
|
return str;
|
|
32
27
|
}
|
|
33
|
-
|
|
34
|
-
let result = [];
|
|
28
|
+
const result = [];
|
|
35
29
|
let pos = 0;
|
|
36
|
-
|
|
30
|
+
const chunkLength = lineLength * 1024;
|
|
31
|
+
const wrapRegex = new RegExp('.{' + lineLength + '}', 'g');
|
|
37
32
|
while (pos < str.length) {
|
|
38
|
-
|
|
39
|
-
.substr(pos, chunkLength)
|
|
40
|
-
.replace(new RegExp('.{' + lineLength + '}', 'g'), '$&\r\n')
|
|
41
|
-
.trim();
|
|
33
|
+
const wrappedLines = str.substr(pos, chunkLength).replace(wrapRegex, '$&\r\n').trim();
|
|
42
34
|
result.push(wrappedLines);
|
|
43
35
|
pos += chunkLength;
|
|
44
36
|
}
|
|
45
|
-
|
|
46
37
|
return result.join('\r\n').trim();
|
|
47
38
|
}
|
|
48
|
-
|
|
49
39
|
/**
|
|
50
40
|
* Creates a transform stream for encoding data to base64 encoding
|
|
51
41
|
*
|
|
52
42
|
* @constructor
|
|
53
|
-
* @param
|
|
54
|
-
* @param
|
|
43
|
+
* @param options Stream options
|
|
44
|
+
* @param [options.lineLength=76] Maximum length for lines, set to false to disable wrapping
|
|
55
45
|
*/
|
|
56
|
-
class Encoder extends Transform {
|
|
46
|
+
export class Encoder extends Transform {
|
|
57
47
|
constructor(options) {
|
|
58
48
|
super();
|
|
59
|
-
// init Transform
|
|
60
49
|
this.options = options || {};
|
|
61
|
-
|
|
62
50
|
if (this.options.lineLength !== false) {
|
|
63
51
|
this.options.lineLength = this.options.lineLength || 76;
|
|
64
52
|
}
|
|
65
|
-
|
|
66
53
|
this._curLine = '';
|
|
67
54
|
this._remainingBytes = false;
|
|
68
|
-
|
|
69
55
|
this.inputBytes = 0;
|
|
70
56
|
this.outputBytes = 0;
|
|
71
57
|
}
|
|
72
|
-
|
|
58
|
+
/** @internal */
|
|
73
59
|
_transform(chunk, encoding, done) {
|
|
74
|
-
|
|
75
|
-
|
|
60
|
+
let buf = encoding !== 'buffer' ? Buffer.from(chunk, encoding) : chunk;
|
|
61
|
+
if (!buf || !buf.length) {
|
|
62
|
+
setImmediate(done);
|
|
63
|
+
return;
|
|
76
64
|
}
|
|
77
|
-
|
|
78
|
-
if (!chunk || !chunk.length) {
|
|
79
|
-
return setImmediate(done);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
this.inputBytes += chunk.length;
|
|
83
|
-
|
|
65
|
+
this.inputBytes += buf.length;
|
|
84
66
|
if (this._remainingBytes && this._remainingBytes.length) {
|
|
85
|
-
|
|
67
|
+
buf = Buffer.concat([this._remainingBytes, buf], this._remainingBytes.length + buf.length);
|
|
86
68
|
this._remainingBytes = false;
|
|
87
69
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
70
|
+
if (buf.length % 3) {
|
|
71
|
+
this._remainingBytes = buf.slice(buf.length - (buf.length % 3));
|
|
72
|
+
buf = buf.slice(0, buf.length - (buf.length % 3));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
93
75
|
this._remainingBytes = false;
|
|
94
76
|
}
|
|
95
|
-
|
|
96
|
-
let b64 = this._curLine + encode(chunk);
|
|
97
|
-
|
|
77
|
+
let b64 = this._curLine + encode(buf);
|
|
98
78
|
if (this.options.lineLength) {
|
|
99
79
|
b64 = wrap(b64, this.options.lineLength);
|
|
100
|
-
|
|
101
80
|
// remove last line as it is still most probably incomplete
|
|
102
|
-
|
|
81
|
+
const lastLF = b64.lastIndexOf('\n');
|
|
103
82
|
if (lastLF < 0) {
|
|
104
83
|
this._curLine = b64;
|
|
105
84
|
b64 = '';
|
|
106
|
-
}
|
|
85
|
+
}
|
|
86
|
+
else if (lastLF === b64.length - 1) {
|
|
107
87
|
this._curLine = '';
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
this._curLine = b64.substring(lastLF + 1);
|
|
91
|
+
b64 = b64.substring(0, lastLF + 1);
|
|
111
92
|
}
|
|
112
93
|
}
|
|
113
|
-
|
|
114
94
|
if (b64) {
|
|
115
95
|
this.outputBytes += b64.length;
|
|
116
96
|
this.push(Buffer.from(b64, 'ascii'));
|
|
117
97
|
}
|
|
118
|
-
|
|
119
98
|
setImmediate(done);
|
|
120
99
|
}
|
|
121
|
-
|
|
100
|
+
/** @internal */
|
|
122
101
|
_flush(done) {
|
|
123
102
|
if (this._remainingBytes && this._remainingBytes.length) {
|
|
124
103
|
this._curLine += encode(this._remainingBytes);
|
|
125
104
|
}
|
|
126
|
-
|
|
127
105
|
if (this._curLine) {
|
|
128
106
|
this._curLine = wrap(this._curLine, this.options.lineLength);
|
|
129
107
|
this.outputBytes += this._curLine.length;
|
|
130
|
-
this.push(this._curLine, 'ascii');
|
|
108
|
+
this.push(Buffer.from(this._curLine, 'ascii'));
|
|
131
109
|
this._curLine = '';
|
|
132
110
|
}
|
|
133
111
|
done();
|
|
134
112
|
}
|
|
135
113
|
}
|
|
136
|
-
|
|
137
|
-
// expose to the world
|
|
138
|
-
module.exports = {
|
|
139
|
-
encode,
|
|
140
|
-
wrap,
|
|
141
|
-
Encoder
|
|
142
|
-
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type DKIMKey, type DKIMPrivateKey, type DKIMSignOptions } from './sign.js';
|
|
2
|
+
import { PassThrough, type Readable } from 'node:stream';
|
|
3
|
+
/**
|
|
4
|
+
* A single DKIM signing key
|
|
5
|
+
*/
|
|
6
|
+
export type { DKIMKey, DKIMPrivateKey, DKIMSignOptions };
|
|
7
|
+
/**
|
|
8
|
+
* Options for the DKIM signer
|
|
9
|
+
*/
|
|
10
|
+
export interface DKIMOptions extends DKIMSignOptions {
|
|
11
|
+
/** One or more signing keys, used instead of the domainName, keySelector and privateKey options */
|
|
12
|
+
keys?: DKIMKey | DKIMKey[] | undefined;
|
|
13
|
+
/** Directory for buffering large message bodies to disk, no buffering when not set */
|
|
14
|
+
cacheDir?: string | false | undefined;
|
|
15
|
+
/** Body size in bytes from which the body is buffered to cacheDir, defaults to 10 MB */
|
|
16
|
+
cacheTreshold?: number | undefined;
|
|
17
|
+
/** Hash algorithm for the body hash and the signature, defaults to sha256 */
|
|
18
|
+
hashAlgo?: string | undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The signed message as returned by DKIM#sign
|
|
22
|
+
*/
|
|
23
|
+
export interface DKIMSignedStream extends PassThrough {
|
|
24
|
+
/** true if the message body was buffered to cacheDir while signing */
|
|
25
|
+
usingCache: boolean;
|
|
26
|
+
}
|
|
27
|
+
declare class DKIM {
|
|
28
|
+
options: DKIMOptions;
|
|
29
|
+
keys: DKIMKey[];
|
|
30
|
+
constructor(options: DKIMOptions);
|
|
31
|
+
sign(input: Readable | Buffer | string, extraOptions?: DKIMOptions): DKIMSignedStream;
|
|
32
|
+
}
|
|
33
|
+
/** The signer options without any key material */
|
|
34
|
+
export type DKIMOptionalOptions = Omit<DKIMOptions, 'keys' | 'domainName' | 'keySelector' | 'privateKey'>;
|
|
35
|
+
/** The signer options for a single key given as domainName, keySelector and privateKey */
|
|
36
|
+
export type DKIMSingleKeyOptions = Omit<DKIMOptions, 'keys'>;
|
|
37
|
+
/** The signer options for one or more keys given through `keys` */
|
|
38
|
+
export type DKIMMultipleKeysOptions = DKIMOptionalOptions & {
|
|
39
|
+
keys: DKIMKey | DKIMKey[];
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Type aliases in the layout of @types/nodemailer, so `DKIM.Options` style references keep working
|
|
43
|
+
*/
|
|
44
|
+
declare namespace DKIM {
|
|
45
|
+
type Options = DKIMOptions;
|
|
46
|
+
type OptionalOptions = DKIMOptionalOptions;
|
|
47
|
+
type SingleKeyOptions = DKIMSingleKeyOptions;
|
|
48
|
+
type MultipleKeysOptions = DKIMMultipleKeysOptions;
|
|
49
|
+
}
|
|
50
|
+
/** The same aliases as module level exports, for `import * as DKIM` and `import DKIM = require()` */
|
|
51
|
+
export type { DKIMOptions as Options, DKIMOptionalOptions as OptionalOptions, DKIMSingleKeyOptions as SingleKeyOptions, DKIMMultipleKeysOptions as MultipleKeysOptions };
|
|
52
|
+
export default DKIM;
|
|
@@ -1,75 +1,49 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
// FIXME:
|
|
4
2
|
// replace this Transform mess with a method that pipes input argument to output argument
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
import MessageParser from './message-parser.js';
|
|
4
|
+
import RelaxedBody from './relaxed-body.js';
|
|
5
|
+
import sign from './sign.js';
|
|
6
|
+
import { PassThrough } from 'node:stream';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import crypto from 'node:crypto';
|
|
10
|
+
import { copyOwnKeys } from '../shared/objects.js';
|
|
14
11
|
const DKIM_ALGO = 'sha256';
|
|
15
|
-
const MAX_MESSAGE_SIZE =
|
|
16
|
-
|
|
17
|
-
/*
|
|
18
|
-
// Usage:
|
|
19
|
-
|
|
20
|
-
let dkim = new DKIM({
|
|
21
|
-
domainName: 'example.com',
|
|
22
|
-
keySelector: 'key-selector',
|
|
23
|
-
privateKey,
|
|
24
|
-
cacheDir: '/tmp'
|
|
25
|
-
});
|
|
26
|
-
dkim.sign(input).pipe(process.stdout);
|
|
27
|
-
|
|
28
|
-
// Where inputStream is a rfc822 message (either a stream, string or Buffer)
|
|
29
|
-
// and outputStream is a DKIM signed rfc822 message
|
|
30
|
-
*/
|
|
31
|
-
|
|
12
|
+
const MAX_MESSAGE_SIZE = 10 * 1024 * 1024; // buffer messages larger than this to disk
|
|
32
13
|
class DKIMSigner {
|
|
33
14
|
constructor(options, keys, input, output) {
|
|
34
15
|
this.options = options || {};
|
|
35
16
|
this.keys = keys;
|
|
36
|
-
|
|
37
17
|
this.cacheTreshold = Number(this.options.cacheTreshold) || MAX_MESSAGE_SIZE;
|
|
38
18
|
this.hashAlgo = this.options.hashAlgo || DKIM_ALGO;
|
|
39
|
-
|
|
40
19
|
this.cacheDir = this.options.cacheDir || false;
|
|
41
|
-
|
|
42
20
|
this.chunks = [];
|
|
43
21
|
this.chunklen = 0;
|
|
44
22
|
this.readPos = 0;
|
|
45
|
-
this.cachePath = this.cacheDir
|
|
23
|
+
this.cachePath = this.cacheDir
|
|
24
|
+
? path.join(this.cacheDir, 'message.' + Date.now() + '-' + crypto.randomBytes(14).toString('hex'))
|
|
25
|
+
: false;
|
|
46
26
|
this.cache = false;
|
|
47
|
-
|
|
48
27
|
this.headers = false;
|
|
49
28
|
this.bodyHash = false;
|
|
50
29
|
this.parser = false;
|
|
51
30
|
this.relaxedBody = false;
|
|
52
|
-
|
|
53
31
|
this.input = input;
|
|
54
32
|
this.output = output;
|
|
55
33
|
this.output.usingCache = false;
|
|
56
|
-
|
|
57
34
|
this.hasErrored = false;
|
|
58
|
-
|
|
59
35
|
this.input.on('error', err => {
|
|
60
36
|
this.hasErrored = true;
|
|
61
37
|
this.cleanup();
|
|
62
38
|
output.emit('error', err);
|
|
63
39
|
});
|
|
64
40
|
}
|
|
65
|
-
|
|
66
41
|
cleanup() {
|
|
67
42
|
if (!this.cache || !this.cachePath) {
|
|
68
43
|
return;
|
|
69
44
|
}
|
|
70
45
|
fs.unlink(this.cachePath, () => false);
|
|
71
46
|
}
|
|
72
|
-
|
|
73
47
|
createReadCache() {
|
|
74
48
|
// pipe remainings to cache file
|
|
75
49
|
this.cache = fs.createReadStream(this.cachePath);
|
|
@@ -82,56 +56,62 @@ class DKIMSigner {
|
|
|
82
56
|
});
|
|
83
57
|
this.cache.pipe(this.output);
|
|
84
58
|
}
|
|
85
|
-
|
|
86
59
|
sendNextChunk() {
|
|
87
60
|
if (this.hasErrored) {
|
|
88
61
|
return;
|
|
89
62
|
}
|
|
90
|
-
|
|
91
63
|
if (this.readPos >= this.chunks.length) {
|
|
92
64
|
if (!this.cache) {
|
|
93
|
-
|
|
65
|
+
this.output.end();
|
|
66
|
+
return;
|
|
94
67
|
}
|
|
95
68
|
return this.createReadCache();
|
|
96
69
|
}
|
|
97
|
-
|
|
70
|
+
const chunk = this.chunks[this.readPos++];
|
|
98
71
|
if (this.output.write(chunk) === false) {
|
|
99
|
-
|
|
72
|
+
this.output.once('drain', () => {
|
|
100
73
|
this.sendNextChunk();
|
|
101
74
|
});
|
|
75
|
+
return;
|
|
102
76
|
}
|
|
103
77
|
setImmediate(() => this.sendNextChunk());
|
|
104
78
|
}
|
|
105
|
-
|
|
106
79
|
sendSignedOutput() {
|
|
107
80
|
let keyPos = 0;
|
|
108
|
-
|
|
81
|
+
const signNextKey = () => {
|
|
109
82
|
if (keyPos >= this.keys.length) {
|
|
110
83
|
this.output.write(this.parser.rawHeaders);
|
|
111
|
-
|
|
84
|
+
setImmediate(() => this.sendNextChunk());
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const key = this.keys[keyPos++];
|
|
88
|
+
let dkimField;
|
|
89
|
+
try {
|
|
90
|
+
dkimField = sign(this.headers, this.hashAlgo, this.bodyHash, {
|
|
91
|
+
domainName: key.domainName,
|
|
92
|
+
keySelector: key.keySelector,
|
|
93
|
+
privateKey: key.privateKey,
|
|
94
|
+
headerFieldNames: this.options.headerFieldNames,
|
|
95
|
+
skipFields: this.options.skipFields
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
this.hasErrored = true;
|
|
100
|
+
this.cleanup();
|
|
101
|
+
this.output.emit('error', err);
|
|
102
|
+
return;
|
|
112
103
|
}
|
|
113
|
-
let key = this.keys[keyPos++];
|
|
114
|
-
let dkimField = sign(this.headers, this.hashAlgo, this.bodyHash, {
|
|
115
|
-
domainName: key.domainName,
|
|
116
|
-
keySelector: key.keySelector,
|
|
117
|
-
privateKey: key.privateKey,
|
|
118
|
-
headerFieldNames: this.options.headerFieldNames,
|
|
119
|
-
skipFields: this.options.skipFields
|
|
120
|
-
});
|
|
121
104
|
if (dkimField) {
|
|
122
105
|
this.output.write(Buffer.from(dkimField + '\r\n'));
|
|
123
106
|
}
|
|
124
|
-
|
|
107
|
+
setImmediate(signNextKey);
|
|
125
108
|
};
|
|
126
|
-
|
|
127
109
|
if (this.bodyHash && this.headers) {
|
|
128
110
|
return signNextKey();
|
|
129
111
|
}
|
|
130
|
-
|
|
131
112
|
this.output.write(this.parser.rawHeaders);
|
|
132
113
|
this.sendNextChunk();
|
|
133
114
|
}
|
|
134
|
-
|
|
135
115
|
createWriteCache() {
|
|
136
116
|
this.output.usingCache = true;
|
|
137
117
|
// pipe remainings to cache file
|
|
@@ -155,21 +135,17 @@ class DKIMSigner {
|
|
|
155
135
|
this.relaxedBody.removeAllListeners('readable');
|
|
156
136
|
this.relaxedBody.pipe(this.cache);
|
|
157
137
|
}
|
|
158
|
-
|
|
159
138
|
signStream() {
|
|
160
139
|
this.parser = new MessageParser();
|
|
161
140
|
this.relaxedBody = new RelaxedBody({
|
|
162
141
|
hashAlgo: this.hashAlgo
|
|
163
142
|
});
|
|
164
|
-
|
|
165
143
|
this.parser.on('headers', value => {
|
|
166
144
|
this.headers = value;
|
|
167
145
|
});
|
|
168
|
-
|
|
169
146
|
this.relaxedBody.on('hash', value => {
|
|
170
147
|
this.bodyHash = value;
|
|
171
148
|
});
|
|
172
|
-
|
|
173
149
|
this.relaxedBody.on('readable', () => {
|
|
174
150
|
let chunk;
|
|
175
151
|
if (this.cache) {
|
|
@@ -183,69 +159,63 @@ class DKIMSigner {
|
|
|
183
159
|
}
|
|
184
160
|
}
|
|
185
161
|
});
|
|
186
|
-
|
|
187
162
|
this.relaxedBody.on('end', () => {
|
|
188
163
|
if (this.cache) {
|
|
189
164
|
return;
|
|
190
165
|
}
|
|
191
166
|
this.sendSignedOutput();
|
|
192
167
|
});
|
|
193
|
-
|
|
194
168
|
this.parser.pipe(this.relaxedBody);
|
|
195
169
|
setImmediate(() => this.input.pipe(this.parser));
|
|
196
170
|
}
|
|
197
171
|
}
|
|
198
|
-
|
|
199
172
|
class DKIM {
|
|
200
173
|
constructor(options) {
|
|
201
174
|
this.options = options || {};
|
|
202
|
-
this.keys = [].concat(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
);
|
|
175
|
+
this.keys = [].concat(this.options.keys || {
|
|
176
|
+
domainName: options.domainName,
|
|
177
|
+
keySelector: options.keySelector,
|
|
178
|
+
privateKey: options.privateKey
|
|
179
|
+
});
|
|
209
180
|
}
|
|
210
|
-
|
|
211
181
|
sign(input, extraOptions) {
|
|
212
|
-
|
|
182
|
+
const output = new PassThrough();
|
|
213
183
|
let inputStream = input;
|
|
214
184
|
let writeValue = false;
|
|
215
|
-
|
|
216
185
|
if (Buffer.isBuffer(input)) {
|
|
217
186
|
writeValue = input;
|
|
218
187
|
inputStream = new PassThrough();
|
|
219
|
-
}
|
|
188
|
+
}
|
|
189
|
+
else if (typeof input === 'string') {
|
|
220
190
|
writeValue = Buffer.from(input);
|
|
221
191
|
inputStream = new PassThrough();
|
|
222
192
|
}
|
|
223
|
-
|
|
224
193
|
let options = this.options;
|
|
225
194
|
if (extraOptions && Object.keys(extraOptions).length) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
if (!(key in options)) {
|
|
232
|
-
options[key] = extraOptions[key];
|
|
233
|
-
}
|
|
234
|
-
});
|
|
195
|
+
// extraOptions is mail.data._dkim, caller supplied message data. An own
|
|
196
|
+
// "__proto__" key there would let every option this signer reads and the
|
|
197
|
+
// transport did not set, such as skipFields, answer from the caller
|
|
198
|
+
options = copyOwnKeys({}, extraOptions);
|
|
199
|
+
copyOwnKeys(options, this.options);
|
|
235
200
|
}
|
|
236
|
-
|
|
237
|
-
let signer = new DKIMSigner(options, this.keys, inputStream, output);
|
|
201
|
+
const signer = new DKIMSigner(options, this.keys, inputStream, output);
|
|
238
202
|
setImmediate(() => {
|
|
239
|
-
|
|
203
|
+
try {
|
|
204
|
+
signer.signStream();
|
|
205
|
+
}
|
|
206
|
+
catch (_E) {
|
|
207
|
+
// the body hash is created here, an unknown hashAlgo throws inside this timer
|
|
208
|
+
// where nothing else could catch it
|
|
209
|
+
output.emit('error', sign.unsupportedHashAlgoError(signer.hashAlgo));
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
240
212
|
if (writeValue) {
|
|
241
213
|
setImmediate(() => {
|
|
242
214
|
inputStream.end(writeValue);
|
|
243
215
|
});
|
|
244
216
|
}
|
|
245
217
|
});
|
|
246
|
-
|
|
247
218
|
return output;
|
|
248
219
|
}
|
|
249
220
|
}
|
|
250
|
-
|
|
251
|
-
module.exports = DKIM;
|
|
221
|
+
export default DKIM;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Transform, type TransformOptions } from 'node:stream';
|
|
2
|
+
/**
|
|
3
|
+
* A header line as emitted with the 'headers' event
|
|
4
|
+
*/
|
|
5
|
+
export interface MessageParserHeaderLine {
|
|
6
|
+
/** Lowercase header field name */
|
|
7
|
+
key: string;
|
|
8
|
+
/** Full header line, folded continuation lines included, one character per byte ('binary' encoding) */
|
|
9
|
+
line: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* MessageParser instance is a transform stream that separates message headers
|
|
13
|
+
* from the rest of the body. Headers are emitted with the 'headers' event. Message
|
|
14
|
+
* body is passed on as the resulting stream.
|
|
15
|
+
*/
|
|
16
|
+
declare class MessageParser extends Transform {
|
|
17
|
+
lastBytes: Buffer;
|
|
18
|
+
headersParsed: boolean;
|
|
19
|
+
headerBytes: number;
|
|
20
|
+
headerChunks: Buffer[] | null;
|
|
21
|
+
rawHeaders: Buffer | false;
|
|
22
|
+
bodySize: number;
|
|
23
|
+
constructor(options?: TransformOptions);
|
|
24
|
+
/**
|
|
25
|
+
* Keeps count of the last 4 bytes in order to detect line breaks on chunk boundaries
|
|
26
|
+
*
|
|
27
|
+
* @param data Next data chunk from the stream
|
|
28
|
+
*/
|
|
29
|
+
updateLastBytes(data: Buffer): void;
|
|
30
|
+
/**
|
|
31
|
+
* Finds and removes message headers from the remaining body. We want to keep
|
|
32
|
+
* headers separated until final delivery to be able to modify these
|
|
33
|
+
*
|
|
34
|
+
* @param data Next chunk of data
|
|
35
|
+
* @return Returns true if headers are already found or false otherwise
|
|
36
|
+
*/
|
|
37
|
+
checkHeaders(data: Buffer): boolean;
|
|
38
|
+
parseHeaders(): MessageParserHeaderLine[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Type aliases in the layout of @types/nodemailer, so `MessageParser.Header` style references keep working
|
|
42
|
+
*/
|
|
43
|
+
declare namespace MessageParser {
|
|
44
|
+
type Header = MessageParserHeaderLine;
|
|
45
|
+
}
|
|
46
|
+
/** The same alias as a module level export, for `import * as MessageParser` and `import MessageParser = require()` */
|
|
47
|
+
export type { MessageParserHeaderLine as Header };
|
|
48
|
+
export default MessageParser;
|