node_modules: update (#338)

Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
This commit is contained in:
Dawid Dziurlaanddawidd6 authored and GitHub committed 2026-10-03 10:23:35 +02:00
1 parent e1936242ed
commit a9c5eb6c35
39 files changed
+799 -388

No files matched your search

+25 -8
View File
@@ -90,13 +90,22 @@ class DKIMSigner {
return;
}
const key = this.keys[keyPos++];
const dkimField = (0, sign_js_1.default)(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 = (0, sign_js_1.default)(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'));
}
@@ -196,7 +205,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_js_1.default.unsupportedHashAlgoError(signer.hashAlgo));
return;
}
if (writeValue) {
setImmediate(() => {
inputStream.end(writeValue);
+2
View File
@@ -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
View File
@@ -39,6 +39,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
const punycode = __importStar(require("../punycode/index.js"));
const mimeFuncs = __importStar(require("../mime-funcs/index.js"));
const node_crypto_1 = __importDefault(require("node:crypto"));
const errors = __importStar(require("../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
*
@@ -63,7 +72,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 = node_crypto_1.default.createSign(('rsa-' + hashAlgo).toUpperCase());
let signer;
try {
signer = node_crypto_1.default.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;
@@ -76,6 +91,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;
exports.default = sign;
function generateDKIMHeader(domainName, keySelector, fieldNames, hashAlgo, bodyHash) {
// the caller supplied tag values are interpolated straight into the tag list, and none of