mailauth 4.6.8 → 4.6.9
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 +8 -0
- package/lib/dkim/body/relaxed.js +20 -8
- package/lib/dkim/dkim-verifier.js +1 -2
- package/man/mailauth.1 +1 -1
- package/package.json +6 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.6.9](https://github.com/postalsys/mailauth/compare/v4.6.8...v4.6.9) (2024-08-22)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **deps:** Removed uuid dependency in favor of crypto.randomUUID() ([0b5d8f5](https://github.com/postalsys/mailauth/commit/0b5d8f5328d0b82f75daea7fdbd74e1e76e8b642))
|
|
9
|
+
* **dkim-relaxed:** Faster DKIM hash calculation for relaxed body if the body contains extremely long lines ([fd8c89e](https://github.com/postalsys/mailauth/commit/fd8c89edd87a114464f99ebf79a1e903a8287876))
|
|
10
|
+
|
|
3
11
|
## [4.6.8](https://github.com/postalsys/mailauth/compare/v4.6.7...v4.6.8) (2024-06-04)
|
|
4
12
|
|
|
5
13
|
|
package/lib/dkim/body/relaxed.js
CHANGED
|
@@ -122,24 +122,36 @@ class RelaxedHash {
|
|
|
122
122
|
this._updateBodyHash(chunk);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Performs the following modifications for a single line:
|
|
127
|
+
* - Replace all <LF> chars with <CR><LF>
|
|
128
|
+
* - Replace all spaces and tabs with a single space.
|
|
129
|
+
* - Remove trailing whitespace
|
|
130
|
+
* @param {Buffer} line
|
|
131
|
+
* @returns {Buffer} fixed line
|
|
132
|
+
*/
|
|
125
133
|
fixLineBuffer(line) {
|
|
126
|
-
|
|
134
|
+
// Allocate maximum expected buffer length
|
|
135
|
+
// If the line is only filled with <LF> bytes then we need 2 times the size of the line
|
|
136
|
+
let lineBuf = Buffer.alloc(line.length * 2);
|
|
137
|
+
// Start processing the line from the end to beginning
|
|
138
|
+
let writePos = lineBuf.length - 1;
|
|
127
139
|
|
|
128
140
|
let nonWspFound = false;
|
|
129
141
|
let prevWsp = false;
|
|
130
142
|
|
|
131
143
|
for (let i = line.length - 1; i >= 0; i--) {
|
|
132
144
|
if (line[i] === CHAR_LF) {
|
|
133
|
-
|
|
145
|
+
lineBuf[writePos--] = line[i];
|
|
134
146
|
if (i === 0 || line[i - 1] !== CHAR_CR) {
|
|
135
147
|
// add missing carriage return
|
|
136
|
-
|
|
148
|
+
lineBuf[writePos--] = CHAR_CR;
|
|
137
149
|
}
|
|
138
150
|
continue;
|
|
139
151
|
}
|
|
140
152
|
|
|
141
153
|
if (line[i] === CHAR_CR) {
|
|
142
|
-
|
|
154
|
+
lineBuf[writePos--] = line[i];
|
|
143
155
|
continue;
|
|
144
156
|
}
|
|
145
157
|
|
|
@@ -151,19 +163,19 @@ class RelaxedHash {
|
|
|
151
163
|
}
|
|
152
164
|
|
|
153
165
|
if (prevWsp) {
|
|
154
|
-
|
|
166
|
+
lineBuf[writePos--] = CHAR_SPACE;
|
|
155
167
|
prevWsp = false;
|
|
156
168
|
}
|
|
157
169
|
|
|
158
170
|
nonWspFound = true;
|
|
159
|
-
|
|
171
|
+
lineBuf[writePos--] = line[i];
|
|
160
172
|
}
|
|
161
173
|
|
|
162
174
|
if (prevWsp && nonWspFound) {
|
|
163
|
-
|
|
175
|
+
lineBuf[writePos--] = CHAR_SPACE;
|
|
164
176
|
}
|
|
165
177
|
|
|
166
|
-
return
|
|
178
|
+
return lineBuf.subarray(writePos + 1);
|
|
167
179
|
}
|
|
168
180
|
|
|
169
181
|
update(chunk, final) {
|
|
@@ -8,7 +8,6 @@ const { generateCanonicalizedHeader } = require('./header');
|
|
|
8
8
|
const { getARChain } = require('../arc');
|
|
9
9
|
const addressparser = require('nodemailer/lib/addressparser');
|
|
10
10
|
const crypto = require('node:crypto');
|
|
11
|
-
const { v4: uuidv4 } = require('uuid');
|
|
12
11
|
const libmime = require('libmime');
|
|
13
12
|
|
|
14
13
|
class DkimVerifier extends MessageParser {
|
|
@@ -333,7 +332,7 @@ class DkimVerifier extends MessageParser {
|
|
|
333
332
|
let result = {
|
|
334
333
|
id: signatureHeader.parsed?.b?.value
|
|
335
334
|
? crypto.createHash('sha256').update(Buffer.from(signatureHeader.parsed?.b?.value, 'base64')).digest('hex')
|
|
336
|
-
:
|
|
335
|
+
: crypto.randomUUID(),
|
|
337
336
|
signingDomain: signatureHeader.signingDomain,
|
|
338
337
|
selector: signatureHeader.selector,
|
|
339
338
|
signature: signatureHeader.parsed?.b?.value,
|
package/man/mailauth.1
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mailauth",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.9",
|
|
4
4
|
"description": "Email authentication library for Node.js",
|
|
5
5
|
"main": "lib/mailauth.js",
|
|
6
6
|
"scripts": {
|
|
@@ -42,19 +42,18 @@
|
|
|
42
42
|
"marked": "0.7.0",
|
|
43
43
|
"marked-man": "0.7.0",
|
|
44
44
|
"mbox-reader": "1.2.0",
|
|
45
|
-
"mocha": "10.
|
|
45
|
+
"mocha": "10.7.3"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@postalsys/vmc": "1.0.8",
|
|
49
|
-
"fast-xml-parser": "4.4.
|
|
49
|
+
"fast-xml-parser": "4.4.1",
|
|
50
50
|
"ipaddr.js": "2.2.0",
|
|
51
|
-
"joi": "17.13.
|
|
51
|
+
"joi": "17.13.3",
|
|
52
52
|
"libmime": "5.3.5",
|
|
53
|
-
"nodemailer": "6.9.
|
|
53
|
+
"nodemailer": "6.9.14",
|
|
54
54
|
"punycode.js": "2.3.1",
|
|
55
|
-
"tldts": "6.1.
|
|
55
|
+
"tldts": "6.1.40",
|
|
56
56
|
"undici": "5.28.4",
|
|
57
|
-
"uuid": "9.0.1",
|
|
58
57
|
"yargs": "17.7.2"
|
|
59
58
|
},
|
|
60
59
|
"engines": {
|