oculon 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/README.md +93 -17
  2. package/dist/cli/main.js +397 -0
  3. package/dist/core/calls.d.ts +63 -0
  4. package/dist/core/calls.js +120 -0
  5. package/dist/core/der.d.ts +2 -0
  6. package/dist/core/der.js +17 -0
  7. package/dist/core/http.d.ts +30 -1
  8. package/dist/core/http.js +133 -29
  9. package/dist/core/pdf.d.ts +51 -0
  10. package/dist/core/pdf.js +211 -0
  11. package/dist/core/qr.d.ts +23 -0
  12. package/dist/core/qr.js +577 -0
  13. package/dist/core/quota.js +5 -0
  14. package/dist/core/raster.d.ts +6 -0
  15. package/dist/core/raster.js +298 -0
  16. package/dist/core/safeurl.d.ts +5 -0
  17. package/dist/core/safeurl.js +26 -0
  18. package/dist/core/verdict.d.ts +30 -0
  19. package/dist/core/verdict.js +164 -0
  20. package/dist/core/zip.d.ts +9 -0
  21. package/dist/core/zip.js +46 -0
  22. package/dist/index.d.ts +83 -0
  23. package/dist/index.js +128 -0
  24. package/dist/mcp.d.ts +1 -0
  25. package/dist/mcp.js +256 -6
  26. package/dist/modules/address.d.ts +6 -2
  27. package/dist/modules/address.js +32 -5
  28. package/dist/modules/apk.d.ts +37 -0
  29. package/dist/modules/apk.js +191 -0
  30. package/dist/modules/approvals.d.ts +40 -0
  31. package/dist/modules/approvals.js +155 -0
  32. package/dist/modules/archive.d.ts +21 -0
  33. package/dist/modules/archive.js +94 -0
  34. package/dist/modules/checks.d.ts +59 -0
  35. package/dist/modules/checks.js +167 -0
  36. package/dist/modules/contract.d.ts +56 -0
  37. package/dist/modules/contract.js +167 -0
  38. package/dist/modules/deployer.d.ts +42 -0
  39. package/dist/modules/deployer.js +90 -0
  40. package/dist/modules/doc.d.ts +83 -0
  41. package/dist/modules/doc.js +841 -0
  42. package/dist/modules/eml.d.ts +46 -0
  43. package/dist/modules/eml.js +175 -0
  44. package/dist/modules/hashcheck.d.ts +19 -3
  45. package/dist/modules/hashcheck.js +28 -4
  46. package/dist/modules/image.d.ts +32 -0
  47. package/dist/modules/image.js +276 -0
  48. package/dist/modules/invite.d.ts +27 -0
  49. package/dist/modules/invite.js +69 -0
  50. package/dist/modules/job.d.ts +33 -0
  51. package/dist/modules/job.js +64 -0
  52. package/dist/modules/meerkat.d.ts +1 -1
  53. package/dist/modules/meerkat.js +35 -2
  54. package/dist/modules/monitor.js +14 -0
  55. package/dist/modules/poisoning.d.ts +43 -0
  56. package/dist/modules/poisoning.js +114 -0
  57. package/dist/modules/qrcheck.d.ts +24 -0
  58. package/dist/modules/qrcheck.js +136 -0
  59. package/dist/modules/repo.d.ts +61 -0
  60. package/dist/modules/repo.js +162 -0
  61. package/dist/modules/report.d.ts +32 -0
  62. package/dist/modules/report.js +108 -0
  63. package/dist/modules/signature.d.ts +35 -0
  64. package/dist/modules/signature.js +283 -0
  65. package/dist/modules/site.d.ts +62 -0
  66. package/dist/modules/site.js +191 -0
  67. package/dist/modules/stocktoken.d.ts +48 -0
  68. package/dist/modules/stocktoken.js +99 -0
  69. package/dist/modules/trace.d.ts +37 -0
  70. package/dist/modules/trace.js +150 -0
  71. package/dist/modules/txexplain.d.ts +40 -0
  72. package/dist/modules/txexplain.js +135 -0
  73. package/dist/modules/urlcheck.js +15 -1
  74. package/dist/modules/utility.d.ts +27 -1
  75. package/dist/modules/utility.js +108 -11
  76. package/dist/modules/where.d.ts +63 -0
  77. package/dist/modules/where.js +165 -0
  78. package/dist/report-pdf.d.ts +7 -0
  79. package/dist/report-pdf.js +84 -0
  80. package/dist/sources/cfurlscan.d.ts +24 -0
  81. package/dist/sources/cfurlscan.js +46 -0
  82. package/dist/sources/chainabuse.d.ts +17 -0
  83. package/dist/sources/chainabuse.js +19 -0
  84. package/dist/sources/evm.d.ts +135 -0
  85. package/dist/sources/evm.js +260 -0
  86. package/dist/sources/phishlists.d.ts +20 -0
  87. package/dist/sources/phishlists.js +90 -0
  88. package/dist/telegram.d.ts +17 -0
  89. package/dist/telegram.js +151 -4
  90. package/dist/web/card.d.ts +28 -0
  91. package/dist/web/card.js +75 -0
  92. package/dist/web/docs.html +1 -1
  93. package/dist/web/index.html +213 -5
  94. package/dist/web/landing.html +1 -1
  95. package/dist/web/legal.html +3 -1
  96. package/dist/web/mcp.html +1 -1
  97. package/dist/web/openapi.js +15 -0
  98. package/dist/web/pages.d.ts +24 -0
  99. package/dist/web/pages.js +139 -0
  100. package/dist/web/public.js +16 -1
  101. package/dist/web/server.d.ts +13 -0
  102. package/dist/web/server.js +152 -13
  103. package/dist/web/token.html +25 -4
  104. package/dist/web/token.json +12 -1
  105. package/dist/web/utility.html +40 -14
  106. package/package.json +2 -2
