@nocobase/plugin-workflow-mailer 2.2.16 → 2.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/externalVersion.js +6 -6
  2. package/dist/node_modules/joi/dist/joi-browser.min.js +1 -1
  3. package/dist/node_modules/joi/lib/index.js +1 -1
  4. package/dist/node_modules/joi/lib/messages.js +35 -6
  5. package/dist/node_modules/joi/lib/types/keys.js +18 -1
  6. package/dist/node_modules/joi/lib/types/link.js +18 -2
  7. package/dist/node_modules/joi/lib/types/string.js +2 -2
  8. package/dist/node_modules/joi/package.json +1 -1
  9. package/dist/node_modules/nodemailer/.ncurc.js +2 -0
  10. package/dist/node_modules/nodemailer/.prettierignore +8 -0
  11. package/dist/node_modules/nodemailer/.prettierrc +12 -0
  12. package/dist/node_modules/nodemailer/.prettierrc.js +2 -0
  13. package/dist/node_modules/nodemailer/.release-please-config.json +9 -0
  14. package/dist/node_modules/nodemailer/eslint.config.js +88 -0
  15. package/dist/node_modules/nodemailer/lib/addressparser/index.js +314 -71
  16. package/dist/node_modules/nodemailer/lib/base64/index.js +9 -13
  17. package/dist/node_modules/nodemailer/lib/dkim/index.js +17 -18
  18. package/dist/node_modules/nodemailer/lib/dkim/message-parser.js +12 -13
  19. package/dist/node_modules/nodemailer/lib/dkim/relaxed-body.js +3 -3
  20. package/dist/node_modules/nodemailer/lib/dkim/sign.js +22 -18
  21. package/dist/node_modules/nodemailer/lib/errors.js +59 -0
  22. package/dist/node_modules/nodemailer/lib/fetch/cookies.js +14 -19
  23. package/dist/node_modules/nodemailer/lib/fetch/index.js +164 -27
  24. package/dist/node_modules/nodemailer/lib/json-transport/index.js +4 -4
  25. package/dist/node_modules/nodemailer/lib/mail-composer/index.js +229 -155
  26. package/dist/node_modules/nodemailer/lib/mailer/index.js +106 -54
  27. package/dist/node_modules/nodemailer/lib/mailer/mail-message.js +106 -68
  28. package/dist/node_modules/nodemailer/lib/mime-funcs/index.js +105 -59
  29. package/dist/node_modules/nodemailer/lib/mime-funcs/mime-types.js +21 -14
  30. package/dist/node_modules/nodemailer/lib/mime-node/index.js +389 -137
  31. package/dist/node_modules/nodemailer/lib/mime-node/last-newline.js +1 -1
  32. package/dist/node_modules/nodemailer/lib/mime-node/le-unix.js +4 -7
  33. package/dist/node_modules/nodemailer/lib/mime-node/le-windows.js +1 -4
  34. package/dist/node_modules/nodemailer/lib/nodemailer.js +1 -1
  35. package/dist/node_modules/nodemailer/lib/punycode/index.js +1 -1
  36. package/dist/node_modules/nodemailer/lib/qp/index.js +33 -22
  37. package/dist/node_modules/nodemailer/lib/sendmail-transport/index.js +54 -44
  38. package/dist/node_modules/nodemailer/lib/ses-transport/index.js +110 -193
  39. package/dist/node_modules/nodemailer/lib/shared/index.js +299 -240
  40. package/dist/node_modules/nodemailer/lib/shared/objects.js +42 -0
  41. package/dist/node_modules/nodemailer/lib/shared/url.js +151 -0
  42. package/dist/node_modules/nodemailer/lib/smtp-connection/data-stream.js +3 -6
  43. package/dist/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +50 -19
  44. package/dist/node_modules/nodemailer/lib/smtp-connection/index.js +415 -223
  45. package/dist/node_modules/nodemailer/lib/smtp-pool/index.js +27 -34
  46. package/dist/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +19 -16
  47. package/dist/node_modules/nodemailer/lib/smtp-transport/index.js +66 -53
  48. package/dist/node_modules/nodemailer/lib/stream-transport/index.js +16 -7
  49. package/dist/node_modules/nodemailer/lib/well-known/index.js +7 -7
  50. package/dist/node_modules/nodemailer/lib/well-known/services.json +328 -38
  51. package/dist/node_modules/nodemailer/lib/xoauth2/index.js +105 -33
  52. package/dist/node_modules/nodemailer/package.json +1 -1
  53. package/package.json +4 -4
