mailauth 4.0.0 → 4.0.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/bin/mailauth.js CHANGED
@@ -324,6 +324,12 @@ const argv = yargs(hideBin(process.argv))
324
324
  type: 'string',
325
325
  description: 'Sending domain to validate',
326
326
  demandOption: false
327
+ })
328
+ .option('date', {
329
+ alias: 't',
330
+ type: 'string',
331
+ description: 'ISO formatted timestamp for the certificate expiration checks',
332
+ demandOption: false
327
333
  });
328
334
  },
329
335
  argv => {
package/lib/arc/index.js CHANGED
@@ -351,7 +351,6 @@ const arc = async (data, opts) => {
351
351
  if (result.authenticationResults.dkim && result.authenticationResults.dkim.length) {
352
352
  result.authenticationResults.dkim = result.authenticationResults.dkim.map(entry => {
353
353
  let result = entry.value;
354
-
355
354
  delete entry.value;
356
355
  return Object.assign({ result }, entry);
357
356
  });
package/lib/bimi/index.js CHANGED
@@ -240,7 +240,8 @@ const downloadPromise = (url, cachedFile) => {
240
240
  });
241
241
  };
242
242
 
243
- const validateVMC = async bimiData => {
243
+ const validateVMC = async (bimiData, opts) => {
244
+ opts = opts || {};
244
245
  if (!bimiData) {
245
246
  return false;
246
247
  }
@@ -302,7 +303,7 @@ const validateVMC = async bimiData => {
302
303
 
303
304
  if (authorityValue) {
304
305
  try {
305
- let vmcData = await vmc(authorityValue);
306
+ let vmcData = await vmc(authorityValue, opts);
306
307
 
307
308
  if (!vmcData.logoFile) {
308
309
  let error = new Error('VMC does not contain a log file');
@@ -2,6 +2,7 @@
2
2
 
3
3
  const { authenticate } = require('../mailauth');
4
4
  const fs = require('fs');
5
+ const { resolve } = require('dns').promises;
5
6
 
6
7
  const cmd = async argv => {
7
8
  let source = argv.email;
@@ -52,7 +53,7 @@ const cmd = async argv => {
52
53
  let match = dnsCache?.[name]?.[rr];
53
54
 
54
55
  if (argv.verbose) {
55
- console.error(`DNS query for ${rr} ${name}: ${match ? JSON.stringify(match) : 'not found'}`);
56
+ console.error(`DNS query for ${rr} ${name}: ${match ? JSON.stringify(match) : 'not found'} (using cache)`);
56
57
  }
57
58
 
58
59
  if (!match) {
@@ -63,6 +64,18 @@ const cmd = async argv => {
63
64
 
64
65
  return match;
65
66
  };
67
+ } else if (argv.verbose) {
68
+ opts.resolver = async (name, rr) => {
69
+ let match;
70
+ try {
71
+ match = await resolve(name, rr);
72
+ console.error(`DNS query for ${rr} ${name}: ${match ? JSON.stringify(match) : 'not found'}`);
73
+ return match;
74
+ } catch (err) {
75
+ console.error(`DNS query for ${rr} ${name}: ${err.message}${err.code ? ` [${err.code}]` : ''}`);
76
+ throw err;
77
+ }
78
+ };
66
79
  }
67
80
 
68
81
  let result = await authenticate(stream, opts);
@@ -3,6 +3,7 @@
3
3
  const { authenticate } = require('../mailauth');
4
4
  const fs = require('fs');
5
5
  const { GathererStream } = require('../gatherer-stream');
6
+ const { resolve } = require('dns').promises;
6
7
 
7
8
  const cmd = async argv => {
8
9
  let source = argv.email;
@@ -82,7 +83,7 @@ const cmd = async argv => {
82
83
  let match = dnsCache?.[name]?.[rr];
83
84
 
84
85
  if (argv.verbose) {
85
- console.error(`DNS query for ${rr} ${name}: ${match ? JSON.stringify(match) : 'not found'}`);
86
+ console.error(`DNS query for ${rr} ${name}: ${match ? JSON.stringify(match) : 'not found'} (using cache)`);
86
87
  }
87
88
 
88
89
  if (!match) {
@@ -93,6 +94,18 @@ const cmd = async argv => {
93
94
 
94
95
  return match;
95
96
  };
97
+ } else if (argv.verbose) {
98
+ opts.resolver = async (name, rr) => {
99
+ let match;
100
+ try {
101
+ match = await resolve(name, rr);
102
+ console.error(`DNS query for ${rr} ${name}: ${match ? JSON.stringify(match) : 'not found'}`);
103
+ return match;
104
+ } catch (err) {
105
+ console.error(`DNS query for ${rr} ${name}: ${err.message}${err.code ? ` [${err.code}]` : ''}`);
106
+ throw err;
107
+ }
108
+ };
96
109
  }
97
110
 
98
111
  let result = await authenticate(gatherer, opts);
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { spf } = require('../spf');
4
4
  const fs = require('fs');
5
- const dns = require('dns').promises;
5
+ const { resolve } = require('dns').promises;
6
6
 
7
7
  const cmd = async argv => {
8
8
  let address = argv.sender;
@@ -45,7 +45,7 @@ const cmd = async argv => {
45
45
  let match = dnsCache?.[name]?.[rr];
46
46
 
47
47
  if (argv.verbose) {
48
- console.error(`DNS query for ${rr} ${name}: ${match ? JSON.stringify(match) : 'not found'}`);
48
+ console.error(`DNS query for ${rr} ${name}: ${match ? JSON.stringify(match) : 'not found'} (using cache)`);
49
49
  }
50
50
 
51
51
  if (!match) {
@@ -56,29 +56,17 @@ const cmd = async argv => {
56
56
 
57
57
  return match;
58
58
  };
59
- } else {
59
+ } else if (argv.verbose) {
60
60
  opts.resolver = async (name, rr) => {
61
61
  let match;
62
62
  try {
63
- match = await dns.resolve(name, rr);
64
- } catch (err) {
65
- if (argv.verbose) {
66
- console.error(`DNS query for ${rr} ${name}: ${err.code || err.message}`);
67
- }
68
- throw err;
69
- }
70
-
71
- if (argv.verbose) {
63
+ match = await resolve(name, rr);
72
64
  console.error(`DNS query for ${rr} ${name}: ${match ? JSON.stringify(match) : 'not found'}`);
73
- }
74
-
75
- if (!match) {
76
- let err = new Error('Error');
77
- err.code = 'ENOTFOUND';
65
+ return match;
66
+ } catch (err) {
67
+ console.error(`DNS query for ${rr} ${name}: ${err.message}${err.code ? ` [${err.code}]` : ''}`);
78
68
  throw err;
79
69
  }
80
-
81
- return match;
82
70
  };
83
71
  }
84
72
 
@@ -18,7 +18,20 @@ const cmd = async argv => {
18
18
  bimiData.status = { header: { d: argv.domain } };
19
19
  }
20
20
 
21
- const result = await validateVMC(bimiData);
21
+ let opts = {};
22
+ if (argv.date) {
23
+ let date = new Date(argv.date);
24
+ if (date.toString() !== 'Invalid Date') {
25
+ opts.now = date;
26
+ if (argv.verbose) {
27
+ console.error(`Setting date to: ${argv.date}`);
28
+ }
29
+ } else if (argv.verbose) {
30
+ console.error(`Invalid date argument: ${argv.date}`);
31
+ }
32
+ }
33
+
34
+ const result = await validateVMC(bimiData, opts);
22
35
  process.stdout.write(JSON.stringify(result.authority, false, 2) + '\n');
23
36
  };
24
37
 
@@ -225,7 +225,7 @@ class DkimVerifier extends MessageParser {
225
225
  ? 'pass'
226
226
  : 'fail';
227
227
 
228
- if (status === 'fail') {
228
+ if (status.result === 'fail') {
229
229
  status.comment = 'bad signature';
230
230
  }
231
231
  } catch (err) {
package/man/mailauth.1 CHANGED
@@ -1,4 +1,4 @@
1
- .TH "MAILAUTH" "1" "July 2022" "v3.0.3" "Mailauth Help"
1
+ .TH "MAILAUTH" "1" "August 2022" "v4.0.1" "Mailauth Help"
2
2
  .SH "NAME"
3
3
  \fBmailauth\fR
4
4
  .QP
@@ -107,7 +107,10 @@ Colon separated list of header field names to sign\. (\fBsign\fP, \fBseal\fP)
107
107
  Return signing headers only\. By default, the entire message is printed to the console\. (\fBsign\fP, \fBseal\fP, \fBspf\fP)
108
108
  .IP \(bu 2
109
109
  \fB\-\-max\-lookups\fP, \fB\-x\fP
110
- How many DNS lookups allowed for SPF validation\. Defaults to 50\. (\fBreport\fP, \fBspf\fP)
110
+ How many DNS lookups allowed for SPF validation\. Defaults to 10\. (\fBreport\fP, \fBspf\fP)
111
+ .IP \(bu 2
112
+ \fB\-\-max\-void\-lookups\fP, \fB\-z\fP
113
+ How many empty DNS lookups allowed for SPF validation\. Defaults to 2\. (\fBreport\fP, \fBspf\fP)
111
114
 
112
115
  .RE
113
116
  .SH DNS CACHE
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailauth",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Email authentication library for Node.js",
5
5
  "main": "lib/mailauth.js",
6
6
  "scripts": {
@@ -33,7 +33,7 @@
33
33
  "homepage": "https://github.com/postalsys/mailauth",
34
34
  "devDependencies": {
35
35
  "chai": "4.3.6",
36
- "eslint": "8.20.0",
36
+ "eslint": "8.22.0",
37
37
  "eslint-config-nodemailer": "1.2.0",
38
38
  "eslint-config-prettier": "8.5.0",
39
39
  "js-yaml": "4.1.0",
@@ -45,13 +45,13 @@
45
45
  "pkg": "5.8.0"
46
46
  },
47
47
  "dependencies": {
48
- "@postalsys/vmc": "1.0.5",
48
+ "@postalsys/vmc": "1.0.6",
49
49
  "fast-xml-parser": "4.0.9",
50
50
  "ipaddr.js": "2.0.1",
51
51
  "joi": "17.6.0",
52
52
  "libmime": "5.1.0",
53
53
  "node-forge": "1.3.1",
54
- "nodemailer": "6.7.7",
54
+ "nodemailer": "6.7.8",
55
55
  "psl": "1.9.0",
56
56
  "punycode": "2.1.1",
57
57
  "yargs": "17.5.1"