@timshel_npm/maildev 3.1.1

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.
Files changed (76) hide show
  1. package/LICENSE +16 -0
  2. package/README.md +287 -0
  3. package/bin/maildev +13 -0
  4. package/dist/app/components/angular/angular.js +20282 -0
  5. package/dist/app/components/angular/angular.min.js +201 -0
  6. package/dist/app/components/angular/angular.min.js.map +8 -0
  7. package/dist/app/components/angular-cookies/angular-cookies.js +202 -0
  8. package/dist/app/components/angular-cookies/angular-cookies.min.js +8 -0
  9. package/dist/app/components/angular-cookies/angular-cookies.min.js.map +8 -0
  10. package/dist/app/components/angular-resource/angular-resource.js +546 -0
  11. package/dist/app/components/angular-resource/angular-resource.min.js +12 -0
  12. package/dist/app/components/angular-resource/angular-resource.min.js.map +8 -0
  13. package/dist/app/components/angular-route/angular-route.js +891 -0
  14. package/dist/app/components/angular-route/angular-route.min.js +14 -0
  15. package/dist/app/components/angular-route/angular-route.min.js.map +8 -0
  16. package/dist/app/components/angular-sanitize/angular-sanitize.js +615 -0
  17. package/dist/app/components/angular-sanitize/angular-sanitize.min.js +14 -0
  18. package/dist/app/components/angular-sanitize/angular-sanitize.min.js.map +8 -0
  19. package/dist/app/components/socket.io/socket.io.min.js +7 -0
  20. package/dist/app/favicon.ico +0 -0
  21. package/dist/app/index.html +176 -0
  22. package/dist/app/scripts/app.js +68 -0
  23. package/dist/app/scripts/components/address.js +15 -0
  24. package/dist/app/scripts/controllers/item.js +191 -0
  25. package/dist/app/scripts/controllers/main.js +259 -0
  26. package/dist/app/scripts/services.js +84 -0
  27. package/dist/app/styles/style.css +37 -0
  28. package/dist/app/views/address.html +3 -0
  29. package/dist/app/views/item.html +310 -0
  30. package/dist/app/views/main.html +18 -0
  31. package/dist/app/webfonts/fa-brands-400.eot +0 -0
  32. package/dist/app/webfonts/fa-brands-400.svg +3717 -0
  33. package/dist/app/webfonts/fa-brands-400.ttf +0 -0
  34. package/dist/app/webfonts/fa-brands-400.woff +0 -0
  35. package/dist/app/webfonts/fa-brands-400.woff2 +0 -0
  36. package/dist/app/webfonts/fa-regular-400.eot +0 -0
  37. package/dist/app/webfonts/fa-regular-400.svg +801 -0
  38. package/dist/app/webfonts/fa-regular-400.ttf +0 -0
  39. package/dist/app/webfonts/fa-regular-400.woff +0 -0
  40. package/dist/app/webfonts/fa-regular-400.woff2 +0 -0
  41. package/dist/app/webfonts/fa-solid-900.eot +0 -0
  42. package/dist/app/webfonts/fa-solid-900.svg +5028 -0
  43. package/dist/app/webfonts/fa-solid-900.ttf +0 -0
  44. package/dist/app/webfonts/fa-solid-900.woff +0 -0
  45. package/dist/app/webfonts/fa-solid-900.woff2 +0 -0
  46. package/dist/index.d.ts +26 -0
  47. package/dist/index.js +50 -0
  48. package/dist/lib/auth.d.ts +4 -0
  49. package/dist/lib/auth.js +26 -0
  50. package/dist/lib/helpers/bcc.d.ts +5 -0
  51. package/dist/lib/helpers/bcc.js +16 -0
  52. package/dist/lib/helpers/smtp.d.ts +4 -0
  53. package/dist/lib/helpers/smtp.js +16 -0
  54. package/dist/lib/helpers/strtotime.d.ts +2 -0
  55. package/dist/lib/helpers/strtotime.js +1301 -0
  56. package/dist/lib/logger.d.ts +2 -0
  57. package/dist/lib/logger.js +30 -0
  58. package/dist/lib/mailbuffer.d.ts +21 -0
  59. package/dist/lib/mailbuffer.js +102 -0
  60. package/dist/lib/mailparser.d.ts +2 -0
  61. package/dist/lib/mailparser.js +253 -0
  62. package/dist/lib/mailserver.d.ts +115 -0
  63. package/dist/lib/mailserver.js +497 -0
  64. package/dist/lib/options.d.ts +3 -0
  65. package/dist/lib/options.js +150 -0
  66. package/dist/lib/outgoing.d.ts +40 -0
  67. package/dist/lib/outgoing.js +162 -0
  68. package/dist/lib/routes.d.ts +2 -0
  69. package/dist/lib/routes.js +139 -0
  70. package/dist/lib/type.d.ts +228 -0
  71. package/dist/lib/type.js +2 -0
  72. package/dist/lib/utils.d.ts +4 -0
  73. package/dist/lib/utils.js +65 -0
  74. package/dist/lib/web.d.ts +32 -0
  75. package/dist/lib/web.js +90 -0
  76. package/package.json +109 -0
