Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
fix: switched DKIM verification packages due to user reported issues
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Dec 3, 2019
1 parent 7606f3a commit b36f8d9
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 17 deletions.
1 change: 0 additions & 1 deletion .env.defaults
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
NODE_ENV=development
SECURE=false
IS_SILENT=false
SMTP_PORT=25
SMTP_SSL_KEY_PATH=
Expand Down
1 change: 0 additions & 1 deletion .env.schema
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
NODE_ENV=
SECURE=
IS_SILENT=
SMTP_PORT=
SMTP_SSL_KEY_PATH=
Expand Down
3 changes: 0 additions & 3 deletions ecosystem.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"instances": "max",
"env_production": {
"NODE_ENV": "production",
"IS_SILENT": true,
"SMTP_PORT": "3025"
}
},
Expand All @@ -20,7 +19,6 @@
"instances": "max",
"env_production": {
"NODE_ENV": "production",
"IS_SILENT": true,
"SMTP_PORT": "3465"
}
},
Expand All @@ -32,7 +30,6 @@
"instances": "max",
"env_production": {
"NODE_ENV": "production",
"IS_SILENT": true,
"SMTP_PORT": "3587"
}
}
Expand Down
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const _ = require('lodash');
const addressParser = require('nodemailer/lib/addressparser');
const arrayJoinConjunction = require('array-join-conjunction');
const bytes = require('bytes');
const dkimVerify = require('python-dkim-verify');
const NodeDKIM = require('dkim');
const dmarcParse = require('dmarc-parse');
const dnsbl = require('dnsbl');
const domains = require('disposable-email-domains');
Expand All @@ -31,6 +31,8 @@ const { oneLine } = require('common-tags');

let mailUtilities = require('mailin/lib/mailUtilities.js');

const verifyDKIM = util.promisify(NodeDKIM.verify).bind(NodeDKIM);

const {
CustomError,
MessageSplitter,
Expand Down Expand Up @@ -811,8 +813,10 @@ class ForwardEmail {

async validateDKIM(raw) {
try {
const result = await dkimVerify(raw);
return result;
const result = await verifyDKIM(raw);
return (
result && result.length > 0 && result.every(record => record.verified)
);
} catch (err) {
logger.error(err);
err.responseCode = 421;
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"parse-domain": "^2.3.4",
"pino": "^5.14.0",
"punycode": "^2.1.1",
"python-dkim-verify": "^0.0.3",
"python-spfcheck2": "^0.0.4",
"ratelimiter": "^3.4.0",
"signale": "^1.4.0",
Expand Down
8 changes: 0 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7421,14 +7421,6 @@ punycode@^2.1.0, punycode@^2.1.1:
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==

python-dkim-verify@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/python-dkim-verify/-/python-dkim-verify-0.0.3.tgz#f4be4838e37ca68f57c85916eabbcc30e408ca8e"
integrity sha512-CO7wHtQ4tztZ9qfR40NyRUqGwlHbyV4Pj9iYVKTeHz32zijZQDp3ZmM5f+Xx9KO8nv6qTEcP81kBqU1VoH3d6w==
dependencies:
semver "^6.3.0"
shelljs "^0.8.3"

python-spfcheck2@^0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/python-spfcheck2/-/python-spfcheck2-0.0.4.tgz#06b33c1105eb744ab955b63fee1927924c475f00"
Expand Down

0 comments on commit b36f8d9

Please sign in to comment.