node_modules: update (#332)

Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
This commit is contained in:
Dawid Dziurlaanddawidd6 authored and GitHub committed 2026-10-01 09:48:38 +02:00
1 parent c1dac70e3a
commit 6bf0a2f26a
95 files changed
+1102 -503

No files matched your search

+68 -55
View File
@@ -414,14 +414,21 @@ class SMTPConnection extends EventEmitter {
this._auth = authData || {};
// Select SASL authentication method
this._authMethod = (this._auth.method || '').toString().trim().toUpperCase() || false;
// XOAUTH2 needs a token generator or a custom handler, without either the method
// can not be run even when it is the only one the server advertised
const canUseXOAuth2 = !!this._auth.oauth2 || this.customAuth.has('XOAUTH2');
if (!this._authMethod && this._auth.oauth2 && !this._auth.credentials) {
this._authMethod = 'XOAUTH2';
}
else if (!this._authMethod || (this._authMethod === 'XOAUTH2' && !this._auth.oauth2)) {
// use first supported
this._authMethod = (this._supportedAuth[0] || 'PLAIN').toUpperCase().trim();
// use the first supported method that can be run
const supported = this._supportedAuth.find(method => method !== 'XOAUTH2' || canUseXOAuth2);
this._authMethod = (supported || 'PLAIN').toUpperCase().trim();
}
if (this._authMethod !== 'XOAUTH2' && (!this._auth.credentials || !this._auth.credentials.user || !this._auth.credentials.pass)) {
// a token login needs no credentials, every other method and every custom handler
// gets them filled in from the user and pass values
if ((this._authMethod !== 'XOAUTH2' || this.customAuth.has('XOAUTH2')) &&
(!this._auth.credentials || !this._auth.credentials.user || !this._auth.credentials.pass)) {
if ((this._auth.user && this._auth.pass) || this.customAuth.has(this._authMethod)) {
this._auth.credentials = {
user: this._auth.user,
@@ -458,42 +465,45 @@ class SMTPConnection extends EventEmitter {
returned = true;
callback(this._formatError(err, 'EAUTH', lastResponse, 'AUTH ' + this._authMethod));
};
// one implementation serves both sendCommand overloads, the promise is returned
// exactly when no callback was given
const sendCommand = (cmd, done) => {
let promise;
if (!done) {
promise = new Promise((resolve, reject) => {
done = shared.callbackPromise(resolve, reject);
});
}
this._responseActions.push(str => {
lastResponse = str;
let codes = str.match(/^(\d+)(?:\s(\d+\.\d+\.\d+))?\s/);
let data = {
command: cmd,
response: str
};
if (codes) {
data.status = Number(codes[1]) || 0;
if (codes[2]) {
data.code = codes[2];
}
data.text = str.substr(codes[0].length);
}
else {
data.text = str;
data.status = 0; // just in case we need to perform numeric comparisons
}
done(null, data);
});
setImmediate(() => this._sendCommand(cmd));
return promise;
};
const handlerResponse = handler({
auth: this._auth,
method: this._authMethod,
extensions: [].concat(this._supportedExtensions),
authMethods: [].concat(this._supportedAuth),
maxAllowedSize: this._maxAllowedSize || false,
sendCommand: (cmd, done) => {
let promise;
if (!done) {
promise = new Promise((resolve, reject) => {
done = shared.callbackPromise(resolve, reject);
});
}
this._responseActions.push(str => {
lastResponse = str;
let codes = str.match(/^(\d+)(?:\s(\d+\.\d+\.\d+))?\s/);
let data = {
command: cmd,
response: str
};
if (codes) {
data.status = Number(codes[1]) || 0;
if (codes[2]) {
data.code = codes[2];
}
data.text = str.substr(codes[0].length);
}
else {
data.text = str;
data.status = 0; // just in case we need to perform numeric comparisons
}
done(null, data);
});
setImmediate(() => this._sendCommand(cmd));
return promise;
},
sendCommand: sendCommand,
resolve,
reject
});
@@ -550,29 +560,30 @@ class SMTPConnection extends EventEmitter {
* @param callback Callback to return once sending is completed
*/
send(envelope, message, done) {
if (!message) {
return done(this._formatError('Empty message', 'EMESSAGE', false, 'API'));
}
const isDestroyedMessage = this._isDestroyedMessage('send message');
if (isDestroyedMessage) {
return done(this._formatError(isDestroyedMessage, 'ECONNECTION', false, 'API'));
}
// reject larger messages than allowed
if (this._maxAllowedSize && envelope.size > this._maxAllowedSize) {
setImmediate(() => {
done(this._formatError('Message size larger than allowed ' + this._maxAllowedSize, 'EMESSAGE', false, 'MAIL FROM'));
});
return;
}
// ensure that callback is only called once
// ensure that the callback is only called once. The public callback type has a
// required result, the error paths hand over the error alone
let returned = false;
const callback = function (...args) {
const callback = (err, info) => {
if (returned) {
return;
}
returned = true;
done(...args);
done(err, info);
};
if (!message) {
return callback(this._formatError('Empty message', 'EMESSAGE', false, 'API'));
}
const isDestroyedMessage = this._isDestroyedMessage('send message');
if (isDestroyedMessage) {
return callback(this._formatError(isDestroyedMessage, 'ECONNECTION', false, 'API'));
}
// reject larger messages than allowed
if (this._maxAllowedSize && envelope.size > this._maxAllowedSize) {
setImmediate(() => {
callback(this._formatError('Message size larger than allowed ' + this._maxAllowedSize, 'EMESSAGE', false, 'MAIL FROM'));
});
return;
}
if (typeof message.on === 'function') {
message.on('error', err => callback(this._formatError(err, 'ESTREAM', false, 'API')));
}
@@ -595,11 +606,13 @@ class SMTPConnection extends EventEmitter {
if (err) {
return callback(err);
}
info.envelopeTime = envelopeTime - startTime;
info.messageTime = Date.now() - envelopeTime;
info.messageSize = stream.outByteCount;
info.response = str;
return callback(null, info);
// the envelope info becomes the send result once the timings are on it
const result = info;
result.envelopeTime = envelopeTime - startTime;
result.messageTime = Date.now() - envelopeTime;
result.messageSize = stream.outByteCount;
result.response = str;
return callback(null, result);
});
if (typeof message.pipe === 'function') {
message.pipe(stream);