openrich 0.0.0-stage → 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 (65) hide show
  1. package/.env.example +23 -0
  2. package/LICENSE +21 -0
  3. package/README.md +410 -2
  4. package/assets/logo.svg +41 -0
  5. package/dist/cli.d.ts +2 -0
  6. package/dist/cli.js +144 -0
  7. package/dist/env.d.ts +5 -0
  8. package/dist/env.js +24 -0
  9. package/dist/eval.d.ts +30 -0
  10. package/dist/eval.js +78 -0
  11. package/dist/mcp/client.d.ts +31 -0
  12. package/dist/mcp/client.js +94 -0
  13. package/dist/mcp/oauth.d.ts +13 -0
  14. package/dist/mcp/oauth.js +93 -0
  15. package/dist/mcp/server.d.ts +87 -0
  16. package/dist/mcp/server.js +125 -0
  17. package/dist/merge.d.ts +7 -0
  18. package/dist/merge.js +39 -0
  19. package/dist/providers/devplatforms.d.ts +34 -0
  20. package/dist/providers/devplatforms.js +612 -0
  21. package/dist/providers/finders.d.ts +38 -0
  22. package/dist/providers/finders.js +708 -0
  23. package/dist/providers/freetier.d.ts +9 -0
  24. package/dist/providers/freetier.js +254 -0
  25. package/dist/providers/github.d.ts +8 -0
  26. package/dist/providers/github.js +109 -0
  27. package/dist/providers/identity.d.ts +5 -0
  28. package/dist/providers/identity.js +62 -0
  29. package/dist/providers/index.d.ts +10 -0
  30. package/dist/providers/index.js +68 -0
  31. package/dist/providers/knowledge.d.ts +52 -0
  32. package/dist/providers/knowledge.js +302 -0
  33. package/dist/providers/pattern.d.ts +6 -0
  34. package/dist/providers/pattern.js +99 -0
  35. package/dist/providers/registries.d.ts +36 -0
  36. package/dist/providers/registries.js +396 -0
  37. package/dist/providers/research.d.ts +30 -0
  38. package/dist/providers/research.js +471 -0
  39. package/dist/providers/signals.d.ts +15 -0
  40. package/dist/providers/signals.js +116 -0
  41. package/dist/providers/smtp.d.ts +25 -0
  42. package/dist/providers/smtp.js +97 -0
  43. package/dist/providers/social.d.ts +37 -0
  44. package/dist/providers/social.js +657 -0
  45. package/dist/providers/verifiers.d.ts +47 -0
  46. package/dist/providers/verifiers.js +455 -0
  47. package/dist/providers/websearch.d.ts +32 -0
  48. package/dist/providers/websearch.js +346 -0
  49. package/dist/router.d.ts +31 -0
  50. package/dist/router.js +214 -0
  51. package/dist/server.d.ts +2 -0
  52. package/dist/server.js +52 -0
  53. package/dist/store.d.ts +32 -0
  54. package/dist/store.js +95 -0
  55. package/dist/types.d.ts +82 -0
  56. package/dist/types.js +1 -0
  57. package/dist/util/http.d.ts +19 -0
  58. package/dist/util/http.js +34 -0
  59. package/dist/util/match.d.ts +23 -0
  60. package/dist/util/match.js +72 -0
  61. package/dist/util/names.d.ts +11 -0
  62. package/dist/util/names.js +56 -0
  63. package/dist/util/patterns.d.ts +14 -0
  64. package/dist/util/patterns.js +61 -0
  65. package/package.json +55 -4
