aiplang 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/bin/aiplang.js +7 -7
  2. package/package.json +7 -5
  3. package/server/node_modules/.package-lock.json +9 -0
  4. package/server/node_modules/nodemailer/.gitattributes +6 -0
  5. package/server/node_modules/nodemailer/.ncurc.js +9 -0
  6. package/server/node_modules/nodemailer/.prettierignore +8 -0
  7. package/server/node_modules/nodemailer/.prettierrc +12 -0
  8. package/server/node_modules/nodemailer/.prettierrc.js +10 -0
  9. package/server/node_modules/nodemailer/.release-please-config.json +9 -0
  10. package/server/node_modules/nodemailer/CHANGELOG.md +976 -0
  11. package/server/node_modules/nodemailer/CODE_OF_CONDUCT.md +76 -0
  12. package/server/node_modules/nodemailer/LICENSE +16 -0
  13. package/server/node_modules/nodemailer/README.md +86 -0
  14. package/server/node_modules/nodemailer/SECURITY.txt +22 -0
  15. package/server/node_modules/nodemailer/eslint.config.js +88 -0
  16. package/server/node_modules/nodemailer/lib/addressparser/index.js +382 -0
  17. package/server/node_modules/nodemailer/lib/base64/index.js +140 -0
  18. package/server/node_modules/nodemailer/lib/dkim/index.js +245 -0
  19. package/server/node_modules/nodemailer/lib/dkim/message-parser.js +154 -0
  20. package/server/node_modules/nodemailer/lib/dkim/relaxed-body.js +154 -0
  21. package/server/node_modules/nodemailer/lib/dkim/sign.js +116 -0
  22. package/server/node_modules/nodemailer/lib/errors.js +58 -0
  23. package/server/node_modules/nodemailer/lib/fetch/cookies.js +276 -0
  24. package/server/node_modules/nodemailer/lib/fetch/index.js +278 -0
  25. package/server/node_modules/nodemailer/lib/json-transport/index.js +82 -0
  26. package/server/node_modules/nodemailer/lib/mail-composer/index.js +599 -0
  27. package/server/node_modules/nodemailer/lib/mailer/index.js +446 -0
  28. package/server/node_modules/nodemailer/lib/mailer/mail-message.js +312 -0
  29. package/server/node_modules/nodemailer/lib/mime-funcs/index.js +610 -0
  30. package/server/node_modules/nodemailer/lib/mime-funcs/mime-types.js +2109 -0
  31. package/server/node_modules/nodemailer/lib/mime-node/index.js +1334 -0
  32. package/server/node_modules/nodemailer/lib/mime-node/last-newline.js +33 -0
  33. package/server/node_modules/nodemailer/lib/mime-node/le-unix.js +40 -0
  34. package/server/node_modules/nodemailer/lib/mime-node/le-windows.js +49 -0
  35. package/server/node_modules/nodemailer/lib/nodemailer.js +151 -0
  36. package/server/node_modules/nodemailer/lib/punycode/index.js +460 -0
  37. package/server/node_modules/nodemailer/lib/qp/index.js +230 -0
  38. package/server/node_modules/nodemailer/lib/sendmail-transport/index.js +205 -0
  39. package/server/node_modules/nodemailer/lib/ses-transport/index.js +223 -0
  40. package/server/node_modules/nodemailer/lib/shared/index.js +698 -0
  41. package/server/node_modules/nodemailer/lib/smtp-connection/data-stream.js +105 -0
  42. package/server/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +144 -0
  43. package/server/node_modules/nodemailer/lib/smtp-connection/index.js +1903 -0
  44. package/server/node_modules/nodemailer/lib/smtp-pool/index.js +641 -0
  45. package/server/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +256 -0
  46. package/server/node_modules/nodemailer/lib/smtp-transport/index.js +402 -0
  47. package/server/node_modules/nodemailer/lib/stream-transport/index.js +135 -0
  48. package/server/node_modules/nodemailer/lib/well-known/index.js +47 -0
  49. package/server/node_modules/nodemailer/lib/well-known/services.json +619 -0
  50. package/server/node_modules/nodemailer/lib/xoauth2/index.js +436 -0
  51. package/server/node_modules/nodemailer/package.json +48 -0
  52. package/server/server.js +686 -865
  53. /package/{FLUX-PROJECT-KNOWLEDGE.md → aiplang-knowledge.md} +0 -0
