node_modules: upgrade

This commit is contained in:
Dawid Dziurla
2025-06-13 19:44:16 +02:00
parent 7d23b91650
commit 21abe22bd8
320 changed files with 34046 additions and 3537 deletions

View File

@ -14,7 +14,7 @@ const shared = require('../shared');
const CONNECTION_TIMEOUT = 2 * 60 * 1000; // how much to wait for the connection to be established
const SOCKET_TIMEOUT = 10 * 60 * 1000; // how much to wait for socket inactivity before disconnecting the client
const GREETING_TIMEOUT = 30 * 1000; // how much to wait after connection is established but SMTP greeting is not receieved
const DNS_TIMEOUT = 30 * 1000; // how much to wait for resolveHostname
const DNS_TIMEOUT = 30 * 1000; // how much to wait for resolveHostname
/**
* Generates a SMTP connection object
@ -58,6 +58,8 @@ class SMTPConnection extends EventEmitter {
this.port = Number(this.options.port) || (this.secureConnection ? 465 : 587);
this.host = this.options.host || 'localhost';
this.servername = this.options.servername ? this.options.servername : !net.isIP(this.host) ? this.host : false;
this.allowInternalNetworkInterfaces = this.options.allowInternalNetworkInterfaces || false;
if (typeof this.options.secure === 'undefined' && this.port === 465) {
@ -241,6 +243,8 @@ class SMTPConnection extends EventEmitter {
if (this.options.connection) {
// connection is already opened
this._socket = this.options.connection;
setupConnectionHandlers();
if (this.secureConnection && !this.alreadySecured) {
setImmediate(() =>
this._upgradeConnection(err => {
@ -296,6 +300,12 @@ class SMTPConnection extends EventEmitter {
opts[key] = this.options.tls[key];
});
}
// ensure servername for SNI
if (this.servername && !opts.servername) {
opts.servername = this.servername;
}
return shared.resolveHostname(opts, (err, resolved) => {
if (err) {
return setImmediate(() => this._onError(err, 'EDNS', false, 'CONN'));
@ -404,7 +414,7 @@ class SMTPConnection extends EventEmitter {
if (socket && !socket.destroyed) {
try {
this._socket[closeMethod]();
socket[closeMethod]();
} catch (E) {
// just ignore
}
@ -434,7 +444,7 @@ class SMTPConnection extends EventEmitter {
}
if (this._authMethod !== 'XOAUTH2' && (!this._auth.credentials || !this._auth.credentials.user || !this._auth.credentials.pass)) {
if (this._auth.user && this._auth.pass) {
if ((this._auth.user && this._auth.pass) || this.customAuth.has(this._authMethod)) {
this._auth.credentials = {
user: this._auth.user,
pass: this._auth.pass,
@ -620,6 +630,15 @@ class SMTPConnection extends EventEmitter {
let startTime = Date.now();
this._setEnvelope(envelope, (err, info) => {
if (err) {
// create passthrough stream to consume to prevent OOM
let stream = new PassThrough();
if (typeof message.pipe === 'function') {
message.pipe(stream);
} else {
stream.write(message);
stream.end();
}
return callback(err);
}
let envelopeTime = Date.now();
@ -817,6 +836,20 @@ class SMTPConnection extends EventEmitter {
* @event
*/
_onClose() {
let serverResponse = false;
if (this._remainder && this._remainder.trim()) {
if (this.options.debug || this.options.transactionLog) {
this.logger.debug(
{
tnx: 'server'
},
this._remainder.replace(/\r?\n$/, '')
);
}
this.lastServerResponse = serverResponse = this._remainder.trim();
}
this.logger.info(
{
tnx: 'network'
@ -825,9 +858,11 @@ class SMTPConnection extends EventEmitter {
);
if (this.upgrading && !this._destroyed) {
return this._onError(new Error('Connection closed unexpectedly'), 'ETLS', false, 'CONN');
return this._onError(new Error('Connection closed unexpectedly'), 'ETLS', serverResponse, 'CONN');
} else if (![this._actionGreeting, this.close].includes(this._responseActions[0]) && !this._destroyed) {
return this._onError(new Error('Connection closed unexpectedly'), 'ECONNECTION', false, 'CONN');
return this._onError(new Error('Connection closed unexpectedly'), 'ECONNECTION', serverResponse, 'CONN');
} else if (/^[45]\d{2}\b/.test(serverResponse)) {
return this._onError(new Error('Connection closed unexpectedly'), 'ECONNECTION', serverResponse, 'CONN');
}
this._destroy();
@ -888,6 +923,11 @@ class SMTPConnection extends EventEmitter {
opts[key] = this.options.tls[key];
});
// ensure servername for SNI
if (this.servername && !opts.servername) {
opts.servername = this.servername;
}
this.upgrading = true;
// tls.connect is not an asynchronous function however it may still throw errors and requires to be wrapped with try/catch
try {
@ -944,14 +984,14 @@ class SMTPConnection extends EventEmitter {
if (!str.trim()) {
// skip unexpected empty lines
setImmediate(() => this._processResponse(true));
setImmediate(() => this._processResponse());
}
let action = this._responseActions.shift();
if (typeof action === 'function') {
action.call(this, str);
setImmediate(() => this._processResponse(true));
setImmediate(() => this._processResponse());
} else {
return this._onError(new Error('Unexpected Response'), 'EPROTOCOL', str, 'CONN');
}
@ -1264,6 +1304,12 @@ class SMTPConnection extends EventEmitter {
return;
}
this._ehloLines = str
.split(/\r?\n/)
.map(line => line.replace(/^\d+[ -]/, '').trim())
.filter(line => line)
.slice(1);
// Detect if the server supports STARTTLS
if (!this.secure && !this.options.ignoreTLS && (/[ -]STARTTLS\b/im.test(str) || this.options.requireTLS)) {
this._sendCommand('STARTTLS');
@ -1661,6 +1707,10 @@ class SMTPConnection extends EventEmitter {
rejected: this._envelope.rejected
};
if (this._ehloLines && this._ehloLines.length) {
response.ehlo = this._ehloLines;
}
if (this._envelope.rejectedErrors.length) {
response.rejectedErrors = this._envelope.rejectedErrors;
}