@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.
Files changed (187) 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/dist/cjs/addressparser/index.d.ts +59 -0
  10. package/dist/node_modules/nodemailer/dist/cjs/addressparser/index.js +790 -0
  11. package/dist/node_modules/nodemailer/dist/cjs/base64/index.d.ts +36 -0
  12. package/dist/node_modules/nodemailer/dist/cjs/base64/index.js +119 -0
  13. package/dist/node_modules/nodemailer/dist/cjs/dkim/index.d.ts +52 -0
  14. package/dist/node_modules/nodemailer/dist/cjs/dkim/index.js +228 -0
  15. package/dist/node_modules/nodemailer/dist/cjs/dkim/message-parser.d.ts +48 -0
  16. package/dist/node_modules/nodemailer/dist/cjs/dkim/message-parser.js +180 -0
  17. package/dist/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.d.ts +36 -0
  18. package/dist/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.js +148 -0
  19. package/dist/node_modules/nodemailer/dist/cjs/dkim/sign.d.ts +52 -0
  20. package/dist/node_modules/nodemailer/dist/cjs/dkim/sign.js +165 -0
  21. package/dist/node_modules/nodemailer/dist/cjs/errors.d.ts +96 -0
  22. package/dist/node_modules/nodemailer/dist/cjs/errors.js +70 -0
  23. package/dist/node_modules/nodemailer/dist/cjs/fetch/cookies.d.ts +107 -0
  24. package/dist/node_modules/nodemailer/dist/cjs/fetch/cookies.js +282 -0
  25. package/dist/node_modules/nodemailer/dist/cjs/fetch/index.d.ts +65 -0
  26. package/dist/node_modules/nodemailer/dist/cjs/fetch/index.js +384 -0
  27. package/dist/node_modules/nodemailer/dist/cjs/json-transport/index.d.ts +64 -0
  28. package/dist/node_modules/nodemailer/dist/cjs/json-transport/index.js +99 -0
  29. package/dist/node_modules/nodemailer/dist/cjs/mail-composer/index.d.ts +174 -0
  30. package/dist/node_modules/nodemailer/dist/cjs/mail-composer/index.js +613 -0
  31. package/dist/node_modules/nodemailer/dist/cjs/mailer/index.d.ts +237 -0
  32. package/dist/node_modules/nodemailer/dist/cjs/mailer/index.js +415 -0
  33. package/dist/node_modules/nodemailer/dist/cjs/mailer/mail-message.d.ts +97 -0
  34. package/dist/node_modules/nodemailer/dist/cjs/mailer/mail-message.js +342 -0
  35. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/index.d.ts +161 -0
  36. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/index.js +787 -0
  37. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/mime-types.d.ts +2 -0
  38. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/mime-types.js +2103 -0
  39. package/dist/node_modules/nodemailer/dist/cjs/mime-node/index.d.ts +333 -0
  40. package/dist/node_modules/nodemailer/dist/cjs/mime-node/index.js +1493 -0
  41. package/dist/node_modules/nodemailer/dist/cjs/mime-node/last-newline.d.ts +5 -0
  42. package/dist/node_modules/nodemailer/dist/cjs/mime-node/last-newline.js +32 -0
  43. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-unix.d.ts +9 -0
  44. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-unix.js +40 -0
  45. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-windows.d.ts +10 -0
  46. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-windows.js +47 -0
  47. package/dist/node_modules/nodemailer/dist/cjs/nodemailer.d.ts +124 -0
  48. package/dist/node_modules/nodemailer/dist/cjs/nodemailer.js +1 -0
  49. package/dist/node_modules/nodemailer/dist/cjs/package-info.d.ts +3 -0
  50. package/dist/node_modules/nodemailer/dist/cjs/package-info.js +7 -0
  51. package/dist/node_modules/nodemailer/dist/cjs/package.json +3 -0
  52. package/dist/node_modules/nodemailer/dist/cjs/punycode/index.d.ts +73 -0
  53. package/dist/node_modules/nodemailer/{lib → dist/cjs}/punycode/index.js +63 -112
  54. package/dist/node_modules/nodemailer/dist/cjs/qp/index.d.ts +32 -0
  55. package/dist/node_modules/nodemailer/dist/cjs/qp/index.js +207 -0
  56. package/dist/node_modules/nodemailer/dist/cjs/sendmail-transport/index.d.ts +69 -0
  57. package/dist/node_modules/nodemailer/dist/cjs/sendmail-transport/index.js +210 -0
  58. package/dist/node_modules/nodemailer/dist/cjs/ses-transport/index.d.ts +112 -0
  59. package/dist/node_modules/nodemailer/dist/cjs/ses-transport/index.js +252 -0
  60. package/dist/node_modules/nodemailer/dist/cjs/shared/index.d.ts +260 -0
  61. package/dist/node_modules/nodemailer/dist/cjs/shared/index.js +680 -0
  62. package/dist/node_modules/nodemailer/dist/cjs/shared/objects.d.ts +23 -0
  63. package/dist/node_modules/nodemailer/dist/cjs/shared/objects.js +43 -0
  64. package/dist/node_modules/nodemailer/dist/cjs/shared/url.d.ts +21 -0
  65. package/dist/node_modules/nodemailer/dist/cjs/shared/url.js +255 -0
  66. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.d.ts +15 -0
  67. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.js +108 -0
  68. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.d.ts +47 -0
  69. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.js +189 -0
  70. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/index.d.ts +416 -0
  71. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/index.js +1837 -0
  72. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/index.d.ts +133 -0
  73. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/index.js +569 -0
  74. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.d.ts +62 -0
  75. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.js +257 -0
  76. package/dist/node_modules/nodemailer/dist/cjs/smtp-transport/index.d.ts +156 -0
  77. package/dist/node_modules/nodemailer/dist/cjs/smtp-transport/index.js +371 -0
  78. package/dist/node_modules/nodemailer/dist/cjs/stream-transport/index.d.ts +65 -0
  79. package/dist/node_modules/nodemailer/dist/cjs/stream-transport/index.js +146 -0
  80. package/dist/node_modules/nodemailer/dist/cjs/well-known/index.d.ts +35 -0
  81. package/dist/node_modules/nodemailer/dist/cjs/well-known/index.js +41 -0
  82. package/dist/node_modules/nodemailer/dist/cjs/well-known/services.d.ts +2 -0
  83. package/dist/node_modules/nodemailer/dist/cjs/well-known/services.js +674 -0
  84. package/dist/node_modules/nodemailer/dist/cjs/xoauth2/index.d.ts +201 -0
  85. package/dist/node_modules/nodemailer/dist/cjs/xoauth2/index.js +426 -0
  86. package/dist/node_modules/nodemailer/dist/esm/addressparser/index.d.ts +59 -0
  87. package/dist/node_modules/nodemailer/dist/esm/addressparser/index.js +786 -0
  88. package/dist/node_modules/nodemailer/dist/esm/base64/index.d.ts +36 -0
  89. package/dist/node_modules/nodemailer/{lib → dist/esm}/base64/index.js +39 -68
  90. package/dist/node_modules/nodemailer/dist/esm/dkim/index.d.ts +52 -0
  91. package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/index.js +62 -92
  92. package/dist/node_modules/nodemailer/dist/esm/dkim/message-parser.d.ts +48 -0
  93. package/dist/node_modules/nodemailer/dist/esm/dkim/message-parser.js +176 -0
  94. package/dist/node_modules/nodemailer/dist/esm/dkim/relaxed-body.d.ts +36 -0
  95. package/dist/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js +141 -0
  96. package/dist/node_modules/nodemailer/dist/esm/dkim/sign.d.ts +52 -0
  97. package/dist/node_modules/nodemailer/dist/esm/dkim/sign.js +125 -0
  98. package/dist/node_modules/nodemailer/dist/esm/errors.d.ts +96 -0
  99. package/dist/node_modules/nodemailer/dist/esm/errors.js +67 -0
  100. package/dist/node_modules/nodemailer/dist/esm/fetch/cookies.d.ts +107 -0
  101. package/dist/node_modules/nodemailer/dist/esm/fetch/cookies.js +242 -0
  102. package/dist/node_modules/nodemailer/dist/esm/fetch/index.d.ts +65 -0
  103. package/dist/node_modules/nodemailer/dist/esm/fetch/index.js +344 -0
  104. package/dist/node_modules/nodemailer/dist/esm/json-transport/index.d.ts +64 -0
  105. package/dist/node_modules/nodemailer/dist/esm/json-transport/index.js +62 -0
  106. package/dist/node_modules/nodemailer/dist/esm/mail-composer/index.d.ts +174 -0
  107. package/dist/node_modules/nodemailer/{lib → dist/esm}/mail-composer/index.js +283 -275
  108. package/dist/node_modules/nodemailer/dist/esm/mailer/index.d.ts +237 -0
  109. package/dist/node_modules/nodemailer/{lib → dist/esm}/mailer/index.js +151 -205
  110. package/dist/node_modules/nodemailer/dist/esm/mailer/mail-message.d.ts +97 -0
  111. package/dist/node_modules/nodemailer/{lib → dist/esm}/mailer/mail-message.js +111 -125
  112. package/dist/node_modules/nodemailer/dist/esm/mime-funcs/index.d.ts +161 -0
  113. package/dist/node_modules/nodemailer/dist/esm/mime-funcs/index.js +738 -0
  114. package/dist/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.d.ts +2 -0
  115. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-funcs/mime-types.js +43 -49
  116. package/dist/node_modules/nodemailer/dist/esm/mime-node/index.d.ts +333 -0
  117. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/index.js +576 -437
  118. package/dist/node_modules/nodemailer/dist/esm/mime-node/last-newline.d.ts +5 -0
  119. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/last-newline.js +4 -10
  120. package/dist/node_modules/nodemailer/dist/esm/mime-node/le-unix.d.ts +9 -0
  121. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/le-unix.js +7 -15
  122. package/dist/node_modules/nodemailer/dist/esm/mime-node/le-windows.d.ts +10 -0
  123. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/le-windows.js +6 -16
  124. package/dist/node_modules/nodemailer/dist/esm/nodemailer.d.ts +124 -0
  125. package/dist/node_modules/nodemailer/dist/esm/nodemailer.js +166 -0
  126. package/dist/node_modules/nodemailer/dist/esm/package-info.d.ts +3 -0
  127. package/dist/node_modules/nodemailer/dist/esm/package-info.js +4 -0
  128. package/dist/node_modules/nodemailer/dist/esm/package.json +3 -0
  129. package/dist/node_modules/nodemailer/dist/esm/punycode/index.d.ts +73 -0
  130. package/dist/node_modules/nodemailer/dist/esm/punycode/index.js +405 -0
  131. package/dist/node_modules/nodemailer/dist/esm/qp/index.d.ts +32 -0
  132. package/dist/node_modules/nodemailer/{lib → dist/esm}/qp/index.js +59 -77
  133. package/dist/node_modules/nodemailer/dist/esm/sendmail-transport/index.d.ts +69 -0
  134. package/dist/node_modules/nodemailer/dist/esm/sendmail-transport/index.js +170 -0
  135. package/dist/node_modules/nodemailer/dist/esm/ses-transport/index.d.ts +112 -0
  136. package/dist/node_modules/nodemailer/dist/esm/ses-transport/index.js +212 -0
  137. package/dist/node_modules/nodemailer/dist/esm/shared/index.d.ts +260 -0
  138. package/dist/node_modules/nodemailer/dist/esm/shared/index.js +631 -0
  139. package/dist/node_modules/nodemailer/dist/esm/shared/objects.d.ts +23 -0
  140. package/dist/node_modules/nodemailer/dist/esm/shared/objects.js +38 -0
  141. package/dist/node_modules/nodemailer/dist/esm/shared/url.d.ts +21 -0
  142. package/dist/node_modules/nodemailer/dist/esm/shared/url.js +214 -0
  143. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.d.ts +15 -0
  144. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js +103 -0
  145. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.d.ts +47 -0
  146. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.js +149 -0
  147. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/index.d.ts +416 -0
  148. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/index.js +1797 -0
  149. package/dist/node_modules/nodemailer/dist/esm/smtp-pool/index.d.ts +133 -0
  150. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-pool/index.js +195 -314
  151. package/dist/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.d.ts +62 -0
  152. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-pool/pool-resource.js +70 -107
  153. package/dist/node_modules/nodemailer/dist/esm/smtp-transport/index.d.ts +156 -0
  154. package/dist/node_modules/nodemailer/dist/esm/smtp-transport/index.js +331 -0
  155. package/dist/node_modules/nodemailer/dist/esm/stream-transport/index.d.ts +65 -0
  156. package/dist/node_modules/nodemailer/dist/esm/stream-transport/index.js +106 -0
  157. package/dist/node_modules/nodemailer/dist/esm/well-known/index.d.ts +35 -0
  158. package/dist/node_modules/nodemailer/{lib → dist/esm}/well-known/index.js +12 -23
  159. package/dist/node_modules/nodemailer/dist/esm/well-known/services.d.ts +2 -0
  160. package/dist/node_modules/nodemailer/dist/esm/well-known/services.js +671 -0
  161. package/dist/node_modules/nodemailer/dist/esm/xoauth2/index.d.ts +201 -0
  162. package/dist/node_modules/nodemailer/dist/esm/xoauth2/index.js +386 -0
  163. package/dist/node_modules/nodemailer/dist/well-known/services.json +640 -0
  164. package/dist/node_modules/nodemailer/package.json +1 -1
  165. package/package.json +4 -4
  166. package/dist/node_modules/nodemailer/.gitattributes +0 -6
  167. package/dist/node_modules/nodemailer/.ncurc.js +0 -7
  168. package/dist/node_modules/nodemailer/.prettierrc.js +0 -8
  169. package/dist/node_modules/nodemailer/lib/addressparser/index.js +0 -313
  170. package/dist/node_modules/nodemailer/lib/dkim/message-parser.js +0 -155
  171. package/dist/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
  172. package/dist/node_modules/nodemailer/lib/dkim/sign.js +0 -117
  173. package/dist/node_modules/nodemailer/lib/fetch/cookies.js +0 -281
  174. package/dist/node_modules/nodemailer/lib/fetch/index.js +0 -274
  175. package/dist/node_modules/nodemailer/lib/json-transport/index.js +0 -82
  176. package/dist/node_modules/nodemailer/lib/mime-funcs/index.js +0 -625
  177. package/dist/node_modules/nodemailer/lib/nodemailer.js +0 -1
  178. package/dist/node_modules/nodemailer/lib/sendmail-transport/index.js +0 -210
  179. package/dist/node_modules/nodemailer/lib/ses-transport/index.js +0 -349
  180. package/dist/node_modules/nodemailer/lib/shared/index.js +0 -688
  181. package/dist/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -108
  182. package/dist/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +0 -143
  183. package/dist/node_modules/nodemailer/lib/smtp-connection/index.js +0 -1825
  184. package/dist/node_modules/nodemailer/lib/smtp-transport/index.js +0 -416
  185. package/dist/node_modules/nodemailer/lib/stream-transport/index.js +0 -135
  186. package/dist/node_modules/nodemailer/lib/well-known/services.json +0 -343
  187. package/dist/node_modules/nodemailer/lib/xoauth2/index.js +0 -376
