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,116 @@
1
+ 'use strict';
2
+
3
+ const punycode = require('../punycode');
4
+ const mimeFuncs = require('../mime-funcs');
5
+ const crypto = require('crypto');
6
+
7
+ /**
8
+ * Returns DKIM signature header line
9
+ *
10
+ * @param {Object} headers Parsed headers object from MessageParser
11
+ * @param {String} bodyHash Base64 encoded hash of the message
12
+ * @param {Object} options DKIM options
13
+ * @param {String} options.domainName Domain name to be signed for
14
+ * @param {String} options.keySelector DKIM key selector to use
15
+ * @param {String} options.privateKey DKIM private key to use
16
+ * @return {String} Complete header line
17
+ */
18
+
19
+ module.exports = (headers, hashAlgo, bodyHash, options) => {
20
+ options = options || {};
21
+
22
+ // all listed fields from RFC4871 #5.5
23
+ const defaultFieldNames =
24
+ 'From:Sender:Reply-To:Subject:Date:Message-ID:To:' +
25
+ 'Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID:' +
26
+ 'Content-Description:Resent-Date:Resent-From:Resent-Sender:' +
27
+ 'Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:' +
28
+ 'List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:' +
29
+ 'List-Owner:List-Archive';
30
+
31
+ const fieldNames = options.headerFieldNames || defaultFieldNames;
32
+
33
+ const canonicalizedHeaderData = relaxedHeaders(headers, fieldNames, options.skipFields);
34
+ const dkimHeader = generateDKIMHeader(options.domainName, options.keySelector, canonicalizedHeaderData.fieldNames, hashAlgo, bodyHash);
35
+
36
+ canonicalizedHeaderData.headers += 'dkim-signature:' + relaxedHeaderLine(dkimHeader);
37
+
38
+ const signer = crypto.createSign(('rsa-' + hashAlgo).toUpperCase());
39
+ signer.update(canonicalizedHeaderData.headers);
40
+ let signature;
41
+ try {
42
+ signature = signer.sign(options.privateKey, 'base64');
43
+ } catch (_E) {
44
+ return false;
45
+ }
46
+
47
+ return dkimHeader + signature.replace(/(^.{73}|.{75}(?!\r?\n|\r))/g, '$&\r\n ').trim();
48
+ };
49
+
50
+ module.exports.relaxedHeaders = relaxedHeaders;
51
+
52
+ function generateDKIMHeader(domainName, keySelector, fieldNames, hashAlgo, bodyHash) {
53
+ const dkim = [
54
+ 'v=1',
55
+ 'a=rsa-' + hashAlgo,
56
+ 'c=relaxed/relaxed',
57
+ 'd=' + punycode.toASCII(domainName),
58
+ 'q=dns/txt',
59
+ 's=' + keySelector,
60
+ 'bh=' + bodyHash,
61
+ 'h=' + fieldNames
62
+ ].join('; ');
63
+
64
+ return mimeFuncs.foldLines('DKIM-Signature: ' + dkim, 76) + ';\r\n b=';
65
+ }
66
+
67
+ function relaxedHeaders(headers, fieldNames, skipFields) {
68
+ const includedFields = new Set();
69
+ const skip = new Set();
70
+ const headerFields = new Map();
71
+
72
+ (skipFields || '')
73
+ .toLowerCase()
74
+ .split(':')
75
+ .forEach(field => {
76
+ skip.add(field.trim());
77
+ });
78
+
79
+ (fieldNames || '')
80
+ .toLowerCase()
81
+ .split(':')
82
+ .filter(field => !skip.has(field.trim()))
83
+ .forEach(field => {
84
+ includedFields.add(field.trim());
85
+ });
86
+
87
+ for (let i = headers.length - 1; i >= 0; i--) {
88
+ const line = headers[i];
89
+ // only include the first value from bottom to top
90
+ if (includedFields.has(line.key) && !headerFields.has(line.key)) {
91
+ headerFields.set(line.key, relaxedHeaderLine(line.line));
92
+ }
93
+ }
94
+
95
+ const headersList = [];
96
+ const fields = [];
97
+ includedFields.forEach(field => {
98
+ if (headerFields.has(field)) {
99
+ fields.push(field);
100
+ headersList.push(field + ':' + headerFields.get(field));
101
+ }
102
+ });
103
+
104
+ return {
105
+ headers: headersList.join('\r\n') + '\r\n',
106
+ fieldNames: fields.join(':')
107
+ };
108
+ }
109
+
110
+ function relaxedHeaderLine(line) {
111
+ return line
112
+ .substr(line.indexOf(':') + 1)
113
+ .replace(/\r?\n/g, '')
114
+ .replace(/\s+/g, ' ')
115
+ .trim();
116
+ }
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Nodemailer Error Codes
5
+ *
6
+ * Centralized error code definitions for consistent error handling.
7
+ *
8
+ * Usage:
9
+ * const errors = require('./errors');
10
+ * let err = new Error('Connection closed');
11
+ * err.code = errors.ECONNECTION;
12
+ */
13
+
14
+ /**
15
+ * Error code descriptions for documentation and debugging
16
+ */
17
+ const ERROR_CODES = {
18
+ // Connection errors
19
+ ECONNECTION: 'Connection closed unexpectedly',
20
+ ETIMEDOUT: 'Connection or operation timed out',
21
+ ESOCKET: 'Socket-level error',
22
+ EDNS: 'DNS resolution failed',
23
+
24
+ // TLS/Security errors
25
+ ETLS: 'TLS handshake or STARTTLS failed',
26
+ EREQUIRETLS: 'REQUIRETLS not supported by server (RFC 8689)',
27
+
28
+ // Protocol errors
29
+ EPROTOCOL: 'Invalid SMTP server response',
30
+ EENVELOPE: 'Invalid mail envelope (sender or recipients)',
31
+ EMESSAGE: 'Message delivery error',
32
+ ESTREAM: 'Stream processing error',
33
+
34
+ // Authentication errors
35
+ EAUTH: 'Authentication failed',
36
+ ENOAUTH: 'Authentication credentials not provided',
37
+ EOAUTH2: 'OAuth2 token generation or refresh error',
38
+
39
+ // Resource errors
40
+ EMAXLIMIT: 'Pool resource limit reached (max messages per connection)',
41
+
42
+ // Transport-specific errors
43
+ ESENDMAIL: 'Sendmail command error',
44
+ ESES: 'AWS SES transport error',
45
+
46
+ // Configuration and access errors
47
+ ECONFIG: 'Invalid configuration',
48
+ EPROXY: 'Proxy connection error',
49
+ EFILEACCESS: 'File access rejected (disableFileAccess is set)',
50
+ EURLACCESS: 'URL access rejected (disableUrlAccess is set)',
51
+ EFETCH: 'HTTP fetch error'
52
+ };
53
+
54
+ // Export error codes as string constants and the full definitions object
55
+ module.exports = { ERROR_CODES };
56
+ for (const code of Object.keys(ERROR_CODES)) {
57
+ module.exports[code] = code;
58
+ }
@@ -0,0 +1,276 @@
1
+ 'use strict';
2
+
3
+ // module to handle cookies
4
+
5
+ const urllib = require('url');
6
+
7
+ const SESSION_TIMEOUT = 1800; // 30 min
8
+
9
+ /**
10
+ * Creates a biskviit cookie jar for managing cookie values in memory
11
+ *
12
+ * @constructor
13
+ * @param {Object} [options] Optional options object
14
+ */
15
+ class Cookies {
16
+ constructor(options) {
17
+ this.options = options || {};
18
+ this.cookies = [];
19
+ }
20
+
21
+ /**
22
+ * Stores a cookie string to the cookie storage
23
+ *
24
+ * @param {String} cookieStr Value from the 'Set-Cookie:' header
25
+ * @param {String} url Current URL
26
+ */
27
+ set(cookieStr, url) {
28
+ const urlparts = urllib.parse(url || '');
29
+ const cookie = this.parse(cookieStr);
30
+ let domain;
31
+
32
+ if (cookie.domain) {
33
+ domain = cookie.domain.replace(/^\./, '');
34
+
35
+ // do not allow cross origin cookies
36
+ if (
37
+ // can't be valid if the requested domain is shorter than current hostname
38
+ urlparts.hostname.length < domain.length ||
39
+ // prefix domains with dot to be sure that partial matches are not used
40
+ ('.' + urlparts.hostname).substr(-domain.length + 1) !== '.' + domain
41
+ ) {
42
+ cookie.domain = urlparts.hostname;
43
+ }
44
+ } else {
45
+ cookie.domain = urlparts.hostname;
46
+ }
47
+
48
+ if (!cookie.path) {
49
+ cookie.path = this.getPath(urlparts.pathname);
50
+ }
51
+
52
+ // if no expire date, then use sessionTimeout value
53
+ if (!cookie.expires) {
54
+ cookie.expires = new Date(Date.now() + (Number(this.options.sessionTimeout || SESSION_TIMEOUT) || SESSION_TIMEOUT) * 1000);
55
+ }
56
+
57
+ return this.add(cookie);
58
+ }
59
+
60
+ /**
61
+ * Returns cookie string for the 'Cookie:' header.
62
+ *
63
+ * @param {String} url URL to check for
64
+ * @returns {String} Cookie header or empty string if no matches were found
65
+ */
66
+ get(url) {
67
+ return this.list(url)
68
+ .map(cookie => cookie.name + '=' + cookie.value)
69
+ .join('; ');
70
+ }
71
+
72
+ /**
73
+ * Lists all valied cookie objects for the specified URL
74
+ *
75
+ * @param {String} url URL to check for
76
+ * @returns {Array} An array of cookie objects
77
+ */
78
+ list(url) {
79
+ const result = [];
80
+
81
+ for (let i = this.cookies.length - 1; i >= 0; i--) {
82
+ const cookie = this.cookies[i];
83
+
84
+ if (this.isExpired(cookie)) {
85
+ this.cookies.splice(i, 1);
86
+ continue;
87
+ }
88
+
89
+ if (this.match(cookie, url)) {
90
+ result.unshift(cookie);
91
+ }
92
+ }
93
+
94
+ return result;
95
+ }
96
+
97
+ /**
98
+ * Parses cookie string from the 'Set-Cookie:' header
99
+ *
100
+ * @param {String} cookieStr String from the 'Set-Cookie:' header
101
+ * @returns {Object} Cookie object
102
+ */
103
+ parse(cookieStr) {
104
+ const cookie = {};
105
+
106
+ (cookieStr || '')
107
+ .toString()
108
+ .split(';')
109
+ .forEach(cookiePart => {
110
+ const valueParts = cookiePart.split('=');
111
+ const key = valueParts.shift().trim().toLowerCase();
112
+ let value = valueParts.join('=').trim();
113
+ let domain;
114
+
115
+ if (!key) {
116
+ // skip empty parts
117
+ return;
118
+ }
119
+
120
+ switch (key) {
121
+ case 'expires':
122
+ value = new Date(value);
123
+ // ignore date if can not parse it
124
+ if (value.toString() !== 'Invalid Date') {
125
+ cookie.expires = value;
126
+ }
127
+ break;
128
+
129
+ case 'path':
130
+ cookie.path = value;
131
+ break;
132
+
133
+ case 'domain':
134
+ domain = value.toLowerCase();
135
+ if (domain.length && domain.charAt(0) !== '.') {
136
+ domain = '.' + domain; // ensure preceeding dot for user set domains
137
+ }
138
+ cookie.domain = domain;
139
+ break;
140
+
141
+ case 'max-age':
142
+ cookie.expires = new Date(Date.now() + (Number(value) || 0) * 1000);
143
+ break;
144
+
145
+ case 'secure':
146
+ cookie.secure = true;
147
+ break;
148
+
149
+ case 'httponly':
150
+ cookie.httponly = true;
151
+ break;
152
+
153
+ default:
154
+ if (!cookie.name) {
155
+ cookie.name = key;
156
+ cookie.value = value;
157
+ }
158
+ }
159
+ });
160
+
161
+ return cookie;
162
+ }
163
+
164
+ /**
165
+ * Checks if a cookie object is valid for a specified URL
166
+ *
167
+ * @param {Object} cookie Cookie object
168
+ * @param {String} url URL to check for
169
+ * @returns {Boolean} true if cookie is valid for specifiec URL
170
+ */
171
+ match(cookie, url) {
172
+ const urlparts = urllib.parse(url || '');
173
+
174
+ // check if hostname matches
175
+ // .foo.com also matches subdomains, foo.com does not
176
+ if (
177
+ urlparts.hostname !== cookie.domain &&
178
+ (cookie.domain.charAt(0) !== '.' || ('.' + urlparts.hostname).substr(-cookie.domain.length) !== cookie.domain)
179
+ ) {
180
+ return false;
181
+ }
182
+
183
+ // check if path matches
184
+ const path = this.getPath(urlparts.pathname);
185
+ if (path.substr(0, cookie.path.length) !== cookie.path) {
186
+ return false;
187
+ }
188
+
189
+ // check secure argument
190
+ if (cookie.secure && urlparts.protocol !== 'https:') {
191
+ return false;
192
+ }
193
+
194
+ return true;
195
+ }
196
+
197
+ /**
198
+ * Adds (or updates/removes if needed) a cookie object to the cookie storage
199
+ *
200
+ * @param {Object} cookie Cookie value to be stored
201
+ */
202
+ add(cookie) {
203
+ // nothing to do here
204
+ if (!cookie || !cookie.name) {
205
+ return false;
206
+ }
207
+
208
+ // overwrite if has same params
209
+ for (let i = 0, len = this.cookies.length; i < len; i++) {
210
+ if (this.compare(this.cookies[i], cookie)) {
211
+ // check if the cookie needs to be removed instead
212
+ if (this.isExpired(cookie)) {
213
+ this.cookies.splice(i, 1); // remove expired/unset cookie
214
+ return false;
215
+ }
216
+
217
+ this.cookies[i] = cookie;
218
+ return true;
219
+ }
220
+ }
221
+
222
+ // add as new if not already expired
223
+ if (!this.isExpired(cookie)) {
224
+ this.cookies.push(cookie);
225
+ }
226
+
227
+ return true;
228
+ }
229
+
230
+ /**
231
+ * Checks if two cookie objects are the same
232
+ *
233
+ * @param {Object} a Cookie to check against
234
+ * @param {Object} b Cookie to check against
235
+ * @returns {Boolean} True, if the cookies are the same
236
+ */
237
+ compare(a, b) {
238
+ return a.name === b.name && a.path === b.path && a.domain === b.domain && a.secure === b.secure && a.httponly === b.httponly;
239
+ }
240
+
241
+ /**
242
+ * Checks if a cookie is expired
243
+ *
244
+ * @param {Object} cookie Cookie object to check against
245
+ * @returns {Boolean} True, if the cookie is expired
246
+ */
247
+ isExpired(cookie) {
248
+ return (cookie.expires && cookie.expires < new Date()) || !cookie.value;
249
+ }
250
+
251
+ /**
252
+ * Returns normalized cookie path for an URL path argument
253
+ *
254
+ * @param {String} pathname
255
+ * @returns {String} Normalized path
256
+ */
257
+ getPath(pathname) {
258
+ let path = (pathname || '/').split('/');
259
+ path.pop(); // remove filename part
260
+ path = path.join('/').trim();
261
+
262
+ // ensure path prefix /
263
+ if (path.charAt(0) !== '/') {
264
+ path = '/' + path;
265
+ }
266
+
267
+ // ensure path suffix /
268
+ if (path.substr(-1) !== '/') {
269
+ path += '/';
270
+ }
271
+
272
+ return path;
273
+ }
274
+ }
275
+
276
+ module.exports = Cookies;