@@ -0,0 +1,47 @@
1
+ import type { Provider } from '../types.ts';
2
+ /**
3
+ * Email verifiers: confirm an email the router already guessed (q.emailCandidates[0], best first).
4
+ * Each uses the user's OWN key on the provider's free plan. Quotas are the free-plan numbers from each
5
+ * provider's own pricing/docs page (Dec 2026). The router only knows 'day' and 'month' periods, so a
6
+ * one-time signup grant is entered as its size per month and noted as one-time in the description;
7
+ * the provider's 402/429 then stops it for good.
8
+ *
9
+ * Verdict -> finding: valid (and not catch-all) 0.9; catch-all / accept-all / risky 0.3; invalid or unknown none.
10
+ */
11
+ export type Verdict = 'valid' | 'catch-all' | 'invalid' | 'unknown';
12
+ /** Maps any provider's status word to one verdict. A valid status on a catch-all domain is only catch-all. */
13
+ export declare function verdict(status: string, catchAll?: boolean): Verdict;
14
+ /** https://www.zerobounce.net/docs/email-validation-api-quickstart/v2-validate-emails */
15
+ export declare const zerobounceProvider: Provider;
16
+ /** https://hunter.io/api-documentation/v2#email-verifier */
17
+ export declare const hunterVerifyProvider: Provider;
18
+ /** https://getprospect.com/api-docs/email-verifier.md */
19
+ export declare const getprospectVerifyProvider: Provider;
20
+ /** https://docs.enrow.io/api-reference/email-verifier/verify-single.md (+ get-single-verification.md); MCP tools verify_email / get_verification_result */
21
+ export declare const enrowVerifyProvider: Provider;
22
+ /** https://developer.millionverifier.com/ (result: ok, catch_all, unknown, error, disposable, invalid) */
23
+ export declare const millionverifierProvider: Provider;
24
+ /** https://www.reoon.com/articles/api-documentation-of-reoon-email-verifier/ (power mode checks the inbox) */
25
+ export declare const reoonProvider: Provider;
26
+ /** https://verifalia.com/developers/email-verifications/creating-jobs (+ retrieving-jobs). HTTP Basic auth with a Verifalia user. */
27
+ export declare const verifaliaProvider: Provider;
28
+ /** https://docs.quickemailverification.com/email-verification-api/verify-an-email-address */
29
+ export declare const qevProvider: Provider;
30
+ /** https://emailable.com/docs/api/emails/ and /docs/api/status-codes/ (249 = try again) */
31
+ export declare const emailableProvider: Provider;
32
+ /** https://docs.abstractapi.com/api/email-validation (422 = quota reached) */
33
+ export declare const abstractEmailProvider: Provider;
34
+ /** https://docs.usebouncer.com/api-reference/real-time/verify-email.md */
35
+ export declare const bouncerProvider: Provider;
36
+ /** https://docs.clearout.io/developers/api/email-verify.md (+ api overview: error codes 1002/1031 = out of credits) */
37
+ export declare const clearoutProvider: Provider;
38
+ /** https://developers.debounce.com/api-reference/endpoint/single-validation.md (402 = "Credits Low") */
39
+ export declare const debounceProvider: Provider;
40
+ /** https://docs.kickbox.com/docs/single-verification-api (official page blocks fetchers; read via a mirror) */
41
+ export declare const kickboxProvider: Provider;
42
+ /** https://www.mailboxvalidator.com/api-single-validation (error 10004 = insufficient credits, sent as HTTP 401) */
43
+ export declare const mailboxvalidatorProvider: Provider;
44
+ /** https://developers.neverbounce.com/reference/single-check.md (results: valid, invalid, disposable, catchall, unknown) */
45
+ export declare const neverbounceProvider: Provider;
46
+ /** Roomy recurring quotas first, shared and one-time grants last (the router picks the first that fits). */
47
+ export declare const VERIFIER_PROVIDERS: Provider[];
@@ -0,0 +1,455 @@
1
+ import { HttpError, QuotaExceeded } from "../util/http.js";
2
+ import { McpClient, McpError } from "../mcp/client.js";
3
+ import { ENROW_MCP_URL } from "./freetier.js";
4
+ const VALID = new Set(['valid', 'deliverable', 'ok', 'safe', 'safetosend']);
5
+ const CATCH_ALL = new Set(['catchall', 'acceptall', 'risky', 'okforall', 'servercatchall', 'serveriscatchall']);
6
+ const INVALID = new Set(['invalid', 'undeliverable', 'disabled', 'disposable', 'spamtrap', 'abuse', 'donotmail', 'emaildisabled', 'deaddomain', 'deadserver']);
7
+ /** Maps any provider's status word to one verdict. A valid status on a catch-all domain is only catch-all. */
8
+ export function verdict(status, catchAll) {
9
+ const s = String(status ?? '').toLowerCase().replace(/[^a-z]/g, '');
10
+ if (VALID.has(s))
11
+ return catchAll ? 'catch-all' : 'valid';
12
+ if (CATCH_ALL.has(s))
13
+ return 'catch-all';
14
+ if (INVALID.has(s))
15
+ return 'invalid';
16
+ return 'unknown';
17
+ }
18
+ function verifier(s) {
19
+ return {
20
+ id: s.id,
21
+ kind: 'free-tier',
22
+ description: s.description,
23
+ provides: ['email'],
24
+ keyEnv: s.keyEnv,
25
+ enabled: s.enabled,
26
+ quota: s.quota,
27
+ needs: (q) => !q.email && Boolean(q.emailCandidates?.length),
28
+ async run(q, ctx) {
29
+ for (const email of (q.emailCandidates ?? []).slice(0, s.tryNext ? 2 : 1)) {
30
+ const r = await s.check(email, ctx);
31
+ if (r.verdict === 'valid' || r.verdict === 'catch-all') {
32
+ return [{ field: 'email', value: email.toLowerCase(), source: s.id, confidence: r.verdict === 'valid' ? 0.9 : 0.3, evidence: r.detail }];
33
+ }
34
+ ctx.log(`${s.id}: ${email} is ${r.verdict} (${r.detail})`);
35
+ if (r.verdict !== 'invalid')
36
+ break;
37
+ }
38
+ return [];
39
+ },
40
+ };
41
+ }
42
+ const CREDITS = /credit|balance|quota|depleted|exhaust|rate limit|too many/i;
43
+ /** fetch + JSON parse that never throws on status; 402/429 always mean quota. */
44
+ async function call(ctx, url, init = {}, timeoutMs = 35000) {
45
+ const res = await ctx.fetch(url, { ...init, signal: AbortSignal.timeout(timeoutMs) });
46
+ const text = await res.text();
47
+ let data = null;
48
+ try {
49
+ data = text ? JSON.parse(text) : null;
50
+ }
51
+ catch {
52
+ data = text;
53
+ }
54
+ if (res.status === 402 || res.status === 429)
55
+ throw new QuotaExceeded(`HTTP ${res.status} from ${new URL(url).host}: ${text.slice(0, 120)}`);
56
+ return { status: res.status, data, url };
57
+ }
58
+ function fail(r) {
59
+ throw new HttpError(r.status, typeof r.data === 'string' ? r.data : JSON.stringify(r.data), r.url);
60
+ }
61
+ const qs = (o) => new URLSearchParams(o).toString();
62
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
63
+ const yes = (v) => v === true || v === 'true' || v === 'yes' || v === 1 || v === '1';
64
+ // ---- providers ----
65
+ /** https://www.zerobounce.net/docs/email-validation-api-quickstart/v2-validate-emails */
66
+ export const zerobounceProvider = verifier({
67
+ id: 'zerobounce',
68
+ description: 'ZeroBounce email validation (free plan: 100 credits/month, recurring; business-domain signup; unknown results free)',
69
+ keyEnv: 'ZEROBOUNCE_API_KEY',
70
+ quota: { limit: 100, period: 'month' },
71
+ async check(email, ctx) {
72
+ const r = await call(ctx, `https://api.zerobounce.net/v2/validate?${qs({ api_key: ctx.env.ZEROBOUNCE_API_KEY, email, ip_address: '' })}`);
73
+ const d = r.data;
74
+ if (d?.error) {
75
+ if (CREDITS.test(d.error))
76
+ throw new QuotaExceeded(`zerobounce: ${d.error}`);
77
+ throw new Error(`zerobounce: ${d.error}`);
78
+ }
79
+ if (r.status !== 200 || !d?.status)
80
+ fail(r);
81
+ return { verdict: verdict(d.status), detail: `status ${d.status}${d.sub_status ? `/${d.sub_status}` : ''}` };
82
+ },
83
+ });
84
+ /** https://hunter.io/api-documentation/v2#email-verifier */
85
+ export const hunterVerifyProvider = verifier({
86
+ id: 'hunter-verify',
87
+ description: 'Hunter Email Verifier (0.5 credit each; SHARES the 50 free credits/month with hunter, recurring)',
88
+ keyEnv: 'HUNTER_API_KEY',
89
+ quota: { limit: 100, period: 'month' },
90
+ async check(email, ctx) {
91
+ const url = `https://api.hunter.io/v2/email-verifier?${qs({ email, api_key: ctx.env.HUNTER_API_KEY })}`;
92
+ for (let i = 0; i < 3; i++) {
93
+ const r = await call(ctx, url);
94
+ if (r.status === 202)
95
+ continue; // still running; repeated polls count once
96
+ if (r.status !== 200)
97
+ fail(r);
98
+ const d = r.data?.data;
99
+ return { verdict: verdict(d?.status, d?.accept_all), detail: `status ${d?.status}, score ${d?.score}` };
100
+ }
101
+ return { verdict: 'unknown', detail: 'still running after 3 polls' };
102
+ },
103
+ });
104
+ /** https://getprospect.com/api-docs/email-verifier.md */
105
+ export const getprospectVerifyProvider = verifier({
106
+ id: 'getprospect-verify',
107
+ description: 'GetProspect Email Verifier (free plan: one-time $1 wallet, about 1,250 checks at $0.80/1k; unknowns free)',
108
+ keyEnv: 'GETPROSPECT_API_KEY',
109
+ quota: { limit: 1250, period: 'month' },
110
+ async check(email, ctx) {
111
+ const r = await call(ctx, 'https://api.getprospect.com/v2/email/verify', {
112
+ method: 'POST',
113
+ headers: { 'x-api-key': ctx.env.GETPROSPECT_API_KEY, 'content-type': 'application/json' },
114
+ body: JSON.stringify({ data: { email } }),
115
+ }, 85000); // docs: up to 75 s
116
+ if (r.status === 408)
117
+ return { verdict: 'unknown', detail: 'timeout (408), not charged' };
118
+ const d = r.data?.data;
119
+ if (r.status !== 200 && !d?.status)
120
+ fail(r);
121
+ // status is the mailbox verdict; domain_status does not change it (docs).
122
+ return { verdict: verdict(d?.status ?? 'unknown'), detail: `status ${d?.status}, domain ${d?.domain_status}` };
123
+ },
124
+ });
125
+ /** https://docs.enrow.io/api-reference/email-verifier/verify-single.md (+ get-single-verification.md); MCP tools verify_email / get_verification_result */
126
+ export const enrowVerifyProvider = verifier({
127
+ id: 'enrow-verify',
128
+ description: 'Enrow Email Verifier (0.25 credit each; SHARES the 50 free credits/month with enrow, recurring; resolves catch-all)',
129
+ keyEnv: 'ENROW_API_KEY',
130
+ enabled: (env) => Boolean(env.ENROW_API_KEY || env.ENROW_MCP_TOKEN),
131
+ quota: { limit: 200, period: 'month' },
132
+ async check(email, ctx) {
133
+ const read = (d, via) => {
134
+ const q = String(d?.qualification ?? d?.result ?? d?.status ?? '');
135
+ if (!q || /ongoing|pending|operating/i.test(q))
136
+ return null;
137
+ return { verdict: verdict(q), detail: `qualification ${q} (${via})` };
138
+ };
139
+ const wait = (i) => sleep(i < 5 ? 1000 : 3000);
140
+ if (!ctx.env.ENROW_API_KEY) {
141
+ const mcp = new McpClient(ENROW_MCP_URL, ctx.env.ENROW_MCP_TOKEN, ctx.fetch);
142
+ try {
143
+ const start = await mcp.callTool('verify_email', { email });
144
+ if (start.isError) {
145
+ if (CREDITS.test(start.text))
146
+ throw new QuotaExceeded(`enrow-verify: ${start.text}`);
147
+ throw new Error(`enrow verify_email: ${start.text.slice(0, 200)}`);
148
+ }
149
+ const id = start.data?.id;
150
+ if (!id)
151
+ return read(start.data, 'mcp') ?? { verdict: 'unknown', detail: `no id: ${start.text.slice(0, 100)}` };
152
+ for (let i = 0; i < 30; i++) {
153
+ await wait(i);
154
+ const r = await mcp.callTool('get_verification_result', { id });
155
+ if (r.isError)
156
+ throw new Error(`enrow get_verification_result: ${r.text.slice(0, 200)}`);
157
+ const v = read(r.data, 'mcp');
158
+ if (v)
159
+ return v;
160
+ }
161
+ }
162
+ catch (e) {
163
+ if (e instanceof McpError && e.status === 401)
164
+ throw new Error('enrow: MCP sign-in expired, run `openrich login enrow`');
165
+ if (e instanceof McpError && (e.status === 402 || e.status === 429))
166
+ throw new QuotaExceeded(`enrow MCP HTTP ${e.status}`);
167
+ throw e;
168
+ }
169
+ return { verdict: 'unknown', detail: 'gave up waiting' };
170
+ }
171
+ const headers = { 'x-api-key': ctx.env.ENROW_API_KEY, 'content-type': 'application/json' };
172
+ const start = await call(ctx, 'https://api.enrow.io/email/verify/single', { method: 'POST', headers, body: JSON.stringify({ email }) });
173
+ if (start.status !== 200)
174
+ fail(start);
175
+ const id = start.data?.id;
176
+ if (!id)
177
+ return { verdict: 'unknown', detail: 'no verification id' };
178
+ for (let i = 0; i < 30; i++) {
179
+ await wait(i);
180
+ const r = await call(ctx, `https://api.enrow.io/email/verify/single?id=${encodeURIComponent(id)}`, { headers });
181
+ if (r.status === 202)
182
+ continue;
183
+ if (r.status !== 200)
184
+ fail(r);
185
+ const v = read(r.data, 'api');
186
+ if (v)
187
+ return v;
188
+ }
189
+ return { verdict: 'unknown', detail: 'gave up waiting' };
190
+ },
191
+ });
192
+ /** https://developer.millionverifier.com/ (result: ok, catch_all, unknown, error, disposable, invalid) */
193
+ export const millionverifierProvider = verifier({
194
+ id: 'millionverifier',
195
+ description: 'MillionVerifier single API (free: 100 credits at signup, one-time, never expire)',
196
+ keyEnv: 'MILLIONVERIFIER_API_KEY',
197
+ quota: { limit: 100, period: 'month' },
198
+ async check(email, ctx) {
199
+ const r = await call(ctx, `https://api.millionverifier.com/api/v3/?${qs({ api: ctx.env.MILLIONVERIFIER_API_KEY, email, timeout: '20' })}`);
200
+ const d = r.data;
201
+ if (d?.error) {
202
+ if (CREDITS.test(d.error))
203
+ throw new QuotaExceeded(`millionverifier: ${d.error}`);
204
+ throw new Error(`millionverifier: ${d.error}`);
205
+ }
206
+ if (r.status !== 200 || !d?.result)
207
+ fail(r);
208
+ return { verdict: verdict(d.result), detail: `result ${d.result}${d.subresult ? `/${d.subresult}` : ''}` };
209
+ },
210
+ });
211
+ /** https://www.reoon.com/articles/api-documentation-of-reoon-email-verifier/ (power mode checks the inbox) */
212
+ export const reoonProvider = verifier({
213
+ id: 'reoon',
214
+ description: 'Reoon Email Verifier, power mode (free: 20 credits/day recurring, plus 100 one-time at signup)',
215
+ keyEnv: 'REOON_API_KEY',
216
+ quota: { limit: 20, period: 'day' },
217
+ tryNext: true,
218
+ async check(email, ctx) {
219
+ const r = await call(ctx, `https://emailverifier.reoon.com/api/v1/verify?${qs({ email, key: ctx.env.REOON_API_KEY, mode: 'power' })}`, {}, 70000);
220
+ const d = r.data;
221
+ if (d?.status === 'error') {
222
+ if (CREDITS.test(String(d.reason ?? '')))
223
+ throw new QuotaExceeded(`reoon: ${d.reason}`);
224
+ throw new Error(`reoon: ${d.reason}`);
225
+ }
226
+ if (r.status !== 200 || !d?.status)
227
+ fail(r);
228
+ let v = verdict(d.status, d.is_catch_all);
229
+ if (d.status === 'role_account')
230
+ v = d.is_catch_all ? 'catch-all' : yes(d.is_deliverable) ? 'valid' : 'unknown';
231
+ return { verdict: v, detail: `status ${d.status}${d.overall_score != null ? `, score ${d.overall_score}` : ''}` };
232
+ },
233
+ });
234
+ /** https://verifalia.com/developers/email-verifications/creating-jobs (+ retrieving-jobs). HTTP Basic auth with a Verifalia user. */
235
+ export const verifaliaProvider = verifier({
236
+ id: 'verifalia',
237
+ description: 'Verifalia email validation (free: 25 credits/day, recurring, expire daily)',
238
+ keyEnv: 'VERIFALIA_USER',
239
+ enabled: (env) => Boolean(env.VERIFALIA_USER && env.VERIFALIA_PASSWORD),
240
+ quota: { limit: 25, period: 'day' },
241
+ tryNext: true,
242
+ async check(email, ctx) {
243
+ const base = 'https://api.verifalia.com/v2.7/email-validations';
244
+ const headers = {
245
+ authorization: `Basic ${Buffer.from(`${ctx.env.VERIFALIA_USER}:${ctx.env.VERIFALIA_PASSWORD}`).toString('base64')}`,
246
+ 'content-type': 'application/json',
247
+ accept: 'application/json',
248
+ };
249
+ let r = await call(ctx, `${base}?waitTime=30000`, { method: 'POST', headers, body: JSON.stringify({ entries: [{ inputData: email }] }) });
250
+ for (let i = 0; i < 3 && r.status === 202; i++) {
251
+ const id = r.data?.overview?.id;
252
+ if (!id)
253
+ break;
254
+ r = await call(ctx, `${base}/${encodeURIComponent(id)}?waitTime=30000`, { headers });
255
+ }
256
+ if (r.status === 202)
257
+ return { verdict: 'unknown', detail: 'job still running' };
258
+ if (r.status !== 200)
259
+ fail(r);
260
+ const e = r.data?.entries?.data?.[0];
261
+ if (!e)
262
+ return { verdict: 'unknown', detail: 'no entry in result' };
263
+ const v = e.status === 'ServerIsCatchAll' ? 'catch-all'
264
+ : e.classification === 'Deliverable' ? 'valid'
265
+ : e.classification === 'Risky' ? 'catch-all'
266
+ : e.classification === 'Undeliverable' ? 'invalid' : 'unknown';
267
+ return { verdict: v, detail: `${e.classification} (${e.status})` };
268
+ },
269
+ });
270
+ /** https://docs.quickemailverification.com/email-verification-api/verify-an-email-address */
271
+ export const qevProvider = verifier({
272
+ id: 'quickemailverification',
273
+ description: 'QuickEmailVerification (free: 100 verifications/month, recurring)',
274
+ keyEnv: 'QEV_API_KEY',
275
+ quota: { limit: 100, period: 'month' },
276
+ async check(email, ctx) {
277
+ const r = await call(ctx, `https://api.quickemailverification.com/v1/verify?${qs({ email, apikey: ctx.env.QEV_API_KEY })}`);
278
+ const d = r.data;
279
+ if (r.status !== 200 || !d?.result || d.success === false || d.success === 'false')
280
+ fail(r);
281
+ return { verdict: verdict(d.result, yes(d.accept_all)), detail: `result ${d.result}, reason ${d.reason}${yes(d.accept_all) ? ', accept-all' : ''}` };
282
+ },
283
+ });
284
+ /** https://emailable.com/docs/api/emails/ and /docs/api/status-codes/ (249 = try again) */
285
+ export const emailableProvider = verifier({
286
+ id: 'emailable',
287
+ description: 'Emailable verify (free: 250 credits at signup, one-time, never expire)',
288
+ keyEnv: 'EMAILABLE_API_KEY',
289
+ quota: { limit: 250, period: 'month' },
290
+ async check(email, ctx) {
291
+ const url = `https://api.emailable.com/v1/verify?${qs({ email, api_key: ctx.env.EMAILABLE_API_KEY, timeout: '10' })}`;
292
+ for (let i = 0; i < 3; i++) {
293
+ const r = await call(ctx, url);
294
+ if (r.status === 249) {
295
+ await sleep(3000);
296
+ continue;
297
+ }
298
+ if (r.status !== 200 || !r.data?.state)
299
+ fail(r);
300
+ const d = r.data;
301
+ return { verdict: verdict(d.state, yes(d.accept_all)), detail: `state ${d.state}, reason ${d.reason}` };
302
+ }
303
+ return { verdict: 'unknown', detail: 'still running (249)' };
304
+ },
305
+ });
306
+ /** https://docs.abstractapi.com/api/email-validation (422 = quota reached) */
307
+ export const abstractEmailProvider = verifier({
308
+ id: 'abstract-email',
309
+ description: 'Abstract Email Validation (free: 100 requests/month, recurring; 1 req/s)',
310
+ keyEnv: 'ABSTRACT_EMAIL_API_KEY',
311
+ quota: { limit: 100, period: 'month' },
312
+ async check(email, ctx) {
313
+ const r = await call(ctx, `https://emailvalidation.abstractapi.com/v1/?${qs({ api_key: ctx.env.ABSTRACT_EMAIL_API_KEY, email, auto_correct: 'false' })}`);
314
+ if (r.status === 422)
315
+ throw new QuotaExceeded('abstract-email: quota reached (422)');
316
+ const d = r.data;
317
+ if (r.status !== 200 || !d?.deliverability)
318
+ fail(r);
319
+ const catchAll = yes(d.is_catchall_email?.value);
320
+ return { verdict: verdict(d.deliverability, catchAll), detail: `${d.deliverability}${catchAll ? ', catch-all' : ''}, score ${d.quality_score}` };
321
+ },
322
+ });
323
+ /** https://docs.usebouncer.com/api-reference/real-time/verify-email.md */
324
+ export const bouncerProvider = verifier({
325
+ id: 'bouncer',
326
+ description: 'Bouncer real-time verify (free: 100 credits at signup, one-time, never expire)',
327
+ keyEnv: 'BOUNCER_API_KEY',
328
+ quota: { limit: 100, period: 'month' },
329
+ async check(email, ctx) {
330
+ const r = await call(ctx, `https://api.usebouncer.com/v1.1/email/verify?${qs({ email, timeout: '20' })}`, { headers: { 'x-api-key': ctx.env.BOUNCER_API_KEY } });
331
+ const d = r.data;
332
+ if (r.status !== 200 || !d?.status)
333
+ fail(r);
334
+ return { verdict: verdict(d.status, yes(d.domain?.acceptAll)), detail: `status ${d.status}, reason ${d.reason}` };
335
+ },
336
+ });
337
+ /** https://docs.clearout.io/developers/api/email-verify.md (+ api overview: error codes 1002/1031 = out of credits) */
338
+ export const clearoutProvider = verifier({
339
+ id: 'clearout',
340
+ description: 'Clearout instant verify (free: 100 credits at signup, one-time)',
341
+ keyEnv: 'CLEAROUT_API_TOKEN',
342
+ quota: { limit: 100, period: 'month' },
343
+ async check(email, ctx) {
344
+ const r = await call(ctx, 'https://api.clearout.io/v2/email_verify/instant', {
345
+ method: 'POST',
346
+ headers: { authorization: `Bearer ${ctx.env.CLEAROUT_API_TOKEN}`, 'content-type': 'application/json' },
347
+ body: JSON.stringify({ email, timeout: 30000 }),
348
+ }, 40000);
349
+ const d = r.data;
350
+ if (d?.status === 'failed' || d?.error) {
351
+ const code = Number(d?.error?.code);
352
+ if (code === 1002 || code === 1031 || CREDITS.test(String(d?.error?.message ?? '')))
353
+ throw new QuotaExceeded(`clearout: ${d?.error?.message ?? code}`);
354
+ if (r.status === 524)
355
+ return { verdict: 'unknown', detail: 'timeout (524)' };
356
+ fail(r);
357
+ }
358
+ if (r.status !== 200 || !d?.data?.status)
359
+ fail(r);
360
+ return { verdict: verdict(d.data.status), detail: `status ${d.data.status}, safe_to_send ${d.data.safe_to_send}` };
361
+ },
362
+ });
363
+ /** https://developers.debounce.com/api-reference/endpoint/single-validation.md (402 = "Credits Low") */
364
+ export const debounceProvider = verifier({
365
+ id: 'debounce',
366
+ description: 'DeBounce single validation (free: 100 credits at signup, one-time, valid until used)',
367
+ keyEnv: 'DEBOUNCE_API_KEY',
368
+ quota: { limit: 100, period: 'month' },
369
+ async check(email, ctx) {
370
+ const r = await call(ctx, `https://api.debounce.io/v1/?${qs({ api: ctx.env.DEBOUNCE_API_KEY, email })}`);
371
+ const d = r.data?.debounce;
372
+ if (r.status !== 200 || !d?.result)
373
+ fail(r);
374
+ const catchAll = /accept.?all|catch.?all/i.test(String(d.reason ?? ''));
375
+ return { verdict: verdict(d.result, catchAll), detail: `result ${d.result}, reason ${d.reason}` };
376
+ },
377
+ });
378
+ /** https://docs.kickbox.com/docs/single-verification-api (official page blocks fetchers; read via a mirror) */
379
+ export const kickboxProvider = verifier({
380
+ id: 'kickbox',
381
+ description: 'Kickbox single verify (free: 100 verifications per new account, one-time; quota from third-party sources)',
382
+ keyEnv: 'KICKBOX_API_KEY',
383
+ quota: { limit: 100, period: 'month' },
384
+ async check(email, ctx) {
385
+ const r = await call(ctx, `https://api.kickbox.com/v2/verify?${qs({ email, apikey: ctx.env.KICKBOX_API_KEY, timeout: '20000' })}`);
386
+ const d = r.data;
387
+ if (d?.success === false) {
388
+ if (CREDITS.test(String(d.message ?? '')))
389
+ throw new QuotaExceeded(`kickbox: ${d.message}`);
390
+ throw new Error(`kickbox: ${d.message}`);
391
+ }
392
+ if (r.status !== 200 || !d?.result)
393
+ fail(r);
394
+ return { verdict: verdict(d.result, yes(d.accept_all)), detail: `result ${d.result}, reason ${d.reason}` };
395
+ },
396
+ });
397
+ /** https://www.mailboxvalidator.com/api-single-validation (error 10004 = insufficient credits, sent as HTTP 401) */
398
+ export const mailboxvalidatorProvider = verifier({
399
+ id: 'mailboxvalidator',
400
+ description: 'MailboxValidator single validation (free API plan: 300 queries/month, recurring)',
401
+ keyEnv: 'MAILBOXVALIDATOR_API_KEY',
402
+ quota: { limit: 300, period: 'month' },
403
+ tryNext: true,
404
+ async check(email, ctx) {
405
+ const r = await call(ctx, `https://api.mailboxvalidator.com/v2/validation/single?${qs({ email, key: ctx.env.MAILBOXVALIDATOR_API_KEY, format: 'json' })}`);
406
+ const d = r.data;
407
+ if (d?.error) {
408
+ if (Number(d.error.error_code) === 10004)
409
+ throw new QuotaExceeded('mailboxvalidator: insufficient credits');
410
+ throw new Error(`mailboxvalidator: ${d.error.error_message ?? d.error.error_code}`);
411
+ }
412
+ if (r.status !== 200 || d?.status == null)
413
+ fail(r);
414
+ const ok = yes(d.status);
415
+ return { verdict: ok ? (yes(d.is_catchall) ? 'catch-all' : 'valid') : 'invalid', detail: `status ${d.status}${yes(d.is_catchall) ? ', catch-all' : ''}` };
416
+ },
417
+ });
418
+ /** https://developers.neverbounce.com/reference/single-check.md (results: valid, invalid, disposable, catchall, unknown) */
419
+ export const neverbounceProvider = verifier({
420
+ id: 'neverbounce',
421
+ description: 'NeverBounce single check (free credits at signup, one-time; amount unconfirmed, about 10 per help-center snippet)',
422
+ keyEnv: 'NEVERBOUNCE_API_KEY',
423
+ quota: { limit: 10, period: 'month' },
424
+ async check(email, ctx) {
425
+ const r = await call(ctx, `https://api.neverbounce.com/v4.2/single/check?${qs({ key: ctx.env.NEVERBOUNCE_API_KEY, email })}`);
426
+ const d = r.data;
427
+ if (d?.status && d.status !== 'success') {
428
+ if (d.status === 'throttle_triggered' || CREDITS.test(String(d.message ?? '')))
429
+ throw new QuotaExceeded(`neverbounce: ${d.status} ${d.message ?? ''}`);
430
+ throw new Error(`neverbounce: ${d.status} ${d.message ?? ''}`);
431
+ }
432
+ if (r.status !== 200 || !d?.result)
433
+ fail(r);
434
+ return { verdict: verdict(d.result), detail: `result ${d.result}` };
435
+ },
436
+ });
437
+ /** Roomy recurring quotas first, shared and one-time grants last (the router picks the first that fits). */
438
+ export const VERIFIER_PROVIDERS = [
439
+ mailboxvalidatorProvider,
440
+ verifaliaProvider,
441
+ reoonProvider,
442
+ zerobounceProvider,
443
+ qevProvider,
444
+ abstractEmailProvider,
445
+ enrowVerifyProvider,
446
+ hunterVerifyProvider,
447
+ getprospectVerifyProvider,
448
+ emailableProvider,
449
+ millionverifierProvider,
450
+ bouncerProvider,
451
+ clearoutProvider,
452
+ debounceProvider,
453
+ kickboxProvider,
454
+ neverbounceProvider,
455
+ ];
@@ -0,0 +1,32 @@
1
+ import type { Finding, PersonQuery, Provider } from '../types.ts';
2
+ /** "Garry Tan - President & CEO - Y Combinator | LinkedIn" -> name + headline parts. */
3
+ export declare function parseLinkedinTitle(title: string): {
4
+ name: string;
5
+ headline: string[];
6
+ } | null;
7
+ /** linkedin.com/in/<slug> profile URL, normalised; null for posts, companies, jobs. */
8
+ export declare function linkedinProfile(url: string): string | null;
9
+ /** One LinkedIn search hit, when the name on it is the person's and the company is on it too (claimed). */
10
+ export declare function fromLinkedinHit(q: PersonQuery, url: string, title: string, text: string, source: string, base: number): Finding[];
11
+ /** Name-only matches are weaker still: kept only when the results hold exactly one profile with that name. */
12
+ export declare const NAME_ONLY_UNIQUE = 0.5;
13
+ /**
14
+ * Pick the person's LinkedIn profile from search hits (the query already named the company).
15
+ * 1. a hit with the name and the company on it: claimed (0.7)
16
+ * 2. else, if exactly one distinct profile carries the name: name only, unique (0.5)
17
+ * 3. else (no match, or two namesakes): nothing
18
+ */
19
+ export declare function pickLinkedin(q: PersonQuery, hits: {
20
+ url: string;
21
+ title: string;
22
+ text: string;
23
+ }[], source: string, base: number): Finding[];
24
+ export declare const parallelSearchProvider: Provider;
25
+ export declare const parallelEntityProvider: Provider;
26
+ export declare const parallelTaskProvider: Provider;
27
+ export declare function taskFindings(q: PersonQuery, output: any): Finding[];
28
+ export declare const exaPeopleProvider: Provider;
29
+ export declare const exaWebsetsProvider: Provider;
30
+ export declare const WEBSEARCH_FREE: Provider[];
31
+ /** In waterfall order: cheap and fast profile finders first, slower email research last. */
32
+ export declare const WEBSEARCH_FREE_TIER: Provider[];