@@ -1,64 +1,59 @@
1
- 'use strict';
2
-
3
- const Transform = require('stream').Transform;
4
-
1
+ import { Transform } from 'node:stream';
5
2
  /**
6
3
  * Encodes a Buffer into a Quoted-Printable encoded string
7
4
  *
8
- * @param {Buffer} buffer Buffer to convert
9
- * @returns {String} Quoted-Printable encoded string
5
+ * @param buffer Buffer to convert
6
+ * @returns Quoted-Printable encoded string
10
7
  */
11
- function encode(buffer) {
8
+ // the shortest line wrap() can make progress with: a complete =XX sequence and the soft break
9
+ const MIN_LINE_LENGTH = 4;
10
+ // usable characters that do not need encoding
11
+ // https://tools.ietf.org/html/rfc2045#section-6.7
12
+ const QP_RANGES = [
13
+ [0x09], // <TAB>
14
+ [0x0a], // <LF>
15
+ [0x0d], // <CR>
16
+ [0x20, 0x3c], // <SP>!"#$%&'()*+,-./0123456789:;
17
+ [0x3e, 0x7e] // >?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}
18
+ ];
19
+ export function encode(buffer) {
12
20
  if (typeof buffer === 'string') {
13
21
  buffer = Buffer.from(buffer, 'utf-8');
14
22
  }
15
-
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
23
  let result = '';
26
24
  let ord;
27
-
28
25
  for (let i = 0, len = buffer.length; i < len; i++) {
29
26
  ord = buffer[i];
30
27
  // 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))) {
28
+ if (checkRanges(ord, QP_RANGES) &&
29
+ !((ord === 0x20 || ord === 0x09) && (i === len - 1 || buffer[i + 1] === 0x0a || buffer[i + 1] === 0x0d))) {
32
30
  result += String.fromCharCode(ord);
33
31
  continue;
34
32
  }
35
33
  result += '=' + (ord < 0x10 ? '0' : '') + ord.toString(16).toUpperCase();
36
34
  }
37
-
38
35
  return result;
39
36
  }
40
-
41
37
  /**
42
38
  * Adds soft line breaks to a Quoted-Printable string
43
39
  *
44
- * @param {String} str Quoted-Printable encoded string that might need line wrapping
45
- * @param {Number} [lineLength=76] Maximum allowed length for a line
46
- * @returns {String} Soft-wrapped Quoted-Printable encoded string
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
47
43
  */
48
- function wrap(str, lineLength) {
44
+ export function wrap(str, lineLength) {
49
45
  str = (str || '').toString();
50
- lineLength = lineLength || 76;
51
-
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);
52
49
  if (str.length <= lineLength) {
53
50
  return str;
54
51
  }
55
-
56
52
  let pos = 0;
57
- let len = str.length;
53
+ const len = str.length;
58
54
  let match, code, line;
59
- let lineMargin = Math.floor(lineLength / 3);
55
+ const lineMargin = Math.floor(lineLength / 3);
60
56
  let result = '';
61
-
62
57
  // insert soft linebreaks where needed
63
58
  while (pos < len) {
64
59
  line = str.substr(pos, lineLength);
@@ -68,119 +63,114 @@ function wrap(str, lineLength) {
68
63
  pos += line.length;
69
64
  continue;
70
65
  }
71
-
72
66
  if (line.substr(-1) === '\n') {
73
- // nothing to change here
74
67
  result += line;
75
68
  pos += line.length;
76
69
  continue;
77
- } else if ((match = line.substr(-lineMargin).match(/\n.*?$/))) {
70
+ }
71
+ if ((match = line.substr(-lineMargin).match(/\n.*?$/))) {
78
72
  // truncate to nearest line break
79
73
  line = line.substr(0, line.length - (match[0].length - 1));
80
74
  result += line;
81
75
  pos += line.length;
82
76
  continue;
83
- } else if (line.length > lineLength - lineMargin && (match = line.substr(-lineMargin).match(/[ \t.,!?][^ \t.,!?]*$/))) {
77
+ }
78
+ if (line.length > lineLength - lineMargin && (match = line.substr(-lineMargin).match(/[ \t.,!?][^ \t.,!?]*$/))) {
84
79
  // truncate to nearest space
85
80
  line = line.substr(0, line.length - (match[0].length - 1));
86
- } else if (line.match(/[=][\da-f]{0,2}$/i)) {
81
+ }
82
+ else if (line.match(/[=][\da-f]{0,2}$/i)) {
87
83
  // push incomplete encoding sequences to the next line
88
84
  if ((match = line.match(/[=][\da-f]{0,1}$/i))) {
89
85
  line = line.substr(0, line.length - match[0].length);
90
86
  }
91
-
92
87
  // 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))) {
88
+ while (line.length > 3 &&
89
+ line.length < len - pos &&
90
+ !line.match(/^(?:=[\da-f]{2}){1,4}$/i) &&
91
+ (match = line.match(/[=][\da-f]{2}$/gi))) {
94
92
  code = parseInt(match[0].substr(1, 2), 16);
95
93
  if (code < 128) {
96
94
  break;
97
95
  }
98
-
99
96
  line = line.substr(0, line.length - 3);
100
-
101
97
  if (code >= 0xc0) {
102
98
  break;
103
99
  }
104
100
  }
105
101
  }
106
-
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
+ }
107
107
  if (pos + line.length < len && line.substr(-1) !== '\n') {
108
108
  if (line.length === lineLength && line.match(/[=][\da-f]{2}$/i)) {
109
109
  line = line.substr(0, line.length - 3);
110
- } else if (line.length === lineLength) {
110
+ }
111
+ else if (line.length === lineLength) {
111
112
  line = line.substr(0, line.length - 1);
112
113
  }
113
114
  pos += line.length;
114
115
  line += '=\r\n';
115
- } else {
116
+ }
117
+ else {
116
118
  pos += line.length;
117
119
  }
118
-
119
120
  result += line;
120
121
  }
121
-
122
122
  return result;
123
123
  }
