ARC (Authenticated Received Chain) can be handled in two ways:
1. Sealing during authentication
If you provide a seal object in the authenticate() options, the message will be automatically sealed during the authentication process.
const { authenticate } = require('mailauth');
const fs = require('fs');
const { headers } = await authenticate(message, {
trustReceived: true,
seal: {
signingDomain: 'tahvel.info',
selector: 'test.rsa',
privateKey: fs.readFileSync('./test/fixtures/private-rsa.pem'),
},
});
2. Sealing after modifications
If you must modify the message after authentication, use sealMessage(). You must pass the authentication results from the initial authenticate() call to ensure the chain is valid.
const { authenticate, sealMessage } = require('mailauth');
const fs = require('fs');
// 1. Authenticate
const { arc, headers } = await authenticate(message, {
ip: '217.146.67.33',
helo: 'uvn-67-33.tll01.zonevs.eu',
mta: 'mx.ethereal.email',
sender: 'andris@ekiri.ee',
});
// 2. Modify message...
// 3. Seal
const sealHeaders = await sealMessage(message, {
signingDomain: 'tahvel.info',
selector: 'test.rsa',
privateKey: fs.readFileSync('./test/fixtures/private-rsa.pem'),
authResults: arc.authResults,
cv: arc.status.result,
});