polikolog 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.idea/5lab.iml +12 -0
- package/.idea/inspectionProfiles/Project_Default.xml +10 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/06-02.js +48 -0
- package/06-03.js +22 -0
- package/06-04.js +22 -0
- package/index.html +41 -0
- package/m0603.js +28 -0
- package/mypackage/m0603.js +28 -0
- package/mypackage/node_modules/.package-lock.json +24 -0
- package/mypackage/node_modules/nodemailer/.gitattributes +6 -0
- package/mypackage/node_modules/nodemailer/.prettierrc.js +8 -0
- package/mypackage/node_modules/nodemailer/CHANGELOG.md +725 -0
- package/mypackage/node_modules/nodemailer/CODE_OF_CONDUCT.md +76 -0
- package/mypackage/node_modules/nodemailer/CONTRIBUTING.md +67 -0
- package/mypackage/node_modules/nodemailer/LICENSE +16 -0
- package/mypackage/node_modules/nodemailer/README.md +97 -0
- package/mypackage/node_modules/nodemailer/SECURITY.txt +22 -0
- package/mypackage/node_modules/nodemailer/lib/addressparser/index.js +313 -0
- package/mypackage/node_modules/nodemailer/lib/base64/index.js +142 -0
- package/mypackage/node_modules/nodemailer/lib/dkim/index.js +251 -0
- package/mypackage/node_modules/nodemailer/lib/dkim/message-parser.js +155 -0
- package/mypackage/node_modules/nodemailer/lib/dkim/relaxed-body.js +154 -0
- package/mypackage/node_modules/nodemailer/lib/dkim/sign.js +117 -0
- package/mypackage/node_modules/nodemailer/lib/fetch/cookies.js +281 -0
- package/mypackage/node_modules/nodemailer/lib/fetch/index.js +274 -0
- package/mypackage/node_modules/nodemailer/lib/json-transport/index.js +82 -0
- package/mypackage/node_modules/nodemailer/lib/mail-composer/index.js +558 -0
- package/mypackage/node_modules/nodemailer/lib/mailer/index.js +427 -0
- package/mypackage/node_modules/nodemailer/lib/mailer/mail-message.js +315 -0
- package/mypackage/node_modules/nodemailer/lib/mime-funcs/index.js +625 -0
- package/mypackage/node_modules/nodemailer/lib/mime-funcs/mime-types.js +2102 -0
- package/mypackage/node_modules/nodemailer/lib/mime-node/index.js +1290 -0
- package/mypackage/node_modules/nodemailer/lib/mime-node/last-newline.js +33 -0
- package/mypackage/node_modules/nodemailer/lib/mime-node/le-unix.js +43 -0
- package/mypackage/node_modules/nodemailer/lib/mime-node/le-windows.js +52 -0
- package/mypackage/node_modules/nodemailer/lib/nodemailer.js +143 -0
- package/mypackage/node_modules/nodemailer/lib/qp/index.js +219 -0
- package/mypackage/node_modules/nodemailer/lib/sendmail-transport/index.js +210 -0
- package/mypackage/node_modules/nodemailer/lib/ses-transport/index.js +349 -0
- package/mypackage/node_modules/nodemailer/lib/shared/index.js +638 -0
- package/mypackage/node_modules/nodemailer/lib/smtp-connection/data-stream.js +108 -0
- package/mypackage/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +143 -0
- package/mypackage/node_modules/nodemailer/lib/smtp-connection/index.js +1796 -0
- package/mypackage/node_modules/nodemailer/lib/smtp-pool/index.js +648 -0
- package/mypackage/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +253 -0
- package/mypackage/node_modules/nodemailer/lib/smtp-transport/index.js +416 -0
- package/mypackage/node_modules/nodemailer/lib/stream-transport/index.js +135 -0
- package/mypackage/node_modules/nodemailer/lib/well-known/index.js +47 -0
- package/mypackage/node_modules/nodemailer/lib/well-known/services.json +286 -0
- package/mypackage/node_modules/nodemailer/lib/xoauth2/index.js +376 -0
- package/mypackage/node_modules/nodemailer/package.json +46 -0
- package/mypackage/node_modules/nodemailer/postinstall.js +101 -0
- package/mypackage/package.json +15 -0
- package/package.json +15 -0
@@ -0,0 +1,376 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const Stream = require('stream').Stream;
|
4
|
+
const nmfetch = require('../fetch');
|
5
|
+
const crypto = require('crypto');
|
6
|
+
const shared = require('../shared');
|
7
|
+
|
8
|
+
/**
|
9
|
+
* XOAUTH2 access_token generator for Gmail.
|
10
|
+
* Create client ID for web applications in Google API console to use it.
|
11
|
+
* See Offline Access for receiving the needed refreshToken for an user
|
12
|
+
* https://developers.google.com/accounts/docs/OAuth2WebServer#offline
|
13
|
+
*
|
14
|
+
* Usage for generating access tokens with a custom method using provisionCallback:
|
15
|
+
* provisionCallback(user, renew, callback)
|
16
|
+
* * user is the username to get the token for
|
17
|
+
* * renew is a boolean that if true indicates that existing token failed and needs to be renewed
|
18
|
+
* * callback is the callback to run with (error, accessToken [, expires])
|
19
|
+
* * accessToken is a string
|
20
|
+
* * expires is an optional expire time in milliseconds
|
21
|
+
* If provisionCallback is used, then Nodemailer does not try to attempt generating the token by itself
|
22
|
+
*
|
23
|
+
* @constructor
|
24
|
+
* @param {Object} options Client information for token generation
|
25
|
+
* @param {String} options.user User e-mail address
|
26
|
+
* @param {String} options.clientId Client ID value
|
27
|
+
* @param {String} options.clientSecret Client secret value
|
28
|
+
* @param {String} options.refreshToken Refresh token for an user
|
29
|
+
* @param {String} options.accessUrl Endpoint for token generation, defaults to 'https://accounts.google.com/o/oauth2/token'
|
30
|
+
* @param {String} options.accessToken An existing valid accessToken
|
31
|
+
* @param {String} options.privateKey Private key for JSW
|
32
|
+
* @param {Number} options.expires Optional Access Token expire time in ms
|
33
|
+
* @param {Number} options.timeout Optional TTL for Access Token in seconds
|
34
|
+
* @param {Function} options.provisionCallback Function to run when a new access token is required
|
35
|
+
*/
|
36
|
+
class XOAuth2 extends Stream {
|
37
|
+
constructor(options, logger) {
|
38
|
+
super();
|
39
|
+
|
40
|
+
this.options = options || {};
|
41
|
+
|
42
|
+
if (options && options.serviceClient) {
|
43
|
+
if (!options.privateKey || !options.user) {
|
44
|
+
setImmediate(() => this.emit('error', new Error('Options "privateKey" and "user" are required for service account!')));
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
|
48
|
+
let serviceRequestTimeout = Math.min(Math.max(Number(this.options.serviceRequestTimeout) || 0, 0), 3600);
|
49
|
+
this.options.serviceRequestTimeout = serviceRequestTimeout || 5 * 60;
|
50
|
+
}
|
51
|
+
|
52
|
+
this.logger = shared.getLogger(
|
53
|
+
{
|
54
|
+
logger
|
55
|
+
},
|
56
|
+
{
|
57
|
+
component: this.options.component || 'OAuth2'
|
58
|
+
}
|
59
|
+
);
|
60
|
+
|
61
|
+
this.provisionCallback = typeof this.options.provisionCallback === 'function' ? this.options.provisionCallback : false;
|
62
|
+
|
63
|
+
this.options.accessUrl = this.options.accessUrl || 'https://accounts.google.com/o/oauth2/token';
|
64
|
+
this.options.customHeaders = this.options.customHeaders || {};
|
65
|
+
this.options.customParams = this.options.customParams || {};
|
66
|
+
|
67
|
+
this.accessToken = this.options.accessToken || false;
|
68
|
+
|
69
|
+
if (this.options.expires && Number(this.options.expires)) {
|
70
|
+
this.expires = this.options.expires;
|
71
|
+
} else {
|
72
|
+
let timeout = Math.max(Number(this.options.timeout) || 0, 0);
|
73
|
+
this.expires = (timeout && Date.now() + timeout * 1000) || 0;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
/**
|
78
|
+
* Returns or generates (if previous has expired) a XOAuth2 token
|
79
|
+
*
|
80
|
+
* @param {Boolean} renew If false then use cached access token (if available)
|
81
|
+
* @param {Function} callback Callback function with error object and token string
|
82
|
+
*/
|
83
|
+
getToken(renew, callback) {
|
84
|
+
if (!renew && this.accessToken && (!this.expires || this.expires > Date.now())) {
|
85
|
+
return callback(null, this.accessToken);
|
86
|
+
}
|
87
|
+
|
88
|
+
let generateCallback = (...args) => {
|
89
|
+
if (args[0]) {
|
90
|
+
this.logger.error(
|
91
|
+
{
|
92
|
+
err: args[0],
|
93
|
+
tnx: 'OAUTH2',
|
94
|
+
user: this.options.user,
|
95
|
+
action: 'renew'
|
96
|
+
},
|
97
|
+
'Failed generating new Access Token for %s',
|
98
|
+
this.options.user
|
99
|
+
);
|
100
|
+
} else {
|
101
|
+
this.logger.info(
|
102
|
+
{
|
103
|
+
tnx: 'OAUTH2',
|
104
|
+
user: this.options.user,
|
105
|
+
action: 'renew'
|
106
|
+
},
|
107
|
+
'Generated new Access Token for %s',
|
108
|
+
this.options.user
|
109
|
+
);
|
110
|
+
}
|
111
|
+
callback(...args);
|
112
|
+
};
|
113
|
+
|
114
|
+
if (this.provisionCallback) {
|
115
|
+
this.provisionCallback(this.options.user, !!renew, (err, accessToken, expires) => {
|
116
|
+
if (!err && accessToken) {
|
117
|
+
this.accessToken = accessToken;
|
118
|
+
this.expires = expires || 0;
|
119
|
+
}
|
120
|
+
generateCallback(err, accessToken);
|
121
|
+
});
|
122
|
+
} else {
|
123
|
+
this.generateToken(generateCallback);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
/**
|
128
|
+
* Updates token values
|
129
|
+
*
|
130
|
+
* @param {String} accessToken New access token
|
131
|
+
* @param {Number} timeout Access token lifetime in seconds
|
132
|
+
*
|
133
|
+
* Emits 'token': { user: User email-address, accessToken: the new accessToken, timeout: TTL in seconds}
|
134
|
+
*/
|
135
|
+
updateToken(accessToken, timeout) {
|
136
|
+
this.accessToken = accessToken;
|
137
|
+
timeout = Math.max(Number(timeout) || 0, 0);
|
138
|
+
this.expires = (timeout && Date.now() + timeout * 1000) || 0;
|
139
|
+
|
140
|
+
this.emit('token', {
|
141
|
+
user: this.options.user,
|
142
|
+
accessToken: accessToken || '',
|
143
|
+
expires: this.expires
|
144
|
+
});
|
145
|
+
}
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Generates a new XOAuth2 token with the credentials provided at initialization
|
149
|
+
*
|
150
|
+
* @param {Function} callback Callback function with error object and token string
|
151
|
+
*/
|
152
|
+
generateToken(callback) {
|
153
|
+
let urlOptions;
|
154
|
+
let loggedUrlOptions;
|
155
|
+
if (this.options.serviceClient) {
|
156
|
+
// service account - https://developers.google.com/identity/protocols/OAuth2ServiceAccount
|
157
|
+
let iat = Math.floor(Date.now() / 1000); // unix time
|
158
|
+
let tokenData = {
|
159
|
+
iss: this.options.serviceClient,
|
160
|
+
scope: this.options.scope || 'https://mail.google.com/',
|
161
|
+
sub: this.options.user,
|
162
|
+
aud: this.options.accessUrl,
|
163
|
+
iat,
|
164
|
+
exp: iat + this.options.serviceRequestTimeout
|
165
|
+
};
|
166
|
+
let token;
|
167
|
+
try {
|
168
|
+
token = this.jwtSignRS256(tokenData);
|
169
|
+
} catch (err) {
|
170
|
+
return callback(new Error('Can\x27t generate token. Check your auth options'));
|
171
|
+
}
|
172
|
+
|
173
|
+
urlOptions = {
|
174
|
+
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
|
175
|
+
assertion: token
|
176
|
+
};
|
177
|
+
|
178
|
+
loggedUrlOptions = {
|
179
|
+
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
|
180
|
+
assertion: tokenData
|
181
|
+
};
|
182
|
+
} else {
|
183
|
+
if (!this.options.refreshToken) {
|
184
|
+
return callback(new Error('Can\x27t create new access token for user'));
|
185
|
+
}
|
186
|
+
|
187
|
+
// web app - https://developers.google.com/identity/protocols/OAuth2WebServer
|
188
|
+
urlOptions = {
|
189
|
+
client_id: this.options.clientId || '',
|
190
|
+
client_secret: this.options.clientSecret || '',
|
191
|
+
refresh_token: this.options.refreshToken,
|
192
|
+
grant_type: 'refresh_token'
|
193
|
+
};
|
194
|
+
|
195
|
+
loggedUrlOptions = {
|
196
|
+
client_id: this.options.clientId || '',
|
197
|
+
client_secret: (this.options.clientSecret || '').substr(0, 6) + '...',
|
198
|
+
refresh_token: (this.options.refreshToken || '').substr(0, 6) + '...',
|
199
|
+
grant_type: 'refresh_token'
|
200
|
+
};
|
201
|
+
}
|
202
|
+
|
203
|
+
Object.keys(this.options.customParams).forEach(key => {
|
204
|
+
urlOptions[key] = this.options.customParams[key];
|
205
|
+
loggedUrlOptions[key] = this.options.customParams[key];
|
206
|
+
});
|
207
|
+
|
208
|
+
this.logger.debug(
|
209
|
+
{
|
210
|
+
tnx: 'OAUTH2',
|
211
|
+
user: this.options.user,
|
212
|
+
action: 'generate'
|
213
|
+
},
|
214
|
+
'Requesting token using: %s',
|
215
|
+
JSON.stringify(loggedUrlOptions)
|
216
|
+
);
|
217
|
+
|
218
|
+
this.postRequest(this.options.accessUrl, urlOptions, this.options, (error, body) => {
|
219
|
+
let data;
|
220
|
+
|
221
|
+
if (error) {
|
222
|
+
return callback(error);
|
223
|
+
}
|
224
|
+
|
225
|
+
try {
|
226
|
+
data = JSON.parse(body.toString());
|
227
|
+
} catch (E) {
|
228
|
+
return callback(E);
|
229
|
+
}
|
230
|
+
|
231
|
+
if (!data || typeof data !== 'object') {
|
232
|
+
this.logger.debug(
|
233
|
+
{
|
234
|
+
tnx: 'OAUTH2',
|
235
|
+
user: this.options.user,
|
236
|
+
action: 'post'
|
237
|
+
},
|
238
|
+
'Response: %s',
|
239
|
+
(body || '').toString()
|
240
|
+
);
|
241
|
+
return callback(new Error('Invalid authentication response'));
|
242
|
+
}
|
243
|
+
|
244
|
+
let logData = {};
|
245
|
+
Object.keys(data).forEach(key => {
|
246
|
+
if (key !== 'access_token') {
|
247
|
+
logData[key] = data[key];
|
248
|
+
} else {
|
249
|
+
logData[key] = (data[key] || '').toString().substr(0, 6) + '...';
|
250
|
+
}
|
251
|
+
});
|
252
|
+
|
253
|
+
this.logger.debug(
|
254
|
+
{
|
255
|
+
tnx: 'OAUTH2',
|
256
|
+
user: this.options.user,
|
257
|
+
action: 'post'
|
258
|
+
},
|
259
|
+
'Response: %s',
|
260
|
+
JSON.stringify(logData)
|
261
|
+
);
|
262
|
+
|
263
|
+
if (data.error) {
|
264
|
+
// Error Response : https://tools.ietf.org/html/rfc6749#section-5.2
|
265
|
+
let errorMessage = data.error;
|
266
|
+
if (data.error_description) {
|
267
|
+
errorMessage += ': ' + data.error_description;
|
268
|
+
}
|
269
|
+
if (data.error_uri) {
|
270
|
+
errorMessage += ' (' + data.error_uri + ')';
|
271
|
+
}
|
272
|
+
return callback(new Error(errorMessage));
|
273
|
+
}
|
274
|
+
|
275
|
+
if (data.access_token) {
|
276
|
+
this.updateToken(data.access_token, data.expires_in);
|
277
|
+
return callback(null, this.accessToken);
|
278
|
+
}
|
279
|
+
|
280
|
+
return callback(new Error('No access token'));
|
281
|
+
});
|
282
|
+
}
|
283
|
+
|
284
|
+
/**
|
285
|
+
* Converts an access_token and user id into a base64 encoded XOAuth2 token
|
286
|
+
*
|
287
|
+
* @param {String} [accessToken] Access token string
|
288
|
+
* @return {String} Base64 encoded token for IMAP or SMTP login
|
289
|
+
*/
|
290
|
+
buildXOAuth2Token(accessToken) {
|
291
|
+
let authData = ['user=' + (this.options.user || ''), 'auth=Bearer ' + (accessToken || this.accessToken), '', ''];
|
292
|
+
return Buffer.from(authData.join('\x01'), 'utf-8').toString('base64');
|
293
|
+
}
|
294
|
+
|
295
|
+
/**
|
296
|
+
* Custom POST request handler.
|
297
|
+
* This is only needed to keep paths short in Windows – usually this module
|
298
|
+
* is a dependency of a dependency and if it tries to require something
|
299
|
+
* like the request module the paths get way too long to handle for Windows.
|
300
|
+
* As we do only a simple POST request we do not actually require complicated
|
301
|
+
* logic support (no redirects, no nothing) anyway.
|
302
|
+
*
|
303
|
+
* @param {String} url Url to POST to
|
304
|
+
* @param {String|Buffer} payload Payload to POST
|
305
|
+
* @param {Function} callback Callback function with (err, buff)
|
306
|
+
*/
|
307
|
+
postRequest(url, payload, params, callback) {
|
308
|
+
let returned = false;
|
309
|
+
|
310
|
+
let chunks = [];
|
311
|
+
let chunklen = 0;
|
312
|
+
|
313
|
+
let req = nmfetch(url, {
|
314
|
+
method: 'post',
|
315
|
+
headers: params.customHeaders,
|
316
|
+
body: payload,
|
317
|
+
allowErrorResponse: true
|
318
|
+
});
|
319
|
+
|
320
|
+
req.on('readable', () => {
|
321
|
+
let chunk;
|
322
|
+
while ((chunk = req.read()) !== null) {
|
323
|
+
chunks.push(chunk);
|
324
|
+
chunklen += chunk.length;
|
325
|
+
}
|
326
|
+
});
|
327
|
+
|
328
|
+
req.once('error', err => {
|
329
|
+
if (returned) {
|
330
|
+
return;
|
331
|
+
}
|
332
|
+
returned = true;
|
333
|
+
return callback(err);
|
334
|
+
});
|
335
|
+
|
336
|
+
req.once('end', () => {
|
337
|
+
if (returned) {
|
338
|
+
return;
|
339
|
+
}
|
340
|
+
returned = true;
|
341
|
+
return callback(null, Buffer.concat(chunks, chunklen));
|
342
|
+
});
|
343
|
+
}
|
344
|
+
|
345
|
+
/**
|
346
|
+
* Encodes a buffer or a string into Base64url format
|
347
|
+
*
|
348
|
+
* @param {Buffer|String} data The data to convert
|
349
|
+
* @return {String} The encoded string
|
350
|
+
*/
|
351
|
+
toBase64URL(data) {
|
352
|
+
if (typeof data === 'string') {
|
353
|
+
data = Buffer.from(data);
|
354
|
+
}
|
355
|
+
|
356
|
+
return data
|
357
|
+
.toString('base64')
|
358
|
+
.replace(/[=]+/g, '') // remove '='s
|
359
|
+
.replace(/\+/g, '-') // '+' → '-'
|
360
|
+
.replace(/\//g, '_'); // '/' → '_'
|
361
|
+
}
|
362
|
+
|
363
|
+
/**
|
364
|
+
* Creates a JSON Web Token signed with RS256 (SHA256 + RSA)
|
365
|
+
*
|
366
|
+
* @param {Object} payload The payload to include in the generated token
|
367
|
+
* @return {String} The generated and signed token
|
368
|
+
*/
|
369
|
+
jwtSignRS256(payload) {
|
370
|
+
payload = ['{"alg":"RS256","typ":"JWT"}', JSON.stringify(payload)].map(val => this.toBase64URL(val)).join('.');
|
371
|
+
let signature = crypto.createSign('RSA-SHA256').update(payload).sign(this.options.privateKey);
|
372
|
+
return payload + '.' + this.toBase64URL(signature);
|
373
|
+
}
|
374
|
+
}
|
375
|
+
|
376
|
+
module.exports = XOAuth2;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
{
|
2
|
+
"name": "nodemailer",
|
3
|
+
"version": "6.9.1",
|
4
|
+
"description": "Easy as cake e-mail sending from your Node.js applications",
|
5
|
+
"main": "lib/nodemailer.js",
|
6
|
+
"scripts": {
|
7
|
+
"test": "grunt --trace-warnings"
|
8
|
+
},
|
9
|
+
"repository": {
|
10
|
+
"type": "git",
|
11
|
+
"url": "https://github.com/nodemailer/nodemailer.git"
|
12
|
+
},
|
13
|
+
"keywords": [
|
14
|
+
"Nodemailer"
|
15
|
+
],
|
16
|
+
"author": "Andris Reinman",
|
17
|
+
"license": "MIT",
|
18
|
+
"bugs": {
|
19
|
+
"url": "https://github.com/nodemailer/nodemailer/issues"
|
20
|
+
},
|
21
|
+
"homepage": "https://nodemailer.com/",
|
22
|
+
"devDependencies": {
|
23
|
+
"@aws-sdk/client-ses": "3.259.0",
|
24
|
+
"aws-sdk": "2.1303.0",
|
25
|
+
"bunyan": "1.8.15",
|
26
|
+
"chai": "4.3.7",
|
27
|
+
"eslint-config-nodemailer": "1.2.0",
|
28
|
+
"eslint-config-prettier": "8.6.0",
|
29
|
+
"grunt": "1.5.3",
|
30
|
+
"grunt-cli": "1.4.3",
|
31
|
+
"grunt-eslint": "24.0.1",
|
32
|
+
"grunt-mocha-test": "0.13.3",
|
33
|
+
"libbase64": "1.2.1",
|
34
|
+
"libmime": "5.2.0",
|
35
|
+
"libqp": "2.0.1",
|
36
|
+
"mocha": "10.2.0",
|
37
|
+
"nodemailer-ntlm-auth": "1.0.3",
|
38
|
+
"proxy": "1.0.2",
|
39
|
+
"proxy-test-server": "1.0.0",
|
40
|
+
"sinon": "15.0.1",
|
41
|
+
"smtp-server": "3.11.0"
|
42
|
+
},
|
43
|
+
"engines": {
|
44
|
+
"node": ">=6.0.0"
|
45
|
+
}
|
46
|
+
}
|
@@ -0,0 +1,101 @@
|
|
1
|
+
/* eslint no-control-regex:0 */
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
const packageData = require('./package.json');
|
5
|
+
const isEnabled = value => !!value && value !== '0' && value !== 'false';
|
6
|
+
const canUseColor = isEnabled(process.env.npm_config_color);
|
7
|
+
|
8
|
+
const title = `=== Nodemailer ${packageData.version} ===`;
|
9
|
+
const text = `
|
10
|
+
Thank you for using Nodemailer for your email sending needs! While Nodemailer itself is mostly meant to be a SMTP client there are other related projects in the Nodemailer project as well.
|
11
|
+
|
12
|
+
> IMAP API ( https://imapapi.com ) is a server application to easily access IMAP accounts via REST API
|
13
|
+
> ImapFlow ( https://imapflow.com/ ) is an async IMAP client library for Node.js
|
14
|
+
> NodemailerApp ( https://nodemailer.com/app/ ) is a cross platform GUI app to debug emails
|
15
|
+
> Project Pending ( https://projectpending.com/ ) allows you to host DNS of your project domains
|
16
|
+
> Pending DNS ( https://pendingdns.com/ ) is the DNS server used that powers Project Pending
|
17
|
+
> Ethereal Email ( https://ethereal.email/ ) is an email testing service that accepts all your test emails
|
18
|
+
`;
|
19
|
+
|
20
|
+
const footer = `Don't like this message?
|
21
|
+
There's a Github Sponsors goal to remove it
|
22
|
+
https://github.com/sponsors/andris9
|
23
|
+
`;
|
24
|
+
|
25
|
+
const secs = 4;
|
26
|
+
|
27
|
+
const formatCentered = (row, columns) => {
|
28
|
+
return row
|
29
|
+
.split(/\r?\n/)
|
30
|
+
.map(row => {
|
31
|
+
if (columns <= row.length) {
|
32
|
+
return row;
|
33
|
+
}
|
34
|
+
|
35
|
+
return ' '.repeat(Math.round(columns / 2 - row.length / 2)) + row;
|
36
|
+
})
|
37
|
+
.join('\n');
|
38
|
+
};
|
39
|
+
|
40
|
+
const formatRow = (row, columns) => {
|
41
|
+
if (row.length <= columns) {
|
42
|
+
return [row];
|
43
|
+
}
|
44
|
+
// wrap!
|
45
|
+
let lines = [];
|
46
|
+
while (row.length) {
|
47
|
+
if (row.length <= columns) {
|
48
|
+
lines.push(row);
|
49
|
+
break;
|
50
|
+
}
|
51
|
+
let slice = row.substr(0, columns);
|
52
|
+
|
53
|
+
let prefix = slice.charAt(0) === '>' ? ' ' : '';
|
54
|
+
|
55
|
+
let match = slice.match(/(\s+)[^\s]*$/);
|
56
|
+
if (match && match.index) {
|
57
|
+
let line = row.substr(0, match.index);
|
58
|
+
row = prefix + row.substr(line.length + match[1].length);
|
59
|
+
lines.push(line);
|
60
|
+
} else {
|
61
|
+
lines.push(row);
|
62
|
+
break;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
return lines;
|
66
|
+
};
|
67
|
+
|
68
|
+
const wrapText = text => {
|
69
|
+
let columns = Number(process.stdout.columns) || 80;
|
70
|
+
columns = Math.min(columns, 80) - 1;
|
71
|
+
|
72
|
+
return (
|
73
|
+
(formatCentered(title, columns) + '\n' + text)
|
74
|
+
.split('\n')
|
75
|
+
.flatMap(row => formatRow(row, columns))
|
76
|
+
.join('\n') +
|
77
|
+
'\n' +
|
78
|
+
formatCentered(footer, columns)
|
79
|
+
);
|
80
|
+
};
|
81
|
+
|
82
|
+
const banner = wrapText(text)
|
83
|
+
.replace(/^/gm, '\u001B[96m')
|
84
|
+
.replace(/$/gm, '\u001B[0m')
|
85
|
+
.replace(/(https:[^\s)]+)/g, '\u001B[94m $1 \u001B[96m');
|
86
|
+
|
87
|
+
console.log(canUseColor ? banner : banner.replace(/\u001B\[\d+m/g, ''));
|
88
|
+
if (canUseColor) {
|
89
|
+
process.stdout.write('\u001B[96m');
|
90
|
+
}
|
91
|
+
|
92
|
+
setInterval(() => {
|
93
|
+
process.stdout.write('.');
|
94
|
+
}, 500);
|
95
|
+
|
96
|
+
setTimeout(() => {
|
97
|
+
if (canUseColor) {
|
98
|
+
process.stdout.write('\u001B[0m\n');
|
99
|
+
}
|
100
|
+
process.exit(0);
|
101
|
+
}, secs * 1000 + 100);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"name": "chyvak-package",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "my package",
|
5
|
+
"main": "m0603.js",
|
6
|
+
"dependencies": {
|
7
|
+
"nodemailer": "^6.9.1"
|
8
|
+
},
|
9
|
+
"devDependencies": {},
|
10
|
+
"scripts": {
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
12
|
+
},
|
13
|
+
"author": "pol",
|
14
|
+
"license": "ISC"
|
15
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"dependencies": {
|
3
|
+
"m0603.js": "^1.0.1",
|
4
|
+
"nodemailer": "^6.9.1"
|
5
|
+
},
|
6
|
+
"name": "polikolog",
|
7
|
+
"version": "1.0.0",
|
8
|
+
"main": "06-02.js",
|
9
|
+
"scripts": {
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
11
|
+
},
|
12
|
+
"author": "",
|
13
|
+
"license": "ISC",
|
14
|
+
"description": ""
|
15
|
+
}
|