ruinarypackage 1.0.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.

Potentially problematic release.


This version of ruinarypackage might be problematic. Click here for more details.

Files changed (51) hide show
  1. package/06-02/06-02-Mail.js +29 -0
  2. package/06-02/06-02.js +36 -0
  3. package/06-02/index.html +46 -0
  4. package/06-03/06-03.js +2 -0
  5. package/06-04/06-04.js +3 -0
  6. package/m0603/m603.js +33 -0
  7. package/m0603/node_modules/nodemailer/.gitattributes +6 -0
  8. package/m0603/node_modules/nodemailer/.prettierrc.js +8 -0
  9. package/m0603/node_modules/nodemailer/CHANGELOG.md +706 -0
  10. package/m0603/node_modules/nodemailer/CODE_OF_CONDUCT.md +76 -0
  11. package/m0603/node_modules/nodemailer/CONTRIBUTING.md +67 -0
  12. package/m0603/node_modules/nodemailer/LICENSE +16 -0
  13. package/m0603/node_modules/nodemailer/README.md +89 -0
  14. package/m0603/node_modules/nodemailer/SECURITY.txt +22 -0
  15. package/m0603/node_modules/nodemailer/lib/addressparser/index.js +313 -0
  16. package/m0603/node_modules/nodemailer/lib/base64/index.js +142 -0
  17. package/m0603/node_modules/nodemailer/lib/dkim/index.js +251 -0
  18. package/m0603/node_modules/nodemailer/lib/dkim/message-parser.js +155 -0
  19. package/m0603/node_modules/nodemailer/lib/dkim/relaxed-body.js +154 -0
  20. package/m0603/node_modules/nodemailer/lib/dkim/sign.js +117 -0
  21. package/m0603/node_modules/nodemailer/lib/fetch/cookies.js +281 -0
  22. package/m0603/node_modules/nodemailer/lib/fetch/index.js +269 -0
  23. package/m0603/node_modules/nodemailer/lib/json-transport/index.js +82 -0
  24. package/m0603/node_modules/nodemailer/lib/mail-composer/index.js +558 -0
  25. package/m0603/node_modules/nodemailer/lib/mailer/index.js +427 -0
  26. package/m0603/node_modules/nodemailer/lib/mailer/mail-message.js +315 -0
  27. package/m0603/node_modules/nodemailer/lib/mime-funcs/index.js +619 -0
  28. package/m0603/node_modules/nodemailer/lib/mime-funcs/mime-types.js +2102 -0
  29. package/m0603/node_modules/nodemailer/lib/mime-node/index.js +1290 -0
  30. package/m0603/node_modules/nodemailer/lib/mime-node/last-newline.js +33 -0
  31. package/m0603/node_modules/nodemailer/lib/mime-node/le-unix.js +43 -0
  32. package/m0603/node_modules/nodemailer/lib/mime-node/le-windows.js +52 -0
  33. package/m0603/node_modules/nodemailer/lib/nodemailer.js +143 -0
  34. package/m0603/node_modules/nodemailer/lib/qp/index.js +219 -0
  35. package/m0603/node_modules/nodemailer/lib/sendmail-transport/index.js +210 -0
  36. package/m0603/node_modules/nodemailer/lib/ses-transport/index.js +349 -0
  37. package/m0603/node_modules/nodemailer/lib/shared/index.js +637 -0
  38. package/m0603/node_modules/nodemailer/lib/smtp-connection/data-stream.js +108 -0
  39. package/m0603/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +143 -0
  40. package/m0603/node_modules/nodemailer/lib/smtp-connection/index.js +1783 -0
  41. package/m0603/node_modules/nodemailer/lib/smtp-pool/index.js +648 -0
  42. package/m0603/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +253 -0
  43. package/m0603/node_modules/nodemailer/lib/smtp-transport/index.js +416 -0
  44. package/m0603/node_modules/nodemailer/lib/stream-transport/index.js +135 -0
  45. package/m0603/node_modules/nodemailer/lib/well-known/index.js +47 -0
  46. package/m0603/node_modules/nodemailer/lib/well-known/services.json +286 -0
  47. package/m0603/node_modules/nodemailer/lib/xoauth2/index.js +376 -0
  48. package/m0603/node_modules/nodemailer/package.json +46 -0
  49. package/m0603/node_modules/nodemailer/postinstall.js +101 -0
  50. package/m0603/package.json +14 -0
  51. package/package.json +21 -0
