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.
- package/.env.example +23 -0
- package/LICENSE +21 -0
- package/README.md +410 -2
- package/assets/logo.svg +41 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +144 -0
- package/dist/env.d.ts +5 -0
- package/dist/env.js +24 -0
- package/dist/eval.d.ts +30 -0
- package/dist/eval.js +78 -0
- package/dist/mcp/client.d.ts +31 -0
- package/dist/mcp/client.js +94 -0
- package/dist/mcp/oauth.d.ts +13 -0
- package/dist/mcp/oauth.js +93 -0
- package/dist/mcp/server.d.ts +87 -0
- package/dist/mcp/server.js +125 -0
- package/dist/merge.d.ts +7 -0
- package/dist/merge.js +39 -0
- package/dist/providers/devplatforms.d.ts +34 -0
- package/dist/providers/devplatforms.js +612 -0
- package/dist/providers/finders.d.ts +38 -0
- package/dist/providers/finders.js +708 -0
- package/dist/providers/freetier.d.ts +9 -0
- package/dist/providers/freetier.js +254 -0
- package/dist/providers/github.d.ts +8 -0
- package/dist/providers/github.js +109 -0
- package/dist/providers/identity.d.ts +5 -0
- package/dist/providers/identity.js +62 -0
- package/dist/providers/index.d.ts +10 -0
- package/dist/providers/index.js +68 -0
- package/dist/providers/knowledge.d.ts +52 -0
- package/dist/providers/knowledge.js +302 -0
- package/dist/providers/pattern.d.ts +6 -0
- package/dist/providers/pattern.js +99 -0
- package/dist/providers/registries.d.ts +36 -0
- package/dist/providers/registries.js +396 -0
- package/dist/providers/research.d.ts +30 -0
- package/dist/providers/research.js +471 -0
- package/dist/providers/signals.d.ts +15 -0
- package/dist/providers/signals.js +116 -0
- package/dist/providers/smtp.d.ts +25 -0
- package/dist/providers/smtp.js +97 -0
- package/dist/providers/social.d.ts +37 -0
- package/dist/providers/social.js +657 -0
- package/dist/providers/verifiers.d.ts +47 -0
- package/dist/providers/verifiers.js +455 -0
- package/dist/providers/websearch.d.ts +32 -0
- package/dist/providers/websearch.js +346 -0
- package/dist/router.d.ts +31 -0
- package/dist/router.js +214 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +52 -0
- package/dist/store.d.ts +32 -0
- package/dist/store.js +95 -0
- package/dist/types.d.ts +82 -0
- package/dist/types.js +1 -0
- package/dist/util/http.d.ts +19 -0
- package/dist/util/http.js +34 -0
- package/dist/util/match.d.ts +23 -0
- package/dist/util/match.js +72 -0
- package/dist/util/names.d.ts +11 -0
- package/dist/util/names.js +56 -0
- package/dist/util/patterns.d.ts +14 -0
- package/dist/util/patterns.js +61 -0
- package/package.json +55 -4
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { connect } from 'node:net';
|
|
2
|
+
import { randomBytes } from 'node:crypto';
|
|
3
|
+
import { hostname } from 'node:os';
|
|
4
|
+
class Conn {
|
|
5
|
+
sock;
|
|
6
|
+
buf = '';
|
|
7
|
+
waiters = [];
|
|
8
|
+
constructor(sock) {
|
|
9
|
+
this.sock = sock;
|
|
10
|
+
sock.setEncoding('utf8');
|
|
11
|
+
sock.on('data', (d) => {
|
|
12
|
+
this.buf += d;
|
|
13
|
+
// A full reply ends with a line "NNN " (space, not dash).
|
|
14
|
+
const m = this.buf.match(/(?:^|\r?\n)(\d{3}) [^\r\n]*\r?\n$/);
|
|
15
|
+
if (m) {
|
|
16
|
+
const reply = this.buf;
|
|
17
|
+
this.buf = '';
|
|
18
|
+
this.waiters.shift()?.(reply);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
read(timeoutMs) {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
const t = setTimeout(() => reject(new Error('smtp timeout')), timeoutMs);
|
|
25
|
+
this.waiters.push((l) => { clearTimeout(t); resolve(l); });
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
async cmd(line, timeoutMs) {
|
|
29
|
+
return (await this.cmdText(line, timeoutMs)).code;
|
|
30
|
+
}
|
|
31
|
+
async cmdText(line, timeoutMs) {
|
|
32
|
+
const p = this.read(timeoutMs);
|
|
33
|
+
this.sock.write(line + '\r\n');
|
|
34
|
+
const reply = await p;
|
|
35
|
+
const lines = reply.trim().split(/\r?\n/);
|
|
36
|
+
const last = lines[lines.length - 1];
|
|
37
|
+
return { code: Number(last.slice(0, 3)), text: last };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export async function smtpCheck(mx, domain, emails, opts = {}) {
|
|
41
|
+
const timeout = opts.timeoutMs ?? 15000;
|
|
42
|
+
const helo = opts.helo ?? hostname();
|
|
43
|
+
const from = opts.from ?? `verify@${helo.includes('.') ? helo : 'example.com'}`;
|
|
44
|
+
const verdicts = new Map(emails.map((e) => [e, null]));
|
|
45
|
+
const sock = connect({ host: mx, port: 25 });
|
|
46
|
+
const c = new Conn(sock);
|
|
47
|
+
await new Promise((res, rej) => {
|
|
48
|
+
sock.once('connect', () => res());
|
|
49
|
+
sock.once('error', rej);
|
|
50
|
+
setTimeout(() => rej(new Error('smtp connect timeout')), timeout);
|
|
51
|
+
});
|
|
52
|
+
sock.on('error', () => { });
|
|
53
|
+
let catchAll = null;
|
|
54
|
+
try {
|
|
55
|
+
const greet = await c.read(timeout);
|
|
56
|
+
if (!greet.startsWith('220'))
|
|
57
|
+
throw new Error(`smtp greeting: ${greet.slice(0, 80)}`);
|
|
58
|
+
let code = await c.cmd(`EHLO ${helo}`, timeout);
|
|
59
|
+
if (code !== 250)
|
|
60
|
+
code = await c.cmd(`HELO ${helo}`, timeout);
|
|
61
|
+
if (code !== 250)
|
|
62
|
+
throw new Error(`smtp helo rejected (${code})`);
|
|
63
|
+
code = await c.cmd(`MAIL FROM:<${from}>`, timeout);
|
|
64
|
+
if (code !== 250)
|
|
65
|
+
throw new Error(`smtp mail from rejected (${code})`);
|
|
66
|
+
const probe = `zz${randomBytes(6).toString('hex')}@${domain}`;
|
|
67
|
+
const pr = await c.cmdText(`RCPT TO:<${probe}>`, timeout);
|
|
68
|
+
if (isPolicyBlock(pr.text))
|
|
69
|
+
throw new Error(`smtp blocked by policy (bad sender IP?): ${pr.text.slice(0, 120)}`);
|
|
70
|
+
if (pr.code >= 200 && pr.code < 300)
|
|
71
|
+
catchAll = true;
|
|
72
|
+
else if (isMailboxReject(pr))
|
|
73
|
+
catchAll = false;
|
|
74
|
+
if (catchAll === false) {
|
|
75
|
+
for (const e of emails) {
|
|
76
|
+
const r = await c.cmdText(`RCPT TO:<${e}>`, timeout);
|
|
77
|
+
verdicts.set(e, r.code >= 200 && r.code < 300 ? true : isMailboxReject(r) ? false : null);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
sock.write('QUIT\r\n');
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
sock.end();
|
|
84
|
+
setTimeout(() => sock.destroy(), 1000).unref();
|
|
85
|
+
}
|
|
86
|
+
return { catchAll, verdicts };
|
|
87
|
+
}
|
|
88
|
+
/** 5.7.x = policy (blocklisted IP, no PTR, etc.): says nothing about the mailbox. */
|
|
89
|
+
export function isPolicyBlock(text) {
|
|
90
|
+
return /\b5\.7\.\d+\b/.test(text) || /spamhaus|blocked|blacklist|blocklist|reputation|policy/i.test(text);
|
|
91
|
+
}
|
|
92
|
+
/** A real "no such mailbox" answer: 5.1.x, or a 550 that talks about the user/mailbox. */
|
|
93
|
+
export function isMailboxReject(r) {
|
|
94
|
+
if (r.code < 500 || isPolicyBlock(r.text))
|
|
95
|
+
return false;
|
|
96
|
+
return /\b5\.1\.\d+\b/.test(r.text) || /user|mailbox|recipient|address|unknown|not exist|no such/i.test(r.text);
|
|
97
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { PersonQuery, Provider, ProviderContext } from '../types.ts';
|
|
2
|
+
export declare function decodeEntities(s: string): string;
|
|
3
|
+
export declare function zbase32(buf: Uint8Array): string;
|
|
4
|
+
/** WKD hashed local part: z-base-32(SHA-1(lowercase local part)). */
|
|
5
|
+
export declare function wkdHash(localPart: string): string;
|
|
6
|
+
export declare function npub(hex: string): string;
|
|
7
|
+
export declare const blueskyProvider: Provider;
|
|
8
|
+
export declare const mastodonProvider: Provider;
|
|
9
|
+
/** Fetch a WKD key for an address (advanced then direct method). Returns user IDs, or null on miss. */
|
|
10
|
+
export declare function wkdLookup(ctx: ProviderContext, email: string): Promise<string[] | null>;
|
|
11
|
+
export declare const wkdProvider: Provider;
|
|
12
|
+
export declare const libravatarProvider: Provider;
|
|
13
|
+
export declare const nostrProvider: Provider;
|
|
14
|
+
export interface HumansEntry {
|
|
15
|
+
title?: string;
|
|
16
|
+
email?: string;
|
|
17
|
+
twitter?: string;
|
|
18
|
+
location?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Find the person's block in a humans.txt and pull role, contact, twitter and location from it. */
|
|
21
|
+
export declare function parseHumansTxt(txt: string, name: string): HumansEntry | null;
|
|
22
|
+
export declare const humansTxtProvider: Provider;
|
|
23
|
+
/** HTML -> lines of text, with links kept as [[url]] markers so we can find a card's mailto/LinkedIn. */
|
|
24
|
+
export declare function htmlToLines(html: string): string[];
|
|
25
|
+
export interface TeamCard {
|
|
26
|
+
title?: string;
|
|
27
|
+
titleConfidence?: number;
|
|
28
|
+
email?: string;
|
|
29
|
+
linkedin?: string;
|
|
30
|
+
}
|
|
31
|
+
/** Find the person on a team/about page: nearby job title, and a mailto/LinkedIn in the same card. */
|
|
32
|
+
export declare function parseTeamPage(html: string, q: PersonQuery): TeamCard | null;
|
|
33
|
+
/** Same-site links that look like a team page (by path or by link text), absolute URLs. */
|
|
34
|
+
export declare function teamLinks(html: string, base: string, domain: string): string[];
|
|
35
|
+
export declare const teamPageProvider: Provider;
|
|
36
|
+
export declare const mediumProvider: Provider;
|
|
37
|
+
export declare const SOCIAL_PROVIDERS: Provider[];
|