test-smtp-server 0.9.1 → 0.9.4

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/README.md CHANGED
@@ -60,7 +60,7 @@ import { testSmtpServer } from "test-smtp-server";
60
60
 
61
61
  ### Security
62
62
 
63
- The server is started as secure but that may not be possibly in the testing
63
+ The server is started as secure but that may not be possible in the testing
64
64
  environment. If the server does not have a valid certificate, the connection
65
65
  will fail from the client side. Some clients
66
66
  (e.g. nodemailer/SMTP-Transport options) allow connections to non-secure
@@ -26,6 +26,8 @@ export declare class eMail {
26
26
  export declare type testSmtpServerOptions = {
27
27
  /** the port number to use (default: 1025) */
28
28
  smtpPort?: number;
29
+ /** restrict ip addresses to localhost */
30
+ localhostOnly?: boolean;
29
31
  /** logging function like console.log() */
30
32
  debug?: (message?: unknown, ...optionalParams: any[]) => void;
31
33
  };
@@ -38,6 +40,7 @@ export declare class testSmtpServer {
38
40
  private debug;
39
41
  private emails;
40
42
  private isDebugging;
43
+ private localhostOnly;
41
44
  private port;
42
45
  private server;
43
46
  constructor(options?: testSmtpServerOptions | undefined);
@@ -50,11 +50,15 @@ class testSmtpServer {
50
50
  this.debug = (_message, ..._optionalParams) => { };
51
51
  this.emails = [];
52
52
  this.isDebugging = false;
53
+ this.localhostOnly = true;
53
54
  this.port = 1025;
54
55
  if (options) {
55
56
  if (options.smtpPort) {
56
57
  this.port = options.smtpPort;
57
58
  }
59
+ if (options.localhostOnly) {
60
+ this.localhostOnly = options.localhostOnly;
61
+ }
58
62
  if (options.debug) {
59
63
  this.debug = options.debug;
60
64
  }
@@ -64,7 +68,8 @@ class testSmtpServer {
64
68
  this.server = new smtp_server_1.SMTPServer({
65
69
  authOptional: true,
66
70
  onConnect(session, callback) {
67
- if (session.remoteAddress !== "127.0.0.1") {
71
+ // 172.17 prefix is a linux docker container
72
+ if (that.localhostOnly && !session.remoteAddress.match(/^172.17|127.0.0.1|::1$/)) {
68
73
  return callback(new Error("Only connections from localhost allowed"));
69
74
  }
70
75
  return callback(); // Accept the connection
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "test-smtp-server",
3
- "version": "0.9.1",
3
+ "version": "0.9.4",
4
4
  "description": "The test-smtp-server package allows internal testing of projects needing an SMTP server.",
5
5
  "main": "./build/lib/test-smtp-server.js",
6
- "xtype": "module",
7
6
  "types": "./build/lib/test-smtp-server.d.ts",
8
7
  "directories": {
9
8
  "lib": "lib",
@@ -47,19 +46,19 @@
47
46
  "devDependencies": {
48
47
  "@types/nodemailer": "^6.4.4",
49
48
  "@types/smtp-server": "^3.5.7",
50
- "@typescript-eslint/eslint-plugin": "^5.1.0",
51
- "@typescript-eslint/parser": "^5.1.0",
52
- "commander": "^8.3.0",
53
- "eslint": "^8.2.0",
54
- "eslint-config-prettier": "^8.3.0",
55
- "eslint-plugin-jsdoc": "^37.0.0",
56
- "nodemailer": "^6.7.0",
57
- "typescript": "^4.4.4"
49
+ "@typescript-eslint/eslint-plugin": "^5.29.0",
50
+ "@typescript-eslint/parser": "^5.29.0",
51
+ "commander": "^9.3.0",
52
+ "eslint": "^8.18.0",
53
+ "eslint-config-prettier": "^8.5.0",
54
+ "eslint-plugin-jsdoc": "^39.3.3",
55
+ "nodemailer": "^6.7.5",
56
+ "typescript": "^4.7.4"
58
57
  },
59
58
  "dependencies": {
60
59
  "@types/mailparser": "^3.4.0",
61
- "mailparser": "^3.4.0",
62
- "smtp-server": "^3.9.0"
60
+ "mailparser": "^3.5.0",
61
+ "smtp-server": "^3.11.0"
63
62
  },
64
63
  "engines": {
65
64
  "node": ">= 16.0.0"