@@ -250,7 +250,7 @@ const decode = function (input) {
250
250
  // Main decoding loop: start just after the last delimiter if any basic code
251
251
  // points were copied; start at the beginning otherwise.
252
252
 
253
- for (let index = basic > 0 ? basic + 1 : 0; index < inputLength /* no final expression */; ) {
253
+ for (let index = basic > 0 ? basic + 1 : 0; index < inputLength /* no final expression */;) {
254
254
  // `index` is the index of the next character to be consumed.
255
255
  // Decode a generalized variable-length integer into `delta`,
256
256
  // which gets added to `i`. The overflow checking is easier
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Transform = require('stream').Transform;
3
+ const { Transform } = require('stream');
4
4
 
5
5
  /**
6
6
  * Encodes a Buffer into a Quoted-Printable encoded string
@@ -8,27 +8,31 @@ const Transform = require('stream').Transform;
8
8
  * @param {Buffer} buffer Buffer to convert
9
9
  * @returns {String} Quoted-Printable encoded string
10
10
  */
11
+ // usable characters that do not need encoding
12
+ // https://tools.ietf.org/html/rfc2045#section-6.7
13
+ const QP_RANGES = [
14
+ [0x09], // <TAB>
15
+ [0x0a], // <LF>
16
+ [0x0d], // <CR>
17
+ [0x20, 0x3c], // <SP>!"#$%&'()*+,-./0123456789:;
18
+ [0x3e, 0x7e] // >?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}
19
+ ];
20
+
11
21
  function encode(buffer) {
12
22
  if (typeof buffer === 'string') {
13
23
  buffer = Buffer.from(buffer, 'utf-8');
14
24
  }
15
25
 
16
- // usable characters that do not need encoding
17
- let ranges = [
18
- // https://tools.ietf.org/html/rfc2045#section-6.7
19
- [0x09], // <TAB>
20
- [0x0a], // <LF>
21
- [0x0d], // <CR>
22
- [0x20, 0x3c], // <SP>!"#$%&'()*+,-./0123456789:;
23
- [0x3e, 0x7e] // >?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}
24
- ];
25
26
  let result = '';
26
27
  let ord;
27
28
 
28
29
  for (let i = 0, len = buffer.length; i < len; i++) {
29
30
  ord = buffer[i];
30
31
  // if the char is in allowed range, then keep as is, unless it is a WS in the end of a line
31
- if (checkRanges(ord, ranges) && !((ord === 0x20 || ord === 0x09) && (i === len - 1 || buffer[i + 1] === 0x0a || buffer[i + 1] === 0x0d))) {
32
+ if (
33
+ checkRanges(ord, QP_RANGES) &&
34
+ !((ord === 0x20 || ord === 0x09) && (i === len - 1 || buffer[i + 1] === 0x0a || buffer[i + 1] === 0x0d))
35
+ ) {
32
36
  result += String.fromCharCode(ord);
33
37
  continue;
34
38
  }
@@ -54,9 +58,9 @@ function wrap(str, lineLength) {
54
58
  }
55
59
 
56
60
  let pos = 0;
57
- let len = str.length;
61
+ const len = str.length;
58
62
  let match, code, line;
59
- let lineMargin = Math.floor(lineLength / 3);
63
+ const lineMargin = Math.floor(lineLength / 3);
60
64
  let result = '';
61
65
 
62
66
  // insert soft linebreaks where needed
@@ -70,17 +74,20 @@ function wrap(str, lineLength) {
70
74
  }
71
75
 
72
76
  if (line.substr(-1) === '\n') {
73
- // nothing to change here
74
77
  result += line;
75
78
  pos += line.length;
76
79
  continue;
77
- } else if ((match = line.substr(-lineMargin).match(/\n.*?$/))) {
80
+ }
81
+
82
+ if ((match = line.substr(-lineMargin).match(/\n.*?$/))) {
78
83
  // truncate to nearest line break
79
84
  line = line.substr(0, line.length - (match[0].length - 1));
80
85
  result += line;
81
86
  pos += line.length;
82
87
  continue;
83
- } else if (line.length > lineLength - lineMargin && (match = line.substr(-lineMargin).match(/[ \t.,!?][^ \t.,!?]*$/))) {
88
+ }
89
+
90
+ if (line.length > lineLength - lineMargin && (match = line.substr(-lineMargin).match(/[ \t.,!?][^ \t.,!?]*$/))) {
84
91
  // truncate to nearest space
85
92
  line = line.substr(0, line.length - (match[0].length - 1));
86
93
  } else if (line.match(/[=][\da-f]{0,2}$/i)) {
@@ -90,7 +97,12 @@ function wrap(str, lineLength) {
90
97
  }
91
98
 
92
99
  // ensure that utf-8 sequences are not split
93
- while (line.length > 3 && line.length < len - pos && !line.match(/^(?:=[\da-f]{2}){1,4}$/i) && (match = line.match(/[=][\da-f]{2}$/gi))) {
100
+ while (
101
+ line.length > 3 &&
102
+ line.length < len - pos &&
103
+ !line.match(/^(?:=[\da-f]{2}){1,4}$/i) &&
104
+ (match = line.match(/[=][\da-f]{2}$/gi))
105
+ ) {
94
106
  code = parseInt(match[0].substr(1, 2), 16);
95
107
  if (code < 128) {
96
108
  break;
@@ -131,13 +143,14 @@ function wrap(str, lineLength) {
131
143
  */
132
144
  function checkRanges(nr, ranges) {
133
145
  for (let i = ranges.length - 1; i >= 0; i--) {
134
- if (!ranges[i].length) {
146
+ const range = ranges[i];
147
+ if (!range.length) {
135
148
  continue;
136
149
  }
137
- if (ranges[i].length === 1 && nr === ranges[i][0]) {
150
+ if (range.length === 1 && nr === range[0]) {
138
151
  return true;
139
152
  }
140
- if (ranges[i].length === 2 && nr >= ranges[i][0] && nr <= ranges[i][1]) {
153
+ if (range.length === 2 && nr >= range[0] && nr <= range[1]) {
141
154
  return true;
142
155
  }
143
156
  }
@@ -155,7 +168,6 @@ class Encoder extends Transform {
155
168
  constructor(options) {
156
169
  super();
157
170
 
158
- // init Transform
159
171
  this.options = options || {};
160
172
 
161
173
  if (this.options.lineLength !== false) {
@@ -211,7 +223,6 @@ class Encoder extends Transform {
211
223
  }
212
224
  }
213
225
 
214
- // expose to the world
215
226
  module.exports = {
216
227
  encode,
217
228
  wrap,
@@ -1,8 +1,11 @@
1
1
  'use strict';
2
2
 
3
- const spawn = require('child_process').spawn;
3
+ const { spawn } = require('child_process');
4
4
  const packageData = require('../../package.json');
5
5
  const shared = require('../shared');
6
+ const errors = require('../errors');
7
+ const LeWindows = require('../mime-node/le-windows');
8
+ const LeUnix = require('../mime-node/le-unix');
6
9
 
7
10
  /**
8
11
  * Generates a Transport object for Sendmail
@@ -23,32 +26,30 @@ class SendmailTransport {
23
26
  // use a reference to spawn for mocking purposes
24
27
  this._spawn = spawn;
25
28
 
26
- this.options = options || {};
29
+ this.options = options;
27
30
 
28
31
  this.name = 'Sendmail';
29
32
  this.version = packageData.version;
30
33
 
31
34
  this.path = 'sendmail';
32
35
  this.args = false;
33
- this.winbreak = false;
34
36
 
35
37
  this.logger = shared.getLogger(this.options, {
36
38
  component: this.options.component || 'sendmail'
37
39
  });
38
40
 
39
- if (options) {
40
- if (typeof options === 'string') {
41
- this.path = options;
42
- } else if (typeof options === 'object') {
43
- if (options.path) {
44
- this.path = options.path;
45
- }
46
- if (Array.isArray(options.args)) {
47
- this.args = options.args;
48
- }
49
- this.winbreak = ['win', 'windows', 'dos', '\r\n'].includes((options.newline || '').toString().toLowerCase());
41
+ if (typeof options === 'string') {
42
+ this.path = options;
43
+ } else if (typeof options === 'object') {
44
+ if (options.path) {
45
+ this.path = options.path;
46
+ }
47
+ if (Array.isArray(options.args)) {
48
+ this.args = options.args;
50
49
  }
51
50
  }
51
+
52
+ this.winbreak = ['win', 'windows', 'dos', '\r\n'].includes((options.newline || '').toString().toLowerCase());
52
53
  }
53
54
 
54
55
  /**
@@ -61,28 +62,29 @@ class SendmailTransport {
61
62
  // Sendmail strips this header line by itself
62
63
  mail.message.keepBcc = true;
63
64
 
64
- let envelope = mail.data.envelope || mail.message.getEnvelope();
65
- let messageId = mail.message.messageId();
66
- let args;
67
- let sendmail;
65
+ const envelope = mail.message.getEnvelope();
66
+ const messageId = mail.message.messageId();
68
67
  let returned;
69
68
 
70
69
  const hasInvalidAddresses = []
71
70
  .concat(envelope.from || [])
72
71
  .concat(envelope.to || [])
73
- .some(addr => /^-/.test(addr));
72
+ // a local part is either a dot-atom or a quoted-string, so a leading dash sits at
73
+ // offset 0 or, behind the opening quote, at offset 1. Only the first shape is read
74
+ // as an option by sendmail, but both are the address this guard keeps out of argv
75
+ .some(addr => /^"?-/.test(addr));
74
76
  if (hasInvalidAddresses) {
75
- return done(new Error('Can not send mail. Invalid envelope addresses.'));
77
+ const err = new Error('Can not send mail. Invalid envelope addresses.');
78
+ err.code = errors.ESENDMAIL;
79
+ return done(err);
76
80
  }
77
81
 
78
- if (this.args) {
79
- // force -i to keep single dots
80
- args = ['-i'].concat(this.args).concat(envelope.to);
81
- } else {
82
- args = ['-i'].concat(envelope.from ? ['-f', envelope.from] : []).concat(envelope.to);
83
- }
82
+ // force -i to keep single dots
83
+ const args = this.args
84
+ ? ['-i'].concat(this.args).concat(envelope.to)
85
+ : ['-i'].concat(envelope.from ? ['-f', envelope.from] : []).concat(envelope.to);
84
86
 
85
- let callback = err => {
87
+ const callback = err => {
86
88
  if (returned) {
87
89
  // ignore any additional responses, already done
88
90
  return;
@@ -91,16 +93,16 @@ class SendmailTransport {
91
93
  if (typeof done === 'function') {
92
94
  if (err) {
93
95
  return done(err);
94
- } else {
95
- return done(null, {
96
- envelope: mail.data.envelope || mail.message.getEnvelope(),
97
- messageId,
98
- response: 'Messages queued for delivery'
99
- });
100
96
  }
97
+ return done(null, {
98
+ envelope,
99
+ messageId,
100
+ response: 'Messages queued for delivery'
101
+ });
101
102
  }
102
103
  };
103
104
 
105
+ let sendmail;
104
106
  try {
105
107
  sendmail = this._spawn(this.path, args);
106
108
  } catch (E) {
@@ -135,12 +137,10 @@ class SendmailTransport {
135
137
  if (!code) {
136
138
  return callback();
137
139
  }
138
- let err;
139
- if (code === 127) {
140
- err = new Error('Sendmail command not found, process exited with code ' + code);
141
- } else {
142
- err = new Error('Sendmail exited with code ' + code);
143
- }
140
+ const err = new Error(
141
+ code === 127 ? 'Sendmail command not found, process exited with code ' + code : 'Sendmail exited with code ' + code
142
+ );
143
+ err.code = errors.ESENDMAIL;
144
144
 
145
145
  this.logger.error(
146
146
  {
@@ -170,7 +170,7 @@ class SendmailTransport {
170
170
  callback(err);
171
171
  });
172
172
 
173
- let recipients = [].concat(envelope.to || []);
173
+ const recipients = [].concat(envelope.to || []);
174
174
  if (recipients.length > 3) {
175
175
  recipients.push('...and ' + recipients.splice(2).length + ' more');
176
176
  }
@@ -184,8 +184,16 @@ class SendmailTransport {
184
184
  recipients.join(', ')
185
185
  );
186
186
 
187
- let sourceStream = mail.message.createReadStream();
188
- sourceStream.once('error', err => {
187
+ const sourceStream = mail.message.createReadStream();
188
+ let stream = sourceStream;
189
+ if (this.options.newline) {
190
+ // apply the transport-level line ending transform; the message-level
191
+ // `newline` option is handled by MimeNode in createReadStream()
192
+ stream = sourceStream.pipe(this.winbreak ? new LeWindows() : new LeUnix());
193
+ sourceStream.once('error', err => stream.emit('error', err));
194
+ }
195
+
196
+ stream.once('error', err => {
189
197
  this.logger.error(
190
198
  {
191
199
  err,
@@ -200,9 +208,11 @@ class SendmailTransport {
200
208
  callback(err);
201
209
  });
202
210
 
203
- sourceStream.pipe(sendmail.stdin);
211
+ stream.pipe(sendmail.stdin);
204
212
  } else {
205
- return callback(new Error('sendmail was not found'));
213
+ const err = new Error('sendmail was not found');
214
+ err.code = errors.ESENDMAIL;
215
+ return callback(err);
206
216
  }
207
217
  }
208
218
  }