test-smtp-server 0.9.3 → 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.
@@ -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.match(/^127.0.0.1|::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,6 +1,6 @@
1
1
  {
2
2
  "name": "test-smtp-server",
3
- "version": "0.9.3",
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
6
  "types": "./build/lib/test-smtp-server.d.ts",
@@ -46,14 +46,14 @@
46
46
  "devDependencies": {
47
47
  "@types/nodemailer": "^6.4.4",
48
48
  "@types/smtp-server": "^3.5.7",
49
- "@typescript-eslint/eslint-plugin": "^5.26.0",
50
- "@typescript-eslint/parser": "^5.26.0",
51
- "commander": "^9.0.0",
52
- "eslint": "^8.2.0",
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
53
  "eslint-config-prettier": "^8.5.0",
54
- "eslint-plugin-jsdoc": "^39.3.2",
54
+ "eslint-plugin-jsdoc": "^39.3.3",
55
55
  "nodemailer": "^6.7.5",
56
- "typescript": "^4.7.2"
56
+ "typescript": "^4.7.4"
57
57
  },
58
58
  "dependencies": {
59
59
  "@types/mailparser": "^3.4.0",