oculon 0.1.5 → 0.1.6
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 +55 -3
- package/dist/cli/main.js +102 -0
- package/dist/core/evm.d.ts +20 -0
- package/dist/core/evm.js +165 -0
- package/dist/core/http.js +3 -0
- package/dist/core/quota.js +3 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +25 -0
- package/dist/mcp.js +31 -1
- package/dist/modules/address.d.ts +32 -0
- package/dist/modules/address.js +91 -0
- package/dist/modules/headers.d.ts +50 -0
- package/dist/modules/headers.js +108 -0
- package/dist/modules/honeypot.d.ts +36 -0
- package/dist/modules/honeypot.js +53 -0
- package/dist/modules/iban.d.ts +30 -0
- package/dist/modules/iban.js +82 -0
- package/dist/modules/lookalike.d.ts +34 -0
- package/dist/modules/lookalike.js +122 -0
- package/dist/modules/personal.d.ts +1 -1
- package/dist/modules/personal.js +14 -4
- package/dist/modules/utility.d.ts +121 -0
- package/dist/modules/utility.js +306 -0
- package/dist/telegram.d.ts +2 -0
- package/dist/telegram.js +43 -6
- package/dist/web/assets/logo-200.png +0 -0
- package/dist/web/burns.d.ts +21 -0
- package/dist/web/burns.js +53 -0
- package/dist/web/landing.html +1 -1
- package/dist/web/legal.html +1 -1
- package/dist/web/mcp.html +1 -1
- package/dist/web/openapi.js +4 -0
- package/dist/web/public.js +5 -1
- package/dist/web/server.d.ts +17 -0
- package/dist/web/server.js +129 -3
- package/dist/web/token.html +97 -0
- package/dist/web/token.json +9 -0
- package/dist/web/utility.html +225 -0
- package/package.json +1 -1
package/dist/modules/personal.js
CHANGED
|
@@ -28,13 +28,13 @@ export function listPersonal(ctx, owner) {
|
|
|
28
28
|
return db(ctx).prepare('SELECT * FROM personal_monitors WHERE owner = ? ORDER BY id').all(owner).map(toMonitor);
|
|
29
29
|
}
|
|
30
30
|
/** Reads the request into a rule and saves it for this owner (at most MAX_PER_OWNER). */
|
|
31
|
-
export async function addPersonal(ctx, owner, text) {
|
|
31
|
+
export async function addPersonal(ctx, owner, text, max = MAX_PER_OWNER) {
|
|
32
32
|
if (!isOwner(owner))
|
|
33
33
|
throw new Error('invalid owner');
|
|
34
34
|
const d = db(ctx);
|
|
35
35
|
const n = d.prepare('SELECT COUNT(*) n FROM personal_monitors WHERE owner = ?').get(owner).n;
|
|
36
|
-
if (n >=
|
|
37
|
-
throw new Error(`you can keep up to ${
|
|
36
|
+
if (n >= max)
|
|
37
|
+
throw new Error(`you can keep up to ${max} monitors; remove one first${max === MAX_PER_OWNER ? ' (OCULON holders can keep more)' : ''}`);
|
|
38
38
|
const r = await parseMonitor(text);
|
|
39
39
|
d.prepare('INSERT INTO personal_monitors (owner, kind, target, description, created_at) VALUES (?, ?, ?, ?, ?) ON CONFLICT(owner, kind, target) DO NOTHING').run(owner, r.kind, r.target, r.description, ctx.now().getTime());
|
|
40
40
|
const row = d.prepare('SELECT * FROM personal_monitors WHERE owner = ? AND kind = ? AND target = ?').get(owner, r.kind, r.target);
|
|
@@ -54,7 +54,17 @@ export function personalAlerts(ctx, owner, limit = 50) {
|
|
|
54
54
|
export async function runPersonal(ctx, opts = {}) {
|
|
55
55
|
const d = db(ctx);
|
|
56
56
|
const now = ctx.now().getTime();
|
|
57
|
-
|
|
57
|
+
// Monitors of OCULON holders (a signed-in wallet with enough tokens) are checked every ~15 minutes instead of hourly.
|
|
58
|
+
let holderSql = '';
|
|
59
|
+
try {
|
|
60
|
+
d.prepare('SELECT 1 FROM holder_sessions LIMIT 1').get();
|
|
61
|
+
holderSql = ' OR (last_run <= ? AND owner IN (SELECT owner FROM holder_sessions WHERE expires_at > ?))';
|
|
62
|
+
}
|
|
63
|
+
catch { /* no holder table yet */ }
|
|
64
|
+
const args = [now - (opts.everyMs ?? 55 * 60_000)];
|
|
65
|
+
if (holderSql)
|
|
66
|
+
args.push(now - 14 * 60_000, now);
|
|
67
|
+
const rows = d.prepare(`SELECT * FROM personal_monitors WHERE last_run IS NULL OR last_run <= ?${holderSql} ORDER BY COALESCE(last_run, 0) LIMIT ?`).all(...args, opts.max ?? 60);
|
|
58
68
|
const out = [];
|
|
59
69
|
for (const r of rows) {
|
|
60
70
|
const item = { id: r.id, kind: r.kind, target: r.target, label: r.description, createdAt: new Date(r.created_at).toISOString(), lastRun: r.last_run ? new Date(r.last_run).toISOString() : null };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { Ctx } from '../core/context.js';
|
|
2
|
+
import type { Oculon } from '../index.js';
|
|
3
|
+
import { type Rpc } from '../web/burns.js';
|
|
4
|
+
export declare const UTILITY: {
|
|
5
|
+
readonly investigate: 1500000n;
|
|
6
|
+
readonly safety: 2000000n;
|
|
7
|
+
readonly holder: 3500000n;
|
|
8
|
+
readonly safetyDays: 30;
|
|
9
|
+
readonly holderMonitors: 30;
|
|
10
|
+
readonly sessionDays: 7;
|
|
11
|
+
};
|
|
12
|
+
/** Burns before the utility went live (buyback burns, for example) do not count. */
|
|
13
|
+
export declare const UTILITY_START: number;
|
|
14
|
+
/** What the burning wallet signs, so only the wallet that burned can spend its burn. */
|
|
15
|
+
export declare function utilityMessage(kind: 'investigate' | 'safety', target: string, tx: string): string;
|
|
16
|
+
export interface TokenConfig {
|
|
17
|
+
ca: string;
|
|
18
|
+
txBase: string | null;
|
|
19
|
+
}
|
|
20
|
+
export declare function tokenConfig(): TokenConfig | null;
|
|
21
|
+
/** Tests replace the chain with a stub. */
|
|
22
|
+
export declare function setUtilityRpc(r: Rpc | null): void;
|
|
23
|
+
export interface Burn {
|
|
24
|
+
tx: string;
|
|
25
|
+
from: string;
|
|
26
|
+
amount: string;
|
|
27
|
+
raw: string;
|
|
28
|
+
block: number;
|
|
29
|
+
time: string;
|
|
30
|
+
}
|
|
31
|
+
/** Confirms that `tx` burned at least `min` whole OCULON and has not been used before. Throws a readable error otherwise. */
|
|
32
|
+
export declare function verifyBurn(ctx: Ctx, txInput: string, min: bigint): Promise<Burn>;
|
|
33
|
+
export interface InvestigationPart {
|
|
34
|
+
title: string;
|
|
35
|
+
ok: boolean;
|
|
36
|
+
verdict: string | null;
|
|
37
|
+
lines: string[];
|
|
38
|
+
error?: string;
|
|
39
|
+
sources: string[];
|
|
40
|
+
}
|
|
41
|
+
export interface Investigation {
|
|
42
|
+
id: string;
|
|
43
|
+
target: string;
|
|
44
|
+
kind: string;
|
|
45
|
+
status: 'running' | 'done';
|
|
46
|
+
burn: Burn | null;
|
|
47
|
+
parts: InvestigationPart[];
|
|
48
|
+
createdAt: string;
|
|
49
|
+
finishedAt: string | null;
|
|
50
|
+
}
|
|
51
|
+
export declare function targetKind(t: string): 'evm' | 'crypto' | 'domain' | 'name';
|
|
52
|
+
/** A few readable lines out of any module result: its verdict, then its reasons, warnings or flags. */
|
|
53
|
+
export declare function summarize(title: string, r: {
|
|
54
|
+
result: unknown;
|
|
55
|
+
provenance: {
|
|
56
|
+
source: string;
|
|
57
|
+
status: string;
|
|
58
|
+
}[];
|
|
59
|
+
}): InvestigationPart;
|
|
60
|
+
export declare function runInvestigation(o: Oculon, target: string): Promise<InvestigationPart[]>;
|
|
61
|
+
export declare function startInvestigation(o: Oculon, tx: string, targetInput: string, signature: string): Promise<{
|
|
62
|
+
id: string;
|
|
63
|
+
burn: Burn;
|
|
64
|
+
}>;
|
|
65
|
+
export declare function getInvestigation(ctx: Ctx, id: string): Investigation | null;
|
|
66
|
+
export declare function listInvestigations(ctx: Ctx, limit?: number): {
|
|
67
|
+
id: string;
|
|
68
|
+
target: string;
|
|
69
|
+
status: string;
|
|
70
|
+
createdAt: string;
|
|
71
|
+
}[];
|
|
72
|
+
export interface SafetyState {
|
|
73
|
+
token: string;
|
|
74
|
+
active: boolean;
|
|
75
|
+
expiresAt: string | null;
|
|
76
|
+
verdict: string | null;
|
|
77
|
+
reasons: string[];
|
|
78
|
+
name: string | null;
|
|
79
|
+
symbol: string | null;
|
|
80
|
+
lastCheck: string | null;
|
|
81
|
+
history: {
|
|
82
|
+
at: string;
|
|
83
|
+
verdict: string;
|
|
84
|
+
}[];
|
|
85
|
+
}
|
|
86
|
+
export declare function checkSafety(o: Oculon, token: string): Promise<SafetyState>;
|
|
87
|
+
export declare function startSafety(o: Oculon, tx: string, tokenInput: string, signature: string): Promise<{
|
|
88
|
+
state: SafetyState;
|
|
89
|
+
burn: Burn;
|
|
90
|
+
}>;
|
|
91
|
+
export declare function safetyState(ctx: Ctx, token: string): SafetyState;
|
|
92
|
+
/** Re-checks every active monitor not checked in the last `everyMs` (default 14 minutes). Returns verdict changes. */
|
|
93
|
+
export declare function runSafety(o: Oculon, everyMs?: number): Promise<{
|
|
94
|
+
token: string;
|
|
95
|
+
from: string | null;
|
|
96
|
+
to: string;
|
|
97
|
+
}[]>;
|
|
98
|
+
/** A shields-style SVG badge with the live verdict, or "not monitored". */
|
|
99
|
+
export declare function badgeSvg(s: SafetyState): string;
|
|
100
|
+
export declare function holderMessage(domain: string, address: string, nonce: string, issuedAt: string): string;
|
|
101
|
+
export declare function createNonce(domain: string, addressInput: string, now?: number): {
|
|
102
|
+
message: string;
|
|
103
|
+
nonce: string;
|
|
104
|
+
};
|
|
105
|
+
export declare function balanceOf(address: string): Promise<bigint>;
|
|
106
|
+
export interface HolderSession {
|
|
107
|
+
key: string | null;
|
|
108
|
+
address: string;
|
|
109
|
+
balance: string;
|
|
110
|
+
holder: boolean;
|
|
111
|
+
expiresAt: string | null;
|
|
112
|
+
needs: string;
|
|
113
|
+
}
|
|
114
|
+
export declare function verifyHolder(ctx: Ctx, owner: string, message: string, signature: string): Promise<HolderSession>;
|
|
115
|
+
/** The holder session behind an owner (web visitor), if any is still valid. */
|
|
116
|
+
export declare function holderFor(ctx: Ctx, owner: string): {
|
|
117
|
+
address: string;
|
|
118
|
+
expiresAt: string;
|
|
119
|
+
} | null;
|
|
120
|
+
export declare function holderOwners(ctx: Ctx): Set<string>;
|
|
121
|
+
export declare function signOutHolder(ctx: Ctx, owner: string): void;
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* $OCULON utility, read straight from Robinhood Chain: nothing is custodied, nothing is paid to anyone.
|
|
3
|
+
* A. Burn-to-Investigate: burn 1,500,000 OCULON, get a deep investigation of one domain, wallet, token or
|
|
4
|
+
* company, published as a public page that links the burn transaction.
|
|
5
|
+
* B. Live Safety Badge: burn 2,000,000 OCULON, and Oculon watches one Robinhood Chain token for 30 days.
|
|
6
|
+
* The badge shows the live verdict. Burning buys monitoring, never a better verdict.
|
|
7
|
+
* C. Holder tier: sign a message with a wallet that holds 3,500,000 OCULON (no account, no email) and get
|
|
8
|
+
* more personal monitors, checked every 15 minutes instead of every hour.
|
|
9
|
+
* A burn is a transfer of OCULON to the dead or zero address, confirmed on chain; each transaction counts once.
|
|
10
|
+
*/
|
|
11
|
+
import { randomBytes } from 'node:crypto';
|
|
12
|
+
import { readFileSync } from 'node:fs';
|
|
13
|
+
import { dirname, join } from 'node:path';
|
|
14
|
+
import { fileURLToPath } from 'node:url';
|
|
15
|
+
import { recoverPersonalSigner } from '../core/evm.js';
|
|
16
|
+
import { formatUnits, rpcClient } from '../web/burns.js';
|
|
17
|
+
export const UTILITY = { investigate: 1500000n, safety: 2000000n, holder: 3500000n, safetyDays: 30, holderMonitors: 30, sessionDays: 7 };
|
|
18
|
+
/** Burns before the utility went live (buyback burns, for example) do not count. */
|
|
19
|
+
export const UTILITY_START = Date.parse('2026-11-26T00:00:00Z');
|
|
20
|
+
/** What the burning wallet signs, so only the wallet that burned can spend its burn. */
|
|
21
|
+
export function utilityMessage(kind, target, tx) {
|
|
22
|
+
return `Oculon ${kind === 'investigate' ? 'investigation' : 'safety badge'}\nTarget: ${target.trim()}\nBurn: ${tx.trim().toLowerCase()}`;
|
|
23
|
+
}
|
|
24
|
+
function checkSigner(kind, target, burn, signature) {
|
|
25
|
+
const signer = recoverPersonalSigner(utilityMessage(kind, target, burn.tx), signature);
|
|
26
|
+
if (!signer)
|
|
27
|
+
throw new Error('sign the request with the wallet that made the burn');
|
|
28
|
+
if (signer !== burn.from)
|
|
29
|
+
throw new Error('the signature is not from the wallet that made this burn');
|
|
30
|
+
}
|
|
31
|
+
const E18 = 10n ** 18n;
|
|
32
|
+
const TRANSFER = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef';
|
|
33
|
+
const BURN_TO = new Set(['0x000000000000000000000000000000000000dead', '0x0000000000000000000000000000000000000000']);
|
|
34
|
+
const DEFAULT_RPC = 'https://rpc.mainnet.chain.robinhood.com';
|
|
35
|
+
export function tokenConfig() {
|
|
36
|
+
try {
|
|
37
|
+
const t = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'web', 'token.json'), 'utf8'));
|
|
38
|
+
return t.ca && /^0x[0-9a-fA-F]{40}$/.test(t.ca) ? { ca: t.ca.toLowerCase(), txBase: t.txBase ?? null } : null;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
let rpcOverride = null;
|
|
45
|
+
/** Tests replace the chain with a stub. */
|
|
46
|
+
export function setUtilityRpc(r) { rpcOverride = r; }
|
|
47
|
+
const rpc = () => rpcOverride ?? rpcClient(process.env.ROBINHOOD_PUBLIC_RPC_URL?.trim() || DEFAULT_RPC);
|
|
48
|
+
function db(ctx) {
|
|
49
|
+
const d = ctx.store.db;
|
|
50
|
+
d.exec(`CREATE TABLE IF NOT EXISTS utility_burns (tx TEXT PRIMARY KEY, kind TEXT NOT NULL, target TEXT NOT NULL, from_addr TEXT NOT NULL, amount TEXT NOT NULL, block INTEGER, burned_at TEXT, created_at INTEGER NOT NULL);
|
|
51
|
+
CREATE TABLE IF NOT EXISTS investigations (id TEXT PRIMARY KEY, tx TEXT NOT NULL, target TEXT NOT NULL, status TEXT NOT NULL, result TEXT, created_at INTEGER NOT NULL, finished_at INTEGER);
|
|
52
|
+
CREATE TABLE IF NOT EXISTS safety_monitors (token TEXT PRIMARY KEY, expires_at INTEGER NOT NULL, created_at INTEGER NOT NULL, last_check INTEGER, verdict TEXT, reasons TEXT, name TEXT, symbol TEXT);
|
|
53
|
+
CREATE TABLE IF NOT EXISTS safety_checks (token TEXT NOT NULL, at INTEGER NOT NULL, verdict TEXT NOT NULL, reasons TEXT NOT NULL);
|
|
54
|
+
CREATE TABLE IF NOT EXISTS holder_sessions (key TEXT PRIMARY KEY, owner TEXT NOT NULL, address TEXT NOT NULL, balance TEXT NOT NULL, expires_at INTEGER NOT NULL, created_at INTEGER NOT NULL);`);
|
|
55
|
+
return d;
|
|
56
|
+
}
|
|
57
|
+
/** Confirms that `tx` burned at least `min` whole OCULON and has not been used before. Throws a readable error otherwise. */
|
|
58
|
+
export async function verifyBurn(ctx, txInput, min) {
|
|
59
|
+
const tx = txInput.trim().toLowerCase();
|
|
60
|
+
if (!/^0x[0-9a-f]{64}$/.test(tx))
|
|
61
|
+
throw new Error('give the burn transaction hash: 0x followed by 64 hex characters');
|
|
62
|
+
const cfg = tokenConfig();
|
|
63
|
+
if (!cfg)
|
|
64
|
+
throw new Error('the official token address is not configured on this install');
|
|
65
|
+
const used = db(ctx).prepare('SELECT kind FROM utility_burns WHERE tx = ?').get(tx);
|
|
66
|
+
if (used)
|
|
67
|
+
throw new Error(`this burn was already used for ${used.kind === 'investigate' ? 'an investigation' : used.kind === 'safety' ? 'a safety badge' : used.kind}`);
|
|
68
|
+
const r = rpc();
|
|
69
|
+
const receipt = await r('eth_getTransactionReceipt', [tx]);
|
|
70
|
+
if (!receipt)
|
|
71
|
+
throw new Error('transaction not found yet: wait until it is confirmed, then try again');
|
|
72
|
+
if (receipt.status !== '0x1')
|
|
73
|
+
throw new Error('this transaction failed on chain, so nothing was burned');
|
|
74
|
+
let raw = 0n;
|
|
75
|
+
let from = receipt.from.toLowerCase();
|
|
76
|
+
for (const l of receipt.logs) {
|
|
77
|
+
if (l.address.toLowerCase() !== cfg.ca || l.topics[0] !== TRANSFER || l.topics.length < 3)
|
|
78
|
+
continue;
|
|
79
|
+
const to = `0x${l.topics[2].slice(26)}`.toLowerCase();
|
|
80
|
+
if (!BURN_TO.has(to))
|
|
81
|
+
continue;
|
|
82
|
+
raw += BigInt(l.data);
|
|
83
|
+
from = `0x${l.topics[1].slice(26)}`.toLowerCase();
|
|
84
|
+
}
|
|
85
|
+
if (raw === 0n)
|
|
86
|
+
throw new Error('no OCULON was sent to the burn address in this transaction');
|
|
87
|
+
if (raw < min * E18)
|
|
88
|
+
throw new Error(`this burn is ${formatUnits(raw, 18)} OCULON; it needs at least ${min.toLocaleString('en-US')}`);
|
|
89
|
+
const blk = await r('eth_getBlockByNumber', [receipt.blockNumber, false]);
|
|
90
|
+
if (Number(BigInt(blk.timestamp)) * 1000 < UTILITY_START)
|
|
91
|
+
throw new Error('this burn happened before the utility went live, so it cannot be used');
|
|
92
|
+
return { tx, from, amount: formatUnits(raw, 18), raw: raw.toString(), block: Number(BigInt(receipt.blockNumber)), time: new Date(Number(BigInt(blk.timestamp)) * 1000).toISOString() };
|
|
93
|
+
}
|
|
94
|
+
function recordBurn(ctx, kind, target, b) {
|
|
95
|
+
db(ctx).prepare('INSERT INTO utility_burns (tx, kind, target, from_addr, amount, block, burned_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)').run(b.tx, kind, target, b.from, b.amount, b.block, b.time, ctx.now().getTime());
|
|
96
|
+
}
|
|
97
|
+
export function targetKind(t) {
|
|
98
|
+
if (/^0x[0-9a-fA-F]{40}$/.test(t))
|
|
99
|
+
return 'evm';
|
|
100
|
+
if (/^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,62}$/.test(t) || /^T[1-9A-HJ-NP-Za-km-z]{33}$/.test(t) || /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(t))
|
|
101
|
+
return 'crypto';
|
|
102
|
+
if (/^(https?:\/\/)?([a-z0-9-]+\.)+[a-z]{2,}(\/.*)?$/i.test(t))
|
|
103
|
+
return 'domain';
|
|
104
|
+
return 'name';
|
|
105
|
+
}
|
|
106
|
+
/** A few readable lines out of any module result: its verdict, then its reasons, warnings or flags. */
|
|
107
|
+
export function summarize(title, r) {
|
|
108
|
+
const x = r.result;
|
|
109
|
+
const verdict = ['verdict', 'risk'].map((k) => x?.[k]).find((v) => typeof v === 'string' || typeof v === 'number');
|
|
110
|
+
const lines = [];
|
|
111
|
+
for (const k of ['reasons', 'warnings', 'flags', 'problems', 'fixes']) {
|
|
112
|
+
const v = x?.[k];
|
|
113
|
+
if (Array.isArray(v))
|
|
114
|
+
lines.push(...v.filter((s) => typeof s === 'string').slice(0, 8));
|
|
115
|
+
}
|
|
116
|
+
if (Array.isArray(x?.live))
|
|
117
|
+
lines.push(...x.live.slice(0, 12).map((l) => `lookalike live: ${l.domain} (${l.kind})`));
|
|
118
|
+
if (Array.isArray(x?.breaches))
|
|
119
|
+
lines.push(...x.breaches.slice(0, 6).map((b) => `breach: ${b.title}, ${b.accounts.toLocaleString('en-US')} accounts, ${b.breachDate}`));
|
|
120
|
+
if (Array.isArray(x?.victims))
|
|
121
|
+
lines.push(...x.victims.slice(0, 6).map((v) => `ransomware claim: ${v.group} lists ${v.victim}${v.discovered ? ` (${v.discovered.slice(0, 10)})` : ''}`));
|
|
122
|
+
if (typeof x?.score === 'number' && !verdict)
|
|
123
|
+
lines.unshift(`score ${x.score}`);
|
|
124
|
+
return { title, ok: true, verdict: verdict === undefined ? null : String(verdict), lines: lines.slice(0, 16), sources: r.provenance.map((p) => `${p.source} ${p.status.toLowerCase()}`) };
|
|
125
|
+
}
|
|
126
|
+
async function part(title, f) {
|
|
127
|
+
try {
|
|
128
|
+
return summarize(title, await f());
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
return { title, ok: false, verdict: null, lines: [], error: e.message.slice(0, 200), sources: [] };
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export async function runInvestigation(o, target) {
|
|
135
|
+
const kind = targetKind(target);
|
|
136
|
+
if (kind === 'evm') {
|
|
137
|
+
return Promise.all([
|
|
138
|
+
part('Robinhood Chain token', () => o.robinhoodToken(target)),
|
|
139
|
+
part('Deployer history', () => o.robinhoodDeployer(target)),
|
|
140
|
+
part('Address on Robinhood Chain', () => o.addressCheck(target, { network: 'robinhood' })),
|
|
141
|
+
part('Address on Ethereum', () => o.addressCheck(target)),
|
|
142
|
+
]);
|
|
143
|
+
}
|
|
144
|
+
if (kind === 'crypto')
|
|
145
|
+
return Promise.all([part('Address', () => o.addressCheck(target))]);
|
|
146
|
+
if (kind === 'domain') {
|
|
147
|
+
const d = target.replace(/^https?:\/\//, '').replace(/\/.*$/, '').toLowerCase();
|
|
148
|
+
return Promise.all([
|
|
149
|
+
part('Link safety', () => o.urlCheck(`https://${d}`)),
|
|
150
|
+
part('Lookalike domains', () => o.lookalikes(d)),
|
|
151
|
+
part('Email spoofing protection', () => o.emailSecurity(d)),
|
|
152
|
+
part('Data breaches', () => o.breaches(d)),
|
|
153
|
+
part('Ransomware claims', () => o.ransomware(d.split('.')[0].length >= 3 ? d.split('.')[0] : d)),
|
|
154
|
+
]);
|
|
155
|
+
}
|
|
156
|
+
return Promise.all([
|
|
157
|
+
part('Company registers', () => o.companyCheck(target)),
|
|
158
|
+
part('Ransomware claims', () => o.ransomware(target)),
|
|
159
|
+
part('Scam patterns in the name', () => o.scamCheck(target)),
|
|
160
|
+
]);
|
|
161
|
+
}
|
|
162
|
+
export async function startInvestigation(o, tx, targetInput, signature) {
|
|
163
|
+
const target = targetInput.trim().slice(0, 200);
|
|
164
|
+
if (target.length < 3)
|
|
165
|
+
throw new Error('give what to investigate: a domain, a wallet or token address, or a company name');
|
|
166
|
+
const burn = await verifyBurn(o.ctx, tx, UTILITY.investigate);
|
|
167
|
+
checkSigner('investigate', target, burn, signature);
|
|
168
|
+
const id = randomBytes(6).toString('hex');
|
|
169
|
+
const d = db(o.ctx);
|
|
170
|
+
recordBurn(o.ctx, 'investigate', target, burn);
|
|
171
|
+
d.prepare('INSERT INTO investigations (id, tx, target, status, created_at) VALUES (?, ?, ?, ?, ?)').run(id, burn.tx, target, 'running', o.ctx.now().getTime());
|
|
172
|
+
void runInvestigation(o, target).then((parts) => {
|
|
173
|
+
d.prepare('UPDATE investigations SET status = ?, result = ?, finished_at = ? WHERE id = ?').run('done', JSON.stringify(parts), Date.now(), id);
|
|
174
|
+
}).catch((e) => {
|
|
175
|
+
d.prepare('UPDATE investigations SET status = ?, result = ?, finished_at = ? WHERE id = ?').run('done', JSON.stringify([{ title: 'Investigation', ok: false, verdict: null, lines: [], error: String(e.message), sources: [] }]), Date.now(), id);
|
|
176
|
+
});
|
|
177
|
+
return { id, burn };
|
|
178
|
+
}
|
|
179
|
+
export function getInvestigation(ctx, id) {
|
|
180
|
+
if (!/^[0-9a-f]{12}$/.test(id))
|
|
181
|
+
return null;
|
|
182
|
+
const row = db(ctx).prepare('SELECT i.*, b.from_addr, b.amount, b.raw, b.block, b.burned_at FROM investigations i LEFT JOIN (SELECT tx, from_addr, amount, amount AS raw, block, burned_at FROM utility_burns) b ON b.tx = i.tx WHERE i.id = ?').get(id);
|
|
183
|
+
if (!row)
|
|
184
|
+
return null;
|
|
185
|
+
return {
|
|
186
|
+
id, target: String(row.target), kind: targetKind(String(row.target)), status: row.status,
|
|
187
|
+
burn: row.from_addr ? { tx: String(row.tx), from: String(row.from_addr), amount: String(row.amount), raw: '', block: Number(row.block), time: String(row.burned_at) } : null,
|
|
188
|
+
parts: row.result ? JSON.parse(String(row.result)) : [],
|
|
189
|
+
createdAt: new Date(Number(row.created_at)).toISOString(), finishedAt: row.finished_at ? new Date(Number(row.finished_at)).toISOString() : null,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
export function listInvestigations(ctx, limit = 20) {
|
|
193
|
+
return db(ctx).prepare('SELECT id, target, status, created_at FROM investigations ORDER BY created_at DESC LIMIT ?').all(limit).map((r) => ({ id: r.id, target: r.target, status: r.status, createdAt: new Date(r.created_at).toISOString() }));
|
|
194
|
+
}
|
|
195
|
+
export async function checkSafety(o, token) {
|
|
196
|
+
const t = token.toLowerCase();
|
|
197
|
+
const r = await o.robinhoodToken(t);
|
|
198
|
+
const now = o.ctx.now().getTime();
|
|
199
|
+
const d = db(o.ctx);
|
|
200
|
+
d.prepare('UPDATE safety_monitors SET last_check = ?, verdict = ?, reasons = ?, name = ?, symbol = ? WHERE token = ?').run(now, r.result.verdict, JSON.stringify(r.result.reasons), r.result.name, r.result.symbol, t);
|
|
201
|
+
const last = d.prepare('SELECT verdict FROM safety_checks WHERE token = ? ORDER BY at DESC LIMIT 1').get(t);
|
|
202
|
+
if (!last || last.verdict !== r.result.verdict)
|
|
203
|
+
d.prepare('INSERT INTO safety_checks (token, at, verdict, reasons) VALUES (?, ?, ?, ?)').run(t, now, r.result.verdict, JSON.stringify(r.result.reasons));
|
|
204
|
+
return safetyState(o.ctx, t);
|
|
205
|
+
}
|
|
206
|
+
export async function startSafety(o, tx, tokenInput, signature) {
|
|
207
|
+
const token = tokenInput.trim().toLowerCase();
|
|
208
|
+
if (!/^0x[0-9a-f]{40}$/.test(token))
|
|
209
|
+
throw new Error('give the Robinhood Chain token address to monitor: 0x followed by 40 hex characters');
|
|
210
|
+
const burn = await verifyBurn(o.ctx, tx, UTILITY.safety);
|
|
211
|
+
checkSigner('safety', token, burn, signature);
|
|
212
|
+
const d = db(o.ctx);
|
|
213
|
+
const now = o.ctx.now().getTime();
|
|
214
|
+
const cur = d.prepare('SELECT expires_at FROM safety_monitors WHERE token = ?').get(token);
|
|
215
|
+
const start = cur && cur.expires_at > now ? cur.expires_at : now;
|
|
216
|
+
const expires = start + UTILITY.safetyDays * 86_400_000;
|
|
217
|
+
recordBurn(o.ctx, 'safety', token, burn);
|
|
218
|
+
d.prepare('INSERT INTO safety_monitors (token, expires_at, created_at) VALUES (?, ?, ?) ON CONFLICT(token) DO UPDATE SET expires_at = excluded.expires_at').run(token, expires, now);
|
|
219
|
+
const state = await checkSafety(o, token).catch(() => safetyState(o.ctx, token));
|
|
220
|
+
return { state, burn };
|
|
221
|
+
}
|
|
222
|
+
export function safetyState(ctx, token) {
|
|
223
|
+
const t = token.toLowerCase();
|
|
224
|
+
const d = db(ctx);
|
|
225
|
+
const m = d.prepare('SELECT * FROM safety_monitors WHERE token = ?').get(t);
|
|
226
|
+
const hist = d.prepare('SELECT at, verdict FROM safety_checks WHERE token = ? ORDER BY at DESC LIMIT 30').all(t).map((h) => ({ at: new Date(h.at).toISOString(), verdict: h.verdict }));
|
|
227
|
+
return { token: t, active: !!m && m.expires_at > ctx.now().getTime(), expiresAt: m ? new Date(m.expires_at).toISOString() : null, verdict: m?.verdict ?? null, reasons: m?.reasons ? JSON.parse(m.reasons) : [], name: m?.name ?? null, symbol: m?.symbol ?? null, lastCheck: m?.last_check ? new Date(m.last_check).toISOString() : null, history: hist };
|
|
228
|
+
}
|
|
229
|
+
/** Re-checks every active monitor not checked in the last `everyMs` (default 14 minutes). Returns verdict changes. */
|
|
230
|
+
export async function runSafety(o, everyMs = 14 * 60_000) {
|
|
231
|
+
const now = o.ctx.now().getTime();
|
|
232
|
+
const rows = db(o.ctx).prepare('SELECT token, verdict FROM safety_monitors WHERE expires_at > ? AND (last_check IS NULL OR last_check <= ?)').all(now, now - everyMs);
|
|
233
|
+
const changes = [];
|
|
234
|
+
for (const r of rows) {
|
|
235
|
+
try {
|
|
236
|
+
const s = await checkSafety(o, r.token);
|
|
237
|
+
if (s.verdict && s.verdict !== r.verdict)
|
|
238
|
+
changes.push({ token: r.token, from: r.verdict, to: s.verdict });
|
|
239
|
+
}
|
|
240
|
+
catch { /* next round */ }
|
|
241
|
+
}
|
|
242
|
+
return changes;
|
|
243
|
+
}
|
|
244
|
+
const esc = (s) => s.replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
245
|
+
/** A shields-style SVG badge with the live verdict, or "not monitored". */
|
|
246
|
+
export function badgeSvg(s) {
|
|
247
|
+
const v = s.active ? s.verdict ?? 'CHECKING' : 'NOT MONITORED';
|
|
248
|
+
const color = !s.active ? '#5d676b' : v === 'OK' ? '#2ea36b' : v === 'CAUTION' ? '#c98a12' : v === 'DANGER' ? '#d23b4a' : '#5d676b';
|
|
249
|
+
const left = 'Oculon safety', lw = 96, rw = Math.max(64, Math.ceil(v.length * 8.2 + 22));
|
|
250
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${lw + rw}" height="22" role="img" aria-label="${left}: ${esc(v)}"><title>${left}: ${esc(v)}</title><rect width="${lw}" height="22" fill="#0b1013"/><rect x="${lw}" width="${rw}" height="22" fill="${color}"/><g fill="#fff" font-family="Verdana,DejaVu Sans,sans-serif" font-size="11"><text x="9" y="15" fill="#00f0ff">${left}</text><text x="${lw + 9}" y="15" font-weight="bold">${esc(v)}</text></g></svg>`;
|
|
251
|
+
}
|
|
252
|
+
// ---------- C. Holder tier ----------
|
|
253
|
+
const nonces = new Map();
|
|
254
|
+
export function holderMessage(domain, address, nonce, issuedAt) {
|
|
255
|
+
return `${domain} wants you to sign in with your wallet:\n${address}\n\nSign in to Oculon to check your OCULON holder tier. This does not send a transaction or cost anything.\n\nNonce: ${nonce}\nIssued At: ${issuedAt}`;
|
|
256
|
+
}
|
|
257
|
+
export function createNonce(domain, addressInput, now = Date.now()) {
|
|
258
|
+
const address = addressInput.trim().toLowerCase();
|
|
259
|
+
if (!/^0x[0-9a-f]{40}$/.test(address))
|
|
260
|
+
throw new Error('give the wallet address you will sign with');
|
|
261
|
+
for (const [k, v] of nonces)
|
|
262
|
+
if (v.exp < now)
|
|
263
|
+
nonces.delete(k);
|
|
264
|
+
if (nonces.size > 5000)
|
|
265
|
+
throw new Error('too many sign-in attempts right now, try again in a minute');
|
|
266
|
+
const nonce = randomBytes(12).toString('hex');
|
|
267
|
+
nonces.set(nonce, { address, exp: now + 10 * 60_000 });
|
|
268
|
+
return { nonce, message: holderMessage(domain, address, nonce, new Date(now).toISOString()) };
|
|
269
|
+
}
|
|
270
|
+
export async function balanceOf(address) {
|
|
271
|
+
const cfg = tokenConfig();
|
|
272
|
+
if (!cfg)
|
|
273
|
+
throw new Error('the official token address is not configured on this install');
|
|
274
|
+
const hex = await rpc()('eth_call', [{ to: cfg.ca, data: `0x70a08231${address.slice(2).toLowerCase().padStart(64, '0')}` }, 'latest']);
|
|
275
|
+
return BigInt(hex);
|
|
276
|
+
}
|
|
277
|
+
export async function verifyHolder(ctx, owner, message, signature) {
|
|
278
|
+
const nonce = /Nonce: ([0-9a-f]{24})/.exec(message)?.[1];
|
|
279
|
+
const entry = nonce ? nonces.get(nonce) : undefined;
|
|
280
|
+
if (!nonce || !entry || entry.exp < Date.now())
|
|
281
|
+
throw new Error('this sign-in request expired; start again');
|
|
282
|
+
const signer = recoverPersonalSigner(message, signature);
|
|
283
|
+
if (!signer || signer !== entry.address || !message.includes(entry.address))
|
|
284
|
+
throw new Error('the signature does not match the wallet address');
|
|
285
|
+
nonces.delete(nonce);
|
|
286
|
+
const raw = await balanceOf(signer);
|
|
287
|
+
const balance = formatUnits(raw, 18);
|
|
288
|
+
const needs = `${UTILITY.holder.toLocaleString('en-US')} OCULON`;
|
|
289
|
+
if (raw < UTILITY.holder * E18)
|
|
290
|
+
return { key: null, address: signer, balance, holder: false, expiresAt: null, needs };
|
|
291
|
+
const key = randomBytes(24).toString('hex');
|
|
292
|
+
const exp = ctx.now().getTime() + UTILITY.sessionDays * 86_400_000;
|
|
293
|
+
db(ctx).prepare('INSERT INTO holder_sessions (key, owner, address, balance, expires_at, created_at) VALUES (?, ?, ?, ?, ?, ?)').run(key, owner, signer, raw.toString(), exp, ctx.now().getTime());
|
|
294
|
+
return { key, address: signer, balance, holder: true, expiresAt: new Date(exp).toISOString(), needs };
|
|
295
|
+
}
|
|
296
|
+
/** The holder session behind an owner (web visitor), if any is still valid. */
|
|
297
|
+
export function holderFor(ctx, owner) {
|
|
298
|
+
const r = db(ctx).prepare('SELECT address, expires_at FROM holder_sessions WHERE owner = ? AND expires_at > ? ORDER BY expires_at DESC LIMIT 1').get(owner, ctx.now().getTime());
|
|
299
|
+
return r ? { address: r.address, expiresAt: new Date(r.expires_at).toISOString() } : null;
|
|
300
|
+
}
|
|
301
|
+
export function holderOwners(ctx) {
|
|
302
|
+
return new Set(db(ctx).prepare('SELECT DISTINCT owner FROM holder_sessions WHERE expires_at > ?').all(ctx.now().getTime()).map((r) => r.owner));
|
|
303
|
+
}
|
|
304
|
+
export function signOutHolder(ctx, owner) {
|
|
305
|
+
db(ctx).prepare('DELETE FROM holder_sessions WHERE owner = ?').run(owner);
|
|
306
|
+
}
|
package/dist/telegram.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export interface BotOptions {
|
|
|
10
10
|
alertMinScore?: number;
|
|
11
11
|
/** Minutes between background scans for alerts; 0 disables. */
|
|
12
12
|
watchMinutes?: number;
|
|
13
|
+
/** Minutes between the scans of a host process (oculon serve --watch) that feeds this bot's alerts. */
|
|
14
|
+
scheduleMinutes?: number;
|
|
13
15
|
/** Anyone may use the public commands (rate limited); allowlisted chats keep every command. Default OCULON_TELEGRAM_PUBLIC=1. */
|
|
14
16
|
publicMode?: boolean;
|
|
15
17
|
log?: (m: string) => void;
|
package/dist/telegram.js
CHANGED
|
@@ -21,9 +21,9 @@ export function formatSignal(s) {
|
|
|
21
21
|
return `<b>[${Math.round(s.score)}] ${esc(s.title)}</b> <code>${esc(s.module)}</code>${ev ? `\n${ev}` : ''}`;
|
|
22
22
|
}
|
|
23
23
|
/** Commands anyone may use when the bot is public. Everything else stays with the allowlisted chats. */
|
|
24
|
-
export const PUBLIC_COMMANDS = new Set(['/start', '/help', '/scam', '/url', '/factcheck', '/recall', '/email', '/travel', '/airport', '/country', '/papers', '/audit', '/monitor', '/monitors', '/unmonitor', '/cve', '/vulns', '/hazards', '/blackout', '/cloud', '/space', '/air', '/radar', '/signals', '/alerts', '/ask', '/ip', '/hash', '/ransomware', '/company', '/breaches', '/phone', '/satellite']);
|
|
24
|
+
export const PUBLIC_COMMANDS = new Set(['/start', '/help', '/scam', '/url', '/factcheck', '/recall', '/email', '/travel', '/airport', '/country', '/papers', '/audit', '/monitor', '/monitors', '/unmonitor', '/cve', '/vulns', '/hazards', '/blackout', '/cloud', '/space', '/air', '/radar', '/signals', '/alerts', '/ask', '/ip', '/hash', '/ransomware', '/company', '/breaches', '/phone', '/satellite', '/iban', '/lookalike', '/honeypot', '/address', '/headers']);
|
|
25
25
|
/** Commands that start many upstream calls or an LLM get a tighter budget. */
|
|
26
|
-
const HEAVY = new Set(['/factcheck', '/papers', '/travel', '/country', '/ask', '/scam', '/audit', '/radar', '/ip', '/hash', '/company']);
|
|
26
|
+
const HEAVY = new Set(['/factcheck', '/papers', '/travel', '/country', '/ask', '/scam', '/audit', '/radar', '/ip', '/hash', '/company', '/lookalike', '/honeypot', '/address']);
|
|
27
27
|
export const PUBLIC_HELP = [
|
|
28
28
|
'<b>Oculon</b>: check anything, every answer sourced.',
|
|
29
29
|
'',
|
|
@@ -40,6 +40,11 @@ export const PUBLIC_HELP = [
|
|
|
40
40
|
'/papers <topic> — research brief',
|
|
41
41
|
'/audit <npm:name@ver ...> — dependency vulnerabilities',
|
|
42
42
|
'/phone <+number> — who is calling? premium-rate and callback-scam warnings',
|
|
43
|
+
'/iban <IBAN> — is this IBAN valid before you pay?',
|
|
44
|
+
'/headers <raw headers> — was this email spoofed? SPF, DKIM, DMARC, origin',
|
|
45
|
+
'/lookalike <domain> — lookalike domains and new certificates for a brand',
|
|
46
|
+
'/honeypot <token> [eth|bsc|base] — can this token be sold?',
|
|
47
|
+
'/address <crypto address> — sanctions, balance and activity',
|
|
43
48
|
'/company <name, LEI or EU VAT> — is this supplier real?',
|
|
44
49
|
'/breaches [domain] — newest data breaches, or one domain',
|
|
45
50
|
'/ip <address or domain> — abuse reports, scanners, Tor, threat reports',
|
|
@@ -68,7 +73,7 @@ export const HELP = [
|
|
|
68
73
|
'/monitor <request> — watch anything in plain words, e.g. /monitor internet outages in Iran',
|
|
69
74
|
'/recall <VIN, "2018 Honda Accord" or product> — vehicle and product recalls',
|
|
70
75
|
'/email <domain> — can someone spoof email from this domain?',
|
|
71
|
-
'/phone · /company · /breaches · /ip · /hash · /ransomware · /satellite — caller, supplier, breach and threat checks',
|
|
76
|
+
'/phone · /company · /iban · /headers · /breaches · /ip · /hash · /lookalike · /honeypot · /address · /ransomware · /satellite — caller, supplier, email, breach, crypto and threat checks',
|
|
72
77
|
'/airport <JFK|EGLL> — airport weather, delays and ground stops',
|
|
73
78
|
'/country <name> — economy, leaders, currency, travel advice, headlines',
|
|
74
79
|
'/papers <topic> — research brief: most cited and newest papers',
|
|
@@ -457,6 +462,37 @@ export class TelegramBot {
|
|
|
457
462
|
const items = d.breaches.slice(0, 8).map((b) => `• <b>${esc(b.title)}</b> <i>${esc(b.breachDate ?? '')} · ${b.accounts.toLocaleString('en-US')} accounts</i>`).join('\n');
|
|
458
463
|
return { html: `<b>${d.query ? `Breaches: ${esc(d.query)}` : 'Newest breaches'}</b>${d.query ? ` (${d.total})` : ''}\n${items || 'None found.'}\n<i>Source: Have I Been Pwned (CC BY 4.0)</i>` };
|
|
459
464
|
}
|
|
465
|
+
case '/iban': {
|
|
466
|
+
if (!arg)
|
|
467
|
+
return needArg('DE89 3704 0044 0532 0130 00');
|
|
468
|
+
const d = (await o.ibanCheck(arg)).result;
|
|
469
|
+
return { html: `<b>${esc(d.formatted ?? d.input)}</b>: <b>${d.valid ? 'VALID FORMAT' : 'NOT VALID'}</b>${d.countryName ? `\n${esc(d.countryName)}${d.bank ? ` · ${esc(d.bank.kind)} ${esc(d.bank.code)}` : ''}` : ''}${d.problems.map((p) => `\nx ${esc(p)}`).join('')}\n${esc(d.advice[0] ?? '')}` };
|
|
470
|
+
}
|
|
471
|
+
case '/headers': {
|
|
472
|
+
if (!arg)
|
|
473
|
+
return needArg('Received: ... (paste the raw headers from "Show original")');
|
|
474
|
+
const d = (await o.headerCheck(arg)).result;
|
|
475
|
+
return { html: `<b>${esc(d.from.address ?? 'unknown sender')}</b>: <b>${esc(d.verdict.toUpperCase())}</b> (risk ${d.risk}/100)\nSPF ${esc(d.auth.spf ?? '?')} · DKIM ${esc(d.auth.dkim ?? '?')} · DMARC ${esc(d.auth.dmarc ?? '?')}${d.origin.ip ? `\nsent from ${esc(d.origin.ip)}${d.origin.country ? ` · ${esc(d.origin.country)}` : ''}` : ''}${d.flags.slice(0, 5).map((f) => `\n! ${esc(f)}`).join('')}\n${esc(d.advice[0] ?? '')}` };
|
|
476
|
+
}
|
|
477
|
+
case '/lookalike': {
|
|
478
|
+
if (!arg)
|
|
479
|
+
return needArg('example.com');
|
|
480
|
+
const d = (await o.lookalikes(arg)).result;
|
|
481
|
+
return { html: `<b>${esc(d.domain)}</b>: <b>${d.risk.toUpperCase()} RISK</b>, ${d.live.length} of ${d.checked} lookalikes exist${d.live.slice(0, 10).map((l) => `\n${esc(l.domain)} · ${esc(l.kind)}${l.mx ? ' · mail' : ''}`).join('')}${d.certs.length ? `\n\nNew certificates: ${d.certs.slice(0, 5).map((c) => esc(c.name)).join(', ')}` : ''}` };
|
|
482
|
+
}
|
|
483
|
+
case '/honeypot': {
|
|
484
|
+
if (!arg)
|
|
485
|
+
return needArg('0x6982508145454Ce325dDbE47a25d4ec3d2311933 eth');
|
|
486
|
+
const [addr, chain] = arg.split(/\s+/);
|
|
487
|
+
const d = (await o.honeypotCheck(addr, chain ? { chain } : {})).result;
|
|
488
|
+
return { html: `<b>${esc(d.symbol ?? d.address)}</b> on ${esc(d.chain)}: <b>${esc(d.verdict.toUpperCase())}</b>\nbuy tax ${d.buyTax ?? '?'}% · sell tax ${d.sellTax ?? '?'}%${d.reasons.map((r) => `\n! ${esc(r)}`).join('')}\n${esc(d.advice[0] ?? '')}` };
|
|
489
|
+
}
|
|
490
|
+
case '/address': {
|
|
491
|
+
if (!arg)
|
|
492
|
+
return needArg('bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh');
|
|
493
|
+
const d = (await o.addressCheck(arg)).result;
|
|
494
|
+
return { html: `<b>${esc(d.address)}</b>: <b>${d.sanctioned ? 'SANCTIONED' : d.warnings.length ? 'CHECK FIRST' : 'NO RED FLAGS'}</b>\n${esc(d.format)}${d.activity ? `\n${esc([d.activity.label, d.activity.balance, d.activity.txCount !== null ? `${d.activity.txCount} transactions` : null].filter(Boolean).join(' · '))}` : ''}${d.warnings.map((w) => `\n! ${esc(w)}`).join('')}\n${esc(d.advice[0] ?? '')}` };
|
|
495
|
+
}
|
|
460
496
|
case '/phone': {
|
|
461
497
|
if (!arg)
|
|
462
498
|
return needArg('+1 876 555 0100');
|
|
@@ -799,7 +835,8 @@ export class TelegramBot {
|
|
|
799
835
|
db.prepare('INSERT OR IGNORE INTO telegram_subs (chat_id, created_at) VALUES (?, ?)').run(chatId, Date.now());
|
|
800
836
|
else
|
|
801
837
|
db.prepare('DELETE FROM telegram_subs WHERE chat_id = ?').run(chatId);
|
|
802
|
-
|
|
838
|
+
const every = this.opts.watchMinutes || this.opts.scheduleMinutes;
|
|
839
|
+
return { html: on ? `Alerts on: signals scoring ${this.opts.alertMinScore ?? 70}+ will be sent here${every ? ` (scan every ${every} min)` : ' when the bot runs with a watch interval'}.` : 'Alerts off.' };
|
|
803
840
|
}
|
|
804
841
|
default:
|
|
805
842
|
return { html: `Unknown command. ${helpHtml()}` };
|
|
@@ -911,12 +948,12 @@ export class TelegramBot {
|
|
|
911
948
|
const me = await this.call('getMe', {});
|
|
912
949
|
this.log(`bot @${me.username} running; ${this.opts.allowedChats.length} allowed chat(s)`);
|
|
913
950
|
if (this.isPublic) {
|
|
914
|
-
await this.call('setMyCommands', { commands: ['scam', 'url', 'factcheck', 'recall', 'email', 'phone', 'company', 'breaches', 'ip', 'hash', 'ransomware', 'travel', 'airport', 'country', 'papers', 'audit', 'monitor', 'monitors', 'unmonitor', 'cve', 'hazards', 'blackout', 'alerts', 'help'].map((c) => ({ command: c, description: `Oculon ${c}` })) }).catch(() => { });
|
|
951
|
+
await this.call('setMyCommands', { commands: ['scam', 'url', 'factcheck', 'recall', 'email', 'phone', 'company', 'iban', 'headers', 'breaches', 'ip', 'hash', 'lookalike', 'honeypot', 'address', 'ransomware', 'travel', 'airport', 'country', 'papers', 'audit', 'monitor', 'monitors', 'unmonitor', 'cve', 'hazards', 'blackout', 'alerts', 'help'].map((c) => ({ command: c, description: `Oculon ${c}` })) }).catch(() => { });
|
|
915
952
|
}
|
|
916
953
|
for (const chat of this.opts.allowedChats)
|
|
917
954
|
await this.call('setMyCommands', {
|
|
918
955
|
scope: { type: 'chat', chat_id: Number(chat) },
|
|
919
|
-
commands: ['ask', 'scam', 'monitors', 'unmonitor', 'url', 'factcheck', 'travel', 'audit', 'monitor', 'recall', 'email', 'phone', 'company', 'breaches', 'ip', 'hash', 'ransomware', 'satellite', 'airport', 'country', 'papers', 'case', 'brief', 'report', 'narratives', 'health', 'impact', 'contradict', 'sanctions', 'watch', 'fence', 'markets', 'launches', 'rewind', 'deployer', 'scoops', 'rh', 'ships', 'radar', 'signals', 'dossier', 'hype', 'footprint', 'plane', 'mil', 'events', 'lights', 'image', 'wallet', 'token', 'space', 'air', 'score', 'cloud', 'bgp', 'vulns', 'cve', 'regs', 'defi', 'squawk', 'filings', 'fires', 'sentinel', 'radar_image', 'darkships', 'vessel', 'blackout', 'hazards', 'podcast', 'exposure', 'social', 'calendar', 'connect', 'live', 'feedback', 'alerts'].filter((c) => onchainEnabled() || !/^(deployer|rh|wallet|token|defi|protocol)$/.test(c)).map((c) => ({ command: c, description: `Oculon ${c}` })),
|
|
956
|
+
commands: ['ask', 'scam', 'monitors', 'unmonitor', 'url', 'factcheck', 'travel', 'audit', 'monitor', 'recall', 'email', 'phone', 'company', 'iban', 'headers', 'breaches', 'ip', 'hash', 'lookalike', 'honeypot', 'address', 'ransomware', 'satellite', 'airport', 'country', 'papers', 'case', 'brief', 'report', 'narratives', 'health', 'impact', 'contradict', 'sanctions', 'watch', 'fence', 'markets', 'launches', 'rewind', 'deployer', 'scoops', 'rh', 'ships', 'radar', 'signals', 'dossier', 'hype', 'footprint', 'plane', 'mil', 'events', 'lights', 'image', 'wallet', 'token', 'space', 'air', 'score', 'cloud', 'bgp', 'vulns', 'cve', 'regs', 'defi', 'squawk', 'filings', 'fires', 'sentinel', 'radar_image', 'darkships', 'vessel', 'blackout', 'hazards', 'podcast', 'exposure', 'social', 'calendar', 'connect', 'live', 'feedback', 'alerts'].filter((c) => onchainEnabled() || !/^(deployer|rh|wallet|token|defi|protocol)$/.test(c)).map((c) => ({ command: c, description: `Oculon ${c}` })),
|
|
920
957
|
}).catch(() => { });
|
|
921
958
|
if (this.opts.watchMinutes && this.opts.watchMinutes > 0) {
|
|
922
959
|
this.scheduler = startScheduler(this.oculon, {
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token burns for /thetoken, read straight from the chain: every Transfer of the token to the dead address or
|
|
3
|
+
* the zero address since the deploy block, with the block time. The total is the dead address balance plus
|
|
4
|
+
* everything sent to the zero address. Callers cache the result so page views do not hit the RPC.
|
|
5
|
+
*/
|
|
6
|
+
export interface Burn {
|
|
7
|
+
tx: string;
|
|
8
|
+
time: string;
|
|
9
|
+
amount: string;
|
|
10
|
+
}
|
|
11
|
+
export interface BurnInfo {
|
|
12
|
+
total: string;
|
|
13
|
+
percent: string | null;
|
|
14
|
+
burns: Burn[];
|
|
15
|
+
checkedAt: string;
|
|
16
|
+
}
|
|
17
|
+
/** Whole tokens with thousands separators, plus two decimals when there are any. */
|
|
18
|
+
export declare function formatUnits(raw: bigint, decimals: number): string;
|
|
19
|
+
export type Rpc = <T>(method: string, params: unknown[]) => Promise<T>;
|
|
20
|
+
export declare function rpcClient(url: string, fetchImpl?: typeof fetch): Rpc;
|
|
21
|
+
export declare function readBurns(rpc: Rpc, token: string, fromBlock: number, now?: Date): Promise<BurnInfo>;
|