@@ -0,0 +1,312 @@
1
+ 'use strict';
2
+
3
+ const shared = require('../shared');
4
+ const MimeNode = require('../mime-node');
5
+ const mimeFuncs = require('../mime-funcs');
6
+
7
+ class MailMessage {
8
+ constructor(mailer, data) {
9
+ this.mailer = mailer;
10
+ this.data = {};
11
+ this.message = null;
12
+
13
+ data = data || {};
14
+ const options = mailer.options || {};
15
+ const defaults = mailer._defaults || {};
16
+
17
+ Object.assign(this.data, data);
18
+
19
+ this.data.headers = this.data.headers || {};
20
+
21
+ // apply defaults
22
+ Object.keys(defaults).forEach(key => {
23
+ if (!(key in this.data)) {
24
+ this.data[key] = defaults[key];
25
+ } else if (key === 'headers') {
26
+ // headers is a special case. Allow setting individual default headers
27
+ Object.keys(defaults.headers).forEach(key => {
28
+ if (!(key in this.data.headers)) {
29
+ this.data.headers[key] = defaults.headers[key];
30
+ }
31
+ });
32
+ }
33
+ });
34
+
35
+ // force specific keys from transporter options
36
+ ['disableFileAccess', 'disableUrlAccess', 'normalizeHeaderKey'].forEach(key => {
37
+ if (key in options) {
38
+ this.data[key] = options[key];
39
+ }
40
+ });
41
+ }
42
+
43
+ resolveContent(...args) {
44
+ return shared.resolveContent(...args);
45
+ }
46
+
47
+ resolveAll(callback) {
48
+ const keys = [
49
+ [this.data, 'html'],
50
+ [this.data, 'text'],
51
+ [this.data, 'watchHtml'],
52
+ [this.data, 'amp'],
53
+ [this.data, 'icalEvent']
54
+ ];
55
+
56
+ if (this.data.alternatives && this.data.alternatives.length) {
57
+ this.data.alternatives.forEach((alternative, i) => {
58
+ keys.push([this.data.alternatives, i]);
59
+ });
60
+ }
61
+
62
+ if (this.data.attachments && this.data.attachments.length) {
63
+ this.data.attachments.forEach((attachment, i) => {
64
+ if (!attachment.filename) {
65
+ attachment.filename =
66
+ (attachment.path || attachment.href || '').split('/').pop().split('?').shift() || 'attachment-' + (i + 1);
67
+ if (attachment.filename.indexOf('.') < 0) {
68
+ attachment.filename += '.' + mimeFuncs.detectExtension(attachment.contentType);
69
+ }
70
+ }
71
+
72
+ if (!attachment.contentType) {
73
+ attachment.contentType = mimeFuncs.detectMimeType(attachment.filename || attachment.path || attachment.href || 'bin');
74
+ }
75
+
76
+ keys.push([this.data.attachments, i]);
77
+ });
78
+ }
79
+
80
+ const mimeNode = new MimeNode();
81
+
82
+ const addressKeys = ['from', 'to', 'cc', 'bcc', 'sender', 'replyTo'];
83
+
84
+ addressKeys.forEach(address => {
85
+ let value;
86
+ if (this.message) {
87
+ value = [].concat(mimeNode._parseAddresses(this.message.getHeader(address === 'replyTo' ? 'reply-to' : address)) || []);
88
+ } else if (this.data[address]) {
89
+ value = [].concat(mimeNode._parseAddresses(this.data[address]) || []);
90
+ }
91
+ if (value && value.length) {
92
+ this.data[address] = value;
93
+ } else if (address in this.data) {
94
+ this.data[address] = null;
95
+ }
96
+ });
97
+
98
+ const singleKeys = ['from', 'sender'];
99
+ singleKeys.forEach(address => {
100
+ if (this.data[address]) {
101
+ this.data[address] = this.data[address].shift();
102
+ }
103
+ });
104
+
105
+ let pos = 0;
106
+ const resolveNext = () => {
107
+ if (pos >= keys.length) {
108
+ return callback(null, this.data);
109
+ }
110
+ const args = keys[pos++];
111
+ if (!args[0] || !args[0][args[1]]) {
112
+ return resolveNext();
113
+ }
114
+ shared.resolveContent(...args, (err, value) => {
115
+ if (err) {
116
+ return callback(err);
117
+ }
118
+
119
+ const node = {
120
+ content: value
121
+ };
122
+ if (args[0][args[1]] && typeof args[0][args[1]] === 'object' && !Buffer.isBuffer(args[0][args[1]])) {
123
+ Object.keys(args[0][args[1]]).forEach(key => {
124
+ if (!(key in node) && !['content', 'path', 'href', 'raw'].includes(key)) {
125
+ node[key] = args[0][args[1]][key];
126
+ }
127
+ });
128
+ }
129
+
130
+ args[0][args[1]] = node;
131
+ resolveNext();
132
+ });
133
+ };
134
+
135
+ setImmediate(() => resolveNext());
136
+ }
137
+
138
+ normalize(callback) {
139
+ const envelope = this.data.envelope || this.message.getEnvelope();
140
+ const messageId = this.message.messageId();
141
+
142
+ this.resolveAll((err, data) => {
143
+ if (err) {
144
+ return callback(err);
145
+ }
146
+
147
+ data.envelope = envelope;
148
+ data.messageId = messageId;
149
+
150
+ ['html', 'text', 'watchHtml', 'amp'].forEach(key => {
151
+ if (data[key] && data[key].content) {
152
+ if (typeof data[key].content === 'string') {
153
+ data[key] = data[key].content;
154
+ } else if (Buffer.isBuffer(data[key].content)) {
155
+ data[key] = data[key].content.toString();
156
+ }
157
+ }
158
+ });
159
+
160
+ if (data.icalEvent && Buffer.isBuffer(data.icalEvent.content)) {
161
+ data.icalEvent.content = data.icalEvent.content.toString('base64');
162
+ data.icalEvent.encoding = 'base64';
163
+ }
164
+
165
+ if (data.alternatives && data.alternatives.length) {
166
+ data.alternatives.forEach(alternative => {
167
+ if (alternative && alternative.content && Buffer.isBuffer(alternative.content)) {
168
+ alternative.content = alternative.content.toString('base64');
169
+ alternative.encoding = 'base64';
170
+ }
171
+ });
172
+ }
173
+
174
+ if (data.attachments && data.attachments.length) {
175
+ data.attachments.forEach(attachment => {
176
+ if (attachment && attachment.content && Buffer.isBuffer(attachment.content)) {
177
+ attachment.content = attachment.content.toString('base64');
178
+ attachment.encoding = 'base64';
179
+ }
180
+ });
181
+ }
182
+
183
+ data.normalizedHeaders = {};
184
+ Object.keys(data.headers || {}).forEach(key => {
185
+ let value = [].concat(data.headers[key] || []).shift();
186
+ value = (value && value.value) || value;
187
+ if (value) {
188
+ if (['references', 'in-reply-to', 'message-id', 'content-id'].includes(key)) {
189
+ value = this.message._encodeHeaderValue(key, value);
190
+ }
191
+ data.normalizedHeaders[key] = value;
192
+ }
193
+ });
194
+
195
+ if (data.list && typeof data.list === 'object') {
196
+ const listHeaders = this._getListHeaders(data.list);
197
+ listHeaders.forEach(entry => {
198
+ data.normalizedHeaders[entry.key] = entry.value.map(val => (val && val.value) || val).join(', ');
199
+ });
200
+ }
201
+
202
+ if (data.references) {
203
+ data.normalizedHeaders.references = this.message._encodeHeaderValue('references', data.references);
204
+ }
205
+
206
+ if (data.inReplyTo) {
207
+ data.normalizedHeaders['in-reply-to'] = this.message._encodeHeaderValue('in-reply-to', data.inReplyTo);
208
+ }
209
+
210
+ return callback(null, data);
211
+ });
212
+ }
213
+
214
+ setMailerHeader() {
215
+ if (!this.message || !this.data.xMailer) {
216
+ return;
217
+ }
218
+ this.message.setHeader('X-Mailer', this.data.xMailer);
219
+ }
220
+
221
+ setPriorityHeaders() {
222
+ if (!this.message || !this.data.priority) {
223
+ return;
224
+ }
225
+ switch ((this.data.priority || '').toString().toLowerCase()) {
226
+ case 'high':
227
+ this.message.setHeader('X-Priority', '1 (Highest)');
228
+ this.message.setHeader('X-MSMail-Priority', 'High');
229
+ this.message.setHeader('Importance', 'High');
230
+ break;
231
+ case 'low':
232
+ this.message.setHeader('X-Priority', '5 (Lowest)');
233
+ this.message.setHeader('X-MSMail-Priority', 'Low');
234
+ this.message.setHeader('Importance', 'Low');
235
+ break;
236
+ default:
237
+ // do not add anything, since all messages are 'Normal' by default
238
+ }
239
+ }
240
+
241
+ setListHeaders() {
242
+ if (!this.message || !this.data.list || typeof this.data.list !== 'object') {
243
+ return;
244
+ }
245
+ // add optional List-* headers
246
+ this._getListHeaders(this.data.list).forEach(listHeader => {
247
+ listHeader.value.forEach(value => {
248
+ this.message.addHeader(listHeader.key, value);
249
+ });
250
+ });
251
+ }
252
+
253
+ _getListHeaders(listData) {
254
+ // make sure an url looks like <protocol:url>
255
+ return Object.keys(listData).map(key => ({
256
+ key: 'list-' + key.toLowerCase().trim(),
257
+ value: [].concat(listData[key] || []).map(value => ({
258
+ prepared: true,
259
+ foldLines: true,
260
+ value: []
261
+ .concat(value || [])
262
+ .map(value => {
263
+ if (typeof value === 'string') {
264
+ value = {
265
+ url: value
266
+ };
267
+ }
268
+
269
+ if (value && value.url) {
270
+ if (key.toLowerCase().trim() === 'id') {
271
+ // List-ID: "comment" <domain>
272
+ let comment = value.comment || '';
273
+ if (mimeFuncs.isPlainText(comment)) {
274
+ comment = '"' + comment + '"';
275
+ } else {
276
+ comment = mimeFuncs.encodeWord(comment);
277
+ }
278
+
279
+ return (value.comment ? comment + ' ' : '') + this._formatListUrl(value.url).replace(/^<[^:]+\/{,2}/, '');
280
+ }
281
+
282
+ // List-*: <http://domain> (comment)
283
+ let comment = value.comment || '';
284
+ if (!mimeFuncs.isPlainText(comment)) {
285
+ comment = mimeFuncs.encodeWord(comment);
286
+ }
287
+
288
+ return this._formatListUrl(value.url) + (value.comment ? ' (' + comment + ')' : '');
289
+ }
290
+
291
+ return '';
292
+ })
293
+ .filter(value => value)
294
+ .join(', ')
295
+ }))
296
+ }));
297
+ }
298
+
299
+ _formatListUrl(url) {
300
+ url = url.replace(/[\s<]+|[\s>]+/g, '');
301
+ if (/^(https?|mailto|ftp):/.test(url)) {
302
+ return '<' + url + '>';
303
+ }
304
+ if (/^[^@]+@[^@]+$/.test(url)) {
305
+ return '<mailto:' + url + '>';
306
+ }
307
+
308
+ return '<http://' + url + '>';
309
+ }
310
+ }
311
+
312
+ module.exports = MailMessage;