@nocobase/plugin-workflow-mailer 2.3.0-beta.13 → 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 (173) hide show
  1. package/dist/externalVersion.js +6 -6
  2. package/dist/node_modules/joi/package.json +1 -1
  3. package/dist/node_modules/nodemailer/dist/cjs/addressparser/index.d.ts +59 -0
  4. package/dist/node_modules/nodemailer/dist/cjs/addressparser/index.js +790 -0
  5. package/dist/node_modules/nodemailer/dist/cjs/base64/index.d.ts +36 -0
  6. package/dist/node_modules/nodemailer/dist/cjs/base64/index.js +119 -0
  7. package/dist/node_modules/nodemailer/dist/cjs/dkim/index.d.ts +52 -0
  8. package/dist/node_modules/nodemailer/dist/cjs/dkim/index.js +228 -0
  9. package/dist/node_modules/nodemailer/dist/cjs/dkim/message-parser.d.ts +48 -0
  10. package/dist/node_modules/nodemailer/dist/cjs/dkim/message-parser.js +180 -0
  11. package/dist/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.d.ts +36 -0
  12. package/dist/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.js +148 -0
  13. package/dist/node_modules/nodemailer/dist/cjs/dkim/sign.d.ts +52 -0
  14. package/dist/node_modules/nodemailer/dist/cjs/dkim/sign.js +165 -0
  15. package/dist/node_modules/nodemailer/dist/cjs/errors.d.ts +96 -0
  16. package/dist/node_modules/nodemailer/dist/cjs/errors.js +70 -0
  17. package/dist/node_modules/nodemailer/dist/cjs/fetch/cookies.d.ts +107 -0
  18. package/dist/node_modules/nodemailer/dist/cjs/fetch/cookies.js +282 -0
  19. package/dist/node_modules/nodemailer/dist/cjs/fetch/index.d.ts +65 -0
  20. package/dist/node_modules/nodemailer/dist/cjs/fetch/index.js +384 -0
  21. package/dist/node_modules/nodemailer/dist/cjs/json-transport/index.d.ts +64 -0
  22. package/dist/node_modules/nodemailer/dist/cjs/json-transport/index.js +99 -0
  23. package/dist/node_modules/nodemailer/dist/cjs/mail-composer/index.d.ts +174 -0
  24. package/dist/node_modules/nodemailer/dist/cjs/mail-composer/index.js +613 -0
  25. package/dist/node_modules/nodemailer/dist/cjs/mailer/index.d.ts +237 -0
  26. package/dist/node_modules/nodemailer/dist/cjs/mailer/index.js +415 -0
  27. package/dist/node_modules/nodemailer/dist/cjs/mailer/mail-message.d.ts +97 -0
  28. package/dist/node_modules/nodemailer/dist/cjs/mailer/mail-message.js +342 -0
  29. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/index.d.ts +161 -0
  30. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/index.js +787 -0
  31. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/mime-types.d.ts +2 -0
  32. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/mime-types.js +2103 -0
  33. package/dist/node_modules/nodemailer/dist/cjs/mime-node/index.d.ts +333 -0
  34. package/dist/node_modules/nodemailer/dist/cjs/mime-node/index.js +1493 -0
  35. package/dist/node_modules/nodemailer/dist/cjs/mime-node/last-newline.d.ts +5 -0
  36. package/dist/node_modules/nodemailer/dist/cjs/mime-node/last-newline.js +32 -0
  37. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-unix.d.ts +9 -0
  38. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-unix.js +40 -0
  39. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-windows.d.ts +10 -0
  40. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-windows.js +47 -0
  41. package/dist/node_modules/nodemailer/dist/cjs/nodemailer.d.ts +124 -0
  42. package/dist/node_modules/nodemailer/dist/cjs/nodemailer.js +1 -0
  43. package/dist/node_modules/nodemailer/dist/cjs/package-info.d.ts +3 -0
  44. package/dist/node_modules/nodemailer/dist/cjs/package-info.js +7 -0
  45. package/dist/node_modules/nodemailer/dist/cjs/package.json +3 -0
  46. package/dist/node_modules/nodemailer/dist/cjs/punycode/index.d.ts +73 -0
  47. package/dist/node_modules/nodemailer/{lib → dist/cjs}/punycode/index.js +62 -111
  48. package/dist/node_modules/nodemailer/dist/cjs/qp/index.d.ts +32 -0
  49. package/dist/node_modules/nodemailer/dist/cjs/qp/index.js +207 -0
  50. package/dist/node_modules/nodemailer/dist/cjs/sendmail-transport/index.d.ts +69 -0
  51. package/dist/node_modules/nodemailer/dist/cjs/sendmail-transport/index.js +210 -0
  52. package/dist/node_modules/nodemailer/dist/cjs/ses-transport/index.d.ts +112 -0
  53. package/dist/node_modules/nodemailer/dist/cjs/ses-transport/index.js +252 -0
  54. package/dist/node_modules/nodemailer/dist/cjs/shared/index.d.ts +260 -0
  55. package/dist/node_modules/nodemailer/dist/cjs/shared/index.js +680 -0
  56. package/dist/node_modules/nodemailer/dist/cjs/shared/objects.d.ts +23 -0
  57. package/dist/node_modules/nodemailer/dist/cjs/shared/objects.js +43 -0
  58. package/dist/node_modules/nodemailer/dist/cjs/shared/url.d.ts +21 -0
  59. package/dist/node_modules/nodemailer/dist/cjs/shared/url.js +255 -0
  60. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.d.ts +15 -0
  61. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.js +108 -0
  62. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.d.ts +47 -0
  63. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.js +189 -0
  64. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/index.d.ts +416 -0
  65. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/index.js +1837 -0
  66. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/index.d.ts +133 -0
  67. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/index.js +569 -0
  68. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.d.ts +62 -0
  69. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.js +257 -0
  70. package/dist/node_modules/nodemailer/dist/cjs/smtp-transport/index.d.ts +156 -0
  71. package/dist/node_modules/nodemailer/dist/cjs/smtp-transport/index.js +371 -0
  72. package/dist/node_modules/nodemailer/dist/cjs/stream-transport/index.d.ts +65 -0
  73. package/dist/node_modules/nodemailer/dist/cjs/stream-transport/index.js +146 -0
  74. package/dist/node_modules/nodemailer/dist/cjs/well-known/index.d.ts +35 -0
  75. package/dist/node_modules/nodemailer/dist/cjs/well-known/index.js +41 -0
  76. package/dist/node_modules/nodemailer/dist/cjs/well-known/services.d.ts +2 -0
  77. package/dist/node_modules/nodemailer/dist/cjs/well-known/services.js +674 -0
  78. package/dist/node_modules/nodemailer/dist/cjs/xoauth2/index.d.ts +201 -0
  79. package/dist/node_modules/nodemailer/dist/cjs/xoauth2/index.js +426 -0
  80. package/dist/node_modules/nodemailer/dist/esm/addressparser/index.d.ts +59 -0
  81. package/dist/node_modules/nodemailer/{lib → dist/esm}/addressparser/index.js +361 -131
  82. package/dist/node_modules/nodemailer/dist/esm/base64/index.d.ts +36 -0
  83. package/dist/node_modules/nodemailer/{lib → dist/esm}/base64/index.js +31 -56
  84. package/dist/node_modules/nodemailer/dist/esm/dkim/index.d.ts +52 -0
  85. package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/index.js +49 -78
  86. package/dist/node_modules/nodemailer/dist/esm/dkim/message-parser.d.ts +48 -0
  87. package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/message-parser.js +64 -42
  88. package/dist/node_modules/nodemailer/dist/esm/dkim/relaxed-body.d.ts +36 -0
  89. package/dist/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js +141 -0
  90. package/dist/node_modules/nodemailer/dist/esm/dkim/sign.d.ts +52 -0
  91. package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/sign.js +50 -46
  92. package/dist/node_modules/nodemailer/dist/esm/errors.d.ts +96 -0
  93. package/dist/node_modules/nodemailer/{lib → dist/esm}/errors.js +26 -18
  94. package/dist/node_modules/nodemailer/dist/esm/fetch/cookies.d.ts +107 -0
  95. package/dist/node_modules/nodemailer/dist/esm/fetch/cookies.js +242 -0
  96. package/dist/node_modules/nodemailer/dist/esm/fetch/index.d.ts +65 -0
  97. package/dist/node_modules/nodemailer/{lib → dist/esm}/fetch/index.js +80 -147
  98. package/dist/node_modules/nodemailer/dist/esm/json-transport/index.d.ts +64 -0
  99. package/dist/node_modules/nodemailer/{lib → dist/esm}/json-transport/index.js +19 -39
  100. package/dist/node_modules/nodemailer/dist/esm/mail-composer/index.d.ts +174 -0
  101. package/dist/node_modules/nodemailer/{lib → dist/esm}/mail-composer/index.js +199 -265
  102. package/dist/node_modules/nodemailer/dist/esm/mailer/index.d.ts +237 -0
  103. package/dist/node_modules/nodemailer/{lib → dist/esm}/mailer/index.js +128 -234
  104. package/dist/node_modules/nodemailer/dist/esm/mailer/mail-message.d.ts +97 -0
  105. package/dist/node_modules/nodemailer/{lib → dist/esm}/mailer/mail-message.js +62 -114
  106. package/dist/node_modules/nodemailer/dist/esm/mime-funcs/index.d.ts +161 -0
  107. package/dist/node_modules/nodemailer/dist/esm/mime-funcs/index.js +738 -0
  108. package/dist/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.d.ts +2 -0
  109. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-funcs/mime-types.js +29 -42
  110. package/dist/node_modules/nodemailer/dist/esm/mime-node/index.d.ts +333 -0
  111. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/index.js +259 -372
  112. package/dist/node_modules/nodemailer/dist/esm/mime-node/last-newline.d.ts +5 -0
  113. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/last-newline.js +4 -10
  114. package/dist/node_modules/nodemailer/dist/esm/mime-node/le-unix.d.ts +9 -0
  115. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/le-unix.js +6 -11
  116. package/dist/node_modules/nodemailer/dist/esm/mime-node/le-windows.d.ts +10 -0
  117. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/le-windows.js +6 -13
  118. package/dist/node_modules/nodemailer/dist/esm/nodemailer.d.ts +124 -0
  119. package/dist/node_modules/nodemailer/dist/esm/nodemailer.js +166 -0
  120. package/dist/node_modules/nodemailer/dist/esm/package-info.d.ts +3 -0
  121. package/dist/node_modules/nodemailer/dist/esm/package-info.js +4 -0
  122. package/dist/node_modules/nodemailer/dist/esm/package.json +3 -0
  123. package/dist/node_modules/nodemailer/dist/esm/punycode/index.d.ts +73 -0
  124. package/dist/node_modules/nodemailer/dist/esm/punycode/index.js +405 -0
  125. package/dist/node_modules/nodemailer/dist/esm/qp/index.d.ts +32 -0
  126. package/dist/node_modules/nodemailer/{lib → dist/esm}/qp/index.js +38 -67
  127. package/dist/node_modules/nodemailer/dist/esm/sendmail-transport/index.d.ts +69 -0
  128. package/dist/node_modules/nodemailer/{lib → dist/esm}/sendmail-transport/index.js +51 -101
  129. package/dist/node_modules/nodemailer/dist/esm/ses-transport/index.d.ts +112 -0
  130. package/dist/node_modules/nodemailer/dist/esm/ses-transport/index.js +212 -0
  131. package/dist/node_modules/nodemailer/dist/esm/shared/index.d.ts +260 -0
  132. package/dist/node_modules/nodemailer/{lib → dist/esm}/shared/index.js +156 -272
  133. package/dist/node_modules/nodemailer/dist/esm/shared/objects.d.ts +23 -0
  134. package/dist/node_modules/nodemailer/{lib → dist/esm}/shared/objects.js +13 -17
  135. package/dist/node_modules/nodemailer/dist/esm/shared/url.d.ts +21 -0
  136. package/dist/node_modules/nodemailer/dist/esm/shared/url.js +214 -0
  137. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.d.ts +15 -0
  138. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js +103 -0
  139. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.d.ts +47 -0
  140. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-connection/http-proxy-client.js +49 -74
  141. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/index.d.ts +416 -0
  142. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-connection/index.js +574 -794
  143. package/dist/node_modules/nodemailer/dist/esm/smtp-pool/index.d.ts +133 -0
  144. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-pool/index.js +172 -284
  145. package/dist/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.d.ts +62 -0
  146. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-pool/pool-resource.js +57 -97
  147. package/dist/node_modules/nodemailer/dist/esm/smtp-transport/index.d.ts +156 -0
  148. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-transport/index.js +81 -179
  149. package/dist/node_modules/nodemailer/dist/esm/stream-transport/index.d.ts +65 -0
  150. package/dist/node_modules/nodemailer/{lib → dist/esm}/stream-transport/index.js +36 -74
  151. package/dist/node_modules/nodemailer/dist/esm/well-known/index.d.ts +35 -0
  152. package/dist/node_modules/nodemailer/{lib → dist/esm}/well-known/index.js +5 -16
  153. package/dist/node_modules/nodemailer/dist/esm/well-known/services.d.ts +2 -0
  154. package/dist/node_modules/nodemailer/dist/esm/well-known/services.js +671 -0
  155. package/dist/node_modules/nodemailer/dist/esm/xoauth2/index.d.ts +201 -0
  156. package/dist/node_modules/nodemailer/{lib → dist/esm}/xoauth2/index.js +125 -187
  157. package/dist/node_modules/nodemailer/{lib → dist}/well-known/services.json +9 -2
  158. package/dist/node_modules/nodemailer/package.json +1 -1
  159. package/package.json +3 -3
  160. package/dist/node_modules/nodemailer/.gitattributes +0 -6
  161. package/dist/node_modules/nodemailer/.ncurc.js +0 -9
  162. package/dist/node_modules/nodemailer/.prettierignore +0 -8
  163. package/dist/node_modules/nodemailer/.prettierrc +0 -12
  164. package/dist/node_modules/nodemailer/.prettierrc.js +0 -10
  165. package/dist/node_modules/nodemailer/.release-please-config.json +0 -9
  166. package/dist/node_modules/nodemailer/eslint.config.js +0 -88
  167. package/dist/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
  168. package/dist/node_modules/nodemailer/lib/fetch/cookies.js +0 -276
  169. package/dist/node_modules/nodemailer/lib/mime-funcs/index.js +0 -671
  170. package/dist/node_modules/nodemailer/lib/nodemailer.js +0 -1
  171. package/dist/node_modules/nodemailer/lib/ses-transport/index.js +0 -266
  172. package/dist/node_modules/nodemailer/lib/shared/url.js +0 -151
  173. package/dist/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -105
@@ -0,0 +1,97 @@
1
+ import MimeNode, { type MimeNodePreparedHeaderValue } from '../mime-node/index.js';
2
+ import type { MailComposerOptions } from '../mail-composer/index.js';
3
+ import type { DKIMOptions } from '../dkim/index.js';
4
+ import type { SMTPEnvelopeDsn } from '../smtp-connection/index.js';
5
+ import type { SMTPTransportAuthOptions } from '../smtp-transport/index.js';
6
+ import type { SESSendEmailRequest } from '../ses-transport/index.js';
7
+ import type { NodemailerError } from '../errors.js';
8
+ import type { ResolveContentOptions } from '../shared/index.js';
9
+ import type Mail from './index.js';
10
+ import type { SentMessageInfo } from './index.js';
11
+ /**
12
+ * The message data accepted by sendMail. MailComposerOptions describes the fields the MIME
13
+ * tree is built from, the fields below are the ones the mailer reads on top of those
14
+ */
15
+ export interface SendMailOptions extends MailComposerOptions {
16
+ /** DKIM signing options for this message, used instead of the ones of the transporter */
17
+ dkim?: DKIMOptions | undefined;
18
+ /** Extra DKIM options for this message, merged over the options of the signer. The SES transport sets skipFields here, the option is not meant for callers */
19
+ _dkim?: DKIMOptions | undefined;
20
+ /** Recipients allowed on this message, 0 disables the limit, defaults to 100000 */
21
+ maxRecipients?: number | undefined;
22
+ /** SMTP transports: DSN parameters for the envelope, sent when the server supports the DSN extension */
23
+ dsn?: SMTPEnvelopeDsn | undefined;
24
+ /** SMTP transports: RFC 8689, send the REQUIRETLS parameter with MAIL FROM */
25
+ requireTLSExtensionEnabled?: boolean | undefined;
26
+ /** SMTP transports: per-message authentication settings, used instead of the transport level auth */
27
+ auth?: SMTPTransportAuthOptions | undefined;
28
+ /** SES transport: extra SendEmailCommand parameters merged into the API call */
29
+ ses?: SESSendEmailRequest | undefined;
30
+ }
31
+ /**
32
+ * Default message fields, the third argument of createTransport. Applied to every message
33
+ * for the fields the message does not set itself, the headers are merged one by one
34
+ */
35
+ export type MailDefaults = SendMailOptions;
36
+ /**
37
+ * The message data as held by a MailMessage: the options the caller passed to sendMail with
38
+ * the transporter defaults applied. resolveAll rewrites the content and address fields in
39
+ * place and normalize adds the envelope, the Message-ID and the normalized headers
40
+ */
41
+ export interface MailMessageData extends SendMailOptions {
42
+ /** Header values flattened to strings and keyed by lowercase header name, set by normalize */
43
+ normalizedHeaders?: {
44
+ [key: string]: string;
45
+ } | undefined;
46
+ }
47
+ /**
48
+ * Callback for resolveAll and normalize, receives the message data with every content value
49
+ * resolved
50
+ */
51
+ export type MailMessageDataCallback = (err: NodemailerError | null, data: MailMessageData) => void;
52
+ /**
53
+ * Callback for resolveContent, receives the resolved content value
54
+ */
55
+ export type MailMessageContentCallback = (err: NodemailerError | null, value?: any) => void;
56
+ /**
57
+ * A single prepared List-* header value, emitted as is
58
+ */
59
+ export interface MailMessageListHeaderValue extends MimeNodePreparedHeaderValue {
60
+ prepared: boolean;
61
+ foldLines: boolean;
62
+ value: string;
63
+ }
64
+ /**
65
+ * A List-* header as built from the list value, one prepared value per list entry
66
+ */
67
+ export interface MailMessageListHeader {
68
+ /** Header key, 'list-' followed by the lowercase list key */
69
+ key: string;
70
+ value: MailMessageListHeaderValue[];
71
+ }
72
+ export default class MailMessage<T = SentMessageInfo> {
73
+ mailer: Mail<T>;
74
+ data: MailMessageData;
75
+ /**
76
+ * The compiled MIME tree. Set once the compile step is done, so it is null while the
77
+ * 'compile' plugins run and set by the time the 'stream' plugins and the transport see
78
+ * the message. Declared as always set, the way @types/nodemailer declared it, since the
79
+ * plugins that read it are the ones that run after it is set
80
+ */
81
+ message: MimeNode;
82
+ constructor(mailer: Mail<T>, data?: SendMailOptions);
83
+ resolveContent(data: {
84
+ [key: string]: any;
85
+ }, key: string | number, callback: MailMessageContentCallback): void;
86
+ resolveContent(data: {
87
+ [key: string]: any;
88
+ }, key: string | number, options: ResolveContentOptions | false | undefined, callback: MailMessageContentCallback): void;
89
+ resolveContent(data: {
90
+ [key: string]: any;
91
+ }, key: string | number, options?: ResolveContentOptions | false): Promise<any>;
92
+ resolveAll(callback: MailMessageDataCallback): void;
93
+ normalize(callback: MailMessageDataCallback): void;
94
+ setMailerHeader(): void;
95
+ setPriorityHeaders(): void;
96
+ setListHeaders(): void;
97
+ }
@@ -0,0 +1,342 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const shared = __importStar(require("../shared/index.js"));
40
+ const index_js_1 = __importDefault(require("../mime-node/index.js"));
41
+ const mimeFuncs = __importStar(require("../mime-funcs/index.js"));
42
+ // Only an own key counts as already set. `key in obj` also matches every member of
43
+ // Object.prototype, which silently drops a transporter default legitimately named
44
+ // toString or constructor.
45
+ const hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
46
+ class MailMessage {
47
+ constructor(mailer, data) {
48
+ this.mailer = mailer;
49
+ this.data = {};
50
+ this.message = null;
51
+ data = data || {};
52
+ const options = mailer.options || {};
53
+ const defaults = mailer._defaults || {};
54
+ shared.copyOwnKeys(this.data, data);
55
+ this.data.headers = this.data.headers || {};
56
+ // Apply defaults. `_defaults` is caller supplied too, it is the second argument of
57
+ // createTransport, so it needs the same treatment as `data` above
58
+ shared.copyOwnKeys(this.data, defaults, key => hasOwn(this.data, key));
59
+ // headers is a special case. Allow setting individual default headers
60
+ shared.copyOwnKeys(this.data.headers, defaults.headers, key => hasOwn(this.data.headers, key));
61
+ // force specific keys from transporter options
62
+ ['disableFileAccess', 'disableUrlAccess', 'normalizeHeaderKey', 'maxRecipients'].forEach(key => {
63
+ if (key in options) {
64
+ this.data[key] = options[key];
65
+ }
66
+ });
67
+ // The access flags are a sandbox rather than a message field, so `defaults` counts as
68
+ // transporter configuration for them. For a transporter plugin it is the only channel
69
+ // there is, createTransport leaves `options` undefined for one, and the defaults copy
70
+ // above yields to anything the message already set, which let message data switch the
71
+ // sandbox back off. Closing is one way here, same as in resolveContent below: either
72
+ // side may switch a flag on, neither can switch off what the other closed.
73
+ ['disableFileAccess', 'disableUrlAccess'].forEach(key => {
74
+ if (!(key in options) && hasOwn(defaults, key)) {
75
+ this.data[key] = this.data[key] || defaults[key];
76
+ }
77
+ });
78
+ }
79
+ resolveContent(data, key, options, callback) {
80
+ // Most plugins call this with the legacy (data, key, callback) signature, which carries
81
+ // no access policy. The policy belongs to the message, so apply it here. Explicit
82
+ // options may only tighten it, never reopen what the transporter closed.
83
+ if (!callback && typeof options === 'function') {
84
+ callback = options;
85
+ options = false;
86
+ }
87
+ options = options || {};
88
+ const policy = {
89
+ disableFileAccess: this.data.disableFileAccess || options.disableFileAccess,
90
+ disableUrlAccess: this.data.disableUrlAccess || options.disableUrlAccess
91
+ };
92
+ return shared.resolveContent(data, key, policy, callback);
93
+ }
94
+ resolveAll(callback) {
95
+ const keys = [
96
+ [this.data, 'html'],
97
+ [this.data, 'text'],
98
+ [this.data, 'watchHtml'],
99
+ [this.data, 'amp'],
100
+ [this.data, 'icalEvent']
101
+ ];
102
+ if (this.data.alternatives && this.data.alternatives.length) {
103
+ this.data.alternatives.forEach((alternative, i) => {
104
+ keys.push([this.data.alternatives, i]);
105
+ });
106
+ }
107
+ if (this.data.attachments && this.data.attachments.length) {
108
+ this.data.attachments.forEach((attachment, i) => {
109
+ if (!attachment.filename) {
110
+ // a backslash separates as well, so a Windows path does not put the sender's directories in the headers
111
+ attachment.filename =
112
+ (attachment.path || attachment.href || '').split(/[/\\]/).pop().split('?').shift() ||
113
+ 'attachment-' + (i + 1);
114
+ if (attachment.filename.indexOf('.') < 0) {
115
+ attachment.filename += '.' + mimeFuncs.detectExtension(attachment.contentType);
116
+ }
117
+ }
118
+ if (!attachment.contentType) {
119
+ attachment.contentType = mimeFuncs.detectMimeType(attachment.filename || attachment.path || attachment.href || 'bin');
120
+ }
121
+ keys.push([this.data.attachments, i]);
122
+ });
123
+ }
124
+ const mimeNode = new index_js_1.default();
125
+ const addressKeys = ['from', 'to', 'cc', 'bcc', 'sender', 'replyTo'];
126
+ addressKeys.forEach(address => {
127
+ let value;
128
+ if (this.message) {
129
+ value = [].concat(mimeNode._parseAddresses(this.message.getHeader(address === 'replyTo' ? 'reply-to' : address)) || []);
130
+ }
131
+ else if (this.data[address]) {
132
+ value = [].concat(mimeNode._parseAddresses(this.data[address]) || []);
133
+ }
134
+ if (value && value.length) {
135
+ this.data[address] = value;
136
+ }
137
+ else if (address in this.data) {
138
+ this.data[address] = null;
139
+ }
140
+ });
141
+ const singleKeys = ['from', 'sender'];
142
+ singleKeys.forEach(address => {
143
+ if (this.data[address]) {
144
+ this.data[address] = this.data[address].shift();
145
+ }
146
+ });
147
+ let pos = 0;
148
+ const resolveNext = () => {
149
+ if (pos >= keys.length) {
150
+ return callback(null, this.data);
151
+ }
152
+ const args = keys[pos++];
153
+ if (!args[0] || !args[0][args[1]]) {
154
+ return resolveNext();
155
+ }
156
+ shared.resolveContent(...args, { disableFileAccess: this.data.disableFileAccess, disableUrlAccess: this.data.disableUrlAccess }, (err, value) => {
157
+ if (err) {
158
+ return callback(err);
159
+ }
160
+ const node = {
161
+ content: value
162
+ };
163
+ if (args[0][args[1]] && typeof args[0][args[1]] === 'object' && !Buffer.isBuffer(args[0][args[1]])) {
164
+ // The keys are the caller's, so copying them takes the same "__proto__"
165
+ // rule as the constructor. `key in node` stays as the already-set test
166
+ // here, unlike for the defaults: it also skips the Object.prototype
167
+ // member names, and letting message data land a `toString` string on a
168
+ // node only buys a TypeError the first time something stringifies it.
169
+ shared.copyOwnKeys(node, args[0][args[1]], key => key in node || ['content', 'path', 'href', 'raw'].includes(key));
170
+ }
171
+ args[0][args[1]] = node;
172
+ resolveNext();
173
+ });
174
+ };
175
+ setImmediate(() => resolveNext());
176
+ }
177
+ normalize(callback) {
178
+ const envelope = this.message.getEnvelope();
179
+ const messageId = this.message.messageId();
180
+ this.resolveAll((err, data) => {
181
+ if (err) {
182
+ return callback(err);
183
+ }
184
+ data.envelope = envelope;
185
+ data.messageId = messageId;
186
+ ['html', 'text', 'watchHtml', 'amp'].forEach(key => {
187
+ if (data[key] && data[key].content) {
188
+ if (typeof data[key].content === 'string') {
189
+ data[key] = data[key].content;
190
+ }
191
+ else if (Buffer.isBuffer(data[key].content)) {
192
+ data[key] = data[key].content.toString();
193
+ }
194
+ }
195
+ });
196
+ if (data.icalEvent && Buffer.isBuffer(data.icalEvent.content)) {
197
+ data.icalEvent.content = data.icalEvent.content.toString('base64');
198
+ data.icalEvent.encoding = 'base64';
199
+ }
200
+ if (data.alternatives && data.alternatives.length) {
201
+ data.alternatives.forEach((alternative) => {
202
+ if (alternative && alternative.content && Buffer.isBuffer(alternative.content)) {
203
+ alternative.content = alternative.content.toString('base64');
204
+ alternative.encoding = 'base64';
205
+ }
206
+ });
207
+ }
208
+ if (data.attachments && data.attachments.length) {
209
+ data.attachments.forEach((attachment) => {
210
+ if (attachment && attachment.content && Buffer.isBuffer(attachment.content)) {
211
+ attachment.content = attachment.content.toString('base64');
212
+ attachment.encoding = 'base64';
213
+ }
214
+ });
215
+ }
216
+ data.normalizedHeaders = {};
217
+ Object.keys(data.headers || {}).forEach(key => {
218
+ if (shared.isProtoKey(key)) {
219
+ return;
220
+ }
221
+ let value = [].concat(data.headers[key] || []).shift();
222
+ value = (value && value.value) || value;
223
+ if (value) {
224
+ if (['references', 'in-reply-to', 'message-id', 'content-id'].includes(key)) {
225
+ value = this.message._encodeHeaderValue(key, value);
226
+ }
227
+ data.normalizedHeaders[key] = value;
228
+ }
229
+ });
230
+ if (data.list && typeof data.list === 'object') {
231
+ const listHeaders = this._getListHeaders(data.list);
232
+ listHeaders.forEach(entry => {
233
+ data.normalizedHeaders[entry.key] = entry.value.map(val => (val && val.value) || val).join(', ');
234
+ });
235
+ }
236
+ if (data.references) {
237
+ data.normalizedHeaders.references = this.message._encodeHeaderValue('references', data.references);
238
+ }
239
+ if (data.inReplyTo) {
240
+ data.normalizedHeaders['in-reply-to'] = this.message._encodeHeaderValue('in-reply-to', data.inReplyTo);
241
+ }
242
+ return callback(null, data);
243
+ });
244
+ }
245
+ setMailerHeader() {
246
+ if (!this.message || !this.data.xMailer) {
247
+ return;
248
+ }
249
+ this.message.setHeader('X-Mailer', this.data.xMailer);
250
+ }
251
+ setPriorityHeaders() {
252
+ if (!this.message || !this.data.priority) {
253
+ return;
254
+ }
255
+ switch ((this.data.priority || '').toString().toLowerCase()) {
256
+ case 'high':
257
+ this.message.setHeader('X-Priority', '1 (Highest)');
258
+ this.message.setHeader('X-MSMail-Priority', 'High');
259
+ this.message.setHeader('Importance', 'High');
260
+ break;
261
+ case 'low':
262
+ this.message.setHeader('X-Priority', '5 (Lowest)');
263
+ this.message.setHeader('X-MSMail-Priority', 'Low');
264
+ this.message.setHeader('Importance', 'Low');
265
+ break;
266
+ default:
267
+ // do not add anything, since all messages are 'Normal' by default
268
+ }
269
+ }
270
+ setListHeaders() {
271
+ if (!this.message || !this.data.list || typeof this.data.list !== 'object') {
272
+ return;
273
+ }
274
+ // add optional List-* headers
275
+ this._getListHeaders(this.data.list).forEach(listHeader => {
276
+ listHeader.value.forEach(value => {
277
+ this.message.addHeader(listHeader.key, value);
278
+ });
279
+ });
280
+ }
281
+ /** @internal */
282
+ _getListHeaders(listData) {
283
+ // make sure an url looks like <protocol:url>
284
+ return Object.keys(listData).map(key => ({
285
+ key: 'list-' + key.toLowerCase().trim(),
286
+ value: [].concat(listData[key] || []).map(value => ({
287
+ prepared: true,
288
+ foldLines: true,
289
+ value: []
290
+ .concat(value || [])
291
+ .map(value => {
292
+ if (typeof value === 'string') {
293
+ value = {
294
+ url: value
295
+ };
296
+ }
297
+ if (value && value.url) {
298
+ // strip CR/LF so a comment can't inject extra header lines. DEL is neither
299
+ // qtext nor ctext, so it can not be carried literally by either construct
300
+ // and has to become an encoded word like any other non-plaintext value
301
+ let comment = (value.comment || '').toString().replace(/\r?\n|\r/g, ' ');
302
+ const needsEncoding = !mimeFuncs.isPlainText(comment) || /\x7f/.test(comment);
303
+ if (key.toLowerCase().trim() === 'id') {
304
+ // List-ID: "comment" <domain>, where an unescaped quote or a trailing
305
+ // backslash in the comment would swallow the <domain> behind it
306
+ comment = needsEncoding ? mimeFuncs.encodeWord(comment) : mimeFuncs.quoteString(comment);
307
+ // List-ID expects a bare domain-like identifier, so strip the
308
+ // scheme prefix that _formatListUrl adds or passes through
309
+ return ((value.comment ? comment + ' ' : '') + this._formatListUrl(value.url).replace(/^<[^:]+:\/{0,2}/, '<'));
310
+ }
311
+ // List-*: <http://domain> (comment)
312
+ // the ctext specials go out as quoted-pairs, otherwise a ")" closes the
313
+ // comment early and leaves the rest as junk, an unpaired "(" opens a
314
+ // nested comment that never closes, and a trailing backslash escapes
315
+ // the closing ")" so the comment swallows whatever follows it
316
+ comment = needsEncoding ? mimeFuncs.encodeWord(comment) : comment.replace(/[()\\]/g, '\\$&');
317
+ return this._formatListUrl(value.url) + (value.comment ? ' (' + comment + ')' : '');
318
+ }
319
+ return '';
320
+ })
321
+ .filter(value => value)
322
+ .join(', ')
323
+ }))
324
+ }));
325
+ }
326
+ /** @internal */
327
+ _formatListUrl(url) {
328
+ // a url has no way to carry a control char or DEL, and the angle brackets around it
329
+ // are not a quoting construct, so anything left here lands in the header raw
330
+ url = url.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, '').replace(/[\s<]+|[\s>]+/g, '');
331
+ if (/^(https?|mailto|ftp):/.test(url)) {
332
+ return '<' + url + '>';
333
+ }
334
+ if (/^[^@]+@[^@]+$/.test(url)) {
335
+ return '<mailto:' + url + '>';
336
+ }
337
+ return '<http://' + url + '>';
338
+ }
339
+ }
340
+ exports.default = MailMessage;
341
+ module.exports = exports.default;
342
+ Object.defineProperty(module.exports, 'default', { value: exports.default, enumerable: false, writable: true, configurable: true });
@@ -0,0 +1,161 @@
1
+ /**
2
+ * A header value split into the value token and its parameters, the result of parseHeaderValue
3
+ */
4
+ export interface ParsedHeaderValue {
5
+ /** The value ahead of the parameters, for example the content type, an empty string when there is none */
6
+ value: string;
7
+ /** Parameter values keyed by lowercase parameter name */
8
+ params: Record<string, string>;
9
+ }
10
+ /**
11
+ * Header value structure accepted by buildHeaderValue
12
+ */
13
+ export interface StructuredHeaderValue {
14
+ /** The value ahead of the parameters, for example the content type */
15
+ value: string | false;
16
+ /** Parameter values keyed by parameter name */
17
+ params?: Record<string, string> | undefined;
18
+ }
19
+ /**
20
+ * A single key=value pair of an rfc2231 encoded header parameter
21
+ */
22
+ export interface EncodedHeaderParam {
23
+ /** Parameter name with the continuation suffix, for example title*0* */
24
+ key: string;
25
+ /** Parameter value of this part */
26
+ value: string;
27
+ }
28
+ /** The names @types/nodemailer used for the two types above */
29
+ export type HeaderValue = StructuredHeaderValue;
30
+ export type ParsedHeaderParam = EncodedHeaderParam;
31
+ /**
32
+ * Checks if a value is plaintext string (uses only printable 7bit chars)
33
+ *
34
+ * When isParam is set the value is destined for a header parameter, so HT, CR and LF
35
+ * are not plaintext either: a header parameter has no way to carry them. HT is a valid
36
+ * fold point, so folding and unfolding a header would rewrite it as a space, and CR/LF
37
+ * cannot appear in a header value at all. DEL is neither a token character nor qtext,
38
+ * so it can not be carried bare or quoted. Such values have to go through the rfc2231
39
+ * parameter continuation encoding instead, the same way a quote already does.
40
+ *
41
+ * @param value String to be tested
42
+ * @param [isParam] Set to true if the value is a header parameter value
43
+ * @returns true if it is a plaintext string
44
+ */
45
+ export declare function isPlainText(value: unknown, isParam?: boolean): boolean;
46
+ /**
47
+ * Wraps a value into a quoted-string. Inside one a quote would end the string early
48
+ * and a backslash would escape whatever follows it, so both go out as quoted-pairs.
49
+ *
50
+ * @param value String to be quoted
51
+ * @returns The value as a quoted-string, quotes included
52
+ */
53
+ export declare function quoteString(value?: string): string;
54
+ /**
55
+ * Checks if a multi line string containes lines longer than the selected value.
56
+ *
57
+ * Useful when detecting if a mail message needs any processing at all:
58
+ * if only plaintext characters are used and lines are short, then there is
59
+ * no need to encode the values in any way. If the value is plaintext but has
60
+ * longer lines then allowed, then use format=flowed
61
+ *
62
+ * @param str Multi line string to check
63
+ * @param lineLength Max line length to check for
64
+ * @returns Returns true if there is at least one line longer than lineLength chars
65
+ */
66
+ export declare function hasLongerLines(str: string, lineLength: number): boolean;
67
+ /**
68
+ * Encodes a string or an Buffer to an UTF-8 MIME Word (rfc2047)
69
+ *
70
+ * @param data String to be encoded
71
+ * @param mimeWordEncoding='Q' Encoding for the mime word, either Q or B
72
+ * @param [maxLength=0] If set, split mime words into several chunks if needed
73
+ * @return Single or several mime words joined together
74
+ */
75
+ export declare function encodeWord(data: string | Buffer, mimeWordEncoding?: string, maxLength?: number): string;
76
+ /**
77
+ * Finds word sequences with non ascii text and converts these to mime words
78
+ *
79
+ * @param value String to be encoded
80
+ * @param mimeWordEncoding='Q' Encoding for the mime word, either Q or B
81
+ * @param [maxLength=0] If set, split mime words into several chunks if needed
82
+ * @param [encodeAll=false] If true and the value needs encoding then encodes entire string, not just the smallest match
83
+ * @return String with possible mime words
84
+ */
85
+ export declare function encodeWords(value: string, mimeWordEncoding?: string, maxLength?: number, encodeAll?: boolean): string;
86
+ /**
87
+ * Joins parsed header value together as 'value; param1=value1; param2=value2'
88
+ * PS: We are following RFC 822 for the list of special characters that we need to keep in quotes.
89
+ * Refer: https://www.w3.org/Protocols/rfc1341/4_Content-Type.html
90
+ * @param structured Parsed header value
91
+ * @return joined header value
92
+ */
93
+ export declare function buildHeaderValue(structured: StructuredHeaderValue): string;
94
+ /**
95
+ * Encodes a string or an Buffer to an UTF-8 Parameter Value Continuation encoding (rfc2231)
96
+ * Useful for splitting long parameter values.
97
+ *
98
+ * For example
99
+ * title="unicode string"
100
+ * becomes
101
+ * title*0*=utf-8''unicode
102
+ * title*1*=%20string
103
+ *
104
+ * @param key Parameter name the generated keys are built from, for example title
105
+ * @param data String to be encoded
106
+ * @param [maxLength=50] Max length for generated chunks
107
+ * @return A list of encoded keys and headers
108
+ */
109
+ export declare function buildHeaderParam(key: string, data: string | Buffer, maxLength?: number): EncodedHeaderParam[];
110
+ /**
111
+ * Parses a header value with key=value arguments into a structured
112
+ * object.
113
+ *
114
+ * parseHeaderValue('content-type: text/plain; CHARSET='UTF-8'') ->
115
+ * {
116
+ * 'value': 'text/plain',
117
+ * 'params': {
118
+ * 'charset': 'UTF-8'
119
+ * }
120
+ * }
121
+ *
122
+ * @param str Header value
123
+ * @return Header value as a parsed structure
124
+ */
125
+ export declare function parseHeaderValue(str: string): ParsedHeaderValue;
126
+ /**
127
+ * Returns file extension for a content type string. If no suitable extensions
128
+ * are found, 'bin' is used as the default extension
129
+ *
130
+ * @param mimeType Content type to be checked for
131
+ * @return File extension
132
+ */
133
+ export declare function detectExtension(mimeType?: string | false): string;
134
+ /**
135
+ * Returns content type for a file extension. If no suitable content types
136
+ * are found, 'application/octet-stream' is used as the default content type
137
+ *
138
+ * @param extension Extension to be checked for
139
+ * @return File extension
140
+ */
141
+ export declare function detectMimeType(extension?: string | false): string;
142
+ /**
143
+ * Folds long lines, useful for folding header lines (afterSpace=false) and
144
+ * flowed text (afterSpace=true)
145
+ *
146
+ * @param str String to be folded
147
+ * @param [lineLength=76] Maximum length of a line
148
+ * @param afterSpace If true, leave a space in th end of a line
149
+ * @return String with folded lines
150
+ */
151
+ export declare function foldLines(str: string, lineLength?: number, afterSpace?: boolean): string;
152
+ /**
153
+ * Splits a mime encoded string. Needed for dividing mime words into smaller chunks
154
+ *
155
+ * @param str Mime encoded string to be split up
156
+ * @param maxlen Maximum length of characters for one part (minimum 12)
157
+ * @return Split string
158
+ */
159
+ export declare function splitMimeEncodedString(str: string, maxlen?: number): string[];
160
+ export declare function encodeURICharComponent(chr: string): string;
161
+ export declare function safeEncodeURIComponent(str: string): string;