mailauth 4.7.2 → 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,12 @@
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
+
3
10
  ## [4.7.2](https://github.com/postalsys/mailauth/compare/v4.7.1...v4.7.2) (2024-10-02)
4
11
 
5
12
 
@@ -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,50 +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
26
  this.byteLength = 0;
47
27
 
48
- this.messageHasher = new MessageHasher(canonicalization, ...options);
49
- this.bodyHash = null;
50
- this.messageHasher.once('finish', () => this.finishHashing());
51
- this.messageHasher.once('end', () => this.finishHashing());
52
- this.messageHasher.once('error', err => this.destroy(err));
53
- }
54
-
55
- finishHashing() {
56
- if (this.finished || !this.finishCb) {
57
- return;
58
- }
59
- this.finished = true;
60
- let done = this.finishCb;
61
- this.finishCb = null;
62
-
63
- this.bodyHash = this.messageHasher.bodyHash;
64
- this.emit('hash', this.bodyHash);
28
+ this.hasher = dkimBody(canonicalization, ...options);
65
29
 
66
- done();
30
+ this.bodyHash = null;
67
31
  }
68
32
 
69
33
  _transform(chunk, encoding, done) {
@@ -77,19 +41,16 @@ class BodyHashStream extends Transform {
77
41
 
78
42
  this.byteLength += chunk.length;
79
43
 
44
+ this.hasher.update(chunk);
80
45
  this.push(chunk);
81
46
 
82
- if (this.messageHasher.write(chunk) === false) {
83
- // wait for drain
84
- return this.messageHasher.once('drain', done);
85
- }
86
-
87
47
  done();
88
48
  }
89
49
 
90
50
  _flush(done) {
91
- this.finishCb = done;
92
- this.messageHasher.end();
51
+ this.bodyHash = this.hasher.digest('base64');
52
+ this.emit('hash', this.bodyHash);
53
+ done();
93
54
  }
94
55
  }
95
56
 
package/man/mailauth.1 CHANGED
@@ -1,4 +1,4 @@
1
- .TH "MAILAUTH" "1" "October 2024" "v4.7.2" "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.2",
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
  },