@konfeature/ap-email-guessr 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/package.json +9 -40
  2. package/src/i18n/translation.json +17 -0
  3. package/src/index.d.ts.map +1 -0
  4. package/src/index.js.map +1 -0
  5. package/src/lib/actions/find-email.d.ts.map +1 -0
  6. package/{dist/src → src}/lib/actions/find-email.js +35 -31
  7. package/src/lib/actions/find-email.js.map +1 -0
  8. package/src/lib/actions/generate-emails.d.ts.map +1 -0
  9. package/{dist/src → src}/lib/actions/generate-emails.js +13 -9
  10. package/src/lib/actions/generate-emails.js.map +1 -0
  11. package/src/lib/common/dns.d.ts.map +1 -0
  12. package/src/lib/common/dns.js +40 -0
  13. package/src/lib/common/dns.js.map +1 -0
  14. package/src/lib/common/find-email.d.ts.map +1 -0
  15. package/src/lib/common/find-email.js +82 -0
  16. package/src/lib/common/find-email.js.map +1 -0
  17. package/src/lib/common/find-person.d.ts.map +1 -0
  18. package/src/lib/common/find-person.js +98 -0
  19. package/src/lib/common/find-person.js.map +1 -0
  20. package/src/lib/common/http.d.ts.map +1 -0
  21. package/{dist/src → src}/lib/common/http.js +5 -7
  22. package/src/lib/common/http.js.map +1 -0
  23. package/src/lib/common/mx-fingerprint.d.ts.map +1 -0
  24. package/{dist/src → src}/lib/common/mx-fingerprint.js +4 -3
  25. package/src/lib/common/mx-fingerprint.js.map +1 -0
  26. package/src/lib/common/patterns.d.ts.map +1 -0
  27. package/{dist/src → src}/lib/common/patterns.js +6 -5
  28. package/src/lib/common/patterns.js.map +1 -0
  29. package/src/lib/common/providers/o365.d.ts.map +1 -0
  30. package/{dist/src → src}/lib/common/providers/o365.js +81 -73
  31. package/src/lib/common/providers/o365.js.map +1 -0
  32. package/src/lib/common/verifier.d.ts.map +1 -0
  33. package/src/lib/common/verifier.js.map +1 -0
  34. package/src/lib/common/verifiers/no2bounce-verifier.d.ts.map +1 -0
  35. package/src/lib/common/verifiers/no2bounce-verifier.js +135 -0
  36. package/src/lib/common/verifiers/no2bounce-verifier.js.map +1 -0
  37. package/src/lib/common/verifiers/o365-verifier.d.ts.map +1 -0
  38. package/src/lib/common/verifiers/o365-verifier.js +33 -0
  39. package/src/lib/common/verifiers/o365-verifier.js.map +1 -0
  40. package/README.md +0 -128
  41. package/dist/src/lib/common/dns.js +0 -37
  42. package/dist/src/lib/common/find-email.js +0 -78
  43. package/dist/src/lib/common/find-person.js +0 -102
  44. package/dist/src/lib/common/verifiers/no2bounce-verifier.js +0 -123
  45. package/dist/src/lib/common/verifiers/o365-verifier.js +0 -30
  46. /package/{dist/src → src}/index.d.ts +0 -0
  47. /package/{dist/src → src}/index.js +0 -0
  48. /package/{dist/src → src}/lib/actions/find-email.d.ts +0 -0
  49. /package/{dist/src → src}/lib/actions/generate-emails.d.ts +0 -0
  50. /package/{dist/src → src}/lib/common/dns.d.ts +0 -0
  51. /package/{dist/src → src}/lib/common/find-email.d.ts +0 -0
  52. /package/{dist/src → src}/lib/common/find-person.d.ts +0 -0
  53. /package/{dist/src → src}/lib/common/http.d.ts +0 -0
  54. /package/{dist/src → src}/lib/common/mx-fingerprint.d.ts +0 -0
  55. /package/{dist/src → src}/lib/common/patterns.d.ts +0 -0
  56. /package/{dist/src → src}/lib/common/providers/o365.d.ts +0 -0
  57. /package/{dist/src → src}/lib/common/verifier.d.ts +0 -0
  58. /package/{dist/src → src}/lib/common/verifier.js +0 -0
  59. /package/{dist/src → src}/lib/common/verifiers/no2bounce-verifier.d.ts +0 -0
  60. /package/{dist/src → src}/lib/common/verifiers/o365-verifier.d.ts +0 -0