@@ -0,0 +1,26 @@
1
+ /**
2
+ * MailDev - index
3
+ *
4
+ * Author: Dan Farrelly <daniel.j.farrelly@gmail.com>
5
+ * Licensed under the MIT License.
6
+ */
7
+ import type { MailServerOptions } from "./lib/mailserver";
8
+ import type { WebOptions } from "./lib/web";
9
+ import { MailServer } from "./lib/mailserver";
10
+ import { Web } from "./lib/web";
11
+ export interface MailDevOptions extends MailServerOptions {
12
+ verbose?: boolean;
13
+ silent?: boolean;
14
+ logMailContents?: boolean;
15
+ web?: MailDevWebOptions;
16
+ }
17
+ interface MailDevWebOptions extends WebOptions {
18
+ disabled?: boolean;
19
+ }
20
+ export declare class MailDev extends MailServer {
21
+ web: Web | undefined;
22
+ constructor(config?: MailDevOptions, mailEventSubjectMapper?: (Mail: any) => string | undefined);
23
+ listen(): Promise<any>;
24
+ close(): Promise<any>;
25
+ }
26
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MailDev = void 0;
4
+ const mailserver_1 = require("./lib/mailserver");
5
+ const web_1 = require("./lib/web");
6
+ const async = require("async");
7
+ const logger = require("./lib/logger");
8
+ class MailDev extends mailserver_1.MailServer {
9
+ constructor(config, mailEventSubjectMapper) {
10
+ var _a, _b, _c;
11
+ if (config === null || config === void 0 ? void 0 : config.verbose) {
12
+ logger.setLevel(2);
13
+ }
14
+ else if (config === null || config === void 0 ? void 0 : config.silent) {
15
+ logger.setLevel(0);
16
+ }
17
+ // Start the Mailserver
18
+ super(config, mailEventSubjectMapper);
19
+ // Start the web server
20
+ if (!((_a = config === null || config === void 0 ? void 0 : config.web) === null || _a === void 0 ? void 0 : _a.disabled)) {
21
+ // Default to run on same IP as smtp
22
+ const host = ((_b = config === null || config === void 0 ? void 0 : config.web) === null || _b === void 0 ? void 0 : _b.host) ? (_c = config === null || config === void 0 ? void 0 : config.web) === null || _c === void 0 ? void 0 : _c.host : config === null || config === void 0 ? void 0 : config.host;
23
+ this.web = new web_1.Web(this, Object.assign(Object.assign({}, config === null || config === void 0 ? void 0 : config.web), { host }));
24
+ }
25
+ if (config === null || config === void 0 ? void 0 : config.logMailContents) {
26
+ this.on("new", function (mail) {
27
+ const mailContents = JSON.stringify(mail, null, 2);
28
+ logger.info(`Received the following mail contents:\n${mailContents}`);
29
+ });
30
+ }
31
+ process.on("SIGTERM", this.close.bind(this));
32
+ process.on("SIGINT", this.close.bind(this));
33
+ }
34
+ listen() {
35
+ const p = [super.listen()];
36
+ if (this.web) {
37
+ p.push(this.web.listen());
38
+ }
39
+ return Promise.all(p);
40
+ }
41
+ close() {
42
+ logger.info("Received shutdown signal, shutting down now...");
43
+ const p = [super.close()];
44
+ if (this.web) {
45
+ p.push(this.web.close());
46
+ }
47
+ return Promise.all(p);
48
+ }
49
+ }
50
+ exports.MailDev = MailDev;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * MailDev - auth.js
3
+ */
4
+ export declare function auth(user: string, password: string): (req: any, res: any, next: any) => any;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.auth = auth;
4
+ /**
5
+ * MailDev - auth.js
6
+ */
7
+ function auth(user, password) {
8
+ return function (req, res, next) {
9
+ // allow health checks without auth
10
+ if (req.path === "/healthz") {
11
+ return next();
12
+ }
13
+ let auth;
14
+ if (req.headers.authorization) {
15
+ auth = Buffer.from(req.headers.authorization.substring(6), "base64").toString().split(":");
16
+ }
17
+ if (!auth || auth[0] !== user || auth[1] !== password) {
18
+ res.statusCode = 401;
19
+ res.setHeader("WWW-Authenticate", 'Basic realm="Authentication required"');
20
+ res.send("Unauthorized");
21
+ }
22
+ else {
23
+ next();
24
+ }
25
+ };
26
+ }
@@ -0,0 +1,5 @@
1
+ import type { EmailAddress } from "../type";
2
+ /**
3
+ * Filter out addresses from recipients, the remaining are the bcc.
4
+ */
5
+ export declare function calculateBcc(recipients: EmailAddress[], to: EmailAddress[], cc: EmailAddress[]): EmailAddress[];
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateBcc = calculateBcc;
4
+ /**
5
+ * Filter out addresses from recipients, the remaining are the bcc.
6
+ */
7
+ function calculateBcc(recipients, to, cc) {
8
+ const bcc = [...recipients];
9
+ to.concat(cc).forEach((ea) => {
10
+ const index = bcc.findIndex((e) => ea.address === e.address);
11
+ if (index > -1) {
12
+ bcc.splice(index, 1);
13
+ }
14
+ });
15
+ return bcc;
16
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Authorize callback for smtp server
3
+ */
4
+ export declare function createOnAuthCallback(username: string | undefined, password: string | undefined): (auth: any, session: any, callback: any) => any;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createOnAuthCallback = createOnAuthCallback;
4
+ /**
5
+ * Authorize callback for smtp server
6
+ */
7
+ function createOnAuthCallback(username, password) {
8
+ return function onAuth(auth, session, callback) {
9
+ if (auth.username && auth.password) {
10
+ if (auth.username !== username || auth.password !== password) {
11
+ return callback(new Error("Invalid username or password"));
12
+ }
13
+ }
14
+ callback(null, { user: username });
15
+ };
16
+ }
@@ -0,0 +1,2 @@
1
+ declare function _exports(str: any, now: any): number | false;
2
+ export = _exports;