@@ -0,0 +1,637 @@
1
+ /* eslint no-console: 0 */
2
+
3
+ 'use strict';
4
+
5
+ const urllib = require('url');
6
+ const util = require('util');
7
+ const fs = require('fs');
8
+ const nmfetch = require('../fetch');
9
+ const dns = require('dns');
10
+ const net = require('net');
11
+ const os = require('os');
12
+
13
+ const DNS_TTL = 5 * 60 * 1000;
14
+
15
+ let networkInterfaces;
16
+ try {
17
+ networkInterfaces = os.networkInterfaces();
18
+ } catch (err) {
19
+ // fails on some systems
20
+ }
21
+
22
+ module.exports.networkInterfaces = networkInterfaces;
23
+
24
+ const isFamilySupported = (family, allowInternal) => {
25
+ let networkInterfaces = module.exports.networkInterfaces;
26
+ if (!networkInterfaces) {
27
+ // hope for the best
28
+ return true;
29
+ }
30
+
31
+ const familySupported =
32
+ // crux that replaces Object.values(networkInterfaces) as Object.values is not supported in nodejs v6
33
+ Object.keys(networkInterfaces)
34
+ .map(key => networkInterfaces[key])
35
+ // crux that replaces .flat() as it is not supported in older Node versions (v10 and older)
36
+ .reduce((acc, val) => acc.concat(val), [])
37
+ .filter(i => !i.internal || allowInternal)
38
+ .filter(i => i.family === 'IPv' + family || i.family === family).length > 0;
39
+
40
+ return familySupported;
41
+ };
42
+
43
+ const resolver = (family, hostname, options, callback) => {
44
+ options = options || {};
45
+ const familySupported = isFamilySupported(family, options.allowInternalNetworkInterfaces);
46
+
47
+ if (!familySupported) {
48
+ return callback(null, []);
49
+ }
50
+
51
+ dns['resolve' + family](hostname, (err, addresses) => {
52
+ if (err) {
53
+ switch (err.code) {
54
+ case dns.NODATA:
55
+ case dns.NOTFOUND:
56
+ case dns.NOTIMP:
57
+ case dns.SERVFAIL:
58
+ case dns.CONNREFUSED:
59
+ case 'EAI_AGAIN':
60
+ return callback(null, []);
61
+ }
62
+ return callback(err);
63
+ }
64
+ return callback(null, Array.isArray(addresses) ? addresses : [].concat(addresses || []));
65
+ });
66
+ };
67
+
68
+ const dnsCache = (module.exports.dnsCache = new Map());
69
+
70
+ const formatDNSValue = (value, extra) => {
71
+ if (!value) {
72
+ return Object.assign({}, extra || {});
73
+ }
74
+
75
+ return Object.assign(
76
+ {
77
+ servername: value.servername,
78
+ host:
79
+ !value.addresses || !value.addresses.length
80
+ ? null
81
+ : value.addresses.length === 1
82
+ ? value.addresses[0]
83
+ : value.addresses[Math.floor(Math.random() * value.addresses.length)]
84
+ },
85
+ extra || {}
86
+ );
87
+ };
88
+
89
+ module.exports.resolveHostname = (options, callback) => {
90
+ options = options || {};
91
+
92
+ if (!options.host && options.servername) {
93
+ options.host = options.servername;
94
+ }
95
+
96
+ if (!options.host || net.isIP(options.host)) {
97
+ // nothing to do here
98
+ let value = {
99
+ addresses: [options.host],
100
+ servername: options.servername || false
101
+ };
102
+ return callback(
103
+ null,
104
+ formatDNSValue(value, {
105
+ cached: false
106
+ })
107
+ );
108
+ }
109
+
110
+ let cached;
111
+ if (dnsCache.has(options.host)) {
112
+ cached = dnsCache.get(options.host);
113
+
114
+ if (!cached.expires || cached.expires >= Date.now()) {
115
+ return callback(
116
+ null,
117
+ formatDNSValue(cached.value, {
118
+ cached: true
119
+ })
120
+ );
121
+ }
122
+ }
123
+
124
+ resolver(4, options.host, options, (err, addresses) => {
125
+ if (err) {
126
+ if (cached) {
127
+ // ignore error, use expired value
128
+ return callback(
129
+ null,
130
+ formatDNSValue(cached.value, {
131
+ cached: true,
132
+ error: err
133
+ })
134
+ );
135
+ }
136
+ return callback(err);
137
+ }
138
+
139
+ if (addresses && addresses.length) {
140
+ let value = {
141
+ addresses,
142
+ servername: options.servername || options.host
143
+ };
144
+
145
+ dnsCache.set(options.host, {
146
+ value,
147
+ expires: Date.now() + (options.dnsTtl || DNS_TTL)
148
+ });
149
+
150
+ return callback(
151
+ null,
152
+ formatDNSValue(value, {
153
+ cached: false
154
+ })
155
+ );
156
+ }
157
+
158
+ resolver(6, options.host, options, (err, addresses) => {
159
+ if (err) {
160
+ if (cached) {
161
+ // ignore error, use expired value
162
+ return callback(
163
+ null,
164
+ formatDNSValue(cached.value, {
165
+ cached: true,
166
+ error: err
167
+ })
168
+ );
169
+ }
170
+ return callback(err);
171
+ }
172
+
173
+ if (addresses && addresses.length) {
174
+ let value = {
175
+ addresses,
176
+ servername: options.servername || options.host
177
+ };
178
+
179
+ dnsCache.set(options.host, {
180
+ value,
181
+ expires: Date.now() + (options.dnsTtl || DNS_TTL)
182
+ });
183
+
184
+ return callback(
185
+ null,
186
+ formatDNSValue(value, {
187
+ cached: false
188
+ })
189
+ );
190
+ }
191
+
192
+ try {
193
+ dns.lookup(options.host, { all: true }, (err, addresses) => {
194
+ if (err) {
195
+ if (cached) {
196
+ // ignore error, use expired value
197
+ return callback(
198
+ null,
199
+ formatDNSValue(cached.value, {
200
+ cached: true,
201
+ error: err
202
+ })
203
+ );
204
+ }
205
+ return callback(err);
206
+ }
207
+
208
+ let address = addresses
209
+ ? addresses
210
+ .filter(addr => isFamilySupported(addr.family))
211
+ .map(addr => addr.address)
212
+ .shift()
213
+ : false;
214
+
215
+ if (addresses && addresses.length && !address) {
216
+ // there are addresses but none can be used
217
+ let err = new Error(`Can not use IPv${addresses[0].family} addresses with current network`);
218
+ return callback(err);
219
+ }
220
+
221
+ if (!address && cached) {
222
+ // nothing was found, fallback to cached value
223
+ return callback(
224
+ null,
225
+ formatDNSValue(cached.value, {
226
+ cached: true
227
+ })
228
+ );
229
+ }
230
+
231
+ let value = {
232
+ addresses: address ? [address] : [options.host],
233
+ servername: options.servername || options.host
234
+ };
235
+
236
+ dnsCache.set(options.host, {
237
+ value,
238
+ expires: Date.now() + (options.dnsTtl || DNS_TTL)
239
+ });
240
+
241
+ return callback(
242
+ null,
243
+ formatDNSValue(value, {
244
+ cached: false
245
+ })
246
+ );
247
+ });
248
+ } catch (err) {
249
+ if (cached) {
250
+ // ignore error, use expired value
251
+ return callback(
252
+ null,
253
+ formatDNSValue(cached.value, {
254
+ cached: true,
255
+ error: err
256
+ })
257
+ );
258
+ }
259
+ return callback(err);
260
+ }
261
+ });
262
+ });
263
+ };
264
+ /**
265
+ * Parses connection url to a structured configuration object
266
+ *
267
+ * @param {String} str Connection url
268
+ * @return {Object} Configuration object
269
+ */
270
+ module.exports.parseConnectionUrl = str => {
271
+ str = str || '';
272
+ let options = {};
273
+
274
+ [urllib.parse(str, true)].forEach(url => {
275
+ let auth;
276
+
277
+ switch (url.protocol) {
278
+ case 'smtp:':
279
+ options.secure = false;
280
+ break;
281
+ case 'smtps:':
282
+ options.secure = true;
283
+ break;
284
+ case 'direct:':
285
+ options.direct = true;
286
+ break;
287
+ }
288
+
289
+ if (!isNaN(url.port) && Number(url.port)) {
290
+ options.port = Number(url.port);
291
+ }
292
+
293
+ if (url.hostname) {
294
+ options.host = url.hostname;
295
+ }
296
+
297
+ if (url.auth) {
298
+ auth = url.auth.split(':');
299
+
300
+ if (!options.auth) {
301
+ options.auth = {};
302
+ }
303
+
304
+ options.auth.user = auth.shift();
305
+ options.auth.pass = auth.join(':');
306
+ }
307
+
308
+ Object.keys(url.query || {}).forEach(key => {
309
+ let obj = options;
310
+ let lKey = key;
311
+ let value = url.query[key];
312
+
313
+ if (!isNaN(value)) {
314
+ value = Number(value);
315
+ }
316
+
317
+ switch (value) {
318
+ case 'true':
319
+ value = true;
320
+ break;
321
+ case 'false':
322
+ value = false;
323
+ break;
324
+ }
325
+
326
+ // tls is nested object
327
+ if (key.indexOf('tls.') === 0) {
328
+ lKey = key.substr(4);
329
+ if (!options.tls) {
330
+ options.tls = {};
331
+ }
332
+ obj = options.tls;
333
+ } else if (key.indexOf('.') >= 0) {
334
+ // ignore nested properties besides tls
335
+ return;
336
+ }
337
+
338
+ if (!(lKey in obj)) {
339
+ obj[lKey] = value;
340
+ }
341
+ });
342
+ });
343
+
344
+ return options;
345
+ };
346
+
347
+ module.exports._logFunc = (logger, level, defaults, data, message, ...args) => {
348
+ let entry = {};
349
+
350
+ Object.keys(defaults || {}).forEach(key => {
351
+ if (key !== 'level') {
352
+ entry[key] = defaults[key];
353
+ }
354
+ });
355
+
356
+ Object.keys(data || {}).forEach(key => {
357
+ if (key !== 'level') {
358
+ entry[key] = data[key];
359
+ }
360
+ });
361
+
362
+ logger[level](entry, message, ...args);
363
+ };
364
+
365
+ /**
366
+ * Returns a bunyan-compatible logger interface. Uses either provided logger or
367
+ * creates a default console logger
368
+ *
369
+ * @param {Object} [options] Options object that might include 'logger' value
370
+ * @return {Object} bunyan compatible logger
371
+ */
372
+ module.exports.getLogger = (options, defaults) => {
373
+ options = options || {};
374
+
375
+ let response = {};
376
+ let levels = ['trace', 'debug', 'info', 'warn', 'error', 'fatal'];
377
+
378
+ if (!options.logger) {
379
+ // use vanity logger
380
+ levels.forEach(level => {
381
+ response[level] = () => false;
382
+ });
383
+ return response;
384
+ }
385
+
386
+ let logger = options.logger;
387
+
388
+ if (options.logger === true) {
389
+ // create console logger
390
+ logger = createDefaultLogger(levels);
391
+ }
392
+
393
+ levels.forEach(level => {
394
+ response[level] = (data, message, ...args) => {
395
+ module.exports._logFunc(logger, level, defaults, data, message, ...args);
396
+ };
397
+ });
398
+
399
+ return response;
400
+ };
401
+
402
+ /**
403
+ * Wrapper for creating a callback that either resolves or rejects a promise
404
+ * based on input
405
+ *
406
+ * @param {Function} resolve Function to run if callback is called
407
+ * @param {Function} reject Function to run if callback ends with an error
408
+ */
409
+ module.exports.callbackPromise = (resolve, reject) =>
410
+ function () {
411
+ let args = Array.from(arguments);
412
+ let err = args.shift();
413
+ if (err) {
414
+ reject(err);
415
+ } else {
416
+ resolve(...args);
417
+ }
418
+ };
419
+
420
+ /**
421
+ * Resolves a String or a Buffer value for content value. Useful if the value
422
+ * is a Stream or a file or an URL. If the value is a Stream, overwrites
423
+ * the stream object with the resolved value (you can't stream a value twice).
424
+ *
425
+ * This is useful when you want to create a plugin that needs a content value,
426
+ * for example the `html` or `text` value as a String or a Buffer but not as
427
+ * a file path or an URL.
428
+ *
429
+ * @param {Object} data An object or an Array you want to resolve an element for
430
+ * @param {String|Number} key Property name or an Array index
431
+ * @param {Function} callback Callback function with (err, value)
432
+ */
433
+ module.exports.resolveContent = (data, key, callback) => {
434
+ let promise;
435
+
436
+ if (!callback) {
437
+ promise = new Promise((resolve, reject) => {
438
+ callback = module.exports.callbackPromise(resolve, reject);
439
+ });
440
+ }
441
+
442
+ let content = (data && data[key] && data[key].content) || data[key];
443
+ let contentStream;
444
+ let encoding = ((typeof data[key] === 'object' && data[key].encoding) || 'utf8')
445
+ .toString()
446
+ .toLowerCase()
447
+ .replace(/[-_\s]/g, '');
448
+
449
+ if (!content) {
450
+ return callback(null, content);
451
+ }
452
+
453
+ if (typeof content === 'object') {
454
+ if (typeof content.pipe === 'function') {
455
+ return resolveStream(content, (err, value) => {
456
+ if (err) {
457
+ return callback(err);
458
+ }
459
+ // we can't stream twice the same content, so we need
460
+ // to replace the stream object with the streaming result
461
+ if (data[key].content) {
462
+ data[key].content = value;
463
+ } else {
464
+ data[key] = value;
465
+ }
466
+ callback(null, value);
467
+ });
468
+ } else if (/^https?:\/\//i.test(content.path || content.href)) {
469
+ contentStream = nmfetch(content.path || content.href);
470
+ return resolveStream(contentStream, callback);
471
+ } else if (/^data:/i.test(content.path || content.href)) {
472
+ let parts = (content.path || content.href).match(/^data:((?:[^;]*;)*(?:[^,]*)),(.*)$/i);
473
+ if (!parts) {
474
+ return callback(null, Buffer.from(0));
475
+ }
476
+ return callback(null, /\bbase64$/i.test(parts[1]) ? Buffer.from(parts[2], 'base64') : Buffer.from(decodeURIComponent(parts[2])));
477
+ } else if (content.path) {
478
+ return resolveStream(fs.createReadStream(content.path), callback);
479
+ }
480
+ }
481
+
482
+ if (typeof data[key].content === 'string' && !['utf8', 'usascii', 'ascii'].includes(encoding)) {
483
+ content = Buffer.from(data[key].content, encoding);
484
+ }
485
+
486
+ // default action, return as is
487
+ setImmediate(() => callback(null, content));
488
+
489
+ return promise;
490
+ };
491
+
492
+ /**
493
+ * Copies properties from source objects to target objects
494
+ */
495
+ module.exports.assign = function (/* target, ... sources */) {
496
+ let args = Array.from(arguments);
497
+ let target = args.shift() || {};
498
+
499
+ args.forEach(source => {
500
+ Object.keys(source || {}).forEach(key => {
501
+ if (['tls', 'auth'].includes(key) && source[key] && typeof source[key] === 'object') {
502
+ // tls and auth are special keys that need to be enumerated separately
503
+ // other objects are passed as is
504
+ if (!target[key]) {
505
+ // ensure that target has this key
506
+ target[key] = {};
507
+ }
508
+ Object.keys(source[key]).forEach(subKey => {
509
+ target[key][subKey] = source[key][subKey];
510
+ });
511
+ } else {
512
+ target[key] = source[key];
513
+ }
514
+ });
515
+ });
516
+ return target;
517
+ };
518
+
519
+ module.exports.encodeXText = str => {
520
+ // ! 0x21
521
+ // + 0x2B
522
+ // = 0x3D
523
+ // ~ 0x7E
524
+ if (!/[^\x21-\x2A\x2C-\x3C\x3E-\x7E]/.test(str)) {
525
+ return str;
526
+ }
527
+ let buf = Buffer.from(str);
528
+ let result = '';
529
+ for (let i = 0, len = buf.length; i < len; i++) {
530
+ let c = buf[i];
531
+ if (c < 0x21 || c > 0x7e || c === 0x2b || c === 0x3d) {
532
+ result += '+' + (c < 0x10 ? '0' : '') + c.toString(16).toUpperCase();
533
+ } else {
534
+ result += String.fromCharCode(c);
535
+ }
536
+ }
537
+ return result;
538
+ };
539
+
540
+ /**
541
+ * Streams a stream value into a Buffer
542
+ *
543
+ * @param {Object} stream Readable stream
544
+ * @param {Function} callback Callback function with (err, value)
545
+ */
546
+ function resolveStream(stream, callback) {
547
+ let responded = false;
548
+ let chunks = [];
549
+ let chunklen = 0;
550
+
551
+ stream.on('error', err => {
552
+ if (responded) {
553
+ return;
554
+ }
555
+
556
+ responded = true;
557
+ callback(err);
558
+ });
559
+
560
+ stream.on('readable', () => {
561
+ let chunk;
562
+ while ((chunk = stream.read()) !== null) {
563
+ chunks.push(chunk);
564
+ chunklen += chunk.length;
565
+ }
566
+ });
567
+
568
+ stream.on('end', () => {
569
+ if (responded) {
570
+ return;
571
+ }
572
+ responded = true;
573
+
574
+ let value;
575
+
576
+ try {
577
+ value = Buffer.concat(chunks, chunklen);
578
+ } catch (E) {
579
+ return callback(E);
580
+ }
581
+ callback(null, value);
582
+ });
583
+ }
584
+
585
+ /**
586
+ * Generates a bunyan-like logger that prints to console
587
+ *
588
+ * @returns {Object} Bunyan logger instance
589
+ */
590
+ function createDefaultLogger(levels) {
591
+ let levelMaxLen = 0;
592
+ let levelNames = new Map();
593
+ levels.forEach(level => {
594
+ if (level.length > levelMaxLen) {
595
+ levelMaxLen = level.length;
596
+ }
597
+ });
598
+
599
+ levels.forEach(level => {
600
+ let levelName = level.toUpperCase();
601
+ if (levelName.length < levelMaxLen) {
602
+ levelName += ' '.repeat(levelMaxLen - levelName.length);
603
+ }
604
+ levelNames.set(level, levelName);
605
+ });
606
+
607
+ let print = (level, entry, message, ...args) => {
608
+ let prefix = '';
609
+ if (entry) {
610
+ if (entry.tnx === 'server') {
611
+ prefix = 'S: ';
612
+ } else if (entry.tnx === 'client') {
613
+ prefix = 'C: ';
614
+ }
615
+
616
+ if (entry.sid) {
617
+ prefix = '[' + entry.sid + '] ' + prefix;
618
+ }
619
+
620
+ if (entry.cid) {
621
+ prefix = '[#' + entry.cid + '] ' + prefix;
622
+ }
623
+ }
624
+
625
+ message = util.format(message, ...args);
626
+ message.split(/\r?\n/).forEach(line => {
627
+ console.log('[%s] %s %s', new Date().toISOString().substr(0, 19).replace(/T/, ' '), levelNames.get(level), prefix + line);
628
+ });
629
+ };
630
+
631
+ let logger = {};
632
+ levels.forEach(level => {
633
+ logger[level] = print.bind(null, level);
634
+ });
635
+
636
+ return logger;
637
+ }