@@ -1,102 +0,0 @@
1
- "use strict";
2
- /**
3
- * Per-person email finder: generate ordered candidates, pick the right verifier
4
- * for the domain, then run the credit-minimizing early-stop search.
5
- *
6
- * Routing: use the free O365 account check when mail genuinely routes through
7
- * Microsoft (Microsoft/consumer MX, or a "Managed" realm on a domain that is not
8
- * a known non-Microsoft mailbox host). Everything else goes to no2bounce. The
9
- * "Managed realm but Google/Zoho MX" exclusion is the louyetu.fr false-negative
10
- * fix: a leftover Azure AD tenant must not be trusted as Microsoft mail.
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.findPersonEmail = findPersonEmail;
14
- const dns_1 = require("./dns");
15
- const find_email_1 = require("./find-email");
16
- const mx_fingerprint_1 = require("./mx-fingerprint");
17
- const o365_1 = require("./providers/o365");
18
- const patterns_1 = require("./patterns");
19
- const no2bounce_verifier_1 = require("./verifiers/no2bounce-verifier");
20
- const o365_verifier_1 = require("./verifiers/o365-verifier");
21
- const NO2BOUNCE_BATCH_SIZE = 5;
22
- function earlyExit(candidatesConsidered, domain, mxProvider, verdict, confidence, reason) {
23
- return {
24
- found: false,
25
- email: null,
26
- verdict,
27
- confidence,
28
- catchAll: false,
29
- candidatesChecked: 0,
30
- creditsUsed: 0,
31
- attempts: [],
32
- reason,
33
- domain,
34
- mxProvider,
35
- verifierUsed: "none",
36
- candidatesConsidered,
37
- };
38
- }
39
- async function findPersonEmail(firstName, lastName, domain, options) {
40
- const candidates = (0, patterns_1.generateEmailCandidates)({
41
- firstName,
42
- lastName,
43
- domain,
44
- patternSet: options.patternSet,
45
- maxVariants: options.maxVariants,
46
- });
47
- const cleanDomain = (0, patterns_1.normalizeDomain)(domain);
48
- if (candidates.length === 0) {
49
- return earlyExit(0, cleanDomain, "none", "invalid", 0.03, "no_candidates");
50
- }
51
- const routing = await (0, dns_1.resolveMail)(cleanDomain);
52
- const provider = (0, mx_fingerprint_1.fingerprintMx)(routing.hosts);
53
- if (routing.nullMx) {
54
- return earlyExit(candidates.length, cleanDomain, provider.id, "invalid", 0.02, "null_mx");
55
- }
56
- if (routing.hosts.length === 0) {
57
- return earlyExit(candidates.length, cleanDomain, provider.id, "invalid", 0.03, "no_mx_record");
58
- }
59
- const consumer = (0, o365_1.isMicrosoftConsumerDomain)(cleanDomain);
60
- let namespace = null;
61
- let microsoftBacked = consumer || provider.microsoftBacked;
62
- // Only spend a realm lookup on ambiguous MX (not obviously Microsoft, not a
63
- // known foreign mailbox host) — that's where O365-behind-a-gateway hides.
64
- if (options.useO365 &&
65
- !microsoftBacked &&
66
- !(0, mx_fingerprint_1.hostsNonMicrosoftMailboxes)(provider)) {
67
- namespace = await (0, o365_1.getUserRealm)(cleanDomain, options.timeoutMs);
68
- if (namespace === "Managed") {
69
- microsoftBacked = true;
70
- }
71
- }
72
- let verifier;
73
- let verifierUsed;
74
- if (options.useO365 && microsoftBacked) {
75
- verifier = (0, o365_verifier_1.createO365Verifier)(namespace ?? "Managed", true, options.timeoutMs);
76
- verifierUsed = "o365";
77
- }
78
- else if (options.no2bounceToken) {
79
- verifier = (0, no2bounce_verifier_1.createNo2BounceVerifier)({
80
- apitoken: options.no2bounceToken,
81
- timeoutMs: options.timeoutMs,
82
- });
83
- verifierUsed = "no2bounce";
84
- }
85
- else {
86
- return earlyExit(candidates.length, cleanDomain, provider.id, "unknown", 0.5, "no2bounce_token_required");
87
- }
88
- const result = await (0, find_email_1.findEmail)(candidates, verifier, {
89
- maxChecks: options.maxChecks,
90
- stopOnFirstHit: options.stopOnFirstHit,
91
- batchSize: verifierUsed === "no2bounce" ? NO2BOUNCE_BATCH_SIZE : 1,
92
- });
93
- return {
94
- ...result,
95
- reason: `${verifierUsed}_${result.verdict}`,
96
- domain: cleanDomain,
97
- mxProvider: provider.id,
98
- verifierUsed,
99
- candidatesConsidered: candidates.length,
100
- };
101
- }
102
- //# sourceMappingURL=find-person.js.map
@@ -1,123 +0,0 @@
1
- "use strict";
2
- /**
3
- * Verifier adapter for the no2bounce API (wire format confirmed against the
4
- * live API).
5
- *
6
- * Async flow: POST a 1-email batch to get a `trackingId` (under `data`), then
7
- * GET-poll `?trackingId=` until the *top-level* `overallStatus` is "Completed".
8
- * For a single email the top-level count fields are that email's verdict.
9
- * Billing is 1 credit per email (`creditDebited`), with no refund on undeliverable.
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.decodeSingle = decodeSingle;
13
- exports.createNo2BounceVerifier = createNo2BounceVerifier;
14
- const http_1 = require("../http");
15
- const ENDPOINT = "https://connect.no2bounce.com/v2/n2b_validate_bulk";
16
- // no2bounce risk-scores accept-all domains per address: "Deliverable/AcceptAll"
17
- // is a predicted hit, "UnDeliverable/AcceptAll" a predicted miss, and
18
- // "Risky/AcceptAll" genuinely uncertain (so we stop on it).
19
- function decodeSingle(r) {
20
- if ((r.Deliverable ?? 0) >= 1) {
21
- return { verdict: "valid", catchAll: false };
22
- }
23
- if ((r["Deliverable/AcceptAll"] ?? 0) >= 1) {
24
- return { verdict: "valid", catchAll: true };
25
- }
26
- if ((r["Risky/AcceptAll"] ?? 0) >= 1) {
27
- return { verdict: "catch_all", catchAll: true };
28
- }
29
- if ((r.Undeliverable ?? 0) >= 1) {
30
- return { verdict: "invalid", catchAll: false };
31
- }
32
- if ((r["UnDeliverable/AcceptAll"] ?? 0) >= 1) {
33
- return { verdict: "invalid", catchAll: true };
34
- }
35
- return { verdict: "unknown", catchAll: false };
36
- }
37
- function isComplete(r) {
38
- return (String(r.overallStatus ?? "")
39
- .toLowerCase()
40
- .startsWith("complet") || (r.percent ?? 0) >= 100);
41
- }
42
- const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
43
- function createNo2BounceVerifier(options) {
44
- const pollIntervalMs = options.pollIntervalMs ?? 2000;
45
- const maxWaitMs = options.maxWaitMs ?? 30000;
46
- const authHeader = { apitoken: options.apitoken };
47
- async function submit(email) {
48
- const res = await (0, http_1.httpRequest)({
49
- url: ENDPOINT,
50
- method: "POST",
51
- headers: { ...authHeader, "Content-Type": "application/json" },
52
- body: JSON.stringify({ emailList: [email] }),
53
- timeoutMs: options.timeoutMs,
54
- });
55
- if (res.status !== 200) {
56
- throw new Error(`submit_${res.status}`);
57
- }
58
- const json = JSON.parse(res.body);
59
- const id = json.data?.trackingId ?? json.data?.taskId;
60
- return id === undefined ? undefined : String(id);
61
- }
62
- async function poll(trackingId) {
63
- const url = `${ENDPOINT}?trackingId=${encodeURIComponent(trackingId)}`;
64
- const deadline = Date.now() + maxWaitMs;
65
- while (Date.now() < deadline) {
66
- await sleep(pollIntervalMs);
67
- try {
68
- const res = await (0, http_1.httpRequest)({
69
- url,
70
- method: "GET",
71
- headers: authHeader,
72
- timeoutMs: options.timeoutMs,
73
- });
74
- if (res.status !== 200) {
75
- continue;
76
- }
77
- const parsed = JSON.parse(res.body);
78
- if (isComplete(parsed)) {
79
- return parsed;
80
- }
81
- }
82
- catch {
83
- // Transient poll error; keep trying until the deadline.
84
- }
85
- }
86
- return null;
87
- }
88
- return {
89
- name: "no2bounce",
90
- async verify(email) {
91
- let trackingId;
92
- try {
93
- trackingId = await submit(email);
94
- }
95
- catch (error) {
96
- // Submission rejected → no credit charged.
97
- return {
98
- email,
99
- verdict: "unknown",
100
- creditsUsed: 0,
101
- reason: error instanceof Error ? error.message : "submit_failed",
102
- };
103
- }
104
- if (!trackingId) {
105
- return { email, verdict: "unknown", creditsUsed: 0, reason: "no_tracking_id" };
106
- }
107
- const parsed = await poll(trackingId);
108
- if (!parsed) {
109
- return { email, verdict: "unknown", creditsUsed: 1, reason: "poll_timeout" };
110
- }
111
- const { verdict, catchAll } = decodeSingle(parsed);
112
- return {
113
- email,
114
- verdict,
115
- catchAll,
116
- creditsUsed: parsed.creditDebited ?? 1,
117
- reason: `n2b_${verdict}${catchAll ? "_acceptall" : ""}`,
118
- raw: parsed,
119
- };
120
- },
121
- };
122
- }
123
- //# sourceMappingURL=no2bounce-verifier.js.map
@@ -1,30 +0,0 @@
1
- "use strict";
2
- /**
3
- * Verifier adapter for the direct Microsoft 365 account check. Free (no
4
- * credits): it asks Azure AD whether the account exists over HTTPS, so it never
5
- * touches port 25 and never spends a no2bounce credit.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.createO365Verifier = createO365Verifier;
9
- const o365_1 = require("../providers/o365");
10
- function createO365Verifier(namespace, applicable, timeoutMs) {
11
- return {
12
- name: "o365",
13
- async verify(email) {
14
- const result = await (0, o365_1.checkO365Account)(email, namespace, applicable, timeoutMs);
15
- const verdict = result.exists === true
16
- ? "valid"
17
- : result.exists === false
18
- ? "invalid"
19
- : "unknown";
20
- return {
21
- email,
22
- verdict,
23
- creditsUsed: 0,
24
- reason: result.reason,
25
- raw: result,
26
- };
27
- },
28
- };
29
- }
30
- //# sourceMappingURL=o365-verifier.js.map
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes