New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mailauth

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mailauth - npm Package Compare versions

Comparing version 4.1.0 to 4.2.0

lib/dmarc/get-dmarc-record.js

68

lib/dmarc/verify.js

@@ -7,70 +7,4 @@ 'use strict';

const { formatAuthHeaderRow, getAlignment } = require('../tools');
const getDmarcRecord = require('./get-dmarc-record');
const resolveTxt = async (domain, resolver) => {
try {
let txt = await resolver(`_dmarc.${domain}`, 'TXT');
if (!txt || !txt.length) {
return false;
}
txt = txt.map(row => row.join('').trim()).filter(row => /^v=DMARC1\b/i.test(row));
if (txt.length !== 1) {
//no records or multiple records yield in no policy
return false;
}
return txt[0];
} catch (err) {
if (err.code === 'ENOTFOUND' || err.code === 'ENODATA') {
return false;
}
throw err;
}
};
const getDmarcRecord = async (domain, resolver) => {
let txt = await resolveTxt(domain, resolver);
let isOrgRecord = false;
if (!txt) {
let orgDomain = psl.get(domain);
if (orgDomain !== domain) {
// try org domain as well
txt = await resolveTxt(orgDomain, resolver);
isOrgRecord = true;
}
}
if (!txt) {
return false;
}
let parsed = Object.fromEntries(
txt
.split(';')
.map(e => e.trim())
.filter(e => e)
.map(e => {
let splitPos = e.indexOf('=');
if (splitPos < 0) {
return [e.toLowerCase().trim(), false];
} else if (splitPos === 0) {
return [false, e];
}
let key = e.substr(0, splitPos).toLowerCase().trim();
let val = e.substr(splitPos + 1);
if (['pct', 'ri'].includes(key)) {
val = parseInt(val, 10) || 0;
}
return [key, val];
})
);
parsed.rr = txt;
parsed.isOrgRecord = isOrgRecord;
return parsed;
};
const verifyDmarc = async opts => {

@@ -77,0 +11,0 @@ let { headerFrom, spfDomains, dkimDomains, resolver, arcResult } = opts;

@@ -1,12 +0,11 @@

name license type link installed version author
---- ------------ ---- ----------------- ------
@postalsys/vmc MIT https://registry.npmjs.org/@postalsys/vmc/-/vmc-1.0.6.tgz 1.0.6 Postal Systems OÜ
fast-xml-parser MIT git+https://github.com/NaturalIntelligence/fast-xml-parser.git 4.0.10 Amit Gupta (https://amitkumargupta.work/)
ipaddr.js MIT git://github.com/whitequark/ipaddr.js.git 2.0.1 whitequark <whitequark@whitequark.org>
joi BSD-3-Clause git://github.com/hapijs/joi.git 17.6.1 n/a
libmime MIT git://github.com/andris9/libmime.git 5.1.0 Andris Reinman <andris@kreata.ee>
node-forge (BSD-3-Clause OR GPL-2.0) git+https://github.com/digitalbazaar/forge.git 1.3.1 Digital Bazaar, Inc. support@digitalbazaar.com http://digitalbazaar.com/
nodemailer MIT git+https://github.com/nodemailer/nodemailer.git 6.7.8 Andris Reinman
psl MIT git+ssh://git@github.com/lupomontero/psl.git 1.9.0 Lupo Montero <lupomontero@gmail.com> (https://lupomontero.com/)
punycode MIT git+https://github.com/bestiejs/punycode.js.git 2.1.1 Mathias Bynens https://mathiasbynens.be/
yargs MIT git+https://github.com/yargs/yargs.git 17.5.1 n/a
name license type link installed version author
---- ------------ ---- ----------------- ------
@postalsys/vmc MIT https://registry.npmjs.org/@postalsys/vmc/-/vmc-1.0.6.tgz 1.0.6 Postal Systems OÜ
fast-xml-parser MIT git+https://github.com/NaturalIntelligence/fast-xml-parser.git 4.0.15 Amit Gupta (https://amitkumargupta.work/)
ipaddr.js MIT git://github.com/whitequark/ipaddr.js.git 2.0.1 whitequark <whitequark@whitequark.org>
joi BSD-3-Clause git://github.com/hapijs/joi.git 17.7.0 n/a
libmime MIT git://github.com/andris9/libmime.git 5.2.0 Andris Reinman <andris@kreata.ee>
nodemailer MIT git+https://github.com/nodemailer/nodemailer.git 6.9.0 Andris Reinman
psl MIT git+ssh://git@github.com/lupomontero/psl.git 1.9.0 Lupo Montero <lupomontero@gmail.com> (https://lupomontero.com/)
punycode MIT git+https://github.com/mathiasbynens/punycode.js.git 2.3.0 Mathias Bynens https://mathiasbynens.be/
yargs MIT git+https://github.com/yargs/yargs.git 17.6.2 n/a
{
"name": "mailauth",
"version": "4.1.0",
"version": "4.2.0",
"description": "Email authentication library for Node.js",

@@ -36,3 +36,3 @@ "main": "lib/mailauth.js",

"chai": "4.3.7",
"eslint": "8.32.0",
"eslint": "8.33.0",
"eslint-config-nodemailer": "1.2.0",

@@ -50,7 +50,7 @@ "eslint-config-prettier": "8.6.0",

"@postalsys/vmc": "1.0.6",
"fast-xml-parser": "4.0.15",
"fast-xml-parser": "4.1.1",
"ipaddr.js": "2.0.1",
"joi": "17.7.0",
"libmime": "5.2.0",
"nodemailer": "6.9.0",
"libmime": "5.2.1",
"nodemailer": "6.9.1",
"psl": "1.9.0",

@@ -57,0 +57,0 @@ "punycode": "2.3.0",

@@ -297,2 +297,35 @@ ![](https://github.com/postalsys/mailauth/raw/master/assets/mailauth.png)

## DMARC
DMARC is verified as part of the authentication process and even as the `dmarc` handler is exported, it requires input from previous steps.
### Helpers
#### getDmarcRecord
Returns parsed DMARC DNS record for a domain, or a subdomain
```
const getDmarcRecord = require('mailauth/lib/dmarc/get-dmarc-record');
const dmarcRecord = getDmarcRecord("ethereal.email");
console.log(dmarcRecord);
```
**Output**
```
{
v: 'DMARC1',
p: 'none',
pct: 100,
rua: 'mailto:re+joqy8fpatm3@dmarc.postmarkapp.com',
sp: 'none',
aspf: 'r',
rr: 'v=DMARC1; p=none; pct=100; rua=mailto:re+joqy8fpatm3@dmarc.postmarkapp.com; sp=none; aspf=r;',
isOrgRecord: false
}
```
`isOrgRecord` is `true` for sudomains, where organizational domain's DMARC policy applies, so use the `sp`, not `p` policy.
## BIMI

@@ -299,0 +332,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc