mailauth 4.7.1 → 4.7.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.7.3](https://github.com/postalsys/mailauth/compare/v4.7.2...v4.7.3) (2024-10-21)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **BodyHashStream:** Skip header ([3da03d2](https://github.com/postalsys/mailauth/commit/3da03d23baa90acb119c7946c2cd740a72ba069d))
9
+
10
+ ## [4.7.2](https://github.com/postalsys/mailauth/compare/v4.7.1...v4.7.2) (2024-10-02)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **dkim:** Store byteLength in BodyHashStream ([081f823](https://github.com/postalsys/mailauth/commit/081f82340505d4beb88f12728919d851d35b6576))
16
+
3
17
  ## [4.7.1](https://github.com/postalsys/mailauth/compare/v4.7.0...v4.7.1) (2024-10-02)
4
18
 
5
19
 
@@ -3,7 +3,6 @@
3
3
  const { SimpleHash } = require('./simple');
4
4
  const { RelaxedHash } = require('./relaxed');
5
5
  const { Transform } = require('node:stream');
6
- const { MessageParser } = require('../message-parser');
7
6
 
8
7
  const dkimBody = (canonicalization, ...options) => {
9
8
  canonicalization = (canonicalization || 'simple/simple').toString().split('/').pop().toLowerCase().trim();
@@ -20,48 +19,15 @@ const dkimBody = (canonicalization, ...options) => {
20
19
  }
21
20
  };
22
21
 
23
- class MessageHasher extends MessageParser {
24
- constructor(canonicalization, ...options) {
25
- super();
26
- this.hasher = dkimBody(canonicalization, ...options);
27
- this.bodyHash = null;
28
- }
29
-
30
- async nextChunk(chunk) {
31
- this.hasher.update(chunk);
32
- }
33
-
34
- async finalChunk() {
35
- this.bodyHash = this.hasher.digest('base64');
36
- }
37
- }
38
-
39
22
  class BodyHashStream extends Transform {
40
23
  constructor(canonicalization, ...options) {
41
24
  super();
42
25
 
43
- this.finished = false;
44
- this.finishCb = null;
45
-
46
- this.messageHasher = new MessageHasher(canonicalization, ...options);
47
- this.bodyHash = null;
48
- this.messageHasher.once('finish', () => this.finishHashing());
49
- this.messageHasher.once('end', () => this.finishHashing());
50
- this.messageHasher.once('error', err => this.destroy(err));
51
- }
52
-
53
- finishHashing() {
54
- if (this.finished || !this.finishCb) {
55
- return;
56
- }
57
- this.finished = true;
58
- let done = this.finishCb;
59
- this.finishCb = null;
26
+ this.byteLength = 0;
60
27
 
61
- this.bodyHash = this.messageHasher.bodyHash;
62
- this.emit('hash', this.bodyHash);
28
+ this.hasher = dkimBody(canonicalization, ...options);
63
29
 
64
- done();
30
+ this.bodyHash = null;
65
31
  }
66
32
 
67
33
  _transform(chunk, encoding, done) {
@@ -73,18 +39,18 @@ class BodyHashStream extends Transform {
73
39
  chunk = Buffer.from(chunk, encoding);
74
40
  }
75
41
 
76
- if (this.messageHasher.write(chunk) === false) {
77
- // wait for drain
78
- return this.messageHasher.once('drain', done);
79
- }
42
+ this.byteLength += chunk.length;
80
43
 
44
+ this.hasher.update(chunk);
81
45
  this.push(chunk);
46
+
82
47
  done();
83
48
  }
84
49
 
85
50
  _flush(done) {
86
- this.finishCb = done;
87
- this.messageHasher.end();
51
+ this.bodyHash = this.hasher.digest('base64');
52
+ this.emit('hash', this.bodyHash);
53
+ done();
88
54
  }
89
55
  }
90
56
 
package/man/mailauth.1 CHANGED
@@ -1,4 +1,4 @@
1
- .TH "MAILAUTH" "1" "October 2024" "v4.7.1" "Mailauth Help"
1
+ .TH "MAILAUTH" "1" "October 2024" "v4.7.3" "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.7.1",
3
+ "version": "4.7.3",
4
4
  "description": "Email authentication library for Node.js",
5
5
  "main": "lib/mailauth.js",
6
6
  "scripts": {
@@ -52,7 +52,7 @@
52
52
  "libmime": "5.3.5",
53
53
  "nodemailer": "6.9.15",
54
54
  "punycode.js": "2.3.1",
55
- "tldts": "6.1.49",
55
+ "tldts": "6.1.52",
56
56
  "undici": "5.28.4",
57
57
  "yargs": "17.7.2"
58
58
  },