mirror of https://github.com/eleith/emailjs.git
build: update bundle
This commit is contained in:
parent
1f23fa7fb3
commit
0018bdb14f
140
email.js
140
email.js
|
@ -32,17 +32,17 @@ const OPERATORS = new Map([
|
||||||
* @return {AddressToken[]} An array of operator|text tokens
|
* @return {AddressToken[]} An array of operator|text tokens
|
||||||
*/
|
*/
|
||||||
function tokenizeAddress(address = '') {
|
function tokenizeAddress(address = '') {
|
||||||
var _a, _b;
|
|
||||||
const tokens = [];
|
const tokens = [];
|
||||||
let token = undefined;
|
let token = undefined;
|
||||||
let operator = undefined;
|
let operator = undefined;
|
||||||
for (const character of address.toString()) {
|
for (const character of address.toString()) {
|
||||||
if (((_a = operator === null || operator === void 0 ? void 0 : operator.length) !== null && _a !== void 0 ? _a : 0) > 0 && character === operator) {
|
const operatorHasLength = operator != null && operator.length > 0;
|
||||||
|
if (operatorHasLength === true && character === operator) {
|
||||||
tokens.push({ type: 'operator', value: character });
|
tokens.push({ type: 'operator', value: character });
|
||||||
token = undefined;
|
token = undefined;
|
||||||
operator = undefined;
|
operator = undefined;
|
||||||
}
|
}
|
||||||
else if (((_b = operator === null || operator === void 0 ? void 0 : operator.length) !== null && _b !== void 0 ? _b : 0) === 0 && OPERATORS.has(character)) {
|
else if (operatorHasLength === false && OPERATORS.has(character)) {
|
||||||
tokens.push({ type: 'operator', value: character });
|
tokens.push({ type: 'operator', value: character });
|
||||||
token = undefined;
|
token = undefined;
|
||||||
operator = OPERATORS.get(character);
|
operator = OPERATORS.get(character);
|
||||||
|
@ -71,7 +71,6 @@ function tokenizeAddress(address = '') {
|
||||||
* @return {AddressObject[]} addresses object array
|
* @return {AddressObject[]} addresses object array
|
||||||
*/
|
*/
|
||||||
function convertAddressTokens(tokens) {
|
function convertAddressTokens(tokens) {
|
||||||
var _a, _b;
|
|
||||||
const addressObjects = [];
|
const addressObjects = [];
|
||||||
const groups = [];
|
const groups = [];
|
||||||
let addresses = [];
|
let addresses = [];
|
||||||
|
@ -134,7 +133,11 @@ function convertAddressTokens(tokens) {
|
||||||
// If no address was found, try to detect one from regular text
|
// If no address was found, try to detect one from regular text
|
||||||
if (addresses.length === 0 && texts.length > 0) {
|
if (addresses.length === 0 && texts.length > 0) {
|
||||||
for (let i = texts.length - 1; i >= 0; i--) {
|
for (let i = texts.length - 1; i >= 0; i--) {
|
||||||
if ((_b = (_a = texts[i]) === null || _a === void 0 ? void 0 : _a.match(/^[^@\s]+@[^@\s]+$/)) !== null && _b !== void 0 ? _b : false) {
|
const text = texts[i];
|
||||||
|
if (text == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (/^[^@\s]+@[^@\s]+$/.test(text)) {
|
||||||
addresses = texts.splice(i, 1);
|
addresses = texts.splice(i, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +146,7 @@ function convertAddressTokens(tokens) {
|
||||||
if (addresses.length === 0) {
|
if (addresses.length === 0) {
|
||||||
for (let i = texts.length - 1; i >= 0; i--) {
|
for (let i = texts.length - 1; i >= 0; i--) {
|
||||||
const text = texts[i];
|
const text = texts[i];
|
||||||
if ((text === null || text === void 0 ? void 0 : text.length) > 0) {
|
if (text != null && text.length > 0) {
|
||||||
texts[i] = text
|
texts[i] = text
|
||||||
.replace(/\s*\b[^@\s]+@[^@\s]+\b\s*/, (address) => {
|
.replace(/\s*\b[^@\s]+@[^@\s]+\b\s*/, (address) => {
|
||||||
if (addresses.length === 0) {
|
if (addresses.length === 0) {
|
||||||
|
@ -235,20 +238,15 @@ function addressparser(address) {
|
||||||
* @returns {string} the converted date
|
* @returns {string} the converted date
|
||||||
*/
|
*/
|
||||||
function getRFC2822Date(date = new Date(), useUtc = false) {
|
function getRFC2822Date(date = new Date(), useUtc = false) {
|
||||||
var _a, _b;
|
|
||||||
if (useUtc) {
|
if (useUtc) {
|
||||||
return getRFC2822DateUTC(date);
|
return getRFC2822DateUTC(date);
|
||||||
}
|
}
|
||||||
const dates = date
|
const [zero, one, two, ...rest] = date
|
||||||
.toString()
|
.toString()
|
||||||
.replace('GMT', '')
|
.replace('GMT', '')
|
||||||
.replace(/\s\(.*\)$/, '')
|
.replace(/\s\(.*\)$/, '')
|
||||||
.split(' ');
|
.split(' ');
|
||||||
dates[0] = dates[0] + ',';
|
return [zero + ',', two, one, ...rest].join(' ');
|
||||||
const day = (_a = dates[1]) !== null && _a !== void 0 ? _a : '';
|
|
||||||
dates[1] = (_b = dates[2]) !== null && _b !== void 0 ? _b : '';
|
|
||||||
dates[2] = day;
|
|
||||||
return dates.join(' ');
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {Date} [date] an optional date to convert to RFC2822 format (UTC)
|
* @param {Date} [date] an optional date to convert to RFC2822 format (UTC)
|
||||||
|
@ -291,22 +289,22 @@ const MAX_CHUNK_LENGTH = 16383; // must be multiple of 3
|
||||||
const MAX_MIME_WORD_LENGTH = 52;
|
const MAX_MIME_WORD_LENGTH = 52;
|
||||||
const MAX_B64_MIME_WORD_BYTE_LENGTH = 39;
|
const MAX_B64_MIME_WORD_BYTE_LENGTH = 39;
|
||||||
function tripletToBase64(num) {
|
function tripletToBase64(num) {
|
||||||
var _a, _b;
|
return ('' +
|
||||||
return (((_a = LOOKUP[(num >> 18) & 0x3f]) !== null && _a !== void 0 ? _a : '') +
|
LOOKUP[(num >> 18) & 0x3f] +
|
||||||
((_b = LOOKUP[(num >> 12) & 0x3f]) !== null && _b !== void 0 ? _b : '') +
|
LOOKUP[(num >> 12) & 0x3f] +
|
||||||
LOOKUP[(num >> 6) & 0x3f] +
|
LOOKUP[(num >> 6) & 0x3f] +
|
||||||
LOOKUP[num & 0x3f]);
|
LOOKUP[num & 0x3f]);
|
||||||
}
|
}
|
||||||
function encodeChunk(uint8, start, end) {
|
function encodeChunk(uint8, start, end) {
|
||||||
var _a, _b, _c;
|
|
||||||
let output = '';
|
let output = '';
|
||||||
for (let i = start; i < end; i += 3) {
|
for (let i = start; i < end; i += 3) {
|
||||||
output += tripletToBase64((((_a = uint8[i]) !== null && _a !== void 0 ? _a : 0) << 16) + (((_b = uint8[i + 1]) !== null && _b !== void 0 ? _b : 0) << 8) + ((_c = uint8[i + 2]) !== null && _c !== void 0 ? _c : 0));
|
output += tripletToBase64((Number(uint8[i]) << 16) +
|
||||||
|
(Number(uint8[i + 1]) << 8) +
|
||||||
|
Number(uint8[i + 2]));
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
function encodeBase64(data) {
|
function encodeBase64(data) {
|
||||||
var _a, _b, _c;
|
|
||||||
const len = data.length;
|
const len = data.length;
|
||||||
const extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
|
const extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
|
||||||
let output = '';
|
let output = '';
|
||||||
|
@ -316,13 +314,13 @@ function encodeBase64(data) {
|
||||||
}
|
}
|
||||||
// pad the end with zeros, but make sure to not forget the extra bytes
|
// pad the end with zeros, but make sure to not forget the extra bytes
|
||||||
if (extraBytes === 1) {
|
if (extraBytes === 1) {
|
||||||
const tmp = (_a = data[len - 1]) !== null && _a !== void 0 ? _a : 0;
|
const tmp = Number(data[len - 1]);
|
||||||
output += LOOKUP[tmp >> 2];
|
output += LOOKUP[tmp >> 2];
|
||||||
output += LOOKUP[(tmp << 4) & 0x3f];
|
output += LOOKUP[(tmp << 4) & 0x3f];
|
||||||
output += '==';
|
output += '==';
|
||||||
}
|
}
|
||||||
else if (extraBytes === 2) {
|
else if (extraBytes === 2) {
|
||||||
const tmp = (((_b = data[len - 2]) !== null && _b !== void 0 ? _b : 0) << 8) + ((_c = data[len - 1]) !== null && _c !== void 0 ? _c : 0);
|
const tmp = (Number(data[len - 2]) << 8) + Number(data[len - 1]);
|
||||||
output += LOOKUP[tmp >> 10];
|
output += LOOKUP[tmp >> 10];
|
||||||
output += LOOKUP[(tmp >> 4) & 0x3f];
|
output += LOOKUP[(tmp >> 4) & 0x3f];
|
||||||
output += LOOKUP[(tmp << 2) & 0x3f];
|
output += LOOKUP[(tmp << 2) & 0x3f];
|
||||||
|
@ -338,7 +336,6 @@ function encodeBase64(data) {
|
||||||
* @return {string[]} lines
|
* @return {string[]} lines
|
||||||
*/
|
*/
|
||||||
function splitMimeEncodedString(str, maxlen = 12) {
|
function splitMimeEncodedString(str, maxlen = 12) {
|
||||||
var _a;
|
|
||||||
const minWordLength = 12; // require at least 12 symbols to fit possible 4 octet UTF-8 sequences
|
const minWordLength = 12; // require at least 12 symbols to fit possible 4 octet UTF-8 sequences
|
||||||
const maxWordLength = Math.max(maxlen, minWordLength);
|
const maxWordLength = Math.max(maxlen, minWordLength);
|
||||||
const lines = [];
|
const lines = [];
|
||||||
|
@ -352,9 +349,10 @@ function splitMimeEncodedString(str, maxlen = 12) {
|
||||||
while (!done) {
|
while (!done) {
|
||||||
let chr;
|
let chr;
|
||||||
done = true;
|
done = true;
|
||||||
const match = str.substring(curLine.length).match(/^=([0-9A-F]{2})/i); // check if not middle of a unicode char sequence
|
const matchset = str.substring(curLine.length).match(/^=([0-9A-F]{2})/i); // check if not middle of a unicode char sequence
|
||||||
if (match) {
|
if (matchset != null) {
|
||||||
chr = parseInt((_a = match[1]) !== null && _a !== void 0 ? _a : '', 16);
|
const [, secondMatch = ''] = matchset;
|
||||||
|
chr = parseInt(secondMatch, 16);
|
||||||
// invalid sequence, move one char back anc recheck
|
// invalid sequence, move one char back anc recheck
|
||||||
if (chr < 0xc2 && chr > 0x7f) {
|
if (chr < 0xc2 && chr > 0x7f) {
|
||||||
curLine = curLine.substring(0, curLine.length - 3);
|
curLine = curLine.substring(0, curLine.length - 3);
|
||||||
|
@ -377,9 +375,7 @@ function splitMimeEncodedString(str, maxlen = 12) {
|
||||||
function checkRanges(nr) {
|
function checkRanges(nr) {
|
||||||
return RANGES.reduce((val, range) => val ||
|
return RANGES.reduce((val, range) => val ||
|
||||||
(range.length === 1 && nr === range[0]) ||
|
(range.length === 1 && nr === range[0]) ||
|
||||||
(range.length === 2 &&
|
(range.length === 2 && nr >= Number(range[0]) && nr <= Number(range[1])), false);
|
||||||
nr >= range[0] &&
|
|
||||||
nr <= range[1]), false);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Encodes all non printable and non ascii bytes to =XX form, where XX is the
|
* Encodes all non printable and non ascii bytes to =XX form, where XX is the
|
||||||
|
@ -550,7 +546,7 @@ class Message {
|
||||||
this.header[header.toLowerCase()] = convertPersonToAddress(headers[header]);
|
this.header[header.toLowerCase()] = convertPersonToAddress(headers[header]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// allow any headers the user wants to set??
|
// allow any headers the user wants to set
|
||||||
this.header[header.toLowerCase()] = headers[header];
|
this.header[header.toLowerCase()] = headers[header];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -765,10 +761,10 @@ class MessageStream extends Stream {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const outputFile = (attachment, next) => {
|
const outputFile = (attachment, next) => {
|
||||||
var _a;
|
|
||||||
const chunk = MIME64CHUNK * 16;
|
const chunk = MIME64CHUNK * 16;
|
||||||
const buffer = Buffer.alloc(chunk);
|
const buffer = Buffer.alloc(chunk);
|
||||||
const inputEncoding = ((_a = attachment === null || attachment === void 0 ? void 0 : attachment.headers) === null || _a === void 0 ? void 0 : _a['content-transfer-encoding']) || 'base64';
|
const { headers = {} } = attachment;
|
||||||
|
const inputEncoding = headers['content-transfer-encoding'] || 'base64';
|
||||||
const encoding = inputEncoding === '7bit'
|
const encoding = inputEncoding === '7bit'
|
||||||
? 'ascii'
|
? 'ascii'
|
||||||
: inputEncoding === '8bit'
|
: inputEncoding === '8bit'
|
||||||
|
@ -813,7 +809,7 @@ class MessageStream extends Stream {
|
||||||
*/
|
*/
|
||||||
const outputStream = (attachment, callback) => {
|
const outputStream = (attachment, callback) => {
|
||||||
const { stream } = attachment;
|
const { stream } = attachment;
|
||||||
if (stream === null || stream === void 0 ? void 0 : stream.readable) {
|
if (stream != null && stream.readable) {
|
||||||
let previous = Buffer.alloc(0);
|
let previous = Buffer.alloc(0);
|
||||||
stream.resume();
|
stream.resume();
|
||||||
stream.on('end', () => {
|
stream.on('end', () => {
|
||||||
|
@ -865,11 +861,13 @@ class MessageStream extends Stream {
|
||||||
if (index < list.length) {
|
if (index < list.length) {
|
||||||
output(`--${boundary}${CRLF$1}`);
|
output(`--${boundary}${CRLF$1}`);
|
||||||
const item = list[index];
|
const item = list[index];
|
||||||
if (item === null || item === void 0 ? void 0 : item.related) {
|
if (item != null) {
|
||||||
outputRelated(item, () => outputMessage(boundary, list, index + 1, callback));
|
if (item.related) {
|
||||||
}
|
outputRelated(item, () => outputMessage(boundary, list, index + 1, callback));
|
||||||
else if (item) {
|
}
|
||||||
outputAttachment(item, () => outputMessage(boundary, list, index + 1, callback));
|
else {
|
||||||
|
outputAttachment(item, () => outputMessage(boundary, list, index + 1, callback));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -896,10 +894,8 @@ class MessageStream extends Stream {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const outputData = (attachment, callback) => {
|
const outputData = (attachment, callback) => {
|
||||||
var _a, _b;
|
const { data = '' } = attachment;
|
||||||
outputBase64(attachment.encoded
|
outputBase64(attachment.encoded ? data : Buffer.from(data).toString('base64'), callback);
|
||||||
? (_a = attachment.data) !== null && _a !== void 0 ? _a : ''
|
|
||||||
: Buffer.from((_b = attachment.data) !== null && _b !== void 0 ? _b : '').toString('base64'), callback);
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @param {Message} message the message to output
|
* @param {Message} message the message to output
|
||||||
|
@ -927,8 +923,8 @@ class MessageStream extends Stream {
|
||||||
const boundary = generateBoundary();
|
const boundary = generateBoundary();
|
||||||
output(`Content-Type: multipart/related; boundary="${boundary}"${CRLF$1}${CRLF$1}--${boundary}${CRLF$1}`);
|
output(`Content-Type: multipart/related; boundary="${boundary}"${CRLF$1}${CRLF$1}--${boundary}${CRLF$1}`);
|
||||||
outputAttachment(message, () => {
|
outputAttachment(message, () => {
|
||||||
var _a;
|
const { related = [] } = message;
|
||||||
outputMessage(boundary, (_a = message.related) !== null && _a !== void 0 ? _a : [], 0, () => {
|
outputMessage(boundary, related, 0, () => {
|
||||||
output(`${CRLF$1}--${boundary}--${CRLF$1}${CRLF$1}`);
|
output(`${CRLF$1}--${boundary}--${CRLF$1}${CRLF$1}`);
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
@ -959,12 +955,13 @@ class MessageStream extends Stream {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const close$1 = (err) => {
|
const close$1 = (err) => {
|
||||||
var _a, _b;
|
|
||||||
if (err) {
|
if (err) {
|
||||||
this.emit('error', err);
|
this.emit('error', err);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.emit('data', (_b = (_a = this.buffer) === null || _a === void 0 ? void 0 : _a.toString('utf-8', 0, this.bufferIndex)) !== null && _b !== void 0 ? _b : '');
|
this.emit('data', this.buffer != null
|
||||||
|
? this.buffer.toString('utf-8', 0, this.bufferIndex)
|
||||||
|
: '');
|
||||||
this.emit('end');
|
this.emit('end');
|
||||||
}
|
}
|
||||||
this.buffer = null;
|
this.buffer = null;
|
||||||
|
@ -1084,7 +1081,8 @@ class SMTPError extends Error {
|
||||||
* @returns {SMTPError} error
|
* @returns {SMTPError} error
|
||||||
*/
|
*/
|
||||||
static create(message, code, error, smtp) {
|
static create(message, code, error, smtp) {
|
||||||
const msg = (error === null || error === void 0 ? void 0 : error.message) ? `${message} (${error.message})` : message;
|
const shouldUseError = error != null && error.message != null && error.message.length > 0;
|
||||||
|
const msg = shouldUseError ? `${message} (${error.message})` : message;
|
||||||
const err = new SMTPError(msg);
|
const err = new SMTPError(msg);
|
||||||
err.code = code;
|
err.code = code;
|
||||||
err.smtp = smtp;
|
err.smtp = smtp;
|
||||||
|
@ -1099,14 +1097,11 @@ class SMTPResponseMonitor {
|
||||||
constructor(stream, timeout, onerror) {
|
constructor(stream, timeout, onerror) {
|
||||||
let buffer = '';
|
let buffer = '';
|
||||||
const notify = () => {
|
const notify = () => {
|
||||||
var _a, _b;
|
|
||||||
if (buffer.length) {
|
if (buffer.length) {
|
||||||
// parse buffer for response codes
|
// parse buffer for response codes
|
||||||
const line = buffer.replace('\r', '');
|
const line = buffer.replace('\r', '');
|
||||||
if (!((_b = (_a = line
|
const code = line.trim().split(/\n/).pop();
|
||||||
.trim()
|
if (code == null || /^(\d{3})\s/.test(code) === false) {
|
||||||
.split(/\n/)
|
|
||||||
.pop()) === null || _a === void 0 ? void 0 : _a.match(/^(\d{3})\s/)) !== null && _b !== void 0 ? _b : false)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const match = line ? line.match(/(\d+)\s?(.*)/) : null;
|
const match = line ? line.match(/(\d+)\s?(.*)/) : null;
|
||||||
|
@ -1212,7 +1207,6 @@ class SMTPConnection extends EventEmitter {
|
||||||
* NOTE: `host` is trimmed before being used to establish a connection; however, the original untrimmed value will still be visible in configuration.
|
* NOTE: `host` is trimmed before being used to establish a connection; however, the original untrimmed value will still be visible in configuration.
|
||||||
*/
|
*/
|
||||||
constructor({ timeout, host, user, password, domain, port, ssl, tls, logger, authentication, } = {}) {
|
constructor({ timeout, host, user, password, domain, port, ssl, tls, logger, authentication, } = {}) {
|
||||||
var _a;
|
|
||||||
super();
|
super();
|
||||||
this.timeout = DEFAULT_TIMEOUT;
|
this.timeout = DEFAULT_TIMEOUT;
|
||||||
this.log = log;
|
this.log = log;
|
||||||
|
@ -1257,7 +1251,7 @@ class SMTPConnection extends EventEmitter {
|
||||||
}
|
}
|
||||||
this.port = port || (ssl ? SMTP_SSL_PORT : tls ? SMTP_TLS_PORT : SMTP_PORT);
|
this.port = port || (ssl ? SMTP_SSL_PORT : tls ? SMTP_TLS_PORT : SMTP_PORT);
|
||||||
this.loggedin = user && password ? false : true;
|
this.loggedin = user && password ? false : true;
|
||||||
if (!user && ((_a = password === null || password === void 0 ? void 0 : password.length) !== null && _a !== void 0 ? _a : 0) > 0) {
|
if (user == null && password != null && password.length > 0) {
|
||||||
throw new Error('`password` cannot be set without `user`');
|
throw new Error('`password` cannot be set without `user`');
|
||||||
}
|
}
|
||||||
// keep these strings hidden when quicky debugging/logging
|
// keep these strings hidden when quicky debugging/logging
|
||||||
|
@ -1505,7 +1499,6 @@ class SMTPConnection extends EventEmitter {
|
||||||
// MTA's will disconnect on an ehlo. Toss an exception if
|
// MTA's will disconnect on an ehlo. Toss an exception if
|
||||||
// that happens -ddm
|
// that happens -ddm
|
||||||
data.split('\n').forEach((ext) => {
|
data.split('\n').forEach((ext) => {
|
||||||
var _a, _b;
|
|
||||||
const parse = ext.match(/^(?:\d+[-=]?)\s*?([^\s]+)(?:\s+(.*)\s*?)?$/);
|
const parse = ext.match(/^(?:\d+[-=]?)\s*?([^\s]+)(?:\s+(.*)\s*?)?$/);
|
||||||
// To be able to communicate with as many SMTP servers as possible,
|
// To be able to communicate with as many SMTP servers as possible,
|
||||||
// we have to take the old-style auth advertisement into account,
|
// we have to take the old-style auth advertisement into account,
|
||||||
|
@ -1518,7 +1511,8 @@ class SMTPConnection extends EventEmitter {
|
||||||
// It's actually stricter, in that only spaces are allowed between
|
// It's actually stricter, in that only spaces are allowed between
|
||||||
// parameters, but were not going to check for that here. Note
|
// parameters, but were not going to check for that here. Note
|
||||||
// that the space isn't present if there are no parameters.
|
// that the space isn't present if there are no parameters.
|
||||||
this.features[(_b = (_a = parse[1]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : ''] = parse[2] || true;
|
const [, one = '', two = true] = parse;
|
||||||
|
this.features[one.toLowerCase()] = two;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1551,8 +1545,7 @@ class SMTPConnection extends EventEmitter {
|
||||||
* @returns {boolean} whether the extension exists
|
* @returns {boolean} whether the extension exists
|
||||||
*/
|
*/
|
||||||
has_extn(opt) {
|
has_extn(opt) {
|
||||||
var _a;
|
return this.features != null && this.features[opt.toLowerCase()] != null;
|
||||||
return ((_a = this.features) !== null && _a !== void 0 ? _a : {})[opt.toLowerCase()] === undefined;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
|
@ -1620,9 +1613,13 @@ class SMTPConnection extends EventEmitter {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
message(data) {
|
message(data) {
|
||||||
var _a, _b;
|
|
||||||
this.log(data);
|
this.log(data);
|
||||||
(_b = (_a = this.sock) === null || _a === void 0 ? void 0 : _a.write(data)) !== null && _b !== void 0 ? _b : this.log('no socket to write to');
|
if (this.sock != null) {
|
||||||
|
this.sock.write(data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.log('no socket to write to');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
|
@ -1686,15 +1683,13 @@ class SMTPConnection extends EventEmitter {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
login(callback, user, password, options = {}) {
|
login(callback, user, password, options = {}) {
|
||||||
var _a, _b;
|
|
||||||
const login = {
|
const login = {
|
||||||
user: user ? () => user : this.user,
|
user: user ? () => user : this.user,
|
||||||
password: password ? () => password : this.password,
|
password: password ? () => password : this.password,
|
||||||
method: (_b = (_a = options === null || options === void 0 ? void 0 : options.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : '',
|
method: options.method != null ? options.method.toUpperCase() : '',
|
||||||
};
|
};
|
||||||
const domain = (options === null || options === void 0 ? void 0 : options.domain) || this.domain;
|
const domain = options.domain || this.domain;
|
||||||
const initiate = (err, data) => {
|
const initiate = (err, data) => {
|
||||||
var _a;
|
|
||||||
if (err) {
|
if (err) {
|
||||||
caller(callback, err);
|
caller(callback, err);
|
||||||
return;
|
return;
|
||||||
|
@ -1722,7 +1717,8 @@ class SMTPConnection extends EventEmitter {
|
||||||
// less preferred methods.
|
// less preferred methods.
|
||||||
if (!method) {
|
if (!method) {
|
||||||
let auth = '';
|
let auth = '';
|
||||||
if (typeof ((_a = this.features) === null || _a === void 0 ? void 0 : _a['auth']) === 'string') {
|
if (this.features != null &&
|
||||||
|
typeof this.features['auth'] === 'string') {
|
||||||
auth = this.features['auth'];
|
auth = this.features['auth'];
|
||||||
}
|
}
|
||||||
for (const authMethod of this.authentication) {
|
for (const authMethod of this.authentication) {
|
||||||
|
@ -1926,12 +1922,11 @@ class SMTPClient {
|
||||||
createMessageStack(message, callback = function () {
|
createMessageStack(message, callback = function () {
|
||||||
/* ø */
|
/* ø */
|
||||||
}) {
|
}) {
|
||||||
var _a;
|
const [{ address: from = '' } = {}] = addressparser(message.header.from);
|
||||||
const [firstParsedAddress] = addressparser(message.header.from);
|
|
||||||
const stack = {
|
const stack = {
|
||||||
message,
|
message,
|
||||||
to: [],
|
to: new Array(),
|
||||||
from: firstParsedAddress === null || firstParsedAddress === void 0 ? void 0 : firstParsedAddress.address,
|
from,
|
||||||
callback: callback.bind(this),
|
callback: callback.bind(this),
|
||||||
};
|
};
|
||||||
const { header: { to, cc, bcc, 'return-path': returnPath }, } = message;
|
const { header: { to, cc, bcc, 'return-path': returnPath }, } = message;
|
||||||
|
@ -1947,8 +1942,8 @@ class SMTPClient {
|
||||||
if (typeof returnPath === 'string' && returnPath.length > 0) {
|
if (typeof returnPath === 'string' && returnPath.length > 0) {
|
||||||
const parsedAddresses = addressparser(returnPath);
|
const parsedAddresses = addressparser(returnPath);
|
||||||
if (parsedAddresses.length > 0) {
|
if (parsedAddresses.length > 0) {
|
||||||
const [firstParsedAddress] = parsedAddresses;
|
const [{ address = '' } = {}] = parsedAddresses;
|
||||||
stack.returnPath = (_a = firstParsedAddress === null || firstParsedAddress === void 0 ? void 0 : firstParsedAddress.address) !== null && _a !== void 0 ? _a : '';
|
stack.returnPath = address;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return stack;
|
return stack;
|
||||||
|
@ -2093,12 +2088,11 @@ class SMTPClient {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
_sendrcpt(stack) {
|
_sendrcpt(stack) {
|
||||||
var _a;
|
|
||||||
if (stack.to == null || typeof stack.to === 'string') {
|
if (stack.to == null || typeof stack.to === 'string') {
|
||||||
throw new TypeError('stack.to must be array');
|
throw new TypeError('stack.to must be array');
|
||||||
}
|
}
|
||||||
const to = (_a = stack.to.shift()) === null || _a === void 0 ? void 0 : _a.address;
|
const to = stack.to.shift();
|
||||||
this.smtp.rcpt(this._sendsmtp(stack, stack.to.length ? this._sendrcpt : this._senddata), `<${to}>`);
|
this.smtp.rcpt(this._sendsmtp(stack, stack.to.length ? this._sendrcpt : this._senddata), `<${to == null ? '' : to.address || ''}>`);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue