mailauth 4.6.0 → 4.6.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/.ncurc.js ADDED
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ upgrade: true,
3
+ reject: [
4
+ 'marked',
5
+ 'marked-man',
6
+ // only works as ESM
7
+ 'chai',
8
+
9
+ // Fails in Node 16
10
+ 'undici'
11
+ ]
12
+ };
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.6.1](https://github.com/postalsys/mailauth/compare/v4.6.0...v4.6.1) (2024-01-24)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **dkim-verify:** Show the length of the source body in DKIM results ([d28663b](https://github.com/postalsys/mailauth/commit/d28663b30b0bfaf07d395e9d3eaea044c9085657))
9
+
3
10
  ## [4.6.0](https://github.com/postalsys/mailauth/compare/v4.5.2...v4.6.0) (2023-11-02)
4
11
 
5
12
 
@@ -26,9 +26,14 @@ class RelaxedHash {
26
26
  this.bodyHash = crypto.createHash(algorithm);
27
27
 
28
28
  this.remainder = false;
29
- this.byteLength = 0;
30
29
 
30
+ // total body size
31
+ this.byteLength = 0;
32
+ // total canonicalized body size
33
+ this.canonicalizedLength = 0;
34
+ // hashed canonicalized body size (after l= tag)
31
35
  this.bodyHashedBytes = 0;
36
+
32
37
  this.maxBodyLength = maxBodyLength;
33
38
 
34
39
  this.maxSizeReached = maxBodyLength === 0;
@@ -37,6 +42,8 @@ class RelaxedHash {
37
42
  }
38
43
 
39
44
  _updateBodyHash(chunk) {
45
+ this.canonicalizedLength += chunk.length;
46
+
40
47
  if (this.maxSizeReached) {
41
48
  return;
42
49
  }
@@ -18,8 +18,12 @@ class SimpleHash {
18
18
  this.bodyHash = crypto.createHash(algorithm);
19
19
 
20
20
  this.remainder = [];
21
- this.byteLength = 0;
22
21
 
22
+ // total body size
23
+ this.byteLength = 0;
24
+ // total canonicalized body size
25
+ this.canonicalizedLength = 0;
26
+ // hashed canonicalized body size (after l= tag)
23
27
  this.bodyHashedBytes = 0;
24
28
 
25
29
  this.maxBodyLength = maxBodyLength;
@@ -29,6 +33,8 @@ class SimpleHash {
29
33
  }
30
34
 
31
35
  _updateBodyHash(chunk) {
36
+ this.canonicalizedLength += chunk.length;
37
+
32
38
  if (this.maxSizeReached) {
33
39
  return;
34
40
  }
@@ -259,7 +259,9 @@ class DkimSigner extends MessageParser {
259
259
  // value for the l= tag (if needed)
260
260
  typeof signatureData.maxBodyLength === 'number'
261
261
  ? {
262
- bodyHashedBytes: this.bodyHashes.get(hashKey).hasher.bodyHashedBytes
262
+ bodyHashedBytes: this.bodyHashes.get(hashKey).hasher.bodyHashedBytes,
263
+ canonicalizedLength: this.bodyHashes.get(hashKey).hasher.canonicalizedLength,
264
+ sourceBodyLength: this.bodyHashes.get(hashKey).hasher.byteLength
263
265
  }
264
266
  : {}
265
267
  )
@@ -296,6 +296,8 @@ class DkimVerifier extends MessageParser {
296
296
  }
297
297
 
298
298
  signatureHeader.bodyHashedBytes = this.bodyHashes.get(signatureHeader.bodyHashKey)?.bodyHashedBytes;
299
+ signatureHeader.canonicalizedLength = this.bodyHashes.get(signatureHeader.bodyHashKey)?.canonicalizedLength;
300
+ signatureHeader.sourceBodyLength = this.bodyHashes.get(signatureHeader.bodyHashKey)?.byteLength;
299
301
 
300
302
  if (typeof signatureHeader.maxBodyLength === 'number' && signatureHeader.maxBodyLength !== signatureHeader.bodyHashedBytes) {
301
303
  status.result = 'fail';
@@ -314,12 +316,23 @@ class DkimVerifier extends MessageParser {
314
316
  status
315
317
  };
316
318
 
319
+ if (typeof signatureHeader.sourceBodyLength === 'number') {
320
+ result.sourceBodyLength = signatureHeader.sourceBodyLength;
321
+ }
322
+
317
323
  if (typeof signatureHeader.bodyHashedBytes === 'number') {
318
324
  result.canonBodyLength = signatureHeader.bodyHashedBytes;
319
325
  }
320
326
 
327
+ if (typeof signatureHeader.canonicalizedLength === 'number') {
328
+ result.canonBodyLengthTotal = signatureHeader.canonicalizedLength;
329
+ }
330
+
321
331
  if (typeof signatureHeader.maxBodyLength === 'number') {
322
- result.bodyLengthCount = signatureHeader.maxBodyLength;
332
+ result.canonBodyLengthLimited = true;
333
+ result.canonBodyLengthLimit = signatureHeader.maxBodyLength;
334
+ } else {
335
+ result.canonBodyLengthLimited = false;
323
336
  }
324
337
 
325
338
  if (publicKey) {
package/man/mailauth.1 CHANGED
@@ -1,4 +1,4 @@
1
- .TH "MAILAUTH" "1" "November 2023" "v4.6.0" "Mailauth Help"
1
+ .TH "MAILAUTH" "1" "January 2024" "v4.6.1" "Mailauth Help"
2
2
  .SH "NAME"
3
3
  \fBmailauth\fR
4
4
  .QP
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailauth",
3
- "version": "4.6.0",
3
+ "version": "4.6.1",
4
4
  "description": "Email authentication library for Node.js",
5
5
  "main": "lib/mailauth.js",
6
6
  "scripts": {
@@ -33,28 +33,29 @@
33
33
  },
34
34
  "homepage": "https://github.com/postalsys/mailauth",
35
35
  "devDependencies": {
36
- "chai": "4.3.10",
37
- "eslint": "8.52.0",
36
+ "chai": "4.4.1",
37
+ "eslint": "8.56.0",
38
38
  "eslint-config-nodemailer": "1.2.0",
39
- "eslint-config-prettier": "9.0.0",
39
+ "eslint-config-prettier": "9.1.0",
40
40
  "js-yaml": "4.1.0",
41
41
  "license-report": "6.5.0",
42
42
  "marked": "0.7.0",
43
43
  "marked-man": "0.7.0",
44
44
  "mbox-reader": "1.1.5",
45
45
  "mocha": "10.2.0",
46
+ "npm-check-updates": "16.14.12",
46
47
  "pkg": "5.8.1"
47
48
  },
48
49
  "dependencies": {
49
50
  "@postalsys/vmc": "1.0.6",
50
- "fast-xml-parser": "4.3.2",
51
+ "fast-xml-parser": "4.3.3",
51
52
  "ipaddr.js": "2.1.0",
52
- "joi": "17.11.0",
53
+ "joi": "17.12.0",
53
54
  "libmime": "5.2.1",
54
- "nodemailer": "6.9.7",
55
+ "nodemailer": "6.9.8",
55
56
  "psl": "1.9.0",
56
57
  "punycode": "2.3.1",
57
- "undici": "5.27.0",
58
+ "undici": "5.28.2",
58
59
  "yargs": "17.7.2"
59
60
  },
60
61
  "engines": {
package/.ncurc.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "upgrade": true,
3
- "reject": ["marked", "marked-man"]
4
- }