otm-detector
Advanced tools
Comparing version 1.0.1 to 1.0.3
11
index.js
@@ -8,4 +8,11 @@ import dns from "node:dns/promises"; | ||
const otmDns = options.dns || dns; | ||
const records = await otmDns.resolveMx(domain) | ||
return records.some((record) => OTM_HOSTS.has(record.exchange)) | ||
try { | ||
const records = await otmDns.resolveMx(domain) | ||
return records.some((record) => OTM_HOSTS.has(record.exchange)) | ||
} catch (e) { | ||
if (e.code === "ENOTFOUND") { | ||
return false | ||
} | ||
throw e | ||
} | ||
}; |
@@ -5,2 +5,5 @@ import test from "node:test"; | ||
const ENOTFOUND = new Error("ENOTFOUND"); | ||
ENOTFOUND.code = "ENOTFOUND"; | ||
const domains = [ | ||
@@ -17,10 +20,22 @@ { | ||
}, | ||
{ | ||
domain: "uentiheunsthieunst.com", | ||
mx: ENOTFOUND, | ||
result: false, | ||
}, | ||
]; | ||
for (const domain of domains) { | ||
test(`Check if ${domain.domain} has ${domain.mx.join(", ")} as MX`, async (t) => { | ||
test(`Check if ${domain.domain} has ${domain.mx} as MX`, async (t) => { | ||
assert.equal( | ||
await isOneTimeMail(domain.domain, { dns: { | ||
resolveMx: async () => domain.mx.map((exchange) => ({ exchange })), | ||
}}), | ||
await isOneTimeMail(domain.domain, { | ||
dns: { | ||
resolveMx: async () => { | ||
if (domain.mx instanceof Error) { | ||
throw domain.mx; | ||
} | ||
return domain.mx.map((exchange) => ({ exchange })); | ||
}, | ||
}, | ||
}), | ||
domain.result | ||
@@ -27,0 +42,0 @@ ); |
{ | ||
"name": "otm-detector", | ||
"version": "1.0.1", | ||
"version": "1.0.3", | ||
"description": "Detect one-time mail services, the new way", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4657
59