oculon 0.1.6 → 0.1.7
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/README.md +24 -8
- package/dist/cli/main.js +82 -0
- package/dist/core/calls.d.ts +63 -0
- package/dist/core/calls.js +120 -0
- package/dist/core/http.d.ts +11 -0
- package/dist/core/http.js +110 -30
- package/dist/core/pdf.d.ts +51 -0
- package/dist/core/pdf.js +211 -0
- package/dist/core/verdict.d.ts +30 -0
- package/dist/core/verdict.js +164 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +29 -0
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.js +129 -5
- package/dist/modules/checks.d.ts +59 -0
- package/dist/modules/checks.js +134 -0
- package/dist/modules/doc.d.ts +61 -0
- package/dist/modules/doc.js +715 -0
- package/dist/modules/utility.d.ts +27 -1
- package/dist/modules/utility.js +108 -11
- package/dist/report-pdf.d.ts +7 -0
- package/dist/report-pdf.js +81 -0
- package/dist/web/card.d.ts +28 -0
- package/dist/web/card.js +75 -0
- package/dist/web/index.html +76 -4
- package/dist/web/openapi.js +2 -0
- package/dist/web/pages.d.ts +24 -0
- package/dist/web/pages.js +139 -0
- package/dist/web/public.js +2 -0
- package/dist/web/server.js +84 -10
- package/dist/web/token.html +2 -1
- package/dist/web/utility.html +40 -14
- package/package.json +1 -1
package/dist/web/index.html
CHANGED
|
@@ -347,6 +347,10 @@ nav button { white-space: nowrap; }
|
|
|
347
347
|
.ov-hidden button { background: none; border: 1px solid var(--line); color: var(--muted); font: 11.5px var(--mono); padding: 3px 8px; margin: 0 6px 6px 0; cursor: pointer; }
|
|
348
348
|
@media (max-width: 1100px) { .hosts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
|
349
349
|
@media (max-width: 720px) { .hosts { grid-template-columns: minmax(0, 1fr); } .ib { grid-template-columns: 44px minmax(0, 1fr); } .ib .acts { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; } .tl-it { grid-template-columns: 90px 40px minmax(0, 1fr); } }
|
|
350
|
+
.filepick{flex:1 1 260px;display:flex;align-items:center;gap:10px;border:1px dashed rgba(0,240,255,.45);padding:10px 12px;cursor:pointer;color:var(--soft,#cfcfcf);font-size:14px;min-width:0}
|
|
351
|
+
.filepick input{max-width:110px}
|
|
352
|
+
#inv-ta{flex:1 1 100%;width:100%;font:13px/1.5 ui-monospace,Consolas,monospace;background:#05090a;color:#e8eef0;border:1px solid #2a3437;padding:10px;resize:vertical}
|
|
353
|
+
.seen{margin-top:14px;border-left:3px solid #00f0ff;padding:8px 12px;background:rgba(0,240,255,.05)}
|
|
350
354
|
</style>
|
|
351
355
|
</head>
|
|
352
356
|
<body>
|
|
@@ -555,6 +559,9 @@ nav button { white-space: nowrap; }
|
|
|
555
559
|
<optgroup label="Everyday checks">
|
|
556
560
|
<option value="scam">Is this message a scam? (paste it)</option>
|
|
557
561
|
<option value="url">Is this link safe? (URL)</option>
|
|
562
|
+
<option value="doc">Was this document edited? (PDF, screenshot or photo)</option>
|
|
563
|
+
<option value="iban">Is this IBAN valid? (IBAN)</option>
|
|
564
|
+
<option value="headers">Was this email spoofed? (paste raw headers)</option>
|
|
558
565
|
<option value="factcheck">Fact check (claim or news URL)</option>
|
|
559
566
|
<option value="audit">Dependency audit (package.json or npm:name@version)</option>
|
|
560
567
|
<option value="travel">Travel risk (place)</option>
|
|
@@ -571,6 +578,9 @@ nav button { white-space: nowrap; }
|
|
|
571
578
|
<optgroup label="Threat intel">
|
|
572
579
|
<option value="ip">IP address check (IP or domain)</option>
|
|
573
580
|
<option value="hash">File hash check (MD5, SHA-1, SHA-256)</option>
|
|
581
|
+
<option value="lookalike">Lookalike domains of a brand (domain)</option>
|
|
582
|
+
<option value="address">Crypto address check (BTC, 0x, Solana, Tron)</option>
|
|
583
|
+
<option value="honeypot">Can this token be sold? (0x, Ethereum, BNB, Base)</option>
|
|
574
584
|
<option value="ransomware">Ransomware claims (country, sector, name, or empty)</option>
|
|
575
585
|
<option value="satellites">Satellites (name, NORAD number, or empty for new launches)</option>
|
|
576
586
|
</optgroup>
|
|
@@ -598,6 +608,8 @@ nav button { white-space: nowrap; }
|
|
|
598
608
|
</optgroup>
|
|
599
609
|
</select>
|
|
600
610
|
<input type="text" id="inv-q" placeholder="paypa1-secure-login.top/verify" aria-label="Query">
|
|
611
|
+
<label id="inv-file-l" class="filepick" hidden><input type="file" id="inv-file" accept=".pdf,.png,.jpg,.jpeg,application/pdf,image/png,image/jpeg"><span id="inv-file-n">Choose a PDF, PNG or JPEG (max 10 MB)</span></label>
|
|
612
|
+
<textarea id="inv-ta" rows="7" hidden aria-label="Raw email headers" placeholder="Paste the full raw headers. Gmail: open the email, ⋮ menu, Show original. Outlook: File, Properties, Internet headers."></textarea>
|
|
601
613
|
<button class="go" id="inv-go">Investigate</button>
|
|
602
614
|
</div>
|
|
603
615
|
<div id="inv-out" class="out"></div>
|
|
@@ -933,7 +945,7 @@ function handleMapClick(e) {
|
|
|
933
945
|
const waitMap = setInterval(() => { if (map) { map.on('click', handleMapClick); clearInterval(waitMap); } }, 300);
|
|
934
946
|
|
|
935
947
|
/* investigate */
|
|
936
|
-
const placeholders = { phone: '+1 876 555 0100', password: 'type a password (it never leaves your browser)', breaches: '(empty = newest breaches) or adobe.com', company: 'NL004495445B01', ip: '185.220.101.1', hash: '094fd325049b8a9cf6d3e5ef2a6d4cc6a567d7d49c35f8bb8dd9e3c6acf3d78d', ransomware: '(empty = newest claims) or Healthcare, DE, a company', satellites: '(empty = new launches) or ISS, 25544', scam: 'USPS: your package is on hold, pay the $1.99 fee within 24 hours at usps-redelivery-help.top/track', recall: '2018 Honda Accord', emailsec: 'example.com', airport: 'JFK', country: 'Argentina', papers: 'solid-state battery', url: 'paypa1-secure-login.top/verify', factcheck: 'The Great Wall of China is visible from space', audit: 'npm:lodash@4.17.15 npm:request pypi:requests==2.19.0', travel: 'Lisbon', dossier: 'Nvidia', hype: 'ai agent', footprint: 'openai.com', lights: 'Gaza Strip', aircraft: 'N628TS', image: 'Kyoto', /*onchain*/wallet: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', token: '0xdac17f958d2ee523a2206206994597c13d831ec7', /*/onchain*/air: 'New Delhi', space: '(no input needed)', /*onchain*/robinhood: '(no input needed)', deployer: '0x… token or deployer', /*/onchain*/launches: 'OpenAI', markets: '(no input needed)', rewind: '2026-11-12', sanctions: 'IMO 1234567 or 0x… or exact name', health: 'Nvidia', impact: '(empty = current quakes and storms)', contradictions: 'Anthropic IPO' };
|
|
948
|
+
const placeholders = { doc: '', headers: '', iban: 'GB82 WEST 1234 5698 7654 32', lookalike: 'paypal.com', address: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh', honeypot: '0x6982508145454ce325ddbe47a25d4ec3d2311933', phone: '+1 876 555 0100', password: 'type a password (it never leaves your browser)', breaches: '(empty = newest breaches) or adobe.com', company: 'NL004495445B01', ip: '185.220.101.1', hash: '094fd325049b8a9cf6d3e5ef2a6d4cc6a567d7d49c35f8bb8dd9e3c6acf3d78d', ransomware: '(empty = newest claims) or Healthcare, DE, a company', satellites: '(empty = new launches) or ISS, 25544', scam: 'USPS: your package is on hold, pay the $1.99 fee within 24 hours at usps-redelivery-help.top/track', recall: '2018 Honda Accord', emailsec: 'example.com', airport: 'JFK', country: 'Argentina', papers: 'solid-state battery', url: 'paypa1-secure-login.top/verify', factcheck: 'The Great Wall of China is visible from space', audit: 'npm:lodash@4.17.15 npm:request pypi:requests==2.19.0', travel: 'Lisbon', dossier: 'Nvidia', hype: 'ai agent', footprint: 'openai.com', lights: 'Gaza Strip', aircraft: 'N628TS', image: 'Kyoto', /*onchain*/wallet: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', token: '0xdac17f958d2ee523a2206206994597c13d831ec7', /*/onchain*/air: 'New Delhi', space: '(no input needed)', /*onchain*/robinhood: '(no input needed)', deployer: '0x… token or deployer', /*/onchain*/launches: 'OpenAI', markets: '(no input needed)', rewind: '2026-11-12', sanctions: 'IMO 1234567 or 0x… or exact name', health: 'Nvidia', impact: '(empty = current quakes and storms)', contradictions: 'Anthropic IPO' };
|
|
937
949
|
const usd = (x) => (x == null ? '?' : '$' + Math.round(x).toLocaleString('en-US'));
|
|
938
950
|
|
|
939
951
|
/* brief: tiny, safe Markdown renderer (escape first, then headings, bold, links, bullets) */
|
|
@@ -1080,7 +1092,15 @@ $('#ask-go').onclick = async () => {
|
|
|
1080
1092
|
finally { $('#ask-go').disabled = false; }
|
|
1081
1093
|
};
|
|
1082
1094
|
$('#ask-q').addEventListener('keydown', (e) => { if (e.key === 'Enter') $('#ask-go').click(); });
|
|
1083
|
-
$('#inv-kind').onchange = () => { const k = $('#inv-kind').value; $('#inv-q').placeholder = placeholders[k]; $('#inv-q').type = k === 'password' ? 'password' : 'text'; if (k === 'password') $('#inv-q').value = ''; };
|
|
1095
|
+
$('#inv-kind').onchange = () => { const k = $('#inv-kind').value; $('#inv-q').placeholder = placeholders[k]; $('#inv-q').type = k === 'password' ? 'password' : 'text'; if (k === 'password') $('#inv-q').value = ''; $('#inv-q').hidden = k === 'doc' || k === 'headers'; $('#inv-file-l').hidden = k !== 'doc'; $('#inv-ta').hidden = k !== 'headers'; };
|
|
1096
|
+
$('#inv-file').onchange = () => { const f = $('#inv-file').files[0]; $('#inv-file-n').textContent = f ? f.name + ' · ' + Math.round(f.size / 1024) + ' KB' : 'Choose a PDF, PNG or JPEG (max 10 MB)'; };
|
|
1097
|
+
/* Under every recorded check: what changed since last time, the replay log and the PDF report. */
|
|
1098
|
+
function checkFoot(r) {
|
|
1099
|
+
const c = r && r.check;
|
|
1100
|
+
if (!c) return '';
|
|
1101
|
+
const seen = c.seenBefore ? `<div class="seen"><b>Seen before</b> on ${esc(c.seenBefore.at.slice(0, 16).replace('T', ' '))} UTC${c.seenBefore.changes.length ? `: what changed<ul class="ev">${c.seenBefore.changes.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>` : '. Nothing changed since then.'}</div>` : '';
|
|
1102
|
+
return `${seen}<p class="row" style="margin-top:12px;gap:14px"><a class="icon-btn" href="${esc(c.replay)}" target="_blank" rel="noopener">Replay log</a><a class="icon-btn" href="${esc(c.report)}" target="_blank" rel="noopener">PDF report</a><span class="meta">check ${esc(c.id.slice(0, 8))}</span></p>`;
|
|
1103
|
+
}
|
|
1084
1104
|
const spark = (xs) => { const m = Math.max(...xs, 1e-9); return `<span class="spark">${xs.map((x) => `<i style="height:${Math.max(2, Math.round((x / m) * 28))}px" title="${esc(x)}"></i>`).join('')}</span>`; };
|
|
1085
1105
|
const sigList = (s) => (s.length ? `<h3>Signals</h3>${s.map(renderSignal).join('')}` : '');
|
|
1086
1106
|
const link = (u, t) => `<a href="${safeUrl(u)}" target="_blank" rel="noopener noreferrer">${esc(t)}</a>`;
|
|
@@ -1134,6 +1154,36 @@ const views = {
|
|
|
1134
1154
|
const park = d.recalls.some((x) => x.parkIt || x.parkOutside);
|
|
1135
1155
|
return `<h3>${esc(head)} <span class="pill ${park ? 'bad' : d.recalls.length ? 'warn' : 'ok'}">${d.recalls.length ? d.recalls.length + ' recall' + (d.recalls.length === 1 ? '' : 's') : 'no recalls found'}</span></h3>${d.recalls.length ? `<ul class="ev">${d.recalls.slice(0, 15).map((x) => `<li>${x.parkIt ? '<b class="err">DO NOT DRIVE</b> ' : x.parkOutside ? '<b class="err">PARK OUTSIDE</b> ' : x.classification === 'Class I' ? '<b class="err">Class I</b> ' : ''}<b>${esc(x.title)}</b> <span class="meta">${esc(x.source)} ${esc(x.id)} · ${esc(x.date || '')}</span><div>${esc(x.hazard)}</div>${x.remedy ? `<div class="meta">${esc(x.remedy)}</div>` : ''}<a href="${safeUrl(x.url)}" target="_blank" rel="noopener noreferrer">details</a></li>`).join('')}</ul>` : ''}${d.note ? `<p class="meta">${esc(d.note)}</p>` : ''}`;
|
|
1136
1156
|
},
|
|
1157
|
+
doc: (r) => {
|
|
1158
|
+
const d = r.result;
|
|
1159
|
+
const t = d.verdict === 'dangerous file' || d.verdict === 'likely edited' ? 'bad' : d.verdict === 'signs of editing' ? 'warn' : 'ok';
|
|
1160
|
+
const meta = ['producer', 'creator', 'creator tool', 'software', 'created', 'modified', 'edit history'].filter((k) => d.metadata[k]).map((k) => `<tr><td>${esc(k)}</td><td>${esc(d.metadata[k])}</td></tr>`).join('');
|
|
1161
|
+
return `<h3>${esc(d.name)} ${tonePill(t, d.verdict)} <span class="meta">risk ${d.risk}/100 · ${esc(d.type)} · ${Math.round(d.bytes / 1024)} KB${d.revisions > 1 ? ' · saved ' + d.revisions + ' times' : ''}${d.signed ? ' · digitally signed' : ''}</span></h3>${d.flags.length ? `<ul class="ev">${d.flags.map((x) => `<li class="err">${esc(x)}</li>`).join('')}</ul>` : ''}${d.ibans.length ? `<h3>IBANs in the document</h3><ul class="ev">${d.ibans.map((i) => `<li><code>${esc(i.iban)}</code> ${tonePill(i.valid ? 'ok' : 'bad', i.valid ? 'valid' : 'not valid')} <span class="meta">${esc(i.country || '')}</span></li>`).join('')}</ul>` : ''}${meta ? `<h3>Made with</h3><table>${meta}</table>` : ''}${d.domains.length ? `<p class="meta">Domains in the text: ${esc(d.domains.join(', '))}</p>` : ''}<p class="meta">Text: ${d.text.chars} characters from the ${esc(d.text.from)}.</p>${d.notes.map((n) => `<p class="meta">${esc(n)}</p>`).join('')}<h3>What to do</h3><ul class="ev">${d.advice.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>`;
|
|
1162
|
+
},
|
|
1163
|
+
iban: (r) => {
|
|
1164
|
+
const d = r.result;
|
|
1165
|
+
return `<h3><code>${esc(d.formatted || d.input)}</code> ${tonePill(d.valid ? 'ok' : 'bad', d.valid ? 'valid format' : 'not valid')}</h3>${d.countryName ? `<p>${esc([d.countryName, d.bank ? d.bank.kind + ' ' + d.bank.code : null, d.sortCode ? 'sort code ' + d.sortCode : null].filter(Boolean).join(' · '))}</p>` : ''}${d.problems.length || d.warnings.length ? `<ul class="ev">${[...d.problems, ...d.warnings].map((x) => `<li class="err">${esc(x)}</li>`).join('')}</ul>` : ''}<h3>What to do</h3><ul class="ev">${d.advice.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>`;
|
|
1166
|
+
},
|
|
1167
|
+
headers: (r) => {
|
|
1168
|
+
const d = r.result;
|
|
1169
|
+
const t = d.verdict === 'likely spoofed' ? 'bad' : d.verdict === 'suspicious' ? 'warn' : 'ok';
|
|
1170
|
+
return `<h3>${esc(d.from.address || 'unknown sender')} ${tonePill(t, d.verdict)} <span class="meta">risk ${d.risk}/100</span></h3><p>SPF ${esc(d.auth.spf || '?')} · DKIM ${esc(d.auth.dkim || '?')} · DMARC ${esc(d.auth.dmarc || '?')}${d.origin.ip ? ` · sent from ${esc(d.origin.ip)}${d.origin.country ? ' · ' + esc(d.origin.country) : ''}${d.origin.isp ? ' · ' + esc(d.origin.isp) : ''}` : ''}</p>${d.flags.length ? `<ul class="ev">${d.flags.map((x) => `<li class="err">${esc(x)}</li>`).join('')}</ul>` : ''}<h3>What to do</h3><ul class="ev">${d.advice.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>`;
|
|
1171
|
+
},
|
|
1172
|
+
lookalike: (r) => {
|
|
1173
|
+
const d = r.result;
|
|
1174
|
+
const t = d.risk === 'high' ? 'bad' : d.risk === 'medium' ? 'warn' : 'ok';
|
|
1175
|
+
return `<h3>${esc(d.domain)} ${tonePill(t, d.risk + ' risk')} <span class="meta">${d.live.length} of ${d.checked} lookalikes exist</span></h3>${d.live.length ? `<table><tr><th>domain</th><th>kind</th><th></th></tr>${d.live.slice(0, 30).map((l) => `<tr><td><code>${esc(l.domain)}</code></td><td>${esc(l.kind)}</td><td>${l.mx ? '<span class="err">receives mail</span> ' : ''}${l.certSeen ? '<span class="err">new cert ' + esc(l.certSeen.slice(0, 10)) + '</span>' : ''}</td></tr>`).join('')}</table>` : ''}${d.certs.length ? `<h3>Certificates naming the brand, last 90 days</h3><ul class="ev">${d.certs.slice(0, 12).map((x) => `<li><code>${esc(x.name)}</code> <span class="meta">${esc(x.firstSeen.slice(0, 10))} · ${esc(x.issuer)}</span></li>`).join('')}</ul>` : ''}<p class="meta">${esc(d.note)}</p>`;
|
|
1176
|
+
},
|
|
1177
|
+
honeypot: (r) => {
|
|
1178
|
+
const d = r.result;
|
|
1179
|
+
const t = d.verdict === 'honeypot' || d.verdict === 'high risk' ? 'bad' : d.verdict === 'caution' ? 'warn' : 'ok';
|
|
1180
|
+
return `<h3>${esc(d.symbol || d.address)} <span class="meta">${esc(d.chain)}</span> ${tonePill(t, d.verdict)}</h3><p>Buy tax ${d.buyTax ?? '?'}% · sell tax ${d.sellTax ?? '?'}%${d.holders ? ` · ${d.holders.failed} of ${d.holders.checked} recent holders could not sell` : ''}</p>${d.reasons.length ? `<ul class="ev">${d.reasons.map((x) => `<li class="err">${esc(x)}</li>`).join('')}</ul>` : ''}<h3>What to do</h3><ul class="ev">${d.advice.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>`;
|
|
1181
|
+
},
|
|
1182
|
+
address: (r) => {
|
|
1183
|
+
const d = r.result;
|
|
1184
|
+
const t = d.sanctioned ? 'bad' : d.warnings.length ? 'warn' : 'ok';
|
|
1185
|
+
return `<h3><code>${esc(d.address)}</code> ${tonePill(t, d.sanctioned ? 'sanctioned' : d.warnings.length ? 'check first' : 'no red flags')}</h3><p>${esc(d.format)}${d.network ? ' · ' + esc(d.network) : ''}${d.activity ? ' · ' + esc([d.activity.label, d.activity.balance, d.activity.txCount != null ? d.activity.txCount + ' transactions' : null, d.activity.isContract ? 'smart contract' : null].filter(Boolean).join(' · ')) : ''}</p>${d.warnings.length ? `<ul class="ev">${d.warnings.map((x) => `<li class="err">${esc(x)}</li>`).join('')}</ul>` : ''}<h3>What to do</h3><ul class="ev">${d.advice.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>`;
|
|
1186
|
+
},
|
|
1137
1187
|
emailsec: (r) => {
|
|
1138
1188
|
const d = r.result;
|
|
1139
1189
|
const tone = d.verdict === 'protected' ? 'ok' : d.verdict === 'partly protected' ? 'warn' : 'bad';
|
|
@@ -1290,13 +1340,35 @@ $('#inv-go').onclick = async () => {
|
|
|
1290
1340
|
finally { $('#inv-go').disabled = false; }
|
|
1291
1341
|
return;
|
|
1292
1342
|
}
|
|
1293
|
-
|
|
1343
|
+
if (kind === 'doc' || kind === 'headers') {
|
|
1344
|
+
$('#inv-go').disabled = true;
|
|
1345
|
+
try {
|
|
1346
|
+
let r;
|
|
1347
|
+
if (kind === 'doc') {
|
|
1348
|
+
const f = $('#inv-file').files[0];
|
|
1349
|
+
if (!f) throw new Error('Choose a file first.');
|
|
1350
|
+
if (f.size > 10 * 1024 * 1024) throw new Error('The file is larger than 10 MB.');
|
|
1351
|
+
out.innerHTML = '<p class="meta">Reading the file…</p>';
|
|
1352
|
+
const data = await new Promise((res, rej) => { const fr = new FileReader(); fr.onload = () => res(String(fr.result)); fr.onerror = () => rej(new Error('could not read the file')); fr.readAsDataURL(f); });
|
|
1353
|
+
r = await post('/api/doc', { name: f.name, data });
|
|
1354
|
+
} else {
|
|
1355
|
+
const h = $('#inv-ta').value.trim();
|
|
1356
|
+
if (h.length < 20) throw new Error('Paste the raw headers first.');
|
|
1357
|
+
out.innerHTML = '<p class="meta">Checking…</p>';
|
|
1358
|
+
r = await post('/api/headers', { headers: h });
|
|
1359
|
+
}
|
|
1360
|
+
out.innerHTML = views[kind](r) + checkFoot(r) + `<h3>Sources</h3>${renderSources(r.provenance)}`;
|
|
1361
|
+
} catch (err) { out.innerHTML = `<p class="err">${esc(err.message)}</p>`; }
|
|
1362
|
+
finally { $('#inv-go').disabled = false; }
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
const param = { iban: 'iban', lookalike: 'domain', address: 'address', honeypot: 'address', phone: 'number', breaches: 'domain', company: 'q', ip: 'ip', hash: 'hash', ransomware: 'q', satellites: 'q', scam: 'message', recall: 'q', emailsec: 'domain', airport: 'code', country: 'name', papers: 'topic', url: 'url', factcheck: 'claim', audit: 'packages', travel: 'place', dossier: 'name', hype: 'topic', footprint: 'domain', lights: 'place', aircraft: 'q', /*onchain*/wallet: 'address', token: 'address', /*/onchain*/air: 'place', space: 'x', /*onchain*/robinhood: 'x', deployer: 'address', /*/onchain*/launches: 'company', markets: 'x', rewind: 'date', sanctions: 'q', health: 'company', impact: 'place', contradictions: 'topic' }[kind];
|
|
1294
1366
|
$('#inv-go').disabled = true;
|
|
1295
1367
|
out.innerHTML = '<p class="meta">Working… some sources are rate-limited and take a while.</p>';
|
|
1296
1368
|
try {
|
|
1297
1369
|
const r = kind === 'audit' && /^[{]/.test(q) ? await post('/api/audit', { manifest: q }) : await api(`/api/${kind}?${param}=${encodeURIComponent(q)}`);
|
|
1298
1370
|
const shareable = ['url', 'factcheck', 'travel', 'audit', 'recall', 'emailsec', 'papers', 'country', 'airport'].includes(kind) && !(kind === 'audit' && /^[{]/.test(q));
|
|
1299
|
-
out.innerHTML = views[kind](r) + (shareable ? '<p class="row" style="margin-top:14px"><button class="icon-btn" id="inv-share">Share result</button><span class="meta" id="inv-share-out"></span></p>' : '') + `<h3>Sources</h3>${renderSources(r.provenance)}`;
|
|
1371
|
+
out.innerHTML = views[kind](r) + checkFoot(r) + (shareable ? '<p class="row" style="margin-top:14px"><button class="icon-btn" id="inv-share">Share result</button><span class="meta" id="inv-share-out"></span></p>' : '') + `<h3>Sources</h3>${renderSources(r.provenance)}`;
|
|
1300
1372
|
if (shareable) $('#inv-share').onclick = async () => {
|
|
1301
1373
|
const b = $('#inv-share');
|
|
1302
1374
|
b.disabled = true;
|
package/dist/web/openapi.js
CHANGED
|
@@ -16,6 +16,8 @@ const E = [
|
|
|
16
16
|
['/api/lookalike', 'lookalikes', 'Lookalike domains of a brand that exist in DNS, and new certificates naming the brand.', [{ name: 'domain', desc: 'The real domain', example: 'example.com', required: true }]],
|
|
17
17
|
['/api/honeypot', 'honeypotCheck', 'Can this token be sold? Buy and sell simulation with taxes (Ethereum, BNB Chain, Base).', [{ name: 'address', desc: 'Token contract address', example: '0x6982508145454Ce325dDbE47a25d4ec3d2311933', required: true }, { name: 'chain', desc: 'eth, bsc or base', example: 'eth' }]],
|
|
18
18
|
['/api/address', 'addressCheck', 'Crypto address check without keys: chain, OFAC sanctions, balance and activity.', [{ name: 'address', desc: 'Crypto address', example: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh', required: true }, { name: 'network', desc: '"robinhood" for Robinhood Chain 0x addresses', example: 'robinhood' }]],
|
|
19
|
+
['/api/check', 'getCheck', 'An earlier check by its id (returned as check.id by every check): verdict, every source call in order, what changed since the check before it, and the full result.', [{ name: 'id', desc: 'Check id', example: 'qQcUfNGmZgrcQ9kD', required: true }]],
|
|
20
|
+
['/api/status', 'sourceStatus', 'Which sources are up, slow, degraded or down, from real calls: success rate, median time, last error.', [{ name: 'hours', desc: 'Window in hours (default 24, max 48)', example: '24' }]],
|
|
19
21
|
['/api/satellites', 'satellites', 'Satellites launched in the last 30 days, or one object\'s orbit, owner and status.', [{ name: 'q', desc: 'Satellite name or NORAD number (optional)', example: '25544' }]],
|
|
20
22
|
['/api/travel', 'travelRisk', 'Travel risk for the coming week: official advice, weather, air, outbreaks, disasters, quakes, outages.', [{ name: 'place', desc: 'City or country', example: 'Lisbon', required: true }]],
|
|
21
23
|
['/api/airport', 'airportStatus', 'Airport weather (METAR, TAF), FAA delays and ground stops, nearby emergency squawks.', [{ name: 'code', desc: 'IATA or ICAO code, or name', example: 'JFK', required: true }]],
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-rendered pages for the replay log (/replay/<id>), source status (/status) and the AI-agent guides
|
|
3
|
+
* (/llms.txt, /llms-full.txt). Plain HTML in the site's look; no scripts needed to read them.
|
|
4
|
+
*/
|
|
5
|
+
import type { SourceStatus } from '../core/calls.js';
|
|
6
|
+
import type { CheckRecord } from '../modules/checks.js';
|
|
7
|
+
/** /replay/<id>: what a check said and every source it called, in order. */
|
|
8
|
+
export declare function replayPage(c: CheckRecord, history: {
|
|
9
|
+
id: string;
|
|
10
|
+
at: string;
|
|
11
|
+
verdict: string | null;
|
|
12
|
+
risk: number | null;
|
|
13
|
+
}[], base: string): string;
|
|
14
|
+
/** /status: which sources answered in the last day. */
|
|
15
|
+
export declare function statusPage(list: SourceStatus[], base: string, hours: number): string;
|
|
16
|
+
export interface ToolDoc {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
inputSchema: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
/** /llms.txt: a short guide for AI agents (llmstxt.org format). */
|
|
22
|
+
export declare function llmsTxt(tools: ToolDoc[], base: string, mcpUrl: string): string;
|
|
23
|
+
/** /llms-full.txt: every tool with its full description and arguments. */
|
|
24
|
+
export declare function llmsFull(tools: ToolDoc[], base: string, mcpUrl: string): string;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
2
|
+
const when = (iso) => `${iso.slice(0, 16).replace('T', ' ')} UTC`;
|
|
3
|
+
function shell(title, desc, body, canonical) {
|
|
4
|
+
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
5
|
+
<title>${esc(title)}</title><meta name="description" content="${esc(desc)}"><meta name="robots" content="noindex">
|
|
6
|
+
<link rel="icon" type="image/png" href="/favicon.ico"><meta name="theme-color" content="#000000">
|
|
7
|
+
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
8
|
+
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">
|
|
9
|
+
<style>
|
|
10
|
+
:root{--line:#1f2a2d;--soft:#cfd8da;--mut:#8fa3a7;--y:#00f0ff;--bad:#ff5d6c;--warn:#f5a524;--ok:#3ddc97;--sans:'Space Grotesk',system-ui,sans-serif;--mono:'Space Mono',ui-monospace,Consolas,monospace}
|
|
11
|
+
*{box-sizing:border-box}html,body{overflow-x:clip}
|
|
12
|
+
body{margin:0;background:#000;color:#fff;font-family:var(--sans);-webkit-font-smoothing:antialiased}
|
|
13
|
+
a{color:var(--y)}
|
|
14
|
+
header{border-bottom:1px solid #222}header .in{display:flex;justify-content:space-between;align-items:center;padding:18px clamp(16px,3vw,40px);gap:16px}
|
|
15
|
+
.logo{font-size:16px;font-weight:600;letter-spacing:.4em;text-decoration:none;color:#fff}.logo img{width:20px;height:20px;vertical-align:-4px;margin-right:12px}
|
|
16
|
+
header nav{display:flex;gap:20px;font-size:14px}header nav a{color:var(--soft);text-decoration:none}
|
|
17
|
+
main{max-width:980px;margin:0 auto;padding:48px clamp(16px,4vw,40px) 90px}
|
|
18
|
+
.lbl{font:12px var(--mono);letter-spacing:.14em;text-transform:uppercase;color:var(--mut)}
|
|
19
|
+
h1{margin:10px 0 8px;font-size:clamp(28px,4.5vw,44px);font-weight:400;letter-spacing:-.03em;line-height:1.1;overflow-wrap:anywhere}
|
|
20
|
+
h2{margin:40px 0 12px;font-size:20px;font-weight:500;padding-top:18px;border-top:1px solid #222}
|
|
21
|
+
p,li{color:var(--soft);font-size:16px;line-height:1.65}
|
|
22
|
+
.pill{display:inline-block;font:700 13px var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:6px 10px;color:#000;background:var(--mut)}
|
|
23
|
+
.pill.bad{background:var(--bad);color:#fff}.pill.warn{background:var(--warn)}.pill.ok{background:var(--ok)}
|
|
24
|
+
.kv{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-top:22px}
|
|
25
|
+
.kv div{border:1px solid var(--line);padding:12px 14px;background:rgba(4,10,12,.9)}.kv b{display:block;font:400 11px var(--mono);letter-spacing:.14em;color:var(--mut);text-transform:uppercase}.kv span{display:block;margin-top:6px;font:700 15px var(--mono);overflow-wrap:anywhere}
|
|
26
|
+
.tw{overflow-x:auto;border:1px solid var(--line)}
|
|
27
|
+
table{width:100%;border-collapse:collapse;font:13px var(--mono)}
|
|
28
|
+
th{text-align:left;font-weight:400;color:var(--mut);letter-spacing:.1em;text-transform:uppercase;font-size:11px;padding:10px 10px;border-bottom:1px solid var(--line);white-space:nowrap}
|
|
29
|
+
td{padding:9px 10px;border-bottom:1px solid #111a1c;color:#e8eef0;vertical-align:top}
|
|
30
|
+
td.n{text-align:right;white-space:nowrap}
|
|
31
|
+
.bar{display:inline-block;height:8px;background:var(--y);vertical-align:middle;min-width:2px}
|
|
32
|
+
.s-LIVE{color:var(--ok)}.s-CACHED{color:var(--y)}.s-ERROR{color:var(--bad)}.s-UNAVAILABLE{color:var(--warn)}
|
|
33
|
+
.st{font:700 12px var(--mono);text-transform:uppercase;letter-spacing:.08em}.st.up{color:var(--ok)}.st.slow{color:var(--warn)}.st.degraded{color:var(--warn)}.st.down{color:var(--bad)}
|
|
34
|
+
.btn{display:inline-block;font:700 13px var(--mono);letter-spacing:.08em;background:var(--y);color:#000;padding:11px 15px;text-decoration:none;margin:6px 10px 0 0}
|
|
35
|
+
.btn.o{background:none;color:var(--y);border:1px solid rgba(0,240,255,.5)}
|
|
36
|
+
.note{font-size:13px;color:var(--mut)}
|
|
37
|
+
pre{white-space:pre-wrap;overflow-wrap:anywhere;background:#050b0d;border:1px solid var(--line);padding:14px;font:12px/1.6 var(--mono);color:#dfe7e9;max-height:520px;overflow:auto}
|
|
38
|
+
footer{border-top:1px solid #222}footer .in{max-width:980px;margin:0 auto;padding:22px clamp(16px,4vw,40px);font:12px var(--mono);color:#5e5e5e;display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap}footer a{color:var(--mut)}
|
|
39
|
+
@media (max-width:720px){.kv{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
|
40
|
+
</style><link rel="canonical" href="${esc(canonical)}"></head><body>
|
|
41
|
+
<header><div class="in"><a class="logo" href="/"><img src="/assets/logo.svg" alt="">OCULON</a><nav><a href="/app">App</a><a href="/docs">Docs</a><a href="/status">Status</a></nav></div></header>
|
|
42
|
+
<main>${body}</main>
|
|
43
|
+
<footer><div class="in"><span>Oculon contributors · MIT</span><span><a href="/">Home</a> · <a href="/docs">Docs</a> · <a href="/status">Status</a> · <a href="/thetoken">Token</a></span></div></footer>
|
|
44
|
+
</body></html>`;
|
|
45
|
+
}
|
|
46
|
+
/** /replay/<id>: what a check said and every source it called, in order. */
|
|
47
|
+
export function replayPage(c, history, base) {
|
|
48
|
+
const v = c.verdict;
|
|
49
|
+
const t0 = c.calls.length ? Date.parse(c.calls[0].at) - c.calls[0].ms : Date.parse(c.createdAt);
|
|
50
|
+
const maxMs = Math.max(1, ...c.calls.map((k) => k.ms));
|
|
51
|
+
const rows = c.calls.map((k, i) => `<tr><td class="n">${i + 1}</td><td class="n">+${Math.max(0, ((Date.parse(k.at) - k.ms - t0) / 1000)).toFixed(2)}s</td><td>${esc(k.source)}</td><td>${esc(k.host)}${k.via ? ' <span class="note">(mirror)</span>' : ''}</td><td class="s-${esc(k.status)}">${esc(k.status)}${k.note ? `<div class="note">${esc(k.note)}</div>` : ''}</td><td class="n">${k.ms} ms <span class="bar" style="width:${Math.round((k.ms / maxMs) * 80)}px"></span></td></tr>`).join('');
|
|
52
|
+
const seen = c.seenBefore ? `<h2>Seen before</h2><p>Last checked ${esc(when(c.seenBefore.at))}, verdict then: <b>${esc(c.seenBefore.verdict ?? 'none')}</b>. ${c.seenBefore.changes.length ? '' : 'Nothing changed since then.'}</p>${c.seenBefore.changes.length ? `<ul>${c.seenBefore.changes.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>` : ''}` : '';
|
|
53
|
+
const hist = history.length > 1 ? `<h2>History of this target</h2><div class="tw"><table><tr><th>When</th><th>Verdict</th><th>Risk</th><th></th></tr>${history.map((h) => `<tr><td>${esc(when(h.at))}</td><td>${esc(h.verdict ?? '-')}</td><td class="n">${h.risk ?? '-'}</td><td>${h.id === c.id ? '<span class="note">this check</span>' : `<a href="/replay/${esc(h.id)}">replay</a>`}</td></tr>`).join('')}</table></div>` : '';
|
|
54
|
+
const result = c.result ? `<h2>Full result</h2><pre>${esc(JSON.stringify(c.result, null, 2).slice(0, 60_000))}</pre>` : '';
|
|
55
|
+
const body = `<div class="lbl">Replay log · ${esc(c.kind)}</div><h1>${esc(c.label)}</h1>
|
|
56
|
+
<p><span class="pill ${esc(v.tone)}">${esc(v.verdict ?? 'result')}</span>${v.risk !== null ? ` <span class="note">risk ${v.risk}/100</span>` : ''}</p>
|
|
57
|
+
<div class="kv"><div><b>Checked</b><span>${esc(when(c.createdAt))}</span></div><div><b>Took</b><span>${(c.durationMs / 1000).toFixed(1)} s</span></div><div><b>Source calls</b><span>${c.calls.length}</span></div><div><b>Live / cached / failed</b><span>${v.sources.live} / ${v.sources.cached} / ${v.sources.failed}</span></div></div>
|
|
58
|
+
<p><a class="btn" href="/report/${esc(c.id)}.pdf">Download PDF report</a><a class="btn o" href="/app#investigate">Run a new check</a></p>
|
|
59
|
+
${v.points.length ? `<h2>Why</h2><ul>${v.points.map((p) => `<li>${esc(p)}</li>`).join('')}</ul>` : ''}${seen}
|
|
60
|
+
<h2>Every source called</h2><p class="note">In the order they answered. Cached answers took 0 ms. A failed source is not a finding; a mirror answered when the main host was down.</p>
|
|
61
|
+
${rows ? `<div class="tw"><table><tr><th>#</th><th>Start</th><th>Source</th><th>Host</th><th>Status</th><th>Time</th></tr>${rows}</table></div>` : '<p>No network calls: this check ran on the input alone.</p>'}
|
|
62
|
+
${hist}${result}<p class="note" style="margin-top:28px">Kept for 90 days. Anyone with this link can see it.</p>`;
|
|
63
|
+
return shell(`Replay: ${c.label}`, `Oculon replay log of a ${c.kind} check`, body, `${base}/replay/${c.id}`);
|
|
64
|
+
}
|
|
65
|
+
/** /status: which sources answered in the last day. */
|
|
66
|
+
export function statusPage(list, base, hours) {
|
|
67
|
+
const n = (s) => list.filter((x) => x.state === s).length;
|
|
68
|
+
const rows = list.map((s) => `<tr><td>${esc(s.source)}<div class="note">${esc(s.hosts.join(', '))}</div></td><td><span class="st ${s.state}">${s.state}</span>${s.skippedUntil ? `<div class="note">skipped until ${esc(s.skippedUntil.slice(11, 16))} UTC, fallback in use</div>` : ''}</td><td class="n">${s.okPct}%</td><td class="n">${s.calls}</td><td class="n">${s.medianMs === null ? '-' : `${s.medianMs} ms`}</td><td>${s.lastError ? `${esc(s.lastError.at.slice(11, 16))} <span class="note">${esc(s.lastError.note)}</span>` : '<span class="note">none</span>'}</td></tr>`).join('');
|
|
69
|
+
const body = `<div class="lbl">Source status · last ${hours} hours</div><h1>Which sources are up, slow or down.</h1>
|
|
70
|
+
<p>Every check calls public sources. This page shows how each one answered Oculon in the last ${hours} hours, measured from real calls. When a source keeps failing it is skipped for a few minutes and a mirror or the last cached answer is used instead, and the result says so.</p>
|
|
71
|
+
<div class="kv"><div><b>Up</b><span style="color:var(--ok)">${n('up')}</span></div><div><b>Slow</b><span style="color:var(--warn)">${n('slow')}</span></div><div><b>Degraded</b><span style="color:var(--warn)">${n('degraded')}</span></div><div><b>Down</b><span style="color:var(--bad)">${n('down')}</span></div></div>
|
|
72
|
+
<h2>Sources</h2>${rows ? `<div class="tw"><table><tr><th>Source</th><th>State</th><th>Worked</th><th>Calls</th><th>Median</th><th>Last error</th></tr>${rows}</table></div>` : '<p>No live calls yet in this window.</p>'}
|
|
73
|
+
<p class="note" style="margin-top:20px">Up: the last calls worked. Degraded: some of the last five failed. Down: they all failed, or the source is being skipped. Slow: median above 5 seconds. JSON: <a href="/api/status">/api/status</a>.</p>`;
|
|
74
|
+
return shell('Oculon status', 'Which Oculon sources are up, slow or down', body, `${base}/status`);
|
|
75
|
+
}
|
|
76
|
+
const FIRST_SENTENCE = /^.*?(?<!\be\.g|\bi\.e|\bvs)[.?!](?=\s+[A-Z("]|$)/;
|
|
77
|
+
const WS = /\s+/g;
|
|
78
|
+
/** First sentence, not fooled by "e.g." or "i.e.". */
|
|
79
|
+
function firstSentence(d) {
|
|
80
|
+
const m = FIRST_SENTENCE.exec(d.replace(WS, ' '));
|
|
81
|
+
return (m ? m[0] : d).trim();
|
|
82
|
+
}
|
|
83
|
+
/** /llms.txt: a short guide for AI agents (llmstxt.org format). */
|
|
84
|
+
export function llmsTxt(tools, base, mcpUrl) {
|
|
85
|
+
const groups = [
|
|
86
|
+
['Everyday checks', /scam|url_check|doc_check|iban|email_headers|lookalike|phone|password|breaches|company|email_security|recall|travel|fact_check/],
|
|
87
|
+
['Threat intel', /ip_check|hash|ransomware|vulns|cve|package|exposure|bgp|blackout|cloud/],
|
|
88
|
+
['Crypto', /token|wallet|honeypot|address_check|robinhood|defi|protocol|sanctions/],
|
|
89
|
+
];
|
|
90
|
+
const line = (t) => `- [${t.name}](${base}/llms-full.txt#${t.name}): ${firstSentence(t.description)}`;
|
|
91
|
+
const used = new Set();
|
|
92
|
+
const sections = groups.map(([g, re]) => {
|
|
93
|
+
const ts = tools.filter((t) => re.test(t.name) && !used.has(t.name));
|
|
94
|
+
ts.forEach((t) => used.add(t.name));
|
|
95
|
+
return `## ${g}\n\n${ts.map(line).join('\n')}`;
|
|
96
|
+
});
|
|
97
|
+
const rest = tools.filter((t) => !used.has(t.name));
|
|
98
|
+
return `# Oculon
|
|
99
|
+
|
|
100
|
+
> Free, open-source OSINT engine (MIT). Checks things before you trust them: messages, links, documents, IBANs, phone numbers, email headers, IPs, file hashes, tokens and wallets. Every answer lists the sources it used and whether each was live, cached or unavailable.
|
|
101
|
+
|
|
102
|
+
Use it from an AI agent over MCP: add ${mcpUrl} as a remote MCP server (no key, no sign-in), or run \`npx oculon mcp\` locally. ${tools.length} tools.
|
|
103
|
+
|
|
104
|
+
Rules for agents:
|
|
105
|
+
- Report data as given. A source marked ERROR or UNAVAILABLE is not a finding.
|
|
106
|
+
- Check tools return a verdict, a risk score, reasons, and a check id. Pass \`brief: true\` to any tool for a short answer with fewer tokens.
|
|
107
|
+
- A check id opens a replay log (${base}/replay/<id>) with every source call, and a PDF report (${base}/report/<id>.pdf).
|
|
108
|
+
- Source health: ${base}/status (JSON at ${base}/api/status).
|
|
109
|
+
|
|
110
|
+
## Docs
|
|
111
|
+
|
|
112
|
+
- [Full tool reference](${base}/llms-full.txt): every tool with its arguments
|
|
113
|
+
- [Documentation](${base.replace('//app.', '//docs.')}): install, CLI, SDK, MCP, web
|
|
114
|
+
- [OpenAPI](${base}/openapi.json): the HTTP API
|
|
115
|
+
- [Source code](https://github.com/oculonlive/oculon)
|
|
116
|
+
|
|
117
|
+
${sections.join('\n\n')}
|
|
118
|
+
|
|
119
|
+
## Optional
|
|
120
|
+
|
|
121
|
+
${rest.map(line).join('\n')}
|
|
122
|
+
`;
|
|
123
|
+
}
|
|
124
|
+
/** /llms-full.txt: every tool with its full description and arguments. */
|
|
125
|
+
export function llmsFull(tools, base, mcpUrl) {
|
|
126
|
+
const args = (s) => {
|
|
127
|
+
const props = (s.properties ?? {});
|
|
128
|
+
const req = new Set((s.required ?? []));
|
|
129
|
+
const rows = Object.entries(props).map(([k, p]) => ` - \`${k}\` (${p.type ?? 'any'}${req.has(k) ? ', required' : ''})${p.description ? `: ${p.description}` : ''}${p.enum ? ` One of: ${p.enum.join(', ')}.` : ''}`);
|
|
130
|
+
return rows.length ? rows.join('\n') : ' - no arguments';
|
|
131
|
+
};
|
|
132
|
+
return `# Oculon: full tool reference
|
|
133
|
+
|
|
134
|
+
MCP endpoint: ${mcpUrl} (remote, no key) or \`npx oculon mcp\` (local, stdio).
|
|
135
|
+
Every tool also takes \`brief\` (boolean): a short answer for agents (verdict, risk, top reasons, sources, check id).
|
|
136
|
+
Check tools return \`check.id\`: replay log at ${base}/replay/<id>, PDF report at ${base}/report/<id>.pdf.
|
|
137
|
+
|
|
138
|
+
${tools.map((t) => `## ${t.name}\n\n${t.description}\n\nArguments:\n${args(t.inputSchema)}\n`).join('\n')}`;
|
|
139
|
+
}
|
package/dist/web/public.js
CHANGED
|
@@ -10,6 +10,8 @@ import { createHash, timingSafeEqual } from 'node:crypto';
|
|
|
10
10
|
/** Read-only endpoints the public pages call. Everything else needs the admin cookie. */
|
|
11
11
|
export const PUBLIC_API = new Set([
|
|
12
12
|
'/api/meta',
|
|
13
|
+
'/api/status',
|
|
14
|
+
'/api/check',
|
|
13
15
|
'/api/readme',
|
|
14
16
|
'/api/console',
|
|
15
17
|
'/api/signals',
|
package/dist/web/server.js
CHANGED
|
@@ -24,7 +24,9 @@ import { mailEnabled } from '../sources/resend.js';
|
|
|
24
24
|
import { analyst, crossExamine, isAnalystModel } from '../analyst.js';
|
|
25
25
|
import { scrubSecrets } from '../core/keys.js';
|
|
26
26
|
import { readBurns, rpcClient } from './burns.js';
|
|
27
|
-
import {
|
|
27
|
+
import { CHECK_ROUTES } from '../modules/checks.js';
|
|
28
|
+
import { llmsFull, llmsTxt, replayPage, statusPage } from './pages.js';
|
|
29
|
+
import { UTILITY, badgeSvg, createNonce, getInvestigation, holderFor, listInvestigations, runSafety, safetyState, signOutHolder, startInvestigation, startInvestigationHold, startSafety, startSafetyHold, tokenConfig, verifyHolder } from '../modules/utility.js';
|
|
28
30
|
/** Analyst questions and cross-examinations per visitor address per hour on a public install. */
|
|
29
31
|
const ANALYST_PER_HOUR = Number(process.env.OCULON_ANALYST_PER_HOUR ?? 40);
|
|
30
32
|
const analystHits = new Map();
|
|
@@ -393,7 +395,7 @@ export const POST_ROUTES = {
|
|
|
393
395
|
const raw = String(b.headers ?? '');
|
|
394
396
|
if (!raw.trim())
|
|
395
397
|
throw new HttpError(400, 'missing headers');
|
|
396
|
-
return o.headerCheck(raw.slice(0, 100_000));
|
|
398
|
+
return slim(await o.headerCheck(raw.slice(0, 100_000)));
|
|
397
399
|
},
|
|
398
400
|
'/api/fences': (b, o) => {
|
|
399
401
|
const box = Array.isArray(b.box) ? b.box.map(Number) : null;
|
|
@@ -561,7 +563,8 @@ export function tokenBlock(t) {
|
|
|
561
563
|
// The third cell links to the launchpad page when there is one, otherwise to a block explorer.
|
|
562
564
|
const link = launchpad ? { k: 'Launchpad', u: launchpad, label: new URL(launchpad).hostname.replace(/^www\./, '') } : explorer ? { k: 'Explorer', u: explorer, label: 'view' } : null;
|
|
563
565
|
const cell = (k, v) => `<div><b>${k}</b><span>${v ? esc(v) : '-'}</span></div>`;
|
|
564
|
-
|
|
566
|
+
const badge = /^0x[0-9a-fA-F]{40}$/.test(ca) ? `<a class="sbadge" href="/safety/${esc(ca.toLowerCase())}" title="Live safety check of this token"><img src="/badge/${esc(ca.toLowerCase())}.svg" alt="Oculon safety badge" height="22"></a>` : '';
|
|
567
|
+
return `<div class="ca"><div class="lbl">Contract address</div><div class="addr"><code id="ca-value">${esc(ca)}</code><button id="copy-ca" type="button">COPY</button></div>${badge}`
|
|
565
568
|
+ `<div class="meta">${cell('Chain', (t.chain ?? '').trim())}${cell('Ticker', (t.ticker ?? '').trim() ? `$${(t.ticker ?? '').trim().replace(/^\$/, '')}` : '')}<div><b>${link ? link.k : 'Explorer'}</b><span>${link ? `<a href="${esc(link.u)}" target="_blank" rel="noopener">${esc(link.label)}</a>` : '-'}</span></div></div></div>`;
|
|
566
569
|
}
|
|
567
570
|
function send(res, status, body, type, cache = 'no-store') {
|
|
@@ -574,6 +577,9 @@ function send(res, status, body, type, cache = 'no-store') {
|
|
|
574
577
|
});
|
|
575
578
|
res.end(body);
|
|
576
579
|
}
|
|
580
|
+
function siteDomainEarly(opts) {
|
|
581
|
+
return (opts.domain ?? process.env.OCULON_DOMAIN ?? '').trim().toLowerCase() || null;
|
|
582
|
+
}
|
|
577
583
|
export function createWebServer(opts = {}) {
|
|
578
584
|
const oculon = opts.oculon ?? new Oculon();
|
|
579
585
|
const log = opts.log ?? (() => { });
|
|
@@ -585,7 +591,8 @@ export function createWebServer(opts = {}) {
|
|
|
585
591
|
// OCULON_OPEN=1 opens the whole app to every visitor (no sign-in, no read-only gate, no rate limit).
|
|
586
592
|
const openApp = opts.open ?? process.env.OCULON_OPEN === '1';
|
|
587
593
|
// One MCP server for the HTTP transport, sharing this server's Oculon instance.
|
|
588
|
-
const
|
|
594
|
+
const appBase = siteDomainEarly(opts) ? `https://app.${siteDomainEarly(opts)}` : `http://127.0.0.1:${opts.port ?? 4747}`;
|
|
595
|
+
const mcpServer = new McpServer(() => oculon, { remote: publicMode, baseUrl: appBase });
|
|
589
596
|
// OCULON_PURGE_ONCHAIN=1 clears data left by the paused on-chain modules when the server starts.
|
|
590
597
|
if (!onchainEnabled() && process.env.OCULON_PURGE_ONCHAIN === '1') {
|
|
591
598
|
const removed = oculon.ctx.store.purgeOnchain();
|
|
@@ -742,7 +749,7 @@ export function createWebServer(opts = {}) {
|
|
|
742
749
|
try {
|
|
743
750
|
if (req.method === 'GET') {
|
|
744
751
|
if (url.pathname === '/api/utility/info')
|
|
745
|
-
return json({ token: tokenConfig(), amounts: { investigate: UTILITY.investigate.toString(), safety: UTILITY.safety.toString(), holder: UTILITY.holder.toString() }, safetyDays: UTILITY.safetyDays, holderMonitors: UTILITY.holderMonitors, holder: holderFor(oculon.ctx, owner), investigations: listInvestigations(oculon.ctx, 12) });
|
|
752
|
+
return json({ token: tokenConfig(), amounts: { investigate: UTILITY.investigate.toString(), safety: UTILITY.safety.toString(), holdInvestigate: UTILITY.holdInvestigate.toString(), holdSafety: UTILITY.holdSafety.toString(), holder: UTILITY.holder.toString() }, safetyDays: UTILITY.safetyDays, holderMonitors: UTILITY.holderMonitors, holder: holderFor(oculon.ctx, owner), investigations: listInvestigations(oculon.ctx, 12) });
|
|
746
753
|
if (url.pathname === '/api/utility/investigation') {
|
|
747
754
|
const v = getInvestigation(oculon.ctx, url.searchParams.get('id') ?? '');
|
|
748
755
|
return v ? json(v) : json({ error: 'no such investigation' }, 404);
|
|
@@ -765,9 +772,9 @@ export function createWebServer(opts = {}) {
|
|
|
765
772
|
return json({ ok: true });
|
|
766
773
|
}
|
|
767
774
|
if (url.pathname === '/api/utility/investigate')
|
|
768
|
-
return json(await startInvestigation(oculon, String(b.tx ?? ''), String(b.target ?? ''), String(b.signature ?? '')));
|
|
775
|
+
return json(b.mode === 'hold' ? await startInvestigationHold(oculon, String(b.target ?? ''), String(b.address ?? ''), String(b.nonce ?? ''), String(b.signature ?? '')) : await startInvestigation(oculon, String(b.tx ?? ''), String(b.target ?? ''), String(b.signature ?? '')));
|
|
769
776
|
if (url.pathname === '/api/utility/safety')
|
|
770
|
-
return json(await startSafety(oculon, String(b.tx ?? ''), String(b.token ?? ''), String(b.signature ?? '')));
|
|
777
|
+
return json(b.mode === 'hold' ? await startSafetyHold(oculon, String(b.token ?? ''), String(b.address ?? ''), String(b.nonce ?? ''), String(b.signature ?? '')) : await startSafety(oculon, String(b.tx ?? ''), String(b.token ?? ''), String(b.signature ?? '')));
|
|
771
778
|
}
|
|
772
779
|
return json({ error: 'not found' }, 404);
|
|
773
780
|
}
|
|
@@ -862,6 +869,28 @@ export function createWebServer(opts = {}) {
|
|
|
862
869
|
if (req.method === 'POST' && OWNER_ONLY.has(url.pathname) && !owner) {
|
|
863
870
|
return send(res, 403, '{"error":"the shared watchlist is managed by the owner; add your own monitors instead"}', 'application/json');
|
|
864
871
|
}
|
|
872
|
+
if (url.pathname === '/api/doc' && req.method === 'POST') {
|
|
873
|
+
if (!sameSite())
|
|
874
|
+
return send(res, 403, '{"error":"forbidden"}', 'application/json');
|
|
875
|
+
const ip = (viaEdge && String(req.headers['x-oculon-client-ip'] ?? '').trim()) || clientIp(req);
|
|
876
|
+
if (publicMode && !isAdmin(req, adminToken) && !analystLimit(ip))
|
|
877
|
+
return send(res, 429, '{"error":"You have checked a lot this hour. Try again a bit later."}', 'application/json');
|
|
878
|
+
try {
|
|
879
|
+
const b = await readJson(req, 15_000_000);
|
|
880
|
+
const b64 = String(b.data ?? '').replace(/^data:[^;]+;base64,/, '');
|
|
881
|
+
if (!b64)
|
|
882
|
+
throw new HttpError(400, 'choose a file first');
|
|
883
|
+
const file = Buffer.from(b64, 'base64');
|
|
884
|
+
const name = String(b.name ?? 'document').slice(0, 120);
|
|
885
|
+
const { createHash } = await import('node:crypto');
|
|
886
|
+
const r = await oculon.recordCheck('doc', createHash('sha256').update(file).digest('hex'), () => oculon.docCheck(file, name), { label: name });
|
|
887
|
+
log('POST /api/doc');
|
|
888
|
+
return send(res, 200, JSON.stringify({ ...slim(r.value), check: r.check }), 'application/json; charset=utf-8');
|
|
889
|
+
}
|
|
890
|
+
catch (e) {
|
|
891
|
+
return send(res, e instanceof HttpError ? e.status : 400, JSON.stringify({ error: e.message }), 'application/json; charset=utf-8');
|
|
892
|
+
}
|
|
893
|
+
}
|
|
865
894
|
if (req.method === 'POST' && POST_ROUTES[url.pathname]) {
|
|
866
895
|
// Writes only from this dashboard: a custom header (forces a CORS preflight that this server never
|
|
867
896
|
// grants), a JSON body, and a same-host Origin when the browser sends one.
|
|
@@ -878,8 +907,10 @@ export function createWebServer(opts = {}) {
|
|
|
878
907
|
return send(res, 403, '{"error":"forbidden"}', 'application/json');
|
|
879
908
|
}
|
|
880
909
|
try {
|
|
881
|
-
const body = await readJson(req);
|
|
882
|
-
const out =
|
|
910
|
+
const body = await readJson(req, url.pathname === '/api/headers' ? 200_000 : undefined);
|
|
911
|
+
const out = url.pathname === '/api/headers'
|
|
912
|
+
? await oculon.recordCheck('headers', String(body.headers ?? ''), async () => POST_ROUTES[url.pathname](body, oculon), { label: `email headers: ${(/^subject:\s*(.+)$/im.exec(String(body.headers ?? ''))?.[1] ?? 'pasted').slice(0, 70)}` }).then((r) => ({ ...r.value, check: r.check }))
|
|
913
|
+
: await POST_ROUTES[url.pathname](body, oculon);
|
|
883
914
|
log(`POST ${url.pathname}`);
|
|
884
915
|
return send(res, 200, JSON.stringify(out), 'application/json; charset=utf-8');
|
|
885
916
|
}
|
|
@@ -889,6 +920,46 @@ export function createWebServer(opts = {}) {
|
|
|
889
920
|
}
|
|
890
921
|
if (req.method !== 'GET')
|
|
891
922
|
return send(res, 405, '{"error":"method not allowed"}', 'application/json');
|
|
923
|
+
{
|
|
924
|
+
const base = siteDomain ? `https://app.${siteDomain}` : `http://${req.headers.host ?? '127.0.0.1'}`;
|
|
925
|
+
if (url.pathname === '/llms.txt' || url.pathname === '/llms-full.txt') {
|
|
926
|
+
const r = (await mcpServer.handle({ jsonrpc: '2.0', id: 0, method: 'tools/list' }));
|
|
927
|
+
const tools = r?.result?.tools ?? [];
|
|
928
|
+
const mcpUrl = siteDomain ? `https://mcp.${siteDomain}` : `${base}/mcp`;
|
|
929
|
+
res.setHeader('access-control-allow-origin', '*');
|
|
930
|
+
return send(res, 200, url.pathname === '/llms.txt' ? llmsTxt(tools, base, mcpUrl) : llmsFull(tools, base, mcpUrl), 'text/plain; charset=utf-8', 'public, max-age=3600');
|
|
931
|
+
}
|
|
932
|
+
if (url.pathname === '/status' || url.pathname === '/status/') {
|
|
933
|
+
const hours = Math.min(48, Number(url.searchParams.get('hours') ?? 24) || 24);
|
|
934
|
+
return send(res, 200, statusPage(oculon.sourceStatus(hours), base, hours), 'text/html; charset=utf-8', 'no-cache');
|
|
935
|
+
}
|
|
936
|
+
if (url.pathname === '/api/status') {
|
|
937
|
+
const hours = Math.min(48, Number(url.searchParams.get('hours') ?? 24) || 24);
|
|
938
|
+
res.setHeader('access-control-allow-origin', '*');
|
|
939
|
+
return send(res, 200, JSON.stringify({ hours, sources: oculon.sourceStatus(hours) }), 'application/json; charset=utf-8');
|
|
940
|
+
}
|
|
941
|
+
const replayId = /^\/replay\/([A-Za-z0-9_-]{10,40})\/?$/.exec(url.pathname)?.[1];
|
|
942
|
+
if (replayId) {
|
|
943
|
+
const c = oculon.check(replayId);
|
|
944
|
+
if (!c)
|
|
945
|
+
return send(res, 404, '<!doctype html><meta charset="utf-8"><title>Not found</title><body style="background:#000;color:#ccc;font-family:system-ui;padding:40px"><p>This check does not exist, or it is older than 90 days.</p>', 'text/html; charset=utf-8');
|
|
946
|
+
return send(res, 200, replayPage(c, oculon.checkHistory(replayId), base), 'text/html; charset=utf-8', 'private, max-age=60');
|
|
947
|
+
}
|
|
948
|
+
if (url.pathname === '/api/check') {
|
|
949
|
+
const c = oculon.check(url.searchParams.get('id') ?? '');
|
|
950
|
+
if (!c)
|
|
951
|
+
return send(res, 404, '{"error":"no such check"}', 'application/json');
|
|
952
|
+
return send(res, 200, JSON.stringify({ ...c, history: oculon.checkHistory(c.id) }), 'application/json; charset=utf-8');
|
|
953
|
+
}
|
|
954
|
+
const reportId = /^\/report\/([A-Za-z0-9_-]{10,40})\.pdf$/.exec(url.pathname)?.[1];
|
|
955
|
+
if (reportId) {
|
|
956
|
+
const pdf = oculon.checkPdf(reportId, base);
|
|
957
|
+
if (!pdf)
|
|
958
|
+
return send(res, 404, '{"error":"no such check"}', 'application/json');
|
|
959
|
+
res.writeHead(200, { 'content-type': 'application/pdf', 'content-disposition': `inline; filename="oculon-${reportId.slice(0, 8)}.pdf"`, 'cache-control': 'private, max-age=300', 'x-content-type-options': 'nosniff' });
|
|
960
|
+
return void res.end(pdf);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
892
963
|
if (url.pathname === '/openapi.json') {
|
|
893
964
|
res.setHeader('access-control-allow-origin', '*');
|
|
894
965
|
return send(res, 200, JSON.stringify(openApiSpec(siteDomain ? `https://app.${siteDomain}` : `http://${req.headers.host ?? '127.0.0.1'}`), null, 2), 'application/json; charset=utf-8', 'public, max-age=3600');
|
|
@@ -987,7 +1058,10 @@ export function createWebServer(opts = {}) {
|
|
|
987
1058
|
try {
|
|
988
1059
|
if (!onchainEnabled() && ONCHAIN_ROUTES.has(url.pathname))
|
|
989
1060
|
return send(res, 404, '{"error":"on-chain features are paused"}', 'application/json');
|
|
990
|
-
|
|
1061
|
+
const ck = CHECK_ROUTES[url.pathname];
|
|
1062
|
+
let out = ck && url.searchParams.get(ck.param)?.trim()
|
|
1063
|
+
? await oculon.recordCheck(ck.kind, url.searchParams.get(ck.param).trim(), async () => route(url.searchParams, oculon)).then((r) => (r.value && typeof r.value === 'object' ? { ...r.value, check: r.check } : r.value))
|
|
1064
|
+
: await route(url.searchParams, oculon);
|
|
991
1065
|
if (!onchainEnabled())
|
|
992
1066
|
out = withoutOnchain(url.pathname, out);
|
|
993
1067
|
if (!admin && url.pathname === '/api/signals')
|
package/dist/web/token.html
CHANGED
|
@@ -40,6 +40,7 @@ code{font:.86em var(--mono);background:rgba(0,20,24,.8);border:1px solid rgba(0,
|
|
|
40
40
|
.ca .meta{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin-top:18px}
|
|
41
41
|
.ca .meta div{border:1px solid #1f2a2d;padding:12px 14px}.ca .meta b{display:block;font:400 11px var(--mono);letter-spacing:.14em;color:var(--mut);text-transform:uppercase}.ca .meta span{display:block;margin-top:6px;font:700 16px var(--mono);overflow-wrap:anywhere}
|
|
42
42
|
.ca.none p{margin:0}
|
|
43
|
+
.sbadge{display:inline-block;margin-top:14px}.sbadge img{display:block}
|
|
43
44
|
.burn{margin-top:16px;border:1px solid rgba(255,93,108,.35);background:rgba(18,4,6,.75);backdrop-filter:blur(8px);padding:24px}
|
|
44
45
|
.btot{display:flex;align-items:baseline;gap:14px;flex-wrap:wrap;margin-top:10px}.btot span{font:700 clamp(28px,5vw,40px) var(--mono);color:#ff7a86}.btot em{font:400 14px var(--mono);color:var(--mut);font-style:normal}
|
|
45
46
|
.btable{margin-top:16px;overflow-x:auto}.btable table{width:100%;border-collapse:collapse;font:13px var(--mono)}
|
|
@@ -71,7 +72,7 @@ footer{border-top:1px solid var(--line);background:rgba(0,0,0,.6)}footer .in{max
|
|
|
71
72
|
<p>If an address is missing from any of the three, it is not Oculon. Oculon will never message you first, ask for your recovery phrase, or ask you to send funds to an address.</p>
|
|
72
73
|
|
|
73
74
|
<h2>Use OCULON</h2>
|
|
74
|
-
<p>
|
|
75
|
+
<p>Hold 1,500,000 OCULON for one deep investigation every 30 days of a domain, wallet, token or company. Hold 2,000,000 to keep a live safety badge on a Robinhood Chain token while you hold. Hold 3,500,000 for up to 30 personal monitors, checked every 15 minutes. Prefer not to hold? Burn 1,500,000 for an investigation or 1,000,000 for 30 days of a badge. Everything is read from the chain; Oculon stays free for everyone.</p>
|
|
75
76
|
<p><a href="/utility" style="color:var(--y)">Open the utility page →</a></p>
|
|
76
77
|
|
|
77
78
|
<h2>What Oculon is</h2>
|