@@ -0,0 +1,69 @@
1
+ const BRANDS = /\b(binance|coinbase|kraken|okx|bybit|kucoin|metamask|trust ?wallet|phantom|ledger|trezor|uniswap|opensea|pancakeswap|blur|magic ?eden|arbitrum|optimism|base|solana|ethereum|polygon|ton|tonkeeper|layerzero|zksync|starknet|eigenlayer|pump\.?fun|jupiter|raydium|telegram|discord|paypal|apple|microsoft|google|amazon|meta|tesla|spacex|elon)\b/i;
2
+ const LURE = /\b(official|support|help ?desk|customer (care|service)|airdrop|claim|giveaway|reward|recovery|refund|validator|presale|whitelist|admin|team|announcement)\b/i;
3
+ const num = (s) => (s ? Number(s.replace(/[^\d]/g, '')) || null : null);
4
+ export async function inviteCheck(ctx, input) {
5
+ const raw = input.trim().replace(/^https?:\/\//i, '').replace(/^www\./i, '');
6
+ const tg = /^(?:t(?:elegram)?\.me|telegram\.dog)\/(\+[\w-]+|joinchat\/[\w-]+|s\/[\w]{4,}|[\w]{4,})/i.exec(raw);
7
+ const dc = /^(?:discord\.gg|discord(?:app)?\.com\/invite)\/([\w-]{2,})/i.exec(raw);
8
+ if (!tg && !dc)
9
+ throw new Error('give a Telegram (t.me/...) or Discord (discord.gg/...) invite link');
10
+ const provenance = [];
11
+ const reasons = [];
12
+ let r;
13
+ if (tg) {
14
+ const path = tg[1].replace(/^s\//, '');
15
+ const link = `https://t.me/${path}`;
16
+ const p = await ctx.http.getPage(link, { source: 'telegram-preview', timeoutMs: 20_000, maxBytes: 300_000 });
17
+ provenance.push(p.prov);
18
+ if (!p.data)
19
+ throw new Error(`t.me did not answer (${p.prov.note ?? p.prov.status})`);
20
+ const h = p.data.body.toString('utf8');
21
+ const meta = (k) => new RegExp(`property="og:${k}" content="([^"]*)"`, 'i').exec(h)?.[1]?.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, "'") ?? null;
22
+ const extra = /tgme_page_extra">([^<]*)</.exec(h)?.[1]?.trim() ?? '';
23
+ const title = meta('title');
24
+ const valid = Boolean(/tgme_page_title/.test(h) && title && !/^Telegram: (Contact|Join Group Chat)/.test(title));
25
+ const kind = /subscriber/i.test(extra) ? 'channel' : /member/i.test(extra) ? 'group' : /tgme_action_button_new[^>]*>\s*(Send Message|Start Bot)/i.test(h) || /@\w+bot\b/i.test(extra) ? 'user or bot' : null;
26
+ r = { link, platform: 'telegram', name: valid ? title : null, description: meta('description'), members: num(/([\d\s]+)\s*(subscribers|members)/i.exec(extra)?.[1]), online: num(/([\d\s]+)\s*online/i.exec(extra)?.[1]), verified: /verified-icon/.test(h), createdAt: null, kind };
27
+ if (!valid)
28
+ return { module: 'invite', input: link, generatedAt: ctx.now().toISOString(), signals: [], provenance, result: { ...r, verdict: 'invite not valid', risk: 0, reasons: ['the link does not open a group, channel or account: it is expired, private or never existed'], advice: ['Ask for a new link from the project\'s official website.'] } };
29
+ if (/class="[^"]*\b(scam|fake)\b[^"]*"/i.test(h) || /\b(SCAM|FAKE)\b/.test(/tgme_page_title[\s\S]{0,400}/.exec(h)?.[0] ?? ''))
30
+ reasons.push(['Telegram itself labels this account as scam or fake', 90]);
31
+ }
32
+ else {
33
+ const code = dc[1];
34
+ const link = `https://discord.gg/${code}`;
35
+ const d = await ctx.http.get(`https://discord.com/api/v10/invites/${encodeURIComponent(code)}?with_counts=true&with_expiration=true`, { source: 'discord', ttlSec: 600, retries: 1 });
36
+ provenance.push(d.prov);
37
+ if (!d.data?.guild)
38
+ return { module: 'invite', input: link, generatedAt: ctx.now().toISOString(), signals: [], provenance, result: { link, platform: 'discord', name: null, description: null, members: null, online: null, verified: false, createdAt: null, kind: null, verdict: 'invite not valid', risk: 0, reasons: [d.prov.note === 'HTTP 404' ? 'the invite is expired or never existed' : `Discord did not answer (${d.prov.note ?? d.prov.status})`], advice: ['Get the invite from the project\'s official website or verified X account.'] } };
39
+ const g = d.data.guild;
40
+ const created = new Date(Number((BigInt(g.id) >> 22n) + 1420070400000n)).toISOString();
41
+ const feats = g.features ?? [];
42
+ r = { link, platform: 'discord', name: g.name, description: g.description ?? null, members: d.data.approximate_member_count ?? null, online: d.data.approximate_presence_count ?? null, verified: feats.includes('VERIFIED') || feats.includes('PARTNERED'), createdAt: created, kind: feats.includes('COMMUNITY') ? 'community server' : 'server' };
43
+ const age = (ctx.now().getTime() - Date.parse(created)) / 86_400_000;
44
+ if (age < 30)
45
+ reasons.push([`the server was created ${Math.max(0, Math.round(age))} days ago`, 20]);
46
+ if ((g.verification_level ?? 0) === 0 && (r.members ?? 0) > 50)
47
+ reasons.push(['no verification level: anyone can post right away, including fake admins', 5]);
48
+ if (d.data.expires_at)
49
+ reasons.push([`the invite expires on ${d.data.expires_at.slice(0, 10)}: official projects usually share permanent links`, 5]);
50
+ }
51
+ const text = `${r.name ?? ''} ${r.link}`;
52
+ const brand = BRANDS.exec(text)?.[0], lure = LURE.exec(text)?.[0];
53
+ if (!r.verified && brand && lure)
54
+ reasons.push([`uses "${brand}" and "${lure}" in its name without a verified badge: the classic fake support or fake project pattern`, 50]);
55
+ else if (!r.verified && lure && /support|help|customer|recovery|refund|validator/i.test(lure))
56
+ reasons.push([`calls itself "${lure}": real companies do not run support through invite links`, 30]);
57
+ else if (!r.verified && brand && (r.members ?? 0) < 500)
58
+ reasons.push([`uses the name "${brand}" with only ${r.members ?? 0} members and no verified badge`, 25]);
59
+ if (/airdrop|claim|giveaway|presale|double/i.test(`${r.name ?? ''} ${r.description ?? ''}`))
60
+ reasons.push(['promises an airdrop, claim, giveaway or presale', 15]);
61
+ if (r.members !== null && r.online !== null && r.members > 1000 && r.online / r.members < 0.005)
62
+ reasons.push([`${r.members.toLocaleString('en-US')} members but only ${r.online} online: often bought members`, 10]);
63
+ const risk = Math.min(100, reasons.reduce((s, [, w]) => s + w, 0));
64
+ const verdict = risk >= 90 ? 'labeled scam' : risk >= 50 ? 'likely impersonation' : risk >= 20 ? 'suspicious' : 'no known risk found';
65
+ const advice = risk >= 50
66
+ ? ['Do not join. Nobody from support will ever ask for your seed phrase, a "validation" or a payment in a chat.', 'Find the real community through the project\'s official website.']
67
+ : ['Admins and support never message you first. Ignore anyone in the group who offers help in private messages.'];
68
+ return { module: 'invite', input: r.link, generatedAt: ctx.now().toISOString(), signals: [], provenance, result: { ...r, verdict, risk, reasons: reasons.sort((a, b) => b[1] - a[1]).map(([x]) => x), advice } };
69
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Job offer check: paste the message from a "recruiter" and see whether it follows the patterns of job scams.
3
+ * Patterns, matched in plain code: fees before you start, "tasks" you pay to unlock (like, rate, review,
4
+ * boost orders), pay that does not fit the work, contact only through WhatsApp or Telegram, hired without an
5
+ * interview, early requests for ID or bank details, check-cashing and reimbursement tricks, and coding "test
6
+ * tasks" that ask you to run a repository.
7
+ * Links and the sender go through the scam check; a GitHub repo in the message goes through the repo check.
8
+ */
9
+ import type { Ctx } from '../core/context.js';
10
+ import type { ModuleResult } from '../core/types.js';
11
+ export interface JobReport {
12
+ verdict: 'job scam' | 'likely scam' | 'suspicious' | 'no known risk found';
13
+ risk: number;
14
+ patterns: {
15
+ name: string;
16
+ evidence: string;
17
+ }[];
18
+ links: {
19
+ url: string;
20
+ verdict: string;
21
+ risk: number;
22
+ }[];
23
+ sender: string | null;
24
+ repo: {
25
+ repo: string;
26
+ verdict: string;
27
+ risk: number;
28
+ findings: string[];
29
+ } | null;
30
+ reasons: string[];
31
+ advice: string[];
32
+ }
33
+ export declare function jobCheck(ctx: Ctx, text: string): Promise<ModuleResult<JobReport>>;
@@ -0,0 +1,64 @@
1
+ import { scamCheck } from './scam.js';
2
+ import { repoCheck } from './repo.js';
3
+ const PATTERNS = [
4
+ ['asks for a fee before you start', /\b((registration|training|onboarding|equipment|starter kit|processing|visa|background check|activation|membership)\s+fees?|pay (a |the )?(small |one[- ]time )?(fee|deposit)|deposit (to|before you|in order to) (start|unlock|activate|begin))\b/i, 40],
5
+ ['paid "tasks" you have to unlock (like, rate, review or boost orders)', /\b((like|rate|review|subscribe|follow|boost|optimi[sz]e|submit)\s.{0,30}\b(videos?|apps?|products?|hotels?|orders?|tasks?|listings?)\b.{0,80}\b(commission|earn|paid|\$)|complete \d+ (tasks|orders)|prepaid tasks?|task (set|package|combo)|commission per (task|order)|recharge|top[- ]?up (your )?(account|balance))/i, 40],
6
+ ['pay or deposits in crypto', /\b(usdt|trc-?20|erc-?20 wallet|binance pay|crypto (wallet|deposit)|send (bitcoin|btc|eth|usdt))\b/i, 20],
7
+ ['pay that does not fit the work', /(\$|usd|€|£)\s?\d{3,5}\s?(\+\s?)?(per|\/|a)\s?(day|daily)|earn (up to )?(\$|usd|€|£)\s?\d{3,}[^.]{0,30}(day|daily|week)|daily (income|salary|pay|profit)/i, 20],
8
+ ['contact only through WhatsApp or Telegram', /\b(whatsapp|telegram|signal|wa\.me|t\.me)\b.{0,60}\b(contact|text|message|add|reach|chat|interview|hr|manager)\b|\b(contact|text|message|add|reach)\b.{0,40}\b(whatsapp|telegram)\b/i, 15],
9
+ ['hired without an interview', /\b(no interview( needed| required)?|you('ve| have) been (selected|hired|shortlisted|approved)|congratulations.{0,60}(selected|position|role|hired))\b/i, 20],
10
+ ['asks for ID or bank details early', /\b(send|provide|share|upload)\b.{0,50}\b(passport|id card|national id|ssn|social security|bank (details|account|statement)|driver'?s? licen[sc]e|card number)\b/i, 25],
11
+ ['check cashing or buy-and-reimburse trick', /\b(deposit|cash) (a |the )?(check|cheque)|send (the )?(rest|remaining|difference|balance) back|buy (gift cards|equipment|supplies).{0,60}(reimburs|refund|pay you back)/i, 40],
12
+ ['a coding "test task" that asks you to run a project', /\b(clone|download|run|install|set up|npm install|yarn)\b.{0,50}\b(repo|repository|project|codebase|test task|assignment|take[- ]home)\b/i, 15],
13
+ ['vague company and role', /\b(online (assistant|job|work)|data entry|simple (tasks|job|work)|part[- ]time.{0,30}(from home|online)|no experience (needed|required))\b/i, 10],
14
+ ];
15
+ export async function jobCheck(ctx, text) {
16
+ const msg = text.trim();
17
+ if (msg.length < 20)
18
+ throw new Error('paste the whole job message or email (at least a sentence)');
19
+ if (msg.length > 30_000)
20
+ throw new Error('the message is too long (max 30,000 characters)');
21
+ const provenance = [];
22
+ const signals = [];
23
+ const patterns = [];
24
+ const reasons = [];
25
+ for (const [name, re, w] of PATTERNS) {
26
+ const m = re.exec(msg);
27
+ if (m) {
28
+ patterns.push({ name, evidence: m[0].slice(0, 120) });
29
+ reasons.push([name, w]);
30
+ }
31
+ }
32
+ const s = await scamCheck(ctx, msg);
33
+ provenance.push(...s.provenance.slice(0, 8));
34
+ signals.push(...s.signals);
35
+ const links = s.result.links.map((l) => ({ url: l.url, verdict: l.verdict, risk: l.risk }));
36
+ for (const l of s.result.links.filter((x) => x.risk >= 40).slice(0, 3))
37
+ reasons.push([`link ${l.url.slice(0, 80)}: ${l.verdict}${l.reasons[0] ? ` (${l.reasons[0]})` : ''}`, l.verdict === 'malicious' ? 40 : 15]);
38
+ const sender = s.result.sender?.email ?? null;
39
+ if (s.result.sender?.freeMail && /\b(recruit|hiring|hr|talent|company|inc|ltd|llc|corp)\b/i.test(msg))
40
+ reasons.push([`a company recruiter writing from a free mailbox (${s.result.sender.domain})`, 15]);
41
+ let repo = null;
42
+ const gh = /https?:\/\/(?:www\.)?github\.com\/[\w.-]+\/[\w.-]+/i.exec(msg)?.[0];
43
+ if (gh) {
44
+ try {
45
+ const r = await repoCheck(ctx, gh);
46
+ provenance.push(...r.provenance.slice(0, 3));
47
+ signals.push(...r.signals);
48
+ repo = { repo: r.result.repo, verdict: r.result.verdict, risk: r.result.risk, findings: r.result.reasons.slice(0, 5) };
49
+ if (r.result.verdict === 'malicious code found')
50
+ reasons.unshift([`the repo in the message (${r.result.repo}) contains malicious code: ${r.result.reasons[0] ?? ''}`, 70]);
51
+ else if (r.result.verdict === 'suspicious')
52
+ reasons.push([`the repo in the message (${r.result.repo}) looks suspicious`, 25]);
53
+ }
54
+ catch (e) {
55
+ reasons.push([`the GitHub link could not be checked (${e.message.slice(0, 60)})`, 0]);
56
+ }
57
+ }
58
+ const risk = Math.min(100, reasons.reduce((a, [, w]) => a + w, 0));
59
+ const verdict = risk >= 70 ? 'job scam' : risk >= 45 ? 'likely scam' : risk >= 20 ? 'suspicious' : 'no known risk found';
60
+ const advice = risk >= 45
61
+ ? ['Do not pay anything, do not send ID or bank details, and do not run code they send.', 'Real employers never charge you to start, and never pay you through "tasks" you top up yourself.', 'Look the company up yourself and contact it through its official website to ask whether the offer is real.']
62
+ : ['Look the company and the recruiter up yourself (official site, LinkedIn) before you share documents.', 'Run any code from a test task in a throwaway virtual machine, never on a machine with a wallet.'];
63
+ return { module: 'job', input: msg.slice(0, 200), generatedAt: ctx.now().toISOString(), signals, provenance, result: { verdict, risk, patterns, links, sender, repo, reasons: reasons.sort((a, b) => b[1] - a[1]).map(([r]) => r), advice } };
64
+ }
@@ -9,7 +9,7 @@ export declare function splitQuakeTarget(target: string): {
9
9
  place: string;
10
10
  min: number;
11
11
  };
12
- export declare const WATCH_KINDS: readonly ['company', 'domain', 'wallet', 'token', 'plane', 'topic', 'lights', 'air', 'port', 'news', 'outage', 'cve', 'quake', 'hazard', 'url', 'package', 'travel'];
12
+ export declare const WATCH_KINDS: readonly ['company', 'domain', 'wallet', 'token', 'approvals', 'contract', 'plane', 'topic', 'lights', 'air', 'port', 'news', 'outage', 'cve', 'quake', 'hazard', 'url', 'package', 'travel'];
13
13
  export type WatchKind = (typeof WATCH_KINDS)[number];
14
14
  export interface WatchItem {
15
15
  id: number;
@@ -20,6 +20,8 @@ import { hazards } from './hazards.js';
20
20
  import { urlCheck } from './urlcheck.js';
21
21
  import { audit } from './audit.js';
22
22
  import { travel } from './travel.js';
23
+ import { approvalsCheck } from './approvals.js';
24
+ import { contractRisk } from './contract.js';
23
25
  const lc = (s) => s.toLowerCase().normalize('NFD').replace(/[̀-ͯ]/g, '');
24
26
  /** "Tokyo|5.5" is a place with a minimum magnitude; a bare place uses 5.0. */
25
27
  export function splitQuakeTarget(target) {
@@ -27,7 +29,7 @@ export function splitQuakeTarget(target) {
27
29
  const m = Number(min);
28
30
  return { place: (place ?? '').trim(), min: Number.isFinite(m) && m > 0 ? m : 5 };
29
31
  }
30
- export const WATCH_KINDS = ['company', 'domain', 'wallet', 'token', 'plane', 'topic', 'lights', 'air', 'port', 'news', 'outage', 'cve', 'quake', 'hazard', 'url', 'package', 'travel'];
32
+ export const WATCH_KINDS = ['company', 'domain', 'wallet', 'token', 'approvals', 'contract', 'plane', 'topic', 'lights', 'air', 'port', 'news', 'outage', 'cve', 'quake', 'hazard', 'url', 'package', 'travel'];
31
33
  const toItem = (r) => ({ id: r.id, kind: r.kind, target: r.target, label: r.label, createdAt: new Date(r.created_at).toISOString(), lastRun: r.last_run ? new Date(r.last_run).toISOString() : null });
32
34
  export function addWatch(ctx, kind, target, label) {
33
35
  if (!WATCH_KINDS.includes(kind))
@@ -128,6 +130,37 @@ export async function observe(ctx, item, prev) {
128
130
  }
129
131
  return { state: { verdict: r.verdict, liq }, changes };
130
132
  }
133
+ case 'approvals': {
134
+ const [address, chain] = item.target.split('@');
135
+ const r = (await approvalsCheck(ctx, address, { chain })).result;
136
+ const keys = r.approvals.map((a) => `${a.token}|${a.spender}`);
137
+ if (prev) {
138
+ for (const a of r.approvals.filter((x) => newOnes(keys, prev.keys).includes(`${x.token}|${x.spender}`)).slice(0, 5))
139
+ changes.push(`new approval: ${a.symbol ?? a.token.slice(0, 10)} to ${a.spenderName ?? a.spender} (${a.amount}${a.risk !== 'low' ? `, ${a.risk} risk: ${a.why}` : ''})`);
140
+ if (prev.verdict !== r.verdict)
141
+ changes.push(`verdict ${String(prev.verdict)} → ${r.verdict}`);
142
+ }
143
+ return { state: { keys, verdict: r.verdict }, changes };
144
+ }
145
+ case 'contract': {
146
+ const [address, chain] = item.target.split('@');
147
+ const r = (await contractRisk(ctx, address, { chain })).result;
148
+ const liq = r.liquidity?.usd ?? null;
149
+ const impl = r.proxy?.implementation ?? null;
150
+ if (prev) {
151
+ if (prev.owner !== r.owner)
152
+ changes.push(`owner changed: ${String(prev.owner ?? 'none')} → ${r.owner ?? 'none'}`);
153
+ if (prev.impl !== impl && impl)
154
+ changes.push(`contract code upgraded: implementation ${String(prev.impl ?? 'none')} → ${impl}`);
155
+ if (typeof prev.liq === 'number' && prev.liq > 1000 && liq !== null && Math.abs(pct(liq, prev.liq)) >= 0.3)
156
+ changes.push(`liquidity ${fmtPct(pct(liq, prev.liq))} (${Math.round(prev.liq).toLocaleString('en-US')} → ${Math.round(liq).toLocaleString('en-US')})`);
157
+ if (prev.verdict !== r.verdict)
158
+ changes.push(`verdict ${String(prev.verdict)} → ${r.verdict}${r.reasons[0] ? ` (${r.reasons[0]})` : ''}`);
159
+ if (typeof prev.top10 === 'number' && r.holders?.top10Percent !== null && r.holders?.top10Percent !== undefined && r.holders.top10Percent - prev.top10 >= 10)
160
+ changes.push(`top 10 holders went from ${prev.top10}% to ${r.holders.top10Percent}%`);
161
+ }
162
+ return { state: { owner: r.owner, impl, liq, verdict: r.verdict, top10: r.holders?.top10Percent ?? null }, changes };
163
+ }
131
164
  case 'plane': {
132
165
  const t = (await track(ctx, item.target)).result;
133
166
  if (prev && t.change)
@@ -258,7 +291,7 @@ export async function observe(ctx, item, prev) {
258
291
  }
259
292
  }
260
293
  }
261
- const KIND_WEIGHT = { company: 55, domain: 60, wallet: 60, token: 65, plane: 65, topic: 50, lights: 65, air: 50, port: 60, news: 50, outage: 70, cve: 65, quake: 70, hazard: 70, url: 70, package: 60, travel: 65 };
294
+ const KIND_WEIGHT = { company: 55, domain: 60, wallet: 60, token: 65, approvals: 70, contract: 70, plane: 65, topic: 50, lights: 65, air: 50, port: 60, news: 50, outage: 70, cve: 65, quake: 70, hazard: 70, url: 70, package: 60, travel: 65 };
262
295
  /** Run every watch item (or the given ids) one after another, so free-tier rate limits are respected. */
263
296
  export async function runWatch(ctx, ids) {
264
297
  const rows = ctx.store.db.prepare('SELECT * FROM watchlist ORDER BY id').all().filter((r) => !ids || ids.includes(r.id));
@@ -19,6 +19,8 @@ const KIND_HELP = {
19
19
  port: 'ships queuing or military vessels at a port. target: the port',
20
20
  wallet: 'activity of a crypto wallet. target: the address',
21
21
  token: 'risk verdict and liquidity of a token. target: the contract address',
22
+ approvals: 'new token or NFT approvals on a wallet (who can take its tokens). target: the wallet address, optionally "address@arbitrum" or "address@polygon"',
23
+ contract: 'owner changes, code upgrades, liquidity pulls and holder concentration of a token contract (rug-pull watch). target: the contract address, optionally "address@base" etc.',
22
24
  };
23
25
  export const availableKinds = () => WATCH_KINDS.filter((k) => onchainEnabled() || !ONCHAIN_WATCH_KINDS.has(k));
24
26
  const describe = (kind, target) => {
@@ -43,6 +45,8 @@ const describe = (kind, target) => {
43
45
  case 'port': return `vessel queues at ${target}`;
44
46
  case 'wallet': return `activity of wallet ${target}`;
45
47
  case 'token': return `risk changes of token ${target}`;
48
+ case 'approvals': return `new approvals on wallet ${target}`;
49
+ case 'contract': return `owner, code and liquidity changes of contract ${target}`;
46
50
  }
47
51
  };
48
52
  // Drops quotes, a leading "the", and trailing verbs such as "changes", "gets worse", "turns red".
@@ -53,6 +57,16 @@ export function parseMonitorPattern(text) {
53
57
  const t = text.trim().replace(/\bthe\s+(?=[A-Z])/g, '');
54
58
  const after = (re) => { const m = re.exec(t); return m?.[1] ? clean(m[1]) : null; };
55
59
  let target;
60
+ const evm = /\b(0x[0-9a-fA-F]{40})\b/.exec(t)?.[1];
61
+ const onChain = /\b(?:on|@)\s*(arbitrum|polygon|base|bsc|bnb)\b/i.exec(t)?.[1]?.toLowerCase();
62
+ if (evm && /\b(approv|allowance|drain|spend)/i.test(t)) {
63
+ const tg = onChain ? `${evm}@${onChain}` : evm;
64
+ return { kind: 'approvals', target: tg, description: describe('approvals', tg) };
65
+ }
66
+ if (evm && /\b(rug|liquidity|owner|upgrade|contract|dev wallet)/i.test(t)) {
67
+ const tg = onChain ? `${evm}@${onChain}` : evm;
68
+ return { kind: 'contract', target: tg, description: describe('contract', tg) };
69
+ }
56
70
  if ((target = after(/\b(https?:\/\/\S+)/i)))
57
71
  return { kind: 'url', target, description: describe('url', target) };
58
72
  if ((target = after(/\b((?:npm|pypi):[@\w./-]+)/i)))
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Address poisoning check: has someone planted lookalike addresses in this wallet's history?
3
+ * Attackers send zero-value transfers, dust or fake tokens from an address that starts and ends like one the
4
+ * victim really pays, hoping the victim copies it from the history next time. This check takes the addresses
5
+ * the wallet really sent to (transactions it signed itself, Etherscan), then looks through recent token
6
+ * transfers for other addresses that share the first and last characters, zero-value "transfers" the wallet
7
+ * never signed, and tokens posing as USDT or USDC.
8
+ */
9
+ import type { Ctx } from '../core/context.js';
10
+ import type { ModuleResult } from '../core/types.js';
11
+ export interface Lookalike {
12
+ fake: string;
13
+ real: string;
14
+ matched: string;
15
+ seen: number;
16
+ lastSeen: string;
17
+ how: string[];
18
+ }
19
+ export interface PoisoningReport {
20
+ address: string;
21
+ chain: string;
22
+ verdict: 'poisoned' | 'suspicious transfers' | 'no poisoning found';
23
+ risk: number;
24
+ lookalikes: Lookalike[];
25
+ fakeTokens: {
26
+ contract: string;
27
+ symbol: string;
28
+ transfers: number;
29
+ }[];
30
+ zeroValue: number;
31
+ realCounterparties: number;
32
+ checkedTransfers: number;
33
+ reasons: string[];
34
+ advice: string[];
35
+ }
36
+ /** How many characters two addresses share at the start (after 0x) and at the end. */
37
+ export declare function sharedEnds(a: string, b: string): {
38
+ head: number;
39
+ tail: number;
40
+ };
41
+ export declare function poisoningCheck(ctx: Ctx, input: string, opts?: {
42
+ chain?: string;
43
+ }): Promise<ModuleResult<PoisoningReport>>;
@@ -0,0 +1,114 @@
1
+ import { signalId } from '../core/text.js';
2
+ import { esTokenTx, esTxList, evmChain, historySource, isAddr, rpcCall } from '../sources/evm.js';
3
+ const OFFICIAL = {
4
+ eth: { USDT: ['0xdac17f958d2ee523a2206206994597c13d831ec7'], USDC: ['0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'], WETH: ['0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'], DAI: ['0x6b175474e89094c44da98b954eedeac495271d0f'] },
5
+ optimism: { USDT: ['0x94b008aa00579c1307b0ef2c499ad98a8ce58e58'], USDC: ['0x0b2c639c533813f4aa9d7837caf62653d097ff85', '0x7f5c764cbc14f9669b88837ca1490cca17c31607'], WETH: ['0x4200000000000000000000000000000000000006'] },
6
+ base: { USDC: ['0x833589fcd6edb6e08f4c7c32d4f71b54bda02913'], USDT: ['0xfde4c96c8593536e31f229ea8f37b2ada2699bb2'], WETH: ['0x4200000000000000000000000000000000000006'] },
7
+ bsc: { USDT: ['0x55d398326f99059ff775485246999027b3197955'], USDC: ['0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d'], WETH: ['0x2170ed0880ac9a755fd29b2688956bd959f933f8'] },
8
+ arbitrum: { USDT: ['0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9'], USDC: ['0xaf88d065e77c8cc2239327c5edb3a432268e5831', '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8'], WETH: ['0x82af49447d8a07e3bd95bd0d56f35241523fbab1'] },
9
+ polygon: { USDT: ['0xc2132d05d31c914a87c6611c10748aeb04b58e8f'], USDC: ['0x3c499c542cef5e3811e1192ce70d8cc03d5c3359', '0x2791bca1f2de4661ed88a30c99a7a9449aa84174'], WETH: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'] },
10
+ };
11
+ /** How many characters two addresses share at the start (after 0x) and at the end. */
12
+ export function sharedEnds(a, b) {
13
+ const x = a.toLowerCase().slice(2), y = b.toLowerCase().slice(2);
14
+ let head = 0, tail = 0;
15
+ while (head < 40 && x[head] === y[head])
16
+ head++;
17
+ while (tail < 40 && x[39 - tail] === y[39 - tail])
18
+ tail++;
19
+ return { head, tail };
20
+ }
21
+ export async function poisoningCheck(ctx, input, opts = {}) {
22
+ const address = input.trim().toLowerCase();
23
+ if (!isAddr(address))
24
+ throw new Error('give a wallet address: 0x followed by 40 hex characters');
25
+ const c = evmChain(opts.chain, 'transfers');
26
+ const provenance = [];
27
+ const [txs, toks] = await Promise.all([esTxList(ctx, c, address, 500), esTokenTx(ctx, c, address, 500)]);
28
+ provenance.push(txs.prov, toks.prov);
29
+ if (txs.data === null && toks.data === null)
30
+ throw new Error(`could not read the wallet history (${txs.prov.note ?? txs.prov.status})`);
31
+ // Addresses the wallet really paid: transactions it signed, and token transfers inside them.
32
+ const signed = new Set((txs.data ?? []).filter((t) => t.from.toLowerCase() === address).map((t) => t.hash.toLowerCase()));
33
+ // Alchemy lists only value transactions, so token transfers out of the wallet are confirmed by asking the chain
34
+ // who sent each transaction (the newest 40).
35
+ if (historySource(c) === 'alchemy') {
36
+ const open = [...new Set((toks.data ?? []).filter((t) => t.from.toLowerCase() === address && !signed.has(t.hash.toLowerCase())).map((t) => t.hash.toLowerCase()))].slice(0, 40);
37
+ for (let i = 0; i < open.length; i += 10) {
38
+ const got = await Promise.all(open.slice(i, i + 10).map((h) => rpcCall(ctx, c, 'eth_getTransactionByHash', [h], 86_400).then((r) => [h, r.data?.from?.toLowerCase()])));
39
+ for (const [h, from] of got)
40
+ if (from === address)
41
+ signed.add(h);
42
+ }
43
+ }
44
+ const real = new Set();
45
+ for (const t of txs.data ?? [])
46
+ if (t.from.toLowerCase() === address && t.to && BigInt(t.value || '0') > 0n)
47
+ real.add(t.to.toLowerCase());
48
+ for (const t of toks.data ?? [])
49
+ if (signed.has(t.hash.toLowerCase()) && t.from.toLowerCase() === address && BigInt(t.value || '0') > 0n)
50
+ real.add(t.to.toLowerCase());
51
+ // Received from: also addresses people copy (exchange deposit, a friend).
52
+ for (const t of toks.data ?? [])
53
+ if (t.to.toLowerCase() === address && BigInt(t.value || '0') > 0n && OFFICIAL[c.key]?.[t.tokenSymbol]?.includes(t.contractAddress.toLowerCase()))
54
+ real.add(t.from.toLowerCase());
55
+ const official = OFFICIAL[c.key] ?? {};
56
+ const fakeTok = new Map();
57
+ const found = new Map();
58
+ let zero = 0;
59
+ for (const t of toks.data ?? []) {
60
+ const from = t.from.toLowerCase(), to = t.to.toLowerCase(), ca = t.contractAddress.toLowerCase();
61
+ const isZero = BigInt(t.value || '0') === 0n;
62
+ const notSigned = !signed.has(t.hash.toLowerCase());
63
+ if (isZero && notSigned)
64
+ zero++;
65
+ const sym = (t.tokenSymbol ?? '').toUpperCase().replace(/[^A-Z]/g, '');
66
+ const fake = Boolean(official[sym] && !official[sym].includes(ca));
67
+ if (fake) {
68
+ const f = fakeTok.get(ca) ?? { contract: ca, symbol: t.tokenSymbol, transfers: 0 };
69
+ f.transfers++;
70
+ fakeTok.set(ca, f);
71
+ }
72
+ const other = from === address ? to : from;
73
+ if (real.has(other))
74
+ continue;
75
+ for (const r of real) {
76
+ const { head, tail } = sharedEnds(other, r);
77
+ if (head + tail >= 7 && head >= 3 && tail >= 3) {
78
+ const l = found.get(other) ?? { fake: other, real: r, matched: `0x${r.slice(2, 2 + head)}...${r.slice(-tail)}`, seen: 0, lastSeen: '', how: [] };
79
+ l.seen++;
80
+ const ts = new Date(Number(t.timeStamp) * 1000).toISOString();
81
+ if (ts > l.lastSeen)
82
+ l.lastSeen = ts;
83
+ const how = isZero && notSigned ? 'zero-value transfer you never signed' : fake ? `fake ${t.tokenSymbol} token` : from === address ? 'tokens sent to it' : 'dust sent to you';
84
+ if (!l.how.includes(how))
85
+ l.how.push(how);
86
+ found.set(other, l);
87
+ break;
88
+ }
89
+ }
90
+ }
91
+ const lookalikes = [...found.values()].sort((a, b) => b.seen - a.seen).slice(0, 20);
92
+ const sentToFake = lookalikes.filter((l) => l.how.includes('tokens sent to it'));
93
+ const reasons = [];
94
+ for (const l of lookalikes.slice(0, 5))
95
+ reasons.push(`${l.fake} looks like ${l.real} (same ${l.matched}): ${l.how.join(', ')}`);
96
+ if (sentToFake.length)
97
+ reasons.unshift(`you already sent funds to ${sentToFake.length} lookalike address${sentToFake.length > 1 ? 'es' : ''}`);
98
+ if (fakeTok.size)
99
+ reasons.push(`${fakeTok.size} fake token${fakeTok.size > 1 ? 's' : ''} posing as ${[...new Set([...fakeTok.values()].map((f) => f.symbol))].join(', ')}`);
100
+ if (zero >= 3 && !lookalikes.length)
101
+ reasons.push(`${zero} zero-value transfers this wallet never signed`);
102
+ const risk = Math.min(100, (sentToFake.length ? 60 : 0) + lookalikes.length * 20 + fakeTok.size * 10 + (zero >= 3 ? 10 : 0));
103
+ const verdict = lookalikes.length ? 'poisoned' : fakeTok.size || zero >= 3 ? 'suspicious transfers' : 'no poisoning found';
104
+ const advice = lookalikes.length
105
+ ? ['Never copy an address from your transaction history. Use your address book, or copy it from the exchange or the person each time.', 'Compare the whole address, not just the first and last characters.', 'The lookalike transfers cannot move your funds by themselves; they only wait for you to copy the wrong address.']
106
+ : ['Nothing planted found in the recent history. Keep using an address book for addresses you pay often.'];
107
+ const now = ctx.now().toISOString();
108
+ const signals = sentToFake.length ? [{ id: signalId('poisoning', address, c.key), module: 'poisoning', title: `${address.slice(0, 10)} sent funds to a lookalike address`, score: 75, entity: `wallet:${address}`, evidence: sentToFake.slice(0, 2).map((l) => ({ source: 'etherscan', text: `${l.fake} posing as ${l.real}` })), createdAt: now }] : [];
109
+ return {
110
+ module: 'poisoning', input: address, generatedAt: now,
111
+ result: { address, chain: c.label, verdict, risk, lookalikes, fakeTokens: [...fakeTok.values()], zeroValue: zero, realCounterparties: real.size, checkedTransfers: (toks.data ?? []).length, reasons, advice },
112
+ signals, provenance,
113
+ };
114
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * QR code check (quishing): read the QR code in a photo or screenshot, then check what it points to.
3
+ * The code is read here, without an upload (see core/qr.ts). Then:
4
+ * - a link goes through the URL check (Safe Browsing, URLhaus, urlscan.io, domain age, lookalikes),
5
+ * - a crypto payment code (ethereum:, bitcoin:, solana:) or a bare address goes through the address check,
6
+ * - an EPC / SEPA payment code has its IBAN checked,
7
+ * - Wi-Fi, phone, SMS and email codes are shown as what they would do.
8
+ * Fake parking-meter, parcel and "verify your account" QR codes are the common case.
9
+ */
10
+ import type { Ctx } from '../core/context.js';
11
+ import type { ModuleResult } from '../core/types.js';
12
+ export interface QrReport {
13
+ name: string;
14
+ found: boolean;
15
+ content: string | null;
16
+ kind: 'link' | 'crypto payment' | 'bank payment' | 'wifi' | 'phone' | 'sms' | 'email' | 'contact' | 'text' | null;
17
+ verdict: string;
18
+ risk: number;
19
+ target: Record<string, string>;
20
+ reasons: string[];
21
+ advice: string[];
22
+ check: unknown;
23
+ }
24
+ export declare function qrCheck(ctx: Ctx, file: Buffer, name?: string): Promise<ModuleResult<QrReport>>;
@@ -0,0 +1,136 @@
1
+ import { decodeGray } from '../core/raster.js';
2
+ import { readQr } from '../core/qr.js';
3
+ import { urlCheck } from './urlcheck.js';
4
+ import { addressCheck, detectChain } from './address.js';
5
+ import { checkIban } from './iban.js';
6
+ export async function qrCheck(ctx, file, name = 'image') {
7
+ if (!file.length)
8
+ throw new Error('the file is empty');
9
+ if (file.length > 15 * 1024 * 1024)
10
+ throw new Error('the image is larger than 15 MB');
11
+ const now = ctx.now().toISOString();
12
+ const provenance = [{ source: 'oculon-qr', url: 'local', status: 'LIVE', fetchedAt: now, note: 'QR code read from the image here, not uploaded' }];
13
+ const texts = readQr(decodeGray(file));
14
+ const base = { name: name.slice(0, 120), target: {}, reasons: [], check: null };
15
+ if (!texts.length) {
16
+ return { module: 'qr', input: base.name, generatedAt: now, signals: [], provenance, result: { ...base, found: false, content: null, kind: null, verdict: 'no QR code found', risk: 0, advice: ['Crop the photo to the code, keep it sharp and straight, or take a screenshot of it. Codes larger than version 15 (about 400 characters) are not read yet.'] } };
17
+ }
18
+ const content = texts[0].trim();
19
+ const t = base.target, reasons = base.reasons;
20
+ let kind = 'text', verdict = 'no known risk found', risk = 0, check = null;
21
+ let advice = ['Only scan codes from a source you trust. A sticker on a parking meter or a letter you did not expect is the common trick.'];
22
+ const crypto = /^(ethereum|bitcoin|solana|tron|litecoin):(?:pay-)?([^?@/\s]+)/i.exec(content);
23
+ const bare = !crypto && !/\s/.test(content) && detectChain(content).chain !== 'unknown' ? content : null;
24
+ if (/^https?:\/\//i.test(content) || /^www\./i.test(content)) {
25
+ kind = 'link';
26
+ t.url = content;
27
+ const r = await urlCheck(ctx, content);
28
+ provenance.push(...r.provenance);
29
+ check = { verdict: r.result.verdict, risk: r.result.risk, domain: r.result.domain, reasons: r.result.reasons, domainAgeDays: r.result.domainInfo?.ageDays ?? null };
30
+ verdict = r.result.verdict;
31
+ risk = r.result.risk;
32
+ reasons.push(...r.result.reasons.slice(0, 8));
33
+ if (/^https?:\/\/[^/]*\b(bit\.ly|tinyurl\.com|t\.co|is\.gd|cutt\.ly|rb\.gy|shorturl\.at|qrco\.de|qr\.page)\b/i.test(content)) {
34
+ reasons.push('a link shortener hides where the code really goes');
35
+ risk = Math.max(risk, 25);
36
+ }
37
+ advice = risk >= 50 ? ['Do not open the link and do not pay through it. Pay at the official app or website you type in yourself.'] : ['Check the domain in the browser bar after it opens, before you log in or pay.'];
38
+ }
39
+ else if (crypto || bare) {
40
+ kind = 'crypto payment';
41
+ const addr = crypto ? crypto[2] : bare;
42
+ t.address = addr;
43
+ if (crypto) {
44
+ t.network = crypto[1].toLowerCase();
45
+ const amt = /[?&](?:amount|value)=([^&]+)/i.exec(content)?.[1];
46
+ if (amt)
47
+ t.amount = decodeURIComponent(amt);
48
+ const chainId = /@(\d+)/.exec(content)?.[1];
49
+ if (chainId)
50
+ t.chainId = chainId;
51
+ if (/\/transfer\?address=/i.test(content)) {
52
+ t.token = addr;
53
+ t.address = /address=(0x[0-9a-fA-F]{40})/.exec(content)?.[1] ?? addr;
54
+ }
55
+ }
56
+ try {
57
+ const r = await addressCheck(ctx, t.address);
58
+ provenance.push(...r.provenance);
59
+ check = r.result;
60
+ reasons.push(...r.result.warnings);
61
+ risk = r.result.sanctioned ? 90 : r.result.warnings.length ? 30 : 0;
62
+ verdict = r.result.sanctioned ? 'sanctioned address' : r.result.warnings.length ? 'check the address' : 'no known risk found';
63
+ }
64
+ catch (e) {
65
+ reasons.push(`address not checked: ${e.message}`);
66
+ }
67
+ advice = ['Compare the whole address with the one the recipient gave you through another channel before paying.'];
68
+ }
69
+ else if (/^BCD\r?\n/.test(content)) {
70
+ kind = 'bank payment';
71
+ const L = content.split(/\r?\n/);
72
+ t.name = L[5] ?? '';
73
+ t.iban = L[6] ?? '';
74
+ if (L[7])
75
+ t.amount = L[7];
76
+ if (L[9] || L[10])
77
+ t.reference = (L[9] || L[10]);
78
+ const ib = checkIban(t.iban);
79
+ check = ib;
80
+ if (!ib.valid) {
81
+ risk = 60;
82
+ verdict = 'invalid IBAN';
83
+ reasons.push(`the IBAN in the code is not valid (${ib.problems[0] ?? 'checksum fails'})`);
84
+ }
85
+ else {
86
+ verdict = 'check the recipient';
87
+ risk = 15;
88
+ reasons.push(`pays ${t.amount ?? 'an amount you choose'} to ${t.name} (${ib.formatted ?? t.iban}${ib.countryName ? `, ${ib.countryName}` : ''})`);
89
+ }
90
+ advice = ['Check the recipient name your bank shows before you confirm the payment.'];
91
+ }
92
+ else if (/^WIFI:/i.test(content)) {
93
+ kind = 'wifi';
94
+ t.network = /S:((?:[^;\\]|\\.)*)/.exec(content)?.[1] ?? '';
95
+ t.security = /T:([^;]*)/.exec(content)?.[1] || 'none';
96
+ verdict = 'joins a Wi-Fi network';
97
+ risk = t.security === 'none' || /nopass/i.test(t.security) ? 20 : 5;
98
+ reasons.push(`connects to Wi-Fi "${t.network}" (${t.security})`);
99
+ advice = ['Only join networks you expect at this place; an open network can watch your traffic.'];
100
+ }
101
+ else if (/^tel:/i.test(content)) {
102
+ kind = 'phone';
103
+ t.number = content.slice(4);
104
+ verdict = 'calls a number';
105
+ reasons.push(`calls ${t.number}`);
106
+ }
107
+ else if (/^(smsto|sms):/i.test(content)) {
108
+ kind = 'sms';
109
+ const [, num, body] = /^(?:smsto|sms):([^:?]*)[:?]?(?:body=)?(.*)$/i.exec(content) ?? [];
110
+ t.number = num ?? '';
111
+ t.message = (body ?? '').slice(0, 200);
112
+ verdict = 'sends a text message';
113
+ risk = 15;
114
+ reasons.push(`prepares a text to ${t.number}: premium numbers cost money`);
115
+ }
116
+ else if (/^mailto:/i.test(content)) {
117
+ kind = 'email';
118
+ t.to = content.slice(7).split('?')[0];
119
+ verdict = 'writes an email';
120
+ reasons.push(`opens an email to ${t.to}`);
121
+ }
122
+ else if (/^BEGIN:VCARD/i.test(content) || /^MECARD:/i.test(content)) {
123
+ kind = 'contact';
124
+ t.name = /(?:FN|N):([^\r\n;]+)/.exec(content)?.[1] ?? '';
125
+ verdict = 'adds a contact';
126
+ reasons.push(`adds contact ${t.name}`);
127
+ }
128
+ else {
129
+ t.text = content.slice(0, 300);
130
+ const m = /\b((?:[a-z0-9-]+\.)+[a-z]{2,})(\/\S*)?/i.exec(content);
131
+ if (m) {
132
+ reasons.push(`the text names ${m[1]}`);
133
+ }
134
+ }
135
+ return { module: 'qr', input: base.name, generatedAt: now, signals: [], provenance, result: { name: base.name, found: true, content: content.slice(0, 2000), kind, verdict, risk, target: t, reasons, advice, check } };
136
+ }