openrich 0.0.0-stage → 0.1.0

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,612 @@
1
+ import { getJson, HttpError, QuotaExceeded, UA } from "../util/http.js";
2
+ import { mentionsCompany, sameName } from "../util/match.js";
3
+ import { slug } from "../util/names.js";
4
+ /*
5
+ * Developer platforms. Two input styles:
6
+ * - by handle: q.github / q.usernames (router-filled). The same handle on another site is NOT proof of the
7
+ * same person, so every hit must either link back to q.github (0.85+) or carry a matching display name (0.6).
8
+ * - by name: name search, accepted only with sameName() plus a company or profile cross-check.
9
+ */
10
+ const H = { 'User-Agent': UA };
11
+ const NOREPLY = /noreply|no-reply|localhost|\.local$|example\.(com|org)$/i;
12
+ const EMAIL_RE = /[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}/gi;
13
+ /** Candidate handles, GitHub login first, de-duplicated case-insensitively, at most 3 (be polite). */
14
+ export function handles(q) {
15
+ const seen = new Set();
16
+ const out = [];
17
+ for (const h of [q.github, ...(q.usernames ?? [])]) {
18
+ if (!h || !/^[A-Za-z0-9._-]{2,39}$/.test(h) || seen.has(h.toLowerCase()))
19
+ continue;
20
+ seen.add(h.toLowerCase());
21
+ out.push(h);
22
+ }
23
+ return out.slice(0, 3);
24
+ }
25
+ const byHandle = (q) => Boolean(q.github || q.usernames?.length);
26
+ const byName = (q) => Boolean(q.firstName && q.lastName);
27
+ const fullName = (q) => q.name ?? [q.firstName, q.lastName].filter(Boolean).join(' ');
28
+ /** Does some text link to the query's GitHub account (github.com/<login> or <login>.github.io)? */
29
+ export function linksGithub(text, q) {
30
+ if (!text || !q.github)
31
+ return false;
32
+ const l = q.github.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
33
+ return new RegExp(`github\\.com/${l}(?![a-z0-9-])|\\b${l}\\.github\\.io`, 'i').test(text);
34
+ }
35
+ /** Does text name the person ("Jane Doe", or "janedoe" as in janedoe.com)? */
36
+ function mentionsName(text, q) {
37
+ if (!q.firstName || !q.lastName)
38
+ return false;
39
+ const f = slug(q.firstName);
40
+ const l = slug(q.lastName);
41
+ if (f.length < 2 || l.length < 2)
42
+ return false;
43
+ return slug(text).includes(f + l) || new RegExp(`\\b${q.firstName}\\s+${q.lastName}\\b`, 'i').test(text);
44
+ }
45
+ /**
46
+ * The confidence rule shared by every handle-based source.
47
+ * 0.9 links back to q.github; 0.75 name matches and company mentioned; 0.6 name matches; 0 otherwise.
48
+ */
49
+ export function judge(q, name, texts) {
50
+ if (texts.some((t) => linksGithub(t, q)))
51
+ return 0.9;
52
+ if (!sameName(name ?? undefined, fullName(q)))
53
+ return 0;
54
+ return texts.some((t) => mentionsCompany(t, q)) ? 0.75 : 0.6;
55
+ }
56
+ function adder(out, source, conf) {
57
+ return (field, value, c = conf, evidence) => {
58
+ if (typeof value !== 'string' || !value.trim())
59
+ return;
60
+ const v = value.trim();
61
+ if (out.some((f) => f.field === field && f.value.toLowerCase() === v.toLowerCase()))
62
+ return;
63
+ out.push({ field, value: v, source, confidence: c, ...(evidence ? { evidence } : {}) });
64
+ };
65
+ }
66
+ /** An email is the work email only when it sits at the query's domain. */
67
+ function emailField(q, em) {
68
+ return q.domain && em.toLowerCase().endsWith(`@${q.domain}`) ? 'email' : 'personal_email';
69
+ }
70
+ function addEmail(add, q, em, conf, evidence) {
71
+ if (typeof em !== 'string' || !em.includes('@') || NOREPLY.test(em))
72
+ return;
73
+ add(emailField(q, em), em.toLowerCase(), conf, evidence);
74
+ }
75
+ /** URL-ish string to a usable URL; twitter/x URLs go to the twitter field. */
76
+ function addLink(add, url, conf) {
77
+ if (typeof url !== 'string' || !url.trim())
78
+ return;
79
+ const u = /^https?:\/\//i.test(url) ? url : `https://${url}`;
80
+ if (/keybase\.io\/[^/]+\/sigs\//i.test(u))
81
+ return; // proof statements, not a profile
82
+ if (/(twitter|x)\.com\//i.test(u))
83
+ add('twitter', u, conf);
84
+ else if (/keybase\.io\/|reddit\.com\/user|news\.ycombinator\.com\/user|mastodon|bsky\.app\/profile/i.test(u))
85
+ add('profile', u, conf);
86
+ else if (/linkedin\.com\//i.test(u))
87
+ add('linkedin', u, conf);
88
+ else if (/github\.com\//i.test(u))
89
+ add('github', u, conf);
90
+ else
91
+ add('website', u, conf);
92
+ }
93
+ function decodeHtml(s) {
94
+ return s
95
+ .replace(/<p>/gi, '\n')
96
+ .replace(/<a [^>]*href="([^"]+)"[^>]*>[^<]*<\/a>/gi, ' $1 ')
97
+ .replace(/<[^>]+>/g, ' ')
98
+ .replace(/&#x([0-9a-f]+);/gi, (_, h) => String.fromCharCode(parseInt(h, 16)))
99
+ .replace(/&#(\d+);/g, (_, d) => String.fromCharCode(Number(d)))
100
+ .replace(/&quot;/g, '"')
101
+ .replace(/&amp;/g, '&')
102
+ .replace(/&lt;/g, '<')
103
+ .replace(/&gt;/g, '>');
104
+ }
105
+ /** Try each candidate handle until one passes judge(). */
106
+ async function firstMatch(q, fetchOne, score, list = handles(q)) {
107
+ for (const h of list) {
108
+ const p = await fetchOne(h);
109
+ if (!p)
110
+ continue;
111
+ const c = score(p);
112
+ if (c > 0)
113
+ return { h, p, c };
114
+ }
115
+ return null;
116
+ }
117
+ // ---------------------------------------------------------------------------
118
+ /** GitLab: username lookup works without a key (name only); GITLAB_TOKEN unlocks name search and full profiles. */
119
+ export const gitlabProvider = {
120
+ id: 'gitlab',
121
+ kind: 'free',
122
+ description: 'GitLab.com public profiles (GITLAB_TOKEN optional, enables name search and full profile)',
123
+ provides: ['profile', 'name', 'company', 'title', 'location', 'website', 'linkedin', 'twitter', 'bio', 'photo', 'personal_email', 'email'],
124
+ needs: (q) => byHandle(q) || (byName(q) && Boolean(q.domain || q.company)),
125
+ async run(q, ctx) {
126
+ const h = { ...H };
127
+ if (ctx.env.GITLAB_TOKEN)
128
+ h['PRIVATE-TOKEN'] = ctx.env.GITLAB_TOKEN;
129
+ const API = 'https://gitlab.com/api/v4';
130
+ const full = async (u) => ctx.env.GITLAB_TOKEN ? ((await getJson(ctx.fetch, `${API}/users/${u.id}`, { headers: h })).data ?? u) : u;
131
+ const texts = (p) => [p.website_url, p.bio, p.organization, p.twitter ? `https://x.com/${p.twitter}` : null];
132
+ const score = (p) => judge(q, p.name, texts(p));
133
+ let hit = await firstMatch(q, async (u) => {
134
+ const r = (await getJson(ctx.fetch, `${API}/users?username=${encodeURIComponent(u)}`, { headers: h })).data;
135
+ return r?.[0] ? full(r[0]) : null;
136
+ }, score);
137
+ if (!hit && ctx.env.GITLAB_TOKEN && byName(q) && (q.domain || q.company)) {
138
+ const r = (await getJson(ctx.fetch, `${API}/users?search=${encodeURIComponent(fullName(q))}&per_page=5`, { headers: h })).data ?? [];
139
+ for (const u of r.filter((x) => sameName(x.name, fullName(q))).slice(0, 3)) {
140
+ const p = await full(u);
141
+ const c = score(p);
142
+ // Name search needs more than the name: a company mention or a link back.
143
+ if (c >= 0.75) {
144
+ hit = { h: p.username, p, c };
145
+ break;
146
+ }
147
+ }
148
+ }
149
+ if (!hit)
150
+ return [];
151
+ const { p, c } = hit;
152
+ const out = [];
153
+ const add = adder(out, 'gitlab', c);
154
+ add('profile', p.web_url ?? `https://gitlab.com/${p.username}`);
155
+ add('name', p.name);
156
+ add('company', p.organization);
157
+ add('title', p.job_title);
158
+ add('location', p.location);
159
+ addLink(add, p.website_url, c);
160
+ if (p.linkedin)
161
+ add('linkedin', /^https?:/.test(p.linkedin) ? p.linkedin : `https://www.linkedin.com/in/${p.linkedin}`);
162
+ if (p.twitter)
163
+ add('twitter', `https://x.com/${p.twitter}`);
164
+ add('bio', p.bio);
165
+ add('photo', p.avatar_url, c * 0.9);
166
+ addEmail(add, q, p.public_email, c);
167
+ return out;
168
+ },
169
+ };
170
+ // ---------------------------------------------------------------------------
171
+ /** Stack Exchange filter: default user fields + about_me, minus badges/collectives. */
172
+ const SE_FILTER = '!2.Lw3JRM6rB4qH0Q-WV9v';
173
+ export const stackexchangeProvider = {
174
+ id: 'stackexchange',
175
+ kind: 'free',
176
+ description: 'Stack Overflow users by name, accepted only with name + company/GitHub cross-check (STACKEXCHANGE_KEY optional)',
177
+ provides: ['profile', 'location', 'website', 'photo'],
178
+ needs: (q) => byName(q) && Boolean(q.domain || q.company || q.github),
179
+ async run(q, ctx) {
180
+ const key = ctx.env.STACKEXCHANGE_KEY ? `&key=${encodeURIComponent(ctx.env.STACKEXCHANGE_KEY)}` : '';
181
+ const url = `https://api.stackexchange.com/2.3/users?inname=${encodeURIComponent(fullName(q))}&site=stackoverflow&pagesize=10&order=desc&sort=reputation&filter=${SE_FILTER}${key}`;
182
+ let data;
183
+ try {
184
+ data = (await getJson(ctx.fetch, url, { headers: H })).data;
185
+ }
186
+ catch (e) {
187
+ if (e instanceof HttpError && /throttle_violation|quota/i.test(e.body))
188
+ throw new QuotaExceeded(`stackexchange: ${e.body.slice(0, 120)}`);
189
+ throw e;
190
+ }
191
+ if (!data)
192
+ return [];
193
+ if (data.quota_remaining === 0)
194
+ ctx.log('stackexchange: daily quota used up');
195
+ if (data.backoff)
196
+ ctx.log(`stackexchange: asked to back off ${data.backoff}s`);
197
+ for (const u of data.items ?? []) {
198
+ const name = decodeHtml(String(u.display_name ?? ''));
199
+ if (!sameName(name, fullName(q)))
200
+ continue;
201
+ const about = u.about_me ? decodeHtml(String(u.about_me)) : '';
202
+ const texts = [u.website_url, u.location, about];
203
+ let c = 0;
204
+ if (texts.some((t) => linksGithub(t, q)))
205
+ c = 0.85;
206
+ else if (texts.some((t) => mentionsCompany(t, q)))
207
+ c = 0.7;
208
+ if (!c)
209
+ continue;
210
+ const out = [];
211
+ const add = adder(out, 'stackexchange', c);
212
+ add('profile', u.link);
213
+ add('location', u.location ? decodeHtml(u.location) : null);
214
+ addLink(add, u.website_url, c);
215
+ add('photo', u.profile_image, c * 0.9);
216
+ return out;
217
+ }
218
+ return [];
219
+ },
220
+ };
221
+ // ---------------------------------------------------------------------------
222
+ export const hackernewsProvider = {
223
+ id: 'hackernews',
224
+ kind: 'free',
225
+ description: 'Hacker News profile "about" text by username (links, name, email)',
226
+ provides: ['profile', 'personal_email', 'email', 'website'],
227
+ needs: byHandle,
228
+ async run(q, ctx) {
229
+ const hit = await firstMatch(q, async (u) => (await getJson(ctx.fetch, `https://hacker-news.firebaseio.com/v0/user/${encodeURIComponent(u)}.json`, { headers: H })).data, (p) => {
230
+ const about = decodeHtml(String(p.about ?? ''));
231
+ if (!about)
232
+ return 0;
233
+ if (linksGithub(about, q))
234
+ return 0.85;
235
+ if (!mentionsName(about, q))
236
+ return 0;
237
+ return mentionsCompany(about, q) ? 0.75 : 0.6;
238
+ });
239
+ if (!hit)
240
+ return [];
241
+ const about = decodeHtml(String(hit.p.about ?? ''));
242
+ const out = [];
243
+ const add = adder(out, 'hackernews', hit.c);
244
+ add('profile', `https://news.ycombinator.com/user?id=${hit.p.id}`);
245
+ // Only bracketed obfuscation ("jane [at] x [dot] com"); a bare " at " is ordinary prose.
246
+ const deob = about.replace(/\s*[[(]at[\])]\s*/gi, '@').replace(/\s*[[(]dot[\])]\s*/gi, '.');
247
+ for (const em of new Set(deob.match(EMAIL_RE) ?? []))
248
+ addEmail(add, q, em, hit.c, 'hacker news about');
249
+ for (const m of about.match(/https?:\/\/[^\s<>"')]+/gi) ?? []) {
250
+ if (/news\.ycombinator\.com/i.test(m))
251
+ continue;
252
+ addLink(add, m.replace(/[.,;]+$/, ''), hit.c * 0.9);
253
+ }
254
+ return out;
255
+ },
256
+ };
257
+ // ---------------------------------------------------------------------------
258
+ export const devtoProvider = {
259
+ id: 'devto',
260
+ kind: 'free',
261
+ description: 'DEV Community profiles by username (GitHub/X usernames are OAuth-linked)',
262
+ provides: ['profile', 'name', 'bio', 'location', 'website', 'github', 'twitter', 'photo'],
263
+ needs: byHandle,
264
+ async run(q, ctx) {
265
+ const hit = await firstMatch(q, async (u) => (await getJson(ctx.fetch, `https://dev.to/api/users/by_username?url=${encodeURIComponent(u)}`, { headers: H })).data, (p) => {
266
+ if (q.github && String(p.github_username ?? '').toLowerCase() === q.github.toLowerCase())
267
+ return 0.9;
268
+ return judge(q, p.name, [p.website_url, p.summary]);
269
+ });
270
+ if (!hit)
271
+ return [];
272
+ const { p, c } = hit;
273
+ const out = [];
274
+ const add = adder(out, 'devto', c);
275
+ add('profile', `https://dev.to/${p.username}`);
276
+ add('name', p.name);
277
+ add('bio', p.summary);
278
+ add('location', p.location);
279
+ addLink(add, p.website_url, c);
280
+ if (p.github_username)
281
+ add('github', `https://github.com/${p.github_username}`);
282
+ if (p.twitter_username)
283
+ add('twitter', `https://x.com/${p.twitter_username}`);
284
+ add('photo', p.profile_image, c * 0.9);
285
+ return out;
286
+ },
287
+ };
288
+ // ---------------------------------------------------------------------------
289
+ /** Keybase: proofs are signed statements published on each service, so linked accounts are verified. */
290
+ export const keybaseProvider = {
291
+ id: 'keybase',
292
+ kind: 'free',
293
+ description: 'Keybase cryptographically verified account links (GitHub, X, websites, HN, Reddit)',
294
+ provides: ['name', 'github', 'twitter', 'website', 'profile', 'location', 'bio'],
295
+ needs: byHandle,
296
+ async run(q, ctx) {
297
+ const look = async (svc, u) => (await getJson(ctx.fetch, `https://keybase.io/_/api/1.0/user/lookup.json?${svc}=${encodeURIComponent(u)}&fields=basics,profile,proofs_summary`, { headers: H }))
298
+ .data?.them?.[0] ?? null;
299
+ let user = null;
300
+ let c = 0;
301
+ if (q.github) {
302
+ user = await look('github', q.github);
303
+ if (user)
304
+ c = 0.9;
305
+ }
306
+ if (!user) {
307
+ // Other handles might be X handles. A proven X account is still only ours if the name matches.
308
+ for (const u of handles(q).filter((h) => h !== q.github)) {
309
+ const t = await look('twitter', u);
310
+ if (t && sameName(t.profile?.full_name, fullName(q))) {
311
+ user = t;
312
+ c = 0.85;
313
+ break;
314
+ }
315
+ }
316
+ }
317
+ if (!user)
318
+ return [];
319
+ const out = [];
320
+ const add = adder(out, 'keybase', c);
321
+ add('profile', `https://keybase.io/${user.basics?.username}`);
322
+ add('name', user.profile?.full_name);
323
+ add('location', user.profile?.location);
324
+ add('bio', user.profile?.bio);
325
+ for (const pr of user.proofs_summary?.all ?? []) {
326
+ if (pr.state !== 1 || !pr.service_url)
327
+ continue; // 1 = proof currently verified
328
+ const t = String(pr.proof_type);
329
+ if (t === 'github')
330
+ add('github', pr.service_url, 0.9);
331
+ else if (t === 'twitter')
332
+ add('twitter', String(pr.service_url).replace('twitter.com', 'x.com'), 0.9);
333
+ else if (t === 'dns' || t === 'generic_web_site')
334
+ add('website', String(pr.service_url).replace(/^http:/, 'https:'), 0.9);
335
+ else
336
+ add('profile', pr.service_url, 0.9);
337
+ }
338
+ return out;
339
+ },
340
+ };
341
+ // ---------------------------------------------------------------------------
342
+ /**
343
+ * npm: packages maintained by <username>; maintainer entries carry the npm account email.
344
+ * The npm user is accepted when its packages live under github.com/<q.github>/, or its email names the person.
345
+ */
346
+ export const npmProvider = {
347
+ id: 'npm',
348
+ kind: 'free',
349
+ description: 'npm registry maintainer emails (accepted via package repo links or a name-bearing email)',
350
+ provides: ['personal_email', 'email', 'profile'],
351
+ needs: byHandle,
352
+ async run(q, ctx) {
353
+ for (const u of handles(q)) {
354
+ const r = (await getJson(ctx.fetch, `https://registry.npmjs.org/-/v1/search?text=maintainer:${encodeURIComponent(u)}&size=20`, { headers: H })).data;
355
+ const pkgs = (r?.objects ?? []).map((o) => o.package).filter(Boolean);
356
+ const emails = new Set();
357
+ for (const p of pkgs)
358
+ for (const m of p.maintainers ?? [])
359
+ if (String(m.username).toLowerCase() === u.toLowerCase() && m.email)
360
+ emails.add(String(m.email).toLowerCase());
361
+ if (!emails.size)
362
+ continue;
363
+ const repoLinked = pkgs.some((p) => (p.maintainers ?? []).some((m) => String(m.username).toLowerCase() === u.toLowerCase()) && (linksGithub(p.links?.repository, q) || linksGithub(p.links?.homepage, q)));
364
+ const out = [];
365
+ for (const em of emails) {
366
+ const local = slug(em.split('@')[0]);
367
+ const named = Boolean(q.lastName && slug(q.lastName).length >= 3 && local.includes(slug(q.lastName)) && q.firstName && local.includes(slug(q.firstName)[0]));
368
+ const atDomain = Boolean(q.domain && em.endsWith(`@${q.domain}`) && named);
369
+ if (!(repoLinked || named || atDomain))
370
+ continue;
371
+ const add = adder(out, 'npm', 0.7);
372
+ addEmail(add, q, em, 0.7, repoLinked ? `npm maintainer of github.com/${q.github} packages` : 'npm maintainer email matches name');
373
+ add('profile', `https://www.npmjs.com/~${u}`);
374
+ }
375
+ if (out.length)
376
+ return out;
377
+ }
378
+ return [];
379
+ },
380
+ };
381
+ // ---------------------------------------------------------------------------
382
+ /** crates.io accounts are GitHub OAuth logins, so the GitHub login maps to exactly one crates.io user. */
383
+ export const cratesProvider = {
384
+ id: 'crates',
385
+ kind: 'free',
386
+ description: 'crates.io user for the GitHub login (accounts are GitHub OAuth)',
387
+ provides: ['profile', 'name', 'photo'],
388
+ needs: (q) => Boolean(q.github),
389
+ async run(q, ctx) {
390
+ const u = (await getJson(ctx.fetch, `https://crates.io/api/v1/users/${encodeURIComponent(q.github)}`, { headers: H })).data?.user;
391
+ if (!u || (u.github_username_matches === false))
392
+ return [];
393
+ const out = [];
394
+ const add = adder(out, 'crates', 0.9);
395
+ add('profile', `https://crates.io/users/${u.login}`);
396
+ add('name', u.name, 0.85);
397
+ add('photo', u.avatar, 0.8);
398
+ return out;
399
+ },
400
+ };
401
+ // ---------------------------------------------------------------------------
402
+ /** RubyGems: profile shows the email only if public; accepted via gems hosted under github.com/<q.github>/ or a name-bearing email. */
403
+ export const rubygemsProvider = {
404
+ id: 'rubygems',
405
+ kind: 'free',
406
+ description: 'RubyGems public profile email (accepted via gem repo links or a name-bearing email)',
407
+ provides: ['personal_email', 'email', 'profile'],
408
+ needs: byHandle,
409
+ async run(q, ctx) {
410
+ for (const u of handles(q)) {
411
+ const p = (await getJson(ctx.fetch, `https://rubygems.org/api/v1/profiles/${encodeURIComponent(u)}.json`, { headers: H })).data;
412
+ if (!p?.email)
413
+ continue;
414
+ const em = String(p.email).toLowerCase();
415
+ const local = slug(em.split('@')[0]);
416
+ let c = 0;
417
+ if (q.github) {
418
+ const gems = (await getJson(ctx.fetch, `https://rubygems.org/api/v1/owners/${encodeURIComponent(u)}/gems.json`, { headers: H })).data ?? [];
419
+ if (gems.some((g) => linksGithub(g.source_code_uri, q) || linksGithub(g.homepage_uri, q)))
420
+ c = 0.7;
421
+ }
422
+ if (!c && q.firstName && q.lastName && slug(q.lastName).length >= 3 && local.includes(slug(q.lastName)) && local.includes(slug(q.firstName)[0]))
423
+ c = 0.6;
424
+ if (!c)
425
+ continue;
426
+ const out = [];
427
+ const add = adder(out, 'rubygems', c);
428
+ addEmail(add, q, em, c, 'rubygems public profile');
429
+ add('profile', `https://rubygems.org/profiles/${p.handle}`);
430
+ return out;
431
+ }
432
+ return [];
433
+ },
434
+ };
435
+ // ---------------------------------------------------------------------------
436
+ /** MetaCPAN (CPAN authors): name search; profiles list GitHub/X/LinkedIn, plus emails and websites. */
437
+ export const metacpanProvider = {
438
+ id: 'metacpan',
439
+ kind: 'free',
440
+ description: 'MetaCPAN author profiles by name (emails, websites, linked accounts)',
441
+ provides: ['email', 'personal_email', 'website', 'location', 'github', 'twitter', 'linkedin', 'profile', 'photo'],
442
+ needs: byName,
443
+ async run(q, ctx) {
444
+ const url = `https://fastapi.metacpan.org/v1/author/_search?q=${encodeURIComponent(`name:"${fullName(q)}"`)}&size=10`;
445
+ const hits = ((await getJson(ctx.fetch, url, { headers: H })).data?.hits?.hits ?? [])
446
+ .map((h) => h._source)
447
+ .filter((a) => a && sameName(a.name, fullName(q)));
448
+ const scored = hits.map((a) => {
449
+ const gh = (a.profile ?? []).find((p) => p.name === 'github')?.id;
450
+ const texts = [...(a.website ?? []), ...(a.blog ?? []).map((b) => b.url), ...(a.email ?? [])];
451
+ let c = 0.6;
452
+ if (q.github && gh && String(gh).toLowerCase() === q.github.toLowerCase())
453
+ c = 0.85;
454
+ else if (texts.some((t) => mentionsCompany(t, q)))
455
+ c = 0.7;
456
+ return { a, c };
457
+ });
458
+ // A bare name match is only trusted when it is the only author with that name.
459
+ const best = scored.sort((x, y) => y.c - x.c)[0];
460
+ if (!best || (best.c === 0.6 && scored.length > 1))
461
+ return [];
462
+ const { a, c } = best;
463
+ const out = [];
464
+ const add = adder(out, 'metacpan', c);
465
+ add('profile', `https://metacpan.org/author/${a.pauseid}`);
466
+ for (const em of a.email ?? [])
467
+ addEmail(add, q, em, Math.min(c, 0.7), 'metacpan author email');
468
+ for (const w of a.website ?? [])
469
+ addLink(add, w, c * 0.9);
470
+ add('location', [a.city, a.region, a.country].filter(Boolean).join(', '));
471
+ add('photo', a.gravatar_url, c * 0.8);
472
+ for (const p of a.profile ?? []) {
473
+ const id = String(p.id ?? '');
474
+ if (!id)
475
+ continue;
476
+ if (p.name === 'github')
477
+ add('github', `https://github.com/${id}`);
478
+ else if (p.name === 'twitter')
479
+ add('twitter', `https://x.com/${id}`);
480
+ else if (p.name === 'linkedin')
481
+ add('linkedin', /^https?:/.test(id) ? id : `https://www.linkedin.com/in/${id}`);
482
+ else if (p.name === 'stackoverflow')
483
+ add('profile', `https://stackoverflow.com/users/${id}`);
484
+ }
485
+ return out;
486
+ },
487
+ };
488
+ // ---------------------------------------------------------------------------
489
+ /** Launchpad: confirms an email belongs to a registered person (getByEmail), or finds a person by name. */
490
+ export const launchpadProvider = {
491
+ id: 'launchpad',
492
+ kind: 'free',
493
+ description: 'Launchpad (Ubuntu) people: email ownership check and name search',
494
+ provides: ['email', 'name', 'profile', 'bio'],
495
+ needs: (q) => Boolean(q.email || q.emailCandidates?.length || byName(q)),
496
+ async run(q, ctx) {
497
+ const API = 'https://api.launchpad.net/1.0/people';
498
+ const out = [];
499
+ const emails = [q.email, ...(q.emailCandidates ?? [])].filter((e) => Boolean(e)).slice(0, 3);
500
+ for (const em of emails) {
501
+ const p = (await getJson(ctx.fetch, `${API}?ws.op=getByEmail&email=${encodeURIComponent(em)}`, { headers: H })).data;
502
+ if (!p || p.is_team)
503
+ continue;
504
+ const hasName = Boolean(q.firstName && q.lastName);
505
+ if (hasName && !sameName(p.display_name, fullName(q)))
506
+ continue;
507
+ const c = hasName ? 0.85 : 0.7;
508
+ const add = adder(out, 'launchpad', c);
509
+ add('email', em, c, 'registered Launchpad account email');
510
+ add('profile', p.web_link);
511
+ add('name', p.display_name);
512
+ return out;
513
+ }
514
+ if (!byName(q))
515
+ return out;
516
+ const r = (await getJson(ctx.fetch, `${API}?ws.op=findPerson&text=${encodeURIComponent(fullName(q))}&ws.size=5`, { headers: H })).data;
517
+ const people = (r?.entries ?? []).filter((p) => !p.is_team && sameName(p.display_name, fullName(q)));
518
+ // Name search: only a unique name match, and only with a company or GitHub cross-check.
519
+ if (people.length !== 1)
520
+ return out;
521
+ const p = people[0];
522
+ const c = linksGithub(p.description, q) ? 0.85 : mentionsCompany(p.description, q) ? 0.7 : 0;
523
+ if (!c)
524
+ return out;
525
+ const add = adder(out, 'launchpad', c);
526
+ add('profile', p.web_link);
527
+ add('bio', p.description);
528
+ return out;
529
+ },
530
+ };
531
+ // ---------------------------------------------------------------------------
532
+ export const huggingfaceProvider = {
533
+ id: 'huggingface',
534
+ kind: 'free',
535
+ description: 'Hugging Face user overview by username (name must match)',
536
+ provides: ['profile', 'bio', 'photo'],
537
+ needs: byHandle,
538
+ async run(q, ctx) {
539
+ const hit = await firstMatch(q, async (u) => (await getJson(ctx.fetch, `https://huggingface.co/api/users/${encodeURIComponent(u)}/overview`, { headers: H })).data, (p) => (p.type && p.type !== 'user' ? 0 : judge(q, p.fullname, [p.details])));
540
+ if (!hit)
541
+ return [];
542
+ const { p, c } = hit;
543
+ const out = [];
544
+ const add = adder(out, 'huggingface', c);
545
+ add('profile', `https://huggingface.co/${p.user ?? hit.h}`);
546
+ add('bio', p.details);
547
+ if (p.avatarUrl && !/\.svg$/.test(p.avatarUrl))
548
+ add('photo', String(p.avatarUrl).replace(/^\//, 'https://huggingface.co/'), c * 0.9);
549
+ return out;
550
+ },
551
+ };
552
+ // ---------------------------------------------------------------------------
553
+ export const codebergProvider = {
554
+ id: 'codeberg',
555
+ kind: 'free',
556
+ description: 'Codeberg (Forgejo) user profiles by username',
557
+ provides: ['profile', 'name', 'website', 'location', 'bio', 'photo', 'personal_email', 'email'],
558
+ needs: byHandle,
559
+ async run(q, ctx) {
560
+ const hit = await firstMatch(q, async (u) => (await getJson(ctx.fetch, `https://codeberg.org/api/v1/users/${encodeURIComponent(u)}`, { headers: H })).data, (p) => judge(q, p.full_name, [p.website, p.description]));
561
+ if (!hit)
562
+ return [];
563
+ const { p, c } = hit;
564
+ const out = [];
565
+ const add = adder(out, 'codeberg', c);
566
+ add('profile', p.html_url ?? `https://codeberg.org/${p.login}`);
567
+ add('name', p.full_name);
568
+ addLink(add, p.website, c);
569
+ add('location', p.location);
570
+ add('bio', p.description);
571
+ add('photo', p.avatar_url, c * 0.9);
572
+ addEmail(add, q, p.email, c);
573
+ return out;
574
+ },
575
+ };
576
+ // ---------------------------------------------------------------------------
577
+ export const dockerhubProvider = {
578
+ id: 'dockerhub',
579
+ kind: 'free',
580
+ description: 'Docker Hub user profiles by username',
581
+ provides: ['profile', 'name', 'company', 'location', 'website'],
582
+ needs: byHandle,
583
+ async run(q, ctx) {
584
+ const hit = await firstMatch(q, async (u) => (await getJson(ctx.fetch, `https://hub.docker.com/v2/users/${encodeURIComponent(u)}/`, { headers: H })).data, (p) => (p.type && p.type !== 'User' ? 0 : judge(q, p.full_name, [p.profile_url, p.company])));
585
+ if (!hit)
586
+ return [];
587
+ const { p, c } = hit;
588
+ const out = [];
589
+ const add = adder(out, 'dockerhub', c);
590
+ add('profile', `https://hub.docker.com/u/${p.username}`);
591
+ add('name', p.full_name);
592
+ add('company', p.company);
593
+ add('location', p.location);
594
+ addLink(add, p.profile_url, c);
595
+ return out;
596
+ },
597
+ };
598
+ export const DEV_PROVIDERS = [
599
+ gitlabProvider,
600
+ stackexchangeProvider,
601
+ hackernewsProvider,
602
+ devtoProvider,
603
+ keybaseProvider,
604
+ npmProvider,
605
+ cratesProvider,
606
+ rubygemsProvider,
607
+ metacpanProvider,
608
+ launchpadProvider,
609
+ huggingfaceProvider,
610
+ codebergProvider,
611
+ dockerhubProvider,
612
+ ];
@@ -0,0 +1,38 @@
1
+ import type { Provider } from '../types.ts';
2
+ /**
3
+ * More email finders on their free plans. Each uses the user's OWN key, one account, no rotation.
4
+ * Built from each vendor's official API docs (Dec 2026); none has been live-verified with a real key.
5
+ * Quota = hits per period (the router counts only calls that returned findings), taken from the
6
+ * vendor's free plan. One-time signup credits are modelled as a month and say "one-time".
7
+ *
8
+ * Confidence: verified/valid 0.88-0.9, risky/catch-all 0.5, unknown 0.4, extra fields 0.7.
9
+ * Masked or partial emails are dropped.
10
+ */
11
+ /** Waits between polls. Tests replace `timing.sleep` so they run without real delays. */
12
+ export declare const timing: {
13
+ sleep: (ms: number) => Promise<void>;
14
+ maxWaitMs: number;
15
+ };
16
+ export declare const tombaProvider: Provider;
17
+ export declare const snovProvider: Provider;
18
+ export declare const skrappProvider: Provider;
19
+ export declare const voilanorbertProvider: Provider;
20
+ export declare const dropcontactProvider: Provider;
21
+ export declare const icypeasProvider: Provider;
22
+ export declare const cufinderProvider: Provider;
23
+ export declare const mineleadProvider: Provider;
24
+ export declare const getemailProvider: Provider;
25
+ export declare const datagmaProvider: Provider;
26
+ export declare const apolloProvider: Provider;
27
+ export declare const diffbotProvider: Provider;
28
+ export declare const surfeProvider: Provider;
29
+ /**
30
+ * Not built (Dec 2026):
31
+ * - nymeria: no name + domain finder; /person/enrich needs a LinkedIn URL or email, /person/search takes only
32
+ * first/last name (no company filter documented) and bills 1 credit per person returned, on a 5/month plan.
33
+ * - findthatlead: no public API documented (api docs URL 404s; pricing page lists no API).
34
+ * - bettercontact: API listed only on paid plans; whether the 50 signup credits work through the API is not documented.
35
+ * - aviato: no name + domain lookup; access by contacting sales, no documented free plan.
36
+ * - crustdata: email enrich takes only LinkedIn URLs/emails/ids and needs enterprise access (self-serve keys get 403).
37
+ */
38
+ export declare const FINDER_PROVIDERS: Provider[];