@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.
- package/LICENSE +16 -0
- package/README.md +287 -0
- package/bin/maildev +13 -0
- package/dist/app/components/angular/angular.js +20282 -0
- package/dist/app/components/angular/angular.min.js +201 -0
- package/dist/app/components/angular/angular.min.js.map +8 -0
- package/dist/app/components/angular-cookies/angular-cookies.js +202 -0
- package/dist/app/components/angular-cookies/angular-cookies.min.js +8 -0
- package/dist/app/components/angular-cookies/angular-cookies.min.js.map +8 -0
- package/dist/app/components/angular-resource/angular-resource.js +546 -0
- package/dist/app/components/angular-resource/angular-resource.min.js +12 -0
- package/dist/app/components/angular-resource/angular-resource.min.js.map +8 -0
- package/dist/app/components/angular-route/angular-route.js +891 -0
- package/dist/app/components/angular-route/angular-route.min.js +14 -0
- package/dist/app/components/angular-route/angular-route.min.js.map +8 -0
- package/dist/app/components/angular-sanitize/angular-sanitize.js +615 -0
- package/dist/app/components/angular-sanitize/angular-sanitize.min.js +14 -0
- package/dist/app/components/angular-sanitize/angular-sanitize.min.js.map +8 -0
- package/dist/app/components/socket.io/socket.io.min.js +7 -0
- package/dist/app/favicon.ico +0 -0
- package/dist/app/index.html +176 -0
- package/dist/app/scripts/app.js +68 -0
- package/dist/app/scripts/components/address.js +15 -0
- package/dist/app/scripts/controllers/item.js +191 -0
- package/dist/app/scripts/controllers/main.js +259 -0
- package/dist/app/scripts/services.js +84 -0
- package/dist/app/styles/style.css +37 -0
- package/dist/app/views/address.html +3 -0
- package/dist/app/views/item.html +310 -0
- package/dist/app/views/main.html +18 -0
- package/dist/app/webfonts/fa-brands-400.eot +0 -0
- package/dist/app/webfonts/fa-brands-400.svg +3717 -0
- package/dist/app/webfonts/fa-brands-400.ttf +0 -0
- package/dist/app/webfonts/fa-brands-400.woff +0 -0
- package/dist/app/webfonts/fa-brands-400.woff2 +0 -0
- package/dist/app/webfonts/fa-regular-400.eot +0 -0
- package/dist/app/webfonts/fa-regular-400.svg +801 -0
- package/dist/app/webfonts/fa-regular-400.ttf +0 -0
- package/dist/app/webfonts/fa-regular-400.woff +0 -0
- package/dist/app/webfonts/fa-regular-400.woff2 +0 -0
- package/dist/app/webfonts/fa-solid-900.eot +0 -0
- package/dist/app/webfonts/fa-solid-900.svg +5028 -0
- package/dist/app/webfonts/fa-solid-900.ttf +0 -0
- package/dist/app/webfonts/fa-solid-900.woff +0 -0
- package/dist/app/webfonts/fa-solid-900.woff2 +0 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +50 -0
- package/dist/lib/auth.d.ts +4 -0
- package/dist/lib/auth.js +26 -0
- package/dist/lib/helpers/bcc.d.ts +5 -0
- package/dist/lib/helpers/bcc.js +16 -0
- package/dist/lib/helpers/smtp.d.ts +4 -0
- package/dist/lib/helpers/smtp.js +16 -0
- package/dist/lib/helpers/strtotime.d.ts +2 -0
- package/dist/lib/helpers/strtotime.js +1301 -0
- package/dist/lib/logger.d.ts +2 -0
- package/dist/lib/logger.js +30 -0
- package/dist/lib/mailbuffer.d.ts +21 -0
- package/dist/lib/mailbuffer.js +102 -0
- package/dist/lib/mailparser.d.ts +2 -0
- package/dist/lib/mailparser.js +253 -0
- package/dist/lib/mailserver.d.ts +115 -0
- package/dist/lib/mailserver.js +497 -0
- package/dist/lib/options.d.ts +3 -0
- package/dist/lib/options.js +150 -0
- package/dist/lib/outgoing.d.ts +40 -0
- package/dist/lib/outgoing.js +162 -0
- package/dist/lib/routes.d.ts +2 -0
- package/dist/lib/routes.js +139 -0
- package/dist/lib/type.d.ts +228 -0
- package/dist/lib/type.js +2 -0
- package/dist/lib/utils.d.ts +4 -0
- package/dist/lib/utils.js +65 -0
- package/dist/lib/web.d.ts +32 -0
- package/dist/lib/web.js +90 -0
- package/package.json +109 -0
package/dist/lib/web.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Web = void 0;
|
|
4
|
+
const routes_1 = require("./routes");
|
|
5
|
+
const express = require("express");
|
|
6
|
+
const cors = require("cors");
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const http = require("http");
|
|
9
|
+
const https = require("https");
|
|
10
|
+
const socketio = require("socket.io");
|
|
11
|
+
const auth = require("./auth");
|
|
12
|
+
const logger = require("./logger");
|
|
13
|
+
const path = require("path");
|
|
14
|
+
class Web {
|
|
15
|
+
constructor(mailserver, options) {
|
|
16
|
+
var _a, _b, _c, _d, _e;
|
|
17
|
+
/**
|
|
18
|
+
* Keep record of all connections to close them on shutdown
|
|
19
|
+
*/
|
|
20
|
+
this.connections = {};
|
|
21
|
+
const app = express();
|
|
22
|
+
this.protocol = (options === null || options === void 0 ? void 0 : options.ssl) ? "https" : "http";
|
|
23
|
+
this.port = (_a = options === null || options === void 0 ? void 0 : options.port) !== null && _a !== void 0 ? _a : 1080;
|
|
24
|
+
this.host = (_b = options === null || options === void 0 ? void 0 : options.host) !== null && _b !== void 0 ? _b : "0.0.0.0";
|
|
25
|
+
this.basePathname = (_c = options === null || options === void 0 ? void 0 : options.basePathname) !== null && _c !== void 0 ? _c : "/";
|
|
26
|
+
this.server = (options === null || options === void 0 ? void 0 : options.ssl)
|
|
27
|
+
? https.createServer({
|
|
28
|
+
key: fs.readFileSync(options === null || options === void 0 ? void 0 : options.ssl.key),
|
|
29
|
+
cert: fs.readFileSync(options === null || options === void 0 ? void 0 : options.ssl.cert),
|
|
30
|
+
}, app)
|
|
31
|
+
: http.createServer(app);
|
|
32
|
+
if (options === null || options === void 0 ? void 0 : options.auth) {
|
|
33
|
+
app.use(auth((_d = options === null || options === void 0 ? void 0 : options.auth) === null || _d === void 0 ? void 0 : _d.user, (_e = options === null || options === void 0 ? void 0 : options.auth) === null || _e === void 0 ? void 0 : _e.pass));
|
|
34
|
+
}
|
|
35
|
+
this.io = socketio({ path: path.posix.join(this.basePathname, "/socket.io") });
|
|
36
|
+
app.use(this.basePathname, express.static(path.join(__dirname, "../app")));
|
|
37
|
+
app.use(cors());
|
|
38
|
+
(0, routes_1.routes)(app, mailserver, this.basePathname);
|
|
39
|
+
this.io.attach(this.server);
|
|
40
|
+
this.io.on("connection", webSocketConnection(mailserver));
|
|
41
|
+
}
|
|
42
|
+
listen() {
|
|
43
|
+
const self = this;
|
|
44
|
+
this.server.on("connection", (socket) => {
|
|
45
|
+
const key = `${socket.remoteAddress}:${socket.remotePort}`;
|
|
46
|
+
self.connections[key] = socket;
|
|
47
|
+
socket.on("close", function () {
|
|
48
|
+
delete self.connections[key];
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
self.server.listen(self.port, self.host, () => {
|
|
53
|
+
logger.info(`MailDev webapp running at ${self.protocol}://${self.host}:${self.port}${self.basePathname}`);
|
|
54
|
+
resolve();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
close() {
|
|
59
|
+
const self = this;
|
|
60
|
+
closeConnections(this.connections);
|
|
61
|
+
return new Promise((resolve, reject) => {
|
|
62
|
+
self.io.close(resolve);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.Web = Web;
|
|
67
|
+
function closeConnections(connections) {
|
|
68
|
+
for (const key in connections) {
|
|
69
|
+
connections[key].destroy();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* WebSockets
|
|
74
|
+
*/
|
|
75
|
+
function webSocketConnection(mailserver) {
|
|
76
|
+
return function onConnection(socket) {
|
|
77
|
+
const newHandler = (mail) => {
|
|
78
|
+
socket.emit("newMail", mail);
|
|
79
|
+
};
|
|
80
|
+
const deleteHandler = (mail) => {
|
|
81
|
+
socket.emit("deleteMail", mail);
|
|
82
|
+
};
|
|
83
|
+
mailserver.on("new", newHandler);
|
|
84
|
+
mailserver.on("delete", deleteHandler);
|
|
85
|
+
socket.on("disconnect", () => {
|
|
86
|
+
mailserver.removeListener("new", newHandler);
|
|
87
|
+
mailserver.removeListener("delete", deleteHandler);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@timshel_npm/maildev",
|
|
3
|
+
"description": "SMTP Server and Web Interface for reading and testing emails during development",
|
|
4
|
+
"version": "3.1.1",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"email",
|
|
7
|
+
"e-mail",
|
|
8
|
+
"mail",
|
|
9
|
+
"maildev",
|
|
10
|
+
"mailcatcher",
|
|
11
|
+
"testing",
|
|
12
|
+
"development",
|
|
13
|
+
"smtp"
|
|
14
|
+
],
|
|
15
|
+
"author": "Timshel",
|
|
16
|
+
"homepage": "https://github.com/timshel/maildev",
|
|
17
|
+
"maintainers": [
|
|
18
|
+
{
|
|
19
|
+
"name": "Timshel",
|
|
20
|
+
"email": "timshel@users.noreply.github.com"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/timshel/maildev.git"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"clean": "rm -rf dist coverage tsconfig.tsbuildinfo",
|
|
29
|
+
"build": "tsc --build && npm run copy-app && npm run css",
|
|
30
|
+
"copy-app": "mkdir -p dist && cp -r ./src/app ./dist/ && rm -rf ./dist/app/styles",
|
|
31
|
+
"start": "npm run build && node ./bin/maildev",
|
|
32
|
+
"test": "prettier . -c && npm run build && nyc _mocha --exit --timeout 5000",
|
|
33
|
+
"test:debug": "npm run build && nyc _mocha --exit --timeout 5000",
|
|
34
|
+
"lint": "prettier . -c",
|
|
35
|
+
"lint:fix": "prettier . -w",
|
|
36
|
+
"dev": "node ./scripts/dev.js && npm run css-watch",
|
|
37
|
+
"css": "sass --style=compressed --no-source-map src/app/styles/style.scss:dist/app/styles/style.css",
|
|
38
|
+
"css-watch": "sass --watch --style=compressed --no-source-map src/app/styles/style.scss:dist/app/styles/style.css",
|
|
39
|
+
"docker-build": "./src/scripts/dockerBuild.sh",
|
|
40
|
+
"docker-run": "docker run --rm -p 1080:1080 -p 1025:1025 maildev/maildev:$npm_package_version",
|
|
41
|
+
"docker-push": "./src/scripts/dockerPush.sh",
|
|
42
|
+
"update-readme": "node ./src/scripts/updateUsageREADME.js",
|
|
43
|
+
"prepare": "npm run build"
|
|
44
|
+
},
|
|
45
|
+
"main": "dist/index.js",
|
|
46
|
+
"types": "dist/index.d.ts",
|
|
47
|
+
"files": [
|
|
48
|
+
"dist",
|
|
49
|
+
"README.md"
|
|
50
|
+
],
|
|
51
|
+
"bin": {
|
|
52
|
+
"maildev": "./bin/maildev"
|
|
53
|
+
},
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@types/mailparser": "^3.4.6",
|
|
57
|
+
"addressparser": "1.0.1",
|
|
58
|
+
"async": "^3.2.6",
|
|
59
|
+
"commander": "^12.1.0",
|
|
60
|
+
"compression": "^1.8.0",
|
|
61
|
+
"cors": "^2.8.5",
|
|
62
|
+
"dompurify": "^3.2.6",
|
|
63
|
+
"express": "^4.21.2",
|
|
64
|
+
"jsdom": "^24.1.3",
|
|
65
|
+
"mailparser": "^3.7.3",
|
|
66
|
+
"mime": "1.6.0",
|
|
67
|
+
"nodemailer": "^6.10.1",
|
|
68
|
+
"smtp-server": "^3.13.8",
|
|
69
|
+
"socket.io": "^4.8.1",
|
|
70
|
+
"wildstring": "1.0.9"
|
|
71
|
+
},
|
|
72
|
+
"overrides": {
|
|
73
|
+
"socket.io-adapter": "2.5.5"
|
|
74
|
+
},
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"@types/express": "^4.17.23",
|
|
77
|
+
"@types/node": "^18.19.111",
|
|
78
|
+
"expect": "^29.7.0",
|
|
79
|
+
"http-proxy-middleware": "^3.0.5",
|
|
80
|
+
"jest": "^29.7.0",
|
|
81
|
+
"jest-mock": "^29.7.0",
|
|
82
|
+
"mocha": "^10.8.2",
|
|
83
|
+
"nodemon": "^3.1.10",
|
|
84
|
+
"nyc": "^17.1.0",
|
|
85
|
+
"prettier": "^3.5.3",
|
|
86
|
+
"sass": "^1.89.1",
|
|
87
|
+
"ts-node": "^10.9.2",
|
|
88
|
+
"ts-node-dev": "^2.0.0",
|
|
89
|
+
"typescript": "^5.8.3"
|
|
90
|
+
},
|
|
91
|
+
"engines": {
|
|
92
|
+
"node": ">=18.0.0"
|
|
93
|
+
},
|
|
94
|
+
"nyc": {
|
|
95
|
+
"exclude": [
|
|
96
|
+
"test/**/*",
|
|
97
|
+
"src/lib/helpers/strtotime.js"
|
|
98
|
+
],
|
|
99
|
+
"ignore-class-method": "methodToIgnore",
|
|
100
|
+
"reporter": [
|
|
101
|
+
"json",
|
|
102
|
+
"lcov",
|
|
103
|
+
"text-summary"
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
"prettier": {
|
|
107
|
+
"printWidth": 100
|
|
108
|
+
}
|
|
109
|
+
}
|