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,105 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { Transform } = require('stream');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Escapes dots in the beginning of lines. Ends the stream with <CR><LF>.<CR><LF>
|
|
7
|
+
* Also makes sure that only <CR><LF> sequences are used for linebreaks
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} options Stream options
|
|
10
|
+
*/
|
|
11
|
+
class DataStream extends Transform {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super(options);
|
|
14
|
+
this.options = options || {};
|
|
15
|
+
|
|
16
|
+
this.inByteCount = 0;
|
|
17
|
+
this.outByteCount = 0;
|
|
18
|
+
this.lastByte = false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Escapes dots
|
|
23
|
+
*/
|
|
24
|
+
_transform(chunk, encoding, done) {
|
|
25
|
+
const chunks = [];
|
|
26
|
+
let chunklen = 0;
|
|
27
|
+
let i,
|
|
28
|
+
len,
|
|
29
|
+
lastPos = 0;
|
|
30
|
+
let buf;
|
|
31
|
+
|
|
32
|
+
if (!chunk || !chunk.length) {
|
|
33
|
+
return done();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (typeof chunk === 'string') {
|
|
37
|
+
chunk = Buffer.from(chunk);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.inByteCount += chunk.length;
|
|
41
|
+
|
|
42
|
+
for (i = 0, len = chunk.length; i < len; i++) {
|
|
43
|
+
if (chunk[i] === 0x2e) {
|
|
44
|
+
// .
|
|
45
|
+
if ((i && chunk[i - 1] === 0x0a) || (!i && (!this.lastByte || this.lastByte === 0x0a))) {
|
|
46
|
+
buf = chunk.slice(lastPos, i + 1);
|
|
47
|
+
chunks.push(buf);
|
|
48
|
+
chunks.push(Buffer.from('.'));
|
|
49
|
+
chunklen += buf.length + 1;
|
|
50
|
+
lastPos = i + 1;
|
|
51
|
+
}
|
|
52
|
+
} else if (chunk[i] === 0x0a) {
|
|
53
|
+
// \n
|
|
54
|
+
if ((i && chunk[i - 1] !== 0x0d) || (!i && this.lastByte !== 0x0d)) {
|
|
55
|
+
if (i > lastPos) {
|
|
56
|
+
buf = chunk.slice(lastPos, i);
|
|
57
|
+
chunks.push(buf);
|
|
58
|
+
chunklen += buf.length + 2;
|
|
59
|
+
} else {
|
|
60
|
+
chunklen += 2;
|
|
61
|
+
}
|
|
62
|
+
chunks.push(Buffer.from('\r\n'));
|
|
63
|
+
lastPos = i + 1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (chunklen) {
|
|
69
|
+
// add last piece
|
|
70
|
+
if (lastPos < chunk.length) {
|
|
71
|
+
buf = chunk.slice(lastPos);
|
|
72
|
+
chunks.push(buf);
|
|
73
|
+
chunklen += buf.length;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.outByteCount += chunklen;
|
|
77
|
+
this.push(Buffer.concat(chunks, chunklen));
|
|
78
|
+
} else {
|
|
79
|
+
this.outByteCount += chunk.length;
|
|
80
|
+
this.push(chunk);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
this.lastByte = chunk[chunk.length - 1];
|
|
84
|
+
done();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Finalizes the stream with a dot on a single line
|
|
89
|
+
*/
|
|
90
|
+
_flush(done) {
|
|
91
|
+
let buf;
|
|
92
|
+
if (this.lastByte === 0x0a) {
|
|
93
|
+
buf = Buffer.from('.\r\n');
|
|
94
|
+
} else if (this.lastByte === 0x0d) {
|
|
95
|
+
buf = Buffer.from('\n.\r\n');
|
|
96
|
+
} else {
|
|
97
|
+
buf = Buffer.from('\r\n.\r\n');
|
|
98
|
+
}
|
|
99
|
+
this.outByteCount += buf.length;
|
|
100
|
+
this.push(buf);
|
|
101
|
+
done();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
module.exports = DataStream;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Minimal HTTP/S proxy client
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const net = require('net');
|
|
8
|
+
const tls = require('tls');
|
|
9
|
+
const urllib = require('url');
|
|
10
|
+
const errors = require('../errors');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Establishes proxied connection to destinationPort
|
|
14
|
+
*
|
|
15
|
+
* httpProxyClient("http://localhost:3128/", 80, "google.com", function(err, socket){
|
|
16
|
+
* socket.write("GET / HTTP/1.0\r\n\r\n");
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* @param {String} proxyUrl proxy configuration, etg "http://proxy.host:3128/"
|
|
20
|
+
* @param {Number} destinationPort Port to open in destination host
|
|
21
|
+
* @param {String} destinationHost Destination hostname
|
|
22
|
+
* @param {Function} callback Callback to run with the rocket object once connection is established
|
|
23
|
+
*/
|
|
24
|
+
function httpProxyClient(proxyUrl, destinationPort, destinationHost, callback) {
|
|
25
|
+
const proxy = urllib.parse(proxyUrl);
|
|
26
|
+
|
|
27
|
+
const options = {
|
|
28
|
+
host: proxy.hostname,
|
|
29
|
+
port: Number(proxy.port) ? Number(proxy.port) : proxy.protocol === 'https:' ? 443 : 80
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
let connect;
|
|
33
|
+
if (proxy.protocol === 'https:') {
|
|
34
|
+
// we can use untrusted proxies as long as we verify actual SMTP certificates
|
|
35
|
+
options.rejectUnauthorized = false;
|
|
36
|
+
connect = tls.connect.bind(tls);
|
|
37
|
+
} else {
|
|
38
|
+
connect = net.connect.bind(net);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let socket;
|
|
42
|
+
|
|
43
|
+
// Error harness for initial connection. Once connection is established, the responsibility
|
|
44
|
+
// to handle errors is passed to whoever uses this socket
|
|
45
|
+
let finished = false;
|
|
46
|
+
const tempSocketErr = err => {
|
|
47
|
+
if (finished) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
finished = true;
|
|
51
|
+
try {
|
|
52
|
+
socket.destroy();
|
|
53
|
+
} catch (_E) {
|
|
54
|
+
// ignore
|
|
55
|
+
}
|
|
56
|
+
callback(err);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const timeoutErr = () => {
|
|
60
|
+
const err = new Error('Proxy socket timed out');
|
|
61
|
+
err.code = 'ETIMEDOUT';
|
|
62
|
+
tempSocketErr(err);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
socket = connect(options, () => {
|
|
66
|
+
if (finished) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const reqHeaders = {
|
|
71
|
+
Host: destinationHost + ':' + destinationPort,
|
|
72
|
+
Connection: 'close'
|
|
73
|
+
};
|
|
74
|
+
if (proxy.auth) {
|
|
75
|
+
reqHeaders['Proxy-Authorization'] = 'Basic ' + Buffer.from(proxy.auth).toString('base64');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
socket.write(
|
|
79
|
+
// HTTP method
|
|
80
|
+
'CONNECT ' +
|
|
81
|
+
destinationHost +
|
|
82
|
+
':' +
|
|
83
|
+
destinationPort +
|
|
84
|
+
' HTTP/1.1\r\n' +
|
|
85
|
+
// HTTP request headers
|
|
86
|
+
Object.keys(reqHeaders)
|
|
87
|
+
.map(key => key + ': ' + reqHeaders[key])
|
|
88
|
+
.join('\r\n') +
|
|
89
|
+
// End request
|
|
90
|
+
'\r\n\r\n'
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
let headers = '';
|
|
94
|
+
const onSocketData = chunk => {
|
|
95
|
+
let match;
|
|
96
|
+
let remainder;
|
|
97
|
+
|
|
98
|
+
if (finished) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
headers += chunk.toString('binary');
|
|
103
|
+
if ((match = headers.match(/\r\n\r\n/))) {
|
|
104
|
+
socket.removeListener('data', onSocketData);
|
|
105
|
+
|
|
106
|
+
remainder = headers.substr(match.index + match[0].length);
|
|
107
|
+
headers = headers.substr(0, match.index);
|
|
108
|
+
if (remainder) {
|
|
109
|
+
socket.unshift(Buffer.from(remainder, 'binary'));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// proxy connection is now established
|
|
113
|
+
finished = true;
|
|
114
|
+
|
|
115
|
+
// check response code
|
|
116
|
+
match = headers.match(/^HTTP\/\d+\.\d+ (\d+)/i);
|
|
117
|
+
if (!match || (match[1] || '').charAt(0) !== '2') {
|
|
118
|
+
try {
|
|
119
|
+
socket.destroy();
|
|
120
|
+
} catch (_E) {
|
|
121
|
+
// ignore
|
|
122
|
+
}
|
|
123
|
+
const err = new Error('Invalid response from proxy' + ((match && ': ' + match[1]) || ''));
|
|
124
|
+
err.code = errors.EPROXY;
|
|
125
|
+
return callback(err);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
socket.removeListener('error', tempSocketErr);
|
|
129
|
+
socket.removeListener('timeout', timeoutErr);
|
|
130
|
+
socket.setTimeout(0);
|
|
131
|
+
|
|
132
|
+
return callback(null, socket);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
socket.on('data', onSocketData);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
socket.setTimeout(httpProxyClient.timeout || 30 * 1000);
|
|
139
|
+
socket.on('timeout', timeoutErr);
|
|
140
|
+
|
|
141
|
+
socket.once('error', tempSocketErr);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
module.exports = httpProxyClient;
|