mailauth 4.5.1 → 4.6.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/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## [4.6.0](https://github.com/postalsys/mailauth/compare/v4.5.2...v4.6.0) (2023-11-02)
4
+
5
+
6
+ ### Features
7
+
8
+ * **deploy:** Set up automatic publishing ([f9b9c32](https://github.com/postalsys/mailauth/commit/f9b9c325e4dbac060114aa12c5887ea8c92c0bf8))
package/cli.md CHANGED
@@ -22,7 +22,9 @@ Command line utility and a [Node.js library](README.md) for email authentication
22
22
 
23
23
  Download `mailauth` for your platform:
24
24
 
25
- - [MacOS](https://github.com/postalsys/mailauth/releases/latest/download/mailauth.pkg)
25
+ - MacOS
26
+ - [Intel processors](https://github.com/postalsys/mailauth/releases/latest/download/mailauth.pkg)
27
+ - [Apple silicon](https://github.com/postalsys/mailauth/releases/latest/download/mailauth-arm.pkg)
26
28
  - [Linux](https://github.com/postalsys/mailauth/releases/latest/download/mailauth.tar.gz)
27
29
  - [Windows](https://github.com/postalsys/mailauth/releases/latest/download/mailauth.exe)
28
30
  - Or install from the NPM registry: `npm install -g mailauth`
package/lib/bimi/index.js CHANGED
@@ -201,10 +201,8 @@ const downloadPromise = async (url, cachedFile) => {
201
201
  throw error;
202
202
  }
203
203
 
204
- let ab = await res.arrayBuffer();
205
- process.stdout.write(Buffer.from(ab));
206
-
207
- return Buffer.from(ab);
204
+ const arrayBufferValue = await res.arrayBuffer();
205
+ return Buffer.from(arrayBufferValue);
208
206
  };
209
207
 
210
208
  const validateVMC = async (bimiData, opts) => {
@@ -182,7 +182,8 @@ class DkimVerifier extends MessageParser {
182
182
 
183
183
  let signingHeaders = {
184
184
  keys: signingHeaderLines.keys,
185
- headers: signingHeaderLines.headers.map(l => l.line.toString())
185
+ headers: signingHeaderLines.headers.map(l => l.line.toString()),
186
+ canonicalizedHeader: canonicalizedHeader.toString('base64')
186
187
  };
187
188
 
188
189
  let publicKey, rr, modulusLength;
package/lib/tools.js CHANGED
@@ -269,14 +269,36 @@ const getPublicKey = async (type, name, minBitLength, resolver) => {
269
269
  }
270
270
 
271
271
  let paddingNeeded = publicKeyValue.length % 4 ? 4 - (publicKeyValue.length % 4) : 0;
272
+ let paddedPublicKey = publicKeyValue + '='.repeat(paddingNeeded);
273
+
274
+ let rawPublicKey = Buffer.from(publicKeyValue, 'base64');
275
+ let publicKeyObj;
276
+ let publicKeyOpts;
277
+
278
+ if (rawPublicKey.length === 32) {
279
+ // seems like an ed25519 key
280
+ rawPublicKey = Buffer.concat([Buffer.from('302A300506032B6570032100', 'hex'), rawPublicKey]);
281
+ publicKeyOpts = {
282
+ key: rawPublicKey,
283
+ format: 'der',
284
+ type: 'spki'
285
+ };
286
+ } else {
287
+ const publicKeyPem = Buffer.from(`-----BEGIN PUBLIC KEY-----\n${paddedPublicKey.replace(/.{64}/g, '$&\n').trim()}\n-----END PUBLIC KEY-----`);
288
+ publicKeyOpts = {
289
+ key: publicKeyPem,
290
+ format: 'pem'
291
+ };
292
+ }
272
293
 
273
- const publicKeyPem = Buffer.from(
274
- `-----BEGIN PUBLIC KEY-----\n${(publicKeyValue + '='.repeat(paddingNeeded)).replace(/.{64}/g, '$&\n')}\n-----END PUBLIC KEY-----`
275
- );
276
- const publicKeyObj = crypto.createPublicKey({
277
- key: publicKeyPem,
278
- format: 'pem'
279
- });
294
+ try {
295
+ publicKeyObj = crypto.createPublicKey(publicKeyOpts);
296
+ } catch (err) {
297
+ let error = new Error('Unknown key type (${keyType})', { cause: err });
298
+ error.code = 'EINVALIDTYPE';
299
+ error.rr = rr;
300
+ throw error;
301
+ }
280
302
 
281
303
  let keyType = publicKeyObj.asymmetricKeyType;
282
304
 
@@ -297,7 +319,10 @@ const getPublicKey = async (type, name, minBitLength, resolver) => {
297
319
  }
298
320
 
299
321
  return {
300
- publicKey: publicKeyPem,
322
+ publicKey: publicKeyObj.export({
323
+ type: publicKeyObj.asymmetricKeyType === 'ed25519' ? 'spki' : 'pkcs1',
324
+ format: 'pem'
325
+ }),
301
326
  rr,
302
327
  modulusLength
303
328
  };
package/man/mailauth.1 CHANGED
@@ -1,4 +1,4 @@
1
- .TH "MAILAUTH" "1" "July 2023" "v4.5.0" "Mailauth Help"
1
+ .TH "MAILAUTH" "1" "November 2023" "v4.6.0" "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.5.1",
3
+ "version": "4.6.0",
4
4
  "description": "Email authentication library for Node.js",
5
5
  "main": "lib/mailauth.js",
6
6
  "scripts": {
@@ -9,7 +9,8 @@
9
9
  "man": "cd man && marked-man --version `node -e \"console.log('v'+require('../package.json').version)\"` --manual 'Mailauth Help' --section 1 man.md > mailauth.1",
10
10
  "build-source": "rm -rf node_modules package-lock.json && npm install && npm run man && npm run licenses && rm -rf node_modules package-lock.json && npm install --production && rm -rf package-lock.json",
11
11
  "build-dist": "npx pkg --compress Brotli package.json && rm -rf package-lock.json && npm install",
12
- "licenses": "license-report --only=prod --output=table --config license-report-config.json > licenses.txt"
12
+ "licenses": "license-report --only=prod --output=table --config license-report-config.json > licenses.txt",
13
+ "update": "rm -rf node_modules package-lock.json && ncu -u && npm install"
13
14
  },
14
15
  "repository": {
15
16
  "type": "git",
@@ -32,12 +33,12 @@
32
33
  },
33
34
  "homepage": "https://github.com/postalsys/mailauth",
34
35
  "devDependencies": {
35
- "chai": "4.3.7",
36
- "eslint": "8.46.0",
36
+ "chai": "4.3.10",
37
+ "eslint": "8.52.0",
37
38
  "eslint-config-nodemailer": "1.2.0",
38
- "eslint-config-prettier": "8.10.0",
39
+ "eslint-config-prettier": "9.0.0",
39
40
  "js-yaml": "4.1.0",
40
- "license-report": "6.4.0",
41
+ "license-report": "6.5.0",
41
42
  "marked": "0.7.0",
42
43
  "marked-man": "0.7.0",
43
44
  "mbox-reader": "1.1.5",
@@ -46,14 +47,14 @@
46
47
  },
47
48
  "dependencies": {
48
49
  "@postalsys/vmc": "1.0.6",
49
- "fast-xml-parser": "4.2.7",
50
+ "fast-xml-parser": "4.3.2",
50
51
  "ipaddr.js": "2.1.0",
51
- "joi": "17.9.2",
52
+ "joi": "17.11.0",
52
53
  "libmime": "5.2.1",
53
- "nodemailer": "6.9.4",
54
+ "nodemailer": "6.9.7",
54
55
  "psl": "1.9.0",
55
- "punycode": "2.3.0",
56
- "undici": "5.23.0",
56
+ "punycode": "2.3.1",
57
+ "undici": "5.27.0",
57
58
  "yargs": "17.7.2"
58
59
  },
59
60
  "engines": {
package/licenses.txt DELETED
@@ -1,11 +0,0 @@
1
- name license type link installed version author
2
- ---- ------------ ---- ----------------- ------
3
- @postalsys/vmc MIT https://registry.npmjs.org/@postalsys/vmc/-/vmc-1.0.6.tgz 1.0.6 Postal Systems OÜ
4
- fast-xml-parser MIT git+https://github.com/NaturalIntelligence/fast-xml-parser.git 4.2.7 Amit Gupta (https://amitguptagwl.github.io)
5
- ipaddr.js MIT git://github.com/whitequark/ipaddr.js.git 2.1.0 whitequark <whitequark@whitequark.org>
6
- joi BSD-3-Clause git://github.com/hapijs/joi.git 17.9.2 n/a
7
- libmime MIT git://github.com/andris9/libmime.git 5.2.1 Andris Reinman <andris@kreata.ee>
8
- nodemailer MIT-0 git+https://github.com/nodemailer/nodemailer.git 6.9.4 Andris Reinman
9
- psl MIT git+ssh://git@github.com/lupomontero/psl.git 1.9.0 Lupo Montero <lupomontero@gmail.com> (https://lupomontero.com/)
10
- punycode MIT git+https://github.com/mathiasbynens/punycode.js.git 2.3.0 Mathias Bynens https://mathiasbynens.be/
11
- yargs MIT git+https://github.com/yargs/yargs.git 17.7.2 n/a