m0603va 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.
- package/Laba6/file1.js +23 -0
- package/Laba6/file2.js +23 -0
- package/Laba6/index.html +63 -0
- package/Laba6/m0603.js +29 -0
- package/Laba6/node_modules/.package-lock.json +83 -0
- package/Laba6/node_modules/httpntlm/.jshintrc +4 -0
- package/Laba6/node_modules/httpntlm/LICENSE +20 -0
- package/Laba6/node_modules/httpntlm/README.md +148 -0
- package/Laba6/node_modules/httpntlm/httpntlm.js +104 -0
- package/Laba6/node_modules/httpntlm/ntlm.js +390 -0
- package/Laba6/node_modules/httpntlm/package.json +33 -0
- package/Laba6/node_modules/httpreq/LICENSE +19 -0
- package/Laba6/node_modules/httpreq/README.md +383 -0
- package/Laba6/node_modules/httpreq/contributors.md +26 -0
- package/Laba6/node_modules/httpreq/lib/httpreq.js +681 -0
- package/Laba6/node_modules/httpreq/package.json +102 -0
- package/Laba6/node_modules/m0603sol/m0603.js +29 -0
- package/Laba6/node_modules/m0603sol/package.json +12 -0
- package/Laba6/node_modules/nodemailer/.gitattributes +6 -0
- package/Laba6/node_modules/nodemailer/.prettierrc.js +8 -0
- package/Laba6/node_modules/nodemailer/CHANGELOG.md +725 -0
- package/Laba6/node_modules/nodemailer/CODE_OF_CONDUCT.md +76 -0
- package/Laba6/node_modules/nodemailer/CONTRIBUTING.md +67 -0
- package/Laba6/node_modules/nodemailer/LICENSE +16 -0
- package/Laba6/node_modules/nodemailer/README.md +97 -0
- package/Laba6/node_modules/nodemailer/SECURITY.txt +22 -0
- package/Laba6/node_modules/nodemailer/lib/addressparser/index.js +313 -0
- package/Laba6/node_modules/nodemailer/lib/base64/index.js +142 -0
- package/Laba6/node_modules/nodemailer/lib/dkim/index.js +251 -0
- package/Laba6/node_modules/nodemailer/lib/dkim/message-parser.js +155 -0
- package/Laba6/node_modules/nodemailer/lib/dkim/relaxed-body.js +154 -0
- package/Laba6/node_modules/nodemailer/lib/dkim/sign.js +117 -0
- package/Laba6/node_modules/nodemailer/lib/fetch/cookies.js +281 -0
- package/Laba6/node_modules/nodemailer/lib/fetch/index.js +274 -0
- package/Laba6/node_modules/nodemailer/lib/json-transport/index.js +82 -0
- package/Laba6/node_modules/nodemailer/lib/mail-composer/index.js +558 -0
- package/Laba6/node_modules/nodemailer/lib/mailer/index.js +427 -0
- package/Laba6/node_modules/nodemailer/lib/mailer/mail-message.js +315 -0
- package/Laba6/node_modules/nodemailer/lib/mime-funcs/index.js +625 -0
- package/Laba6/node_modules/nodemailer/lib/mime-funcs/mime-types.js +2102 -0
- package/Laba6/node_modules/nodemailer/lib/mime-node/index.js +1290 -0
- package/Laba6/node_modules/nodemailer/lib/mime-node/last-newline.js +33 -0
- package/Laba6/node_modules/nodemailer/lib/mime-node/le-unix.js +43 -0
- package/Laba6/node_modules/nodemailer/lib/mime-node/le-windows.js +52 -0
- package/Laba6/node_modules/nodemailer/lib/nodemailer.js +143 -0
- package/Laba6/node_modules/nodemailer/lib/qp/index.js +219 -0
- package/Laba6/node_modules/nodemailer/lib/sendmail-transport/index.js +210 -0
- package/Laba6/node_modules/nodemailer/lib/ses-transport/index.js +349 -0
- package/Laba6/node_modules/nodemailer/lib/shared/index.js +638 -0
- package/Laba6/node_modules/nodemailer/lib/smtp-connection/data-stream.js +108 -0
- package/Laba6/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +143 -0
- package/Laba6/node_modules/nodemailer/lib/smtp-connection/index.js +1796 -0
- package/Laba6/node_modules/nodemailer/lib/smtp-pool/index.js +648 -0
- package/Laba6/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +253 -0
- package/Laba6/node_modules/nodemailer/lib/smtp-transport/index.js +416 -0
- package/Laba6/node_modules/nodemailer/lib/stream-transport/index.js +135 -0
- package/Laba6/node_modules/nodemailer/lib/well-known/index.js +47 -0
- package/Laba6/node_modules/nodemailer/lib/well-known/services.json +286 -0
- package/Laba6/node_modules/nodemailer/lib/xoauth2/index.js +376 -0
- package/Laba6/node_modules/nodemailer/package.json +46 -0
- package/Laba6/node_modules/nodemailer/postinstall.js +101 -0
- package/Laba6/node_modules/nodemailer-fetch/.eslintrc.js +56 -0
- package/Laba6/node_modules/nodemailer-fetch/.travis.yml +19 -0
- package/Laba6/node_modules/nodemailer-fetch/CHANGELOG.md +30 -0
- package/Laba6/node_modules/nodemailer-fetch/Gruntfile.js +27 -0
- package/Laba6/node_modules/nodemailer-fetch/LICENSE +16 -0
- package/Laba6/node_modules/nodemailer-fetch/README.md +55 -0
- package/Laba6/node_modules/nodemailer-fetch/lib/cookies.js +275 -0
- package/Laba6/node_modules/nodemailer-fetch/lib/fetch.js +224 -0
- package/Laba6/node_modules/nodemailer-fetch/package.json +30 -0
- package/Laba6/node_modules/nodemailer-fetch/test/cookies-test.js +391 -0
- package/Laba6/node_modules/nodemailer-fetch/test/fetch-test.js +486 -0
- package/Laba6/node_modules/nodemailer-shared/.eslintrc.js +59 -0
- package/Laba6/node_modules/nodemailer-shared/.travis.yml +18 -0
- package/Laba6/node_modules/nodemailer-shared/Gruntfile.js +27 -0
- package/Laba6/node_modules/nodemailer-shared/LICENSE +16 -0
- package/Laba6/node_modules/nodemailer-shared/README.md +14 -0
- package/Laba6/node_modules/nodemailer-shared/lib/shared.js +282 -0
- package/Laba6/node_modules/nodemailer-shared/package.json +36 -0
- package/Laba6/node_modules/nodemailer-shared/test/fixtures/message.html +1 -0
- package/Laba6/node_modules/nodemailer-shared/test/shared-test.js +291 -0
- package/Laba6/node_modules/nodemailer-smtp-transport/.eslintrc.js +59 -0
- package/Laba6/node_modules/nodemailer-smtp-transport/Gruntfile.js +27 -0
- package/Laba6/node_modules/nodemailer-smtp-transport/LICENSE +19 -0
- package/Laba6/node_modules/nodemailer-smtp-transport/README.md +7 -0
- package/Laba6/node_modules/nodemailer-smtp-transport/lib/smtp-transport.js +281 -0
- package/Laba6/node_modules/nodemailer-smtp-transport/package.json +37 -0
- package/Laba6/node_modules/nodemailer-wellknown/.travis.yml +17 -0
- package/Laba6/node_modules/nodemailer-wellknown/LICENSE +19 -0
- package/Laba6/node_modules/nodemailer-wellknown/README.md +80 -0
- package/Laba6/node_modules/nodemailer-wellknown/index.js +47 -0
- package/Laba6/node_modules/nodemailer-wellknown/package.json +26 -0
- package/Laba6/node_modules/nodemailer-wellknown/services.json +255 -0
- package/Laba6/node_modules/nodemailer-wellknown/test.js +23 -0
- package/Laba6/node_modules/smtp-connection/.eslintrc.js +56 -0
- package/Laba6/node_modules/smtp-connection/CHANGELOG.md +164 -0
- package/Laba6/node_modules/smtp-connection/Gruntfile.js +27 -0
- package/Laba6/node_modules/smtp-connection/LICENSE +19 -0
- package/Laba6/node_modules/smtp-connection/README.md +200 -0
- package/Laba6/node_modules/smtp-connection/lib/data-stream.js +111 -0
- package/Laba6/node_modules/smtp-connection/lib/smtp-connection.js +1443 -0
- package/Laba6/node_modules/smtp-connection/package.json +41 -0
- package/Laba6/node_modules/underscore/LICENSE +23 -0
- package/Laba6/node_modules/underscore/README.md +22 -0
- package/Laba6/node_modules/underscore/package.json +41 -0
- package/Laba6/node_modules/underscore/underscore-min.js +6 -0
- package/Laba6/node_modules/underscore/underscore.js +1415 -0
- package/Laba6/package-lock.json +94 -0
- package/Laba6/package.json +17 -0
- package/Laba6.txt +31 -0
- package/file1.js +23 -0
- package/file2.js +23 -0
- package/index.html +63 -0
- package/m0603.js +29 -0
- package/m0603Sol/m0603.js +29 -0
- package/m0603Sol/package.json +12 -0
- package/package.json +17 -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,56 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
rules: {
|
5
|
+
indent: [2, 4, {
|
6
|
+
SwitchCase: 1
|
7
|
+
}],
|
8
|
+
quotes: [2, 'single'],
|
9
|
+
'linebreak-style': [2, 'unix'],
|
10
|
+
semi: [2, 'always'],
|
11
|
+
strict: [2, 'global'],
|
12
|
+
eqeqeq: 2,
|
13
|
+
'dot-notation': 2,
|
14
|
+
curly: 2,
|
15
|
+
'no-fallthrough': 2,
|
16
|
+
'quote-props': [2, 'as-needed'],
|
17
|
+
'no-unused-expressions': [2, {
|
18
|
+
allowShortCircuit: true
|
19
|
+
}],
|
20
|
+
'no-unused-vars': 2,
|
21
|
+
'no-undef': 2,
|
22
|
+
'handle-callback-err': 2,
|
23
|
+
'no-new': 2,
|
24
|
+
'new-cap': 2,
|
25
|
+
'no-eval': 2,
|
26
|
+
'no-invalid-this': 2,
|
27
|
+
radix: [2, 'always'],
|
28
|
+
'no-use-before-define': [2, 'nofunc'],
|
29
|
+
'callback-return': [2, ['callback', 'cb', 'done']],
|
30
|
+
'comma-dangle': [2, 'never'],
|
31
|
+
'comma-style': [2, 'last'],
|
32
|
+
'no-regex-spaces': 2,
|
33
|
+
'no-empty': 2,
|
34
|
+
'no-duplicate-case': 2,
|
35
|
+
'no-empty-character-class': 2,
|
36
|
+
'no-redeclare': [2, {
|
37
|
+
builtinGlobals: true
|
38
|
+
}],
|
39
|
+
'block-scoped-var': 2,
|
40
|
+
'no-sequences': 2,
|
41
|
+
'no-throw-literal': 2,
|
42
|
+
'no-useless-concat': 2,
|
43
|
+
'no-void': 2,
|
44
|
+
yoda: 2,
|
45
|
+
'no-bitwise': 2,
|
46
|
+
'no-lonely-if': 2,
|
47
|
+
'no-mixed-spaces-and-tabs': 2,
|
48
|
+
'no-console': 0
|
49
|
+
},
|
50
|
+
env: {
|
51
|
+
es6: false,
|
52
|
+
node: true
|
53
|
+
},
|
54
|
+
extends: 'eslint:recommended',
|
55
|
+
fix: true
|
56
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
language: node_js
|
2
|
+
sudo: false
|
3
|
+
node_js:
|
4
|
+
- "0.10"
|
5
|
+
- 0.12
|
6
|
+
- iojs
|
7
|
+
- '4'
|
8
|
+
- '5'
|
9
|
+
before_install:
|
10
|
+
- npm install -g grunt-cli
|
11
|
+
notifications:
|
12
|
+
email:
|
13
|
+
- andris@kreata.ee
|
14
|
+
webhooks:
|
15
|
+
urls:
|
16
|
+
- https://webhooks.gitter.im/e/0ed18fd9b3e529b3c2cc
|
17
|
+
on_success: change # options: [always|never|change] default: always
|
18
|
+
on_failure: always # options: [always|never|change] default: always
|
19
|
+
on_start: false # default: false
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## v1.6.0 2016-08-18
|
4
|
+
|
5
|
+
* Added new option `headers`
|
6
|
+
|
7
|
+
## v1.5.0 2016-08-18
|
8
|
+
|
9
|
+
* Allow streams as POST body
|
10
|
+
|
11
|
+
## v1.3.0 2016-02-11
|
12
|
+
|
13
|
+
* Added new option `timeout`
|
14
|
+
|
15
|
+
## v1.2.1 2016-01-18
|
16
|
+
|
17
|
+
* Enclose http.request into try..catch to get url parse errors
|
18
|
+
|
19
|
+
## v1.2.0 2016-01-18
|
20
|
+
|
21
|
+
* Export `Cookies` constructor
|
22
|
+
|
23
|
+
## v1.1.0 2016-01-18
|
24
|
+
|
25
|
+
* Exposed `options` object
|
26
|
+
* Added new options `maxRedirects`, `userAgent` and `cookie`
|
27
|
+
|
28
|
+
## v1.0.0 2015-12-30
|
29
|
+
|
30
|
+
* Initial version
|
@@ -0,0 +1,27 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
module.exports = function (grunt) {
|
4
|
+
|
5
|
+
// Project configuration.
|
6
|
+
grunt.initConfig({
|
7
|
+
eslint: {
|
8
|
+
all: ['lib/*.js', 'test/*.js', 'Gruntfile.js', '.eslintrc.js']
|
9
|
+
},
|
10
|
+
|
11
|
+
mochaTest: {
|
12
|
+
all: {
|
13
|
+
options: {
|
14
|
+
reporter: 'spec'
|
15
|
+
},
|
16
|
+
src: ['test/*-test.js']
|
17
|
+
}
|
18
|
+
}
|
19
|
+
});
|
20
|
+
|
21
|
+
// Load the plugin(s)
|
22
|
+
grunt.loadNpmTasks('grunt-eslint');
|
23
|
+
grunt.loadNpmTasks('grunt-mocha-test');
|
24
|
+
|
25
|
+
// Tasks
|
26
|
+
grunt.registerTask('default', ['eslint', 'mochaTest']);
|
27
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Copyright (c) 2015-2016 Andris Reinman
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
11
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
12
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
13
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
14
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
15
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
16
|
+
SOFTWARE.
|