mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2026-10-09 09:59:45 +07:00
node_modules: update (#338)
Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
This commit is contained in:
1 parent
e1936242ed
commit
a9c5eb6c35
39 files changed
+799
-388
No files matched your search
+25
-8
@@ -85,13 +85,22 @@ class DKIMSigner {
|
||||
return;
|
||||
}
|
||||
const key = this.keys[keyPos++];
|
||||
const dkimField = sign(this.headers, this.hashAlgo, this.bodyHash, {
|
||||
domainName: key.domainName,
|
||||
keySelector: key.keySelector,
|
||||
privateKey: key.privateKey,
|
||||
headerFieldNames: this.options.headerFieldNames,
|
||||
skipFields: this.options.skipFields
|
||||
});
|
||||
let dkimField;
|
||||
try {
|
||||
dkimField = sign(this.headers, this.hashAlgo, this.bodyHash, {
|
||||
domainName: key.domainName,
|
||||
keySelector: key.keySelector,
|
||||
privateKey: key.privateKey,
|
||||
headerFieldNames: this.options.headerFieldNames,
|
||||
skipFields: this.options.skipFields
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
this.hasErrored = true;
|
||||
this.cleanup();
|
||||
this.output.emit('error', err);
|
||||
return;
|
||||
}
|
||||
if (dkimField) {
|
||||
this.output.write(Buffer.from(dkimField + '\r\n'));
|
||||
}
|
||||
@@ -191,7 +200,15 @@ class DKIM {
|
||||
}
|
||||
const signer = new DKIMSigner(options, this.keys, inputStream, output);
|
||||
setImmediate(() => {
|
||||
signer.signStream();
|
||||
try {
|
||||
signer.signStream();
|
||||
}
|
||||
catch (_E) {
|
||||
// the body hash is created here, an unknown hashAlgo throws inside this timer
|
||||
// where nothing else could catch it
|
||||
output.emit('error', sign.unsupportedHashAlgoError(signer.hashAlgo));
|
||||
return;
|
||||
}
|
||||
if (writeValue) {
|
||||
setImmediate(() => {
|
||||
inputStream.end(writeValue);
|
||||
|
||||
+2
@@ -1,4 +1,5 @@
|
||||
import crypto from 'node:crypto';
|
||||
import type { NodemailerError } from '../errors.js';
|
||||
import type { MessageParserHeaderLine } from './message-parser.js';
|
||||
/**
|
||||
* Private key accepted by crypto.Sign#sign: a PEM string, a Buffer, a KeyObject or an
|
||||
@@ -45,5 +46,6 @@ export interface DKIMRelaxedHeaders {
|
||||
declare function sign(headers: MessageParserHeaderLine[], hashAlgo: string, bodyHash: string, options?: DKIMSignOptions): string | false;
|
||||
declare namespace sign {
|
||||
var relaxedHeaders: (headers: MessageParserHeaderLine[], fieldNames?: string, skipFields?: string) => DKIMRelaxedHeaders;
|
||||
var unsupportedHashAlgoError: (hashAlgo: string) => NodemailerError;
|
||||
}
|
||||
export default sign;
|
||||
+17
-1
@@ -1,6 +1,15 @@
|
||||
import * as punycode from '../punycode/index.js';
|
||||
import * as mimeFuncs from '../mime-funcs/index.js';
|
||||
import crypto from 'node:crypto';
|
||||
import * as errors from '../errors.js';
|
||||
/**
|
||||
* Error for a hashAlgo value the crypto module does not know
|
||||
*/
|
||||
function unsupportedHashAlgoError(hashAlgo) {
|
||||
const err = new Error('Unsupported DKIM hash algorithm "' + hashAlgo + '"');
|
||||
err.code = errors.ECONFIG;
|
||||
return err;
|
||||
}
|
||||
/**
|
||||
* Returns DKIM signature header line
|
||||
*
|
||||
@@ -25,7 +34,13 @@ function sign(headers, hashAlgo, bodyHash, options) {
|
||||
const canonicalizedHeaderData = relaxedHeaders(headers, fieldNames, options.skipFields);
|
||||
const dkimHeader = generateDKIMHeader(options.domainName, options.keySelector, canonicalizedHeaderData.fieldNames, hashAlgo, bodyHash);
|
||||
canonicalizedHeaderData.headers += 'dkim-signature:' + relaxedHeaderLine(dkimHeader);
|
||||
const signer = crypto.createSign(('rsa-' + hashAlgo).toUpperCase());
|
||||
let signer;
|
||||
try {
|
||||
signer = crypto.createSign(('rsa-' + hashAlgo).toUpperCase());
|
||||
}
|
||||
catch (_E) {
|
||||
throw unsupportedHashAlgoError(hashAlgo);
|
||||
}
|
||||
// the header lines are 'binary' strings, so this reproduces the original header bytes
|
||||
signer.update(canonicalizedHeaderData.headers, 'latin1');
|
||||
let signature;
|
||||
@@ -38,6 +53,7 @@ function sign(headers, hashAlgo, bodyHash, options) {
|
||||
return dkimHeader + signature.replace(/(^.{73}|.{75}(?!\r?\n|\r))/g, '$&\r\n ').trim();
|
||||
}
|
||||
sign.relaxedHeaders = relaxedHeaders;
|
||||
sign.unsupportedHashAlgoError = unsupportedHashAlgoError;
|
||||
export default sign;
|
||||
function generateDKIMHeader(domainName, keySelector, fieldNames, hashAlgo, bodyHash) {
|
||||
// the caller supplied tag values are interpolated straight into the tag list, and none of
|
||||
|
||||
Reference in new issue
Block a user