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.
- package/bin/aiplang.js +7 -7
- package/package.json +7 -5
- package/server/node_modules/.package-lock.json +9 -0
- package/server/node_modules/nodemailer/.gitattributes +6 -0
- package/server/node_modules/nodemailer/.ncurc.js +9 -0
- package/server/node_modules/nodemailer/.prettierignore +8 -0
- package/server/node_modules/nodemailer/.prettierrc +12 -0
- package/server/node_modules/nodemailer/.prettierrc.js +10 -0
- package/server/node_modules/nodemailer/.release-please-config.json +9 -0
- package/server/node_modules/nodemailer/CHANGELOG.md +976 -0
- package/server/node_modules/nodemailer/CODE_OF_CONDUCT.md +76 -0
- package/server/node_modules/nodemailer/LICENSE +16 -0
- package/server/node_modules/nodemailer/README.md +86 -0
- package/server/node_modules/nodemailer/SECURITY.txt +22 -0
- package/server/node_modules/nodemailer/eslint.config.js +88 -0
- package/server/node_modules/nodemailer/lib/addressparser/index.js +382 -0
- package/server/node_modules/nodemailer/lib/base64/index.js +140 -0
- package/server/node_modules/nodemailer/lib/dkim/index.js +245 -0
- package/server/node_modules/nodemailer/lib/dkim/message-parser.js +154 -0
- package/server/node_modules/nodemailer/lib/dkim/relaxed-body.js +154 -0
- package/server/node_modules/nodemailer/lib/dkim/sign.js +116 -0
- package/server/node_modules/nodemailer/lib/errors.js +58 -0
- package/server/node_modules/nodemailer/lib/fetch/cookies.js +276 -0
- package/server/node_modules/nodemailer/lib/fetch/index.js +278 -0
- package/server/node_modules/nodemailer/lib/json-transport/index.js +82 -0
- package/server/node_modules/nodemailer/lib/mail-composer/index.js +599 -0
- package/server/node_modules/nodemailer/lib/mailer/index.js +446 -0
- package/server/node_modules/nodemailer/lib/mailer/mail-message.js +312 -0
- package/server/node_modules/nodemailer/lib/mime-funcs/index.js +610 -0
- package/server/node_modules/nodemailer/lib/mime-funcs/mime-types.js +2109 -0
- package/server/node_modules/nodemailer/lib/mime-node/index.js +1334 -0
- package/server/node_modules/nodemailer/lib/mime-node/last-newline.js +33 -0
- package/server/node_modules/nodemailer/lib/mime-node/le-unix.js +40 -0
- package/server/node_modules/nodemailer/lib/mime-node/le-windows.js +49 -0
- package/server/node_modules/nodemailer/lib/nodemailer.js +151 -0
- package/server/node_modules/nodemailer/lib/punycode/index.js +460 -0
- package/server/node_modules/nodemailer/lib/qp/index.js +230 -0
- package/server/node_modules/nodemailer/lib/sendmail-transport/index.js +205 -0
- package/server/node_modules/nodemailer/lib/ses-transport/index.js +223 -0
- package/server/node_modules/nodemailer/lib/shared/index.js +698 -0
- package/server/node_modules/nodemailer/lib/smtp-connection/data-stream.js +105 -0
- package/server/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +144 -0
- package/server/node_modules/nodemailer/lib/smtp-connection/index.js +1903 -0
- package/server/node_modules/nodemailer/lib/smtp-pool/index.js +641 -0
- package/server/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +256 -0
- package/server/node_modules/nodemailer/lib/smtp-transport/index.js +402 -0
- package/server/node_modules/nodemailer/lib/stream-transport/index.js +135 -0
- package/server/node_modules/nodemailer/lib/well-known/index.js +47 -0
- package/server/node_modules/nodemailer/lib/well-known/services.json +619 -0
- package/server/node_modules/nodemailer/lib/xoauth2/index.js +436 -0
- package/server/node_modules/nodemailer/package.json +48 -0
- package/server/server.js +686 -865
- /package/{FLUX-PROJECT-KNOWLEDGE.md → aiplang-knowledge.md} +0 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const http = require('http');
|
|
4
|
+
const https = require('https');
|
|
5
|
+
const urllib = require('url');
|
|
6
|
+
const zlib = require('zlib');
|
|
7
|
+
const { PassThrough } = require('stream');
|
|
8
|
+
const Cookies = require('./cookies');
|
|
9
|
+
const packageData = require('../../package.json');
|
|
10
|
+
const net = require('net');
|
|
11
|
+
const errors = require('../errors');
|
|
12
|
+
|
|
13
|
+
const MAX_REDIRECTS = 5;
|
|
14
|
+
|
|
15
|
+
module.exports = function (url, options) {
|
|
16
|
+
return nmfetch(url, options);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports.Cookies = Cookies;
|
|
20
|
+
|
|
21
|
+
function nmfetch(url, options) {
|
|
22
|
+
options = options || {};
|
|
23
|
+
|
|
24
|
+
options.fetchRes = options.fetchRes || new PassThrough();
|
|
25
|
+
options.cookies = options.cookies || new Cookies();
|
|
26
|
+
options.redirects = options.redirects || 0;
|
|
27
|
+
options.maxRedirects = isNaN(options.maxRedirects) ? MAX_REDIRECTS : options.maxRedirects;
|
|
28
|
+
|
|
29
|
+
if (options.cookie) {
|
|
30
|
+
[].concat(options.cookie || []).forEach(cookie => {
|
|
31
|
+
options.cookies.set(cookie, url);
|
|
32
|
+
});
|
|
33
|
+
options.cookie = false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const fetchRes = options.fetchRes;
|
|
37
|
+
const parsed = urllib.parse(url);
|
|
38
|
+
let method = (options.method || '').toString().trim().toUpperCase() || 'GET';
|
|
39
|
+
let finished = false;
|
|
40
|
+
let cookies;
|
|
41
|
+
let body;
|
|
42
|
+
|
|
43
|
+
const handler = parsed.protocol === 'https:' ? https : http;
|
|
44
|
+
|
|
45
|
+
const headers = {
|
|
46
|
+
'accept-encoding': 'gzip,deflate',
|
|
47
|
+
'user-agent': 'nodemailer/' + packageData.version
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
Object.keys(options.headers || {}).forEach(key => {
|
|
51
|
+
headers[key.toLowerCase().trim()] = options.headers[key];
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (options.userAgent) {
|
|
55
|
+
headers['user-agent'] = options.userAgent;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (parsed.auth) {
|
|
59
|
+
headers.Authorization = 'Basic ' + Buffer.from(parsed.auth).toString('base64');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if ((cookies = options.cookies.get(url))) {
|
|
63
|
+
headers.cookie = cookies;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (options.body) {
|
|
67
|
+
if (options.contentType !== false) {
|
|
68
|
+
headers['Content-Type'] = options.contentType || 'application/x-www-form-urlencoded';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (typeof options.body.pipe === 'function') {
|
|
72
|
+
// it's a stream
|
|
73
|
+
headers['Transfer-Encoding'] = 'chunked';
|
|
74
|
+
body = options.body;
|
|
75
|
+
body.on('error', err => {
|
|
76
|
+
if (finished) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
finished = true;
|
|
80
|
+
err.code = errors.EFETCH;
|
|
81
|
+
err.sourceUrl = url;
|
|
82
|
+
fetchRes.emit('error', err);
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
if (options.body instanceof Buffer) {
|
|
86
|
+
body = options.body;
|
|
87
|
+
} else if (typeof options.body === 'object') {
|
|
88
|
+
try {
|
|
89
|
+
// encodeURIComponent can fail on invalid input (partial emoji etc.)
|
|
90
|
+
body = Buffer.from(
|
|
91
|
+
Object.keys(options.body)
|
|
92
|
+
.map(key => {
|
|
93
|
+
const value = options.body[key].toString().trim();
|
|
94
|
+
return encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
|
95
|
+
})
|
|
96
|
+
.join('&')
|
|
97
|
+
);
|
|
98
|
+
} catch (E) {
|
|
99
|
+
if (finished) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
finished = true;
|
|
103
|
+
E.code = errors.EFETCH;
|
|
104
|
+
E.sourceUrl = url;
|
|
105
|
+
fetchRes.emit('error', E);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
body = Buffer.from(options.body.toString().trim());
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
headers['Content-Type'] = options.contentType || 'application/x-www-form-urlencoded';
|
|
113
|
+
headers['Content-Length'] = body.length;
|
|
114
|
+
}
|
|
115
|
+
// if method is not provided, use POST instead of GET
|
|
116
|
+
method = (options.method || '').toString().trim().toUpperCase() || 'POST';
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
let req;
|
|
120
|
+
const reqOptions = {
|
|
121
|
+
method,
|
|
122
|
+
host: parsed.hostname,
|
|
123
|
+
path: parsed.path,
|
|
124
|
+
port: parsed.port ? parsed.port : parsed.protocol === 'https:' ? 443 : 80,
|
|
125
|
+
headers,
|
|
126
|
+
rejectUnauthorized: false,
|
|
127
|
+
agent: false
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
if (options.tls) {
|
|
131
|
+
Object.assign(reqOptions, options.tls);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (
|
|
135
|
+
parsed.protocol === 'https:' &&
|
|
136
|
+
parsed.hostname &&
|
|
137
|
+
parsed.hostname !== reqOptions.host &&
|
|
138
|
+
!net.isIP(parsed.hostname) &&
|
|
139
|
+
!reqOptions.servername
|
|
140
|
+
) {
|
|
141
|
+
reqOptions.servername = parsed.hostname;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
req = handler.request(reqOptions);
|
|
146
|
+
} catch (E) {
|
|
147
|
+
finished = true;
|
|
148
|
+
setImmediate(() => {
|
|
149
|
+
E.code = errors.EFETCH;
|
|
150
|
+
E.sourceUrl = url;
|
|
151
|
+
fetchRes.emit('error', E);
|
|
152
|
+
});
|
|
153
|
+
return fetchRes;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (options.timeout) {
|
|
157
|
+
req.setTimeout(options.timeout, () => {
|
|
158
|
+
if (finished) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
finished = true;
|
|
162
|
+
req.abort();
|
|
163
|
+
const err = new Error('Request Timeout');
|
|
164
|
+
err.code = errors.EFETCH;
|
|
165
|
+
err.sourceUrl = url;
|
|
166
|
+
fetchRes.emit('error', err);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
req.on('error', err => {
|
|
171
|
+
if (finished) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
finished = true;
|
|
175
|
+
err.code = errors.EFETCH;
|
|
176
|
+
err.sourceUrl = url;
|
|
177
|
+
fetchRes.emit('error', err);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
req.on('response', res => {
|
|
181
|
+
let inflate;
|
|
182
|
+
|
|
183
|
+
if (finished) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
switch (res.headers['content-encoding']) {
|
|
188
|
+
case 'gzip':
|
|
189
|
+
case 'deflate':
|
|
190
|
+
inflate = zlib.createUnzip();
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (res.headers['set-cookie']) {
|
|
195
|
+
[].concat(res.headers['set-cookie'] || []).forEach(cookie => {
|
|
196
|
+
options.cookies.set(cookie, url);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {
|
|
201
|
+
// redirect
|
|
202
|
+
options.redirects++;
|
|
203
|
+
if (options.redirects > options.maxRedirects) {
|
|
204
|
+
finished = true;
|
|
205
|
+
const err = new Error('Maximum redirect count exceeded');
|
|
206
|
+
err.code = errors.EFETCH;
|
|
207
|
+
err.sourceUrl = url;
|
|
208
|
+
fetchRes.emit('error', err);
|
|
209
|
+
req.abort();
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
// redirect does not include POST body
|
|
213
|
+
options.method = 'GET';
|
|
214
|
+
options.body = false;
|
|
215
|
+
return nmfetch(urllib.resolve(url, res.headers.location), options);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
fetchRes.statusCode = res.statusCode;
|
|
219
|
+
fetchRes.headers = res.headers;
|
|
220
|
+
|
|
221
|
+
if (res.statusCode >= 300 && !options.allowErrorResponse) {
|
|
222
|
+
finished = true;
|
|
223
|
+
const err = new Error('Invalid status code ' + res.statusCode);
|
|
224
|
+
err.code = errors.EFETCH;
|
|
225
|
+
err.sourceUrl = url;
|
|
226
|
+
fetchRes.emit('error', err);
|
|
227
|
+
req.abort();
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
res.on('error', err => {
|
|
232
|
+
if (finished) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
finished = true;
|
|
236
|
+
err.code = errors.EFETCH;
|
|
237
|
+
err.sourceUrl = url;
|
|
238
|
+
fetchRes.emit('error', err);
|
|
239
|
+
req.abort();
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
if (inflate) {
|
|
243
|
+
res.pipe(inflate).pipe(fetchRes);
|
|
244
|
+
inflate.on('error', err => {
|
|
245
|
+
if (finished) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
finished = true;
|
|
249
|
+
err.code = errors.EFETCH;
|
|
250
|
+
err.sourceUrl = url;
|
|
251
|
+
fetchRes.emit('error', err);
|
|
252
|
+
req.abort();
|
|
253
|
+
});
|
|
254
|
+
} else {
|
|
255
|
+
res.pipe(fetchRes);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
setImmediate(() => {
|
|
260
|
+
if (body) {
|
|
261
|
+
try {
|
|
262
|
+
if (typeof body.pipe === 'function') {
|
|
263
|
+
return body.pipe(req);
|
|
264
|
+
}
|
|
265
|
+
req.write(body);
|
|
266
|
+
} catch (err) {
|
|
267
|
+
finished = true;
|
|
268
|
+
err.code = errors.EFETCH;
|
|
269
|
+
err.sourceUrl = url;
|
|
270
|
+
fetchRes.emit('error', err);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
req.end();
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
return fetchRes;
|
|
278
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const packageData = require('../../package.json');
|
|
4
|
+
const shared = require('../shared');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generates a Transport object to generate JSON output
|
|
8
|
+
*
|
|
9
|
+
* @constructor
|
|
10
|
+
* @param {Object} optional config parameter
|
|
11
|
+
*/
|
|
12
|
+
class JSONTransport {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
options = options || {};
|
|
15
|
+
|
|
16
|
+
this.options = options;
|
|
17
|
+
|
|
18
|
+
this.name = 'JSONTransport';
|
|
19
|
+
this.version = packageData.version;
|
|
20
|
+
|
|
21
|
+
this.logger = shared.getLogger(this.options, {
|
|
22
|
+
component: this.options.component || 'json-transport'
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* <p>Compiles a mailcomposer message and forwards it to handler that sends it.</p>
|
|
28
|
+
*
|
|
29
|
+
* @param {Object} emailMessage MailComposer object
|
|
30
|
+
* @param {Function} callback Callback function to run when the sending is completed
|
|
31
|
+
*/
|
|
32
|
+
send(mail, done) {
|
|
33
|
+
// Sendmail strips this header line by itself
|
|
34
|
+
mail.message.keepBcc = true;
|
|
35
|
+
|
|
36
|
+
const envelope = mail.data.envelope || mail.message.getEnvelope();
|
|
37
|
+
const messageId = mail.message.messageId();
|
|
38
|
+
|
|
39
|
+
const recipients = [].concat(envelope.to || []);
|
|
40
|
+
if (recipients.length > 3) {
|
|
41
|
+
recipients.push('...and ' + recipients.splice(2).length + ' more');
|
|
42
|
+
}
|
|
43
|
+
this.logger.info(
|
|
44
|
+
{
|
|
45
|
+
tnx: 'send',
|
|
46
|
+
messageId
|
|
47
|
+
},
|
|
48
|
+
'Composing JSON structure of %s to <%s>',
|
|
49
|
+
messageId,
|
|
50
|
+
recipients.join(', ')
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
setImmediate(() => {
|
|
54
|
+
mail.normalize((err, data) => {
|
|
55
|
+
if (err) {
|
|
56
|
+
this.logger.error(
|
|
57
|
+
{
|
|
58
|
+
err,
|
|
59
|
+
tnx: 'send',
|
|
60
|
+
messageId
|
|
61
|
+
},
|
|
62
|
+
'Failed building JSON structure for %s. %s',
|
|
63
|
+
messageId,
|
|
64
|
+
err.message
|
|
65
|
+
);
|
|
66
|
+
return done(err);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
delete data.envelope;
|
|
70
|
+
delete data.normalizedHeaders;
|
|
71
|
+
|
|
72
|
+
return done(null, {
|
|
73
|
+
envelope,
|
|
74
|
+
messageId,
|
|
75
|
+
message: this.options.skipEncoding ? data : JSON.stringify(data)
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
module.exports = JSONTransport;
|