124
-
125
124
  /**
126
125
  * Helper function to check if a number is inside provided ranges
127
126
  *
128
- * @param {Number} nr Number to check for
129
- * @param {Array} ranges An Array of allowed values
130
- * @returns {Boolean} True if the value was found inside allowed ranges, false otherwise
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
131
130
  */
132
131
  function checkRanges(nr, ranges) {
133
132
  for (let i = ranges.length - 1; i >= 0; i--) {
134
- if (!ranges[i].length) {
133
+ const range = ranges[i];
134
+ if (!range.length) {
135
135
  continue;
136
136
  }
137
- if (ranges[i].length === 1 && nr === ranges[i][0]) {
137
+ if (range.length === 1 && nr === range[0]) {
138
138
  return true;
139
139
  }
140
- if (ranges[i].length === 2 && nr >= ranges[i][0] && nr <= ranges[i][1]) {
140
+ if (range.length === 2 && nr >= range[0] && nr <= range[1]) {
141
141
  return true;
142
142
  }
143
143
  }
144
144
  return false;
145
145
  }
146
-
147
146
  /**
148
147
  * Creates a transform stream for encoding data to Quoted-Printable encoding
149
148
  *
150
149
  * @constructor
151
- * @param {Object} options Stream options
152
- * @param {Number} [options.lineLength=76] Maximum length for lines, set to false to disable wrapping
150
+ * @param options Stream options
151
+ * @param [options.lineLength=76] Maximum length for lines, set to false to disable wrapping
153
152
  */
154
- class Encoder extends Transform {
153
+ export class Encoder extends Transform {
155
154
  constructor(options) {
156
155
  super();
157
-
158
- // init Transform
159
156
  this.options = options || {};
160
-
161
157
  if (this.options.lineLength !== false) {
162
158
  this.options.lineLength = this.options.lineLength || 76;
163
159
  }
164
-
165
160
  this._curLine = '';
166
-
167
161
  this.inputBytes = 0;
168
162
  this.outputBytes = 0;
169
163
  }
170
-
164
+ /** @internal */
171
165
  _transform(chunk, encoding, done) {
172
166
  let qp;
173
-
174
167
  if (encoding !== 'buffer') {
175
168
  chunk = Buffer.from(chunk, encoding);
176
169
  }
177
-
178
170
  if (!chunk || !chunk.length) {
179
171
  return done();
180
172
  }
181
-
182
173
  this.inputBytes += chunk.length;
183
-
184
174
  if (this.options.lineLength) {
185
175
  qp = this._curLine + encode(chunk);
186
176
  qp = wrap(qp, this.options.lineLength);
@@ -188,20 +178,19 @@ class Encoder extends Transform {
188
178
  this._curLine = lastLine;
189
179
  return lineBreak;
190
180
  });
191
-
192
181
  if (qp) {
193
182
  this.outputBytes += qp.length;
194
183
  this.push(qp);
195
184
  }
196
- } else {
185
+ }
186
+ else {
197
187
  qp = encode(chunk);
198
188
  this.outputBytes += qp.length;
199
189
  this.push(qp, 'ascii');
200
190
  }
201
-
202
191
  done();
203
192
  }
204
-
193
+ /** @internal */
205
194
  _flush(done) {
206
195
  if (this._curLine) {
207
196
  this.outputBytes += this._curLine.length;
@@ -210,10 +199,3 @@ class Encoder extends Transform {
210
199
  done();
211
200
  }
212
201
  }
213
-
214
- // expose to the world
215
- module.exports = {
216
- encode,
217
- wrap,
218
- Encoder
219
- };
@@ -0,0 +1,69 @@
1
+ import type { Logger } from '../shared/index.js';
2
+ import type { MimeNodeEnvelope } from '../mime-node/index.js';
3
+ import type MailMessage from '../mailer/mail-message.js';
4
+ import type { default as Mail, SentMessageInfo, SendMailOptions, TransportOptions } from '../mailer/index.js';
5
+ /**
6
+ * Options for the Sendmail transport
7
+ */
8
+ export interface SendmailTransportOptions extends TransportOptions {
9
+ /** Selects this transport in createTransport, the binary itself is set with `path` */
10
+ sendmail?: boolean | string | undefined;
11
+ /** Path to the sendmail binary, defaults to 'sendmail' */
12
+ path?: string | undefined;
13
+ /** Either 'windows' or 'unix', the line ending of the message piped to sendmail */
14
+ newline?: string | undefined;
15
+ /** Arguments for the sendmail binary, replaces the default '-f <sender>' */
16
+ args?: string[] | undefined;
17
+ }
18
+ /**
19
+ * The value the Sendmail transport hands to the send callback
20
+ */
21
+ export interface SendmailSentMessageInfo extends SentMessageInfo {
22
+ /** The envelope the message was sent with */
23
+ envelope: MimeNodeEnvelope;
24
+ /** Message-ID value of the message */
25
+ messageId: string;
26
+ /** Always 'Messages queued for delivery' */
27
+ response: string;
28
+ }
29
+ /**
30
+ * Generates a Transport object for Sendmail
31
+ *
32
+ * Possible options can be the following:
33
+ *
34
+ * * **path** optional path to sendmail binary
35
+ * * **newline** either 'windows' or 'unix'
36
+ * * **args** an array of arguments for the sendmail binary
37
+ *
38
+ * @constructor
39
+ * @param optional config parameter for Sendmail
40
+ */
41
+ declare class SendmailTransport {
42
+ mailer: Mail<SendmailSentMessageInfo>;
43
+ options: SendmailTransportOptions;
44
+ name: string;
45
+ version: string;
46
+ path: string;
47
+ args: string[] | false;
48
+ logger: Logger;
49
+ winbreak: boolean;
50
+ constructor(options?: SendmailTransportOptions | string);
51
+ /**
52
+ * <p>Compiles a mailcomposer message and forwards it to handler that sends it.</p>
53
+ *
54
+ * @param mail MailComposer object
55
+ * @param done Callback function to run when the sending is completed
56
+ */
57
+ send(mail: MailMessage<SendmailSentMessageInfo>, done: (err: Error | null, info?: SendmailSentMessageInfo) => void): void;
58
+ }
59
+ /**
60
+ * Type aliases in the layout of @types/nodemailer, so `SendmailTransport.Options` style references keep working
61
+ */
62
+ declare namespace SendmailTransport {
63
+ type Options = SendmailTransportOptions;
64
+ type MailOptions = SendMailOptions;
65
+ type SentMessageInfo = SendmailSentMessageInfo;
66
+ }
67
+ /** The same aliases as module level exports, for `import * as SendmailTransport` and `import SendmailTransport = require()` */
68
+ export type { SendmailTransportOptions as Options, SendMailOptions as MailOptions, SendmailSentMessageInfo as SentMessageInfo };
69
+ export default SendmailTransport;
@@ -0,0 +1,170 @@
1
+ import { spawn } from 'node:child_process';
2
+ import * as packageData from '../package-info.js';
3
+ import * as shared from '../shared/index.js';
4
+ import * as errors from '../errors.js';
5
+ import LeWindows from '../mime-node/le-windows.js';
6
+ import LeUnix from '../mime-node/le-unix.js';
7
+ /**
8
+ * Generates a Transport object for Sendmail
9
+ *
10
+ * Possible options can be the following:
11
+ *
12
+ * * **path** optional path to sendmail binary
13
+ * * **newline** either 'windows' or 'unix'
14
+ * * **args** an array of arguments for the sendmail binary
15
+ *
16
+ * @constructor
17
+ * @param optional config parameter for Sendmail
18
+ */
19
+ class SendmailTransport {
20
+ constructor(options) {
21
+ options = options || {};
22
+ // use a reference to spawn for mocking purposes
23
+ this._spawn = spawn;
24
+ this.options = options;
25
+ this.name = 'Sendmail';
26
+ this.version = packageData.version;
27
+ this.path = 'sendmail';
28
+ this.args = false;
29
+ this.logger = shared.getLogger(this.options, {
30
+ component: this.options.component || 'sendmail'
31
+ });
32
+ if (typeof options === 'string') {
33
+ this.path = options;
34
+ }
35
+ else if (typeof options === 'object') {
36
+ if (options.path) {
37
+ this.path = options.path;
38
+ }
39
+ if (Array.isArray(options.args)) {
40
+ this.args = options.args;
41
+ }
42
+ }
43
+ this.winbreak = ['win', 'windows', 'dos', '\r\n'].includes((options.newline || '').toString().toLowerCase());
44
+ }
45
+ /**
46
+ * <p>Compiles a mailcomposer message and forwards it to handler that sends it.</p>
47
+ *
48
+ * @param mail MailComposer object
49
+ * @param done Callback function to run when the sending is completed
50
+ */
51
+ send(mail, done) {
52
+ // Sendmail strips this header line by itself. send() runs after the message was
53
+ // compiled, so mail.message is set
54
+ mail.message.keepBcc = true;
55
+ const envelope = mail.message.getEnvelope();
56
+ const messageId = mail.message.messageId();
57
+ let returned;
58
+ const hasInvalidAddresses = []
59
+ .concat(envelope.from || [])
60
+ .concat(envelope.to || [])
61
+ // a local part is either a dot-atom or a quoted-string, so a leading dash sits at
62
+ // offset 0 or, behind the opening quote, at offset 1. Only the first shape is read
63
+ // as an option by sendmail, but both are the address this guard keeps out of argv
64
+ .some(addr => /^"?-/.test(addr));
65
+ if (hasInvalidAddresses) {
66
+ const err = new Error('Can not send mail. Invalid envelope addresses.');
67
+ err.code = errors.ESENDMAIL;
68
+ return done(err);
69
+ }
70
+ // force -i to keep single dots
71
+ const args = this.args
72
+ ? ['-i'].concat(this.args).concat(envelope.to)
73
+ : ['-i'].concat(envelope.from ? ['-f', envelope.from] : []).concat(envelope.to);
74
+ const callback = (err) => {
75
+ if (returned) {
76
+ // ignore any additional responses, already done
77
+ return;
78
+ }
79
+ returned = true;
80
+ if (typeof done === 'function') {
81
+ if (err) {
82
+ return done(err);
83
+ }
84
+ return done(null, {
85
+ envelope,
86
+ messageId,
87
+ response: 'Messages queued for delivery'
88
+ });
89
+ }
90
+ };
91
+ let sendmail;
92
+ try {
93
+ sendmail = this._spawn(this.path, args);
94
+ }
95
+ catch (E) {
96
+ this.logger.error({
97
+ err: E,
98
+ tnx: 'spawn',
99
+ messageId
100
+ }, 'Error occurred while spawning sendmail. %s', E.message);
101
+ return callback(E);
102
+ }
103
+ if (sendmail) {
104
+ sendmail.on('error', err => {
105
+ this.logger.error({
106
+ err,
107
+ tnx: 'spawn',
108
+ messageId
109
+ }, 'Error occurred when sending message %s. %s', messageId, err.message);
110
+ callback(err);
111
+ });
112
+ sendmail.once('exit', code => {
113
+ if (!code) {
114
+ return callback();
115
+ }
116
+ const err = new Error(code === 127 ? 'Sendmail command not found, process exited with code ' + code : 'Sendmail exited with code ' + code);
117
+ err.code = errors.ESENDMAIL;
118
+ this.logger.error({
119
+ err,
120
+ tnx: 'stdin',
121
+ messageId
122
+ }, 'Error sending message %s to sendmail. %s', messageId, err.message);
123
+ callback(err);
124
+ });
125
+ // the close listener is handed the exit code as its first argument, so a non-zero
126
+ // code reaching it before the exit listener did counts as the error value
127
+ sendmail.once('close', callback);
128
+ sendmail.stdin.on('error', err => {
129
+ this.logger.error({
130
+ err,
131
+ tnx: 'stdin',
132
+ messageId
133
+ }, 'Error occurred when piping message %s to sendmail. %s', messageId, err.message);
134
+ callback(err);
135
+ });
136
+ const recipients = [].concat(envelope.to || []);
137
+ if (recipients.length > 3) {
138
+ recipients.push('...and ' + recipients.splice(2).length + ' more');
139
+ }
140
+ this.logger.info({
141
+ tnx: 'send',
142
+ messageId
143
+ }, 'Sending message %s to <%s>', messageId, recipients.join(', '));
144
+ const sourceStream = mail.message.createReadStream();
145
+ let stream = sourceStream;
146
+ if (this.options.newline) {
147
+ // apply the transport-level line ending transform; the message-level
148
+ // `newline` option is handled by MimeNode in createReadStream()
149
+ stream = sourceStream.pipe(this.winbreak ? new LeWindows() : new LeUnix());
150
+ sourceStream.once('error', err => stream.emit('error', err));
151
+ }
152
+ stream.once('error', err => {
153
+ this.logger.error({
154
+ err,
155
+ tnx: 'stdin',
156
+ messageId
157
+ }, 'Error occurred when generating message %s. %s', messageId, err.message);
158
+ sendmail.kill('SIGINT'); // do not deliver the message
159
+ callback(err);
160
+ });
161
+ stream.pipe(sendmail.stdin);
162
+ }
163
+ else {
164
+ const err = new Error('sendmail was not found');
165
+ err.code = errors.ESENDMAIL;
166
+ return callback(err);
167
+ }
168
+ }
169
+ }
170
+ export default SendmailTransport;
@@ -0,0 +1,112 @@
1
+ import EventEmitter from 'node:events';
2
+ import type { Logger } from '../shared/index.js';
3
+ import { type MimeNodeEnvelope } from '../mime-node/index.js';
4
+ import type MailMessage from '../mailer/mail-message.js';
5
+ import type { default as Mail, SentMessageInfo, SendMailOptions, TransportOptions, VerifyCallback } from '../mailer/index.js';
6
+ /**
7
+ * Options for the SES transport
8
+ */
9
+ export interface SESTransportOptions extends TransportOptions {
10
+ /** The AWS SDK v3 objects to send with, `{ sesClient, SendEmailCommand }` from @aws-sdk/client-sesv2 */
11
+ SES: {
12
+ /** SESv2Client instance. Its config.region provider is resolved for the domain of the returned Message-ID */
13
+ sesClient: {
14
+ config?: {
15
+ region?: (() => Promise<string>) | undefined;
16
+ [key: string]: any;
17
+ } | undefined;
18
+ send(command: unknown): Promise<any>;
19
+ };
20
+ /** SendEmailCommand class, constructed with the SendEmailCommandInput of every message */
21
+ SendEmailCommand: new (input: any) => unknown;
22
+ };
23
+ }
24
+ /** The SESv2Client shape the transport needs */
25
+ export type SESTransportClient = SESTransportOptions['SES']['sesClient'];
26
+ /** The SendEmailCommand constructor shape the transport needs */
27
+ export type SESTransportSendEmailCommand = SESTransportOptions['SES']['SendEmailCommand'];
28
+ /**
29
+ * SendEmailCommand parameters, the shape of the `ses` message option that is merged into
30
+ * the API call. Any further SendEmailCommandInput field is accepted as well
31
+ */
32
+ export interface SESSendEmailRequest {
33
+ FromEmailAddress?: string | undefined;
34
+ Destination?: {
35
+ ToAddresses?: string[] | undefined;
36
+ CcAddresses?: string[] | undefined;
37
+ BccAddresses?: string[] | undefined;
38
+ } | undefined;
39
+ ReplyToAddresses?: string[] | undefined;
40
+ Content?: unknown;
41
+ EmailTags?: Array<{
42
+ Name?: string | undefined;
43
+ Value?: string | undefined;
44
+ }> | undefined;
45
+ ConfigurationSetName?: string | undefined;
46
+ ListManagementOptions?: unknown;
47
+ FeedbackForwardingEmailAddress?: string | undefined;
48
+ [key: string]: unknown;
49
+ }
50
+ /**
51
+ * The value the SES transport hands to the send callback
52
+ */
53
+ export interface SESSentMessageInfo extends SentMessageInfo {
54
+ /** The envelope the message was sent with */
55
+ envelope: MimeNodeEnvelope;
56
+ /** Message-ID built from the MessageId SES returned */
57
+ messageId: string;
58
+ /** The MessageId SES returned */
59
+ response: string;
60
+ /** The raw RFC822 message that was sent */
61
+ raw: Buffer;
62
+ }
63
+ /**
64
+ * Generates a Transport object for AWS SES
65
+ *
66
+ * @constructor
67
+ * @param optional config parameter
68
+ */
69
+ declare class SESTransport extends EventEmitter {
70
+ mailer: Mail<SESSentMessageInfo>;
71
+ options: SESTransportOptions;
72
+ ses: SESTransportOptions['SES'];
73
+ name: string;
74
+ version: string;
75
+ logger: Logger;
76
+ constructor(options: SESTransportOptions);
77
+ getRegion(cb: (err: Error | null, region?: string | false) => void): void;
78
+ /**
79
+ * Compiles a mailcomposer message and forwards it to SES
80
+ *
81
+ * @param mail MailComposer object
82
+ * @param callback Callback function to run when the sending is completed
83
+ */
84
+ send(mail: MailMessage<SESSentMessageInfo>, callback: (err: Error | null, info?: SESSentMessageInfo) => void): void;
85
+ /**
86
+ * Verifies SES configuration
87
+ *
88
+ * @returns Promise that resolves to true if the configuration is usable
89
+ */
90
+ verify(): Promise<true>;
91
+ /**
92
+ * Verifies SES configuration
93
+ *
94
+ * @param callback Callback function
95
+ */
96
+ verify(callback: VerifyCallback): void;
97
+ }
98
+ /**
99
+ * Type aliases in the layout of @types/nodemailer, so `SESTransport.Options` style references keep working
100
+ */
101
+ declare namespace SESTransport {
102
+ type Options = SESTransportOptions;
103
+ type MailOptions = SendMailOptions;
104
+ type SentMessageInfo = SESSentMessageInfo;
105
+ type SESv2ClientLike = SESTransportClient;
106
+ type SendEmailCommandConstructorLike = SESTransportSendEmailCommand;
107
+ type SendEmailRequestLike = SESSendEmailRequest;
108
+ type MailSesOptions = SESSendEmailRequest;
109
+ }
110
+ /** The same aliases as module level exports, for `import * as SESTransport` and `import SESTransport = require()` */
111
+ export type { SESTransportOptions as Options, SendMailOptions as MailOptions, SESSentMessageInfo as SentMessageInfo, SESTransportClient as SESv2ClientLike, SESTransportSendEmailCommand as SendEmailCommandConstructorLike, SESSendEmailRequest as SendEmailRequestLike, SESSendEmailRequest as MailSesOptions };
112
+ export default SESTransport;