@nocobase/plugin-workflow-mailer 2.3.0-beta.12 → 2.3.0-beta.14

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
@@ -0,0 +1,613 @@
1
+ "use strict";
2
+ /* eslint no-undefined: 0 */
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ const index_js_1 = __importDefault(require("../mime-node/index.js"));
41
+ const mimeFuncs = __importStar(require("../mime-funcs/index.js"));
42
+ const index_js_2 = require("../shared/index.js");
43
+ /**
44
+ * Creates the object for composing a MimeNode instance out from the mail options
45
+ *
46
+ * @constructor
47
+ * @param mail Mail options
48
+ */
49
+ /**
50
+ * Tells whether a content value is a content descriptor object (something to load or to
51
+ * use as is) rather than the content itself
52
+ */
53
+ function isContentObject(value) {
54
+ const content = value;
55
+ return typeof value === 'object' && !!(content.content || content.path || content.href || content.raw);
56
+ }
57
+ class MailComposer {
58
+ constructor(mail) {
59
+ this.mail = mail || {};
60
+ this.message = false;
61
+ }
62
+ /**
63
+ * Builds MimeNode instance
64
+ */
65
+ compile() {
66
+ this._alternatives = this.getAlternatives();
67
+ this._htmlNode = this._alternatives.filter(alternative => /^text\/html\b/i.test(alternative.contentType)).pop();
68
+ this._attachments = this.getAttachments(!!this._htmlNode);
69
+ this._useRelated = !!(this._htmlNode && this._attachments.related.length);
70
+ this._useAlternative = this._alternatives.length > 1;
71
+ this._useMixed = this._attachments.attached.length > 1 || (this._alternatives.length && this._attachments.attached.length === 1);
72
+ // Compose MIME tree
73
+ if (this.mail.raw) {
74
+ this.message = new index_js_1.default('message/rfc822', {
75
+ newline: this.mail.newline,
76
+ disableUrlAccess: this.mail.disableUrlAccess,
77
+ disableFileAccess: this.mail.disableFileAccess
78
+ }).setRaw(this.mail.raw);
79
+ }
80
+ else if (this._useMixed) {
81
+ this.message = this._createMixed();
82
+ }
83
+ else if (this._useAlternative) {
84
+ this.message = this._createAlternative();
85
+ }
86
+ else if (this._useRelated) {
87
+ this.message = this._createRelated();
88
+ }
89
+ else {
90
+ this.message = this._createContentNode(false, []
91
+ .concat(this._alternatives || [])
92
+ .concat(this._attachments.attached || [])
93
+ .shift() || {
94
+ contentType: 'text/plain',
95
+ content: ''
96
+ });
97
+ }
98
+ // Add custom headers
99
+ if (this.mail.headers) {
100
+ this.message.addHeader(this.mail.headers);
101
+ }
102
+ // Add headers to the root node, always overrides custom headers
103
+ ['from', 'sender', 'to', 'cc', 'bcc', 'reply-to', 'in-reply-to', 'references', 'subject', 'message-id', 'date'].forEach(header => {
104
+ const key = header.replace(/-(\w)/g, (o, c) => c.toUpperCase());
105
+ if (this.mail[key]) {
106
+ this.message.setHeader(header, this.mail[key]);
107
+ }
108
+ });
109
+ // Sets custom envelope
110
+ if (this.mail.envelope) {
111
+ this.message.setEnvelope(this.mail.envelope);
112
+ }
113
+ // ensure Message-Id value
114
+ this.message.messageId();
115
+ return this.message;
116
+ }
117
+ /**
118
+ * List all attachments. Resulting attachment objects can be used as input for MimeNode nodes
119
+ *
120
+ * @param findRelated If true separate related attachments from attached ones
121
+ * @returns An object of arrays (`related` and `attached`)
122
+ */
123
+ getAttachments(findRelated) {
124
+ let eventObject;
125
+ const attachments = [].concat(this.mail.attachments || []).map((attachment, i) => {
126
+ if (/^data:/i.test((attachment.path || attachment.href))) {
127
+ attachment = this._processDataUrl(attachment);
128
+ }
129
+ const contentType = attachment.contentType || mimeFuncs.detectMimeType(attachment.filename || attachment.path || attachment.href || 'bin');
130
+ const isImage = /^image\//i.test(contentType);
131
+ const isMessageNode = /^message\//i.test(contentType);
132
+ const contentDisposition = attachment.contentDisposition || (isMessageNode || (isImage && attachment.cid) ? 'inline' : 'attachment');
133
+ let contentTransferEncoding;
134
+ if ('contentTransferEncoding' in attachment) {
135
+ // also contains `false`, to set
136
+ contentTransferEncoding = attachment.contentTransferEncoding;
137
+ }
138
+ else if (isMessageNode) {
139
+ // the content might include non-ASCII bytes but at this point we do not know it yet
140
+ contentTransferEncoding = '8bit';
141
+ }
142
+ else {
143
+ contentTransferEncoding = 'base64'; // the default
144
+ }
145
+ const data = {
146
+ contentType,
147
+ contentDisposition,
148
+ contentTransferEncoding
149
+ };
150
+ if (attachment.filename) {
151
+ data.filename = attachment.filename;
152
+ }
153
+ else if (!isMessageNode && attachment.filename !== false) {
154
+ // a backslash separates as well, so a Windows path does not put the sender's directories in the headers
155
+ data.filename =
156
+ (attachment.path || attachment.href || '').split(/[/\\]/).pop().split('?').shift() ||
157
+ 'attachment-' + (i + 1);
158
+ if (data.filename.indexOf('.') < 0) {
159
+ data.filename += '.' + mimeFuncs.detectExtension(data.contentType);
160
+ }
161
+ }
162
+ if (/^https?:\/\//i.test(attachment.path)) {
163
+ attachment.href = attachment.path;
164
+ attachment.path = undefined;
165
+ }
166
+ if (attachment.cid) {
167
+ data.cid = attachment.cid;
168
+ }
169
+ if (attachment.raw) {
170
+ data.raw = attachment.raw;
171
+ }
172
+ else if (attachment.path) {
173
+ data.content = {
174
+ path: attachment.path
175
+ };
176
+ }
177
+ else if (attachment.href) {
178
+ data.content = {
179
+ href: attachment.href,
180
+ httpHeaders: attachment.httpHeaders,
181
+ tls: attachment.tls
182
+ };
183
+ }
184
+ else {
185
+ data.content = attachment.content || '';
186
+ }
187
+ if (attachment.encoding) {
188
+ data.encoding = attachment.encoding;
189
+ }
190
+ if (attachment.headers) {
191
+ data.headers = attachment.headers;
192
+ }
193
+ return data;
194
+ });
195
+ if (this.mail.icalEvent) {
196
+ eventObject = Object.assign({}, this._getIcalEvent());
197
+ eventObject.contentType = 'application/ics';
198
+ if (!eventObject.headers) {
199
+ eventObject.headers = {};
200
+ }
201
+ eventObject.filename = eventObject.filename || 'invite.ics';
202
+ eventObject.headers['Content-Disposition'] = 'attachment';
203
+ eventObject.headers['Content-Transfer-Encoding'] = 'base64';
204
+ }
205
+ if (!findRelated) {
206
+ return {
207
+ attached: attachments.concat(eventObject || []),
208
+ related: []
209
+ };
210
+ }
211
+ return {
212
+ attached: attachments.filter(attachment => !attachment.cid).concat(eventObject || []),
213
+ related: attachments.filter(attachment => !!attachment.cid)
214
+ };
215
+ }
216
+ /**
217
+ * Returns the icalEvent value with `path`/`href`/data uri input normalized into
218
+ * a `content` entry, the same way as for regular attachments. The same event is
219
+ * included twice (as a text/calendar alternative and as an application/ics
220
+ * attachment), so the shared content object is marked to be resolved just once
221
+ * and the buffered result is reused by the second node.
222
+ *
223
+ * @returns Normalized icalEvent data
224
+ * @internal
225
+ */
226
+ _getIcalEvent() {
227
+ if (!this._icalEvent) {
228
+ let icalEvent;
229
+ if (isContentObject(this.mail.icalEvent)) {
230
+ // an own "__proto__" key would make the copy inherit path/href from caller
231
+ // data, and the mapping below then replaces the content the caller did set
232
+ icalEvent = (0, index_js_2.copyOwnKeys)({}, this.mail.icalEvent);
233
+ }
234
+ else {
235
+ icalEvent = {
236
+ content: this.mail.icalEvent
237
+ };
238
+ }
239
+ if (/^data:/i.test((icalEvent.path || icalEvent.href))) {
240
+ icalEvent = this._processDataUrl(icalEvent);
241
+ }
242
+ if (/^https?:\/\//i.test(icalEvent.path)) {
243
+ icalEvent.href = icalEvent.path;
244
+ icalEvent.path = undefined;
245
+ }
246
+ if (!icalEvent.raw) {
247
+ // map file path and URL values into `content`, otherwise the content
248
+ // nodes would render an empty body
249
+ if (icalEvent.path) {
250
+ icalEvent.content = {
251
+ path: icalEvent.path
252
+ };
253
+ icalEvent.path = undefined;
254
+ }
255
+ else if (icalEvent.href) {
256
+ icalEvent.content = {
257
+ href: icalEvent.href,
258
+ httpHeaders: icalEvent.httpHeaders,
259
+ tls: icalEvent.tls
260
+ };
261
+ icalEvent.href = undefined;
262
+ }
263
+ }
264
+ if (icalEvent.content && typeof icalEvent.content === 'object') {
265
+ // we are going to have the same attachment twice, so mark this to be
266
+ // resolved just once
267
+ icalEvent.content._resolve = true;
268
+ }
269
+ this._icalEvent = icalEvent;
270
+ }
271
+ return this._icalEvent;
272
+ }
273
+ /**
274
+ * List alternatives. Resulting objects can be used as input for MimeNode nodes
275
+ *
276
+ * @returns An array of alternative elements. Includes the `text` and `html` values as well
277
+ */
278
+ getAlternatives() {
279
+ const alternatives = [];
280
+ let text, html, watchHtml, amp, eventObject;
281
+ if (this.mail.text) {
282
+ if (isContentObject(this.mail.text)) {
283
+ text = this.mail.text;
284
+ }
285
+ else {
286
+ text = {
287
+ content: this.mail.text
288
+ };
289
+ }
290
+ text.contentType = 'text/plain; charset=utf-8';
291
+ }
292
+ if (this.mail.watchHtml) {
293
+ if (isContentObject(this.mail.watchHtml)) {
294
+ watchHtml = this.mail.watchHtml;
295
+ }
296
+ else {
297
+ watchHtml = {
298
+ content: this.mail.watchHtml
299
+ };
300
+ }
301
+ watchHtml.contentType = 'text/watch-html; charset=utf-8';
302
+ }
303
+ if (this.mail.amp) {
304
+ if (isContentObject(this.mail.amp)) {
305
+ amp = this.mail.amp;
306
+ }
307
+ else {
308
+ amp = {
309
+ content: this.mail.amp
310
+ };
311
+ }
312
+ amp.contentType = 'text/x-amp-html; charset=utf-8';
313
+ }
314
+ // NB! when including attachments with a calendar alternative you might end up in a blank screen on some clients
315
+ if (this.mail.icalEvent) {
316
+ eventObject = Object.assign({}, this._getIcalEvent());
317
+ eventObject.filename = false;
318
+ eventObject.contentType =
319
+ 'text/calendar; charset=utf-8; method=' + (eventObject.method || 'PUBLISH').toString().trim().toUpperCase();
320
+ if (!eventObject.headers) {
321
+ eventObject.headers = {};
322
+ }
323
+ }
324
+ if (this.mail.html) {
325
+ if (isContentObject(this.mail.html)) {
326
+ html = this.mail.html;
327
+ }
328
+ else {
329
+ html = {
330
+ content: this.mail.html
331
+ };
332
+ }
333
+ html.contentType = 'text/html; charset=utf-8';
334
+ }
335
+ []
336
+ .concat(text || [])
337
+ .concat(watchHtml || [])
338
+ .concat(amp || [])
339
+ .concat(html || [])
340
+ .concat(eventObject || [])
341
+ .concat(this.mail.alternatives || [])
342
+ .forEach(alternative => {
343
+ if (/^data:/i.test((alternative.path || alternative.href))) {
344
+ alternative = this._processDataUrl(alternative);
345
+ }
346
+ const data = {
347
+ contentType: alternative.contentType ||
348
+ mimeFuncs.detectMimeType(alternative.filename || alternative.path || alternative.href || 'txt'),
349
+ contentTransferEncoding: alternative.contentTransferEncoding
350
+ };
351
+ if (alternative.filename) {
352
+ data.filename = alternative.filename;
353
+ }
354
+ if (/^https?:\/\//i.test(alternative.path)) {
355
+ alternative.href = alternative.path;
356
+ alternative.path = undefined;
357
+ }
358
+ if (alternative.raw) {
359
+ data.raw = alternative.raw;
360
+ }
361
+ else if (alternative.path) {
362
+ data.content = {
363
+ path: alternative.path
364
+ };
365
+ }
366
+ else if (alternative.href) {
367
+ data.content = {
368
+ href: alternative.href,
369
+ httpHeaders: alternative.httpHeaders,
370
+ tls: alternative.tls
371
+ };
372
+ }
373
+ else {
374
+ data.content = alternative.content || '';
375
+ }
376
+ if (alternative.encoding) {
377
+ data.encoding = alternative.encoding;
378
+ }
379
+ if (alternative.headers) {
380
+ data.headers = alternative.headers;
381
+ }
382
+ alternatives.push(data);
383
+ });
384
+ return alternatives;
385
+ }
386
+ /**
387
+ * Builds multipart/mixed node. It should always contain different type of elements on the same level
388
+ * eg. text + attachments
389
+ *
390
+ * @param parentNode Parent for this note. If it does not exist, a root node is created
391
+ * @returns MimeNode node element
392
+ * @internal
393
+ */
394
+ _createMixed(parentNode) {
395
+ const node = parentNode
396
+ ? parentNode.createChild('multipart/mixed', {
397
+ disableUrlAccess: this.mail.disableUrlAccess,
398
+ disableFileAccess: this.mail.disableFileAccess,
399
+ normalizeHeaderKey: this.mail.normalizeHeaderKey,
400
+ newline: this.mail.newline
401
+ })
402
+ : new index_js_1.default('multipart/mixed', {
403
+ baseBoundary: this.mail.baseBoundary,
404
+ textEncoding: this.mail.textEncoding,
405
+ boundaryPrefix: this.mail.boundaryPrefix,
406
+ disableUrlAccess: this.mail.disableUrlAccess,
407
+ disableFileAccess: this.mail.disableFileAccess,
408
+ normalizeHeaderKey: this.mail.normalizeHeaderKey,
409
+ newline: this.mail.newline
410
+ });
411
+ if (this._useAlternative) {
412
+ this._createAlternative(node);
413
+ }
414
+ else if (this._useRelated) {
415
+ this._createRelated(node);
416
+ }
417
+ []
418
+ .concat((!this._useAlternative && this._alternatives) || [])
419
+ .concat(this._attachments.attached || [])
420
+ .forEach(element => {
421
+ // if the element is a html node from related subpart then ignore it
422
+ if (!this._useRelated || element !== this._htmlNode) {
423
+ this._createContentNode(node, element);
424
+ }
425
+ });
426
+ return node;
427
+ }
428
+ /**
429
+ * Builds multipart/alternative node. It should always contain same type of elements on the same level
430
+ * eg. text + html view of the same data
431
+ *
432
+ * @param parentNode Parent for this note. If it does not exist, a root node is created
433
+ * @returns MimeNode node element
434
+ * @internal
435
+ */
436
+ _createAlternative(parentNode) {
437
+ const node = parentNode
438
+ ? parentNode.createChild('multipart/alternative', {
439
+ disableUrlAccess: this.mail.disableUrlAccess,
440
+ disableFileAccess: this.mail.disableFileAccess,
441
+ normalizeHeaderKey: this.mail.normalizeHeaderKey,
442
+ newline: this.mail.newline
443
+ })
444
+ : new index_js_1.default('multipart/alternative', {
445
+ baseBoundary: this.mail.baseBoundary,
446
+ textEncoding: this.mail.textEncoding,
447
+ boundaryPrefix: this.mail.boundaryPrefix,
448
+ disableUrlAccess: this.mail.disableUrlAccess,
449
+ disableFileAccess: this.mail.disableFileAccess,
450
+ normalizeHeaderKey: this.mail.normalizeHeaderKey,
451
+ newline: this.mail.newline
452
+ });
453
+ this._alternatives.forEach(alternative => {
454
+ if (this._useRelated && this._htmlNode === alternative) {
455
+ this._createRelated(node);
456
+ }
457
+ else {
458
+ this._createContentNode(node, alternative);
459
+ }
460
+ });
461
+ return node;
462
+ }
463
+ /**
464
+ * Builds multipart/related node. It should always contain html node with related attachments
465
+ *
466
+ * @param parentNode Parent for this note. If it does not exist, a root node is created
467
+ * @returns MimeNode node element
468
+ * @internal
469
+ */
470
+ _createRelated(parentNode) {
471
+ const node = parentNode
472
+ ? parentNode.createChild('multipart/related; type="text/html"', {
473
+ disableUrlAccess: this.mail.disableUrlAccess,
474
+ disableFileAccess: this.mail.disableFileAccess,
475
+ normalizeHeaderKey: this.mail.normalizeHeaderKey,
476
+ newline: this.mail.newline
477
+ })
478
+ : new index_js_1.default('multipart/related; type="text/html"', {
479
+ baseBoundary: this.mail.baseBoundary,
480
+ textEncoding: this.mail.textEncoding,
481
+ boundaryPrefix: this.mail.boundaryPrefix,
482
+ disableUrlAccess: this.mail.disableUrlAccess,
483
+ disableFileAccess: this.mail.disableFileAccess,
484
+ normalizeHeaderKey: this.mail.normalizeHeaderKey,
485
+ newline: this.mail.newline
486
+ });
487
+ this._createContentNode(node, this._htmlNode);
488
+ this._attachments.related.forEach(alternative => this._createContentNode(node, alternative));
489
+ return node;
490
+ }
491
+ /**
492
+ * Creates a regular node with contents
493
+ *
494
+ * @param parentNode Parent for this note. If it does not exist, a root node is created
495
+ * @param element Node data
496
+ * @returns MimeNode node element
497
+ * @internal
498
+ */
499
+ _createContentNode(parentNode, element) {
500
+ element = element || {};
501
+ element.content = element.content || '';
502
+ const encoding = (element.encoding || 'utf8')
503
+ .toString()
504
+ .toLowerCase()
505
+ .replace(/[-_\s]/g, '');
506
+ const node = parentNode
507
+ ? parentNode.createChild(element.contentType, {
508
+ filename: element.filename,
509
+ textEncoding: this.mail.textEncoding,
510
+ disableUrlAccess: this.mail.disableUrlAccess,
511
+ disableFileAccess: this.mail.disableFileAccess,
512
+ normalizeHeaderKey: this.mail.normalizeHeaderKey,
513
+ newline: this.mail.newline
514
+ })
515
+ : new index_js_1.default(element.contentType, {
516
+ filename: element.filename,
517
+ baseBoundary: this.mail.baseBoundary,
518
+ textEncoding: this.mail.textEncoding,
519
+ boundaryPrefix: this.mail.boundaryPrefix,
520
+ disableUrlAccess: this.mail.disableUrlAccess,
521
+ disableFileAccess: this.mail.disableFileAccess,
522
+ normalizeHeaderKey: this.mail.normalizeHeaderKey,
523
+ newline: this.mail.newline
524
+ });
525
+ // add custom headers
526
+ if (element.headers) {
527
+ node.addHeader(element.headers);
528
+ }
529
+ if (element.cid) {
530
+ node.setHeader('Content-Id', '<' + element.cid.replace(/[<>]/g, '') + '>');
531
+ }
532
+ if (element.contentTransferEncoding) {
533
+ node.setHeader('Content-Transfer-Encoding', element.contentTransferEncoding);
534
+ }
535
+ else if (this.mail.encoding && /^text\//i.test(element.contentType)) {
536
+ node.setHeader('Content-Transfer-Encoding', this.mail.encoding);
537
+ }
538
+ if (!/^text\//i.test(element.contentType) || element.contentDisposition) {
539
+ node.setHeader('Content-Disposition', element.contentDisposition || (element.cid && /^image\//i.test(element.contentType) ? 'inline' : 'attachment'));
540
+ }
541
+ if (typeof element.content === 'string' && !['utf8', 'usascii', 'ascii'].includes(encoding)) {
542
+ element.content = Buffer.from(element.content, encoding);
543
+ }
544
+ // prefer pregenerated raw content
545
+ if (element.raw) {
546
+ node.setRaw(element.raw);
547
+ }
548
+ else {
549
+ node.setContent(element.content);
550
+ }
551
+ return node;
552
+ }
553
+ /**
554
+ * Parses data uri and converts it to a Buffer
555
+ *
556
+ * @param element Content element
557
+ * @return Parsed element
558
+ * @internal
559
+ */
560
+ _processDataUrl(element) {
561
+ const dataUrl = element.path || element.href;
562
+ // Early validation to prevent ReDoS
563
+ if (!dataUrl || typeof dataUrl !== 'string') {
564
+ return element;
565
+ }
566
+ if (!dataUrl.startsWith('data:')) {
567
+ return element;
568
+ }
569
+ if (dataUrl.length > 52428800) {
570
+ // 52428800 chars = 50MB limit for data URL string (~37.5MB decoded image)
571
+ // Extract content type before rejecting to preserve MIME type
572
+ let detectedType = 'application/octet-stream';
573
+ const commaPos = dataUrl.indexOf(',');
574
+ if (commaPos > 0 && commaPos < 200) {
575
+ // Parse header safely with size limit
576
+ const header = dataUrl.substring(5, commaPos); // skip 'data:'
577
+ const parts = header.split(';');
578
+ if (parts[0] && parts[0].includes('/')) {
579
+ detectedType = parts[0].trim();
580
+ }
581
+ }
582
+ // Return empty content for excessively long data URLs
583
+ return Object.assign((0, index_js_2.copyOwnKeys)({}, element), {
584
+ path: false,
585
+ href: false,
586
+ content: Buffer.alloc(0),
587
+ contentType: element.contentType || detectedType
588
+ });
589
+ }
590
+ let parsedDataUri;
591
+ try {
592
+ parsedDataUri = (0, index_js_2.parseDataURI)(dataUrl);
593
+ }
594
+ catch (_err) {
595
+ return element;
596
+ }
597
+ if (!parsedDataUri) {
598
+ return element;
599
+ }
600
+ element.content = parsedDataUri.data;
601
+ element.contentType = element.contentType || parsedDataUri.contentType;
602
+ if ('path' in element) {
603
+ element.path = false;
604
+ }
605
+ if ('href' in element) {
606
+ element.href = false;
607
+ }
608
+ return element;
609
+ }
610
+ }
611
+ exports.default = MailComposer;
612
+ module.exports = exports.default;
613
+ Object.defineProperty(module.exports, 'default', { value: exports.default, enumerable: false, writable: true, configurable: true });