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,282 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var urllib = require('url');
|
4
|
+
var util = require('util');
|
5
|
+
var fs = require('fs');
|
6
|
+
var fetch = require('nodemailer-fetch');
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Parses connection url to a structured configuration object
|
10
|
+
*
|
11
|
+
* @param {String} str Connection url
|
12
|
+
* @return {Object} Configuration object
|
13
|
+
*/
|
14
|
+
module.exports.parseConnectionUrl = function (str) {
|
15
|
+
str = str || '';
|
16
|
+
var options = {};
|
17
|
+
|
18
|
+
[urllib.parse(str, true)].forEach(function (url) {
|
19
|
+
var auth;
|
20
|
+
|
21
|
+
switch (url.protocol) {
|
22
|
+
case 'smtp:':
|
23
|
+
options.secure = false;
|
24
|
+
break;
|
25
|
+
case 'smtps:':
|
26
|
+
options.secure = true;
|
27
|
+
break;
|
28
|
+
case 'direct:':
|
29
|
+
options.direct = true;
|
30
|
+
break;
|
31
|
+
}
|
32
|
+
|
33
|
+
if (!isNaN(url.port) && Number(url.port)) {
|
34
|
+
options.port = Number(url.port);
|
35
|
+
}
|
36
|
+
|
37
|
+
if (url.hostname) {
|
38
|
+
options.host = url.hostname;
|
39
|
+
}
|
40
|
+
|
41
|
+
if (url.auth) {
|
42
|
+
auth = url.auth.split(':');
|
43
|
+
|
44
|
+
if (!options.auth) {
|
45
|
+
options.auth = {};
|
46
|
+
}
|
47
|
+
|
48
|
+
options.auth.user = auth.shift();
|
49
|
+
options.auth.pass = auth.join(':');
|
50
|
+
}
|
51
|
+
|
52
|
+
Object.keys(url.query || {}).forEach(function (key) {
|
53
|
+
var obj = options;
|
54
|
+
var lKey = key;
|
55
|
+
var value = url.query[key];
|
56
|
+
|
57
|
+
if (!isNaN(value)) {
|
58
|
+
value = Number(value);
|
59
|
+
}
|
60
|
+
|
61
|
+
switch (value) {
|
62
|
+
case 'true':
|
63
|
+
value = true;
|
64
|
+
break;
|
65
|
+
case 'false':
|
66
|
+
value = false;
|
67
|
+
break;
|
68
|
+
}
|
69
|
+
|
70
|
+
// tls is nested object
|
71
|
+
if (key.indexOf('tls.') === 0) {
|
72
|
+
lKey = key.substr(4);
|
73
|
+
if (!options.tls) {
|
74
|
+
options.tls = {};
|
75
|
+
}
|
76
|
+
obj = options.tls;
|
77
|
+
} else if (key.indexOf('.') >= 0) {
|
78
|
+
// ignore nested properties besides tls
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
|
82
|
+
if (!(lKey in obj)) {
|
83
|
+
obj[lKey] = value;
|
84
|
+
}
|
85
|
+
});
|
86
|
+
});
|
87
|
+
|
88
|
+
return options;
|
89
|
+
};
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Returns a bunyan-compatible logger interface. Uses either provided logger or
|
93
|
+
* creates a default console logger
|
94
|
+
*
|
95
|
+
* @param {Object} [options] Options object that might include 'logger' value
|
96
|
+
* @return {Object} bunyan compatible logger
|
97
|
+
*/
|
98
|
+
module.exports.getLogger = function (options) {
|
99
|
+
options = options || {};
|
100
|
+
|
101
|
+
if (!options.logger) {
|
102
|
+
// use vanity logger
|
103
|
+
return {
|
104
|
+
info: function () {},
|
105
|
+
debug: function () {},
|
106
|
+
error: function () {}
|
107
|
+
};
|
108
|
+
}
|
109
|
+
|
110
|
+
if (options.logger === true) {
|
111
|
+
// create console logger
|
112
|
+
return createDefaultLogger();
|
113
|
+
}
|
114
|
+
|
115
|
+
// return whatever was passed
|
116
|
+
return options.logger;
|
117
|
+
};
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Wrapper for creating a callback than either resolves or rejects a promise
|
121
|
+
* based on input
|
122
|
+
*
|
123
|
+
* @param {Function} resolve Function to run if callback is called
|
124
|
+
* @param {Function} reject Function to run if callback ends with an error
|
125
|
+
*/
|
126
|
+
module.exports.callbackPromise = function (resolve, reject) {
|
127
|
+
return function () {
|
128
|
+
var args = Array.prototype.slice.call(arguments);
|
129
|
+
var err = args.shift();
|
130
|
+
if (err) {
|
131
|
+
reject(err);
|
132
|
+
} else {
|
133
|
+
resolve.apply(null, args);
|
134
|
+
}
|
135
|
+
};
|
136
|
+
};
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Resolves a String or a Buffer value for content value. Useful if the value
|
140
|
+
* is a Stream or a file or an URL. If the value is a Stream, overwrites
|
141
|
+
* the stream object with the resolved value (you can't stream a value twice).
|
142
|
+
*
|
143
|
+
* This is useful when you want to create a plugin that needs a content value,
|
144
|
+
* for example the `html` or `text` value as a String or a Buffer but not as
|
145
|
+
* a file path or an URL.
|
146
|
+
*
|
147
|
+
* @param {Object} data An object or an Array you want to resolve an element for
|
148
|
+
* @param {String|Number} key Property name or an Array index
|
149
|
+
* @param {Function} callback Callback function with (err, value)
|
150
|
+
*/
|
151
|
+
module.exports.resolveContent = function (data, key, callback) {
|
152
|
+
var promise;
|
153
|
+
|
154
|
+
if (!callback && typeof Promise === 'function') {
|
155
|
+
promise = new Promise(function (resolve, reject) {
|
156
|
+
callback = module.exports.callbackPromise(resolve, reject);
|
157
|
+
});
|
158
|
+
}
|
159
|
+
|
160
|
+
var content = data && data[key] && data[key].content || data[key];
|
161
|
+
var contentStream;
|
162
|
+
var encoding = (typeof data[key] === 'object' && data[key].encoding || 'utf8')
|
163
|
+
.toString()
|
164
|
+
.toLowerCase()
|
165
|
+
.replace(/[-_\s]/g, '');
|
166
|
+
|
167
|
+
if (!content) {
|
168
|
+
return callback(null, content);
|
169
|
+
}
|
170
|
+
|
171
|
+
if (typeof content === 'object') {
|
172
|
+
if (typeof content.pipe === 'function') {
|
173
|
+
return resolveStream(content, function (err, value) {
|
174
|
+
if (err) {
|
175
|
+
return callback(err);
|
176
|
+
}
|
177
|
+
// we can't stream twice the same content, so we need
|
178
|
+
// to replace the stream object with the streaming result
|
179
|
+
data[key] = value;
|
180
|
+
callback(null, value);
|
181
|
+
});
|
182
|
+
} else if (/^https?:\/\//i.test(content.path || content.href)) {
|
183
|
+
contentStream = fetch(content.path || content.href);
|
184
|
+
return resolveStream(contentStream, callback);
|
185
|
+
} else if (/^data:/i.test(content.path || content.href)) {
|
186
|
+
var parts = (content.path || content.href).match(/^data:((?:[^;]*;)*(?:[^,]*)),(.*)$/i);
|
187
|
+
if (!parts) {
|
188
|
+
return callback(null, new Buffer(0));
|
189
|
+
}
|
190
|
+
return callback(null, /\bbase64$/i.test(parts[1]) ? new Buffer(parts[2], 'base64') : new Buffer(decodeURIComponent(parts[2])));
|
191
|
+
} else if (content.path) {
|
192
|
+
return resolveStream(fs.createReadStream(content.path), callback);
|
193
|
+
}
|
194
|
+
}
|
195
|
+
|
196
|
+
if (typeof data[key].content === 'string' && ['utf8', 'usascii', 'ascii'].indexOf(encoding) < 0) {
|
197
|
+
content = new Buffer(data[key].content, encoding);
|
198
|
+
}
|
199
|
+
|
200
|
+
// default action, return as is
|
201
|
+
setImmediate(callback.bind(null, null, content));
|
202
|
+
|
203
|
+
return promise;
|
204
|
+
};
|
205
|
+
|
206
|
+
/**
|
207
|
+
* Streams a stream value into a Buffer
|
208
|
+
*
|
209
|
+
* @param {Object} stream Readable stream
|
210
|
+
* @param {Function} callback Callback function with (err, value)
|
211
|
+
*/
|
212
|
+
function resolveStream(stream, callback) {
|
213
|
+
var responded = false;
|
214
|
+
var chunks = [];
|
215
|
+
var chunklen = 0;
|
216
|
+
|
217
|
+
stream.on('error', function (err) {
|
218
|
+
if (responded) {
|
219
|
+
return;
|
220
|
+
}
|
221
|
+
|
222
|
+
responded = true;
|
223
|
+
callback(err);
|
224
|
+
});
|
225
|
+
|
226
|
+
stream.on('readable', function () {
|
227
|
+
var chunk;
|
228
|
+
while ((chunk = stream.read()) !== null) {
|
229
|
+
chunks.push(chunk);
|
230
|
+
chunklen += chunk.length;
|
231
|
+
}
|
232
|
+
});
|
233
|
+
|
234
|
+
stream.on('end', function () {
|
235
|
+
if (responded) {
|
236
|
+
return;
|
237
|
+
}
|
238
|
+
responded = true;
|
239
|
+
|
240
|
+
var value;
|
241
|
+
|
242
|
+
try {
|
243
|
+
value = Buffer.concat(chunks, chunklen);
|
244
|
+
} catch (E) {
|
245
|
+
return callback(E);
|
246
|
+
}
|
247
|
+
callback(null, value);
|
248
|
+
});
|
249
|
+
}
|
250
|
+
|
251
|
+
/**
|
252
|
+
* Generates a bunyan-like logger that prints to console
|
253
|
+
*
|
254
|
+
* @returns {Object} Bunyan logger instance
|
255
|
+
*/
|
256
|
+
function createDefaultLogger() {
|
257
|
+
|
258
|
+
var logger = {
|
259
|
+
_print: function ( /* level, message */ ) {
|
260
|
+
var args = Array.prototype.slice.call(arguments);
|
261
|
+
var level = args.shift();
|
262
|
+
var message;
|
263
|
+
|
264
|
+
if (args.length > 1) {
|
265
|
+
message = util.format.apply(util, args);
|
266
|
+
} else {
|
267
|
+
message = args.shift();
|
268
|
+
}
|
269
|
+
|
270
|
+
console.log('[%s] %s: %s',
|
271
|
+
new Date().toISOString().substr(0, 19).replace(/T/, ' '),
|
272
|
+
level.toUpperCase(),
|
273
|
+
message);
|
274
|
+
}
|
275
|
+
};
|
276
|
+
|
277
|
+
logger.info = logger._print.bind(null, 'info');
|
278
|
+
logger.debug = logger._print.bind(null, 'debug');
|
279
|
+
logger.error = logger._print.bind(null, 'error');
|
280
|
+
|
281
|
+
return logger;
|
282
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
{
|
2
|
+
"name": "nodemailer-shared",
|
3
|
+
"version": "1.1.0",
|
4
|
+
"description": "Shared methods for the nodemailer stack",
|
5
|
+
"main": "lib/shared.js",
|
6
|
+
"directories": {
|
7
|
+
"test": "test"
|
8
|
+
},
|
9
|
+
"scripts": {
|
10
|
+
"test": "grunt mochaTest"
|
11
|
+
},
|
12
|
+
"repository": {
|
13
|
+
"type": "git",
|
14
|
+
"url": "git+https://github.com/nodemailer/nodemailer-shared.git"
|
15
|
+
},
|
16
|
+
"keywords": [
|
17
|
+
"nodemailer"
|
18
|
+
],
|
19
|
+
"author": "Andris Reinman",
|
20
|
+
"license": "MIT",
|
21
|
+
"bugs": {
|
22
|
+
"url": "https://github.com/nodemailer/nodemailer-shared/issues"
|
23
|
+
},
|
24
|
+
"homepage": "https://github.com/nodemailer/nodemailer-shared#readme",
|
25
|
+
"dependencies": {
|
26
|
+
"nodemailer-fetch": "1.6.0"
|
27
|
+
},
|
28
|
+
"devDependencies": {
|
29
|
+
"chai": "^3.5.0",
|
30
|
+
"grunt": "^1.0.1",
|
31
|
+
"grunt-cli": "^1.2.0",
|
32
|
+
"grunt-eslint": "^19.0.0",
|
33
|
+
"grunt-mocha-test": "^0.12.7",
|
34
|
+
"mocha": "^3.0.2"
|
35
|
+
}
|
36
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
<p>Tere, tere</p><p>vana kere!</p>
|
@@ -0,0 +1,291 @@
|
|
1
|
+
/* eslint no-unused-expressions:0, no-invalid-this:0 */
|
2
|
+
/* globals beforeEach, afterEach, describe, it */
|
3
|
+
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
var chai = require('chai');
|
7
|
+
var expect = chai.expect;
|
8
|
+
var shared = require('../lib/shared');
|
9
|
+
|
10
|
+
var http = require('http');
|
11
|
+
var fs = require('fs');
|
12
|
+
var zlib = require('zlib');
|
13
|
+
|
14
|
+
chai.config.includeStack = true;
|
15
|
+
|
16
|
+
describe('Logger tests', function () {
|
17
|
+
it('Should create a logger', function () {
|
18
|
+
expect(typeof shared.getLogger({
|
19
|
+
logger: false
|
20
|
+
})).to.equal('object');
|
21
|
+
expect(typeof shared.getLogger()).to.equal('object');
|
22
|
+
expect(typeof shared.getLogger({
|
23
|
+
logger: 'stri'
|
24
|
+
})).to.equal('string');
|
25
|
+
});
|
26
|
+
});
|
27
|
+
|
28
|
+
describe('Connection url parser tests', function () {
|
29
|
+
it('Should parse connection url', function () {
|
30
|
+
var url = 'smtps://user:pass@localhost:123?tls.rejectUnauthorized=false&name=horizon';
|
31
|
+
expect(shared.parseConnectionUrl(url)).to.deep.equal({
|
32
|
+
secure: true,
|
33
|
+
port: 123,
|
34
|
+
host: 'localhost',
|
35
|
+
auth: {
|
36
|
+
user: 'user',
|
37
|
+
pass: 'pass'
|
38
|
+
},
|
39
|
+
tls: {
|
40
|
+
rejectUnauthorized: false
|
41
|
+
},
|
42
|
+
name: 'horizon'
|
43
|
+
});
|
44
|
+
});
|
45
|
+
|
46
|
+
it('should not choke on special symbols in auth', function () {
|
47
|
+
var url = 'smtps://user%40gmail.com:%3Apasswith%25Char@smtp.gmail.com';
|
48
|
+
expect(shared.parseConnectionUrl(url)).to.deep.equal({
|
49
|
+
secure: true,
|
50
|
+
host: 'smtp.gmail.com',
|
51
|
+
auth: {
|
52
|
+
user: 'user@gmail.com',
|
53
|
+
pass: ':passwith%Char'
|
54
|
+
}
|
55
|
+
});
|
56
|
+
});
|
57
|
+
});
|
58
|
+
|
59
|
+
describe('Resolver tests', function () {
|
60
|
+
var port = 10337;
|
61
|
+
var server;
|
62
|
+
|
63
|
+
beforeEach(function (done) {
|
64
|
+
server = http.createServer(function (req, res) {
|
65
|
+
if (/redirect/.test(req.url)) {
|
66
|
+
res.writeHead(302, {
|
67
|
+
Location: 'http://localhost:' + port + '/message.html'
|
68
|
+
});
|
69
|
+
res.end('Go to http://localhost:' + port + '/message.html');
|
70
|
+
} else if (/compressed/.test(req.url)) {
|
71
|
+
res.writeHead(200, {
|
72
|
+
'Content-Type': 'text/plain',
|
73
|
+
'Content-Encoding': 'gzip'
|
74
|
+
});
|
75
|
+
var stream = zlib.createGzip();
|
76
|
+
stream.pipe(res);
|
77
|
+
stream.write('<p>Tere, tere</p><p>vana kere!</p>\n');
|
78
|
+
stream.end();
|
79
|
+
} else {
|
80
|
+
res.writeHead(200, {
|
81
|
+
'Content-Type': 'text/plain'
|
82
|
+
});
|
83
|
+
res.end('<p>Tere, tere</p><p>vana kere!</p>\n');
|
84
|
+
}
|
85
|
+
});
|
86
|
+
|
87
|
+
server.listen(port, done);
|
88
|
+
});
|
89
|
+
|
90
|
+
afterEach(function (done) {
|
91
|
+
server.close(done);
|
92
|
+
});
|
93
|
+
|
94
|
+
it('should set text from html string', function (done) {
|
95
|
+
var mail = {
|
96
|
+
data: {
|
97
|
+
html: '<p>Tere, tere</p><p>vana kere!</p>\n'
|
98
|
+
}
|
99
|
+
};
|
100
|
+
shared.resolveContent(mail.data, 'html', function (err, value) {
|
101
|
+
expect(err).to.not.exist;
|
102
|
+
expect(value).to.equal('<p>Tere, tere</p><p>vana kere!</p>\n');
|
103
|
+
done();
|
104
|
+
});
|
105
|
+
});
|
106
|
+
|
107
|
+
it('should set text from html buffer', function (done) {
|
108
|
+
var mail = {
|
109
|
+
data: {
|
110
|
+
html: new Buffer('<p>Tere, tere</p><p>vana kere!</p>\n')
|
111
|
+
}
|
112
|
+
};
|
113
|
+
shared.resolveContent(mail.data, 'html', function (err, value) {
|
114
|
+
expect(err).to.not.exist;
|
115
|
+
expect(value).to.deep.equal(mail.data.html);
|
116
|
+
done();
|
117
|
+
});
|
118
|
+
});
|
119
|
+
|
120
|
+
it('should set text from a html file', function (done) {
|
121
|
+
var mail = {
|
122
|
+
data: {
|
123
|
+
html: {
|
124
|
+
path: __dirname + '/fixtures/message.html'
|
125
|
+
}
|
126
|
+
}
|
127
|
+
};
|
128
|
+
shared.resolveContent(mail.data, 'html', function (err, value) {
|
129
|
+
expect(err).to.not.exist;
|
130
|
+
expect(value).to.deep.equal(new Buffer('<p>Tere, tere</p><p>vana kere!</p>\n'));
|
131
|
+
done();
|
132
|
+
});
|
133
|
+
});
|
134
|
+
|
135
|
+
it('should set text from an html url', function (done) {
|
136
|
+
var mail = {
|
137
|
+
data: {
|
138
|
+
html: {
|
139
|
+
path: 'http://localhost:' + port + '/message.html'
|
140
|
+
}
|
141
|
+
}
|
142
|
+
};
|
143
|
+
shared.resolveContent(mail.data, 'html', function (err, value) {
|
144
|
+
expect(err).to.not.exist;
|
145
|
+
expect(value).to.deep.equal(new Buffer('<p>Tere, tere</p><p>vana kere!</p>\n'));
|
146
|
+
done();
|
147
|
+
});
|
148
|
+
});
|
149
|
+
|
150
|
+
it('should set text from redirecting url', function (done) {
|
151
|
+
var mail = {
|
152
|
+
data: {
|
153
|
+
html: {
|
154
|
+
path: 'http://localhost:' + port + '/redirect.html'
|
155
|
+
}
|
156
|
+
}
|
157
|
+
};
|
158
|
+
shared.resolveContent(mail.data, 'html', function (err, value) {
|
159
|
+
expect(err).to.not.exist;
|
160
|
+
expect(value).to.deep.equal(new Buffer('<p>Tere, tere</p><p>vana kere!</p>\n'));
|
161
|
+
done();
|
162
|
+
});
|
163
|
+
});
|
164
|
+
|
165
|
+
it('should set text from gzipped url', function (done) {
|
166
|
+
var mail = {
|
167
|
+
data: {
|
168
|
+
html: {
|
169
|
+
path: 'http://localhost:' + port + '/compressed.html'
|
170
|
+
}
|
171
|
+
}
|
172
|
+
};
|
173
|
+
shared.resolveContent(mail.data, 'html', function (err, value) {
|
174
|
+
expect(err).to.not.exist;
|
175
|
+
expect(value).to.deep.equal(new Buffer('<p>Tere, tere</p><p>vana kere!</p>\n'));
|
176
|
+
done();
|
177
|
+
});
|
178
|
+
});
|
179
|
+
|
180
|
+
it('should set text from a html stream', function (done) {
|
181
|
+
var mail = {
|
182
|
+
data: {
|
183
|
+
html: fs.createReadStream(__dirname + '/fixtures/message.html')
|
184
|
+
}
|
185
|
+
};
|
186
|
+
shared.resolveContent(mail.data, 'html', function (err, value) {
|
187
|
+
expect(err).to.not.exist;
|
188
|
+
expect(mail).to.deep.equal({
|
189
|
+
data: {
|
190
|
+
html: new Buffer('<p>Tere, tere</p><p>vana kere!</p>\n')
|
191
|
+
}
|
192
|
+
});
|
193
|
+
expect(value).to.deep.equal(new Buffer('<p>Tere, tere</p><p>vana kere!</p>\n'));
|
194
|
+
done();
|
195
|
+
});
|
196
|
+
});
|
197
|
+
|
198
|
+
it('should return an error', function (done) {
|
199
|
+
var mail = {
|
200
|
+
data: {
|
201
|
+
html: {
|
202
|
+
path: 'http://localhost:' + (port + 1000) + '/message.html'
|
203
|
+
}
|
204
|
+
}
|
205
|
+
};
|
206
|
+
shared.resolveContent(mail.data, 'html', function (err) {
|
207
|
+
expect(err).to.exist;
|
208
|
+
done();
|
209
|
+
});
|
210
|
+
});
|
211
|
+
|
212
|
+
it('should return encoded string as buffer', function (done) {
|
213
|
+
var str = '<p>Tere, tere</p><p>vana kere!</p>\n';
|
214
|
+
var mail = {
|
215
|
+
data: {
|
216
|
+
html: {
|
217
|
+
encoding: 'base64',
|
218
|
+
content: new Buffer(str).toString('base64')
|
219
|
+
}
|
220
|
+
}
|
221
|
+
};
|
222
|
+
shared.resolveContent(mail.data, 'html', function (err, value) {
|
223
|
+
expect(err).to.not.exist;
|
224
|
+
expect(value).to.deep.equal(new Buffer(str));
|
225
|
+
done();
|
226
|
+
});
|
227
|
+
});
|
228
|
+
|
229
|
+
describe('data uri tests', function () {
|
230
|
+
|
231
|
+
it('should resolve with mime type and base64', function (done) {
|
232
|
+
var mail = {
|
233
|
+
data: {
|
234
|
+
attachment: {
|
235
|
+
path: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='
|
236
|
+
}
|
237
|
+
}
|
238
|
+
};
|
239
|
+
shared.resolveContent(mail.data, 'attachment', function (err, value) {
|
240
|
+
expect(err).to.not.exist;
|
241
|
+
expect(value).to.deep.equal(new Buffer('iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', 'base64'));
|
242
|
+
done();
|
243
|
+
});
|
244
|
+
});
|
245
|
+
|
246
|
+
it('should resolve with mime type and plaintext', function (done) {
|
247
|
+
var mail = {
|
248
|
+
data: {
|
249
|
+
attachment: {
|
250
|
+
path: 'data:image/png,tere%20tere'
|
251
|
+
}
|
252
|
+
}
|
253
|
+
};
|
254
|
+
shared.resolveContent(mail.data, 'attachment', function (err, value) {
|
255
|
+
expect(err).to.not.exist;
|
256
|
+
expect(value).to.deep.equal(new Buffer('tere tere'));
|
257
|
+
done();
|
258
|
+
});
|
259
|
+
});
|
260
|
+
|
261
|
+
it('should resolve with plaintext', function (done) {
|
262
|
+
var mail = {
|
263
|
+
data: {
|
264
|
+
attachment: {
|
265
|
+
path: 'data:,tere%20tere'
|
266
|
+
}
|
267
|
+
}
|
268
|
+
};
|
269
|
+
shared.resolveContent(mail.data, 'attachment', function (err, value) {
|
270
|
+
expect(err).to.not.exist;
|
271
|
+
expect(value).to.deep.equal(new Buffer('tere tere'));
|
272
|
+
done();
|
273
|
+
});
|
274
|
+
});
|
275
|
+
|
276
|
+
it('should resolve with mime type, charset and base64', function (done) {
|
277
|
+
var mail = {
|
278
|
+
data: {
|
279
|
+
attachment: {
|
280
|
+
path: 'data:image/png;charset=iso-8859-1;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='
|
281
|
+
}
|
282
|
+
}
|
283
|
+
};
|
284
|
+
shared.resolveContent(mail.data, 'attachment', function (err, value) {
|
285
|
+
expect(err).to.not.exist;
|
286
|
+
expect(value).to.deep.equal(new Buffer('iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', 'base64'));
|
287
|
+
done();
|
288
|
+
});
|
289
|
+
});
|
290
|
+
});
|
291
|
+
});
|
@@ -0,0 +1,59 @@
|
|
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
|
+
globals: {
|
57
|
+
Promise: false
|
58
|
+
}
|
59
|
+
};
|
@@ -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']
|
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
|
+
};
|