@mikestraczek/cms-auth
Version:
Authentication and user management for the CMS template
1,385 lines (1,380 loc) • 423 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
var __commonJS = (cb, mod) => function __require2() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
// ../../node_modules/nodemailer/lib/fetch/cookies.js
var require_cookies = __commonJS({
"../../node_modules/nodemailer/lib/fetch/cookies.js"(exports, module) {
"use strict";
var urllib = __require("url");
var SESSION_TIMEOUT = 1800;
var Cookies = class {
constructor(options) {
this.options = options || {};
this.cookies = [];
}
/**
* Stores a cookie string to the cookie storage
*
* @param {String} cookieStr Value from the 'Set-Cookie:' header
* @param {String} url Current URL
*/
set(cookieStr, url) {
let urlparts = urllib.parse(url || "");
let cookie = this.parse(cookieStr);
let domain;
if (cookie.domain) {
domain = cookie.domain.replace(/^\./, "");
if (
// can't be valid if the requested domain is shorter than current hostname
urlparts.hostname.length < domain.length || // prefix domains with dot to be sure that partial matches are not used
("." + urlparts.hostname).substr(-domain.length + 1) !== "." + domain
) {
cookie.domain = urlparts.hostname;
}
} else {
cookie.domain = urlparts.hostname;
}
if (!cookie.path) {
cookie.path = this.getPath(urlparts.pathname);
}
if (!cookie.expires) {
cookie.expires = new Date(Date.now() + (Number(this.options.sessionTimeout || SESSION_TIMEOUT) || SESSION_TIMEOUT) * 1e3);
}
return this.add(cookie);
}
/**
* Returns cookie string for the 'Cookie:' header.
*
* @param {String} url URL to check for
* @returns {String} Cookie header or empty string if no matches were found
*/
get(url) {
return this.list(url).map((cookie) => cookie.name + "=" + cookie.value).join("; ");
}
/**
* Lists all valied cookie objects for the specified URL
*
* @param {String} url URL to check for
* @returns {Array} An array of cookie objects
*/
list(url) {
let result = [];
let i;
let cookie;
for (i = this.cookies.length - 1; i >= 0; i--) {
cookie = this.cookies[i];
if (this.isExpired(cookie)) {
this.cookies.splice(i, i);
continue;
}
if (this.match(cookie, url)) {
result.unshift(cookie);
}
}
return result;
}
/**
* Parses cookie string from the 'Set-Cookie:' header
*
* @param {String} cookieStr String from the 'Set-Cookie:' header
* @returns {Object} Cookie object
*/
parse(cookieStr) {
let cookie = {};
(cookieStr || "").toString().split(";").forEach((cookiePart) => {
let valueParts = cookiePart.split("=");
let key = valueParts.shift().trim().toLowerCase();
let value = valueParts.join("=").trim();
let domain;
if (!key) {
return;
}
switch (key) {
case "expires":
value = new Date(value);
if (value.toString() !== "Invalid Date") {
cookie.expires = value;
}
break;
case "path":
cookie.path = value;
break;
case "domain":
domain = value.toLowerCase();
if (domain.length && domain.charAt(0) !== ".") {
domain = "." + domain;
}
cookie.domain = domain;
break;
case "max-age":
cookie.expires = new Date(Date.now() + (Number(value) || 0) * 1e3);
break;
case "secure":
cookie.secure = true;
break;
case "httponly":
cookie.httponly = true;
break;
default:
if (!cookie.name) {
cookie.name = key;
cookie.value = value;
}
}
});
return cookie;
}
/**
* Checks if a cookie object is valid for a specified URL
*
* @param {Object} cookie Cookie object
* @param {String} url URL to check for
* @returns {Boolean} true if cookie is valid for specifiec URL
*/
match(cookie, url) {
let urlparts = urllib.parse(url || "");
if (urlparts.hostname !== cookie.domain && (cookie.domain.charAt(0) !== "." || ("." + urlparts.hostname).substr(-cookie.domain.length) !== cookie.domain)) {
return false;
}
let path = this.getPath(urlparts.pathname);
if (path.substr(0, cookie.path.length) !== cookie.path) {
return false;
}
if (cookie.secure && urlparts.protocol !== "https:") {
return false;
}
return true;
}
/**
* Adds (or updates/removes if needed) a cookie object to the cookie storage
*
* @param {Object} cookie Cookie value to be stored
*/
add(cookie) {
let i;
let len;
if (!cookie || !cookie.name) {
return false;
}
for (i = 0, len = this.cookies.length; i < len; i++) {
if (this.compare(this.cookies[i], cookie)) {
if (this.isExpired(cookie)) {
this.cookies.splice(i, 1);
return false;
}
this.cookies[i] = cookie;
return true;
}
}
if (!this.isExpired(cookie)) {
this.cookies.push(cookie);
}
return true;
}
/**
* Checks if two cookie objects are the same
*
* @param {Object} a Cookie to check against
* @param {Object} b Cookie to check against
* @returns {Boolean} True, if the cookies are the same
*/
compare(a, b) {
return a.name === b.name && a.path === b.path && a.domain === b.domain && a.secure === b.secure && a.httponly === a.httponly;
}
/**
* Checks if a cookie is expired
*
* @param {Object} cookie Cookie object to check against
* @returns {Boolean} True, if the cookie is expired
*/
isExpired(cookie) {
return cookie.expires && cookie.expires < /* @__PURE__ */ new Date() || !cookie.value;
}
/**
* Returns normalized cookie path for an URL path argument
*
* @param {String} pathname
* @returns {String} Normalized path
*/
getPath(pathname) {
let path = (pathname || "/").split("/");
path.pop();
path = path.join("/").trim();
if (path.charAt(0) !== "/") {
path = "/" + path;
}
if (path.substr(-1) !== "/") {
path += "/";
}
return path;
}
};
module.exports = Cookies;
}
});
// ../../node_modules/nodemailer/package.json
var require_package = __commonJS({
"../../node_modules/nodemailer/package.json"(exports, module) {
module.exports = {
name: "nodemailer",
version: "7.0.5",
description: "Easy as cake e-mail sending from your Node.js applications",
main: "lib/nodemailer.js",
scripts: {
test: "node --test --test-concurrency=1 test/**/*.test.js test/**/*-test.js",
"test:coverage": "c8 node --test --test-concurrency=1 test/**/*.test.js test/**/*-test.js",
lint: "eslint .",
update: "rm -rf node_modules/ package-lock.json && ncu -u && npm install"
},
repository: {
type: "git",
url: "https://github.com/nodemailer/nodemailer.git"
},
keywords: [
"Nodemailer"
],
author: "Andris Reinman",
license: "MIT-0",
bugs: {
url: "https://github.com/nodemailer/nodemailer/issues"
},
homepage: "https://nodemailer.com/",
devDependencies: {
"@aws-sdk/client-sesv2": "3.839.0",
bunyan: "1.8.15",
c8: "10.1.3",
eslint: "8.57.0",
"eslint-config-nodemailer": "1.2.0",
"eslint-config-prettier": "9.1.0",
libbase64: "1.3.0",
libmime: "5.3.7",
libqp: "2.1.1",
"nodemailer-ntlm-auth": "1.0.4",
proxy: "1.0.2",
"proxy-test-server": "1.0.0",
"smtp-server": "3.14.0"
},
engines: {
node: ">=6.0.0"
}
};
}
});
// ../../node_modules/nodemailer/lib/fetch/index.js
var require_fetch = __commonJS({
"../../node_modules/nodemailer/lib/fetch/index.js"(exports, module) {
"use strict";
var http = __require("http");
var https = __require("https");
var urllib = __require("url");
var zlib = __require("zlib");
var PassThrough = __require("stream").PassThrough;
var Cookies = require_cookies();
var packageData = require_package();
var net = __require("net");
var MAX_REDIRECTS = 5;
module.exports = function(url, options) {
return nmfetch(url, options);
};
module.exports.Cookies = Cookies;
function nmfetch(url, options) {
options = options || {};
options.fetchRes = options.fetchRes || new PassThrough();
options.cookies = options.cookies || new Cookies();
options.redirects = options.redirects || 0;
options.maxRedirects = isNaN(options.maxRedirects) ? MAX_REDIRECTS : options.maxRedirects;
if (options.cookie) {
[].concat(options.cookie || []).forEach((cookie) => {
options.cookies.set(cookie, url);
});
options.cookie = false;
}
let fetchRes = options.fetchRes;
let parsed = urllib.parse(url);
let method = (options.method || "").toString().trim().toUpperCase() || "GET";
let finished = false;
let cookies;
let body;
let handler = parsed.protocol === "https:" ? https : http;
let headers = {
"accept-encoding": "gzip,deflate",
"user-agent": "nodemailer/" + packageData.version
};
Object.keys(options.headers || {}).forEach((key) => {
headers[key.toLowerCase().trim()] = options.headers[key];
});
if (options.userAgent) {
headers["user-agent"] = options.userAgent;
}
if (parsed.auth) {
headers.Authorization = "Basic " + Buffer.from(parsed.auth).toString("base64");
}
if (cookies = options.cookies.get(url)) {
headers.cookie = cookies;
}
if (options.body) {
if (options.contentType !== false) {
headers["Content-Type"] = options.contentType || "application/x-www-form-urlencoded";
}
if (typeof options.body.pipe === "function") {
headers["Transfer-Encoding"] = "chunked";
body = options.body;
body.on("error", (err) => {
if (finished) {
return;
}
finished = true;
err.type = "FETCH";
err.sourceUrl = url;
fetchRes.emit("error", err);
});
} else {
if (options.body instanceof Buffer) {
body = options.body;
} else if (typeof options.body === "object") {
try {
body = Buffer.from(
Object.keys(options.body).map((key) => {
let value = options.body[key].toString().trim();
return encodeURIComponent(key) + "=" + encodeURIComponent(value);
}).join("&")
);
} catch (E) {
if (finished) {
return;
}
finished = true;
E.type = "FETCH";
E.sourceUrl = url;
fetchRes.emit("error", E);
return;
}
} else {
body = Buffer.from(options.body.toString().trim());
}
headers["Content-Type"] = options.contentType || "application/x-www-form-urlencoded";
headers["Content-Length"] = body.length;
}
method = (options.method || "").toString().trim().toUpperCase() || "POST";
}
let req;
let reqOptions = {
method,
host: parsed.hostname,
path: parsed.path,
port: parsed.port ? parsed.port : parsed.protocol === "https:" ? 443 : 80,
headers,
rejectUnauthorized: false,
agent: false
};
if (options.tls) {
Object.keys(options.tls).forEach((key) => {
reqOptions[key] = options.tls[key];
});
}
if (parsed.protocol === "https:" && parsed.hostname && parsed.hostname !== reqOptions.host && !net.isIP(parsed.hostname) && !reqOptions.servername) {
reqOptions.servername = parsed.hostname;
}
try {
req = handler.request(reqOptions);
} catch (E) {
finished = true;
setImmediate(() => {
E.type = "FETCH";
E.sourceUrl = url;
fetchRes.emit("error", E);
});
return fetchRes;
}
if (options.timeout) {
req.setTimeout(options.timeout, () => {
if (finished) {
return;
}
finished = true;
req.abort();
let err = new Error("Request Timeout");
err.type = "FETCH";
err.sourceUrl = url;
fetchRes.emit("error", err);
});
}
req.on("error", (err) => {
if (finished) {
return;
}
finished = true;
err.type = "FETCH";
err.sourceUrl = url;
fetchRes.emit("error", err);
});
req.on("response", (res) => {
let inflate;
if (finished) {
return;
}
switch (res.headers["content-encoding"]) {
case "gzip":
case "deflate":
inflate = zlib.createUnzip();
break;
}
if (res.headers["set-cookie"]) {
[].concat(res.headers["set-cookie"] || []).forEach((cookie) => {
options.cookies.set(cookie, url);
});
}
if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location) {
options.redirects++;
if (options.redirects > options.maxRedirects) {
finished = true;
let err = new Error("Maximum redirect count exceeded");
err.type = "FETCH";
err.sourceUrl = url;
fetchRes.emit("error", err);
req.abort();
return;
}
options.method = "GET";
options.body = false;
return nmfetch(urllib.resolve(url, res.headers.location), options);
}
fetchRes.statusCode = res.statusCode;
fetchRes.headers = res.headers;
if (res.statusCode >= 300 && !options.allowErrorResponse) {
finished = true;
let err = new Error("Invalid status code " + res.statusCode);
err.type = "FETCH";
err.sourceUrl = url;
fetchRes.emit("error", err);
req.abort();
return;
}
res.on("error", (err) => {
if (finished) {
return;
}
finished = true;
err.type = "FETCH";
err.sourceUrl = url;
fetchRes.emit("error", err);
req.abort();
});
if (inflate) {
res.pipe(inflate).pipe(fetchRes);
inflate.on("error", (err) => {
if (finished) {
return;
}
finished = true;
err.type = "FETCH";
err.sourceUrl = url;
fetchRes.emit("error", err);
req.abort();
});
} else {
res.pipe(fetchRes);
}
});
setImmediate(() => {
if (body) {
try {
if (typeof body.pipe === "function") {
return body.pipe(req);
} else {
req.write(body);
}
} catch (err) {
finished = true;
err.type = "FETCH";
err.sourceUrl = url;
fetchRes.emit("error", err);
return;
}
}
req.end();
});
return fetchRes;
}
}
});
// ../../node_modules/nodemailer/lib/shared/index.js
var require_shared = __commonJS({
"../../node_modules/nodemailer/lib/shared/index.js"(exports, module) {
"use strict";
var urllib = __require("url");
var util = __require("util");
var fs = __require("fs");
var nmfetch = require_fetch();
var dns = __require("dns");
var net = __require("net");
var os = __require("os");
var DNS_TTL = 5 * 60 * 1e3;
var networkInterfaces;
try {
networkInterfaces = os.networkInterfaces();
} catch (err) {
}
module.exports.networkInterfaces = networkInterfaces;
var isFamilySupported = (family, allowInternal) => {
let networkInterfaces2 = module.exports.networkInterfaces;
if (!networkInterfaces2) {
return true;
}
const familySupported = (
// crux that replaces Object.values(networkInterfaces) as Object.values is not supported in nodejs v6
Object.keys(networkInterfaces2).map((key) => networkInterfaces2[key]).reduce((acc, val) => acc.concat(val), []).filter((i) => !i.internal || allowInternal).filter((i) => i.family === "IPv" + family || i.family === family).length > 0
);
return familySupported;
};
var resolver = (family, hostname, options, callback) => {
options = options || {};
const familySupported = isFamilySupported(family, options.allowInternalNetworkInterfaces);
if (!familySupported) {
return callback(null, []);
}
const resolver2 = dns.Resolver ? new dns.Resolver(options) : dns;
resolver2["resolve" + family](hostname, (err, addresses) => {
if (err) {
switch (err.code) {
case dns.NODATA:
case dns.NOTFOUND:
case dns.NOTIMP:
case dns.SERVFAIL:
case dns.CONNREFUSED:
case dns.REFUSED:
case "EAI_AGAIN":
return callback(null, []);
}
return callback(err);
}
return callback(null, Array.isArray(addresses) ? addresses : [].concat(addresses || []));
});
};
var dnsCache = module.exports.dnsCache = /* @__PURE__ */ new Map();
var formatDNSValue = (value, extra) => {
if (!value) {
return Object.assign({}, extra || {});
}
return Object.assign(
{
servername: value.servername,
host: !value.addresses || !value.addresses.length ? null : value.addresses.length === 1 ? value.addresses[0] : value.addresses[Math.floor(Math.random() * value.addresses.length)]
},
extra || {}
);
};
module.exports.resolveHostname = (options, callback) => {
options = options || {};
if (!options.host && options.servername) {
options.host = options.servername;
}
if (!options.host || net.isIP(options.host)) {
let value = {
addresses: [options.host],
servername: options.servername || false
};
return callback(
null,
formatDNSValue(value, {
cached: false
})
);
}
let cached;
if (dnsCache.has(options.host)) {
cached = dnsCache.get(options.host);
if (!cached.expires || cached.expires >= Date.now()) {
return callback(
null,
formatDNSValue(cached.value, {
cached: true
})
);
}
}
resolver(4, options.host, options, (err, addresses) => {
if (err) {
if (cached) {
return callback(
null,
formatDNSValue(cached.value, {
cached: true,
error: err
})
);
}
return callback(err);
}
if (addresses && addresses.length) {
let value = {
addresses,
servername: options.servername || options.host
};
dnsCache.set(options.host, {
value,
expires: Date.now() + (options.dnsTtl || DNS_TTL)
});
return callback(
null,
formatDNSValue(value, {
cached: false
})
);
}
resolver(6, options.host, options, (err2, addresses2) => {
if (err2) {
if (cached) {
return callback(
null,
formatDNSValue(cached.value, {
cached: true,
error: err2
})
);
}
return callback(err2);
}
if (addresses2 && addresses2.length) {
let value = {
addresses: addresses2,
servername: options.servername || options.host
};
dnsCache.set(options.host, {
value,
expires: Date.now() + (options.dnsTtl || DNS_TTL)
});
return callback(
null,
formatDNSValue(value, {
cached: false
})
);
}
try {
dns.lookup(options.host, { all: true }, (err3, addresses3) => {
if (err3) {
if (cached) {
return callback(
null,
formatDNSValue(cached.value, {
cached: true,
error: err3
})
);
}
return callback(err3);
}
let address = addresses3 ? addresses3.filter((addr) => isFamilySupported(addr.family)).map((addr) => addr.address).shift() : false;
if (addresses3 && addresses3.length && !address) {
console.warn(`Failed to resolve IPv${addresses3[0].family} addresses with current network`);
}
if (!address && cached) {
return callback(
null,
formatDNSValue(cached.value, {
cached: true
})
);
}
let value = {
addresses: address ? [address] : [options.host],
servername: options.servername || options.host
};
dnsCache.set(options.host, {
value,
expires: Date.now() + (options.dnsTtl || DNS_TTL)
});
return callback(
null,
formatDNSValue(value, {
cached: false
})
);
});
} catch (err3) {
if (cached) {
return callback(
null,
formatDNSValue(cached.value, {
cached: true,
error: err3
})
);
}
return callback(err3);
}
});
});
};
module.exports.parseConnectionUrl = (str) => {
str = str || "";
let options = {};
[urllib.parse(str, true)].forEach((url) => {
let auth;
switch (url.protocol) {
case "smtp:":
options.secure = false;
break;
case "smtps:":
options.secure = true;
break;
case "direct:":
options.direct = true;
break;
}
if (!isNaN(url.port) && Number(url.port)) {
options.port = Number(url.port);
}
if (url.hostname) {
options.host = url.hostname;
}
if (url.auth) {
auth = url.auth.split(":");
if (!options.auth) {
options.auth = {};
}
options.auth.user = auth.shift();
options.auth.pass = auth.join(":");
}
Object.keys(url.query || {}).forEach((key) => {
let obj = options;
let lKey = key;
let value = url.query[key];
if (!isNaN(value)) {
value = Number(value);
}
switch (value) {
case "true":
value = true;
break;
case "false":
value = false;
break;
}
if (key.indexOf("tls.") === 0) {
lKey = key.substr(4);
if (!options.tls) {
options.tls = {};
}
obj = options.tls;
} else if (key.indexOf(".") >= 0) {
return;
}
if (!(lKey in obj)) {
obj[lKey] = value;
}
});
});
return options;
};
module.exports._logFunc = (logger, level, defaults, data, message, ...args) => {
let entry = {};
Object.keys(defaults || {}).forEach((key) => {
if (key !== "level") {
entry[key] = defaults[key];
}
});
Object.keys(data || {}).forEach((key) => {
if (key !== "level") {
entry[key] = data[key];
}
});
logger[level](entry, message, ...args);
};
module.exports.getLogger = (options, defaults) => {
options = options || {};
let response = {};
let levels = ["trace", "debug", "info", "warn", "error", "fatal"];
if (!options.logger) {
levels.forEach((level) => {
response[level] = () => false;
});
return response;
}
let logger = options.logger;
if (options.logger === true) {
logger = createDefaultLogger(levels);
}
levels.forEach((level) => {
response[level] = (data, message, ...args) => {
module.exports._logFunc(logger, level, defaults, data, message, ...args);
};
});
return response;
};
module.exports.callbackPromise = (resolve, reject) => function() {
let args = Array.from(arguments);
let err = args.shift();
if (err) {
reject(err);
} else {
resolve(...args);
}
};
module.exports.parseDataURI = (uri) => {
let input = uri;
let commaPos = input.indexOf(",");
if (!commaPos) {
return uri;
}
let data = input.substring(commaPos + 1);
let metaStr = input.substring("data:".length, commaPos);
let encoding;
let metaEntries = metaStr.split(";");
let lastMetaEntry = metaEntries.length > 1 ? metaEntries[metaEntries.length - 1] : false;
if (lastMetaEntry && lastMetaEntry.indexOf("=") < 0) {
encoding = lastMetaEntry.toLowerCase();
metaEntries.pop();
}
let contentType = metaEntries.shift() || "application/octet-stream";
let params = {};
for (let entry of metaEntries) {
let sep = entry.indexOf("=");
if (sep >= 0) {
let key = entry.substring(0, sep);
let value = entry.substring(sep + 1);
params[key] = value;
}
}
switch (encoding) {
case "base64":
data = Buffer.from(data, "base64");
break;
case "utf8":
data = Buffer.from(data);
break;
default:
try {
data = Buffer.from(decodeURIComponent(data));
} catch (err) {
data = Buffer.from(data);
}
data = Buffer.from(data);
}
return { data, encoding, contentType, params };
};
module.exports.resolveContent = (data, key, callback) => {
let promise;
if (!callback) {
promise = new Promise((resolve, reject) => {
callback = module.exports.callbackPromise(resolve, reject);
});
}
let content = data && data[key] && data[key].content || data[key];
let contentStream;
let encoding = (typeof data[key] === "object" && data[key].encoding || "utf8").toString().toLowerCase().replace(/[-_\s]/g, "");
if (!content) {
return callback(null, content);
}
if (typeof content === "object") {
if (typeof content.pipe === "function") {
return resolveStream(content, (err, value) => {
if (err) {
return callback(err);
}
if (data[key].content) {
data[key].content = value;
} else {
data[key] = value;
}
callback(null, value);
});
} else if (/^https?:\/\//i.test(content.path || content.href)) {
contentStream = nmfetch(content.path || content.href);
return resolveStream(contentStream, callback);
} else if (/^data:/i.test(content.path || content.href)) {
let parsedDataUri = module.exports.parseDataURI(content.path || content.href);
if (!parsedDataUri || !parsedDataUri.data) {
return callback(null, Buffer.from(0));
}
return callback(null, parsedDataUri.data);
} else if (content.path) {
return resolveStream(fs.createReadStream(content.path), callback);
}
}
if (typeof data[key].content === "string" && !["utf8", "usascii", "ascii"].includes(encoding)) {
content = Buffer.from(data[key].content, encoding);
}
setImmediate(() => callback(null, content));
return promise;
};
module.exports.assign = function() {
let args = Array.from(arguments);
let target = args.shift() || {};
args.forEach((source) => {
Object.keys(source || {}).forEach((key) => {
if (["tls", "auth"].includes(key) && source[key] && typeof source[key] === "object") {
if (!target[key]) {
target[key] = {};
}
Object.keys(source[key]).forEach((subKey) => {
target[key][subKey] = source[key][subKey];
});
} else {
target[key] = source[key];
}
});
});
return target;
};
module.exports.encodeXText = (str) => {
if (!/[^\x21-\x2A\x2C-\x3C\x3E-\x7E]/.test(str)) {
return str;
}
let buf = Buffer.from(str);
let result = "";
for (let i = 0, len = buf.length; i < len; i++) {
let c = buf[i];
if (c < 33 || c > 126 || c === 43 || c === 61) {
result += "+" + (c < 16 ? "0" : "") + c.toString(16).toUpperCase();
} else {
result += String.fromCharCode(c);
}
}
return result;
};
function resolveStream(stream, callback) {
let responded = false;
let chunks = [];
let chunklen = 0;
stream.on("error", (err) => {
if (responded) {
return;
}
responded = true;
callback(err);
});
stream.on("readable", () => {
let chunk;
while ((chunk = stream.read()) !== null) {
chunks.push(chunk);
chunklen += chunk.length;
}
});
stream.on("end", () => {
if (responded) {
return;
}
responded = true;
let value;
try {
value = Buffer.concat(chunks, chunklen);
} catch (E) {
return callback(E);
}
callback(null, value);
});
}
function createDefaultLogger(levels) {
let levelMaxLen = 0;
let levelNames = /* @__PURE__ */ new Map();
levels.forEach((level) => {
if (level.length > levelMaxLen) {
levelMaxLen = level.length;
}
});
levels.forEach((level) => {
let levelName = level.toUpperCase();
if (levelName.length < levelMaxLen) {
levelName += " ".repeat(levelMaxLen - levelName.length);
}
levelNames.set(level, levelName);
});
let print = (level, entry, message, ...args) => {
let prefix = "";
if (entry) {
if (entry.tnx === "server") {
prefix = "S: ";
} else if (entry.tnx === "client") {
prefix = "C: ";
}
if (entry.sid) {
prefix = "[" + entry.sid + "] " + prefix;
}
if (entry.cid) {
prefix = "[#" + entry.cid + "] " + prefix;
}
}
message = util.format(message, ...args);
message.split(/\r?\n/).forEach((line) => {
console.log("[%s] %s %s", (/* @__PURE__ */ new Date()).toISOString().substr(0, 19).replace(/T/, " "), levelNames.get(level), prefix + line);
});
};
let logger = {};
levels.forEach((level) => {
logger[level] = print.bind(null, level);
});
return logger;
}
}
});
// ../../node_modules/nodemailer/lib/mime-funcs/mime-types.js
var require_mime_types = __commonJS({
"../../node_modules/nodemailer/lib/mime-funcs/mime-types.js"(exports, module) {
"use strict";
var path = __require("path");
var defaultMimeType = "application/octet-stream";
var defaultExtension = "bin";
var mimeTypes = /* @__PURE__ */ new Map([
["application/acad", "dwg"],
["application/applixware", "aw"],
["application/arj", "arj"],
["application/atom+xml", "xml"],
["application/atomcat+xml", "atomcat"],
["application/atomsvc+xml", "atomsvc"],
["application/base64", ["mm", "mme"]],
["application/binhex", "hqx"],
["application/binhex4", "hqx"],
["application/book", ["book", "boo"]],
["application/ccxml+xml,", "ccxml"],
["application/cdf", "cdf"],
["application/cdmi-capability", "cdmia"],
["application/cdmi-container", "cdmic"],
["application/cdmi-domain", "cdmid"],
["application/cdmi-object", "cdmio"],
["application/cdmi-queue", "cdmiq"],
["application/clariscad", "ccad"],
["application/commonground", "dp"],
["application/cu-seeme", "cu"],
["application/davmount+xml", "davmount"],
["application/drafting", "drw"],
["application/dsptype", "tsp"],
["application/dssc+der", "dssc"],
["application/dssc+xml", "xdssc"],
["application/dxf", "dxf"],
["application/ecmascript", ["js", "es"]],
["application/emma+xml", "emma"],
["application/envoy", "evy"],
["application/epub+zip", "epub"],
["application/excel", ["xls", "xl", "xla", "xlb", "xlc", "xld", "xlk", "xll", "xlm", "xlt", "xlv", "xlw"]],
["application/exi", "exi"],
["application/font-tdpfr", "pfr"],
["application/fractals", "fif"],
["application/freeloader", "frl"],
["application/futuresplash", "spl"],
["application/geo+json", "geojson"],
["application/gnutar", "tgz"],
["application/groupwise", "vew"],
["application/hlp", "hlp"],
["application/hta", "hta"],
["application/hyperstudio", "stk"],
["application/i-deas", "unv"],
["application/iges", ["iges", "igs"]],
["application/inf", "inf"],
["application/internet-property-stream", "acx"],
["application/ipfix", "ipfix"],
["application/java", "class"],
["application/java-archive", "jar"],
["application/java-byte-code", "class"],
["application/java-serialized-object", "ser"],
["application/java-vm", "class"],
["application/javascript", "js"],
["application/json", "json"],
["application/lha", "lha"],
["application/lzx", "lzx"],
["application/mac-binary", "bin"],
["application/mac-binhex", "hqx"],
["application/mac-binhex40", "hqx"],
["application/mac-compactpro", "cpt"],
["application/macbinary", "bin"],
["application/mads+xml", "mads"],
["application/marc", "mrc"],
["application/marcxml+xml", "mrcx"],
["application/mathematica", "ma"],
["application/mathml+xml", "mathml"],
["application/mbedlet", "mbd"],
["application/mbox", "mbox"],
["application/mcad", "mcd"],
["application/mediaservercontrol+xml", "mscml"],
["application/metalink4+xml", "meta4"],
["application/mets+xml", "mets"],
["application/mime", "aps"],
["application/mods+xml", "mods"],
["application/mp21", "m21"],
["application/mp4", "mp4"],
["application/mspowerpoint", ["ppt", "pot", "pps", "ppz"]],
["application/msword", ["doc", "dot", "w6w", "wiz", "word"]],
["application/mswrite", "wri"],
["application/mxf", "mxf"],
["application/netmc", "mcp"],
["application/octet-stream", ["*"]],
["application/oda", "oda"],
["application/oebps-package+xml", "opf"],
["application/ogg", "ogx"],
["application/olescript", "axs"],
["application/onenote", "onetoc"],
["application/patch-ops-error+xml", "xer"],
["application/pdf", "pdf"],
["application/pgp-encrypted", "asc"],
["application/pgp-signature", "pgp"],
["application/pics-rules", "prf"],
["application/pkcs-12", "p12"],
["application/pkcs-crl", "crl"],
["application/pkcs10", "p10"],
["application/pkcs7-mime", ["p7c", "p7m"]],
["application/pkcs7-signature", "p7s"],
["application/pkcs8", "p8"],
["application/pkix-attr-cert", "ac"],
["application/pkix-cert", ["cer", "crt"]],
["application/pkix-crl", "crl"],
["application/pkix-pkipath", "pkipath"],
["application/pkixcmp", "pki"],
["application/plain", "text"],
["application/pls+xml", "pls"],
["application/postscript", ["ps", "ai", "eps"]],
["application/powerpoint", "ppt"],
["application/pro_eng", ["part", "prt"]],
["application/prs.cww", "cww"],
["application/pskc+xml", "pskcxml"],
["application/rdf+xml", "rdf"],
["application/reginfo+xml", "rif"],
["application/relax-ng-compact-syntax", "rnc"],
["application/resource-lists+xml", "rl"],
["application/resource-lists-diff+xml", "rld"],
["application/ringing-tones", "rng"],
["application/rls-services+xml", "rs"],
["application/rsd+xml", "rsd"],
["application/rss+xml", "xml"],
["application/rtf", ["rtf", "rtx"]],
["application/sbml+xml", "sbml"],
["application/scvp-cv-request", "scq"],
["application/scvp-cv-response", "scs"],
["application/scvp-vp-request", "spq"],
["application/scvp-vp-response", "spp"],
["application/sdp", "sdp"],
["application/sea", "sea"],
["application/set", "set"],
["application/set-payment-initiation", "setpay"],
["application/set-registration-initiation", "setreg"],
["application/shf+xml", "shf"],
["application/sla", "stl"],
["application/smil", ["smi", "smil"]],
["application/smil+xml", "smi"],
["application/solids", "sol"],
["application/sounder", "sdr"],
["application/sparql-query", "rq"],
["application/sparql-results+xml", "srx"],
["application/srgs", "gram"],
["application/srgs+xml", "grxml"],
["application/sru+xml", "sru"],
["application/ssml+xml", "ssml"],
["application/step", ["step", "stp"]],
["application/streamingmedia", "ssm"],
["application/tei+xml", "tei"],
["application/thraud+xml", "tfi"],
["application/timestamped-data", "tsd"],
["application/toolbook", "tbk"],
["application/vda", "vda"],
["application/vnd.3gpp.pic-bw-large", "plb"],
["application/vnd.3gpp.pic-bw-small", "psb"],
["application/vnd.3gpp.pic-bw-var", "pvb"],
["application/vnd.3gpp2.tcap", "tcap"],
["application/vnd.3m.post-it-notes", "pwn"],
["application/vnd.accpac.simply.aso", "aso"],
["application/vnd.accpac.simply.imp", "imp"],
["application/vnd.acucobol", "acu"],
["application/vnd.acucorp", "atc"],
["application/vnd.adobe.air-application-installer-package+zip", "air"],
["application/vnd.adobe.fxp", "fxp"],
["application/vnd.adobe.xdp+xml", "xdp"],
["application/vnd.adobe.xfdf", "xfdf"],
["application/vnd.ahead.space", "ahead"],
["application/vnd.airzip.filesecure.azf", "azf"],
["application/vnd.airzip.filesecure.azs", "azs"],
["application/vnd.amazon.ebook", "azw"],
["application/vnd.americandynamics.acc", "acc"],
["application/vnd.amiga.ami", "ami"],
["application/vnd.android.package-archive", "apk"],
["application/vnd.anser-web-certificate-issue-initiation", "cii"],
["application/vnd.anser-web-funds-transfer-initiation", "fti"],
["application/vnd.antix.game-component", "atx"],
["application/vnd.apple.installer+xml", "mpkg"],
["application/vnd.apple.mpegurl", "m3u8"],
["application/vnd.aristanetworks.swi", "swi"],
["application/vnd.audiograph", "aep"],
["application/vnd.blueice.multipass", "mpm"],
["application/vnd.bmi", "bmi"],
["application/vnd.businessobjects", "rep"],
["application/vnd.chemdraw+xml", "cdxml"],
["application/vnd.chipnuts.karaoke-mmd", "mmd"],
["application/vnd.cinderella", "cdy"],
["application/vnd.claymore", "cla"],
["application/vnd.cloanto.rp9", "rp9"],
["application/vnd.clonk.c4group", "c4g"],
["application/vnd.cluetrust.cartomobile-config", "c11amc"],
["application/vnd.cluetrust.cartomobile-config-pkg", "c11amz"],
["application/vnd.commonspace", "csp"],
["application/vnd.contact.cmsg", "cdbcmsg"],
["application/vnd.cosmocaller", "cmc"],
["application/vnd.crick.clicker", "clkx"],
["application/vnd.crick.clicker.keyboard", "clkk"],
["application/vnd.crick.clicker.palette", "clkp"],
["application/vnd.crick.clicker.template", "clkt"],
["application/vnd.crick.clicker.wordbank", "clkw"],
["application/vnd.criticaltools.wbs+xml", "wbs"],
["application/vnd.ctc-posml", "pml"],
["application/vnd.cups-ppd", "ppd"],
["application/vnd.curl.car", "car"],
["application/vnd.curl.pcurl", "pcurl"],
["application/vnd.data-vision.rdz", "rdz"],
["application/vnd.denovo.fcselayout-link", "fe_launch"],
["application/vnd.dna", "dna"],
["application/vnd.dolby.mlp", "mlp"],
["application/vnd.dpgraph", "dpg"],
["application/vnd.dreamfactory", "dfac"],
["application/vnd.dvb.ait", "ait"],
["application/vnd.dvb.service", "svc"],
["application/vnd.dynageo", "geo"],
["application/vnd.ecowin.chart", "mag"],
["application/vnd.enliven", "nml"],
["application/vnd.epson.esf", "esf"],
["application/vnd.epson.msf", "msf"],
["application/vnd.epson.quickanime", "qam"],
["application/vnd.epson.salt", "slt"],
["application/vnd.epson.ssf", "ssf"],
["application/vnd.eszigno3+xml", "es3"],
["application/vnd.ezpix-album", "ez2"],
["application/vnd.ezpix-package", "ez3"],
["application/vnd.fdf", "fdf"],
["application/vnd.fdsn.seed", "seed"],
["application/vnd.flographit", "gph"],
["application/vnd.fluxtime.clip", "ftc"],
["application/vnd.framemaker", "fm"],
["application/vnd.frogans.fnc", "fnc"],
["application/vnd.frogans.ltf", "ltf"],
["application/vnd.fsc.weblaunch", "fsc"],
["application/vnd.fujitsu.oasys", "oas"],
["application/vnd.fujitsu.oasys2", "oa2"],
["application/vnd.fujitsu.oasys3", "oa3"],
["application/vnd.fujitsu.oasysgp", "fg5"],
["application/vnd.fujitsu.oasysprs", "bh2"],
["application/vnd.fujixerox.ddd", "ddd"],
["application/vnd.fujixerox.docuworks", "xdw"],
["application/vnd.fujixerox.docuworks.binder", "xbd"],
["application/vnd.fuzzysheet", "fzs"],
["application/vnd.genomatix.tuxedo", "txd"],
["application/vnd.geogebra.file", "ggb"],
["application/vnd.geogebra.tool", "ggt"],
["application/vnd.geometry-explorer", "gex"],
["application/vnd.geonext", "gxt"],
["application/vnd.geoplan", "g2w"],
["application/vnd.geospace", "g3w"],
["application/vnd.gmx", "gmx"],
["application/vnd.google-earth.kml+xml", "kml"],
["application/vnd.google-earth.kmz", "kmz"],
["application/vnd.grafeq", "gqf"],
["application/vnd.groove-account", "gac"],
["application/vnd.groove-help", "ghf"],
["application/vnd.groove-identity-message", "gim"],
["application/vnd.groove-injector", "grv"],
["application/vnd.groove-tool-message", "gtm"],
["application/vnd.groove-tool-template", "tpl"],
["application/vnd.groove-vcard", "vcg"],
["application/vnd.hal+xml", "hal"],
["application/vnd.handheld-entertainment+xml", "zmm"],
["application/vnd.hbci", "hbci"],
["application/vnd.hhe.lesson-player", "les"],
["application/vnd.hp-hpgl", ["hgl", "hpg", "hpgl"]],
["application/vnd.hp-hpid", "hpid"],
["application/vnd.hp-hps", "hps"],
["application/vnd.hp-jlyt", "jlt"],
["application/vnd.hp-pcl", "pcl"],
["application/vnd.hp-pclxl", "pclxl"],
["application/vnd.hydrostatix.sof-data", "sfd-hdstx"],
["application/vnd.hzn-3d-crossword", "x3d"],
["application/vnd.ibm.minipay", "mpy"],
["application/vnd.ibm.modcap", "afp"],
["application/vnd.ibm.rights-management", "irm"],
["application/vnd.ibm.secure-container", "sc"],
["application/vnd.iccprofile", "icc"],
["application/vnd.igloader", "igl"],
["application/vnd.immervision-ivp", "ivp"],
["application/vnd.immervision-ivu", "ivu"],
["application/vnd.insors.igm", "igm"],
["application/vnd.intercon.formnet", "xpw"],
["application/vnd.intergeo", "i2g"],
["application/vnd.intu.qbo", "qbo"],
["application/vnd.intu.qfx", "qfx"],
["application/vnd.ipunplugged.rcprofile", "rcprofile"],
["application/vnd.irepository.package+xml", "irp"],
["application/vnd.is-xpr", "xpr"],
["application/vnd.isac.fcs", "fcs"],
["application/vnd.jam", "jam"],
["application/vnd.jcp.javame.midlet-rms", "rms"],
["application/vnd.jisp", "jisp"],
["application/vnd.joost.joda-archive", "joda"],
["application/vnd.kahootz", "ktz"],
["application/vnd.kde.karbon", "karbon"],
["application/vnd.kde.kchart", "chrt"],
["application/vnd.kde.kformula", "kfo"],
["application/vnd.kde.kivio", "flw"],
["application/vnd.kde.kontour", "kon"],
["application/vnd.kde.kpresenter", "kpr"],
["application/vnd.kde.kspread", "ksp"],
["application/vnd.kde.kword", "kwd"],
["application/vnd.kenameaapp", "htke"],
["application/vnd.kidspiration", "kia"],
["application/vnd.kinar", "kne"],
["application/vnd.koan", "skp"],
["application/vnd.kodak-descriptor", "sse"],
["application/vnd.las.las+xml", "lasxml"],
["application/vnd.llamagraphics.life-balance.desktop", "lbd"],
["application/vnd.llamagraphics.life-balance.exchange+xml", "lbe"],
["application/vnd.lotus-1-2-3", "123"],
["application/vnd.lotus-approach", "apr"],
["application/vnd.lotus-freelance", "pre"],
["application/vnd.lotus-notes", "nsf"],
["application/vnd.lotus-organizer", "org"],
["application/vnd.lotus-screencam", "scm"],
["application/vnd.lotus-wordpro", "lwp"],
["application/vnd.macports.portpkg", "portpkg"],
["application/vnd.mcd", "mcd"],
["application/vnd.medcalcdata", "mc1"],
["application/vnd.mediastation.cdkey", "cdkey"],
["application/vnd.mfer", "mwf"],
["application/vnd.mfmp", "mfm"],
["application/vnd.micrografx.flo", "flo"],
["application/vnd.micrografx.igx", "igx"],
["application/vnd.mif", "mif"],
["application/vnd.mobius.daf", "daf"],
["application/vnd.mobius.dis", "dis"],
["application/vnd.mobius.mbk", "mbk"],
["application/vnd.mobius.mqy", "mqy"],
["application/vnd.mobius.msl", "msl"],
["application/vnd.mobius.plc", "plc"],
["application/vnd.mobius.txf", "txf"],
["application/vnd.mophun.application", "mpn"],
["application/vnd.mophun.certificate", "mpc"],
["application/vnd.mozilla.xul+xml", "xul"],
["application/vnd.ms-artgalry", "cil"],
["application/vnd.ms-cab-compressed", "cab"],
["application/vnd.ms-excel", ["xls", "xla", "xlc", "xlm", "xlt",