@nocobase/plugin-workflow-mailer 2.3.0-beta.13 → 2.3.0-beta.15

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,189 @@
1
+ "use strict";
2
+ /**
3
+ * Minimal HTTP/S proxy client
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ const node_net_1 = __importDefault(require("node:net"));
43
+ const node_tls_1 = __importDefault(require("node:tls"));
44
+ const urllib = __importStar(require("../shared/url.js"));
45
+ const errors = __importStar(require("../errors.js"));
46
+ // Cap the CONNECT response we buffer before the header terminator, so a proxy that
47
+ // never sends \r\n\r\n cannot grow memory unboundedly before the socket times out.
48
+ const MAX_RESPONSE_HEADER_BYTES = 64 * 1024;
49
+ function httpProxyClient(proxyUrl, destinationPort, destinationHost, tlsOptions, callback) {
50
+ if (typeof tlsOptions === 'function') {
51
+ callback = tlsOptions;
52
+ tlsOptions = {};
53
+ }
54
+ tlsOptions = tlsOptions || {};
55
+ // the error paths hand over the error alone
56
+ const done = callback;
57
+ // Reject CRLF in the destination before it reaches the CONNECT request line
58
+ // and Host header. A tainted host/port could otherwise inject additional
59
+ // request headers into the proxy connection (HTTP request splitting).
60
+ destinationPort = Number(destinationPort) || 0;
61
+ if (!destinationPort || /[\r\n]/.test(destinationHost)) {
62
+ const err = new Error('Invalid proxy destination');
63
+ err.code = errors.EPROXY;
64
+ setImmediate(() => done(err));
65
+ return;
66
+ }
67
+ const proxy = urllib.parse(proxyUrl);
68
+ const connectOptions = {
69
+ host: proxy.hostname,
70
+ port: Number(proxy.port) ? Number(proxy.port) : proxy.protocol === 'https:' ? 443 : 80
71
+ };
72
+ let connect;
73
+ if (proxy.protocol === 'https:') {
74
+ // Validate the proxy's TLS certificate by default. A caller that uses a
75
+ // self-signed proxy (e.g. integration tests) opts out explicitly with
76
+ // tls.rejectUnauthorized === false.
77
+ connectOptions.rejectUnauthorized = tlsOptions.rejectUnauthorized !== false;
78
+ connect = node_tls_1.default.connect.bind(node_tls_1.default);
79
+ }
80
+ else {
81
+ connect = node_net_1.default.connect.bind(node_net_1.default);
82
+ }
83
+ let socket;
84
+ // Error harness for initial connection. Once connection is established, the responsibility
85
+ // to handle errors is passed to whoever uses this socket
86
+ let finished = false;
87
+ const tempSocketErr = (err) => {
88
+ if (finished) {
89
+ return;
90
+ }
91
+ finished = true;
92
+ try {
93
+ socket.destroy();
94
+ }
95
+ catch (_E) {
96
+ // ignore
97
+ }
98
+ done(err);
99
+ };
100
+ const timeoutErr = () => {
101
+ const err = new Error('Proxy socket timed out');
102
+ err.code = 'ETIMEDOUT';
103
+ tempSocketErr(err);
104
+ };
105
+ socket = connect(connectOptions, () => {
106
+ if (finished) {
107
+ return;
108
+ }
109
+ const reqHeaders = {
110
+ Host: destinationHost + ':' + destinationPort,
111
+ Connection: 'close'
112
+ };
113
+ if (proxy.auth) {
114
+ reqHeaders['Proxy-Authorization'] = 'Basic ' + Buffer.from(proxy.auth).toString('base64');
115
+ }
116
+ socket.write(
117
+ // HTTP method
118
+ 'CONNECT ' +
119
+ destinationHost +
120
+ ':' +
121
+ destinationPort +
122
+ ' HTTP/1.1\r\n' +
123
+ // HTTP request headers
124
+ Object.keys(reqHeaders)
125
+ .map(key => key + ': ' + reqHeaders[key])
126
+ .join('\r\n') +
127
+ // End request
128
+ '\r\n\r\n');
129
+ // The response is collected as chunks and only the bytes that just arrived, together
130
+ // with the three before them, are searched for the end of the headers. Appending to a
131
+ // string and searching all of it again re-read the whole response on every chunk.
132
+ const chunks = [];
133
+ let received = 0;
134
+ let tail = '';
135
+ const onSocketData = (chunk) => {
136
+ let match;
137
+ if (finished) {
138
+ return;
139
+ }
140
+ const window = tail + chunk.toString('binary');
141
+ const windowEnd = window.indexOf('\r\n\r\n');
142
+ chunks.push(chunk);
143
+ received += chunk.length;
144
+ tail = window.slice(-3);
145
+ if (windowEnd >= 0) {
146
+ socket.removeListener('data', onSocketData);
147
+ const headerEnd = received - window.length + windowEnd;
148
+ const response = Buffer.concat(chunks, received).toString('binary');
149
+ const headers = response.substr(0, headerEnd);
150
+ const remainder = response.substr(headerEnd + 4);
151
+ if (remainder) {
152
+ socket.unshift(Buffer.from(remainder, 'binary'));
153
+ }
154
+ // proxy connection is now established
155
+ finished = true;
156
+ // check response code
157
+ match = headers.match(/^HTTP\/\d+\.\d+ (\d+)/i);
158
+ if (!match || (match[1] || '').charAt(0) !== '2') {
159
+ try {
160
+ socket.destroy();
161
+ }
162
+ catch (_E) {
163
+ // ignore
164
+ }
165
+ const err = new Error('Invalid response from proxy' + ((match && ': ' + match[1]) || ''));
166
+ err.code = errors.EPROXY;
167
+ return done(err);
168
+ }
169
+ socket.removeListener('error', tempSocketErr);
170
+ socket.removeListener('timeout', timeoutErr);
171
+ socket.setTimeout(0);
172
+ return done(null, socket);
173
+ }
174
+ if (received > MAX_RESPONSE_HEADER_BYTES) {
175
+ socket.removeListener('data', onSocketData);
176
+ const err = new Error('Proxy response headers too large');
177
+ err.code = errors.EPROXY;
178
+ return tempSocketErr(err);
179
+ }
180
+ };
181
+ socket.on('data', onSocketData);
182
+ });
183
+ socket.setTimeout(httpProxyClient.timeout || 30 * 1000);
184
+ socket.on('timeout', timeoutErr);
185
+ socket.once('error', tempSocketErr);
186
+ }
187
+ exports.default = httpProxyClient;
188
+ module.exports = exports.default;
189
+ Object.defineProperty(module.exports, 'default', { value: exports.default, enumerable: false, writable: true, configurable: true });
@@ -0,0 +1,416 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import net from 'node:net';
3
+ import tls from 'node:tls';
4
+ import { type Readable } from 'node:stream';
5
+ import * as shared from '../shared/index.js';
6
+ import type { Callback, NodemailerError } from '../errors.js';
7
+ import type XOAuth2 from '../xoauth2/index.js';
8
+ import type { XOAuth2Options } from '../xoauth2/index.js';
9
+ /**
10
+ * Custom authentication handlers keyed by (case insensitive) SASL method name
11
+ */
12
+ export type SMTPConnectionCustomAuthHandlers = {
13
+ [method: string]: SMTPConnectionCustomAuthHandler;
14
+ };
15
+ /**
16
+ * Options for the SMTP connection, see the SMTPConnection class description
17
+ */
18
+ export interface SMTPConnectionOptions {
19
+ /** Port to connect to, defaults to 587, or to 465 when secure is set */
20
+ port?: number | string | undefined;
21
+ /** Hostname or IP address to connect to, defaults to 'localhost' */
22
+ host?: string | undefined;
23
+ /** Use TLS from the start */
24
+ secure?: boolean | undefined;
25
+ /** Marks the provided socket as already upgraded to TLS */
26
+ secured?: boolean | undefined;
27
+ /** Server name for SNI, defaults to host when that is not an IP address */
28
+ servername?: string | undefined;
29
+ /** Ignore STARTTLS even when the server advertises it, has no effect when requireTLS is set */
30
+ ignoreTLS?: boolean | undefined;
31
+ /** Force STARTTLS, fail when the server does not support it. Takes precedence over ignoreTLS and opportunisticTLS */
32
+ requireTLS?: boolean | undefined;
33
+ /** Continue unencrypted when the STARTTLS upgrade fails, has no effect when requireTLS is set */
34
+ opportunisticTLS?: boolean | undefined;
35
+ /** Name of the client server, sent with EHLO/HELO, CRLF is stripped */
36
+ name?: string | undefined;
37
+ /** Outbound address to bind to */
38
+ localAddress?: string | undefined;
39
+ /** Time to wait in ms for the connection to establish, defaults to 2 minutes */
40
+ connectionTimeout?: number | undefined;
41
+ /** Time to wait in ms until the greeting is received, defaults to 30 seconds */
42
+ greetingTimeout?: number | undefined;
43
+ /** Time of inactivity in ms until the connection is closed, defaults to 10 minutes */
44
+ socketTimeout?: number | undefined;
45
+ /** Largest single server response to accept in bytes, defaults to 1 MB */
46
+ maxResponseSize?: number | undefined;
47
+ /** Time to wait in ms for the DNS requests to be resolved, defaults to 30 seconds */
48
+ dnsTimeout?: number | undefined;
49
+ /** Use LMTP instead of SMTP */
50
+ lmtp?: boolean | undefined;
51
+ /** Bunyan compatible logger interface, true for the default console logger */
52
+ logger?: shared.ExternalLogger | boolean | undefined;
53
+ /** Pass SMTP traffic, including the message data, to the logger */
54
+ debug?: boolean | undefined;
55
+ /** Pass SMTP commands and responses to the logger */
56
+ transactionLog?: boolean | undefined;
57
+ /** Options for tls.connect */
58
+ tls?: tls.ConnectionOptions | undefined;
59
+ /** Existing socket to use instead of creating a new one, not connected yet */
60
+ socket?: net.Socket | undefined;
61
+ /** Already opened connection to use instead of creating a new one */
62
+ connection?: net.Socket | undefined;
63
+ /** Count loopback interfaces when checking which address families are usable */
64
+ allowInternalNetworkInterfaces?: boolean | undefined;
65
+ /** Logger component name, defaults to 'smtp-connection' */
66
+ component?: string | undefined;
67
+ /** Custom authentication handlers keyed by method name */
68
+ customAuth?: SMTPConnectionCustomAuthHandlers | undefined;
69
+ }
70
+ /**
71
+ * User and password credentials resolved for a SASL mechanism
72
+ */
73
+ export interface SMTPConnectionCredentials {
74
+ user?: string | undefined;
75
+ pass?: string | undefined;
76
+ /** Extra options for the authentication method, copied from the auth object */
77
+ options?: {
78
+ [key: string]: any;
79
+ } | undefined;
80
+ }
81
+ /**
82
+ * Authentication data for login()
83
+ */
84
+ export interface SMTPConnectionAuth {
85
+ /** Authentication type, informational */
86
+ type?: string | undefined;
87
+ /** SASL method to use, false or unset picks the first supported one (PLAIN if none is advertised) */
88
+ method?: string | false | undefined;
89
+ user?: string | undefined;
90
+ pass?: string | undefined;
91
+ /** Extra options for the authentication method */
92
+ options?: {
93
+ [key: string]: any;
94
+ } | undefined;
95
+ /** XOAuth2 token generator, selects XOAUTH2 when no method is set */
96
+ oauth2?: XOAuth2 | undefined;
97
+ /** Credentials for the SASL mechanism, filled in from user and pass when missing */
98
+ credentials?: SMTPConnectionCredentials | undefined;
99
+ /** Custom authentication handlers receive the auth object as is, so it may carry any other value */
100
+ [key: string]: any;
101
+ }
102
+ /**
103
+ * A parsed server reply, handed to the sendCommand callback of a custom authentication handler
104
+ */
105
+ export interface SMTPConnectionCustomAuthResponse {
106
+ /** The command that was sent */
107
+ command: string;
108
+ /** Raw server response */
109
+ response: string;
110
+ /** Numeric status code, 0 if the response did not start with one */
111
+ status: number;
112
+ /** Enhanced status code, if any */
113
+ code?: string | undefined;
114
+ /** Response text without the status codes */
115
+ text: string;
116
+ }
117
+ /**
118
+ * Callback for a command sent by a custom authentication handler
119
+ */
120
+ export type SMTPConnectionCustomAuthCommandCallback = (err: Error | null, data: SMTPConnectionCustomAuthResponse) => void;
121
+ /**
122
+ * The auth object as a custom authentication handler sees it: the object handed to login()
123
+ * with the credentials filled in from its user and pass values
124
+ */
125
+ export interface SMTPConnectionCustomAuthData extends SMTPConnectionAuth {
126
+ /** The user and pass values of the auth object, the way @types/nodemailer declared them */
127
+ credentials: SMTPConnectionCredentials & {
128
+ user: string;
129
+ pass: string;
130
+ };
131
+ }
132
+ /**
133
+ * The object a custom authentication handler is run with
134
+ */
135
+ export interface SMTPConnectionCustomAuthContext {
136
+ /** The auth object handed to login(), with the credentials filled in */
137
+ auth: SMTPConnectionCustomAuthData;
138
+ /** Selected authentication method name */
139
+ method: string;
140
+ /** SMTP extensions the server advertised */
141
+ extensions: string[];
142
+ /** SASL methods the server advertised */
143
+ authMethods: string[];
144
+ /** Maximum message size the server accepts, false when not advertised */
145
+ maxAllowedSize: number | false;
146
+ /** Sends a command to the server and resolves with the parsed reply */
147
+ sendCommand(cmd: string): Promise<SMTPConnectionCustomAuthResponse>;
148
+ /** Sends a command to the server and hands the parsed reply to the callback */
149
+ sendCommand(cmd: string, done: SMTPConnectionCustomAuthCommandCallback): void;
150
+ /** Marks the user as authenticated */
151
+ resolve(): void;
152
+ /** Fails the authentication with an error */
153
+ reject(err: Error | string): void;
154
+ }
155
+ /**
156
+ * A custom authentication handler. Calls resolve() or reject() on the context, or returns a
157
+ * promise that settles the authentication. Any other return value is ignored
158
+ */
159
+ export type SMTPConnectionCustomAuthHandler = (ctx: SMTPConnectionCustomAuthContext) => unknown;
160
+ /**
161
+ * An envelope address, either a plain string or an object with an address property
162
+ */
163
+ export interface SMTPEnvelopeAddress {
164
+ address?: string | undefined;
165
+ name?: string | undefined;
166
+ }
167
+ /**
168
+ * DSN parameters for the envelope (RFC 3461)
169
+ */
170
+ export interface SMTPEnvelopeDsn {
171
+ /** Return either 'HDRS' (headers) or 'FULL' (body) with the notification */
172
+ ret?: string | null | undefined;
173
+ /** Alias of ret */
174
+ return?: string | undefined;
175
+ /** Envelope identifier, sent as ENVID */
176
+ envid?: string | null | undefined;
177
+ /** Alias of envid */
178
+ id?: string | undefined;
179
+ /** When to notify: 'NEVER', or any combination of 'SUCCESS', 'FAILURE' and 'DELAY' */
180
+ notify?: string | string[] | null | undefined;
181
+ /** Original recipient, sent as ORCPT */
182
+ recipient?: string | undefined;
183
+ /** Alias of recipient, in the 'rfc822;address' form */
184
+ orcpt?: string | null | undefined;
185
+ }
186
+ /**
187
+ * A single DSN notify value
188
+ */
189
+ export type SMTPEnvelopeDsnNotify = 'NEVER' | 'SUCCESS' | 'FAILURE' | 'DELAY';
190
+ /**
191
+ * Envelope object accepted by send()
192
+ */
193
+ export interface SMTPEnvelope {
194
+ /** Sender address, false for the null sender of a bounce message (MAIL FROM:<>) */
195
+ from?: string | SMTPEnvelopeAddress | false | undefined;
196
+ /** Recipient address or addresses */
197
+ to?: string | SMTPEnvelopeAddress | Array<string | SMTPEnvelopeAddress> | undefined;
198
+ /** Message size in bytes, sent as the SIZE parameter when the server supports it */
199
+ size?: number | string | undefined;
200
+ /** DSN parameters, sent when the server supports the DSN extension */
201
+ dsn?: SMTPEnvelopeDsn | undefined;
202
+ /** Declare BODY=8BITMIME when the server supports it */
203
+ use8BitMime?: boolean | undefined;
204
+ /** RFC 8689: send the REQUIRETLS parameter, requires a TLS connection and server support */
205
+ requireTLSExtensionEnabled?: boolean | undefined;
206
+ }
207
+ /**
208
+ * The envelope as tracked by the connection while a message is being sent. The from and to
209
+ * values are normalized to strings and the recipient bookkeeping is added by _setEnvelope
210
+ */
211
+ export interface SMTPConnectionEnvelope extends SMTPEnvelope {
212
+ from?: string | undefined;
213
+ to?: string[] | undefined;
214
+ /** Recipients still waiting for RCPT TO */
215
+ rcptQueue: string[];
216
+ /** Recipients the server rejected */
217
+ rejected: string[];
218
+ /** Errors for the rejected recipients */
219
+ rejectedErrors: NodemailerError[];
220
+ /** Recipients the server accepted */
221
+ accepted: string[];
222
+ }
223
+ /**
224
+ * The recipient bookkeeping of a sent message, known once the envelope is accepted
225
+ */
226
+ export interface SMTPConnectionEnvelopeInfo {
227
+ /** Recipients the server accepted */
228
+ accepted: string[];
229
+ /** Recipients the server rejected */
230
+ rejected: string[];
231
+ /** EHLO response lines, without the greeting line */
232
+ ehlo?: string[] | undefined;
233
+ /** Errors for the rejected recipients */
234
+ rejectedErrors?: NodemailerError[] | undefined;
235
+ }
236
+ /**
237
+ * Result of a sent message
238
+ */
239
+ export interface SMTPConnectionSendInfo extends SMTPConnectionEnvelopeInfo {
240
+ /** Time in ms spent on the envelope commands */
241
+ envelopeTime: number;
242
+ /** Time in ms spent on streaming the message */
243
+ messageTime: number;
244
+ /** Size of the encoded message in bytes */
245
+ messageSize: number;
246
+ /** Final server response for the message */
247
+ response: string;
248
+ }
249
+ /**
250
+ * Callback for send(), receives the result once the server accepted the message. The error
251
+ * path hands over the error alone
252
+ */
253
+ export type SMTPConnectionSendCallback = Callback<SMTPConnectionSendInfo>;
254
+ /**
255
+ * Callback for login() and reset(), the result is true on success
256
+ */
257
+ export type SMTPConnectionCallback = (err: NodemailerError | null, result?: boolean) => void;
258
+ /**
259
+ * Callback for the message data response, yields the server response text
260
+ */
261
+ export type SMTPConnectionResponseCallback = (err: NodemailerError | null, response?: string) => void;
262
+ /**
263
+ * Callback for connect(), run once the SMTP handshake is finished
264
+ */
265
+ export type SMTPConnectionConnectCallback = (err?: NodemailerError) => void;
266
+ /**
267
+ * Options handed to net.connect or tls.connect, resolved hostname values are merged in
268
+ */
269
+ export interface SMTPConnectionConnectOptions extends tls.ConnectionOptions {
270
+ port: number;
271
+ host: string;
272
+ /** Outbound address to bind to */
273
+ localAddress?: string | undefined;
274
+ /** Count loopback interfaces when resolving the hostname */
275
+ allowInternalNetworkInterfaces?: boolean | undefined;
276
+ /** DNS lookup timeout in ms */
277
+ timeout?: number | undefined;
278
+ }
279
+ /**
280
+ * A queued handler for the next server response
281
+ */
282
+ export type SMTPConnectionResponseAction = (str: string) => void;
283
+ /**
284
+ * Generates a SMTP connection object
285
+ *
286
+ * Optional options object takes the following possible properties:
287
+ *
288
+ * * **port** - is the port to connect to (defaults to 587 or 465)
289
+ * * **host** - is the hostname or IP address to connect to (defaults to 'localhost')
290
+ * * **secure** - use SSL
291
+ * * **ignoreTLS** - ignore server support for STARTTLS (has no effect when requireTLS is set)
292
+ * * **requireTLS** - forces the client to use STARTTLS, takes precedence over ignoreTLS and opportunisticTLS
293
+ * * **name** - the name of the client server
294
+ * * **localAddress** - outbound address to bind to (see: http://nodejs.org/api/net.html#net_net_connect_options_connectionlistener)
295
+ * * **greetingTimeout** - Time to wait in ms until greeting message is received from the server (defaults to 30 seconds)
296
+ * * **connectionTimeout** - how many milliseconds to wait for the connection to establish (defaults to 2 minutes)
297
+ * * **socketTimeout** - Time of inactivity until the connection is closed (defaults to 10 minutes)
298
+ * * **maxResponseSize** - Largest single server response to accept in bytes (defaults to 1 MB)
299
+ * * **dnsTimeout** - Time to wait in ms for the DNS requests to be resolved (defaults to 30 seconds)
300
+ * * **lmtp** - if true, uses LMTP instead of SMTP protocol
301
+ * * **logger** - bunyan compatible logger interface
302
+ * * **debug** - if true pass SMTP traffic to the logger
303
+ * * **tls** - options for createCredentials
304
+ * * **socket** - existing socket to use instead of creating a new one (see: http://nodejs.org/api/net.html#net_class_net_socket)
305
+ * * **secured** - boolean indicates that the provided socket has already been upgraded to tls
306
+ *
307
+ * @constructor
308
+ * @namespace SMTP Client module
309
+ * @param [options] Option properties
310
+ */
311
+ declare class SMTPConnection extends EventEmitter {
312
+ id: string;
313
+ stage: 'init' | 'connected';
314
+ options: SMTPConnectionOptions;
315
+ secureConnection: boolean;
316
+ alreadySecured: boolean;
317
+ port: number;
318
+ host: string;
319
+ servername: string | false;
320
+ allowInternalNetworkInterfaces: boolean;
321
+ name: string;
322
+ logger: shared.Logger;
323
+ customAuth: Map<string, SMTPConnectionCustomAuthHandler>;
324
+ /**
325
+ * Expose version nr, just for the reference
326
+ */
327
+ version: string;
328
+ /**
329
+ * If true, then the user is authenticated
330
+ */
331
+ authenticated: boolean;
332
+ /**
333
+ * If set to true, this instance is no longer active
334
+ * @private
335
+ */
336
+ destroyed: boolean;
337
+ /**
338
+ * Defines if the current connection is secure or not. If not,
339
+ * STARTTLS can be used if available
340
+ * @private
341
+ */
342
+ secure: boolean;
343
+ lastServerResponse: string | false;
344
+ /**
345
+ * The socket connecting to the server
346
+ * @public
347
+ */
348
+ _socket: net.Socket | false | null;
349
+ /**
350
+ * Set to true, if EHLO response includes "AUTH".
351
+ * If false then authentication is not tried
352
+ */
353
+ allowsAuth: boolean;
354
+ /**
355
+ * True while the STARTTLS upgrade is in progress
356
+ * @private
357
+ */
358
+ upgrading?: boolean | undefined;
359
+ constructor(options?: SMTPConnectionOptions);
360
+ /**
361
+ * Creates a connection to a SMTP server and sets up connection
362
+ * listener
363
+ */
364
+ connect(connectCallback?: SMTPConnectionConnectCallback): void;
365
+ /**
366
+ * Sends QUIT
367
+ */
368
+ quit(): void;
369
+ /**
370
+ * Closes the connection to the server
371
+ */
372
+ close(): void;
373
+ /**
374
+ * Authenticate user
375
+ */
376
+ login(authData: SMTPConnectionAuth | undefined, callback: SMTPConnectionCallback): void;
377
+ /**
378
+ * Sends a message
379
+ *
380
+ * @param envelope Envelope object, {from: addr, to: [addr]}
381
+ * @param message String, Buffer or a Stream
382
+ * @param done Callback to return once sending is completed
383
+ */
384
+ send(envelope: SMTPEnvelope, message: string | Buffer | Readable, done: SMTPConnectionSendCallback): void;
385
+ /**
386
+ * Resets connection state
387
+ *
388
+ * @param callback Callback to return once connection is reset
389
+ */
390
+ reset(callback: SMTPConnectionCallback): void;
391
+ }
392
+ /**
393
+ * Type aliases in the layout of @types/nodemailer, so `SMTPConnection.Options` style references keep working
394
+ */
395
+ declare namespace SMTPConnection {
396
+ type Options = SMTPConnectionOptions;
397
+ type AuthenticationType = SMTPConnectionAuth;
398
+ type AuthenticationTypeLogin = SMTPConnectionAuth;
399
+ type AuthenticationTypeOAuth2 = SMTPConnectionAuth;
400
+ type AuthenticationTypeCustom = SMTPConnectionAuth;
401
+ type AuthenticationCredentials = SMTPConnectionAuth;
402
+ type AuthenticationOAuth2 = SMTPConnectionAuth;
403
+ type Credentials = SMTPConnectionCredentials;
404
+ type OAuth2 = XOAuth2Options;
405
+ type Envelope = SMTPEnvelope;
406
+ type DSNOptions = SMTPEnvelopeDsn;
407
+ type DSNOption = SMTPEnvelopeDsnNotify;
408
+ type SentMessageInfo = SMTPConnectionSendInfo;
409
+ type SMTPError = NodemailerError;
410
+ type CustomAuthenticationContext = SMTPConnectionCustomAuthContext;
411
+ type CustomAuthenticationResponse = SMTPConnectionCustomAuthResponse;
412
+ type CustomAuthenticationHandlers = SMTPConnectionCustomAuthHandlers;
413
+ }
414
+ /** The same aliases as module level exports, for `import * as SMTPConnection` and `import SMTPConnection = require()` */
415
+ export type { SMTPConnectionOptions as Options, SMTPConnectionAuth as AuthenticationType, SMTPConnectionAuth as AuthenticationTypeLogin, SMTPConnectionAuth as AuthenticationTypeOAuth2, SMTPConnectionAuth as AuthenticationTypeCustom, SMTPConnectionAuth as AuthenticationCredentials, SMTPConnectionAuth as AuthenticationOAuth2, SMTPConnectionCredentials as Credentials, XOAuth2Options as OAuth2, SMTPEnvelope as Envelope, SMTPEnvelopeDsn as DSNOptions, SMTPEnvelopeDsnNotify as DSNOption, SMTPConnectionSendInfo as SentMessageInfo, NodemailerError as SMTPError, SMTPConnectionCustomAuthContext as CustomAuthenticationContext, SMTPConnectionCustomAuthResponse as CustomAuthenticationResponse, SMTPConnectionCustomAuthHandlers as CustomAuthenticationHandlers };
416
+ export default SMTPConnection;