mailauth 2.2.3 → 2.3.0
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/LICENSE.txt +1 -1
- package/README.md +1 -1
- package/cli.md +3 -1
- package/lib/dkim/dkim-verifier.js +12 -1
- package/lib/tools.js +41 -16
- package/licenses.txt +11 -11
- package/man/mailauth.1 +8 -4
- package/man/man.md +1 -1
- package/package.json +10 -9
package/LICENSE.txt
CHANGED
package/README.md
CHANGED
package/cli.md
CHANGED
|
@@ -17,10 +17,12 @@
|
|
|
17
17
|
Download `mailauth` for your platform:
|
|
18
18
|
|
|
19
19
|
- [MacOS](https://github.com/postalsys/mailauth/releases/latest/download/mailauth.pkg)
|
|
20
|
-
- [Linux](https://github.com/postalsys/mailauth/releases/latest/download/mailauth.gz)
|
|
20
|
+
- [Linux](https://github.com/postalsys/mailauth/releases/latest/download/mailauth.tar.gz)
|
|
21
21
|
- [Windows](https://github.com/postalsys/mailauth/releases/latest/download/mailauth.exe)
|
|
22
22
|
- Or install from the NPM registry: `npm install -g mailauth`
|
|
23
23
|
|
|
24
|
+
> **NB!** Downloadable files are quite large because these are packaged Node.js applications
|
|
25
|
+
|
|
24
26
|
## Help
|
|
25
27
|
|
|
26
28
|
```
|
|
@@ -172,7 +172,12 @@ class DkimVerifier extends MessageParser {
|
|
|
172
172
|
instance: ['ARC', 'AS'].includes(signatureHeader.type) ? signatureHeader.parsed?.i?.value : false
|
|
173
173
|
});
|
|
174
174
|
|
|
175
|
-
let
|
|
175
|
+
let signingHeaders = {
|
|
176
|
+
keys: signingHeaderLines.keys,
|
|
177
|
+
headers: signingHeaderLines.headers.map(l => l.line.toString())
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
let publicKey, rr, modulusLength;
|
|
176
181
|
let status = {
|
|
177
182
|
result: 'neutral',
|
|
178
183
|
comment: false,
|
|
@@ -208,6 +213,7 @@ class DkimVerifier extends MessageParser {
|
|
|
208
213
|
|
|
209
214
|
publicKey = res?.publicKey;
|
|
210
215
|
rr = res?.rr;
|
|
216
|
+
modulusLength = res?.modulusLength;
|
|
211
217
|
|
|
212
218
|
try {
|
|
213
219
|
status.result = crypto.verify(
|
|
@@ -283,6 +289,7 @@ class DkimVerifier extends MessageParser {
|
|
|
283
289
|
format: signatureHeader.parsed?.c?.value,
|
|
284
290
|
bodyHash,
|
|
285
291
|
bodyHashExpecting: signatureHeader.parsed?.bh?.value,
|
|
292
|
+
signingHeaders,
|
|
286
293
|
status
|
|
287
294
|
};
|
|
288
295
|
|
|
@@ -298,6 +305,10 @@ class DkimVerifier extends MessageParser {
|
|
|
298
305
|
result.publicKey = publicKey.toString();
|
|
299
306
|
}
|
|
300
307
|
|
|
308
|
+
if (modulusLength) {
|
|
309
|
+
result.modulusLength = modulusLength;
|
|
310
|
+
}
|
|
311
|
+
|
|
301
312
|
if (rr) {
|
|
302
313
|
result.rr = rr;
|
|
303
314
|
}
|
package/lib/tools.js
CHANGED
|
@@ -6,7 +6,6 @@ const punycode = require('punycode/');
|
|
|
6
6
|
const libmime = require('libmime');
|
|
7
7
|
const dns = require('dns').promises;
|
|
8
8
|
const crypto = require('crypto');
|
|
9
|
-
const pki = require('node-forge').pki;
|
|
10
9
|
const https = require('https');
|
|
11
10
|
const packageData = require('../package');
|
|
12
11
|
const parseDkimHeaders = require('./parse-dkim-headers');
|
|
@@ -15,6 +14,9 @@ const { Certificate } = require('@fidm/x509');
|
|
|
15
14
|
const zlib = require('zlib');
|
|
16
15
|
const util = require('util');
|
|
17
16
|
const gunzip = util.promisify(zlib.gunzip);
|
|
17
|
+
const pki = require('node-forge').pki;
|
|
18
|
+
const Joi = require('joi');
|
|
19
|
+
const base64Schema = Joi.string().base64({ paddingRequired: false });
|
|
18
20
|
|
|
19
21
|
const defaultDKIMFieldNames =
|
|
20
22
|
'From:Sender:Reply-To:Subject:Date:Message-ID:To:' +
|
|
@@ -247,14 +249,23 @@ const getPublicKey = async (type, name, minBitLength, resolver) => {
|
|
|
247
249
|
// prefix value for parsing as there is no default value
|
|
248
250
|
let entry = parseDkimHeaders(`DNS: TXT;${rr}`);
|
|
249
251
|
|
|
250
|
-
|
|
251
|
-
if (!
|
|
252
|
+
const publicKeyValue = entry?.parsed?.p?.value;
|
|
253
|
+
if (!publicKeyValue) {
|
|
252
254
|
let err = new Error('Missing key value');
|
|
253
255
|
err.code = 'EINVALIDVAL';
|
|
254
256
|
err.rr = rr;
|
|
255
257
|
throw err;
|
|
256
258
|
}
|
|
257
259
|
|
|
260
|
+
let validation = base64Schema.validate(publicKeyValue);
|
|
261
|
+
if (validation.error) {
|
|
262
|
+
let err = new Error('Invalid base64 format for public key');
|
|
263
|
+
err.code = 'EINVALIDVAL';
|
|
264
|
+
err.rr = rr;
|
|
265
|
+
err.details = validation.error;
|
|
266
|
+
throw err;
|
|
267
|
+
}
|
|
268
|
+
|
|
258
269
|
if (type === 'DKIM' && entry?.parsed?.v && (entry?.parsed?.v?.value || '').toString().toLowerCase().trim() !== 'dkim1') {
|
|
259
270
|
let err = new Error('Unknown key version');
|
|
260
271
|
err.code = 'EINVALIDVER';
|
|
@@ -262,28 +273,42 @@ const getPublicKey = async (type, name, minBitLength, resolver) => {
|
|
|
262
273
|
throw err;
|
|
263
274
|
}
|
|
264
275
|
|
|
265
|
-
|
|
266
|
-
|
|
276
|
+
const publicKeyPem = Buffer.from(`-----BEGIN PUBLIC KEY-----\n${publicKeyValue.replace(/.{64}/g, '$&\r\n')}\n-----END PUBLIC KEY-----`);
|
|
277
|
+
const publicKeyObj = crypto.createPublicKey({
|
|
278
|
+
key: publicKeyPem,
|
|
279
|
+
format: 'pem'
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
let keyType = publicKeyObj.asymmetricKeyType;
|
|
267
283
|
|
|
268
284
|
if (!['rsa', 'ed25519'].includes(keyType) || (entry?.parsed?.k && entry?.parsed?.k?.value?.toLowerCase() !== keyType)) {
|
|
269
|
-
let err = new Error('Unknown key type');
|
|
285
|
+
let err = new Error('Unknown key type (${keyType})');
|
|
270
286
|
err.code = 'EINVALIDTYPE';
|
|
271
287
|
err.rr = rr;
|
|
272
288
|
throw err;
|
|
273
289
|
}
|
|
274
290
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
291
|
+
let modulusLength;
|
|
292
|
+
if (publicKeyObj.asymmetricKeyDetails) {
|
|
293
|
+
modulusLength = publicKeyObj.asymmetricKeyDetails.modulusLength;
|
|
294
|
+
} else {
|
|
295
|
+
// fall back to node-forge
|
|
296
|
+
const pubKeyData = pki.publicKeyFromPem(publicKeyPem.toString());
|
|
297
|
+
modulusLength = pubKeyData.n.bitLength();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (keyType === 'rsa' && modulusLength < 1024) {
|
|
301
|
+
let err = new Error('RSA key too short');
|
|
302
|
+
err.code = 'ESHORTKEY';
|
|
303
|
+
err.rr = rr;
|
|
304
|
+
throw err;
|
|
284
305
|
}
|
|
285
306
|
|
|
286
|
-
return {
|
|
307
|
+
return {
|
|
308
|
+
publicKey: publicKeyPem,
|
|
309
|
+
rr,
|
|
310
|
+
modulusLength
|
|
311
|
+
};
|
|
287
312
|
}
|
|
288
313
|
|
|
289
314
|
let err = new Error('Missing key value');
|
package/licenses.txt
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
name license type link author
|
|
2
|
-
---- ------------ ---- ------
|
|
3
|
-
@fidm/x509 MIT git+ssh://git@github.com/fidm/x509.git n/a
|
|
4
|
-
ipaddr.js MIT git://github.com/whitequark/ipaddr.js.git whitequark
|
|
5
|
-
joi BSD-3-Clause git://github.com/sideway/joi.git n/a
|
|
6
|
-
libmime MIT git://github.com/andris9/libmime.git Andris Reinman
|
|
7
|
-
node-forge (BSD-3-Clause OR GPL-2.0) git+https://github.com/digitalbazaar/forge.git Digital Bazaar, Inc.
|
|
8
|
-
nodemailer MIT git+https://github.com/nodemailer/nodemailer.git Andris Reinman
|
|
9
|
-
psl MIT git+ssh://git@github.com/lupomontero/psl.git Lupo Montero
|
|
10
|
-
punycode MIT git+https://github.com/bestiejs/punycode.js.git Mathias Bynens
|
|
11
|
-
yargs MIT git+https://github.com/yargs/yargs.git n/a
|
|
1
|
+
name license type link installed version author
|
|
2
|
+
---- ------------ ---- ----------------- ------
|
|
3
|
+
@fidm/x509 MIT git+ssh://git@github.com/fidm/x509.git 1.2.1 n/a
|
|
4
|
+
ipaddr.js MIT git://github.com/whitequark/ipaddr.js.git 2.0.1 whitequark
|
|
5
|
+
joi BSD-3-Clause git://github.com/sideway/joi.git 17.5.0 n/a
|
|
6
|
+
libmime MIT git://github.com/andris9/libmime.git 5.0.0 Andris Reinman
|
|
7
|
+
node-forge (BSD-3-Clause OR GPL-2.0) git+https://github.com/digitalbazaar/forge.git 1.2.1 Digital Bazaar, Inc.
|
|
8
|
+
nodemailer MIT git+https://github.com/nodemailer/nodemailer.git 6.7.2 Andris Reinman
|
|
9
|
+
psl MIT git+ssh://git@github.com/lupomontero/psl.git 1.8.0 Lupo Montero
|
|
10
|
+
punycode MIT git+https://github.com/bestiejs/punycode.js.git 2.1.1 Mathias Bynens
|
|
11
|
+
yargs MIT git+https://github.com/yargs/yargs.git 17.3.1 n/a
|
package/man/mailauth.1
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.TH "MAILAUTH" "1" "
|
|
1
|
+
.TH "MAILAUTH" "1" "January 2022" "v2.3.0" "Mailauth Help"
|
|
2
2
|
.SH "NAME"
|
|
3
3
|
\fBmailauth\fR
|
|
4
4
|
.QP
|
|
@@ -33,9 +33,13 @@ Authenticates an email and seals it with an ARC digital signature
|
|
|
33
33
|
\fBspf\fR
|
|
34
34
|
.br
|
|
35
35
|
Authenticates SPF for an IP address and email address
|
|
36
|
+
.P
|
|
37
|
+
\fBlicense\fR
|
|
38
|
+
.br
|
|
39
|
+
Display licenses for mailauth and included modules
|
|
36
40
|
.SH Website
|
|
37
41
|
.P
|
|
38
|
-
\fIhttps://github\.com/
|
|
42
|
+
\fIhttps://github\.com/postalsys/mailauth\fR
|
|
39
43
|
.SH EXAMPLES
|
|
40
44
|
.P
|
|
41
45
|
\fBnpm install mailauth \-g\fP
|
|
@@ -128,10 +132,10 @@ For cached DNS requests use the following JSON structure where main keys are dom
|
|
|
128
132
|
Longer TXT strings can be split into multiple strings\. Unlike in real DNS there is no length limit, so you can put the entire public key into a single string\.
|
|
129
133
|
.SH BUGS
|
|
130
134
|
.P
|
|
131
|
-
Please report any bugs to https://github\.com/
|
|
135
|
+
Please report any bugs to https://github\.com/postalsys/mailauth/issues\.
|
|
132
136
|
.SH LICENSE
|
|
133
137
|
.P
|
|
134
|
-
Copyright (c) 2020,
|
|
138
|
+
Copyright (c) 2020\-2022, Postal Systems (MIT)\.
|
|
135
139
|
.SH SEE ALSO
|
|
136
140
|
.P
|
|
137
141
|
node\.js(1)
|
package/man/man.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mailauth",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Email authentication library for Node.js",
|
|
5
5
|
"main": "lib/mailauth.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"homepage": "https://github.com/postalsys/mailauth",
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"chai": "4.3.4",
|
|
35
|
-
"eslint": "8.
|
|
35
|
+
"eslint": "8.7.0",
|
|
36
36
|
"eslint-config-nodemailer": "1.2.0",
|
|
37
37
|
"eslint-config-prettier": "8.3.0",
|
|
38
38
|
"js-yaml": "4.1.0",
|
|
@@ -40,19 +40,19 @@
|
|
|
40
40
|
"marked": "0.7.0",
|
|
41
41
|
"marked-man": "0.7.0",
|
|
42
42
|
"mbox-reader": "1.1.5",
|
|
43
|
-
"mocha": "9.1.
|
|
44
|
-
"pkg": "5.
|
|
43
|
+
"mocha": "9.1.4",
|
|
44
|
+
"pkg": "5.5.2"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@fidm/x509": "1.2.1",
|
|
48
48
|
"ipaddr.js": "2.0.1",
|
|
49
|
-
"joi": "17.
|
|
49
|
+
"joi": "17.5.0",
|
|
50
50
|
"libmime": "5.0.0",
|
|
51
|
-
"node-forge": "
|
|
52
|
-
"nodemailer": "6.7.
|
|
51
|
+
"node-forge": "1.2.1",
|
|
52
|
+
"nodemailer": "6.7.2",
|
|
53
53
|
"psl": "1.8.0",
|
|
54
54
|
"punycode": "2.1.1",
|
|
55
|
-
"yargs": "17.
|
|
55
|
+
"yargs": "17.3.1"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=14.0.0"
|
|
@@ -69,7 +69,8 @@
|
|
|
69
69
|
],
|
|
70
70
|
"assets": [
|
|
71
71
|
"man/**/*",
|
|
72
|
-
"licenses.txt"
|
|
72
|
+
"licenses.txt",
|
|
73
|
+
"LICENSE.txt"
|
|
73
74
|
],
|
|
74
75
|
"_targets": [
|
|
75
76
|
"node16-macos-x64"
|