Comparing version 4.4.2 to 4.5.0
@@ -15,2 +15,3 @@ #!/usr/bin/env node | ||
const commandVmc = require('../lib/commands/vmc'); | ||
const commandBodyhash = require('../lib/commands/bodyhash'); | ||
@@ -104,2 +105,8 @@ const fs = require('fs'); | ||
}) | ||
.option('algo', { | ||
alias: 'a', | ||
type: 'string', | ||
description: 'Signing algorithm. Defaults either to rsa-sha256 or ed25519-sha256 depending on the private key format.', | ||
default: 'rsa-sha256' | ||
}) | ||
.option('canonicalization', { | ||
@@ -350,2 +357,46 @@ alias: 'c', | ||
.command( | ||
['bodyhash [email]'], | ||
'Generate a signature body hash for an email', | ||
yargs => { | ||
yargs | ||
.option('algo', { | ||
alias: 'a', | ||
type: 'string', | ||
description: 'Hashing algorithm. Defaults to sha256.', | ||
default: 'sha256' | ||
}) | ||
.option('canonicalization', { | ||
alias: 'c', | ||
type: 'string', | ||
description: 'Canonicalization algorithm (c= tag)', | ||
default: 'relaxed' | ||
}) | ||
.option('body-length', { | ||
alias: 'l', | ||
type: 'number', | ||
description: 'Maximum length of canonicalizated body to sign (l= tag)' | ||
}); | ||
yargs.positional('email', { | ||
describe: 'Path to the email message file in EML format. If not specified then content is read from stdin' | ||
}); | ||
}, | ||
argv => { | ||
commandBodyhash(argv) | ||
.then(() => { | ||
process.exit(); | ||
}) | ||
.catch(err => { | ||
if (!err.suppress) { | ||
console.error('Failed to calculate body hash for the input message'); | ||
console.error(err); | ||
} | ||
process.exit(1); | ||
}); | ||
} | ||
) | ||
.command( | ||
['license'], | ||
@@ -352,0 +403,0 @@ 'Show license information', |
30
cli.md
@@ -17,2 +17,3 @@ ![](https://github.com/postalsys/mailauth/raw/master/assets/mailauth.png) | ||
- [vmc](#vmc) - to validate BIMI VMC logo files | ||
- [bodyhash](#bodyhash) - to generate the signature body hash value for an email | ||
- [license](#license) - display licenses for `mailauth` and included modules | ||
@@ -324,2 +325,31 @@ - [DNS cache file](#dns-cache-file) | ||
### bodyhash | ||
`bodyhash` command takes an email message and calculates the body hash value for it | ||
``` | ||
$ mailauth bodyhash [options] [email] | ||
``` | ||
Where | ||
- **options** are option flags and arguments | ||
- **email** is the path to EML formatted email message file. If not provided then email message is read from standard input | ||
**Options** | ||
- `--algo sha256` or `-a sha256` is the signing algorithm. Defaults to "sha256". Can also use the a= tag format ("rsa-sha256"). | ||
- `--canonicalization algo` or `-c algo` is the body canonicalization algorithm, defaults to "relaxed". Can also use the c= tag format ("relaxed/relaxed"). | ||
- `--body-length 12345` or `-l 12345` is the maximum length of canonicalizated body to sign (l= tag) | ||
**Example** | ||
``` | ||
$ mailauth bodyhash /path/message.eml -a sha1 --verbose | ||
Hashing algorithm: sha1 | ||
Body canonicalization algorithm: relaxed | ||
-------- | ||
j+dD7whKXS1yDmyoWtvClYSyYiQ= | ||
``` | ||
### license | ||
@@ -326,0 +356,0 @@ |
@@ -51,8 +51,8 @@ 'use strict'; | ||
} | ||
if (signatureOpts.algorithm) { | ||
console.error(`Hashing algorithm: ${signatureOpts.algorithm}`); | ||
} | ||
if (signatureOpts.canonicalization) { | ||
console.error(`Canonicalization algorithm: ${signatureOpts.canonicalization}`); | ||
} | ||
if (signatureOpts.algorithm) { | ||
console.error(`Hashing algorithm: ${signatureOpts.algorithm}`); | ||
} | ||
if (signatureOpts.maxBodyLength) { | ||
@@ -59,0 +59,0 @@ console.error(`Maximum body length: ${signatureOpts.maxBodyLength}`); |
@@ -13,4 +13,7 @@ 'use strict'; | ||
return new RelaxedHash(...options); | ||
default: | ||
throw new Error('Unknown body canonicalization'); | ||
default: { | ||
let error = new Error('Unknown body canonicalization'); | ||
error.canonicalization = canonicalization; | ||
throw error; | ||
} | ||
} | ||
@@ -17,0 +20,0 @@ }; |
@@ -99,7 +99,11 @@ 'use strict'; | ||
if (!['relaxed', 'simple'].includes(header)) { | ||
throw new Error('Unknown header canonicalization: ' + header); | ||
let error = new Error('Unknown header canonicalization'); | ||
error.canonicalization = header; | ||
throw error; | ||
} | ||
if (!['relaxed', 'simple'].includes(body)) { | ||
throw new Error('Unknown header canonicalization: ' + body); | ||
let error = new Error('Unknown body canonicalization'); | ||
error.canonicalization = body; | ||
throw error; | ||
} | ||
@@ -106,0 +110,0 @@ } catch (err) { |
@@ -14,4 +14,7 @@ 'use strict'; | ||
return relaxedHeaders(type, signingHeaderLines, options); | ||
default: | ||
throw new Error('Unknown header canonicalization'); | ||
default: { | ||
let error = new Error('Unknown header canonicalization'); | ||
error.canonicalization = canonicalization; | ||
throw error; | ||
} | ||
} | ||
@@ -18,0 +21,0 @@ }; |
@@ -453,7 +453,11 @@ /* eslint no-control-regex: 0 */ | ||
if (!['rsa', 'ed25519'].includes(signAlgo)) { | ||
throw new Error('Unknown signing algorithm: ' + signAlgo); | ||
let error = new Error('Unknown signing algorithm'); | ||
error.signAlgo = signAlgo; | ||
throw error; | ||
} | ||
if (!['sha256'].concat(!strict ? 'sha1' : []).includes(hashAlgo)) { | ||
throw new Error('Unknown hashing algorithm: ' + hashAlgo); | ||
let error = new Error('Unknown hashing algorithm'); | ||
error.hashAlgo = hashAlgo; | ||
throw error; | ||
} | ||
@@ -460,0 +464,0 @@ } catch (err) { |
name license type link installed version author | ||
---- ------------ ---- ----------------- ------ | ||
@postalsys/vmc MIT https://registry.npmjs.org/@postalsys/vmc/-/vmc-1.0.6.tgz 1.0.6 Postal Systems OÜ | ||
fast-xml-parser MIT git+https://github.com/NaturalIntelligence/fast-xml-parser.git 4.2.4 Amit Gupta (https://amitkumargupta.work/) | ||
fast-xml-parser MIT git+https://github.com/NaturalIntelligence/fast-xml-parser.git 4.2.6 Amit Gupta (https://amitguptagwl.github.io) | ||
ipaddr.js MIT git://github.com/whitequark/ipaddr.js.git 2.1.0 whitequark <whitequark@whitequark.org> | ||
joi BSD-3-Clause git://github.com/hapijs/joi.git 17.9.2 n/a | ||
libmime MIT git://github.com/andris9/libmime.git 5.2.1 Andris Reinman <andris@kreata.ee> | ||
nodemailer MIT-0 git+https://github.com/nodemailer/nodemailer.git 6.9.3 Andris Reinman | ||
nodemailer MIT-0 git+https://github.com/nodemailer/nodemailer.git 6.9.4 Andris Reinman | ||
psl MIT git+ssh://git@github.com/lupomontero/psl.git 1.9.0 Lupo Montero <lupomontero@gmail.com> (https://lupomontero.com/) | ||
punycode MIT git+https://github.com/mathiasbynens/punycode.js.git 2.3.0 Mathias Bynens https://mathiasbynens.be/ | ||
yargs MIT git+https://github.com/yargs/yargs.git 17.7.2 n/a |
{ | ||
"name": "mailauth", | ||
"version": "4.4.2", | ||
"version": "4.5.0", | ||
"description": "Email authentication library for Node.js", | ||
@@ -36,3 +36,3 @@ "main": "lib/mailauth.js", | ||
"chai": "4.3.7", | ||
"eslint": "8.45.0", | ||
"eslint": "8.46.0", | ||
"eslint-config-nodemailer": "1.2.0", | ||
@@ -50,3 +50,3 @@ "eslint-config-prettier": "8.9.0", | ||
"@postalsys/vmc": "1.0.6", | ||
"fast-xml-parser": "4.2.6", | ||
"fast-xml-parser": "4.2.7", | ||
"ipaddr.js": "2.1.0", | ||
@@ -76,6 +76,6 @@ "joi": "17.9.2", | ||
"targets": [ | ||
"node16-linux-x64", | ||
"node16-macos-x64", | ||
"node18-linux-x64", | ||
"node18-macos-x64", | ||
"node18-macos-arm64", | ||
"node16-win-x64" | ||
"node18-win-x64" | ||
], | ||
@@ -82,0 +82,0 @@ "outputPath": "ee-dist" |
Sorry, the diff of this file is not supported yet
273503
47
5315
7
+ Addedfast-xml-parser@4.2.7(transitive)
- Removedfast-xml-parser@4.2.6(transitive)
Updatedfast-xml-parser@4.2.7