Files
send-mail/node_modules/nodemailer/dist/cjs/well-known/index.js
T

42 lines
1.5 KiB
JavaScript
Raw Normal View History

2026-09-15 13:00:32 +02:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = wellKnown;
const services_js_1 = require("./services.js");
2020-02-29 23:01:03 +01:00
const normalized = {};
2026-09-15 13:00:32 +02:00
Object.keys(services_js_1.services).forEach(key => {
const service = services_js_1.services[key];
2026-04-28 12:50:45 +02:00
const normalizedService = normalizeService(service);
normalized[normalizeKey(key)] = normalizedService;
2020-02-29 23:01:03 +01:00
[].concat(service.aliases || []).forEach(alias => {
2026-04-28 12:50:45 +02:00
normalized[normalizeKey(alias)] = normalizedService;
2020-02-29 23:01:03 +01:00
});
[].concat(service.domains || []).forEach(domain => {
2026-04-28 12:50:45 +02:00
normalized[normalizeKey(domain)] = normalizedService;
2020-02-29 23:01:03 +01:00
});
});
function normalizeKey(key) {
return key.replace(/[^a-zA-Z0-9.-]/g, '').toLowerCase();
}
function normalizeService(service) {
2026-04-28 12:50:45 +02:00
const response = {};
2020-02-29 23:01:03 +01:00
Object.keys(service).forEach(key => {
2026-04-28 12:50:45 +02:00
if (!['domains', 'aliases'].includes(key)) {
2020-02-29 23:01:03 +01:00
response[key] = service[key];
}
});
return response;
}
/**
* Resolves SMTP config for given key. Key can be a name (like 'Gmail'), alias (like 'Google Mail') or
* an email address (like 'test@googlemail.com').
*
2026-09-15 13:00:32 +02:00
* @param key Service name, alias or an email address
* @returns SMTP config or false if not found
2020-02-29 23:01:03 +01:00
*/
2026-09-15 13:00:32 +02:00
function wellKnown(key) {
2020-02-29 23:01:03 +01:00
key = normalizeKey(key.split('@').pop());
return normalized[key] || false;
2026-09-15 13:00:32 +02:00
}
module.exports = exports.default;
Object.defineProperty(module.exports, 'default', { value: exports.default, enumerable: false, writable: true, configurable: true });