WebWorthIt staging: read-only contract + website check (Marty 2026-11-16)
Free check (DeepSeek v4.1 Flash scorecard) and deep report (Opus 5.5) over a generalised evidence pack from the read-only chain tools; fact gate blocks any address, tx or number not in the evidence; MySQL store; hub sign-in, sponsor line recorder, vouchers, ad slots in iframes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
node_modules
|
||||
data
|
||||
.git
|
||||
.env
|
||||
tools/mockup-Main.dc.html
|
||||
**/__pycache__
|
||||
@@ -0,0 +1,5 @@
|
||||
node_modules/
|
||||
data/
|
||||
*.log
|
||||
.env
|
||||
__pycache__/
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
FROM node:22-bookworm-slim
|
||||
# Chromium (website screenshots) + Python 3 with requests (the read-only chain tools). No ML deps: the build stays light.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends chromium python3 python3-requests fonts-liberation fonts-noto-color-emoji ca-certificates tzdata wget \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci --omit=dev --no-audit --no-fund
|
||||
COPY . .
|
||||
RUN mkdir -p /app/data && python3 chain/keccak.py
|
||||
ENV NODE_ENV=production PORT=3000 CHROMIUM_PATH=/usr/bin/chromium PYTHON=python3 TZ=UTC
|
||||
EXPOSE 3000
|
||||
# a container that cannot boot is never swapped in (2026-10-08 rule)
|
||||
HEALTHCHECK --interval=15s --timeout=5s --start-period=30s --retries=4 CMD wget -qO- http://127.0.0.1:3000/health >/dev/null || exit 1
|
||||
CMD ["node","server.js"]
|
||||
@@ -0,0 +1,133 @@
|
||||
"""Shared read-only JSON-RPC helper for the WebWorthIt chain scan.
|
||||
Every method here is a read (eth_call, eth_getLogs, eth_getCode, ...). Nothing signs or sends a transaction.
|
||||
|
||||
Provider facts (checked 2026-11-16):
|
||||
- bsc: nodereal public demo key = archive + full log history, getLogs 50,000 blocks (use 49,000), rate limited.
|
||||
blxrbdn = full history, 5,000 blocks. publicnode = recent days only (silently returns [] for old blocks: never for history).
|
||||
- polygon: publicnode getLogs 10,000 blocks, about 1M blocks of history (older = "Archive requests require a personal token").
|
||||
drpc free: archive eth_getCode ok, getLogs small ranges.
|
||||
- eth: publicnode recent ~100k blocks only; drpc free archive getCode, getLogs small ranges.
|
||||
- base: publicnode 1,000-block getLogs with deep history; drpc archive getCode.
|
||||
"""
|
||||
import requests, time, json, threading
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
NODEREAL = 'https://bsc-mainnet.nodereal.io/v1/64a9df0874fb4a93b9d0a3849de012d3'
|
||||
CHAINS = {
|
||||
'bsc': {'id': 56, 'name': 'BNB Chain', 'native': 'BNB', 'explorer': 'https://bscscan.com',
|
||||
'rpcs': ['https://bsc-dataseed.bnbchain.org', 'https://bsc-rpc.publicnode.com', NODEREAL, 'https://bsc-dataseed1.defibit.io', 'https://bsc-dataseed2.ninicoin.io'],
|
||||
'log_providers': [(NODEREAL, 49000), ('https://bsc.rpc.blxrbdn.com', 5000)],
|
||||
'archive_rpcs': [NODEREAL], 'block_secs': 0.45,
|
||||
'tokens': {'USDT': '0x55d398326f99059ff775485246999027b3197955', 'USDC': '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d', 'BUSD': '0xe9e7cea3dcd96aee6a24b63ae6d6e53fba8a9b56'}},
|
||||
'polygon': {'id': 137, 'name': 'Polygon', 'native': 'POL', 'explorer': 'https://polygonscan.com',
|
||||
'rpcs': ['https://polygon-bor-rpc.publicnode.com', 'https://polygon.drpc.org', 'https://1rpc.io/matic'],
|
||||
'log_providers': [('https://polygon-bor-rpc.publicnode.com', 9999), ('https://polygon.drpc.org', 9999)],
|
||||
'archive_rpcs': ['https://polygon.drpc.org', 'https://1rpc.io/matic'], 'block_secs': 2.0,
|
||||
'tokens': {'USDT': '0xc2132d05d31c914a87c6611c10748aeb04b58e8f', 'USDC': '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359', 'USDC.e': '0x2791bca1f2de4661ed88a30c99a7a9449aa84174'}},
|
||||
'eth': {'id': 1, 'name': 'Ethereum', 'native': 'ETH', 'explorer': 'https://etherscan.io',
|
||||
'rpcs': ['https://ethereum-rpc.publicnode.com', 'https://eth.drpc.org', 'https://1rpc.io/eth'],
|
||||
'log_providers': [('https://ethereum-rpc.publicnode.com', 9999), ('https://eth.drpc.org', 9999)],
|
||||
'archive_rpcs': ['https://eth.drpc.org'], 'block_secs': 12.0,
|
||||
'tokens': {'USDT': '0xdac17f958d2ee523a2206206994597c13d831ec7', 'USDC': '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'}},
|
||||
'base': {'id': 8453, 'name': 'Base', 'native': 'ETH', 'explorer': 'https://basescan.org',
|
||||
'rpcs': ['https://base-rpc.publicnode.com', 'https://base.drpc.org', 'https://mainnet.base.org'],
|
||||
'log_providers': [('https://base-rpc.publicnode.com', 999), ('https://base.drpc.org', 999)],
|
||||
'archive_rpcs': ['https://base.drpc.org', 'https://mainnet.base.org'], 'block_secs': 2.0,
|
||||
'tokens': {'USDC': '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', 'USDT': '0xfde4c96c8593536e31f229ea8f37b2ada2699bb2'}},
|
||||
}
|
||||
TRANSFER = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
|
||||
APPROVAL = '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925'
|
||||
S = requests.Session()
|
||||
S.headers.update({'user-agent': 'webworthit-readonly-scan/1'})
|
||||
|
||||
|
||||
class RPC:
|
||||
def __init__(self, chain):
|
||||
self.name = chain; self.c = CHAINS[chain]; self.i = 0; self.calls = 0; self.lock = threading.Lock()
|
||||
|
||||
def _post(self, u, method, params, timeout=60):
|
||||
with self.lock: self.calls += 1
|
||||
return S.post(u, json={'jsonrpc': '2.0', 'id': 1, 'method': method, 'params': params}, timeout=timeout).json()
|
||||
|
||||
def call(self, method, params, tries=6, urls=None):
|
||||
last = None; us = urls or self.c['rpcs']
|
||||
for t in range(tries):
|
||||
u = us[(self.i + t) % len(us)]
|
||||
try:
|
||||
j = self._post(u, method, params)
|
||||
if 'error' in j:
|
||||
last = j['error']
|
||||
# a revert is an answer, not a provider failure
|
||||
if method == 'eth_call' and isinstance(last, dict) and ('revert' in str(last.get('message', '')).lower() or last.get('code') == 3):
|
||||
raise CallReverted(last)
|
||||
time.sleep(0.4); continue
|
||||
return j['result']
|
||||
except CallReverted:
|
||||
raise
|
||||
except Exception as e:
|
||||
last = str(e); time.sleep(0.4)
|
||||
raise Exception('%s failed: %s' % (method, str(last)[:200]))
|
||||
|
||||
def block(self): return int(self.call('eth_blockNumber', []), 16)
|
||||
|
||||
def eth_call(self, to, data, block='latest', frm=None):
|
||||
q = {'to': to, 'data': data}
|
||||
if frm: q['from'] = frm
|
||||
return self.call('eth_call', [q, block])
|
||||
|
||||
def code(self, a, block='latest', urls=None): return self.call('eth_getCode', [a, block], urls=urls)
|
||||
|
||||
def block_ts(self, n): return int(self.call('eth_getBlockByNumber', [hex(n), False])['timestamp'], 16)
|
||||
|
||||
def _chunk(self, q, a, b, deadline):
|
||||
"""One block range through the provider list. Returns (logs, ok)."""
|
||||
provs = self.c['log_providers']
|
||||
# the first provider is the main one: give it most tries (a rate limit clears in seconds); the others are fallbacks
|
||||
order = [0, 0, 0] + list(range(1, len(provs))) + [0, 0]
|
||||
for attempt, pi in enumerate(order):
|
||||
if time.time() > deadline: return [], False
|
||||
u, span = provs[pi]
|
||||
try:
|
||||
out = []
|
||||
for x in range(a, b + 1, span):
|
||||
if time.time() > deadline: raise TimeoutError()
|
||||
y = min(x + span - 1, b)
|
||||
qq = dict(q); qq['fromBlock'] = hex(x); qq['toBlock'] = hex(y)
|
||||
j = self._post(u, 'eth_getLogs', [qq], timeout=45 if pi == 0 else 20)
|
||||
if 'error' in j: raise Exception(j['error'])
|
||||
out += j['result']
|
||||
return out, True
|
||||
except TimeoutError:
|
||||
return [], False
|
||||
except Exception:
|
||||
time.sleep(min(1.5 * (attempt + 1), 6))
|
||||
return [], False
|
||||
|
||||
def logs(self, addr, frm, to, topics=None, threads=3, deadline=None):
|
||||
"""Logs in [frm, to]. Returns (logs, gaps) where gaps = list of [a, b] ranges that could not be read."""
|
||||
deadline = deadline or time.time() + 600
|
||||
span = self.c['log_providers'][0][1]
|
||||
rngs = [(a, min(a + span - 1, to)) for a in range(frm, to + 1, span)]
|
||||
q = {}
|
||||
if addr: q['address'] = addr
|
||||
if topics: q['topics'] = topics
|
||||
out, gaps = [], []
|
||||
with ThreadPoolExecutor(threads) as ex:
|
||||
for (a, b), (r, ok) in zip(rngs, ex.map(lambda r: self._chunk(q, r[0], r[1], deadline), rngs)):
|
||||
out += r
|
||||
if not ok: gaps.append([a, b])
|
||||
out.sort(key=lambda l: (int(l['blockNumber'], 16), int(l['logIndex'], 16)))
|
||||
# merge adjacent gaps
|
||||
m = []
|
||||
for g in gaps:
|
||||
if m and g[0] == m[-1][1] + 1: m[-1][1] = g[1]
|
||||
else: m.append(g)
|
||||
return out, m
|
||||
|
||||
|
||||
class CallReverted(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def addr_topic(a): return '0x' + '0' * 24 + a.lower()[2:]
|
||||
def topic_addr(t): return '0x' + t[-40:]
|
||||
@@ -0,0 +1,53 @@
|
||||
"""Pure-Python Keccak-256 (the Ethereum variant, not NIST SHA3), for function selectors and event topics from a verified ABI.
|
||||
Small inputs only (signatures), so speed does not matter."""
|
||||
RC = [0x0000000000000001, 0x0000000000008082, 0x800000000000808A, 0x8000000080008000, 0x000000000000808B, 0x0000000080000001,
|
||||
0x8000000080008081, 0x8000000000008009, 0x000000000000008A, 0x0000000000000088, 0x0000000080008009, 0x000000008000000A,
|
||||
0x000000008000808B, 0x800000000000008B, 0x8000000000008089, 0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
|
||||
0x000000000000800A, 0x800000008000000A, 0x8000000080008081, 0x8000000000008080, 0x0000000080000001, 0x8000000080008008]
|
||||
ROT = [[0, 36, 3, 41, 18], [1, 44, 10, 45, 2], [62, 6, 43, 15, 61], [28, 55, 25, 21, 56], [27, 20, 39, 8, 14]]
|
||||
M = (1 << 64) - 1
|
||||
|
||||
|
||||
def _rol(x, n): return ((x << n) | (x >> (64 - n))) & M if n else x
|
||||
|
||||
|
||||
def _f(A):
|
||||
for rnd in range(24):
|
||||
C = [A[x][0] ^ A[x][1] ^ A[x][2] ^ A[x][3] ^ A[x][4] for x in range(5)]
|
||||
D = [C[(x - 1) % 5] ^ _rol(C[(x + 1) % 5], 1) for x in range(5)]
|
||||
A = [[A[x][y] ^ D[x] for y in range(5)] for x in range(5)]
|
||||
B = [[0] * 5 for _ in range(5)]
|
||||
for x in range(5):
|
||||
for y in range(5):
|
||||
B[y][(2 * x + 3 * y) % 5] = _rol(A[x][y], ROT[x][y])
|
||||
A = [[B[x][y] ^ ((~B[(x + 1) % 5][y]) & B[(x + 2) % 5][y]) for y in range(5)] for x in range(5)]
|
||||
A[0][0] ^= RC[rnd]
|
||||
return A
|
||||
|
||||
|
||||
def keccak256(data: bytes) -> bytes:
|
||||
rate = 136
|
||||
p = bytearray(data) + b'\x01' + b'\x00' * ((rate - (len(data) + 1) % rate) % rate)
|
||||
p[-1] |= 0x80
|
||||
A = [[0] * 5 for _ in range(5)]
|
||||
for off in range(0, len(p), rate):
|
||||
blk = p[off:off + rate]
|
||||
for i in range(rate // 8):
|
||||
x, y = i % 5, i // 5
|
||||
A[x][y] ^= int.from_bytes(blk[8 * i:8 * i + 8], 'little')
|
||||
A = _f(A)
|
||||
out = b''
|
||||
for i in range(4):
|
||||
x, y = i % 5, i // 5
|
||||
out += A[x][y].to_bytes(8, 'little')
|
||||
return out
|
||||
|
||||
|
||||
def selector(sig): return '0x' + keccak256(sig.encode()).hex()[:8]
|
||||
def topic(sig): return '0x' + keccak256(sig.encode()).hex()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
assert selector('transfer(address,uint256)') == '0xa9059cbb', selector('transfer(address,uint256)')
|
||||
assert topic('Transfer(address,address,uint256)') == '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
|
||||
print('ok')
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
"""Evidence pack + deterministic facts from evidence.json (any contract, any supported chain).
|
||||
Generalised from D:/tmp/wwi-cost/pack.py (which was hard-wired to the 3xSusu raw files).
|
||||
build(E) -> markdown the model reads. facts(E) -> [{tag, text, source}] used when a model report fails the fact check,
|
||||
and shown beside every report. Every number here is computed in code, never by the model."""
|
||||
import json
|
||||
|
||||
|
||||
def f2(x):
|
||||
return '%.2f' % x if isinstance(x, (int, float)) else str(x)
|
||||
|
||||
|
||||
def short(a): return a[:6] + '...' + a[-4:] if a and len(a) == 42 else a
|
||||
|
||||
|
||||
def build(E):
|
||||
o = []; w = o.append
|
||||
ex = E['explorer']
|
||||
w('# Evidence pack: %s contract %s' % (E['chain_name'], E['address']))
|
||||
w('Read at block %s (%s). All reads are public and read-only.\n' % (E['read_at']['block'], E['read_at']['time_ct']))
|
||||
if not E.get('is_contract'):
|
||||
w('## Not a contract\nThe address has no contract code. It is: %s. Native balance %s %s, nonce %s.' % (E.get('kind'), f2(E.get('native_balance')), E['native'], E.get('nonce')))
|
||||
return '\n'.join(o)
|
||||
px = E['proxy']
|
||||
w('## Proxy and control (VERIFIED: storage slots and eth_call)')
|
||||
w('- Type: %s' % px['type'])
|
||||
w('- Upgradeable: %s' % ('yes' if px['upgradeable'] else 'no proxy slot set'))
|
||||
if px.get('impl') or px.get('eip1822'): w('- Implementation now: %s' % (px.get('impl') or px.get('eip1822')))
|
||||
if px.get('admin'): w('- ERC1967 admin slot: %s' % px['admin'])
|
||||
if px.get('beacon'): w('- Beacon: %s' % px['beacon'])
|
||||
w('- Code size: %s bytes (implementation %s bytes)' % (E.get('code_bytes'), E.get('impl_code_bytes')))
|
||||
w('- Role getters read with eth_call: ' + (json.dumps(E.get('roles')) if E.get('roles') else 'none answered'))
|
||||
if E.get('values'): w('- Other zero-argument values: ' + json.dumps(E['values']))
|
||||
if 'paused' in E: w('- paused() now: %s' % E['paused'])
|
||||
w('- Controller wallets:')
|
||||
for a, k in (E.get('controllers') or {}).items(): w(' - %s: %s' % (a, k.get('desc')))
|
||||
if E.get('upgrade_test'):
|
||||
u = E['upgrade_test']
|
||||
w('- Upgrade test (%s):' % u['method'])
|
||||
for a, t in u['results'].items(): w(' - from %s%s: %s' % (a, ' (random address)' if a == u['random_address'] else '', t))
|
||||
w('- Addresses that can upgrade in one transaction: %s' % (', '.join(E.get('can_upgrade') or []) or 'none found'))
|
||||
w('')
|
||||
w('## Source verification (Sourcify)')
|
||||
for k, v in (E.get('verification') or {}).items(): w('- %s: %s%s' % (k, v.get('match') or 'not verified on Sourcify', (' (' + v['name'] + ')') if v.get('name') else ''))
|
||||
w('- Note: %s\n' % E.get('verification_source'))
|
||||
s = E.get('selectors') or {}
|
||||
w('## Functions in the code (%s selectors, %s named; names from %s)' % (s.get('count'), s.get('named'), s.get('names_source')))
|
||||
w(', '.join('%s %s' % (k, v or '?') for k, v in (s.get('map') or {}).items()))
|
||||
w('- Control or custody related functions present: ' + (', '.join(E.get('risky_functions') or []) or 'none matched'))
|
||||
if E.get('abi_functions'): w('- Verified ABI functions: ' + ', '.join(E['abi_functions'][:120]))
|
||||
w('')
|
||||
c = E.get('creation') or {}; win = E.get('window') or {}
|
||||
w('## Deployment and history read')
|
||||
w('- Creation block: %s (%s) source: %s; time %s; tx %s; deployer %s' % (c.get('block'), c.get('block') is not None and 'known' or 'unknown', c.get('source'), c.get('time_ct'), c.get('tx'), c.get('from')))
|
||||
if E.get('age_days') is not None: w('- Contract age: %s days' % E['age_days'])
|
||||
if c.get('addresses_in_input'): w('- Addresses passed in the deployment transaction input: ' + ', '.join(c['addresses_in_input']))
|
||||
w('- Blocks read: %s to %s (%s blocks, from %s). Complete history: %s' % (win.get('from'), win.get('to'), win.get('blocks'), win.get('from_time_ct'), win.get('complete_history')))
|
||||
for g in E.get('gaps') or []: w('- NOT READ (provider failure or time limit): %s, block ranges %s' % (g['what'], g['ranges'][:6]))
|
||||
w('')
|
||||
ev = E.get('events') or {}
|
||||
w('## Events emitted by the contract (%s logs in the window)' % ev.get('total'))
|
||||
for t in ev.get('by_topic', []): w('- %s %s: %d' % (t['topic'][:10], t['name'] or '', t['count']))
|
||||
for nm, d in (E.get('decoded_events') or {}).items():
|
||||
w('- Decoded %s: %d events; sums of number fields (raw integer units; for 18-decimal coins divide by 10^18): %s; top addresses per field: %s; first samples: %s' % (
|
||||
nm, d['count'], json.dumps(d['uint_field_sums_raw']), json.dumps(d['top_addresses']), json.dumps(d['first_samples'])))
|
||||
cn = E.get('counts') or {}
|
||||
w('\n## Precomputed counts (use these, do not recount)')
|
||||
w('- Upgraded events total: %s' % cn.get('upgrade_events_total'))
|
||||
w('- Upgrades AFTER deployment: %s (%s)' % (cn.get('upgrades_after_deployment'), cn.get('upgrades_note')))
|
||||
w('- Paused events: %s; ownership transfers: %s' % (cn.get('pause_events'), cn.get('ownership_transfers')))
|
||||
w('\n## Admin event timeline')
|
||||
for x in E.get('admin_events') or []:
|
||||
w('- %s block %s tx %s %s %s%s%s' % (x.get('time_ct'), x['block'], x['tx'], x['event'], x.get('arg') or '', ' [in the deployment tx]' if x.get('in_creation_tx') else '',
|
||||
(' sent by ' + x['from'] + ' selector ' + x.get('selector', '')) if x.get('from') else ''))
|
||||
w('\n## Money held and moved (token Transfer logs, VERIFIED)')
|
||||
w('- Native %s balance of the contract now: %s' % (E['native'], f2(E.get('native_balance'))))
|
||||
tx = E.get('txs')
|
||||
if tx:
|
||||
w('- Transactions behind the events: %d (read %d, %s). Direct calls to the contract among them: %d; native %s sent in with them: %s (%d calls carried a value).' % (
|
||||
tx['event_txs_total'], tx['read'], tx['read_note'], tx['direct_calls'], E['native'], f2(tx['native_sent_in']), tx['calls_with_native']))
|
||||
w('- Direct calls by function: ' + ', '.join('%s x%d' % (a, n) for a, n in tx['by_function']))
|
||||
w('- Top direct callers: ' + ', '.join('%s x%d' % (a, n) for a, n in tx['top_senders']))
|
||||
w('- Native coin paid OUT by the contract (internal transfers) is not visible in logs and was not traced (UNKNOWN).')
|
||||
if not E.get('money'): w('- No transfers of the stable tokens checked (%s) in the window, and no balance.' % ', '.join(E.get('tokens_checked', [])))
|
||||
for sy, m in (E.get('money') or {}).items():
|
||||
w('### %s (%s, %s decimals)' % (sy, m['token'], m['decimals']))
|
||||
w('- Balance now (balanceOf): %s' % f2(m['balance_now']))
|
||||
w('- In: %d transfers, %s total, from %d wallets' % (m['in_count'], f2(m['in_total']), m['payers']))
|
||||
w('- Out: %d transfers, %s total, to %d wallets' % (m['out_count'], f2(m['out_total']), m['recipients']))
|
||||
w('- In minus out over the window: %s' % f2(m['net_in_minus_out']))
|
||||
w('- Top recipients (address, total, transfers): ' + '; '.join('%s %s x%d' % (a, f2(v), n) for a, v, n in m['top_recipients']))
|
||||
w('- Top payers: ' + '; '.join('%s %s x%d' % (a, f2(v), n) for a, v, n in m['top_payers']))
|
||||
w('- Most common outgoing sizes (size x count): ' + ', '.join('%s x%d' % (a, n) for a, n in m['out_sizes']))
|
||||
if m['daily_in_counts']: w('- Incoming transfers per day (CT): ' + ', '.join('%s:%d' % (d, n) for d, n in m['daily_in_counts']))
|
||||
w('\n## Wallet approvals to this contract (Approval logs + live allowance, VERIFIED)')
|
||||
if not E.get('approvals'): w('- None found in the window.')
|
||||
for sy, a in (E.get('approvals') or {}).items():
|
||||
w('- %s: %d approval events, %d approving wallets (%d read), %d with a live allowance, %d unlimited, total that could be pulled from wallets right now %s' % (
|
||||
sy, a['approval_events'], a['approving_wallets'], a['read'], a['live_allowances'], a['unlimited'], f2(a['pullable_now'])))
|
||||
p = E.get('positions')
|
||||
if p:
|
||||
w('\n## Positions stored in the contract (%s)' % p['method'])
|
||||
w('- %s = %s; owners read %s; distinct owners %s' % (p['count_function'], p['count'], p['read'], p['owners']))
|
||||
w('- Top owners (address, positions): ' + '; '.join('%s %d' % (a, n) for a, n in p['top_owners']))
|
||||
w('\n## Wallet profiles (role holders, deployer, deployment-input addresses, top recipients)')
|
||||
for a, k in (E.get('wallets') or {}).items():
|
||||
w('- %s [%s] %s, nonce %s, native %s, received from contract %s%s' % (a, ', '.join(k.get('labels') or []) or 'top recipient', k.get('desc'), k.get('nonce'), f2(k.get('native_balance')),
|
||||
json.dumps(k.get('received_from_contract') or {}), (', positions owned %s' % k['positions_owned']) if 'positions_owned' in k else ''))
|
||||
w('\n## Notes')
|
||||
for n in E.get('notes') or []: w('- ' + n)
|
||||
return '\n'.join(o)
|
||||
|
||||
|
||||
def facts(E):
|
||||
F = []; ex = E['explorer']
|
||||
add = lambda tag, text, src=None: F.append({'tag': tag, 'text': text, 'source': src})
|
||||
A = E['address']
|
||||
if not E.get('is_contract'):
|
||||
add('VERIFIED', 'This address has no contract code: it is %s.' % E.get('kind'), ex + '/address/' + A)
|
||||
return F
|
||||
px = E['proxy']
|
||||
if px['upgradeable']:
|
||||
add('VERIFIED', 'The contract is an upgradeable proxy (%s). Its code can be replaced.' % px['type'], ex + '/address/' + A)
|
||||
else:
|
||||
add('VERIFIED', 'No upgradeable-proxy slot is set: %s.' % px['type'], ex + '/address/' + A)
|
||||
for a in E.get('can_upgrade') or []:
|
||||
k = (E.get('controllers') or {}).get(a) or {}
|
||||
add('VERIFIED', 'Address %s can upgrade the code in one transaction (simulated with eth_call). It is a %s.' % (a, k.get('desc', 'wallet')), ex + '/address/' + a)
|
||||
cn = E.get('counts') or {}
|
||||
if cn.get('upgrades_after_deployment') is not None and px['upgradeable']:
|
||||
add('VERIFIED', 'Upgrades after deployment: %s.' % cn['upgrades_after_deployment'], None)
|
||||
for x in [y for y in E.get('admin_events') or [] if y['event'] == 'Upgraded(address)' and not y.get('in_creation_tx')][:6]:
|
||||
add('VERIFIED', 'Upgrade on %s to implementation %s.' % (x.get('time_ct'), x.get('arg')), ex + '/tx/' + x['tx'])
|
||||
for k, v in (E.get('verification') or {}).items():
|
||||
add('VERIFIED' if v.get('match') else 'UNKNOWN', '%s source: %s on Sourcify.' % (k.capitalize(), 'verified (' + v['match'] + ')' if v.get('match') else 'not verified'), None)
|
||||
for fn, a in (E.get('roles') or {}).items():
|
||||
k = (E.get('controllers') or {}).get(a) or {}
|
||||
add('VERIFIED', '%s returns %s (%s).' % (fn, a, k.get('desc', '')), ex + '/address/' + a)
|
||||
if 'paused' in E: add('VERIFIED', 'paused() is %s now.' % E['paused'], None)
|
||||
if E.get('risky_functions'): add('INFERRED', 'Functions related to control or custody found in the code: %s.' % ', '.join(E['risky_functions'][:20]), None)
|
||||
add('VERIFIED', 'Native %s balance now: %s.' % (E['native'], f2(E.get('native_balance'))), ex + '/address/' + A)
|
||||
for sy, m in (E.get('money') or {}).items():
|
||||
add('VERIFIED', '%s balance now: %s. Received %s in %d transfers; sent out %s in %d transfers (blocks %s to %s).' % (
|
||||
sy, f2(m['balance_now']), f2(m['in_total']), m['in_count'], f2(m['out_total']), m['out_count'], E['window']['from'], E['window']['to']), ex + '/address/' + A)
|
||||
for sy, a in (E.get('approvals') or {}).items():
|
||||
add('VERIFIED', '%s approvals: %d wallets approved this contract; %d unlimited; %s could be pulled from wallets right now.' % (sy, a['approving_wallets'], a['unlimited'], f2(a['pullable_now'])), None)
|
||||
p = E.get('positions')
|
||||
if p and p['top_owners']:
|
||||
a, n = p['top_owners'][0]
|
||||
lab = ', '.join(((E.get('wallets') or {}).get(a) or {}).get('labels') or [])
|
||||
add('INFERRED', 'Top position owner %s%s holds %d of %d positions.' % (a, (' (' + lab + ')') if lab else '', n, p['count']), ex + '/address/' + a)
|
||||
win = E.get('window') or {}
|
||||
add('VERIFIED', 'History read: blocks %s to %s%s.' % (win.get('from'), win.get('to'), ' (complete since deployment)' if win.get('complete_history') else ' (partial window)'), None)
|
||||
for g in E.get('gaps') or []: add('UNKNOWN', 'Not read: %s in %d block ranges (provider limit or time cap).' % (g['what'], len(g['ranges'])), None)
|
||||
return F
|
||||
@@ -0,0 +1,72 @@
|
||||
# Contract risk scoring rubric (draft v1, from the 3xSusu review 2026-11-16)
|
||||
|
||||
Score each category 0 to 10 (10 = worst), then weight. A single "critical" red flag caps the overall
|
||||
grade at High risk whatever the total. Every score must cite evidence tagged VERIFIED (on chain, tx/block),
|
||||
INFERRED (bytecode/decompile/simulation) or UNKNOWN. Unknown counts against the project: if the team
|
||||
hid it, assume the worse case and say so.
|
||||
|
||||
## 1. Control and upgradeability (weight 25)
|
||||
Raises risk:
|
||||
- Upgradeable proxy (UUPS or Transparent) whose upgrade right sits with a single EOA (critical)
|
||||
- Upgrades already used after launch, especially after money arrived (each one is a reset of everything audited)
|
||||
- No timelock, no multisig, no on-chain delay or announcement event before upgrade
|
||||
- Implementation source unverified (critical when combined with upgradeability)
|
||||
- Owner can pause the functions members use to get money out (refund/claim/withdraw)
|
||||
- Owner can change fee splits, recipients, limits or token addresses after launch
|
||||
- Controller wallets are EIP-7702 delegated EOAs (code you also need to review)
|
||||
Lowers risk:
|
||||
- Immutable contract, or ownership renounced (verify `owner()` = 0 and no other role can upgrade)
|
||||
- Upgrade/admin held by a Safe with a meaningful threshold plus a timelock of at least 48 h
|
||||
- Verified source matching the deployed bytecode
|
||||
|
||||
## 2. Custody and exit paths (weight 25)
|
||||
List every path by which tokens can leave the contract and who can trigger each. Raises risk:
|
||||
- Any owner/admin sweep, rescue, withdraw, setRecipient or arbitrary-call function (critical)
|
||||
- Members' unlimited token approvals to an upgradeable spender (the code behind the spender can change)
|
||||
- Refund/claim promises that the reserve cannot cover (compare liability vs balance)
|
||||
- Member balances held as a non-transferable internal token that can only be "spent" back into the scheme
|
||||
Lowers risk:
|
||||
- Members can withdraw their own principal at any time, unpausable, without a gate
|
||||
- Exact accounting: outflows = sum of rule-based splits, no unexplained outflows (check with tokenflow)
|
||||
|
||||
## 3. Economic design (weight 20)
|
||||
Raises risk:
|
||||
- Returns funded only by later entrants (matrix/cycler/"3x"): payouts trigger only on new entries
|
||||
- Advertised multiple (e.g. "3x") needs N later entries per position; compute N and the growth needed
|
||||
- Fallback/refund funded by a small slice per entry (e.g. $1 per $35) while the liability grows per position
|
||||
- "Company buy" / system buyback positions owned by an operator wallet that also collects payouts
|
||||
Lowers risk:
|
||||
- An external revenue source exists and is visible on chain
|
||||
- Reserve fully covers stated refund obligations at today's numbers
|
||||
|
||||
## 4. Insider flows (weight 15)
|
||||
Raises risk:
|
||||
- Share of outflows going to deployer-configured wallets (platform, admin, buyback, default referrer)
|
||||
- Insider wallets funding each other or a shared sink, or cycling money back in as "entries"
|
||||
- Insider wallets sending to exchanges/bridges/mixers soon after receipt (label only when confirmed)
|
||||
- Operator-owned positions inflating the entry count or "activity"
|
||||
Lowers risk:
|
||||
- Fixed, small, disclosed fees to a single published treasury
|
||||
|
||||
## 5. Disclosure vs code (weight 10)
|
||||
Raises risk:
|
||||
- Claims of "ownerless", "decentralized", "cannot be changed" while an owner can upgrade (critical)
|
||||
- Guarantee-like language (refund 100% + 50%) that the code meets only partly or in a non-cash token
|
||||
- No verified source, no audit, anonymous team
|
||||
Lowers risk:
|
||||
- Docs match code paths, amounts and conditions
|
||||
|
||||
## 6. Trajectory (weight 5)
|
||||
- Daily/weekly inflow trend: growing, flat, slowing. In a recruitment-funded design, slowing inflow means
|
||||
later entrants' positions stall and refund liabilities mature.
|
||||
- Age of the contract versus refund windows (when do the first obligations fall due?)
|
||||
|
||||
## Red flags that each force "High risk"
|
||||
1. Single-EOA upgrade or sweep right over member funds
|
||||
2. Unverified implementation behind an upgradeable proxy
|
||||
3. "Ownerless/decentralized" marketing while an owner key controls upgrades
|
||||
4. Payouts that exist only when new money enters
|
||||
5. Refund/guarantee liability larger than the reserve that backs it
|
||||
|
||||
## Grade bands
|
||||
0 to 25 Low, 26 to 50 Moderate, 51 to 75 Elevated, 76 to 100 High (or forced High by a red flag).
|
||||
+593
@@ -0,0 +1,593 @@
|
||||
"""WebWorthIt chain scan: one read-only pass over a contract, producing evidence.json (structured facts with sources)
|
||||
and pack.md (the evidence pack the model reads). Generalised from the 3xSusu review tools (D:/tmp/bsc-audit/tools).
|
||||
|
||||
Usage: python3 scan.py CHAIN ADDRESS OUTDIR [--budget SECONDS] [--hint-abi FILE]
|
||||
Prints one JSON progress line per step on stdout ({"step": ...}) and a final {"done": true}.
|
||||
|
||||
READ-ONLY: every RPC used is a read (eth_call, eth_getLogs, eth_getCode, eth_getStorageAt, eth_getBalance, ...).
|
||||
No key, no signing, no transaction is ever sent. eth_call simulations change nothing on chain.
|
||||
|
||||
Deterministic counts (the model never counts): upgrades after deployment, events per type, transfers in/out, totals,
|
||||
balances, positions per owner, approvals. Every number in pack.md comes from here.
|
||||
"""
|
||||
import sys, os, json, time, re, collections, datetime, random
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import requests
|
||||
from chainrpc import RPC, CHAINS, TRANSFER, APPROVAL, addr_topic, topic_addr, CallReverted
|
||||
import keccak
|
||||
|
||||
try:
|
||||
from zoneinfo import ZoneInfo
|
||||
CT = ZoneInfo('America/Chicago')
|
||||
except Exception:
|
||||
CT = None
|
||||
|
||||
SLOTS = {'impl': '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc',
|
||||
'admin': '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103',
|
||||
'beacon': '0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50',
|
||||
'eip1822': '0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7'}
|
||||
EVENTS = {
|
||||
'0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b': 'Upgraded(address)',
|
||||
'0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f': 'AdminChanged(address,address)',
|
||||
'0x1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e': 'BeaconUpgraded(address)',
|
||||
'0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0': 'OwnershipTransferred(address,address)',
|
||||
'0x38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e22700': 'OwnershipTransferStarted(address,address)',
|
||||
'0x62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258': 'Paused(address)',
|
||||
'0x5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa': 'Unpaused(address)',
|
||||
'0xc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2': 'Initialized(uint64)',
|
||||
'0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498': 'Initialized(uint8)',
|
||||
'0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d': 'RoleGranted(bytes32,address,address)',
|
||||
'0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b': 'RoleRevoked(bytes32,address,address)',
|
||||
TRANSFER: 'Transfer(address,address,uint256)', APPROVAL: 'Approval(address,address,uint256)',
|
||||
}
|
||||
ADMIN_EVENTS = {k for k, v in EVENTS.items() if not v.startswith(('Transfer', 'Approval'))}
|
||||
UPGRADED = '0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b'
|
||||
# selectors whose presence matters for custody / control (names from public signature databases)
|
||||
RISKY = re.compile(r'^(upgradeTo|upgradeToAndCall|withdraw|emergencyWithdraw|sweep|rescue|recover|drain|skim|setFee|setFees|setTax|setRouter|'
|
||||
r'setToken|setTreasury|setWallet|setRecipient|setReceiver|setPlatform|setAdmin|setOwner|transferOwnership|renounceOwnership|'
|
||||
r'pause|unpause|mint|burn|blacklist|addBlacklist|setBlacklist|execute|multicall|call|delegatecall|setImplementation|'
|
||||
r'changeAdmin|grantRole|revokeRole|setOperator|setManager|setSplit|setPrice|setLimit|setMax|withdrawAll|withdrawTokens|'
|
||||
r'adminWithdraw|ownerWithdraw|emergency|migrate|setContract|setVault|query)', re.I)
|
||||
POSITION_PAIRS = [('totalEntries()', 'entries(uint256)'), ('totalPositions()', 'positions(uint256)'), ('positionCount()', 'positions(uint256)'),
|
||||
('nextPositionId()', 'positions(uint256)'), ('totalSlots()', 'slots(uint256)'), ('totalNodes()', 'nodes(uint256)'),
|
||||
('totalDeposits()', 'deposits(uint256)'), ('depositCount()', 'deposits(uint256)')]
|
||||
|
||||
|
||||
KNOWN_SEL = {'owner()': '0x8da5cb5b', 'admin()': '0xf851a440', 'getOwner()': '0x893d20e8', 'paused()': '0x5c975abb',
|
||||
'totalEntries()': '0x7fef036e', 'entries(uint256)': '0xb30906d4', 'proxiableUUID()': '0x52d1902d',
|
||||
'upgradeToAndCall(address,bytes)': '0x4f1ef286', 'decimals()': '0x313ce567', 'balanceOf(address)': '0x70a08231',
|
||||
'allowance(address,address)': '0xdd62ed3e', 'getThreshold()': '0xe75235b8', 'getOwners()': '0xa0e67e2b',
|
||||
'pendingOwner()': '0xe30c3978', 'implementation()': '0x5c60da1b', 'symbol()': '0x95d89b41', 'name()': '0x06fdde03'}
|
||||
|
||||
T0 = time.time()
|
||||
|
||||
|
||||
def step(name, **kw):
|
||||
print(json.dumps(dict({'step': name, 't': round(time.time() - T0, 1)}, **kw)), flush=True)
|
||||
|
||||
|
||||
def ct(ts):
|
||||
d = datetime.datetime.fromtimestamp(ts, CT) if CT else datetime.datetime.utcfromtimestamp(ts)
|
||||
return d.strftime('%Y-%m-%d %H:%M ') + (d.tzname() if CT else 'UTC')
|
||||
|
||||
|
||||
def addr_of(w):
|
||||
if not w or w == '0x' or len(w) < 42: return None
|
||||
try:
|
||||
v = int(w, 16)
|
||||
except Exception:
|
||||
return None
|
||||
if v == 0 or v >= 2 ** 160: return None
|
||||
return '0x' + w[-40:].lower()
|
||||
|
||||
|
||||
def words(hexdata):
|
||||
h = hexdata[2:] if hexdata.startswith('0x') else hexdata
|
||||
return [h[i:i + 64] for i in range(0, len(h) - len(h) % 64, 64)]
|
||||
|
||||
|
||||
def disasm_push(code):
|
||||
b = bytes.fromhex(code[2:] if code.startswith('0x') else code); i = 0; out = []
|
||||
while i < len(b):
|
||||
op = b[i]
|
||||
if 0x60 <= op <= 0x7f:
|
||||
n = op - 0x5f; out.append((n, b[i + 1:i + 1 + n].hex(), b[i + 1 + n] if i + 1 + n < len(b) else None)); i += 1 + n
|
||||
else:
|
||||
i += 1
|
||||
return out
|
||||
|
||||
|
||||
def lookup_selectors(sels):
|
||||
res = {}
|
||||
try:
|
||||
for c in range(0, len(sels), 40):
|
||||
chunk = sels[c:c + 40]
|
||||
j = requests.get('https://api.openchain.xyz/signature-database/v1/lookup', params={'function': ','.join(chunk), 'filter': 'true'}, timeout=25).json()
|
||||
for h, v in (j.get('result', {}).get('function') or {}).items():
|
||||
if v: res[h] = [x['name'] for x in v]
|
||||
except Exception:
|
||||
pass
|
||||
missing = [s for s in sels if s not in res]
|
||||
for s in missing[:40]:
|
||||
try:
|
||||
j = requests.get('https://www.4byte.directory/api/v1/signatures/', params={'hex_signature': s}, timeout=15).json()
|
||||
if j.get('results'): res[s] = [x['text_signature'] for x in j['results']][:3]
|
||||
except Exception:
|
||||
pass
|
||||
return res
|
||||
|
||||
|
||||
def sourcify(chain_id, a):
|
||||
try:
|
||||
r = requests.get('https://sourcify.dev/server/v2/contract/%d/%s?fields=deployment,abi,compilation' % (chain_id, a), timeout=25)
|
||||
if r.status_code == 200:
|
||||
j = r.json(); comp = j.get('compilation') or {}
|
||||
return {'match': j.get('match'), 'deployment': j.get('deployment'), 'abi': j.get('abi'), 'name': comp.get('name'), 'verifiedAt': j.get('verifiedAt')}
|
||||
return {'match': None, 'status': r.status_code}
|
||||
except Exception as e:
|
||||
return {'match': None, 'error': str(e)[:120]}
|
||||
|
||||
|
||||
def abi_sig(f):
|
||||
def t(i):
|
||||
if i.get('type', '').startswith('tuple'):
|
||||
return '(' + ','.join(t(c) for c in i.get('components', [])) + ')' + i['type'][5:]
|
||||
return i.get('type')
|
||||
return '%s(%s)' % (f['name'], ','.join(t(i) for i in f.get('inputs', [])))
|
||||
|
||||
|
||||
def main():
|
||||
chain, A, OUT = sys.argv[1], sys.argv[2].lower(), sys.argv[3]
|
||||
budget = 420
|
||||
if '--budget' in sys.argv: budget = int(sys.argv[sys.argv.index('--budget') + 1])
|
||||
hint_abi = []
|
||||
if '--hint-abi' in sys.argv:
|
||||
try: hint_abi = json.load(open(sys.argv[sys.argv.index('--hint-abi') + 1]))
|
||||
except Exception: hint_abi = []
|
||||
os.makedirs(OUT, exist_ok=True)
|
||||
deadline = T0 + budget
|
||||
r = RPC(chain); C = CHAINS[chain]
|
||||
E = {'chain': chain, 'chain_name': C['name'], 'address': A, 'explorer': C['explorer'], 'native': C['native'], 'notes': [], 'gaps': []}
|
||||
E['notes'].append('All data read with public JSON-RPC nodes and public signature/verification databases. Read-only: no transaction was sent.')
|
||||
|
||||
# ---- basics
|
||||
step('basics')
|
||||
latest = r.block(); latest_ts = r.block_ts(latest)
|
||||
E['read_at'] = {'block': latest, 'time_ct': ct(latest_ts), 'ts': latest_ts}
|
||||
code = r.code(A)
|
||||
if len(code) <= 2 or code.startswith('0xef0100'):
|
||||
E['is_contract'] = False
|
||||
E['kind'] = 'EOA+7702-delegation' if code.startswith('0xef0100') else 'EOA (a personal wallet, no contract code)'
|
||||
E['native_balance'] = int(r.call('eth_getBalance', [A, 'latest']), 16) / 1e18
|
||||
E['nonce'] = int(r.call('eth_getTransactionCount', [A, 'latest']), 16)
|
||||
finish(E, OUT); return
|
||||
E['is_contract'] = True; E['code_bytes'] = (len(code) - 2) // 2
|
||||
E['native_balance'] = int(r.call('eth_getBalance', [A, 'latest']), 16) / 1e18
|
||||
|
||||
# ---- proxy
|
||||
step('proxy')
|
||||
px = {k: addr_of(r.call('eth_getStorageAt', [A, s, 'latest'])) for k, s in SLOTS.items()}
|
||||
impl = px['impl'] or px['eip1822']
|
||||
if px['beacon']:
|
||||
px['type'] = 'beacon proxy'
|
||||
try: impl = addr_of(r.eth_call(px['beacon'], '0x5c60da1b'))
|
||||
except Exception: pass
|
||||
elif impl:
|
||||
try:
|
||||
r.eth_call(impl, '0x52d1902d'); uups = True
|
||||
except Exception:
|
||||
uups = False
|
||||
px['type'] = 'UUPS proxy (the upgrade function lives in the implementation)' if uups else ('Transparent proxy (upgrades through the admin slot holder)' if px['admin'] else 'ERC1967 proxy')
|
||||
else:
|
||||
px['type'] = 'not a standard upgradeable proxy (no ERC1967 / EIP-1822 / beacon slot set)'
|
||||
px['upgradeable'] = bool(impl)
|
||||
E['proxy'] = px
|
||||
code_target = impl or A
|
||||
tcode = r.code(code_target) if impl else code
|
||||
E['impl_code_bytes'] = (len(tcode) - 2) // 2
|
||||
|
||||
# ---- verification
|
||||
step('verification')
|
||||
ver = {'contract': sourcify(C['id'], A)}
|
||||
if impl: ver['implementation'] = sourcify(C['id'], impl)
|
||||
E['verification'] = {k: {kk: v.get(kk) for kk in ('match', 'name', 'verifiedAt')} for k, v in ver.items()}
|
||||
E['verification_source'] = 'Sourcify (sourcify.dev). A contract verified only on a block explorer may show as not found here.'
|
||||
abi = (ver.get('implementation') or {}).get('abi') or (ver['contract'] or {}).get('abi') or []
|
||||
abi_src = 'verified source (Sourcify)' if abi else None
|
||||
if not abi and hint_abi:
|
||||
abi = hint_abi; abi_src = 'human-readable ABI found in the project website code (INFERRED)'
|
||||
|
||||
# ---- selectors
|
||||
step('selectors')
|
||||
P = disasm_push(tcode)
|
||||
sels = sorted({'0x' + v for (n, v, nx) in P if n == 4 and nx == 0x14})
|
||||
abi_fns = [f for f in abi if isinstance(f, dict) and f.get('type') == 'function' and f.get('name')]
|
||||
abi_sigs = {abi_sig(f) for f in abi_fns}
|
||||
abi_sel = {keccak.selector(abi_sig(f)): abi_sig(f) for f in abi_fns}
|
||||
outs = {abi_sig(f): [o.get('type') for o in f.get('outputs') or []] for f in abi_fns}
|
||||
for f in abi:
|
||||
if isinstance(f, dict) and f.get('type') == 'event' and f.get('name'):
|
||||
EVENTS.setdefault(keccak.topic(abi_sig(f)), abi_sig(f))
|
||||
missing = [s for s in sels if s not in abi_sel]
|
||||
looked = lookup_selectors(missing) if missing else {}
|
||||
selmap = {s: abi_sel.get(s) or (looked.get(s) or [None])[0] for s in sels}
|
||||
E['selectors'] = {'count': len(sels), 'named': sum(1 for v in selmap.values() if v), 'map': selmap, 'abi_source': abi_src,
|
||||
'names_source': ('verified ABI' if abi_src and 'Sourcify' in abi_src else 'openchain.xyz / 4byte.directory signature databases (a name is a public guess from the selector, INFERRED)')}
|
||||
risky = sorted({v for v in selmap.values() if v and RISKY.match(v)})
|
||||
E['risky_functions'] = risky
|
||||
if abi:
|
||||
E['abi_functions'] = sorted(abi_sigs)[:200]
|
||||
|
||||
# ---- role getters: every zero-argument named function, read with eth_call (read-only)
|
||||
step('roles')
|
||||
zero = sorted({v for v in selmap.values() if v and v.endswith('()')} | {'owner()', 'admin()', 'getOwner()', 'paused()', 'pendingOwner()'})
|
||||
sel_of = {v: s for s, v in selmap.items() if v}
|
||||
sel_of.update({k: v for k, v in KNOWN_SEL.items() if k not in sel_of})
|
||||
roles, values = {}, {}
|
||||
skip = re.compile(r'^(renounceOwnership|pause|unpause|refund\(\)$|claim|withdraw|execute|buy|purchase|deposit|stake|unstake|harvest|compound|sync|skim|mint|burn)', re.I)
|
||||
for fn in zero[:60]:
|
||||
s = sel_of.get(fn)
|
||||
if not s or skip.match(fn) and fn not in ('refund()',): continue
|
||||
try:
|
||||
v = r.eth_call(A, s)
|
||||
except Exception:
|
||||
continue
|
||||
if not v or v == '0x': continue
|
||||
if len(v) == 66:
|
||||
a = addr_of(v)
|
||||
typed = outs.get(fn)
|
||||
is_addr = (typed == ['address']) if typed else (a is not None and int(v, 16) > 2 ** 120)
|
||||
if a and is_addr:
|
||||
roles[fn] = a
|
||||
else:
|
||||
iv = int(v, 16)
|
||||
if fn == 'paused()': values[fn] = bool(iv)
|
||||
elif iv < 10 ** 30: values[fn] = iv
|
||||
E['roles'] = roles; E['values'] = values
|
||||
if 'paused()' in values: E['paused'] = values['paused()']
|
||||
|
||||
# ---- controllers: EOA / contract / Safe
|
||||
step('controllers')
|
||||
ctl = {}
|
||||
for a in sorted(set(list(roles.values()) + [x for x in [px['admin']] if x])):
|
||||
ctl[a] = kind_of(r, a)
|
||||
# transparent proxy: the admin slot holder is usually a ProxyAdmin contract; read its owner
|
||||
if px['admin'] and ctl.get(px['admin'], {}).get('type') == 'contract':
|
||||
try:
|
||||
o = addr_of(r.eth_call(px['admin'], '0x8da5cb5b'))
|
||||
if o: roles['proxy admin owner()'] = o; ctl[o] = kind_of(r, o)
|
||||
except Exception:
|
||||
pass
|
||||
E['controllers'] = ctl
|
||||
|
||||
# ---- who can upgrade: read-only eth_call of upgradeToAndCall(current impl, "") from each role holder and a random address
|
||||
if impl and E['proxy']['type'].startswith('UUPS'):
|
||||
step('upgrade_test')
|
||||
data = '0x4f1ef286' + addr_topic(impl)[2:] + '0' * 62 + '40' + '0' * 64
|
||||
tests = {}
|
||||
cands = list(dict.fromkeys(list(roles.values())))
|
||||
rnd = '0x' + ''.join(random.choice('0123456789abcdef') for _ in range(40))
|
||||
for who in cands[:8] + [rnd]:
|
||||
try:
|
||||
r.call('eth_call', [{'from': who, 'to': A, 'data': data}, 'latest'], tries=3)
|
||||
tests[who] = 'succeeds (this address can upgrade)'
|
||||
except CallReverted as e:
|
||||
msg = e.args[0] if e.args else {}
|
||||
tests[who] = 'reverts ' + str((msg.get('data') if isinstance(msg, dict) else '') or (msg.get('message') if isinstance(msg, dict) else msg))[:80]
|
||||
except Exception as e:
|
||||
tests[who] = 'no answer'
|
||||
E['upgrade_test'] = {'method': 'eth_call (simulation, nothing sent) of upgradeToAndCall(current implementation, empty data)', 'random_address': rnd, 'results': tests}
|
||||
E['can_upgrade'] = [w for w, t in tests.items() if t.startswith('succeeds') and w != rnd]
|
||||
if tests.get(rnd, '').startswith('succeeds'): E['notes'].append('A random address could call upgradeToAndCall in simulation: the check is not conclusive for this contract.')
|
||||
|
||||
# ---- creation block
|
||||
step('creation')
|
||||
dep = (ver['contract'] or {}).get('deployment') or {}
|
||||
created = None; creation_tx = None; creation_src = None
|
||||
if dep.get('blockNumber'):
|
||||
created = int(dep['blockNumber']); creation_tx = (dep.get('transactionHash') or '').lower() or None; creation_src = 'Sourcify deployment record'
|
||||
else:
|
||||
created = find_creation(r, A, latest)
|
||||
if created is not None: creation_src = 'binary search of eth_getCode on an archive node'
|
||||
E['creation'] = {'block': created, 'source': creation_src}
|
||||
if created is not None:
|
||||
try: E['creation']['time_ct'] = ct(r.block_ts(created))
|
||||
except Exception: pass
|
||||
E['age_days'] = round((latest_ts - r.block_ts(created)) / 86400, 1) if created else None
|
||||
|
||||
# ---- log window
|
||||
span0 = C['log_providers'][0][1]
|
||||
cap_chunks = 260 # per filter
|
||||
frm = created if created is not None else max(0, latest - span0 * 40)
|
||||
if latest - frm + 1 > span0 * cap_chunks:
|
||||
E['notes'].append('History is longer than one scan covers: only the latest %d blocks were read.' % (span0 * cap_chunks))
|
||||
frm = latest - span0 * cap_chunks + 1
|
||||
E['window'] = {'from': frm, 'to': latest, 'blocks': latest - frm + 1, 'complete_history': created is not None and frm == created}
|
||||
try: E['window']['from_time_ct'] = ct(r.block_ts(frm))
|
||||
except Exception: pass
|
||||
|
||||
# ---- contract logs
|
||||
step('logs', blocks=latest - frm + 1)
|
||||
L, gaps = r.logs(A, frm, latest, threads=2, deadline=T0 + budget * 0.32)
|
||||
toks = C['tokens']; tlist = list(toks.values()); E['tokens_checked'] = list(toks.keys())
|
||||
qin = [[TRANSFER, APPROVAL], None, addr_topic(A)]; qout = [TRANSFER, addr_topic(A)]
|
||||
inn, g1 = r.logs(tlist, frm, latest, qin, threads=2, deadline=max(time.time() + 30, T0 + budget * 0.52))
|
||||
out, g2 = r.logs(tlist, frm, latest, qout, threads=2, deadline=max(time.time() + 30, T0 + budget * 0.72))
|
||||
# second pass over every range that failed (rate limits clear in seconds), with what is left of the budget
|
||||
passes = 0
|
||||
while (gaps or g1 or g2) and time.time() < T0 + budget * 0.88 and passes < 4:
|
||||
passes += 1; step('retry_gaps', ranges=len(gaps) + len(g1) + len(g2))
|
||||
dl = T0 + budget * 0.88
|
||||
def refill(addr, topics, gs, have):
|
||||
left = []
|
||||
for a, b in gs:
|
||||
more, g = r.logs(addr, a, b, topics, threads=1, deadline=dl); have += more; left += g
|
||||
return left
|
||||
gaps = refill(A, None, gaps, L); g1 = refill(tlist, qin, g1, inn); g2 = refill(tlist, qout, g2, out)
|
||||
for lst in (L, inn, out):
|
||||
seen = set(); uniq = []
|
||||
for l in lst:
|
||||
k = (l['transactionHash'], l['logIndex'])
|
||||
if k not in seen: seen.add(k); uniq.append(l)
|
||||
uniq.sort(key=lambda l: (int(l['blockNumber'], 16), int(l['logIndex'], 16))); lst[:] = uniq
|
||||
if gaps: E['gaps'].append({'what': 'contract events', 'ranges': gaps})
|
||||
if g1: E['gaps'].append({'what': 'token transfers in + approvals', 'ranges': g1})
|
||||
if g2: E['gaps'].append({'what': 'token transfers out', 'ranges': g2})
|
||||
tc = collections.Counter(l['topics'][0] if l['topics'] else 'anonymous' for l in L)
|
||||
E['events'] = {'total': len(L), 'by_topic': [{'topic': t, 'name': EVENTS.get(t), 'count': n} for t, n in tc.most_common(30)]}
|
||||
if not creation_tx and created is not None:
|
||||
first = [l for l in L if int(l['blockNumber'], 16) == created]
|
||||
if first: creation_tx = first[0]['transactionHash'].lower(); E['creation']['tx_source'] = 'transaction of the first event in the creation block'
|
||||
else:
|
||||
try:
|
||||
recs = r.call('eth_getBlockReceipts', [hex(created)], tries=3)
|
||||
for rc in recs or []:
|
||||
if (rc.get('contractAddress') or '').lower() == A: creation_tx = rc['transactionHash'].lower(); E['creation']['tx_source'] = 'block receipts'; break
|
||||
except Exception:
|
||||
pass
|
||||
E['creation']['tx'] = creation_tx
|
||||
tsc = {}
|
||||
def bts(n):
|
||||
if n not in tsc:
|
||||
try: tsc[n] = r.block_ts(n)
|
||||
except Exception: tsc[n] = None
|
||||
return tsc[n]
|
||||
adm = []
|
||||
for l in L:
|
||||
if l['topics'] and l['topics'][0] in ADMIN_EVENTS:
|
||||
b = int(l['blockNumber'], 16)
|
||||
ts = int(l['blockTimestamp'], 16) if l.get('blockTimestamp') else bts(b)
|
||||
arg = topic_addr(l['topics'][1]) if len(l['topics']) > 1 and l['topics'][1][2:26] == '0' * 24 else (topic_addr(l['data']) if l['topics'][0] == UPGRADED and l['data'] != '0x' else None)
|
||||
if l['topics'][0] == '0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0' and len(l['topics']) > 2:
|
||||
arg = '%s -> %s' % (topic_addr(l['topics'][1]), topic_addr(l['topics'][2]))
|
||||
adm.append({'event': EVENTS[l['topics'][0]], 'block': b, 'time_ct': ct(ts) if ts else None, 'tx': l['transactionHash'].lower(), 'arg': arg,
|
||||
'in_creation_tx': bool(creation_tx and l['transactionHash'].lower() == creation_tx)})
|
||||
E['admin_events'] = adm[:80]
|
||||
# decode the contract's own events with the verified ABI (static fields only): counts, sums of number fields, top addresses
|
||||
dec_ev = {}
|
||||
abi_events = {keccak.topic(abi_sig(f)): f for f in abi if isinstance(f, dict) and f.get('type') == 'event' and f.get('name') and not f.get('anonymous')}
|
||||
for t, f in abi_events.items():
|
||||
if t in ADMIN_EVENTS or t in (TRANSFER, APPROVAL): continue
|
||||
ls = [l for l in L if l['topics'] and l['topics'][0] == t]
|
||||
if not ls: continue
|
||||
sums = collections.Counter(); addrs = collections.defaultdict(collections.Counter); samples = []
|
||||
for l in ls:
|
||||
ti = 1; dw = words(l['data']); di = 0; row = {}
|
||||
for inp in f.get('inputs', []):
|
||||
typ = inp.get('type'); nm = inp.get('name') or typ
|
||||
if inp.get('indexed'):
|
||||
raw = l['topics'][ti] if ti < len(l['topics']) else None; ti += 1
|
||||
else:
|
||||
if typ in ('string', 'bytes') or typ.endswith(']') or typ.startswith('tuple'):
|
||||
di += 1; continue
|
||||
raw = '0x' + dw[di] if di < len(dw) else None; di += 1
|
||||
if raw is None: continue
|
||||
if typ == 'address': v = topic_addr(raw); addrs[nm][v] += 1
|
||||
elif typ.startswith('uint'): v = int(raw, 16); sums[nm] += v
|
||||
elif typ == 'bool': v = bool(int(raw, 16))
|
||||
else: v = raw
|
||||
row[nm] = v
|
||||
if len(samples) < 5: samples.append({'block': int(l['blockNumber'], 16), 'tx': l['transactionHash'].lower(), 'fields': row})
|
||||
dec_ev[abi_sig(f)] = {'count': len(ls), 'uint_field_sums_raw': dict(sums), 'top_addresses': {k: v.most_common(8) for k, v in addrs.items()}, 'first_samples': samples}
|
||||
E['decoded_events'] = dec_ev
|
||||
ups = [x for x in adm if x['event'] == 'Upgraded(address)']
|
||||
E['counts'] = {'upgrade_events_total': len(ups), 'upgrades_after_deployment': sum(1 for x in ups if not x['in_creation_tx']) if creation_tx else None,
|
||||
'upgrades_note': 'An Upgraded event inside the deployment transaction sets the first implementation and is not counted as an upgrade.',
|
||||
'pause_events': sum(1 for x in adm if x['event'] == 'Paused(address)'), 'ownership_transfers': sum(1 for x in adm if x['event'].startswith('OwnershipTransferred'))}
|
||||
if creation_tx is None and ups:
|
||||
E['notes'].append('The deployment transaction is unknown, so upgrades after deployment could not be separated from the first implementation set at deployment.')
|
||||
|
||||
# ---- tokens: transfers in/out and approvals to the contract (stable tokens of this chain)
|
||||
step('tokens')
|
||||
dec = {}; sym = {v: k for k, v in toks.items()}
|
||||
for t in tlist:
|
||||
try: dec[t] = int(r.eth_call(t, '0x313ce567'), 16)
|
||||
except Exception: dec[t] = 18 if chain == 'bsc' else 6
|
||||
tin = [l for l in inn if l['topics'][0] == TRANSFER]; apps = [l for l in inn if l['topics'][0] == APPROVAL]
|
||||
money = {}
|
||||
for t in tlist:
|
||||
d = 10 ** dec[t]
|
||||
i_ = [l for l in tin if l['address'].lower() == t]; o_ = [l for l in out if l['address'].lower() == t]
|
||||
try: bal = int(r.eth_call(t, '0x70a08231' + addr_topic(A)[2:]), 16) / d
|
||||
except Exception: bal = None
|
||||
if not i_ and not o_ and not bal: continue
|
||||
fin = collections.Counter(); fout = collections.Counter(); cin = collections.Counter(); cout = collections.Counter()
|
||||
for l in i_: a = topic_addr(l['topics'][1]); fin[a] += int(l['data'], 16) / d; cin[a] += 1
|
||||
for l in o_: a = topic_addr(l['topics'][2]); fout[a] += int(l['data'], 16) / d; cout[a] += 1
|
||||
sizes = collections.Counter(round(int(l['data'], 16) / d, 4) for l in o_)
|
||||
days = collections.Counter()
|
||||
for l in i_:
|
||||
b = int(l['blockNumber'], 16); ts = int(l['blockTimestamp'], 16) if l.get('blockTimestamp') else None
|
||||
if ts: days[ct(ts)[:10]] += 1
|
||||
money[sym[t]] = {'token': t, 'decimals': dec[t], 'balance_now': bal, 'in_count': len(i_), 'in_total': round(sum(fin.values()), 6), 'payers': len(fin),
|
||||
'out_count': len(o_), 'out_total': round(sum(fout.values()), 6), 'recipients': len(fout),
|
||||
'net_in_minus_out': round(sum(fin.values()) - sum(fout.values()), 6),
|
||||
'top_recipients': [[a, round(v, 4), cout[a]] for a, v in fout.most_common(15)],
|
||||
'top_payers': [[a, round(v, 4), cin[a]] for a, v in fin.most_common(10)],
|
||||
'out_sizes': [[k, v] for k, v in sizes.most_common(10)],
|
||||
'daily_in_counts': sorted(days.items())}
|
||||
E['money'] = money
|
||||
|
||||
# approvals: live allowance and balance per approving wallet
|
||||
step('approvals')
|
||||
appr = {}
|
||||
for t in tlist:
|
||||
al = [l for l in apps if l['address'].lower() == t]
|
||||
if not al: continue
|
||||
owners = sorted({topic_addr(l['topics'][1]) for l in al})[:1500]
|
||||
d = 10 ** dec[t]
|
||||
def one(o):
|
||||
try:
|
||||
a_ = int(r.eth_call(t, '0xdd62ed3e' + addr_topic(o)[2:] + addr_topic(A)[2:]), 16)
|
||||
b_ = int(r.eth_call(t, '0x70a08231' + addr_topic(o)[2:]), 16)
|
||||
return o, a_, b_
|
||||
except Exception:
|
||||
return o, None, None
|
||||
with ThreadPoolExecutor(6) as ex: res = list(ex.map(one, owners))
|
||||
ok = [x for x in res if x[1] is not None]
|
||||
live = [x for x in ok if x[1] > 0]
|
||||
appr[sym[t]] = {'approval_events': len(al), 'approving_wallets': len(owners), 'read': len(ok),
|
||||
'live_allowances': len(live), 'unlimited': sum(1 for x in ok if x[1] >= 2 ** 255),
|
||||
'pullable_now': round(sum(min(x[1], x[2]) for x in ok) / d, 6)}
|
||||
E['approvals'] = appr
|
||||
|
||||
# ---- positions probe (contracts that store numbered positions with an owner in the first field)
|
||||
step('positions')
|
||||
pos = None
|
||||
for cnt_fn, get_fn in POSITION_PAIRS:
|
||||
if cnt_fn in sel_of and get_fn in sel_of and time.time() < T0 + budget * 0.93:
|
||||
try:
|
||||
n = int(r.eth_call(A, sel_of[cnt_fn]), 16)
|
||||
except Exception:
|
||||
continue
|
||||
if not (0 < n <= 20000): continue
|
||||
s = sel_of[get_fn]
|
||||
def one(i):
|
||||
try:
|
||||
v = r.eth_call(A, s + hex(i)[2:].rjust(64, '0'))
|
||||
return i, addr_of('0x' + words(v)[0]) if v and len(v) >= 66 else None
|
||||
except Exception:
|
||||
return i, None
|
||||
ids = list(range(0, n + 1))
|
||||
with ThreadPoolExecutor(8) as ex: res = list(ex.map(one, ids))
|
||||
own = collections.Counter(a for i, a in res if a)
|
||||
pos = {'count_function': cnt_fn, 'count': n, 'getter': get_fn, 'read': sum(1 for i, a in res if a),
|
||||
'method': 'eth_call of %s for ids 0..%d; owner = the first returned field (INFERRED layout)' % (get_fn, n),
|
||||
'owners': len(own), 'top_owners': [[a, c] for a, c in own.most_common(15)]}
|
||||
break
|
||||
E['positions'] = pos
|
||||
|
||||
# ---- deployment arguments (addresses passed in the creation transaction)
|
||||
step('deployer')
|
||||
labels = {}
|
||||
for fn, a in roles.items(): labels.setdefault(a, []).append(fn)
|
||||
if creation_tx:
|
||||
try:
|
||||
tx = r.call('eth_getTransactionByHash', [creation_tx])
|
||||
E['creation']['from'] = tx['from'].lower(); labels.setdefault(tx['from'].lower(), []).append('deployer')
|
||||
init_addrs = []
|
||||
for w in words(tx['input'][-64 * 24:]):
|
||||
a = addr_of('0x' + w)
|
||||
if a and w[:24] == '0' * 24 and a not in init_addrs and a != A and int(a, 16) > 2 ** 100: init_addrs.append(a)
|
||||
E['creation']['addresses_in_input'] = init_addrs[:12]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# ---- profiles of labelled wallets (roles + deployer + top recipients)
|
||||
step('wallets')
|
||||
recv = collections.Counter();
|
||||
for sy, m in money.items():
|
||||
for a, v, c in m['top_recipients']: recv[a] += v
|
||||
cand = list(dict.fromkeys(list(labels.keys()) + [a for a in E.get('creation', {}).get('addresses_in_input', [])] + [a for a, _ in recv.most_common(6)]))
|
||||
prof = {}
|
||||
stable = toks.get('USDT') or tlist[0]
|
||||
for a in cand[:16]:
|
||||
try:
|
||||
k = kind_of(r, a)
|
||||
k['native_balance'] = int(r.call('eth_getBalance', [a, 'latest']), 16) / 1e18
|
||||
k['nonce'] = int(r.call('eth_getTransactionCount', [a, 'latest']), 16)
|
||||
k['labels'] = labels.get(a, []) + (['address in deployment input'] if a in E['creation'].get('addresses_in_input', []) else [])
|
||||
got = {sy: round(sum(v for x, v, c in m['top_recipients'] if x == a), 4) for sy, m in money.items()}
|
||||
k['received_from_contract'] = {s: v for s, v in got.items() if v}
|
||||
if pos: k['positions_owned'] = dict(pos['top_owners']).get(a, 0)
|
||||
prof[a] = k
|
||||
except Exception:
|
||||
continue
|
||||
E['wallets'] = prof
|
||||
|
||||
# ---- native coin sent in with the calls that emitted events (msg.value of those transactions; internal transfers out are not traced)
|
||||
step('native_in')
|
||||
hs = list(dict.fromkeys(l['transactionHash'] for l in L))
|
||||
cap = 400; hs_read = hs[-cap:]
|
||||
def gtx(h):
|
||||
try:
|
||||
t = r.call('eth_getTransactionByHash', [h], tries=3)
|
||||
return {'from': t['from'].lower(), 'to': (t.get('to') or '').lower(), 'value': int(t['value'], 16), 'sel': t['input'][:10]}
|
||||
except Exception:
|
||||
return None
|
||||
if time.time() < T0 + budget * 0.95:
|
||||
with ThreadPoolExecutor(8) as ex: txs = [x for x in ex.map(gtx, hs_read) if x]
|
||||
direct = [t for t in txs if t['to'] == A]
|
||||
selc = collections.Counter(t['sel'] for t in direct)
|
||||
sndc = collections.Counter(t['from'] for t in direct)
|
||||
E['txs'] = {'event_txs_total': len(hs), 'read': len(txs), 'read_note': ('the latest %d of them' % cap) if len(hs) > cap else 'all of them',
|
||||
'direct_calls': len(direct), 'native_sent_in': round(sum(t['value'] for t in direct) / 1e18, 6),
|
||||
'calls_with_native': sum(1 for t in direct if t['value']),
|
||||
'by_function': [[selmap.get(k) or k, n] for k, n in selc.most_common(12)], 'top_senders': [[a, n] for a, n in sndc.most_common(10)]}
|
||||
|
||||
# ---- the transactions behind admin events (sender + selector)
|
||||
step('admin_txs')
|
||||
for x in E['admin_events'][:30]:
|
||||
try:
|
||||
t = r.call('eth_getTransactionByHash', [x['tx']], tries=3)
|
||||
x['from'] = t['from'].lower(); x['selector'] = t['input'][:10]
|
||||
except Exception:
|
||||
pass
|
||||
E['rpc_calls'] = r.calls
|
||||
finish(E, OUT)
|
||||
|
||||
|
||||
def kind_of(r, a):
|
||||
code = r.code(a)
|
||||
if len(code) <= 2: return {'type': 'EOA', 'desc': 'personal wallet (EOA), one key'}
|
||||
if code.startswith('0xef0100'): return {'type': 'EOA+7702', 'desc': 'personal wallet with EIP-7702 delegated code', 'delegate': '0x' + code[8:48]}
|
||||
try:
|
||||
th = int(r.eth_call(a, '0xe75235b8'), 16)
|
||||
return {'type': 'safe', 'desc': 'Safe multisig, threshold %d' % th, 'threshold': th}
|
||||
except Exception:
|
||||
return {'type': 'contract', 'desc': 'contract (%d bytes)' % ((len(code) - 2) // 2)}
|
||||
|
||||
|
||||
def find_creation(r, A, latest):
|
||||
urls = r.c.get('archive_rpcs') or []
|
||||
for u in urls:
|
||||
try:
|
||||
def has(b):
|
||||
c = r.call('eth_getCode', [A, hex(b)], tries=3, urls=[u]); return len(c) > 2
|
||||
if not has(latest): continue
|
||||
lo, hi = 0, latest
|
||||
# quick probe: most contracts we see are young, search the recent part first
|
||||
for back in (200000, 2000000, 20000000):
|
||||
if latest - back > 0 and not has(latest - back): lo = latest - back; break
|
||||
while hi - lo > 1:
|
||||
mid = (lo + hi) // 2
|
||||
if has(mid): hi = mid
|
||||
else: lo = mid
|
||||
return hi
|
||||
except Exception:
|
||||
continue
|
||||
return None
|
||||
|
||||
|
||||
def finish(E, OUT):
|
||||
E['elapsed_s'] = round(time.time() - T0, 1)
|
||||
json.dump(E, open(os.path.join(OUT, 'evidence.json'), 'w', encoding='utf8', newline='\n'), indent=1)
|
||||
import pack
|
||||
md = pack.build(E)
|
||||
open(os.path.join(OUT, 'pack.md'), 'w', encoding='utf8', newline='\n').write(md)
|
||||
json.dump(pack.facts(E), open(os.path.join(OUT, 'facts.json'), 'w', encoding='utf8', newline='\n'), indent=1)
|
||||
print(json.dumps({'done': True, 'elapsed': E['elapsed_s'], 'pack_chars': len(md)}), flush=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
// WebWorthIt's site assistant (the network pattern: chatcore.js engine, kb.js store, netkb.js network knowledge).
|
||||
// Every fact below was checked against this repo on KNOWLEDGE_DATE (jobs.js, report.js, sponsor.js, chain/scan.py, public pages).
|
||||
// HOUSE RULE: when a feature changes, update CANNED and FACTS in the same commit and bump KNOWLEDGE_DATE.
|
||||
// Plain words, no em dashes, no promises, "SafePal or any other crypto wallet", never RM Circle. NETKB=0 in staging (nothing published).
|
||||
'use strict';
|
||||
const core = require('./chatcore');
|
||||
|
||||
const KNOWLEDGE_DATE = '2026-11-16';
|
||||
const SITE_HOST = process.env.SITE_HOST || 'webworthit.com';
|
||||
const URL_ = 'https://' + SITE_HOST;
|
||||
const SUPPORT = 'https://instantadpay.com/support';
|
||||
const STAGING = process.env.STAGING === '1';
|
||||
|
||||
const CANNED = [
|
||||
{ id: 'support', title: 'Talk to a person', q: ['How do I contact support?', 'I need a real person', 'My report did not arrive'], tags: ['support', 'help', 'problem'],
|
||||
re: core.SUPPORT_RE, handoff: true,
|
||||
a: 'Network support handles WebWorthIt too: open ' + SUPPORT + ', say it is about WebWorthIt, and include the link to your check.' },
|
||||
{ id: 'about', title: 'What is WebWorthIt?', q: ['What is WebWorthIt?', 'What does a check do?', 'How does this work?'], tags: ['webworthit', 'check', 'overview'],
|
||||
re: /(what('s| is) (web ?worth ?it|this (site|place))|how does (web ?worth ?it|this site|a check|it) work)/i,
|
||||
a: 'WebWorthIt reads a smart contract and the project website and shows, in plain English, who controls the money, where it has gone and whether the website promises match the code. It only uses public information: public blockchain records, public contract code and the public website. A check is read-only and never asks you to connect a wallet. Run one at ' + URL_ + '/#check' },
|
||||
{ id: 'opinion', title: 'Is the score a fact?', q: ['Is the grade a fact?', 'Who decides the score?', 'Is this financial advice?'], tags: ['score', 'opinion', 'advice'],
|
||||
re: /(is (the|a) (score|grade|verdict) (a )?fact|who (decides|sets) the (score|grade)|financial advice|is this advice)/i,
|
||||
a: 'The findings are public facts, each tagged VERIFIED, INFERRED or UNKNOWN and linked to its source. The scores, grade and verdict are our opinion, formed by applying our published rubric to those facts. A report is information about code and on-chain records, not financial advice and not a judgment of any person.' },
|
||||
{ id: 'free', title: 'How many free checks do I get?', q: ['How many free checks?', 'Is it free?', 'Why can I not run another check?'], tags: ['free', 'limit'],
|
||||
re: /(how many (free )?checks|is (it|this) free|free check limit|no more (free )?checks)/i,
|
||||
a: 'Every visitor gets 3 free checks a day. A free check is a short scorecard: a verdict, six category scores and the top findings, each tagged. The deep report is the full write-up.' },
|
||||
{ id: 'price', title: 'What does a deep report cost?', q: ['How much is a deep report?', 'Prices', 'What is the 10 pack?'], tags: ['price', 'deep report', 'pack', 'watch'],
|
||||
re: /(how much|price|cost).*(report|pack|watch)|(deep report|10 ?pack|watch alerts?).*(cost|price|how much)/i,
|
||||
a: 'One deep report is $10. Ten deep reports are $79 ($7.90 a report). Watch alerts are $9 for 3 months on one contract, one payment that stops by itself. All are one-time payments on Polygon with SafePal or any other crypto wallet. No subscriptions.' + (STAGING ? ' On this staging site payments are not live yet: they arrive at launch.' : '') },
|
||||
{ id: 'sponsor', title: 'Do sponsors earn?', q: ['Do I earn if someone I referred buys?', 'Referral rewards', 'What is my share link?'], tags: ['sponsor', 'referral', 'share'],
|
||||
re: /(sponsor|referr|refer a friend|share link|commission|earn).*(webworthit|report|buy|link)?/i,
|
||||
a: 'Yes. When someone you referred buys a deep report, a 10 pack or watch alerts, their sponsor line earns: 20% to the direct sponsor plus 5% on each of levels 2 to 5, paid in the same transaction. Only people who have bought here themselves receive a share; anyone who has not is passed over and the share moves up. Signed-in members find their link in the Share WebWorthIt box. You are paid only when people choose to buy.' + (STAGING ? ' Staging records who would be paid; nothing is paid until launch.' : '') }
|
||||
];
|
||||
const FAQ = [];
|
||||
const FACTS = () => [
|
||||
'- WHAT IT IS: WebWorthIt (' + URL_ + '), part of the Crypto Team Build Network. A contract and website check: who controls the money, where it went, whether payouts depend on later joiners, whether the website matches the code. Chains: BNB Chain, Polygon, Ethereum, Base.',
|
||||
'- PUBLIC ONLY: every check uses only public information anyone could look up: public blockchain records, verified or decompiled public contract code, the project public website. No private data, no hacking, no signing in to or interacting with the project, no moving funds. Read-only. Never asks anyone to connect a wallet to run a check.',
|
||||
'- OPINION: findings are public facts tagged VERIFIED (on chain), INFERRED (code, simulation, website text) or UNKNOWN. Scores, grade and verdict are our opinion from the published rubric (six categories: control and upgradeability 25, custody and exit paths 25, economic design 20, insider flows 15, disclosure vs code 10, trajectory 5; a critical red flag forces High risk). Not financial advice, not a judgment of any person. Projects can reply in their public thread.',
|
||||
'- FACT GATE: every address, transaction and number in a written report must match the evidence, or the report is not shown and only the facts read straight from the chain are shown.',
|
||||
'- LIMITS AND PRICES: 3 free checks a day per visitor. Deep report $10, 10 reports $79, watch alerts $9 for 3 months. One-time payments on Polygon, SafePal or any other crypto wallet.' + (STAGING ? ' Staging: payments arrive at launch.' : ''),
|
||||
'- SPONSORS: 20% to the direct sponsor, 5% on levels 2 to 5, company 60%; pass-up over people who never bought here; voucher redemptions pay nothing.',
|
||||
'- PAGES: Terms ' + URL_ + '/terms, Disclaimer ' + URL_ + '/disclaimer, Privacy ' + URL_ + '/privacy. Run by TrustClickz. SUPPORT: ' + SUPPORT
|
||||
].join('\n');
|
||||
|
||||
const SITE = {
|
||||
id: 'webworthit', hubSite: 'webworthit', netId: 'webworthit', name: 'WebWorthIt', url: URL_, supportUrl: SUPPORT, knowledgeDate: KNOWLEDGE_DATE,
|
||||
dataDir: process.env.DATA_DIR || require('path').join(__dirname, 'data'), canned: CANNED, faq: FAQ, facts: FACTS,
|
||||
intro: 'You are the assistant on WebWorthIt (' + URL_ + '): a read-only contract and website risk check that uses public information only. Scores are opinion from a published rubric, findings are public facts. Never give financial advice and never call a project or a person names. It is part of a network of sites that share one account.',
|
||||
quickTopics: ['What does a check do?', 'Is the grade a fact?', 'How many free checks?', 'Do sponsors earn?']
|
||||
};
|
||||
function init() { return core.init(SITE); }
|
||||
module.exports = { init, handle: core.handle, answer: core.answer, KNOWLEDGE_DATE, CANNED, FAQ, SITE };
|
||||
+219
@@ -0,0 +1,219 @@
|
||||
// The site assistant's engine (Marty 2026-11-15: a chatbot on every rebuilt network site), ported from LinkSpin's chatbot.js.
|
||||
// The site's own chatbot.js holds what it knows (CANNED instant answers + FACTS, written from that site's code); this file
|
||||
// holds how it answers, the same on every site:
|
||||
// 1. the knowledge base's instant answers (kb.js, seeded from CANNED; first matching pattern wins, no AI call)
|
||||
// 2. retrieval over the merged NETWORK knowledge base (this site's entries boosted, netkb.js), into the system prompt
|
||||
// 3. OpenRouter (deepseek/deepseek-v4-flash:nitro, reasoning OFF, retried once), house rules in the prompt and on the way out
|
||||
// Account problems go to the network support desk on InstantAdPay (handoff: true makes the widget offer it).
|
||||
// Routes: POST /api/chat, GET /api/chat/kb-stamp, admin GET/POST /api/admin/kb, GET/PUT/DELETE /api/admin/kb/<id>,
|
||||
// POST /api/admin/kb/test, GET /api/admin/kb/network (x-admin-token, the site's own isAdmin).
|
||||
// The SAME file ships in ViralAdBlitz, DownlineHydra, 5xYourTeam, Viral Banner Blitz, Downline Banners and Stack POL.
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const https = require('https');
|
||||
const http = require('http');
|
||||
const kb = require('./kb');
|
||||
const netkb = require('./netkb');
|
||||
|
||||
const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro';
|
||||
let S = null; // the site: { id, hubSite, name, url, dataDir, canned, faq, facts(), about, supportUrl, linkFor, quickTopics }
|
||||
|
||||
function key() {
|
||||
if (process.env.OPENROUTER_API_KEY) return process.env.OPENROUTER_API_KEY.trim();
|
||||
if (!S || !S.dataDir) return '';
|
||||
try { return fs.readFileSync(path.join(S.dataDir, 'openrouter.key'), 'utf8').trim(); } catch (e) { return ''; }
|
||||
}
|
||||
const enabled = () => !!key();
|
||||
|
||||
// CANNED + FAQ in the shape kb.js stores (order keeps the first-match-wins sequence)
|
||||
function seeds() {
|
||||
return S.canned.map((c, i) => ({ id: 'c-' + c.id, title: c.title, questions: c.q || [], answer: c.a, tags: c.tags || [], pattern: c.re ? c.re.source : '',
|
||||
handoff: !!c.handoff, order: (i + 1) * 10, source: 'canned' })).concat(S.faq || []);
|
||||
}
|
||||
|
||||
const supportUrl = () => S.supportUrl || 'https://instantadpay.com/support';
|
||||
// asking for a person, or one person's own account problem: every site's first CANNED entry uses this (handoff: true)
|
||||
const SUPPORT_RE = /((contact|reach|email|e-mail|message|talk to|speak (to|with)|get hold of) (the )?(support|admin|administrator|owner|marty|staff|someone|a (human|person|real person))|real person|\bhuman\b|customer (service|support)|open a ticket|support (ticket|desk|team|email)|help ?desk|(my|the) (boost|purchase|payment|payout|order|account|sign.?in|log.?in|pro|upgrade|ad|banner|pick)s? (is |was |has |did |does )?(not|never|n.?t|missing|stuck|wrong|failed|broken|lost|gone)|(did ?n.?t|did not|never|has ?n.?t|have ?n.?t) (show|arriv|appear|receiv|get paid|go through|work|confirm)|i (was|got) (charged|scammed)|charged twice)/i;
|
||||
const HOUSE_RULES = () => `RULES:
|
||||
- 1 to 4 sentences, plain text, no markdown, include full URLs when pointing at a page.
|
||||
- Your main job is ${S.name}. Questions about another network site: answer from that site's knowledge-base entry, say which site it is about, and give that site's link exactly as the entry gives it. Never mix two sites' prices, splits or rules.
|
||||
- NEVER promise or estimate income, and never state a maximum or total anyone can earn. This is advertising with a referral program, never an investment. Nobody earns unless real purchases happen in their line. Crypto payments are final.
|
||||
- Whenever ad credits come up, say: Ad credits buy advertising, not income.
|
||||
- Wallets: say "SafePal or any other crypto wallet". Never recommend MetaMask.
|
||||
- Never mention RM Circle. It is not part of this network.
|
||||
- No em dashes. If you do not know, say so plainly; never guess a price, a percentage or a rule.
|
||||
- Anything about one person's own account (a missing payout, a sign-in that will not work, a purchase that did not show, a bug) you cannot look up: say so and send them to network support at ${supportUrl()}.`;
|
||||
|
||||
function networkLine() {
|
||||
const list = netkb.sites();
|
||||
if (!list.length) return '';
|
||||
return '\nNETWORK SITES (one network account works across them; link to use for each):\n' + list.map(s => '- ' + s.name + ': ' + s.go).join('\n') + '\n';
|
||||
}
|
||||
function systemPrompt(kbBlock) {
|
||||
return S.intro + '\n\nFACTS (checked against this site\'s code on ' + S.knowledgeDate + '):\n' + S.facts() + '\n' + networkLine() + '\n' + HOUSE_RULES() + (kbBlock ? '\n\n' + kbBlock : '');
|
||||
}
|
||||
|
||||
function endpoint() {
|
||||
try { return new URL(process.env.OPENROUTER_URL || 'https://openrouter.ai/api/v1/chat/completions'); } catch (e) { return new URL('https://openrouter.ai/api/v1/chat/completions'); }
|
||||
}
|
||||
function askOnce(message, historyText, kbBlock) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const body = JSON.stringify({
|
||||
model: MODEL,
|
||||
reasoning: { enabled: false }, // deepseek-v4-flash reasons by default and can spend the whole max_tokens on it (2026-10-16)
|
||||
max_tokens: 320,
|
||||
messages: [
|
||||
{ role: 'system', content: systemPrompt(kbBlock) },
|
||||
...(historyText ? [{ role: 'user', content: 'Earlier context: ' + String(historyText).slice(0, 800) }] : []),
|
||||
{ role: 'user', content: String(message).slice(0, 600) }
|
||||
]
|
||||
});
|
||||
const ep = endpoint();
|
||||
const req = (ep.protocol === 'http:' ? http : https).request({ hostname: ep.hostname, port: ep.port || undefined, path: ep.pathname + ep.search, method: 'POST',
|
||||
headers: { Authorization: 'Bearer ' + key(), 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body),
|
||||
'HTTP-Referer': S.url, 'X-Title': S.name + ' assistant' }, timeout: 30000 },
|
||||
res => {
|
||||
let d = '';
|
||||
res.on('data', c => { d += c; });
|
||||
res.on('end', () => {
|
||||
// OpenRouter can pad a slow upstream with keepalive lines before the JSON (IAP, 2026-09-17): find the object
|
||||
const i = d.indexOf('{'); let txt = '';
|
||||
try { txt = String(JSON.parse(i < 0 ? d : d.slice(i)).choices[0].message.content || '').trim(); }
|
||||
catch (e) { return reject(new Error('openrouter ' + res.statusCode + ': ' + d.slice(0, 150))); }
|
||||
if (!txt) return reject(new Error('openrouter ' + res.statusCode + ': empty content'));
|
||||
resolve(txt);
|
||||
});
|
||||
});
|
||||
req.on('error', reject);
|
||||
req.on('timeout', () => req.destroy(new Error('openrouter timeout')));
|
||||
req.end(body);
|
||||
});
|
||||
}
|
||||
async function askAI(message, historyText, kbBlock) {
|
||||
try { return await askOnce(message, historyText, kbBlock); }
|
||||
catch (e) { await new Promise(r => setTimeout(r, 700)); return askOnce(message, historyText, kbBlock); } // one provider dropping it is the usual cause
|
||||
}
|
||||
|
||||
// house rules on the way out, whatever the model wrote
|
||||
const RMC_RE = /\brm ?circle\b|rmcircle/i;
|
||||
function scrub(t) {
|
||||
let s = String(t || '').replace(/\s*[—―]\s*/g, ', ').replace(/(\d)\s*–\s*(\d)/g, '$1-$2').replace(/\s*–\s*/g, ', ');
|
||||
s = s.replace(/\*\*(.+?)\*\*/g, '$1').replace(/^#+\s*/gm, '');
|
||||
s = s.replace(/\bMeta ?Mask\b(\s*(,|or|and)\s*)?/gi, '').replace(/\s{2,}/g, ' ').trim();
|
||||
return s;
|
||||
}
|
||||
const UNSURE_RE = /(not sure|do not know|don't know|cannot help|can't help|unable to help|no way for me|i (can|could) ?not (see|check|look)|contact support|network support|support desk|\/support\b)/i;
|
||||
|
||||
async function answer(message, historyText) {
|
||||
const r = await answerRaw(message, historyText);
|
||||
if (r && typeof r.reply === 'string') {
|
||||
r.reply = scrub(r.reply);
|
||||
if (RMC_RE.test(r.reply)) r.reply = 'I can only help with ' + S.name + ' and the network sites. For anything else, network support at ' + supportUrl() + ' can point you the right way.';
|
||||
}
|
||||
return r;
|
||||
}
|
||||
async function answerRaw(message, historyText) {
|
||||
const msg = String(message || '').trim().slice(0, 600);
|
||||
if (!msg) return { error: 'Say something first.' };
|
||||
let hit = null, kbOk = true, other = [];
|
||||
try {
|
||||
await kb.load();
|
||||
// a question about another network site (named, and this site not named) skips this site's instant answers, except a hand-off
|
||||
other = kb.namesOther(msg, S.hubSite);
|
||||
if (other.length && new RegExp('\\b' + S.name.replace(/[^A-Za-z0-9]+/g, '\\s*') + '\\b', 'i').test(msg)) other = [];
|
||||
hit = await kb.fastPath(msg);
|
||||
if (hit && other.length && !hit.handoff) hit = null;
|
||||
} catch (e) { kbOk = false; console.error('kb fast path', e.message); }
|
||||
if (hit) return Object.assign({ reply: hit.answer, canned: true, kb: hit.id }, hit.handoff ? { handoff: true } : {});
|
||||
if (!kbOk) for (const c of S.canned) if (c.re && c.re.test(msg)) return Object.assign({ reply: c.a, canned: true }, c.handoff ? { handoff: true } : {});
|
||||
let kbBlock = '', kbIds = [], hits = [];
|
||||
try {
|
||||
const query = msg.split(/\s+/).length < 4 && historyText ? msg + ' ' + String(historyText).slice(-200) : msg;
|
||||
hits = await kb.context(query, 6);
|
||||
kbBlock = kb.promptBlock(hits); kbIds = hits.map(h => h.entry.id);
|
||||
} catch (e) { console.error('kb search', e.message); }
|
||||
if (!enabled()) {
|
||||
// no AI: the best matching entry, if it is a clear match, else the honest fallback
|
||||
if (hits.length) { const e = hits[0].entry; return { reply: e.answer + (e.site ? ' More at ' + e.go : ''), kb: [e.id] }; }
|
||||
return { reply: S.fallback || ('Good question. The quick answers I have cover how ' + S.name + ' works, what it costs and how payouts work. For anything else, network support at ' + supportUrl() + ' will help.'), handoff: true };
|
||||
}
|
||||
try { const reply = await askAI(msg, historyText, kbBlock); return Object.assign({ reply }, kbIds.length ? { kb: kbIds } : {}, UNSURE_RE.test(reply) ? { handoff: true } : {}); }
|
||||
catch (e) {
|
||||
console.error('chat AI failed', e.message);
|
||||
if (hits.length) { const x = hits[0].entry; return { reply: x.answer + (x.site ? ' More at ' + x.go : ''), kb: [x.id] }; }
|
||||
return { reply: 'I hit a snag answering that one, on our side. The live ledger at ' + S.url + '/ledger and the contract page at ' + S.url + '/contract cover most deep questions, or network support at ' + supportUrl() + ' will answer.', handoff: true };
|
||||
}
|
||||
}
|
||||
|
||||
// ---- rate limit: per visitor, in memory ----
|
||||
const hits = new Map();
|
||||
function limited(ip) {
|
||||
const now = Date.now(); const h = hits.get(ip) || { m: 0, mAt: now, d: 0, dAt: now };
|
||||
if (now - h.mAt > 60000) { h.m = 0; h.mAt = now; }
|
||||
if (now - h.dAt > 86400000) { h.d = 0; h.dAt = now; }
|
||||
h.m++; h.d++; hits.set(ip, h);
|
||||
if (hits.size > 20000) hits.clear();
|
||||
return h.m > 12 || h.d > 300;
|
||||
}
|
||||
const ipOf = req => String(req.headers['cf-connecting-ip'] || String(req.headers['x-forwarded-for'] || '').split(',')[0] || (req.socket && req.socket.remoteAddress) || 'x').trim();
|
||||
|
||||
// h: { json(res, code, obj, extra), readBody(req), isAdmin(req) }; returns true when it answered
|
||||
async function handle(req, res, p, u, h) {
|
||||
if (p === '/api/chat' && req.method === 'POST') {
|
||||
if (limited(ipOf(req))) { h.json(res, 429, { error: 'Give it a minute, then ask again.' }); return true; }
|
||||
const b = await h.readBody(req);
|
||||
const hist = Array.isArray(b.history) ? b.history.map(x => String(x || '')).join(' ').slice(-800) : String(b.history || '').slice(-800);
|
||||
const r = await answer(b.message, hist);
|
||||
if (r.handoff) r.support = supportLink(b.message);
|
||||
h.json(res, r.error ? 400 : 200, r); return true;
|
||||
}
|
||||
if (p === '/api/chat/config' && req.method === 'GET') { h.json(res, 200, { name: S.name, support: supportUrl(), topics: S.quickTopics || [] }, { 'Cache-Control': 'public, max-age=300' }); return true; }
|
||||
if (p === '/api/chat/kb-stamp' && req.method === 'GET') { h.json(res, 200, Object.assign(await kb.stamp(), { knowledgeDate: S.knowledgeDate }), { 'Cache-Control': 'no-store' }); return true; }
|
||||
if (!p.startsWith('/api/admin/kb')) return false;
|
||||
if (!h.isAdmin(req)) { h.json(res, 401, { error: 'no' }); return true; }
|
||||
if (p === '/api/admin/kb') {
|
||||
if (req.method === 'GET') { h.json(res, 200, { entries: await kb.list(u.searchParams.get('q') || ''), stamp: await kb.stamp() }); return true; }
|
||||
if (req.method === 'POST') { const r = await kb.create(await h.readBody(req)); h.json(res, r.error ? 400 : 200, r); return true; }
|
||||
}
|
||||
if (p === '/api/admin/kb/test' && req.method === 'POST') { const b = await h.readBody(req); h.json(res, 200, Object.assign(await kb.test(b.question), b.answer ? { answer: await answer(b.question) } : {})); return true; }
|
||||
if (p === '/api/admin/kb/network' && req.method === 'GET') {
|
||||
if (u.searchParams.get('refresh') === '1') await netkb.refresh();
|
||||
if (u.searchParams.get('publish') === '1') await netkb.publish();
|
||||
h.json(res, 200, Object.assign(netkb.view(), { ai: enabled(), model: MODEL })); return true;
|
||||
}
|
||||
const m = /^\/api\/admin\/kb\/([A-Za-z0-9._:-]{1,80})$/.exec(p);
|
||||
if (m) {
|
||||
if (req.method === 'GET') { const e = await kb.get(m[1]); h.json(res, e ? 200 : 404, e ? { entry: e } : { error: 'Entry not found.' }); return true; }
|
||||
if (req.method === 'PUT') { const r = await kb.update(m[1], await h.readBody(req)); h.json(res, r.error ? (r.error === 'Entry not found.' ? 404 : 400) : 200, r); return true; }
|
||||
if (req.method === 'DELETE') { const r = await kb.remove(m[1]); h.json(res, r.error ? 404 : 200, r); return true; }
|
||||
}
|
||||
h.json(res, 404, { error: 'Not found' }); return true;
|
||||
}
|
||||
// the support desk link the widget offers: InstantAdPay's public form, told which site and question it came from
|
||||
function supportLink(q) {
|
||||
const qs = new URLSearchParams({ from: S.id, subject: (S.name + ': ' + String(q || '').replace(/\s+/g, ' ').trim()).slice(0, 120) });
|
||||
return supportUrl() + '?' + qs.toString();
|
||||
}
|
||||
|
||||
// the link to another network site: its LinkSpin tracked link with ?src=<this site> (netsites.js), else its plain address
|
||||
const hostOf = x => { try { return new URL(x).hostname.toLowerCase().replace(/^www\./, ''); } catch (e) { return ''; } };
|
||||
function linkVia(netId) {
|
||||
return url => {
|
||||
try {
|
||||
const ns = require('./netsites'); const h = hostOf(url);
|
||||
const m = ns.list().concat(ns.FALLBACK || []).find(s => hostOf(s.url) === h);
|
||||
return (m && netId && m.id !== netId && ns.tracked(m.id, netId)) || url;
|
||||
} catch (e) { return url; }
|
||||
};
|
||||
}
|
||||
|
||||
// site: see S above. Call after docstore.init (kb.json is a MySQL document there).
|
||||
function init(site) {
|
||||
S = site; if (!S.linkFor) S.linkFor = linkVia(S.netId);
|
||||
const ready = kb.init({ dataDir: site.dataDir, seeds: seeds(), siteUrl: site.url, helpText: 'network support at ' + supportUrl() });
|
||||
netkb.init({ dataDir: site.dataDir, site: site.hubSite, name: site.name, url: site.url, entries: () => kb.own(), linkFor: site.linkFor });
|
||||
return ready;
|
||||
}
|
||||
|
||||
module.exports = { init, handle, answer, enabled, seeds, systemPrompt, scrub, supportLink, linkVia, SUPPORT_RE, _limited: limited };
|
||||
@@ -0,0 +1,42 @@
|
||||
// WebWorthIt data: MySQL only (Marty's rule: the database is the gold standard, no JSON file stores).
|
||||
// DOCSTORE_URL = mysql://user:pass@host:3306/webworthit (the same database also holds docstore.js documents: kb, sso nonces).
|
||||
'use strict';
|
||||
const mysql = require('mysql2/promise');
|
||||
|
||||
let pool = null;
|
||||
const SCHEMA = [
|
||||
`CREATE TABLE IF NOT EXISTS checks (
|
||||
id CHAR(12) PRIMARY KEY, created BIGINT NOT NULL, ip_hash CHAR(24), holder VARCHAR(120), member VARCHAR(190),
|
||||
kind VARCHAR(8) NOT NULL, website VARCHAR(500), chain VARCHAR(12), address CHAR(42), picked_note TEXT,
|
||||
status VARCHAR(16) NOT NULL, step VARCHAR(40), steps_json TEXT, started BIGINT, finished BIGINT, timings_json TEXT,
|
||||
pack_chars INT, model VARCHAR(80), cost_usd DECIMAL(12,6) DEFAULT 0, tokens_in INT, tokens_out INT,
|
||||
report_json MEDIUMTEXT, factcheck_json MEDIUMTEXT, facts_json MEDIUMTEXT, site_json MEDIUMTEXT, evidence_json LONGTEXT, pack_md LONGTEXT,
|
||||
error TEXT, parent_id CHAR(12), public_label VARCHAR(120), is_public TINYINT DEFAULT 0,
|
||||
INDEX (created), INDEX (address), INDEX (is_public)) ENGINE=InnoDB`,
|
||||
`CREATE TABLE IF NOT EXISTS screenshots (check_id CHAR(12) PRIMARY KEY, mime VARCHAR(40), bytes MEDIUMBLOB, created BIGINT) ENGINE=InnoDB`,
|
||||
`CREATE TABLE IF NOT EXISTS daily_free (day CHAR(10) NOT NULL, ip_hash CHAR(24) NOT NULL, n INT NOT NULL DEFAULT 0, PRIMARY KEY (day, ip_hash)) ENGINE=InnoDB`,
|
||||
`CREATE TABLE IF NOT EXISTS unlock_codes (code_hash CHAR(64) PRIMARY KEY, label VARCHAR(120), created BIGINT, uses INT DEFAULT 0, disabled TINYINT DEFAULT 0) ENGINE=InnoDB`,
|
||||
`CREATE TABLE IF NOT EXISTS promo_codes (code VARCHAR(40) PRIMARY KEY, kind VARCHAR(16) NOT NULL, amount INT NOT NULL, max_uses INT NOT NULL DEFAULT 1,
|
||||
uses INT NOT NULL DEFAULT 0, per_holder_once TINYINT NOT NULL DEFAULT 1, expires BIGINT, note VARCHAR(300), disabled TINYINT NOT NULL DEFAULT 0, created BIGINT) ENGINE=InnoDB`,
|
||||
`CREATE TABLE IF NOT EXISTS promo_redemptions (id INT AUTO_INCREMENT PRIMARY KEY, code VARCHAR(40) NOT NULL, holder VARCHAR(190) NOT NULL, at BIGINT NOT NULL,
|
||||
kind VARCHAR(16), amount INT, ip_hash CHAR(24), INDEX (code), INDEX (holder)) ENGINE=InnoDB`,
|
||||
`CREATE TABLE IF NOT EXISTS credits (holder VARCHAR(190) PRIMARY KEY, deep INT NOT NULL DEFAULT 0, free_extra INT NOT NULL DEFAULT 0, updated BIGINT) ENGINE=InnoDB`,
|
||||
`CREATE TABLE IF NOT EXISTS purchases (id INT AUTO_INCREMENT PRIMARY KEY, at BIGINT NOT NULL, buyer VARCHAR(190), buyer_username VARCHAR(60), buyer_wallet CHAR(42),
|
||||
item VARCHAR(20) NOT NULL, usd DECIMAL(10,2) NOT NULL, via VARCHAR(16) NOT NULL, check_id CHAR(12), ref VARCHAR(60),
|
||||
line_json TEXT, split_json TEXT, note VARCHAR(300), real_money TINYINT NOT NULL DEFAULT 0, INDEX (at), INDEX (buyer), INDEX (buyer_username), INDEX (buyer_wallet)) ENGINE=InnoDB`,
|
||||
`CREATE TABLE IF NOT EXISTS members (email VARCHAR(190) PRIMARY KEY, hub_id VARCHAR(40), username VARCHAR(60), wallet CHAR(42), sponsor VARCHAR(60), created BIGINT, last_seen BIGINT,
|
||||
INDEX (username), INDEX (wallet)) ENGINE=InnoDB`,
|
||||
`CREATE TABLE IF NOT EXISTS sessions (id CHAR(48) PRIMARY KEY, email VARCHAR(190) NOT NULL, created BIGINT NOT NULL, expires BIGINT NOT NULL, INDEX (email)) ENGINE=InnoDB`
|
||||
];
|
||||
|
||||
async function init(url) {
|
||||
if (!url) throw new Error('DOCSTORE_URL is required (MySQL). WebWorthIt never runs on files.');
|
||||
pool = mysql.createPool({ uri: url, connectionLimit: 8, waitForConnections: true, supportBigNumbers: true, bigNumberStrings: false, charset: 'utf8mb4' });
|
||||
for (let i = 0; i < 30; i++) {
|
||||
try { await pool.query('SELECT 1'); break; } catch (e) { if (i === 29) throw e; await new Promise(r => setTimeout(r, 2000)); }
|
||||
}
|
||||
for (const s of SCHEMA) await pool.query(s);
|
||||
}
|
||||
const q = (sql, args) => pool.query(sql, args).then(r => r[0]);
|
||||
const one = async (sql, args) => (await q(sql, args))[0] || null;
|
||||
module.exports = { init, q, one, pool: () => pool };
|
||||
@@ -0,0 +1,34 @@
|
||||
services:
|
||||
webworthit:
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
shm_size: 512m
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
PORT: 3000
|
||||
DATA_DIR: /app/data
|
||||
SITE_HOST: ${SITE_HOST:-webworthit.com}
|
||||
STAGING: ${STAGING:-0}
|
||||
DOCSTORE_URL: ${DOCSTORE_URL:-}
|
||||
SESSION_SECRET: ${SESSION_SECRET:-}
|
||||
ADMIN_TOKEN: ${ADMIN_TOKEN:-}
|
||||
OPENROUTER_API_KEY: ${OPENROUTER_API_KEY:-}
|
||||
FREE_MODEL: ${FREE_MODEL:-deepseek/deepseek-v4.1-flash}
|
||||
DEEP_MODEL: ${DEEP_MODEL:-anthropic/claude-opus-5.5}
|
||||
WWI_TEST_CODE: ${WWI_TEST_CODE:-}
|
||||
WWI_ZONES: ${WWI_ZONES:-}
|
||||
CHAIN_BUDGET_S: ${CHAIN_BUDGET_S:-600}
|
||||
JOBS: ${JOBS:-2}
|
||||
HUB_URL: ${HUB_URL:-}
|
||||
HUB_SECRET: ${HUB_SECRET:-}
|
||||
HUB_SITE: ${HUB_SITE:-webworthit}
|
||||
HUB_SSO: ${HUB_SSO:-off}
|
||||
NETKB: ${NETKB:-0}
|
||||
NETWORK_SITE_ID: ${NETWORK_SITE_ID:-webworthit}
|
||||
NETWORK_SSO_SECRET: ${NETWORK_SSO_SECRET:-}
|
||||
volumes:
|
||||
- wwi-data:/app/data # the session secret + scratch for chain scans only; all data lives in MySQL (DOCSTORE_URL)
|
||||
expose:
|
||||
- "3000"
|
||||
volumes:
|
||||
wwi-data:
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
// Database-backed data documents (Marty 2026-11-13, standing rule: "everything database-driven ... files only for early
|
||||
// prototyping"). Every *.json / *.jsonl data document under DATA_DIR that a module reads or writes with the fs *Sync calls lives
|
||||
// in MySQL instead of on the volume: table `docs` (name = path relative to DATA_DIR, body LONGTEXT, updated_at). The modules keep
|
||||
// their code; install() routes their fs calls on those paths to an in-memory copy that init() loads from MySQL at boot, and every
|
||||
// change is written through to MySQL (coalesced per document, newest body wins, in order, retried until it lands).
|
||||
//
|
||||
// One writer at a time: init() claims the `docs_writer` row; an older app copy still running during a deploy finds the row taken
|
||||
// and stops writing (logged), so it can never put stale data over the new copy's (the 2026-11-13 rotator.json loss).
|
||||
// First boot: a document missing from MySQL is imported from its file, and the file is renamed <name>.imported-<date> (kept, not
|
||||
// read again). Files the volume keeps on purpose: KEEP (rebuildable caches, uploads, images, the geo database, queues read by
|
||||
// listing a folder). The SAME file ships in InstantAdPay, LinkSpin, Downline Banners and VBB.
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
|
||||
const KEEP_FILES = new Set(['chain-index.json']); // a rebuildable cache of the blockchain
|
||||
const KEEP_DIRS = ['uploads', 'geo', 'refuel-pending', 'backups', 'marks', 'kits', 'kitimg']; // binary files, or folders read by listing
|
||||
const O = { readFileSync: fs.readFileSync, writeFileSync: fs.writeFileSync, existsSync: fs.existsSync, renameSync: fs.renameSync,
|
||||
unlinkSync: fs.unlinkSync, statSync: fs.statSync, appendFileSync: fs.appendFileSync };
|
||||
|
||||
let ROOT = null, pool = null, ME = crypto.randomBytes(8).toString('hex'), ready = false, writer = true;
|
||||
const cache = new Map(); // name -> { body: string, at: ms }
|
||||
const pending = new Map(); // name -> body string | null (delete)
|
||||
let flushing = false, timer = null;
|
||||
const stats = { writes: 0, deletes: 0, refused: 0, errors: 0, imported: 0, lastError: null };
|
||||
|
||||
function nameOf(p) {
|
||||
if (!ROOT || typeof p !== 'string' || !/\.jsonl?$/i.test(p)) return null;
|
||||
const abs = path.resolve(p); if (!abs.startsWith(ROOT + path.sep)) return null;
|
||||
const rel = abs.slice(ROOT.length + 1).split(path.sep).join('/');
|
||||
if (KEEP_FILES.has(rel) || KEEP_DIRS.some(d => rel === d || rel.startsWith(d + '/'))) return null;
|
||||
return rel;
|
||||
}
|
||||
const enoent = p => { const e = new Error("ENOENT: no such file or directory, open '" + p + "'"); e.code = 'ENOENT'; e.errno = -2; e.path = p; return e; };
|
||||
const enc = o => (typeof o === 'string' ? o : o && o.encoding) || null;
|
||||
|
||||
function put(name, body) { cache.set(name, { body, at: Date.now() }); pending.set(name, body); kick(); }
|
||||
function drop(name) { cache.delete(name); pending.set(name, null); kick(); }
|
||||
function kick() { if (!timer) timer = setTimeout(() => { timer = null; flush().catch(() => {}); }, 300); }
|
||||
|
||||
async function flush() {
|
||||
if (!pool || flushing || !pending.size) return;
|
||||
flushing = true;
|
||||
try {
|
||||
for (const [name, body] of [...pending]) {
|
||||
if (pending.get(name) !== body) continue; // replaced while we were busy: the newer body goes next round
|
||||
if (!writer) { pending.delete(name); stats.refused++; continue; }
|
||||
const c = await pool.getConnection();
|
||||
try {
|
||||
await c.beginTransaction();
|
||||
const [[w]] = await c.query('SELECT owner FROM docs_writer WHERE id = 1 FOR UPDATE');
|
||||
if (!w || w.owner !== ME) { await c.rollback(); writer = false; pending.delete(name); stats.refused++; console.error('docstore: another app copy took over writing; this copy stops writing'); continue; }
|
||||
if (body === null) { await c.query('DELETE FROM docs WHERE name = ?', [name]); stats.deletes++; }
|
||||
else { await c.query('INSERT INTO docs (name, body, updated_at) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE body = VALUES(body), updated_at = VALUES(updated_at)', [name, body, Date.now()]); stats.writes++; }
|
||||
await c.commit();
|
||||
if (pending.get(name) === body) pending.delete(name);
|
||||
} catch (e) { try { await c.rollback(); } catch (x) {} stats.errors++; stats.lastError = String(e.message).slice(0, 200); console.error('docstore write', name, e.message); }
|
||||
finally { c.release(); }
|
||||
}
|
||||
} finally { flushing = false; if (pending.size) setTimeout(() => flush().catch(() => {}), 1000); }
|
||||
}
|
||||
|
||||
// Route the fs *Sync calls on data documents. Installed before any module runs; until init() the documents read from disk.
|
||||
function install(dataDir) {
|
||||
if (ROOT) return; ROOT = path.resolve(dataDir);
|
||||
fs.readFileSync = function (p, o) {
|
||||
if (!ready && process.env.DOCSTORE_URL && nameOf(p)) console.error('docstore: read before init', p, new Error().stack.split('\n')[2]);
|
||||
const n = ready ? nameOf(p) : null; if (!n) return O.readFileSync.apply(fs, arguments);
|
||||
const d = cache.get(n); if (!d) throw enoent(p);
|
||||
return enc(o) ? d.body : Buffer.from(d.body, 'utf8');
|
||||
};
|
||||
fs.existsSync = function (p) { const n = ready ? nameOf(p) : null; return n ? cache.has(n) : O.existsSync.apply(fs, arguments); };
|
||||
fs.writeFileSync = function (p, data, o) {
|
||||
const n = ready ? nameOf(p) : null; if (!n) return O.writeFileSync.apply(fs, arguments);
|
||||
const flag = o && typeof o === 'object' ? o.flag : null;
|
||||
const s = Buffer.isBuffer(data) ? data.toString('utf8') : String(data);
|
||||
put(n, flag && flag[0] === 'a' ? ((cache.get(n) || {}).body || '') + s : s);
|
||||
};
|
||||
fs.appendFileSync = function (p, data) {
|
||||
const n = ready ? nameOf(p) : null; if (!n) return O.appendFileSync.apply(fs, arguments);
|
||||
put(n, ((cache.get(n) || {}).body || '') + (Buffer.isBuffer(data) ? data.toString('utf8') : String(data)));
|
||||
};
|
||||
fs.renameSync = function (a, b) {
|
||||
const nb = ready ? nameOf(b) : null; const na = ready ? nameOf(a) : null;
|
||||
if (!nb && !na) return O.renameSync.apply(fs, arguments);
|
||||
let body;
|
||||
if (na) { const d = cache.get(na); if (!d) throw enoent(a); body = d.body; drop(na); }
|
||||
else { body = O.readFileSync.call(fs, a, 'utf8'); try { O.unlinkSync.call(fs, a); } catch (e) {} }
|
||||
if (nb) put(nb, body); else O.writeFileSync.call(fs, b, body);
|
||||
};
|
||||
fs.unlinkSync = function (p) { const n = ready ? nameOf(p) : null; if (!n) return O.unlinkSync.apply(fs, arguments); if (!cache.has(n)) throw enoent(p); drop(n); };
|
||||
fs.statSync = function (p, o) {
|
||||
const n = ready ? nameOf(p) : null; if (!n) return O.statSync.apply(fs, arguments);
|
||||
const d = cache.get(n); if (!d) { if (o && o.throwIfNoEntry === false) return undefined; throw enoent(p); }
|
||||
const size = Buffer.byteLength(d.body, 'utf8'); const t = new Date(d.at);
|
||||
return { size, mtimeMs: d.at, mtime: t, ctime: t, birthtime: t, isFile: () => true, isDirectory: () => false, isSymbolicLink: () => false };
|
||||
};
|
||||
}
|
||||
|
||||
// Connect, claim writing, load every document, import files MySQL does not have yet. Throws if MySQL is unreachable: the app
|
||||
// must not run on an empty copy.
|
||||
async function init(opts) {
|
||||
const url = String(process.env.DOCSTORE_URL || '').trim();
|
||||
if (!url) { console.log('docstore: no DOCSTORE_URL, documents stay files (prototype mode)'); return false; }
|
||||
const mysql = require('mysql2/promise');
|
||||
pool = mysql.createPool({ uri: url, connectionLimit: 6, charset: 'utf8mb4' });
|
||||
await pool.query('CREATE TABLE IF NOT EXISTS docs (name VARCHAR(190) PRIMARY KEY, body LONGTEXT NOT NULL, updated_at BIGINT NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4');
|
||||
await pool.query('CREATE TABLE IF NOT EXISTS docs_writer (id TINYINT PRIMARY KEY, owner VARCHAR(40) NOT NULL, at BIGINT NOT NULL) ENGINE=InnoDB');
|
||||
await pool.query('INSERT INTO docs_writer (id, owner, at) VALUES (1, ?, ?) ON DUPLICATE KEY UPDATE owner = VALUES(owner), at = VALUES(at)', [ME, Date.now()]);
|
||||
const [rows] = await pool.query('SELECT name, body, updated_at FROM docs');
|
||||
for (const r of rows) cache.set(r.name, { body: r.body, at: Number(r.updated_at) });
|
||||
for (const sp of (opts && opts.splits) || []) await openSplit(sp);
|
||||
// first boot for any document: import its file, then set the file aside
|
||||
const stamp = new Date().toISOString().slice(0, 10);
|
||||
const walk = dir => { let out = []; let ents = []; try { ents = fs.readdirSync(dir, { withFileTypes: true }); } catch (e) {} for (const e of ents) { const p = path.join(dir, e.name); if (e.isDirectory()) out = out.concat(walk(p)); else out.push(p); } return out; };
|
||||
for (const p of walk(ROOT)) {
|
||||
const n = nameOf(p); if (!n || cache.has(n)) continue;
|
||||
const body = O.readFileSync.call(fs, p, 'utf8');
|
||||
if (/\.json$/i.test(n) && body.trim()) { try { JSON.parse(body); } catch (e) { throw new Error('docstore: ' + n + ' is not valid JSON; fix or move it before switching to MySQL'); } }
|
||||
await pool.query('INSERT INTO docs (name, body, updated_at) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE name = name', [n, body, Date.now()]);
|
||||
const [[got]] = await pool.query('SELECT body FROM docs WHERE name = ?', [n]);
|
||||
cache.set(n, { body: got.body, at: Date.now() }); stats.imported++;
|
||||
O.renameSync.call(fs, p, p + '.imported-' + stamp);
|
||||
}
|
||||
for (const sp of (opts && opts.splits) || []) await migrateSplit(sp);
|
||||
ready = true;
|
||||
console.log('docstore: MySQL documents ready,', cache.size, 'documents,', stats.imported, 'imported from files this boot');
|
||||
const shut = () => { flush().catch(() => {}).finally(() => {}); };
|
||||
process.once('beforeExit', shut);
|
||||
return true;
|
||||
}
|
||||
// ---- row tables: an ever-growing array (spin-link clicks) is one row per item, never a rewrite of the whole document ----
|
||||
// spec { doc: 'rotator.json', field: 'hits', table: 'rot_hits', key: 'id', ts: 'ts' }. rows(table) gives the loaded items (oldest
|
||||
// first); the module inserts / deletes rows itself and saves its document WITHOUT the field.
|
||||
const ROWS = new Map(); const rowQ = []; let rowBusy = false;
|
||||
async function openSplit(sp) {
|
||||
await pool.query('CREATE TABLE IF NOT EXISTS `' + sp.table + '` (id VARCHAR(64) PRIMARY KEY, ts BIGINT NOT NULL, body MEDIUMTEXT NOT NULL, KEY ts (ts)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4');
|
||||
const [r] = await pool.query('SELECT body FROM `' + sp.table + '` ORDER BY ts, id');
|
||||
ROWS.set(sp.table, r.map(x => JSON.parse(x.body)));
|
||||
}
|
||||
async function insertMany(table, items, key, ts) {
|
||||
for (let i = 0; i < items.length; i += 500) {
|
||||
const part = items.slice(i, i + 500);
|
||||
await pool.query('INSERT INTO `' + table + '` (id, ts, body) VALUES ? ON DUPLICATE KEY UPDATE body = VALUES(body), ts = VALUES(ts)', [part.map(x => [String(x[key]), Number(x[ts]) || 0, JSON.stringify(x)])]);
|
||||
}
|
||||
}
|
||||
// first boot: the array still inside the document moves to its table, then the document is saved without it
|
||||
async function migrateSplit(sp) {
|
||||
const d = cache.get(sp.doc); if (!d) return;
|
||||
let obj; try { obj = JSON.parse(d.body); } catch (e) { return; }
|
||||
const arr = Array.isArray(obj[sp.field]) ? obj[sp.field] : null; if (!arr || !arr.length) return;
|
||||
await insertMany(sp.table, arr, sp.key, sp.ts);
|
||||
const [[{ n }]] = await pool.query('SELECT COUNT(*) n FROM `' + sp.table + '`');
|
||||
if (n < arr.length) throw new Error('docstore: ' + sp.table + ' holds ' + n + ' rows after moving ' + arr.length + '; stopping before the document is changed');
|
||||
const seen = new Set((ROWS.get(sp.table) || []).map(x => String(x[sp.key]))); const merged = (ROWS.get(sp.table) || []).concat(arr.filter(x => !seen.has(String(x[sp.key]))));
|
||||
merged.sort((a, b) => (Number(a[sp.ts]) || 0) - (Number(b[sp.ts]) || 0)); ROWS.set(sp.table, merged);
|
||||
obj[sp.field] = []; const body = JSON.stringify(obj);
|
||||
await pool.query('UPDATE docs SET body = ?, updated_at = ? WHERE name = ?', [body, Date.now(), sp.doc]); cache.set(sp.doc, { body, at: Date.now() });
|
||||
console.log('docstore:', arr.length, sp.field, 'moved from', sp.doc, 'to table', sp.table);
|
||||
}
|
||||
function rows(table) { return ROWS.get(table) || null; }
|
||||
function rowOp(op) { if (!pool || !writer) return; rowQ.push(op); if (!rowBusy) runRows(); }
|
||||
async function runRows() {
|
||||
rowBusy = true;
|
||||
try {
|
||||
while (rowQ.length && writer) {
|
||||
const op = rowQ[0];
|
||||
try {
|
||||
if (op.del) await pool.query('DELETE FROM `' + op.table + '` WHERE id IN (?)', [op.ids]);
|
||||
else await pool.query('INSERT INTO `' + op.table + '` (id, ts, body) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE body = VALUES(body), ts = VALUES(ts)', [op.id, op.ts, op.body]);
|
||||
rowQ.shift();
|
||||
} catch (e) { stats.errors++; stats.lastError = String(e.message).slice(0, 200); await new Promise(r => setTimeout(r, 1000)); }
|
||||
}
|
||||
} finally { rowBusy = false; }
|
||||
}
|
||||
const rowPut = (table, id, ts, obj) => rowOp({ table, id: String(id), ts: Number(ts) || 0, body: JSON.stringify(obj) });
|
||||
const rowDel = (table, ids) => { const list = [...ids].map(String); for (let i = 0; i < list.length; i += 1000) rowOp({ table, del: true, ids: list.slice(i, i + 1000) }); };
|
||||
function isOn() { return ready && !!pool; }
|
||||
// once across app copies (two run side by side during a deploy): true for the first caller of a key, false after. Without MySQL: true.
|
||||
async function claim(key) {
|
||||
if (!pool) return true;
|
||||
await pool.query('CREATE TABLE IF NOT EXISTS doc_claims (k VARCHAR(190) PRIMARY KEY, at BIGINT NOT NULL) ENGINE=InnoDB');
|
||||
const [r] = await pool.query('INSERT IGNORE INTO doc_claims (k, at) VALUES (?, ?)', [String(key).slice(0, 190), Date.now()]);
|
||||
return r.affectedRows === 1;
|
||||
}
|
||||
|
||||
// SIGTERM during a deploy: write what is pending, then exit
|
||||
async function drain(ms) { const end = Date.now() + (ms || 8000); while ((pending.size || flushing || rowQ.length || rowBusy) && Date.now() < end) { await flush().catch(() => {}); await new Promise(r => setTimeout(r, 100)); } }
|
||||
function view() { return Object.assign({ ready, writer, documents: cache.size, pending: pending.size, rowQueue: rowQ.length, rowTables: Object.fromEntries([...ROWS].map(([k, v]) => [k, v.length])), bytes: [...cache.values()].reduce((t, d) => t + d.body.length, 0) }, stats); }
|
||||
module.exports = { install, init, drain, flush, view, nameOf, rows, rowPut, rowDel, isOn, claim };
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
// Network hub events for a wallet site (Marty 2026-11-16, "Yes do 1 and 2"). Byte-identical in Viral Banner Blitz, Downline Banners,
|
||||
// ViralAdBlitz, DownlineHydra and 5xYourTeam (like networksso.js): copy it whole, never edit one copy alone.
|
||||
//
|
||||
// The hub tells every hooked site what changed (POST /api/hub/events, the same hook InstantAdPay and LinkSpin take): X-Hub-Ts +
|
||||
// X-Hub-Sig = hex HMAC-SHA256(HUB_SECRET, ts + newline + raw body), 5-minute window. The hub only moves its cursor after a 2xx and
|
||||
// may send an event twice. This site acts on three events and ignores every other one:
|
||||
// member.signedout "Sign out everywhere" on any network site
|
||||
// member.blocked the hub blocked the person
|
||||
// member.erased the hub erased the person ({emailHash, walletHashes}: the person is gone from the hub, so no lookup)
|
||||
// Each one ends that person's sessions here. A wallet site keys sessions by wallet, so the person is mapped through the hub:
|
||||
// POST /v1/resolve {id} (signed as HUB_SITE) gives their main wallet and every contract wallet (contractWallets). An erased
|
||||
// person cannot be looked up any more: the event carries the SHA-256 of each of their wallets (and of their email) instead.
|
||||
// Only sessions made BEFORE the event end (a fresh sign-in after it stays), so a replay can never sign anyone out twice.
|
||||
// A failed lookup answers 503 so the hub sends the batch again; after 5 tries an event is set aside in the log.
|
||||
// Nothing here sends mail, posts or touches a banner, a payout or the chain: it only ends sign-in sessions.
|
||||
//
|
||||
// init({ dataDir, site, end }) where end({ type, personId, at, wallets, walletHashes, emailHash, match }) ends the sessions and
|
||||
// answers how many; match(session-like {address?, email?, wallet?, hubId?}) is the shared test (wallet, wallet hash, email
|
||||
// hash, hub id). Off when HUB_HOOK=0, or without HUB_URL and a 32+ character HUB_SECRET (then the route answers 404).
|
||||
'use strict';
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const WALLET_RE = /^0x[0-9a-f]{40}$/, HASH_RE = /^[0-9a-f]{64}$/;
|
||||
const TRIES = 5, KEEP = 3000, SKEW = 2000;
|
||||
const ACTS = new Set(['member.signedout', 'member.blocked', 'member.erased']);
|
||||
let R = null, st = null, chain_ = Promise.resolve();
|
||||
const SECRET = () => String(process.env.HUB_SECRET || '').trim();
|
||||
const BASE = () => String(process.env.HUB_URL || '').trim().replace(/\/+$/, '');
|
||||
const SITE = () => String(process.env.HUB_SITE || (R && R.site) || '').trim().toLowerCase();
|
||||
const on = () => !/^(0|false|no|off)$/i.test(String(process.env.HUB_HOOK || '').trim()) && /^https?:\/\/[a-z0-9.:-]+$/i.test(BASE()) && SECRET().length >= 32;
|
||||
const lc = v => String(v == null ? '' : v).trim().toLowerCase();
|
||||
const sha = v => crypto.createHash('sha256').update(lc(v)).digest('hex');
|
||||
const FILE = () => path.join(R.dataDir, 'hubevents.json');
|
||||
|
||||
function load() {
|
||||
if (st) return st;
|
||||
try { st = JSON.parse(fs.readFileSync(FILE(), 'utf8')); } catch (e) { st = null; }
|
||||
if (!st || typeof st !== 'object') st = {};
|
||||
st.done = st.done || {}; st.tries = st.tries || {}; st.log = st.log || [];
|
||||
st.stats = Object.assign({ batches: 0, events: 0, ended: 0, ignored: 0, skipped: 0, gaveUp: 0, refused: 0 }, st.stats || {});
|
||||
return st;
|
||||
}
|
||||
function save() { if (!R || !R.dataDir) return; try { const t = FILE() + '.tmp'; fs.writeFileSync(t, JSON.stringify(load())); fs.renameSync(t, FILE()); } catch (e) { console.error('hubevents save', e.message); } }
|
||||
function note(x) { const s = load(); s.log.push(Object.assign({ ts: Date.now() }, x)); if (s.log.length > 200) s.log = s.log.slice(-200); }
|
||||
function init(deps) { R = deps || {}; load(); }
|
||||
|
||||
const sign = (ts, raw) => crypto.createHmac('sha256', SECRET()).update(String(ts) + '\n' + raw).digest('hex');
|
||||
function verify(headers, raw) {
|
||||
if (SECRET().length < 32) return false;
|
||||
const ts = String(headers['x-hub-ts'] || ''), sig = String(headers['x-hub-sig'] || '');
|
||||
if (!/^\d{10,16}$/.test(ts) || Math.abs(Date.now() - Number(ts)) > 5 * 60000 || !/^[0-9a-f]{64}$/.test(sig)) return false;
|
||||
const want = sign(ts, raw);
|
||||
return crypto.timingSafeEqual(Buffer.from(want), Buffer.from(sig));
|
||||
}
|
||||
// the hub person by hub id (null = the hub does not know them); throws when the hub does not answer
|
||||
async function resolveId(id) {
|
||||
const raw = JSON.stringify({ id }); const ts = String(Date.now());
|
||||
const r = await fetch(BASE() + '/v1/resolve', { method: 'POST', body: raw, signal: AbortSignal.timeout(10000),
|
||||
headers: { 'Content-Type': 'application/json', 'X-Hub-Site': SITE(), 'X-Hub-Ts': ts, 'X-Hub-Sig': sign(ts, raw) } });
|
||||
if (r.status !== 200) throw new Error('hub resolve ' + r.status);
|
||||
const j = await r.json(); return j && j.person && typeof j.person === 'object' ? j.person : null;
|
||||
}
|
||||
// every wallet the hub holds for a person: the main wallet and each contract's wallet
|
||||
function walletsOf(p) {
|
||||
const out = new Set(); if (!p) return [];
|
||||
if (WALLET_RE.test(lc(p.wallet))) out.add(lc(p.wallet));
|
||||
for (const w of Object.values(p.contractWallets || {})) if (WALLET_RE.test(lc(w))) out.add(lc(w));
|
||||
return [...out];
|
||||
}
|
||||
// the shared test: does this session / member belong to the person?
|
||||
function matcher(who) {
|
||||
const ws = new Set(who.wallets || []), hs = new Set(who.walletHashes || []), eh = who.emailHash || null, id = who.personId || null;
|
||||
return x => {
|
||||
if (!x) return false;
|
||||
for (const w of [x.address, x.wallet, x.hubWallet]) { const v = lc(w); if (WALLET_RE.test(v) && (ws.has(v) || hs.has(sha(v)))) return true; }
|
||||
if (eh && x.email && sha(x.email) === eh) return true;
|
||||
if (id && (x.hubId === id || x.key === id)) return true;
|
||||
return false;
|
||||
};
|
||||
}
|
||||
async function apply(ev) {
|
||||
if (!ACTS.has(ev.type) || !ev.personId) return 'ignored';
|
||||
const who = { type: ev.type, personId: String(ev.personId), at: Number(ev.at) || Date.now(), wallets: [], walletHashes: [], emailHash: null };
|
||||
if (ev.type === 'member.erased') {
|
||||
const d = ev.data || {};
|
||||
who.walletHashes = (Array.isArray(d.walletHashes) ? d.walletHashes : []).map(lc).filter(h => HASH_RE.test(h)).slice(0, 50);
|
||||
who.emailHash = HASH_RE.test(lc(d.emailHash)) ? lc(d.emailHash) : null;
|
||||
} else {
|
||||
const p = await resolveId(who.personId); // throws: the hub sends it again
|
||||
if (!p) return 'ignored';
|
||||
who.wallets = walletsOf(p);
|
||||
}
|
||||
who.before = who.at + SKEW; // sessions made after the event are fresh sign-ins and stay
|
||||
who.match = matcher(who);
|
||||
const n = Number(await R.end(who)) || 0;
|
||||
note({ type: ev.type, seq: ev.seq, sessions: n });
|
||||
if (n) { load().stats.ended += n; return 'applied'; }
|
||||
return 'none';
|
||||
}
|
||||
function prune() {
|
||||
const s = load(); const seqs = Object.keys(s.done).map(Number).sort((a, b) => a - b);
|
||||
for (const q of seqs.slice(0, Math.max(0, seqs.length - KEEP))) delete s.done[q];
|
||||
}
|
||||
async function handle(events) {
|
||||
const s = load(); s.stats.batches++; let failed = null;
|
||||
for (const ev of Array.isArray(events) ? events : []) {
|
||||
const seq = Number(ev && ev.seq); if (!seq) continue;
|
||||
if (s.done[seq]) { s.stats.skipped++; continue; }
|
||||
s.stats.events++;
|
||||
try {
|
||||
const r = await apply(ev);
|
||||
s.done[seq] = Date.now(); delete s.tries[seq];
|
||||
if (r === 'ignored') s.stats.ignored++;
|
||||
} catch (e) {
|
||||
s.tries[seq] = (s.tries[seq] || 0) + 1;
|
||||
console.error('hubevents', seq, ev.type, e.message);
|
||||
if (s.tries[seq] >= TRIES) { s.done[seq] = Date.now(); delete s.tries[seq]; s.stats.gaveUp++; note({ type: 'gave-up', seq, event: ev.type, error: String(e.message).slice(0, 160) }); continue; }
|
||||
failed = e; break;
|
||||
}
|
||||
}
|
||||
prune(); save();
|
||||
return failed ? { status: 503, body: { error: 'retry' } } : { status: 200, body: { ok: true } };
|
||||
}
|
||||
// the POST /api/hub/events handler -> { status, body }. Batches run one at a time.
|
||||
function receive(headers, raw) {
|
||||
if (!R || !on()) return Promise.resolve({ status: 404, body: { error: 'not found' } });
|
||||
if (!verify(headers || {}, String(raw || ''))) { load().stats.refused++; return Promise.resolve({ status: 401, body: { error: 'unauthorized' } }); }
|
||||
let b; try { b = JSON.parse(raw || '{}'); } catch (e) { return Promise.resolve({ status: 400, body: { error: 'bad json' } }); }
|
||||
const run = chain_.then(() => handle(b && b.events)); chain_ = run.catch(() => {}); return run;
|
||||
}
|
||||
function view() { const s = load(); return { on: on(), stats: s.stats, waiting: Object.keys(s.tries).length, log: s.log.slice(-20) }; }
|
||||
|
||||
module.exports = { init, receive, view, on, verify, walletsOf, matcher, sha, _reset: () => { st = null; chain_ = Promise.resolve(); } };
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// A member's sponsor line from the network hub (the one source of truth, Marty 2026-11-13/14). Walks hubpeople.sponsorOf()
|
||||
// up to `max` places, nearest first: [{ depth, id, username, wallet }]. Used two ways:
|
||||
// - member pages (viraladblitz.com/<username>): the ads of the first 5 people above with a live ad here
|
||||
// - Boost vouchers: the wallets of the line, bound on chain on the buyer's first Boost (VABShop binds link by link)
|
||||
// Answers are cached 5 minutes per start person. {ok: false} = the hub did not answer all the way (the line is partial); the
|
||||
// caller decides (pages fall back to the last good line; vouchers are not signed on a partial line).
|
||||
'use strict';
|
||||
const hubpeople = require('./hubpeople');
|
||||
|
||||
const TTL = () => Number(process.env.HUB_CACHE_MS || 5 * 60000);
|
||||
const cache = new Map(); const lastGood = new Map();
|
||||
|
||||
async function walk(person, max) {
|
||||
const line = []; const seen = new Set([person.id]); let p = person;
|
||||
for (let depth = 1; depth <= max; depth++) {
|
||||
if (!p.sponsor || !p.sponsor.id) return { ok: true, line };
|
||||
if (seen.has(p.sponsor.id)) return { ok: true, line, loop: true }; // a loop in the hub data: stop
|
||||
const r = await hubpeople.sponsorOf(p); if (!r.ok) return { ok: false, line };
|
||||
if (!r.person) return { ok: true, line };
|
||||
seen.add(r.person.id);
|
||||
line.push({ depth, id: r.person.id, username: r.person.username ? String(r.person.username) : null, wallet: hubpeople.wallet(r.person) });
|
||||
p = r.person;
|
||||
}
|
||||
return { ok: true, line };
|
||||
}
|
||||
|
||||
// start = { ref: username } | { wallet }. -> { ok, person, line, stale? }
|
||||
async function lineOf(start, max) {
|
||||
const k = JSON.stringify(start) + '|' + max; const hit = cache.get(k);
|
||||
if (hit && Date.now() - hit.at < TTL()) return hit.v;
|
||||
const me = start.wallet ? await hubpeople.byWallet(start.wallet) : await hubpeople.byRef(start.ref);
|
||||
let v;
|
||||
if (!me.ok) v = { ok: false, person: null, line: [] };
|
||||
else if (!me.person) v = { ok: true, person: null, line: [] };
|
||||
else { const w = await walk(me.person, max); v = { ok: w.ok, person: me.person, line: w.line }; }
|
||||
if (v.ok) { cache.set(k, { at: Date.now(), v }); lastGood.set(k, v); if (cache.size > 20000) cache.clear(); if (lastGood.size > 20000) lastGood.clear(); return v; }
|
||||
const lg = lastGood.get(k); return lg ? Object.assign({}, lg, { ok: false, stale: true }) : v;
|
||||
}
|
||||
|
||||
module.exports = { lineOf, walk, _reset: () => { cache.clear(); lastGood.clear(); } };
|
||||
@@ -0,0 +1,62 @@
|
||||
// Network hub lookups (Marty 2026-11-14: "want everything looped through the hub to verify membership"). The hub is the one
|
||||
// record per person across the network; this asks it who a username, wallet or hub id is:
|
||||
// POST /v1/resolve {ref: <username or wallet>} | {wallet} | {id: 'h_...'} -> {person: view or null}
|
||||
// signed as HUB_SITE with HUB_SECRET (X-Hub-Site, X-Hub-Ts, X-Hub-Sig = hex HMAC-SHA256(ts + newline + raw body)), the same
|
||||
// scheme as hubreport.js. This site cannot see emails (seeEmails false): a person is {id, username, wallet, sponsor: {id, username}, blocked, ...}.
|
||||
// Answers (people and misses) are cached HUB_CACHE_MS (5 minutes). A failed call (timeout, refused, any non-200) is never
|
||||
// cached: it returns {ok: false} so the caller can fall back, and the hub is skipped for 30 seconds so pages never wait on it.
|
||||
// On unless HUB_LOOKUP=0; needs HUB_URL and a 32+ character HUB_SECRET (HUB_ENABLED only switches the shadow report).
|
||||
'use strict';
|
||||
const crypto = require('crypto');
|
||||
|
||||
const DEFAULT_SITE = 'webworthit';
|
||||
const ADDR_RE = /^0x[0-9a-f]{40}$/;
|
||||
const TTL = () => Number(process.env.HUB_CACHE_MS || 5 * 60000);
|
||||
const TIMEOUT = () => Number(process.env.HUB_LOOKUP_TIMEOUT_MS || 2500);
|
||||
const on = () => !/^(0|false|no|off)$/i.test(String(process.env.HUB_LOOKUP || '').trim())
|
||||
&& !!String(process.env.HUB_URL || '').trim() && String(process.env.HUB_SECRET || '').trim().length >= 32;
|
||||
const cache = new Map(); let downUntil = 0; let lastError = null; const stats = { asked: 0, cached: 0, failed: 0 };
|
||||
|
||||
async function call(body) {
|
||||
const raw = JSON.stringify(body); const ts = String(Date.now());
|
||||
const sig = crypto.createHmac('sha256', String(process.env.HUB_SECRET).trim()).update(ts + '\n' + raw).digest('hex');
|
||||
const ac = new AbortController(); const t = setTimeout(() => ac.abort(), TIMEOUT());
|
||||
try {
|
||||
const r = await fetch(String(process.env.HUB_URL).trim().replace(/\/+$/, '') + '/v1/resolve', { method: 'POST', body: raw, signal: ac.signal,
|
||||
headers: { 'Content-Type': 'application/json', 'X-Hub-Site': String(process.env.HUB_SITE || DEFAULT_SITE).trim(), 'X-Hub-Ts': ts, 'X-Hub-Sig': sig } });
|
||||
if (r.status !== 200) throw new Error('hub answered ' + r.status);
|
||||
const j = await r.json();
|
||||
if (!j || typeof j !== 'object' || !('person' in j)) throw new Error('hub answer has no person field');
|
||||
return j.person && typeof j.person === 'object' ? j.person : null;
|
||||
} finally { clearTimeout(t); }
|
||||
}
|
||||
|
||||
// {ok: true, person: view | null} when the hub answered; {ok: false} when it is off or unreachable (the caller falls back)
|
||||
async function resolve(body) {
|
||||
if (!on() || Date.now() < downUntil) return { ok: false };
|
||||
const k = JSON.stringify(body); const hit = cache.get(k);
|
||||
if (hit && Date.now() - hit.at < TTL()) { stats.cached++; return { ok: true, person: hit.person }; }
|
||||
stats.asked++;
|
||||
let person;
|
||||
try { person = await call(body); } catch (e) {
|
||||
stats.failed++; downUntil = Date.now() + Number(process.env.HUB_DOWN_MS || 30000);
|
||||
if (!lastError || Date.now() - lastError.at > 600000) console.error('hub lookup failed, falling back:', e.name === 'AbortError' ? 'timeout' : e.message);
|
||||
lastError = { at: Date.now(), error: e.name === 'AbortError' ? 'timeout' : String(e.message).slice(0, 120) };
|
||||
return { ok: false };
|
||||
}
|
||||
if (cache.size > 20000) cache.clear();
|
||||
cache.set(k, { at: Date.now(), person });
|
||||
if (person && person.id) cache.set(JSON.stringify({ id: person.id }), { at: Date.now(), person });
|
||||
return { ok: true, person };
|
||||
}
|
||||
|
||||
const wallet = p => (p && ADDR_RE.test(String(p.wallet || '').toLowerCase()) ? String(p.wallet).toLowerCase() : null);
|
||||
// a username or wallet -> person (a blocked person counts as unknown)
|
||||
async function byRef(ref) { const r = await resolve({ ref: String(ref || '').trim().toLowerCase() }); return r.ok ? { ok: true, person: r.person && !r.person.blocked ? r.person : null } : r; }
|
||||
async function byWallet(w) { const r = await resolve({ wallet: String(w || '').trim().toLowerCase() }); return r.ok ? { ok: true, person: r.person && !r.person.blocked ? r.person : null } : r; }
|
||||
async function byId(id) { if (!/^h_[0-9a-f]{16}$/.test(String(id || ''))) return { ok: true, person: null }; const r = await resolve({ id: String(id) }); return r.ok ? { ok: true, person: r.person && !r.person.blocked ? r.person : null } : r; }
|
||||
// the person's network sponsor as a full person (with wallet), resolved through the hub by hub id. {ok, person: sponsor or null}
|
||||
async function sponsorOf(p) { if (!p || !p.sponsor || !p.sponsor.id) return { ok: true, person: null }; return byId(p.sponsor.id); }
|
||||
|
||||
function view() { return { on: on(), down: Date.now() < downUntil, cached: cache.size, stats, lastError }; }
|
||||
module.exports = { resolve, byRef, byWallet, byId, sponsorOf, wallet, view, on, _reset: () => { cache.clear(); downUntil = 0; } };
|
||||
@@ -0,0 +1,155 @@
|
||||
// The check pipeline, run in a small in-process queue (2 at a time): website -> contract -> chain -> scoring -> fact check.
|
||||
// Everything here only READS public data. No wallet, no key, no transaction.
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
const { spawn } = require('child_process');
|
||||
const db = require('./db');
|
||||
const website = require('./website');
|
||||
const report = require('./report');
|
||||
|
||||
const CHAINS = { bsc: { name: 'BNB Chain', rpc: ['https://bsc-dataseed.bnbchain.org', 'https://bsc-rpc.publicnode.com'] },
|
||||
polygon: { name: 'Polygon', rpc: ['https://polygon-bor-rpc.publicnode.com', 'https://polygon.drpc.org'] },
|
||||
eth: { name: 'Ethereum', rpc: ['https://ethereum-rpc.publicnode.com', 'https://eth.drpc.org'] },
|
||||
base: { name: 'Base', rpc: ['https://base-rpc.publicnode.com', 'https://mainnet.base.org'] } };
|
||||
const STEPS = ['website', 'contract', 'chain', 'scoring', 'factcheck'];
|
||||
const STEP_NAMES = { website: 'Reading the website', contract: 'Finding the contract', chain: 'Reading the chain', scoring: 'Scoring', factcheck: 'Fact-checking' };
|
||||
const CONCURRENCY = Number(process.env.JOBS || 2);
|
||||
const CHAIN_BUDGET = Number(process.env.CHAIN_BUDGET_S || 420);
|
||||
const WORK = () => path.join(process.env.DATA_DIR || path.join(__dirname, 'data'), 'work');
|
||||
let running = 0; const queue = [];
|
||||
|
||||
async function getCode(chain, a) {
|
||||
for (const u of CHAINS[chain].rpc) {
|
||||
try {
|
||||
const r = await fetch(u, { method: 'POST', headers: { 'Content-Type': 'application/json' }, signal: AbortSignal.timeout(12000), body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'eth_getCode', params: [a, 'latest'] }) });
|
||||
const j = await r.json(); if (j && typeof j.result === 'string') return j.result;
|
||||
} catch (e) {}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function enqueue(id) { queue.push(id); pump(); }
|
||||
function pump() { while (running < CONCURRENCY && queue.length) { const id = queue.shift(); running++; run(id).catch(e => console.error('job', id, e)).finally(() => { running--; pump(); }); } }
|
||||
const qpos = id => queue.indexOf(id);
|
||||
|
||||
async function setStep(id, steps, name, state, note) {
|
||||
steps[name] = Object.assign(steps[name] || {}, { state, note: note || (steps[name] || {}).note || null, at: Date.now() });
|
||||
await db.q('UPDATE checks SET step = ?, steps_json = ? WHERE id = ?', [name, JSON.stringify(steps), id]);
|
||||
}
|
||||
|
||||
function runScan(chain, address, dir, abiFile, onStep) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const args = [path.join(__dirname, 'chain', 'scan.py'), chain, address, dir, '--budget', String(CHAIN_BUDGET)];
|
||||
if (abiFile) args.push('--hint-abi', abiFile);
|
||||
const p = spawn(process.env.PYTHON || 'python3', args, { cwd: path.join(__dirname, 'chain'), env: Object.assign({}, process.env, { PYTHONUNBUFFERED: '1' }) });
|
||||
let err = ''; let buf = '';
|
||||
const kill = setTimeout(() => { try { p.kill('SIGKILL'); } catch (e) {} }, (CHAIN_BUDGET + 240) * 1000);
|
||||
p.stdout.on('data', d => { buf += d; let i; while ((i = buf.indexOf('\n')) >= 0) { const line = buf.slice(0, i); buf = buf.slice(i + 1); try { const j = JSON.parse(line); if (j.step) onStep(j); } catch (e) {} } });
|
||||
p.stderr.on('data', d => { err += d; if (err.length > 20000) err = err.slice(-20000); });
|
||||
p.on('close', code => { clearTimeout(kill); if (code === 0) resolve(); else reject(new Error('chain scan exited ' + code + ': ' + err.slice(-600))); });
|
||||
});
|
||||
}
|
||||
|
||||
async function run(id) {
|
||||
const c = await db.one('SELECT * FROM checks WHERE id = ?', [id]); if (!c) return;
|
||||
const steps = {}; const t = { start: Date.now() };
|
||||
await db.q("UPDATE checks SET status = 'running', started = ? WHERE id = ?", [Date.now(), id]);
|
||||
let siteRes = null; let chain = c.chain; let address = c.address ? c.address.toLowerCase() : null; let pickedNote = null;
|
||||
try {
|
||||
// 1. website
|
||||
if (c.website) {
|
||||
await setStep(id, steps, 'website', 'running');
|
||||
try {
|
||||
siteRes = await website.scan(c.website);
|
||||
if (siteRes.screenshot) await db.q('REPLACE INTO screenshots (check_id, mime, bytes, created) VALUES (?,?,?,?)', [id, 'image/jpeg', siteRes.screenshot, Date.now()]);
|
||||
await setStep(id, steps, 'website', siteRes.ok ? 'done' : 'failed', siteRes.ok ? 'Read "' + (siteRes.title || siteRes.finalUrl || c.website) + '"' : (siteRes.notes[0] || 'The page could not be read.'));
|
||||
} catch (e) { siteRes = { ok: false, notes: ['The page could not be read: ' + String(e.message).split('\n')[0].slice(0, 160)], addresses: [], chainHints: {}, abi: [] }; await setStep(id, steps, 'website', 'failed', siteRes.notes[0]); }
|
||||
} else await setStep(id, steps, 'website', 'skipped', 'No website entered.');
|
||||
t.website = Date.now();
|
||||
|
||||
// 2. contract
|
||||
await setStep(id, steps, 'contract', 'running');
|
||||
if (address) {
|
||||
pickedNote = 'Contract address entered by you.';
|
||||
} else if (siteRes && siteRes.addresses && siteRes.addresses.length) {
|
||||
const hints = Object.entries(siteRes.chainHints || {}).sort((a, b) => b[1] - a[1]).map(x => x[0]);
|
||||
const order = [chain].concat(hints.filter(h => h !== chain));
|
||||
let found = null;
|
||||
for (const cand of siteRes.addresses.slice(0, 8)) {
|
||||
for (const ch of order) {
|
||||
const code = await getCode(ch, cand.address);
|
||||
if (code && code.length > 2 && !code.startsWith('0xef0100')) { found = { cand, ch }; break; }
|
||||
}
|
||||
if (found) break;
|
||||
}
|
||||
if (found) {
|
||||
address = found.cand.address; const switched = found.ch !== chain; chain = found.ch;
|
||||
pickedNote = 'No contract was entered. We found ' + siteRes.addresses.length + ' address' + (siteRes.addresses.length === 1 ? '' : 'es') + ' on the website and used ' + address +
|
||||
' because it appears in: ' + found.cand.seen.join(', ') + ', and it has contract code on ' + CHAINS[chain].name + '.' + (switched ? ' It has no code on the chain you picked, so we read it on ' + CHAINS[chain].name + ' instead.' : '');
|
||||
} else pickedNote = 'No contract was entered, and none of the ' + siteRes.addresses.length + ' addresses on the website has contract code on the chains we checked.';
|
||||
} else {
|
||||
pickedNote = c.website ? 'No contract was entered, and we found no contract address on the website.' : 'No contract address.';
|
||||
}
|
||||
await db.q('UPDATE checks SET address = ?, chain = ?, picked_note = ? WHERE id = ?', [address, chain, pickedNote, id]);
|
||||
await setStep(id, steps, 'contract', address ? 'done' : 'failed', pickedNote);
|
||||
t.contract = Date.now();
|
||||
|
||||
let E = null, pack = null, facts = [];
|
||||
if (address) {
|
||||
// 3. chain (reuse a scan of the same contract from the last 30 minutes: free check, then deep report)
|
||||
await setStep(id, steps, 'chain', 'running', 'Reading roles, upgrades, events, token flows and approvals.');
|
||||
const prev = await db.one("SELECT evidence_json, pack_md, facts_json, finished FROM checks WHERE chain = ? AND address = ? AND evidence_json IS NOT NULL AND finished > ? AND id <> ? ORDER BY finished DESC LIMIT 1",
|
||||
[chain, address, Date.now() - 30 * 60000, id]);
|
||||
if (prev) { E = JSON.parse(prev.evidence_json); pack = prev.pack_md; facts = JSON.parse(prev.facts_json || '[]'); await setStep(id, steps, 'chain', 'done', 'Reused the chain read from ' + Math.round((Date.now() - prev.finished) / 60000) + ' min ago (block ' + E.read_at.block + ').'); }
|
||||
else {
|
||||
const dir = path.join(WORK(), id); fs.mkdirSync(dir, { recursive: true });
|
||||
let abiFile = null;
|
||||
if (siteRes && siteRes.abi && siteRes.abi.length) { abiFile = path.join(dir, 'site-abi.json'); fs.writeFileSync(abiFile, JSON.stringify(siteRes.abi)); }
|
||||
await runScan(chain, address, dir, abiFile, j => setStep(id, steps, 'chain', 'running', 'Chain read: ' + j.step + (j.blocks ? ' (' + j.blocks.toLocaleString('en-US') + ' blocks)' : '')).catch(() => {}));
|
||||
E = JSON.parse(fs.readFileSync(path.join(dir, 'evidence.json'), 'utf8'));
|
||||
pack = fs.readFileSync(path.join(dir, 'pack.md'), 'utf8');
|
||||
facts = JSON.parse(fs.readFileSync(path.join(dir, 'facts.json'), 'utf8'));
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
await setStep(id, steps, 'chain', 'done', 'Read blocks ' + E.window.from + ' to ' + E.window.to + (E.window.complete_history ? ' (complete history)' : ' (partial window)') + '.');
|
||||
}
|
||||
facts = report.deepClean(facts);
|
||||
} else await setStep(id, steps, 'chain', 'skipped', 'No contract to read.');
|
||||
t.chain = Date.now();
|
||||
await db.q('UPDATE checks SET evidence_json = ?, pack_md = ?, facts_json = ?, pack_chars = ?, site_json = ? WHERE id = ?',
|
||||
[E ? JSON.stringify(E) : null, pack, JSON.stringify(facts), pack ? pack.length : 0,
|
||||
siteRes ? JSON.stringify({ ok: siteRes.ok, title: siteRes.title, finalUrl: siteRes.finalUrl, status: siteRes.status, notes: siteRes.notes, addresses: siteRes.addresses, chainHints: siteRes.chainHints, explorerLinks: siteRes.explorerLinks, abiCount: (siteRes.abi || []).length, textChars: (siteRes.text || '').length }) : null, id]);
|
||||
|
||||
// 4 + 5. scoring and fact check
|
||||
if (!E && !(siteRes && siteRes.ok)) throw new Error(pickedNote || 'Nothing to check.');
|
||||
await setStep(id, steps, 'scoring', 'running', c.kind === 'deep' ? 'Writing the deep report.' : 'Writing the scorecard.');
|
||||
const key = String(process.env.OPENROUTER_API_KEY || '').trim();
|
||||
let out;
|
||||
if (!E) {
|
||||
out = { ok: false, report: null, grade: null, factcheck: { passed: false, runs: [], note: 'There is no contract to score. A score needs a contract to read: add the address, or a website that shows it.' }, cost: 0, tin: 0, tout: 0, model: null };
|
||||
} else if (!E.is_contract) {
|
||||
out = { ok: false, report: null, grade: null, factcheck: { passed: false, runs: [], note: 'This address is a personal wallet, not a contract, so there is no code to score.' }, cost: 0, tin: 0, tout: 0, model: null };
|
||||
} else if (!key) throw new Error('OPENROUTER_API_KEY is not set');
|
||||
else {
|
||||
out = await report.write({ kind: c.kind, pack, siteText: siteRes && siteRes.ok ? siteRes.text : '', facts, evidence: E, key });
|
||||
}
|
||||
await setStep(id, steps, 'scoring', out.report ? 'done' : (E && E.is_contract ? 'failed' : 'skipped'), out.report ? 'Scored with the published rubric.' : out.factcheck.note);
|
||||
await setStep(id, steps, 'factcheck', out.factcheck.passed ? 'done' : (out.report === null && E && E.is_contract ? 'failed' : 'skipped'),
|
||||
out.factcheck.passed ? 'Every address, transaction and number matched the evidence.' : out.factcheck.note);
|
||||
t.done = Date.now();
|
||||
const timings = { website_s: (t.website - t.start) / 1000, contract_s: (t.contract - t.website) / 1000, chain_s: (t.chain - t.contract) / 1000, report_s: (t.done - t.chain) / 1000, total_s: (t.done - t.start) / 1000 };
|
||||
await db.q("UPDATE checks SET status = 'done', finished = ?, timings_json = ?, model = ?, cost_usd = ?, tokens_in = ?, tokens_out = ?, report_json = ?, factcheck_json = ? WHERE id = ?",
|
||||
[Date.now(), JSON.stringify(timings), out.model, out.cost, out.tin, out.tout, out.report ? JSON.stringify({ report: out.report, grade: out.grade }) : null, JSON.stringify(out.factcheck), id]);
|
||||
} catch (e) {
|
||||
console.error('check', id, e.message);
|
||||
await db.q("UPDATE checks SET status = 'failed', finished = ?, error = ? WHERE id = ?", [Date.now(), String(e.message).slice(0, 800), id]);
|
||||
}
|
||||
}
|
||||
|
||||
async function resume() {
|
||||
const rows = await db.q("SELECT id FROM checks WHERE status IN ('queued','running') ORDER BY created");
|
||||
for (const r of rows) { await db.q("UPDATE checks SET status = 'queued' WHERE id = ?", [r.id]); enqueue(r.id); }
|
||||
}
|
||||
const newId = () => crypto.randomBytes(9).toString('base64').replace(/[+/=]/g, '').slice(0, 12).padEnd(12, 'x');
|
||||
module.exports = { enqueue, resume, newId, qpos, CHAINS, STEPS, STEP_NAMES, running: () => running, queued: () => queue.length };
|
||||
@@ -0,0 +1,289 @@
|
||||
// Knowledge base behind the site assistant (Marty's support-desk plan, 2026-10-20).
|
||||
// The chatbot answers from maintained entries, and good support replies become entries.
|
||||
//
|
||||
// An entry: { id, title, questions[], answer, tags[], pattern, handoff, order, source, ticketRef,
|
||||
// updated, created, edited, deleted, seedHash }
|
||||
// pattern optional regex (case-insensitive). Entries with one are the instant CANNED fast path:
|
||||
// the first pattern that matches (lowest order) is the reply, no AI call. The CANNED list
|
||||
// in chatbot.js seeds these, so there is ONE source: edit the answer here and the fast
|
||||
// path serves the new text.
|
||||
// source canned | faq | ticket | admin
|
||||
//
|
||||
// Retrieval: BM25 over title, question variants and tags, plus the answer text at a low weight, with
|
||||
// word bigrams so phrase overlap counts more than scattered words. No embeddings, no external calls.
|
||||
// The top hits go into the AI system prompt as "Knowledge base" context (chatbot.js).
|
||||
//
|
||||
// Seeds stay in step with the code: an entry that came from a seed and was never edited in the admin
|
||||
// pane is refreshed when the seed text changes; an edited one is left alone; a deleted seed stays
|
||||
// deleted (tombstone row), and a seed dropped from the code is retired unless an admin edited it.
|
||||
//
|
||||
// Store: DATA_DIR/kb.json (written to a temp file and renamed), which docstore.js keeps in MySQL when DOCSTORE_URL is set
|
||||
// (Marty's database rule). Ported from LinkSpin's kb.js (2026-11-15); keep the scoring and seed rules in step.
|
||||
//
|
||||
// NETWORK (2026-11-15, netkb.js): the other network sites' entries, read from the hub, sit in the same index. This site's
|
||||
// own entries are boosted first (HOME_BOOST); a question that names another site boosts that site's entries instead
|
||||
// (NAMED_BOOST). Other sites' entries never take the instant-answer fast path: they only ride along as context, labelled
|
||||
// with the site and the link to send people to. This site's own entries are published to the hub (netkb.publish).
|
||||
// The SAME file ships in ViralAdBlitz, DownlineHydra, 5xYourTeam, Viral Banner Blitz, Downline Banners and Stack POL.
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
let netkb = null; try { netkb = require('./netkb'); } catch (e) {}
|
||||
|
||||
let DATA_DIR = null, SEEDS = [], ready = null, SITE_URL = '', HELP_TEXT = '', MEMORY = false;
|
||||
let cache = null, cacheAt = 0, index = null, netVer = '';
|
||||
const TTL = 30000; // two app copies share the volume for about 30 s during a deploy: re-read now and then
|
||||
|
||||
// ---------------------------------------------------------------- text + scoring (pure, unit-tested)
|
||||
const STOP = new Set(('a an and are as at be been being but by can could do does did doing for from has have having how i if in into is it its '
|
||||
+ 'me my of on or our ours so than that the their them then there these they this those to too us was we were what when where which who whom why '
|
||||
+ 'will with would you your yours im ive id am just also any about please hi hello hey thanks thank ok okay really very much some there here '
|
||||
+ 'should shall may might must anyone someone something thing things want wanted like know tell').split(' '));
|
||||
const SYN = { paid: 'pay', payment: 'pay', payments: 'pay', paying: 'pay', withdrawal: 'withdraw', withdrawals: 'withdraw', cashout: 'withdraw',
|
||||
signup: 'join', register: 'join', registration: 'join', joining: 'join', joined: 'join', login: 'log', logged: 'log', logout: 'log', signin: 'log',
|
||||
wallets: 'wallet', email: 'email', mail: 'email', pol: 'pol', matic: 'pol', prices: 'price', pricing: 'price', cost: 'price', costs: 'price',
|
||||
ads: 'ad', advert: 'ad', adverts: 'ad', advertising: 'ad', referrals: 'referral', refer: 'referral', referring: 'referral', referred: 'referral' };
|
||||
function stem(w) {
|
||||
if (SYN[w]) return SYN[w];
|
||||
if (w.length > 6 && w.endsWith('able')) return w.slice(0, -4);
|
||||
if (w.length > 5 && w.endsWith('ing')) return w.slice(0, -3);
|
||||
if (w.length > 4 && w.endsWith('ies')) return w.slice(0, -3) + 'y';
|
||||
if (w.length > 4 && w.endsWith('ed') && !w.endsWith('eed')) return w.slice(0, -2);
|
||||
if (w.length > 3 && w.endsWith('s') && !w.endsWith('ss') && !w.endsWith('us')) return w.slice(0, -1);
|
||||
return w;
|
||||
}
|
||||
function words(text) {
|
||||
return String(text || '').toLowerCase().replace(/['’]/g, '').replace(/[^a-z0-9$]+/g, ' ').split(' ')
|
||||
.filter(w => w && !STOP.has(w) && (w.length > 1 || /\d/.test(w))).map(stem);
|
||||
}
|
||||
// unigrams + bigrams of the content words: "coinbase account" scores as a phrase, not two loose words
|
||||
function terms(text) {
|
||||
const w = words(text), out = w.slice();
|
||||
for (let i = 0; i + 1 < w.length; i++) out.push(w[i] + '_' + w[i + 1]);
|
||||
return out;
|
||||
}
|
||||
const FIELDS = { title: 2.0, questions: 2.5, tags: 2.0, answer: 0.35 };
|
||||
const K1 = 1.2, B = 0.75;
|
||||
function fieldText(e, f) {
|
||||
if (f === 'questions') return (e.questions || []).join(' . ');
|
||||
if (f === 'tags') return (e.tags || []).join(' . ');
|
||||
return e[f] || '';
|
||||
}
|
||||
function buildIndex(entries) {
|
||||
const docs = entries.map(e => {
|
||||
const d = { e, f: {} };
|
||||
for (const f of Object.keys(FIELDS)) {
|
||||
const t = terms(fieldText(e, f)), tf = new Map();
|
||||
for (const x of t) tf.set(x, (tf.get(x) || 0) + 1);
|
||||
d.f[f] = { tf, len: t.length };
|
||||
}
|
||||
return d;
|
||||
});
|
||||
const df = new Map(), avg = {};
|
||||
for (const f of Object.keys(FIELDS)) avg[f] = docs.reduce((s, d) => s + d.f[f].len, 0) / Math.max(1, docs.length) || 1;
|
||||
for (const d of docs) {
|
||||
const seen = new Set();
|
||||
for (const f of Object.keys(FIELDS)) for (const t of d.f[f].tf.keys()) seen.add(t);
|
||||
for (const t of seen) df.set(t, (df.get(t) || 0) + 1);
|
||||
}
|
||||
return { docs, df, avg, n: docs.length };
|
||||
}
|
||||
const HOME_BOOST = 2, NAMED_BOOST = 3;
|
||||
// which network sites a question names, by the site name or a short alias ("dlb", "vbb", "iap", ...)
|
||||
const ALIASES = { iap: ['iap', 'instant ad pay'], linkspin: ['link spin'], bannerline: ['dlb', 'downline banner', 'downline banners'], vbb: ['vbb', 'viral banner'],
|
||||
viraladblitz: ['vab', 'viral ad blitz'], downlinehydra: ['hydra', 'dh'], fivex: ['5x', '5x your team', 'five x', 'the draft'], stackpol: ['stack pol', 'stackpol'] };
|
||||
const norm = s => ' ' + String(s || '').toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim() + ' ';
|
||||
function namedSites(query, idx) {
|
||||
const q = norm(query); const out = new Set();
|
||||
for (const s of (idx && idx.sites) || []) {
|
||||
const names = [s.name, s.site].concat(ALIASES[s.site] || []).map(norm);
|
||||
if (names.some(n => n.trim() && q.includes(n))) out.add(s.site);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
// does the question name a network site other than this one (hub site id `self`)? Then the home fast path stands aside and the
|
||||
// answer comes from retrieval over the whole network (a "how much" about another site must not get this site's price).
|
||||
const NAMES = { iap: 'InstantAdPay', linkspin: 'LinkSpin', bannerline: 'Downline Banners', vbb: 'Viral Banner Blitz', viraladblitz: 'ViralAdBlitz',
|
||||
downlinehydra: 'DownlineHydra', fivex: '5xYourTeam', stackpol: 'Stack POL', earnerscorner: 'Earners Corner' };
|
||||
function namesOther(query, self) {
|
||||
const q = norm(query); const out = [];
|
||||
const ids = new Set(Object.keys(NAMES).concat(((index && index.sites) || []).map(s => s.site)));
|
||||
for (const id of ids) {
|
||||
if (id === self) continue;
|
||||
const s = ((index && index.sites) || []).find(x => x.site === id) || {};
|
||||
const names = [s.name, NAMES[id], id.length > 3 ? id : ''].concat(ALIASES[id] || []).filter(Boolean).map(norm);
|
||||
if (names.some(n => n.trim() && q.includes(n))) out.push(id);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
function rank(idx, query, k) {
|
||||
if (!idx || !idx.n) return [];
|
||||
const qt = [...new Set(terms(query))];
|
||||
if (!qt.length) return [];
|
||||
const named = namedSites(query, idx);
|
||||
const out = [];
|
||||
for (const d of idx.docs) {
|
||||
let s = 0;
|
||||
for (const t of qt) {
|
||||
const n = idx.df.get(t); if (!n) continue;
|
||||
const idf = Math.log(1 + (idx.n - n + 0.5) / (n + 0.5)) * (t.includes('_') ? 1.5 : 1);
|
||||
for (const f of Object.keys(FIELDS)) {
|
||||
const tf = d.f[f].tf.get(t); if (!tf) continue;
|
||||
s += FIELDS[f] * idf * (tf * (K1 + 1)) / (tf + K1 * (1 - B + B * d.f[f].len / idx.avg[f]));
|
||||
}
|
||||
}
|
||||
if (s > 0 && d.e.site) s *= named.has(d.e.site) ? NAMED_BOOST : 1;
|
||||
else if (s > 0) s *= named.size ? 1 : HOME_BOOST;
|
||||
if (s > 0) out.push({ entry: d.e, score: Math.round(s * 100) / 100 });
|
||||
}
|
||||
out.sort((a, b) => b.score - a.score);
|
||||
return out.slice(0, k || 5);
|
||||
}
|
||||
// keep hits that are close to the best one, and only when the best is a real match
|
||||
const MIN_SCORE = 3;
|
||||
function relevant(hits) {
|
||||
if (!hits.length || hits[0].score < MIN_SCORE) return [];
|
||||
const floor = Math.max(MIN_SCORE, hits[0].score * 0.3);
|
||||
return hits.filter(h => h.score >= floor);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- store
|
||||
const mem = { entries: [] }; // a site with no data volume (Stack POL): seeds in memory only
|
||||
const J = {
|
||||
file: () => path.join(DATA_DIR, 'kb.json'),
|
||||
async ensure() {},
|
||||
async all() { if (MEMORY) return mem.entries.slice(); try { const d = JSON.parse(fs.readFileSync(J.file(), 'utf8')); return Array.isArray(d.entries) ? d.entries : []; } catch (e) { return []; } },
|
||||
async put(e) {
|
||||
const all = await J.all(), i = all.findIndex(x => x.id === e.id);
|
||||
if (i >= 0) all[i] = e; else all.push(e);
|
||||
if (MEMORY) { mem.entries = all; return; }
|
||||
const tmp = J.file() + '.tmp';
|
||||
fs.writeFileSync(tmp, JSON.stringify({ entries: all }));
|
||||
fs.renameSync(tmp, J.file());
|
||||
}
|
||||
};
|
||||
const store = () => J;
|
||||
|
||||
// ---------------------------------------------------------------- seeds
|
||||
const SEED_FIELDS = ['title', 'questions', 'answer', 'tags', 'pattern', 'handoff', 'order', 'source'];
|
||||
const seedHash = s => crypto.createHash('sha1').update(JSON.stringify(SEED_FIELDS.map(f => s[f] == null ? null : s[f]))).digest('hex');
|
||||
function seedEntry(s) {
|
||||
return { id: s.id, title: s.title, questions: s.questions || [], answer: s.answer, tags: s.tags || [], pattern: s.pattern || '', handoff: !!s.handoff,
|
||||
order: s.order == null ? null : s.order, source: s.source || 'faq' };
|
||||
}
|
||||
async function syncSeeds() {
|
||||
const all = await store().all(), byId = new Map(all.map(e => [e.id, e])), now = Date.now();
|
||||
const seedIds = new Set(SEEDS.map(s => s.id));
|
||||
let added = 0, refreshed = 0, retired = 0;
|
||||
for (const s of SEEDS) {
|
||||
const h = seedHash(seedEntry(s)), cur = byId.get(s.id);
|
||||
if (!cur) { await store().put(Object.assign(seedEntry(s), { ticketRef: '', seedHash: h, edited: false, deleted: false, created: now, updated: now })); added++; }
|
||||
else if (!cur.deleted && !cur.edited && cur.seedHash !== h) { await store().put(Object.assign({}, cur, seedEntry(s), { seedHash: h, updated: now })); refreshed++; }
|
||||
}
|
||||
// a seed taken out of the code goes with it, unless an admin has made the entry their own (guard: a broken seed list retires nothing)
|
||||
if (SEEDS.length >= 10) for (const e of all) if (e.seedHash && !e.edited && !e.deleted && !seedIds.has(e.id)) { await store().put(Object.assign({}, e, { deleted: true, updated: now })); retired++; }
|
||||
if (added || refreshed || retired) console.log('kb: seeds synced, ' + added + ' added, ' + refreshed + ' refreshed, ' + retired + ' retired');
|
||||
}
|
||||
|
||||
// opts: { dataDir (null = memory only), seeds, siteUrl, helpText (where a member gets a person) }
|
||||
function init(opts) {
|
||||
DATA_DIR = opts.dataDir || null; MEMORY = !DATA_DIR; SEEDS = opts.seeds || []; cache = null; index = null; mem.entries = [];
|
||||
SITE_URL = String(opts.siteUrl || '').replace(/\/+$/, ''); HELP_TEXT = opts.helpText || 'network support at https://instantadpay.com/support';
|
||||
ready = (async () => { await store().ensure(); await syncSeeds(); })().catch(e => { console.error('kb init', e.message); });
|
||||
return ready;
|
||||
}
|
||||
// this site's own entries, for netkb.publish
|
||||
async function own() { await load(); return cache.slice(); }
|
||||
async function load(force) {
|
||||
if (ready) await ready;
|
||||
if (!force && cache && Date.now() - cacheAt < TTL && (!netkb || netkb.version() === netVer)) return cache; // a new network set rebuilds at once
|
||||
const all = await store().all();
|
||||
cache = all.filter(e => !e.deleted); cacheAt = Date.now(); rx.clear(); netVer = netkb ? netkb.version() : '';
|
||||
index = buildIndex(cache.concat(netkb ? netkb.remote() : [])); index.sites = netkb ? netkb.sites() : [];
|
||||
return cache;
|
||||
}
|
||||
const rx = new Map();
|
||||
function compiled(src) {
|
||||
if (!rx.has(src)) { let r = null; try { r = new RegExp(src, 'i'); } catch (e) {} rx.set(src, r); }
|
||||
return rx.get(src);
|
||||
}
|
||||
const byOrder = (a, b) => (a.order == null ? 1e9 : a.order) - (b.order == null ? 1e9 : b.order) || a.updated - b.updated;
|
||||
|
||||
// ---------------------------------------------------------------- the chatbot side
|
||||
async function fastPath(msg) {
|
||||
const list = (await load()).filter(e => e.pattern).sort(byOrder);
|
||||
for (const e of list) { const r = compiled(e.pattern); if (r && r.test(msg)) return e; }
|
||||
return null;
|
||||
}
|
||||
async function search(query, k) { await load(); return rank(index, query, k || 5); }
|
||||
async function context(query, k) { return relevant(await search(query, k || 6)); }
|
||||
const label = e => e.site ? ' (about ' + e.siteName + ', another network site; send people to ' + e.go + ')' : '';
|
||||
function promptBlock(hits) {
|
||||
const unsure = 'say "I\'m not sure, ask support" and point to ' + HELP_TEXT + '.';
|
||||
if (!hits.length) return 'KNOWLEDGE BASE: no entry matches this question. If the FACTS above do not answer it either, ' + unsure + ' Do not guess.';
|
||||
return 'KNOWLEDGE BASE (maintained answers, most relevant first). Answer from these when one fits: keep its facts, numbers and links exactly, in your own short words. '
|
||||
+ 'If none of them and none of the FACTS answer the question, ' + unsure + ' Never guess.\n'
|
||||
+ hits.map((h, i) => '[' + (i + 1) + '] ' + h.entry.title + label(h.entry) + '\nAsked as: ' + (h.entry.questions || []).slice(0, 4).join(' | ') + '\nAnswer: ' + h.entry.answer).join('\n\n');
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- the admin side
|
||||
const clean = s => String(s == null ? '' : s).replace(/\s*[—―]\s*/g, ', ').replace(/(\d)\s*–\s*(\d)/g, '$1-$2').replace(/\s*–\s*/g, ', ').replace(/\r\n/g, '\n').trim(); // house rule: no em dashes in member-facing text
|
||||
function validate(o, cur) {
|
||||
o = o || {};
|
||||
const questions = (Array.isArray(o.questions) ? o.questions : String(o.questions || '').split('\n')).map(clean).filter(Boolean).map(q => q.slice(0, 300)).slice(0, 15);
|
||||
const tags = (Array.isArray(o.tags) ? o.tags : String(o.tags || '').split(',')).map(t => clean(t).toLowerCase().slice(0, 40)).filter(Boolean).slice(0, 15);
|
||||
const answer = clean(o.answer).slice(0, 4000);
|
||||
const title = (clean(o.title) || questions[0] || '').slice(0, 200);
|
||||
const pattern = String(o.pattern == null ? (cur ? cur.pattern : '') : o.pattern).trim().slice(0, 2000);
|
||||
if (!title) return { error: 'Give the entry a title or at least one question.' };
|
||||
if (!answer) return { error: 'The answer is empty.' };
|
||||
if (pattern) { try { new RegExp(pattern, 'i'); } catch (e) { return { error: 'The instant-answer pattern is not a valid regular expression: ' + e.message }; } }
|
||||
const order = o.order === '' || o.order == null ? (cur ? cur.order : null) : Number(o.order);
|
||||
return { title, questions, tags, answer, pattern, handoff: o.handoff == null ? !!(cur && cur.handoff) : !!o.handoff, order: Number.isFinite(order) ? Math.round(order) : null };
|
||||
}
|
||||
async function list(q) {
|
||||
const all = (await load(true)).slice();
|
||||
if (!q) return all.sort((a, b) => b.updated - a.updated);
|
||||
const ranked = rank(index, q, 50).filter(h => !h.entry.site).map(h => Object.assign({ score: h.score }, h.entry));
|
||||
const lc = String(q).toLowerCase(), seen = new Set(ranked.map(e => e.id));
|
||||
const plain = all.filter(e => !seen.has(e.id) && (e.id.includes(lc) || (e.title + ' ' + e.answer + ' ' + (e.ticketRef || '')).toLowerCase().includes(lc)));
|
||||
return ranked.concat(plain);
|
||||
}
|
||||
async function get(id) { return (await load(true)).find(e => e.id === String(id)) || null; }
|
||||
async function create(o) {
|
||||
const v = validate(o); if (v.error) return v;
|
||||
const now = Date.now(), id = 'kb-' + now.toString(36) + crypto.randomBytes(2).toString('hex');
|
||||
const src = ['ticket', 'admin'].includes(o.source) ? o.source : 'admin';
|
||||
const e = Object.assign(v, { id, source: src, ticketRef: String(o.ticketRef || '').slice(0, 20), seedHash: '', edited: true, deleted: false, created: now, updated: now });
|
||||
await store().put(e); await load(true); if (netkb) netkb.publishSoon();
|
||||
return { ok: true, entry: e };
|
||||
}
|
||||
async function update(id, o) {
|
||||
const cur = await get(id); if (!cur) return { error: 'Entry not found.' };
|
||||
const v = validate(o, cur); if (v.error) return v;
|
||||
const e = Object.assign({}, cur, v, { edited: true, updated: Date.now() });
|
||||
await store().put(e); await load(true); if (netkb) netkb.publishSoon();
|
||||
return { ok: true, entry: e };
|
||||
}
|
||||
async function remove(id) {
|
||||
const cur = await get(id); if (!cur) return { error: 'Entry not found.' };
|
||||
await store().put(Object.assign({}, cur, { deleted: true, updated: Date.now() })); await load(true); if (netkb) netkb.publishSoon();
|
||||
return { ok: true };
|
||||
}
|
||||
// newest change made by a person (admin pane or a saved ticket reply), as a Central-time day. The chatbot-sync
|
||||
// guard compares it with release-note dates. Seed refreshes do not count: those follow chatbot.js, whose
|
||||
// KNOWLEDGE_DATE already speaks for the code.
|
||||
const ctDay = ts => new Date(ts).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' });
|
||||
async function stamp() {
|
||||
const all = await load();
|
||||
const max = all.reduce((m, e) => e.edited ? Math.max(m, e.updated || 0) : m, 0);
|
||||
return { updated: max ? ctDay(max) : '', count: all.length };
|
||||
}
|
||||
async function test(question) {
|
||||
const fast = await fastPath(String(question || ''));
|
||||
const hits = await search(String(question || ''), 8), used = new Set(relevant(hits).map(h => h.entry.id));
|
||||
return { fast: fast ? { id: fast.id, title: fast.title } : null, ranked: hits.map(h => ({ id: h.entry.id, site: h.entry.site || '', title: h.entry.title, score: h.score, used: used.has(h.entry.id) })) };
|
||||
}
|
||||
|
||||
module.exports = { init, load, own, namesOther, fastPath, search, context, promptBlock, list, get, create, update, remove, stamp, test,
|
||||
_pure: { words, terms, buildIndex, rank, relevant, validate, seedHash, namedSites, MIN_SCORE, HOME_BOOST, NAMED_BOOST } };
|
||||
@@ -0,0 +1,106 @@
|
||||
// Shared network knowledge, site side (Marty 2026-11-15: every network site's chatbot answers about the whole network, with its
|
||||
// own site first). This site publishes its own knowledge-base entries to the network hub and reads the merged set back:
|
||||
// PUT HUB_URL/v1/kb {name, url, entries} replaces this site's set (the hub skips a set it already holds)
|
||||
// GET HUB_URL/v1/kb signed over an empty body, If-None-Match: the last version -> 304 when nothing changed
|
||||
// Signed as HUB_SITE with HUB_SECRET (X-Hub-Site, X-Hub-Ts, X-Hub-Sig = hex HMAC-SHA256(ts + "\n" + raw body)), like hubreport.js.
|
||||
// The merged set is kept in memory and in DATA_DIR/netkb-cache.json (a MySQL document through docstore where the site has
|
||||
// DOCSTORE_URL; written only when the version changes), so a hub outage at boot still answers about the other sites.
|
||||
// Off when HUB_URL or a 32+ character HUB_SECRET is missing, or NETKB=0: the chatbot then answers about this site only.
|
||||
// The SAME file ships in every network site (InstantAdPay, LinkSpin, ViralAdBlitz, DownlineHydra, 5xYourTeam, VBB, Downline
|
||||
// Banners, Stack POL). Keep them identical.
|
||||
'use strict';
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const REFRESH_MS = 10 * 60 * 1000;
|
||||
let O = null; // { dataDir, site, name, url, netId, entries: async () => [...], linkFor: (url) => link }
|
||||
let merged = { version: '', sites: {}, entries: [] }, loadedAt = 0, publishedHash = '', pubTimer = null, timer = null;
|
||||
const stats = { published: 0, publishErrors: 0, reads: 0, notModified: 0, readErrors: 0, lastError: null, lastPublishAt: 0, lastReadAt: 0 };
|
||||
|
||||
const hubUrl = () => String(process.env.HUB_URL || '').trim().replace(/\/+$/, '');
|
||||
const secret = () => String(process.env.HUB_SECRET || '').trim();
|
||||
const siteName = () => String(process.env.HUB_SITE || (O && O.site) || '').trim();
|
||||
const enabled = () => process.env.NETKB !== '0' && !!hubUrl() && secret().length >= 32 && !!siteName();
|
||||
const cacheFile = () => (O && O.dataDir ? path.join(O.dataDir, 'netkb-cache.json') : null);
|
||||
|
||||
async function call(method, route, body, headers) {
|
||||
const raw = body === undefined ? '' : JSON.stringify(body); const ts = String(Date.now());
|
||||
const sig = crypto.createHmac('sha256', secret()).update(ts + '\n' + raw).digest('hex');
|
||||
const r = await fetch(hubUrl() + route, { method, body: method === 'GET' ? undefined : raw, signal: AbortSignal.timeout(15000),
|
||||
headers: Object.assign({ 'Content-Type': 'application/json', 'X-Hub-Site': siteName(), 'X-Hub-Ts': ts, 'X-Hub-Sig': sig }, headers || {}) });
|
||||
let j = null; if (r.status !== 304) { try { j = await r.json(); } catch (e) {} }
|
||||
return { status: r.status, body: j };
|
||||
}
|
||||
|
||||
// the entries this site shares: what the chatbot's knowledge base holds, minus the instant-answer patterns (those stay home)
|
||||
const shape = e => ({ id: String(e.id), title: e.title, questions: (e.questions || []).slice(0, 15), answer: e.answer, tags: (e.tags || []).slice(0, 15), link: e.link || (O && O.url) || undefined });
|
||||
async function publish() {
|
||||
if (!enabled() || !O || typeof O.entries !== 'function') return { skipped: true };
|
||||
const entries = (await O.entries()).filter(e => e && e.id && e.answer && !e.deleted).map(shape);
|
||||
const body = { name: O.name, url: O.url, entries };
|
||||
const h = crypto.createHash('sha1').update(JSON.stringify(body)).digest('hex');
|
||||
if (h === publishedHash) return { same: true };
|
||||
try {
|
||||
const r = await call('PUT', '/v1/kb', body);
|
||||
if (r.status !== 200) { stats.publishErrors++; stats.lastError = 'publish ' + r.status + ' ' + ((r.body && r.body.error) || ''); return { error: stats.lastError }; }
|
||||
publishedHash = h; stats.published++; stats.lastPublishAt = Date.now();
|
||||
return r.body;
|
||||
} catch (e) { stats.publishErrors++; stats.lastError = 'publish ' + e.message; return { error: e.message }; }
|
||||
}
|
||||
// an admin edit: publish a few seconds later (several quick edits go as one)
|
||||
function publishSoon() { if (pubTimer) return; pubTimer = setTimeout(() => { pubTimer = null; publish().catch(() => {}); }, 5000); if (pubTimer.unref) pubTimer.unref(); }
|
||||
|
||||
function readCache() {
|
||||
const f = cacheFile(); if (!f) return;
|
||||
try { const d = JSON.parse(fs.readFileSync(f, 'utf8')); if (d && Array.isArray(d.entries)) { merged = d; loadedAt = 0; } } catch (e) {}
|
||||
}
|
||||
function writeCache() {
|
||||
const f = cacheFile(); if (!f) return;
|
||||
try { fs.writeFileSync(f + '.tmp', JSON.stringify(merged)); fs.renameSync(f + '.tmp', f); } catch (e) { console.error('netkb cache', e.message); }
|
||||
}
|
||||
async function refresh() {
|
||||
if (!enabled()) return { skipped: true };
|
||||
try {
|
||||
const r = await call('GET', '/v1/kb', undefined, merged.version ? { 'If-None-Match': '"' + merged.version + '"' } : {});
|
||||
stats.lastReadAt = Date.now();
|
||||
if (r.status === 304) { stats.notModified++; loadedAt = Date.now(); return { same: true }; }
|
||||
if (r.status !== 200 || !r.body || !Array.isArray(r.body.entries)) { stats.readErrors++; stats.lastError = 'read ' + r.status; return { error: stats.lastError }; }
|
||||
merged = { version: String(r.body.version || ''), sites: r.body.sites || {}, entries: r.body.entries }; loadedAt = Date.now(); stats.reads++;
|
||||
writeCache();
|
||||
return { version: merged.version, count: merged.entries.length };
|
||||
} catch (e) { stats.readErrors++; stats.lastError = 'read ' + e.message; return { error: e.message }; }
|
||||
}
|
||||
|
||||
// other sites' entries, ready for the chatbot's index: id "<site>:<id>", plus where they come from and the link to send people to
|
||||
function remote() {
|
||||
const me = siteName(); const out = [];
|
||||
for (const e of merged.entries || []) {
|
||||
if (!e || e.site === me) continue;
|
||||
const s = (merged.sites || {})[e.site] || {};
|
||||
const url = s.url || e.link || '';
|
||||
out.push({ id: e.site + ':' + e.id, title: e.title, questions: e.questions || [], answer: e.answer, tags: e.tags || [],
|
||||
site: e.site, siteName: s.name || e.site, siteUrl: url, go: (O && typeof O.linkFor === 'function' && url ? O.linkFor(url) : '') || url });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
// the network's sites as the hub knows them (name, link), this one left out
|
||||
function sites() {
|
||||
const me = siteName();
|
||||
return Object.entries(merged.sites || {}).filter(([k]) => k !== me).map(([k, s]) => ({ site: k, name: s.name || k, url: s.url || '', go: (O && typeof O.linkFor === 'function' && s.url ? O.linkFor(s.url) : '') || s.url || '', count: s.count || 0 }));
|
||||
}
|
||||
|
||||
// opts: { dataDir, site (hub site id), name, url, entries: async () => [...], linkFor: url => tracked link }
|
||||
function init(opts) {
|
||||
O = opts || {}; readCache();
|
||||
if (!enabled()) return;
|
||||
const first = setTimeout(async () => { await publish().catch(() => {}); await refresh().catch(() => {}); }, Math.max(0, Number(process.env.NETKB_FIRST_MS) || 8000));
|
||||
if (first.unref) first.unref();
|
||||
timer = setInterval(async () => { await refresh().catch(() => {}); if (!publishedHash) await publish().catch(() => {}); }, Math.max(1000, Number(process.env.NETKB_REFRESH_MS) || REFRESH_MS));
|
||||
if (timer.unref) timer.unref();
|
||||
}
|
||||
function view() { return Object.assign({ enabled: enabled(), site: siteName(), version: merged.version, sites: Object.keys(merged.sites || {}), entries: (merged.entries || []).length, remote: remote().length, loadedAt }, stats); }
|
||||
function _set(m) { merged = m; } // tests
|
||||
|
||||
const version = () => merged.version || '';
|
||||
module.exports = { init, publish, publishSoon, refresh, remote, sites, view, enabled, version, _set };
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
// The network sites list for the footer's "Part of the network" line (Marty 2026-11-14 trust pack).
|
||||
// One source: the hub's public GET /v1/network-sites (HUB_URL). Cached 10 minutes, refreshed in the background, never waits on a
|
||||
// slow hub (2.5 s timeout), and falls back to the same built-in list. Never RM Circle, never the games.
|
||||
// The same file lives in every network site (InstantAdPay, LinkSpin, Downline Banners, VBB, ViralAdBlitz, Stack POL).
|
||||
const FALLBACK = [
|
||||
{ id: 'iap', name: 'InstantAdPay', url: 'https://instantadpay.com' },
|
||||
{ id: 'linkspin', name: 'LinkSpin', url: 'https://linkspin.app' },
|
||||
{ id: 'dlb', name: 'Downline Banners', url: 'https://downlinebanners.com' },
|
||||
{ id: 'vbb', name: 'Viral Banner Blitz', url: 'https://viralbannerblitz.com' },
|
||||
{ id: 'viraladblitz', name: 'ViralAdBlitz', url: 'https://viraladblitz.com' },
|
||||
{ id: 'stackpol', name: 'Stack POL', url: 'https://stackpol.com' },
|
||||
{ id: 'earnerscorner', name: 'Earners Corner', url: 'https://earnerscorner.com' }
|
||||
];
|
||||
const TTL = 10 * 60 * 1000;
|
||||
let cache = { at: 0, list: FALLBACK, from: 'fallback' };
|
||||
let inflight = null;
|
||||
|
||||
const hubUrl = () => String(process.env.HUB_URL || 'https://hub.saasy.top').trim().replace(/\/+$/, '');
|
||||
function clean(list) {
|
||||
if (!Array.isArray(list)) return null;
|
||||
const ok = list.filter(s => s && typeof s.name === 'string' && /^https:\/\/[a-z0-9.-]+(\/[^\s"'<>]*)?$/i.test(String(s.url || '')))
|
||||
.slice(0, 30).map(s => ({ id: String(s.id || s.name).toLowerCase().replace(/[^a-z0-9]+/g, '').slice(0, 30), name: String(s.name).slice(0, 60), url: String(s.url).replace(/\/+$/, '') }));
|
||||
return ok.length ? ok : null;
|
||||
}
|
||||
function refresh() {
|
||||
if (inflight || process.env.NETWORK_SITES_HUB === '0') return inflight;
|
||||
const ac = new AbortController(); const t = setTimeout(() => ac.abort(), 2500);
|
||||
inflight = fetch(hubUrl() + '/v1/network-sites', { signal: ac.signal })
|
||||
.then(r => (r.ok ? r.json() : null))
|
||||
.then(j => { const l = clean(j); if (l) cache = { at: Date.now(), list: l, from: 'hub' }; else cache.at = Date.now(); })
|
||||
.catch(() => { cache.at = Date.now() - TTL + 60 * 1000; }) // hub down: try again in a minute, keep the last good list
|
||||
.finally(() => { clearTimeout(t); inflight = null; });
|
||||
return inflight;
|
||||
}
|
||||
function list() { if (Date.now() - cache.at > TTL) refresh(); return cache.list; }
|
||||
// Tracked links (Marty 2026-11-14: "make sure each of these sites is its own traffic source and link spun so we can track it"): each
|
||||
// entry also gets go = the LinkSpin network link for that site with ?src=<this site>, so a click shows in LinkSpin Reports under the
|
||||
// site that sent it (LinkSpin netlinks.js: fixed codes on the admin account). This site = NETWORK_SITE_ID, else the request host.
|
||||
// No go for this site itself, or when this site cannot be told (a test host): the page then uses the plain url.
|
||||
const CODES = { iap: 'nwiap', linkspin: 'nwls', dlb: 'nwdlb', vbb: 'nwvbb', viraladblitz: 'nwvab', fivex: 'nw5x', downlinehydra: 'nwdh', stackpol: 'nwsp', earnerscorner: 'nwec' };
|
||||
const linksBase = () => String(process.env.NETWORK_LINKS_BASE || 'https://linkspin.app').trim().replace(/\/+$/, '');
|
||||
const hostOf = u => { try { return new URL(u).hostname.toLowerCase().replace(/^www\./, ''); } catch (e) { return ''; } };
|
||||
function selfId(req, l) {
|
||||
const env = String(process.env.NETWORK_SITE_ID || '').trim().toLowerCase(); if (env) return env;
|
||||
const h = String((req && req.headers && (req.headers['x-forwarded-host'] || req.headers.host)) || '').split(',')[0].trim().toLowerCase().replace(/:\d+$/, '').replace(/^www\./, '');
|
||||
const m = h && (l || list()).find(s => hostOf(s.url) === h); return m ? m.id : '';
|
||||
}
|
||||
// the LinkSpin-tracked link to site `id` sent from site `from` (from = id: the site's own promo kit); extra = { s1: member username, s2: one path segment }
|
||||
function tracked(id, from, extra) {
|
||||
const code = CODES[id]; if (!code || !from) return '';
|
||||
const q = new URLSearchParams({ src: from }); for (const [k, v] of Object.entries(extra || {})) if (v) q.set(k, String(v));
|
||||
return linksBase() + '/r/' + code + '?' + q.toString();
|
||||
}
|
||||
function withGo(l, me) { return l.map(s => { const go = me && s.id !== me ? tracked(s.id, me) : ''; return go ? Object.assign({}, s, { go }) : s; }); }
|
||||
// GET /api/network-sites: public, cacheable, the same answer on every page
|
||||
function handle(req, res) {
|
||||
const l = list();
|
||||
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'public, max-age=300', 'X-Content-Type-Options': 'nosniff' });
|
||||
res.end(JSON.stringify(withGo(l, selfId(req, l))));
|
||||
}
|
||||
module.exports = { list, handle, refresh, tracked, selfId, withGo, CODES, FALLBACK, _state: () => cache };
|
||||
+355
@@ -0,0 +1,355 @@
|
||||
// Network sign-in between InstantAdPay and LinkSpin (Marty approved 2026-11-12). The SAME file ships in both repos; each
|
||||
// server calls init({ self, peer, peerBase, ... hooks }) and hands every request to handle() before its own routes.
|
||||
//
|
||||
// One flow, used two ways. R = the site the member is going TO (receiver), P = the site they are signed in on (provider).
|
||||
// 1. R GET /sso/start?mode=go|check&to=/path R makes a random state, keeps it in a 5-minute HttpOnly cookie (nsso.st),
|
||||
// sets the loop guard (nsso.tried, 2 minutes) and sends the browser to P.
|
||||
// 2. P GET /sso/check?st=<state>&to=/path P looks at its OWN member session (never the admin portal). Signed in:
|
||||
// P mints a token bound to R, the state and the email, and sends the browser
|
||||
// to R /sso/in?t=<token>. Not signed in: R /sso/in?none=1&to=/path.
|
||||
// 3. R GET /sso/in?t=<token> R checks signature, audience, expiry (60 s), the state against its cookie
|
||||
// (so nobody can push their own token into someone else's browser), and spends
|
||||
// the nonce (a second use is refused). The email must already be a member
|
||||
// here; then R makes an ordinary session and redirects to the relative path.
|
||||
// Outbound links: P GET /go/<peer>?to=/path is the hop a signed-in member's cross-site link points at. Signed out (or the
|
||||
// secret not set), it is a plain redirect to the other site, so it is always safe to link through.
|
||||
// Silent check: R's sign-in page calls GET /api/sso/status; { check: true } means "bounce once through P". The guard cookie
|
||||
// stops a second bounce for 2 minutes (30 until 2026-11-15, when it blocked Marty's silent sign-in on LinkSpin), signing out sets nsso.off (12 hours, cleared by the next deliberate cross-site link),
|
||||
// bots and non-page fetches never bounce.
|
||||
// Token: "v1.<base64url JSON>.<base64url HMAC-SHA256(NETWORK_SSO_SECRET, 'nsso.v1.' + JSON part)>", JSON = { iss, aud, email,
|
||||
// st, to, iat, exp, n[, wallet, name] }. The token grants a plain member session and nothing else: no wallet action, payout or purchase rides on it.
|
||||
//
|
||||
// Wallet sites (Downline Banners, 2026-11-13, Marty: "sign in once and be logged into all these sites"). Downline Banners has no email
|
||||
// accounts; its members are wallets. IAP and LinkSpin list it under `wallets: { bannerline: base }` and vouch one way: /go/bannerline
|
||||
// and /sso/check?r=bannerline mint a token that also carries the member's wallet (the one they signed in with, else the main wallet
|
||||
// their account linked by signature) and username. Downline Banners runs this file with `from: { iap, linkspin }`, accepts a token from
|
||||
// either, and makes a session for that wallet. /sso/start?via=<site> picks which site to ask; old copies ignore the new parameters.
|
||||
//
|
||||
// THE HUB AS THE PROVIDER (Marty approved 2026-11-15; off unless HUB_SSO=on, with HUB_URL, HUB_SECRET (32+) and HUB_SITE or C.hubSite).
|
||||
// The network hub keeps one network sign-in per browser in its own cookie (7 days, renewed on use). With it on:
|
||||
// /sso/start asks the hub (GET <hub>/sso/check?site=<HUB_SITE>&st&to&m) instead of one other site; the hub answers
|
||||
// /sso/in?h=<token> ("h1." token, HMAC-SHA256 with this site's HUB_SECRET under 'hubsso.v1.', iss 'hub', aud = this site,
|
||||
// 60 s, single use, bound to the state cookie) or /sso/in?none=1&hub=1, and then the old pairwise path is tried once as the
|
||||
// fallback (until every site is switched).
|
||||
// Push: a signed-in member's page load (a real top-level navigation only) with no matching nsso.hp cookie goes once through
|
||||
// <hub>/sso/set?site&t=<this site's token for the member> and straight back, so signing in on any site signs in the hub.
|
||||
// Only when the hub answered /health in the last 2 minutes: a hub that is down never takes a page with it.
|
||||
// Activity (Marty 2026-11-15, DownlineHydra "Wake it", the CRM score): a signed-in member's page load pings POST <hub>/v1/activity
|
||||
// {email|wallet, kind 'visit'} at most once per member per day, fire and forget (HUB_URL + HUB_SECRET; HUB_ACTIVITY=0 turns it off).
|
||||
// signOutEverywhere(session): POST <hub>/v1/sso/signout; the hub ends every hub sign-in of that person and tells hooked sites.
|
||||
'use strict';
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const SECRET = () => String(process.env.NETWORK_SSO_SECRET || '').trim();
|
||||
const enabled = () => SECRET().length >= 32;
|
||||
const TTL = 60 * 1000; // token life
|
||||
const SKEW = 30 * 1000; // clock skew allowed between the two servers
|
||||
const STATE_AGE = 300; // seconds: the state cookie
|
||||
const GO_STATE_AGE = 1200; // seconds: the state cookie on a deliberate tap (time to sign in on the provider first, 2026-11-14)
|
||||
const BACK_AGE = 1200; // seconds: the provider remembers an unfinished deliberate check while the member signs in
|
||||
const TRIED_AGE = 120; // seconds: one silent check per browser per 2 minutes (loop guard only; 30 minutes until 2026-11-15)
|
||||
const OFF_AGE = 12 * 3600; // seconds: no silent check after a sign-out on this site
|
||||
const HINT_AGE = 300; // seconds: the email prefill when the member is not here yet
|
||||
const NAMES = { iap: 'InstantAdPay', linkspin: 'LinkSpin', bannerline: 'Downline Banners', vbb: 'Viral Banner Blitz', viraladblitz: 'ViralAdBlitz', downlinehydra: 'DownlineHydra', fivex: '5xYourTeam' }; // vbb = Viral Banner Blitz, a wallet site like Downline Banners (2026-11-14); viraladblitz = ViralAdBlitz, a wallet site like VBB (2026-11-15); downlinehydra = DownlineHydra (2026-11-15); fivex = 5xYourTeam (2026-11-15)
|
||||
const WALLET_RE = /^0x[0-9a-f]{40}$/;
|
||||
const PUSH_AGE = 6 * 86400; // seconds: this browser's member is signed in on the hub (the hub's own sign-in lasts 7 days)
|
||||
const HUB_BASE = () => String(process.env.HUB_URL || '').trim().replace(/\/+$/, '');
|
||||
const HUB_KEY = () => String(process.env.HUB_SECRET || '').trim();
|
||||
const HUB_NAME = () => String(process.env.HUB_SITE || (C && (C.hubSite || C.self)) || '').trim().toLowerCase();
|
||||
const hubCreds = () => /^https?:\/\/[a-z0-9.:-]+$/i.test(HUB_BASE()) && HUB_KEY().length >= 32 && /^[a-z0-9_-]{1,64}$/.test(HUB_NAME());
|
||||
const hubOn = () => String(process.env.HUB_SSO || '').trim().toLowerCase() === 'on' && hubCreds();
|
||||
let hubSeen = 0, hubChecked = 0, hubAsking = null; // last good /health answer, last time we asked
|
||||
// true when the hub answered /health in the last 2 minutes. Asked at most once a minute; while the answer is unknown (first use, or
|
||||
// the last good answer is old) the caller waits for that one question (2 s at most), so a hub that is down costs one page 2 s a minute.
|
||||
async function hubUp() {
|
||||
const now = Date.now();
|
||||
if (now - hubChecked >= 60000 && !hubAsking && typeof fetch === 'function') {
|
||||
hubChecked = now;
|
||||
const ac = typeof AbortController === 'function' ? new AbortController() : null; const tm = setTimeout(() => { if (ac) ac.abort(); }, 2000);
|
||||
hubAsking = fetch(HUB_BASE() + '/health', { signal: ac ? ac.signal : undefined }).then(r => { if (r.ok) hubSeen = Date.now(); }).catch(() => {}).finally(() => { clearTimeout(tm); hubAsking = null; });
|
||||
}
|
||||
if (hubAsking && Date.now() - hubSeen >= 120000) await hubAsking;
|
||||
return Date.now() - hubSeen < 120000;
|
||||
}
|
||||
|
||||
let C = null; // { self, peer, peerBase(), isProd, dataDir, db, member(req), accept(email, req, v), signIn(email, req, v), landing(to), signinPath(to), defaultPath,
|
||||
// wallets?: { site: base() } + wallet(session) -> { address, name }, from?: { site: base() } }
|
||||
|
||||
const b64u = buf => Buffer.from(buf).toString('base64').replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_');
|
||||
const unb64u = s => Buffer.from(String(s).replace(/-/g, '+').replace(/_/g, '/'), 'base64');
|
||||
const mac = s => crypto.createHmac('sha256', SECRET()).update('nsso.v1.' + s).digest();
|
||||
const mask = e => String(e || '').replace(/^(.).*(@.*)$/, '$1***$2');
|
||||
const log = (what, email, extra) => console.log('network-sso', what, email ? mask(email) : '-', extra || '');
|
||||
|
||||
// a same-site relative path, or the default. No scheme, no host, no protocol-relative //x, no backslashes, no control characters.
|
||||
function safePath(to, dflt) {
|
||||
const d = dflt == null ? '/' : dflt;
|
||||
const s = String(to == null ? '' : to);
|
||||
if (!s || s.length > 600 || s[0] !== '/' || s[1] === '/' || s[1] === '\\' || /[\\\u0000-\u001f\u007f\s]/.test(s)) return d;
|
||||
try { const x = new URL(s, 'http://x.invalid'); if (x.host !== 'x.invalid' || x.protocol !== 'http:') return d; return x.pathname + x.search + x.hash; } catch (e) { return d; }
|
||||
}
|
||||
|
||||
function mint(o) {
|
||||
const now = o.now || Date.now();
|
||||
const t = { iss: o.iss, aud: o.aud, email: String(o.email || '').trim().toLowerCase(), st: o.st, to: safePath(o.to), iat: now, exp: now + TTL, n: crypto.randomBytes(16).toString('hex') };
|
||||
if (o.wallet) t.wallet = String(o.wallet).toLowerCase();
|
||||
if (o.name) t.name = String(o.name).slice(0, 40);
|
||||
const body = b64u(JSON.stringify(t));
|
||||
return 'v1.' + body + '.' + b64u(mac(body));
|
||||
}
|
||||
|
||||
// -> { ok, email, to, n, exp } or { error: reason }
|
||||
function verify(tok, o) {
|
||||
if (!enabled()) return { error: 'off' };
|
||||
const m = /^v1\.([A-Za-z0-9_-]{20,2000})\.([A-Za-z0-9_-]{43})$/.exec(String(tok || ''));
|
||||
if (!m) return { error: 'malformed' };
|
||||
const want = mac(m[1]), got = unb64u(m[2]);
|
||||
if (want.length !== got.length || !crypto.timingSafeEqual(want, got)) return { error: 'signature' };
|
||||
let p; try { p = JSON.parse(unb64u(m[1]).toString('utf8')); } catch (e) { return { error: 'malformed' }; }
|
||||
const now = (o && o.now) || Date.now();
|
||||
if (!p || p.aud !== o.aud || ![].concat(o.iss).includes(p.iss)) return { error: 'audience' };
|
||||
if (!(Number(p.exp) > now) || Number(p.iat) > now + SKEW || Number(p.exp) - Number(p.iat) > TTL) return { error: 'expired' };
|
||||
if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(String(p.email || ''))) return { error: 'email' };
|
||||
if (!/^[a-f0-9]{32}$/.test(String(p.n || ''))) return { error: 'malformed' };
|
||||
const st = String((o && o.st) || '');
|
||||
if (!/^[a-f0-9]{32}$/.test(st) || !/^[a-f0-9]{32}$/.test(String(p.st || '')) || !crypto.timingSafeEqual(Buffer.from(st), Buffer.from(p.st))) return { error: 'state' };
|
||||
if (p.wallet != null && !WALLET_RE.test(String(p.wallet))) return { error: 'wallet' };
|
||||
const name = p.name != null && /^[A-Za-z0-9_.-]{1,40}$/.test(String(p.name)) ? String(p.name) : null;
|
||||
return { ok: true, iss: p.iss, email: String(p.email).toLowerCase(), wallet: p.wallet || null, name, to: safePath(p.to), n: p.n, exp: Number(p.exp) };
|
||||
}
|
||||
|
||||
// hub tokens ("h1.", the hub's format): mint for the hub (push), verify from the hub (sign-in)
|
||||
const hmacHub = x => crypto.createHmac('sha256', HUB_KEY()).update('hubsso.v1.' + x).digest();
|
||||
function mintHub(o) {
|
||||
const now = o.now || Date.now();
|
||||
const t = { iss: HUB_NAME(), aud: 'hub', to: safePath(o.to), iat: now, exp: now + TTL, n: crypto.randomBytes(16).toString('hex') };
|
||||
if (o.email) t.email = String(o.email).trim().toLowerCase(); else if (o.wallet) t.wallet = String(o.wallet).toLowerCase();
|
||||
const body = b64u(JSON.stringify(t));
|
||||
return 'h1.' + body + '.' + b64u(hmacHub(body));
|
||||
}
|
||||
function verifyHub(tok, o) {
|
||||
if (!hubCreds()) return { error: 'off' };
|
||||
const m = /^h1\.([A-Za-z0-9_-]{20,2000})\.([A-Za-z0-9_-]{43})$/.exec(String(tok || ''));
|
||||
if (!m) return { error: 'malformed' };
|
||||
const want = hmacHub(m[1]), got = unb64u(m[2]);
|
||||
if (want.length !== got.length || !crypto.timingSafeEqual(want, got)) return { error: 'signature' };
|
||||
let p; try { p = JSON.parse(unb64u(m[1]).toString('utf8')); } catch (e) { return { error: 'malformed' }; }
|
||||
const now = (o && o.now) || Date.now();
|
||||
if (!p || p.iss !== 'hub' || p.aud !== HUB_NAME()) return { error: 'audience' };
|
||||
if (!(Number(p.exp) > now) || Number(p.iat) > now + SKEW || Number(p.exp) - Number(p.iat) > TTL) return { error: 'expired' };
|
||||
if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(String(p.email || ''))) return { error: 'email' };
|
||||
if (!/^[a-f0-9]{32}$/.test(String(p.n || ''))) return { error: 'malformed' };
|
||||
const st = String((o && o.st) || '');
|
||||
if (!/^[a-f0-9]{32}$/.test(st) || !/^[a-f0-9]{32}$/.test(String(p.st || '')) || !crypto.timingSafeEqual(Buffer.from(st), Buffer.from(p.st))) return { error: 'state' };
|
||||
if (p.wallet != null && !WALLET_RE.test(String(p.wallet))) return { error: 'wallet' };
|
||||
const name = p.name != null && /^[A-Za-z0-9_.-]{1,40}$/.test(String(p.name)) ? String(p.name) : null;
|
||||
return { ok: true, iss: 'hub', email: String(p.email).toLowerCase(), wallet: p.wallet || null, name, to: safePath(p.to), n: p.n, exp: Number(p.exp) };
|
||||
}
|
||||
// a signed /v1 call to the hub (the scheme every site already uses): hex HMAC-SHA256(HUB_SECRET, ts + newline + body)
|
||||
async function hubCall(route, body, ms) {
|
||||
const raw = JSON.stringify(body || {}); const ts = String(Date.now());
|
||||
const ac = typeof AbortController === 'function' ? new AbortController() : null; const tm = setTimeout(() => { if (ac) ac.abort(); }, ms || 5000);
|
||||
try {
|
||||
const r = await fetch(HUB_BASE() + route, { method: 'POST', body: raw, signal: ac ? ac.signal : undefined, headers: { 'Content-Type': 'application/json', 'X-Hub-Site': HUB_NAME(), 'X-Hub-Ts': ts, 'X-Hub-Sig': crypto.createHmac('sha256', HUB_KEY()).update(ts + '\n' + raw).digest('hex') } });
|
||||
let j = null; try { j = await r.json(); } catch (e) {}
|
||||
return { status: r.status, json: j };
|
||||
} finally { clearTimeout(tm); }
|
||||
}
|
||||
const who = s => (s && s.email ? { email: String(s.email).toLowerCase() } : s && s.address && WALLET_RE.test(String(s.address).toLowerCase()) ? { wallet: String(s.address).toLowerCase() } : null);
|
||||
const pushTag = w => b64u(crypto.createHmac('sha256', HUB_KEY()).update('push.' + (w.email || w.wallet)).digest()).slice(0, 22);
|
||||
// once per member per day (memory; a restart may ping once more, the hub counts a visit once per 10 minutes anyway)
|
||||
const pinged = new Map(); let pingDay = '';
|
||||
function activity(w) {
|
||||
if (String(process.env.HUB_ACTIVITY || '') === '0' || !hubCreds() || typeof fetch !== 'function') return;
|
||||
const day = new Date().toISOString().slice(0, 10); if (day !== pingDay) { pinged.clear(); pingDay = day; }
|
||||
const k = w.email || w.wallet; if (pinged.has(k)) return; pinged.set(k, 1);
|
||||
hubCall('/v1/activity', Object.assign({ kind: 'visit' }, w), 5000).then(r => { if (r.status >= 500) pinged.delete(k); }).catch(() => { pinged.delete(k); });
|
||||
}
|
||||
// a real top-level page load of a page (never an API call, an asset, a fetch, a bot or one of our own hops)
|
||||
function pageLoad(req, p) {
|
||||
if (req.method !== 'GET' || isBot(req)) return false;
|
||||
if (req.headers['sec-fetch-dest'] !== 'document' || (req.headers['sec-fetch-mode'] && req.headers['sec-fetch-mode'] !== 'navigate')) return false;
|
||||
if (/^\/(sso|api|go|assets|art|img|fonts|uploads|admin)(\/|$)/.test(p)) return false;
|
||||
return !/\.[a-z0-9]{1,5}$/i.test(p);
|
||||
}
|
||||
async function signOutEverywhere(s) {
|
||||
const w = who(s); if (!w || !hubCreds()) return { ok: false, reason: !w ? 'signed out' : 'hub off' };
|
||||
try { const r = await hubCall('/v1/sso/signout', w, 8000); return r.status === 200 ? Object.assign({ ok: true }, r.json || {}) : { ok: false, reason: 'hub ' + r.status }; }
|
||||
catch (e) { return { ok: false, reason: 'hub unreachable' }; }
|
||||
}
|
||||
|
||||
// single use: true the first time a nonce is spent. MySQL when the site runs on it (two app copies during a deploy share it),
|
||||
// else memory + a small file in DATA_DIR (survives a restart inside the 60-second window).
|
||||
const used = new Map(); let fileLoaded = false, tableReady = null;
|
||||
const FILE = () => C && C.dataDir ? path.join(C.dataDir, 'network-sso-nonces.json') : null;
|
||||
function prune(now) { for (const [k, exp] of used) if (exp < now) used.delete(k); }
|
||||
function loadFile() {
|
||||
if (fileLoaded) return; fileLoaded = true;
|
||||
try { const o = JSON.parse(fs.readFileSync(FILE(), 'utf8')); for (const k of Object.keys(o)) used.set(k, Number(o[k])); } catch (e) {}
|
||||
}
|
||||
function saveFile() { const f = FILE(); if (!f) return; try { fs.writeFileSync(f + '.tmp', JSON.stringify(Object.fromEntries(used))); fs.renameSync(f + '.tmp', f); } catch (e) { console.error('network-sso nonce save', e.message); } }
|
||||
async function spend(n, exp) {
|
||||
const now = Date.now(); loadFile(); prune(now);
|
||||
if (used.has(n)) return false;
|
||||
used.set(n, Number(exp) + SKEW); saveFile();
|
||||
const db = C && C.db;
|
||||
if (db && db.enabled && db.enabled()) {
|
||||
try {
|
||||
if (!tableReady) tableReady = db.q('CREATE TABLE IF NOT EXISTS network_sso_nonces (n VARCHAR(40) PRIMARY KEY, exp BIGINT NOT NULL) ENGINE=InnoDB').catch(e => { tableReady = null; throw e; });
|
||||
await tableReady;
|
||||
await db.q('INSERT INTO network_sso_nonces (n, exp) VALUES (?, ?)', [n, Number(exp) + SKEW]);
|
||||
if (Math.random() < 0.05) db.q('DELETE FROM network_sso_nonces WHERE exp < ?', [now]).catch(() => {});
|
||||
} catch (e) { if (/duplicate/i.test(e.message || '') || e.code === 'ER_DUP_ENTRY') return false; console.error('network-sso nonce db', e.message); return false; } // fail closed
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// crawlers, link previews and headless browsers never bounce
|
||||
const BOT_RE = /bot|crawl|spider|slurp|preview|facebookexternalhit|embedly|quora link|whatsapp|telegram|discord|skype|curl|wget|python|httpclient|headless|lighthouse|pingdom|monitor|go-http|java\/|okhttp|axios|node-fetch|undici/i;
|
||||
const isBot = req => { const ua = String(req.headers['user-agent'] || ''); return !ua || BOT_RE.test(ua); };
|
||||
// only a real top-level page load may start a bounce (sec-fetch-dest is sent by every current browser)
|
||||
const notPage = req => { const d = req.headers['sec-fetch-dest']; return !!d && d !== 'document'; };
|
||||
|
||||
function cookies(req) {
|
||||
const out = {};
|
||||
for (const p of String(req.headers.cookie || '').split(';')) { const i = p.indexOf('='); if (i > 0) { try { out[p.slice(0, i).trim()] = decodeURIComponent(p.slice(i + 1).trim()); } catch (e) {} } }
|
||||
return out;
|
||||
}
|
||||
const ck = (k, v, age, httpOnly) => k + '=' + encodeURIComponent(v) + '; Path=/; SameSite=Lax; Max-Age=' + age + (httpOnly ? '; HttpOnly' : '') + (C && C.isProd ? '; Secure' : '');
|
||||
const go = (res, loc, set) => { const h = { Location: loc, 'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer', 'X-Robots-Tag': 'noindex' }; if (set && set.length) h['Set-Cookie'] = set; res.writeHead(302, h); res.end(); return true; };
|
||||
const sendJson = (res, obj, set) => { const h = { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' }; if (set && set.length) h['Set-Cookie'] = set; res.writeHead(200, h); res.end(JSON.stringify(obj)); return true; };
|
||||
|
||||
function init(opts) { C = Object.assign({ defaultPath: '/' }, opts); fileLoaded = false; used.clear(); if (hubOn()) { hubSeen = 0; hubChecked = 0; hubUp().catch(() => {}); } }
|
||||
|
||||
// the cookie a sign-out adds: no silent check on this site for 12 hours (a deliberate cross-site link still signs in)
|
||||
const offCookie = () => ck('nsso.off', '1', OFF_AGE, true);
|
||||
|
||||
// -> true when the request was one of ours and has been answered
|
||||
async function handle(req, res, u) {
|
||||
if (!C || req.method !== 'GET') return false;
|
||||
const p = u.pathname;
|
||||
const peerName = NAMES[C.peer] || C.peer;
|
||||
const goTo = p.startsWith('/go/') ? p.slice(4) : '';
|
||||
const walletBase = x => (C.wallets && Object.prototype.hasOwnProperty.call(C.wallets, x) ? C.wallets[x] : null);
|
||||
if (goTo && (goTo === C.peer || walletBase(goTo))) {
|
||||
const base = goTo === C.peer ? C.peerBase() : walletBase(goTo)();
|
||||
const to = safePath(u.searchParams.get('to'), '/');
|
||||
const plain = base + to;
|
||||
if (!enabled() || isBot(req)) return go(res, plain);
|
||||
let s = null; try { s = await C.member(req); } catch (e) {}
|
||||
if (!s || !s.email) return go(res, plain);
|
||||
if (goTo !== C.peer) { let w = null; try { w = await C.wallet(s); } catch (e) {} if (!w || !w.address) return go(res, plain); } // no wallet to vouch for: a plain link
|
||||
return go(res, base + '/sso/start?mode=go' + (goTo === C.peer ? '' : '&via=' + C.self) + '&to=' + encodeURIComponent(to));
|
||||
}
|
||||
if (p === '/sso/start') {
|
||||
const to = safePath(u.searchParams.get('to'), C.defaultPath);
|
||||
const mode = u.searchParams.get('mode') === 'go' ? 'go' : 'check';
|
||||
const via = String(u.searchParams.get('via') || '');
|
||||
const from = C.from && Object.prototype.hasOwnProperty.call(C.from, via) ? C.from[via] : null; // a wallet site may ask either provider
|
||||
const viaHub = hubOn() && !u.searchParams.get('nohub') && (await hubUp());
|
||||
if (!(enabled() || viaHub) || isBot(req) || notPage(req)) return go(res, to);
|
||||
let s = null; try { s = await C.member(req); } catch (e) {}
|
||||
if (s && (s.email || s.address)) return go(res, to); // already signed in here
|
||||
const c = cookies(req);
|
||||
if (mode === 'check' && (c['nsso.tried'] || c['nsso.off']) && !u.searchParams.get('nohub')) return go(res, to);
|
||||
const st = crypto.randomBytes(16).toString('hex');
|
||||
if (viaHub) { // the hub answers for the whole network; the pairwise provider is the fallback when it has nobody (nsso.via)
|
||||
const set = [ck('nsso.st', st, mode === 'go' ? GO_STATE_AGE : STATE_AGE, true), ck('nsso.tried', '1', TRIED_AGE, true), ck('nsso.via', via || '-', STATE_AGE, true)];
|
||||
if (mode === 'go' && c['nsso.off']) set.push(ck('nsso.off', '', 0, true));
|
||||
return go(res, HUB_BASE() + '/sso/check?site=' + encodeURIComponent(HUB_NAME()) + '&st=' + st + '&to=' + encodeURIComponent(to) + (mode === 'go' ? '&m=go' : ''), set);
|
||||
}
|
||||
const set = [ck('nsso.st', st, mode === 'go' ? GO_STATE_AGE : STATE_AGE, true), ck('nsso.tried', '1', TRIED_AGE, true)];
|
||||
if (mode === 'go' && c['nsso.off']) set.push(ck('nsso.off', '', 0, true));
|
||||
return go(res, (from ? from() : C.peerBase()) + '/sso/check?st=' + st + (C.from ? '&r=' + C.self : '') + '&to=' + encodeURIComponent(to) + (mode === 'go' ? '&m=go' : ''), set);
|
||||
}
|
||||
if (p === '/sso/resume') { // signed in on the provider after a deliberate tap: finish the check it was asked for (2026-11-14)
|
||||
const q = new URLSearchParams(cookies(req)['nsso.back'] || '');
|
||||
const clear = [ck('nsso.back', '', 0, true)];
|
||||
if (!/^[a-f0-9]{32}$/.test(q.get('st') || '')) return go(res, C.defaultPath, clear);
|
||||
return go(res, '/sso/check?st=' + q.get('st') + (q.get('r') ? '&r=' + encodeURIComponent(q.get('r')) : '') + '&to=' + encodeURIComponent(safePath(q.get('to'), '/')), clear);
|
||||
}
|
||||
if (p === '/sso/check') {
|
||||
const st = String(u.searchParams.get('st') || '');
|
||||
const to = safePath(u.searchParams.get('to'), '/');
|
||||
const r = String(u.searchParams.get('r') || '');
|
||||
const wb = r && r !== C.peer ? walletBase(r) : null; // a wallet site asking: the token carries the wallet
|
||||
if (r && r !== C.peer && !wb) { log('check: unknown site asking, nothing sent', null, r.slice(0, 20)); return go(res, C.defaultPath); } // never answer an unknown site as if the peer asked (2026-11-15: 5xYourTeam was sent to LinkSpin)
|
||||
const base = wb ? wb() : C.peerBase(), aud = wb ? r : C.peer, forName = NAMES[aud] || aud;
|
||||
const none = base + '/sso/in?none=1&to=' + encodeURIComponent(to);
|
||||
if (!enabled() || !/^[a-f0-9]{32}$/.test(st)) return go(res, none);
|
||||
let s = null; try { s = await C.member(req); } catch (e) {}
|
||||
if (!s || !s.email) {
|
||||
if (u.searchParams.get('m') === 'go' && !isBot(req)) { // a deliberate tap: sign in here first, then /sso/resume finishes the trip
|
||||
log('check: not signed in here, asking to sign in', null, 'for ' + forName);
|
||||
const back = new URLSearchParams({ st, to }); if (r) back.set('r', r);
|
||||
return go(res, C.signinPath(C.defaultPath), [ck('nsso.back', back.toString(), BACK_AGE, true)]);
|
||||
}
|
||||
log('check: not signed in here', null, 'for ' + forName); return go(res, none);
|
||||
}
|
||||
let w = null;
|
||||
if (wb) { try { w = await C.wallet(s); } catch (e) {} if (!w || !WALLET_RE.test(String(w.address || '').toLowerCase())) { log('check: no wallet on the account', s.email, 'for ' + forName); return go(res, none); } }
|
||||
log('token issued', s.email, 'for ' + forName);
|
||||
return go(res, base + '/sso/in?t=' + mint({ iss: C.self, aud, email: s.email, wallet: w && w.address, name: w && w.name, st, to }));
|
||||
}
|
||||
if (p === '/sso/in') {
|
||||
const c = cookies(req);
|
||||
const set = [ck('nsso.st', '', 0, true)];
|
||||
if (u.searchParams.get('none')) {
|
||||
const nto = safePath(u.searchParams.get('to'), C.defaultPath);
|
||||
if (u.searchParams.get('hub') && enabled()) { // nobody on the hub: ask the old pairwise provider once (until every site is switched)
|
||||
const via = String(c['nsso.via'] || ''); set.push(ck('nsso.via', '', 0, true));
|
||||
log('none on the hub, trying ' + (NAMES[via] || peerName));
|
||||
return go(res, '/sso/start?nohub=1&mode=' + (u.searchParams.get('m') === 'go' ? 'go' : 'check') + (via && via !== '-' ? '&via=' + encodeURIComponent(via) : '') + '&to=' + encodeURIComponent(nto), set);
|
||||
}
|
||||
log('none: not signed in on ' + (u.searchParams.get('hub') ? 'the hub' : peerName)); return go(res, C.signinPath(nto), set);
|
||||
}
|
||||
const fromHub = !!u.searchParams.get('h');
|
||||
const v = fromHub ? verifyHub(u.searchParams.get('h'), { st: c['nsso.st'] }) : verify(u.searchParams.get('t'), { iss: [C.peer].concat(Object.keys(C.from || {})), aud: C.self, st: c['nsso.st'] });
|
||||
if (v.error) { log('refused: ' + v.error); return go(res, C.signinPath(C.defaultPath), set); }
|
||||
if (!(await spend(v.n, v.exp))) { log('refused: token already used', v.email); return go(res, C.signinPath(v.to), set); }
|
||||
let a = null; try { a = await C.accept(v.email, req, v); } catch (e) { a = { fallback: 'error ' + e.message }; }
|
||||
if (!a || !a.ok) { // not a member here yet (or not allowed to sign in): the normal email-code sign-in, email filled in
|
||||
log('fallback to email code: ' + ((a && a.fallback) || 'not accepted'), v.email);
|
||||
set.push(ck('nsso.hint', v.email, HINT_AGE, true));
|
||||
return go(res, C.signinPath(v.to), set);
|
||||
}
|
||||
let cookie = null; try { cookie = await C.signIn(v.email, req, v); } catch (e) { console.error('network-sso sign-in', e.message); }
|
||||
if (!cookie) { log('fallback to email code: session not made', v.email); return go(res, C.signinPath(v.to), set); }
|
||||
set.push(cookie); if (c['nsso.off']) set.push(ck('nsso.off', '', 0, true));
|
||||
if (fromHub) { const w2 = v.wallet && C.from ? { wallet: v.wallet } : { email: v.email }; set.push(ck('nsso.hp', pushTag(w2), PUSH_AGE, true)); } // the hub already has this sign-in
|
||||
log('signed in from ' + (fromHub ? 'the network hub' : (NAMES[v.iss] || peerName)), v.email);
|
||||
return go(res, C.landing(v.to === '/' ? C.defaultPath : v.to), set); // no page named: the dashboard, not the public home page (2026-11-13)
|
||||
}
|
||||
if (p === '/api/sso/status') {
|
||||
const c = cookies(req); const set = [];
|
||||
let s = null; try { s = await C.member(req); } catch (e) {}
|
||||
const signedIn = !!(s && (s.email || s.address));
|
||||
const out = { peer: hubOn() ? 'the network' : peerName, check: (enabled() || (hubOn() && (await hubUp()))) && !signedIn && !isBot(req) && !c['nsso.tried'] && !c['nsso.off'] };
|
||||
if (c['nsso.hint']) { if (!signedIn) out.hint = c['nsso.hint']; set.push(ck('nsso.hint', '', 0, true)); }
|
||||
return sendJson(res, out, set);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// every GET a site serves passes here first (2026-11-15): a signed-in member's real page load pings the hub's activity once a day and,
|
||||
// with the hub on, tells the hub about this sign-in once (nsso.hp). -> true when it answered (the redirect through the hub).
|
||||
async function page(req, res, u) {
|
||||
if (!C || !hubCreds()) return false;
|
||||
const p = u.pathname;
|
||||
if (!pageLoad(req, p)) return false;
|
||||
let s = null; try { s = await C.member(req); } catch (e) {}
|
||||
const w = who(s); if (!w) return false;
|
||||
activity(w);
|
||||
if (hubOn() && cookies(req)['nsso.hp'] !== pushTag(w) && (await hubUp())) {
|
||||
log('hub: telling the hub about this sign-in', w.email || null);
|
||||
return go(res, HUB_BASE() + '/sso/set?site=' + encodeURIComponent(HUB_NAME()) + '&t=' + mintHub(Object.assign({ to: p + u.search }, w)), [ck('nsso.hp', pushTag(w), PUSH_AGE, true)]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// true when this browser came here from a deliberate network tap and still has to finish it after signing in
|
||||
const pendingBack = req => !!cookies(req)['nsso.back'];
|
||||
|
||||
module.exports = { init, handle, page, enabled, pendingBack, mint, verify, spend, safePath, isBot, offCookie, mask, TTL, NAMES, hubOn, hubCreds, signOutEverywhere, mintHub, verifyHub, _hubSeen: t => { hubSeen = t == null ? Date.now() : t; hubChecked = Date.now(); }, _pinged: pinged };
|
||||
Generated
+163
@@ -0,0 +1,163 @@
|
||||
{
|
||||
"name": "webworthit",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "webworthit",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"mysql2": "^3.11.0",
|
||||
"playwright-core": "1.48.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "26.6.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.6.tgz",
|
||||
"integrity": "sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"undici-types": "~8.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/aws-ssl-profiles": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/aws-ssl-profiles/-/aws-ssl-profiles-1.1.2.tgz",
|
||||
"integrity": "sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/generate-function": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz",
|
||||
"integrity": "sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-property": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.7.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz",
|
||||
"integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/is-property": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz",
|
||||
"integrity": "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/long": {
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",
|
||||
"integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/lru.min": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/lru.min/-/lru.min-1.1.5.tgz",
|
||||
"integrity": "sha512-5J9ysMYUpYIg9RF2vJpy9SinEmSviFSe0GyPpCQ4L5QSkLAgeLXlTAOu2ZwWUU5m+0SBl6gUU1R1ZQB3aKypfA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"bun": ">=1.0.0",
|
||||
"deno": ">=1.30.0",
|
||||
"node": ">=8.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wellwelwel"
|
||||
}
|
||||
},
|
||||
"node_modules/mysql2": {
|
||||
"version": "3.24.6",
|
||||
"resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.24.6.tgz",
|
||||
"integrity": "sha512-enu73KhbAua2L3dIxjc6qg6ZJ7H3pt1BImZASWNWY5xSsmJ1ZuUPULTDGXgmJbI61vb+nJAG19IZclIq19UidQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"aws-ssl-profiles": "^1.1.2",
|
||||
"generate-function": "^2.3.1",
|
||||
"iconv-lite": "^0.7.3",
|
||||
"long": "^5.3.2",
|
||||
"lru.min": "^1.1.4",
|
||||
"named-placeholders": "^1.1.6",
|
||||
"sql-escaper": "^1.5.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/named-placeholders": {
|
||||
"version": "1.1.6",
|
||||
"resolved": "https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.6.tgz",
|
||||
"integrity": "sha512-Tz09sEL2EEuv5fFowm419c1+a/jSMiBjI9gHxVLrVdbUkkNUUfjsVYs9pVZu5oCon/kmRh9TfLEObFtkVxmY0w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"lru.min": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright-core": {
|
||||
"version": "1.48.2",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.48.2.tgz",
|
||||
"integrity": "sha512-sjjw+qrLFlriJo64du+EK0kJgZzoQPsabGF4lBvsid+3CNIZIYLgnMj9V6JY5VhM2Peh20DJWIVpVljLLnlawA==",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"playwright-core": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/sql-escaper": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/sql-escaper/-/sql-escaper-1.7.0.tgz",
|
||||
"integrity": "sha512-ZgP6E9SPnhrhWXxd8+nLKPot3Euzyo3Rpxe6EFAYz2Ffaq9Xg2SH+6d4yJi7vsQDHaQlhzQ1phAopgE6+a1UCQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"bun": ">=1.0.0",
|
||||
"deno": ">=2.0.0",
|
||||
"node": ">=12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/mysqljs/sql-escaper?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "8.9.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz",
|
||||
"integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==",
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "webworthit",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "WebWorthIt: a read-only contract and website risk check. Public information only; scores are opinion from a published rubric.",
|
||||
"main": "server.js",
|
||||
"scripts": { "start": "node server.js" },
|
||||
"engines": { "node": ">=22" },
|
||||
"dependencies": {
|
||||
"mysql2": "^3.11.0",
|
||||
"playwright-core": "1.48.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Not found | WebWorthIt</title>
|
||||
<meta name="description" content="Page not found.">
|
||||
<meta name="theme-color" content="#0E2A22">
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Archivo:wght@500;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap">
|
||||
<link rel="stylesheet" href="/assets/wwi.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap" style="padding-top:64px;padding-bottom:64px"><h1 style="font-size:40px">Page not found</h1><p><a href="/">Back to WebWorthIt</a></p></main>
|
||||
<script src="/assets/common.js?v=1"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,22 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Admin | WebWorthIt</title>
|
||||
<meta name="description" content="WebWorthIt admin.">
|
||||
<meta name="theme-color" content="#0E2A22">
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Archivo:wght@500;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap">
|
||||
<link rel="stylesheet" href="/assets/wwi.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap" style="padding-top:32px;padding-bottom:40px;display:flex;flex-direction:column;gap:20px">
|
||||
<h1 style="font-size:36px">WebWorthIt admin</h1>
|
||||
<div id="tok" class="card"><span>Admin token</span><div style="display:flex;gap:10px;flex-wrap:wrap"><input id="token" class="code" type="password" style="flex:1 1 300px"><button id="save" class="btn dark" type="button">Open</button></div></div>
|
||||
<div id="out"></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=1"></script>
|
||||
<script src="/assets/admin.js?v=1"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 34 34"><rect width="34" height="34" rx="7" fill="#F3F5F1"/><circle cx="14" cy="14" r="10" fill="none" stroke="#0E2A22" stroke-width="2.5"/><path d="M8 16 L12 12 L15 15 L20 9" fill="none" stroke="#E2541B" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M21.5 21.5 L30 30" stroke="#0E2A22" stroke-width="3" stroke-linecap="round"/></svg>
|
||||
|
After Width: | Height: | Size: 440 B |
@@ -0,0 +1,41 @@
|
||||
// Admin: checks (cost, timings, publish to "Network, checked"), test purchases with the sponsor line that would be paid,
|
||||
// voucher codes (create, disable, redemptions), and an admin-run check for our own contracts. The token stays in this browser.
|
||||
(function () {
|
||||
'use strict';
|
||||
var $ = WWI.$, esc = WWI.esc, tok = '';
|
||||
try { tok = sessionStorage.getItem('wwi.admin') || ''; } catch (e) {}
|
||||
function api(path, body) {
|
||||
return fetch(path, { method: body ? 'POST' : 'GET', headers: { 'Content-Type': 'application/json', 'x-admin-token': tok }, body: body ? JSON.stringify(body) : undefined }).then(function (r) { return r.json(); });
|
||||
}
|
||||
var ct = function (t) { return t ? new Date(Number(t)).toLocaleString('en-US', { timeZone: 'America/Chicago', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) + ' CT' : ''; };
|
||||
function load() {
|
||||
api('/api/admin/overview').then(function (j) {
|
||||
if (j.error) { $('out').innerHTML = '<div class="notice">' + esc(j.error) + '</div>'; return; }
|
||||
$('tok').classList.add('hide');
|
||||
var h = '<div class="card"><span class="t">Totals</span><span class="b">' + j.cost.n + ' checks, OpenRouter cost $' + Number(j.cost.usd || 0).toFixed(4) + '. Hub sign-in ' + (j.sso ? 'on' : 'off') + '. Ad zones: ' + (Object.keys(j.zones || {}).length ? esc(JSON.stringify(j.zones)) : 'none set (WWI_ZONES)') + '.</span></div>';
|
||||
h += '<div class="card"><span class="t">Run a check (admin, no limit)</span><div style="display:flex;gap:8px;flex-wrap:wrap"><input id="aAddr" class="code" placeholder="0x... contract" style="flex:2 1 300px"><input id="aSite" class="code" placeholder="https://website (optional)" style="flex:1 1 200px"><select id="aChain" class="code"><option value="polygon">Polygon</option><option value="bsc">BNB Chain</option><option value="eth">Ethereum</option><option value="base">Base</option></select><select id="aKind" class="code"><option value="deep">deep</option><option value="free">free</option></select><input id="aLabel" class="code" placeholder="public label (optional)"><label><input id="aPub" type="checkbox"> public</label><button id="aRun" class="btn dark" type="button">Run</button></div><span id="aMsg" class="b"></span></div>';
|
||||
h += '<div class="card"><span class="t">Checks</span><span class="b">Tick Public to show a check on "Network, checked"; the label comes from this box: <input id="pubLabel" class="code" placeholder="public label, e.g. Viral Banner Blitz"></span><div class="tblwrap"><table class="t"><thead><tr><th>When</th><th>Kind</th><th>What</th><th>Status</th><th>Model</th><th>Cost</th><th>Time</th><th>Public</th></tr></thead><tbody>' + j.checks.map(function (c) {
|
||||
var tm = c.timings_json ? JSON.parse(c.timings_json) : null;
|
||||
return '<tr><td>' + ct(c.created) + '</td><td>' + esc(c.kind) + '</td><td><a href="/c/' + esc(c.id) + '" target="_blank">' + esc(c.website || '') + ' ' + esc(WWI.short(c.address) || '') + ' ' + esc(c.chain || '') + '</a>' + (c.error ? '<br><span style="color:var(--acc2)">' + esc(c.error.slice(0, 160)) + '</span>' : '') + '</td><td>' + esc(c.status) + (c.status !== 'done' ? ' (' + esc(c.step || '') + ')' : '') + '</td><td>' + esc(c.model || '') + '</td><td>$' + Number(c.cost_usd || 0).toFixed(4) + '</td><td>' + (tm ? Math.round(tm.total_s) + ' s' : '') + '</td>'
|
||||
+ '<td><label><input type="checkbox" data-pub="' + esc(c.id) + '"' + (c.is_public ? ' checked' : '') + '> ' + esc(c.public_label || '') + '</label></td></tr>';
|
||||
}).join('') + '</tbody></table></div></div>';
|
||||
h += '<div class="card"><span class="t">Test purchases and the sponsor line (nothing paid in staging)</span><div class="tblwrap"><table class="t"><thead><tr><th>When</th><th>Buyer</th><th>Item</th><th>Via</th><th>Ref</th><th>Line source</th><th>Would pay</th><th>Company</th></tr></thead><tbody>' + j.purchases.map(function (p) {
|
||||
var s = p.split || {}; var l = p.line || {};
|
||||
return '<tr><td>' + ct(p.at) + '</td><td>' + esc(p.buyer_username ? '@' + p.buyer_username : p.buyer || 'visitor') + '</td><td>' + esc(p.item) + ' $' + Number(p.usd).toFixed(2) + '</td><td>' + esc(p.via) + '</td><td>' + esc(p.ref || '') + '</td><td>' + esc(l.source || '') + (l.ok === false ? ' (hub partial)' : '') + '<br><span style="font-size:12px">' + (l.line || []).map(function (x) { return (x.username ? '@' + esc(x.username) : esc(WWI.short(x.wallet) || '?')) + (x.qualified ? ' (bought)' : ' (passed over)'); }).join(' > ') + '</span></td><td>'
|
||||
+ (s.levels || []).map(function (x) { return 'L' + x.level + ' ' + x.pct + '% $' + Number(x.usd).toFixed(2) + ' ' + (x.username ? '@' + esc(x.username) : 'company'); }).join('<br>') + (s.note ? '<br><i>' + esc(s.note) + '</i>' : '') + '</td><td>$' + Number(s.company || 0).toFixed(2) + '</td></tr>';
|
||||
}).join('') + '</tbody></table></div></div>';
|
||||
h += '<div class="card"><span class="t">Vouchers</span><div style="display:flex;gap:8px;flex-wrap:wrap"><input id="pCode" class="code" placeholder="CODE (blank = random)"><select id="pKind" class="code"><option value="deep">deep reports</option><option value="free">extra free checks</option></select><input id="pAmt" class="code" type="number" min="1" value="1" style="width:90px" title="amount per redemption"><input id="pMax" class="code" type="number" min="1" value="1" style="width:110px" title="max uses"><input id="pExp" class="code" type="date" title="expires"><label><input id="pOnce" type="checkbox" checked> once per person</label><input id="pNote" class="code" placeholder="note: who it was given to" style="flex:1 1 220px"><button id="pMake" class="btn dark" type="button">Create</button></div><span id="pMsg" class="b"></span>'
|
||||
+ '<div class="tblwrap"><table class="t"><thead><tr><th>Code</th><th>Gives</th><th>Uses</th><th>Expires</th><th>Note</th><th></th></tr></thead><tbody>' + j.promos.map(function (p) {
|
||||
return '<tr><td class="mono">' + esc(p.code) + '</td><td>' + p.amount + ' ' + (p.kind === 'deep' ? 'deep' : 'free') + '</td><td>' + p.uses + ' / ' + p.max_uses + (p.per_holder_once ? ' (once each)' : '') + '</td><td>' + (p.expires ? ct(p.expires) : '') + '</td><td>' + esc(p.note || '') + '</td><td><button class="btn line" type="button" data-dis="' + esc(p.code) + '" data-en="' + (p.disabled ? 1 : 0) + '">' + (p.disabled ? 'Enable' : 'Disable') + '</button></td></tr>';
|
||||
}).join('') + '</tbody></table></div>'
|
||||
+ '<span class="t" style="font-size:16px">Redemptions</span><div class="tblwrap"><table class="t"><thead><tr><th>When</th><th>Code</th><th>Holder</th><th>Gave</th></tr></thead><tbody>' + j.redemptions.map(function (r) { return '<tr><td>' + ct(r.at) + '</td><td class="mono">' + esc(r.code) + '</td><td>' + esc(String(r.holder).replace(/^t:(.{6}).*/, 'browser $1...')) + '</td><td>' + r.amount + ' ' + esc(r.kind) + '</td></tr>'; }).join('') + '</tbody></table></div></div>';
|
||||
$('out').innerHTML = h;
|
||||
$('aRun').addEventListener('click', function () { api('/api/admin/check', { address: $('aAddr').value.trim(), website: $('aSite').value.trim(), chain: $('aChain').value, kind: $('aKind').value, label: $('aLabel').value.trim(), public: $('aPub').checked }).then(function (r) { $('aMsg').innerHTML = r.id ? 'Started: <a href="/c/' + r.id + '" target="_blank">' + r.id + '</a>' : esc(r.error); }); });
|
||||
$('pMake').addEventListener('click', function () { api('/api/admin/promo', { code: $('pCode').value.trim(), kind: $('pKind').value, amount: $('pAmt').value, maxUses: $('pMax').value, expires: $('pExp').value || null, perHolderOnce: $('pOnce').checked, note: $('pNote').value }).then(function (r) { $('pMsg').textContent = r.ok ? 'Created ' + r.code : r.error; if (r.ok) setTimeout(load, 600); }); });
|
||||
document.querySelectorAll('[data-dis]').forEach(function (b) { b.addEventListener('click', function () { api('/api/admin/promo/disable', { code: b.getAttribute('data-dis'), enable: b.getAttribute('data-en') === '1' }).then(load); }); });
|
||||
document.querySelectorAll('[data-pub]').forEach(function (b) { b.addEventListener('change', function () { var label = b.checked ? $('pubLabel').value.trim() : ''; api('/api/admin/publish', { id: b.getAttribute('data-pub'), public: b.checked, label: label }).then(load); }); });
|
||||
});
|
||||
}
|
||||
$('save').addEventListener('click', function () { tok = $('token').value.trim(); try { sessionStorage.setItem('wwi.admin', tok); } catch (e) {} load(); });
|
||||
if (tok) load();
|
||||
})();
|
||||
@@ -0,0 +1,46 @@
|
||||
/* Site assistant widget (network pattern), WebWorthIt look (wwi.css): ink header, rounded white panel, coral send, aqua chips.
|
||||
The overrides at the end of this file set the look; the shared widget rules above stay as on every network site. */
|
||||
#scChat{--sc-bg:var(--card,#fff);--sc-ink:var(--ink,#0A1F6B);--sc-sub:var(--sub,#3E4C7A);--sc-head:var(--royal,#0A1F6B);--sc-head-ink:#fff;
|
||||
--sc-accent:var(--red,#E3141E);--sc-accent-ink:#fff;--sc-me:var(--royal2,#12308F);--sc-me-ink:#fff;--sc-bot:var(--tint,#E1EBFF);--sc-line:var(--line,#C9D6F5);
|
||||
--sc-chip:var(--gtint,#FFF3CC);--sc-chip-ink:var(--gold-ink,#7A5B00);--sc-gold:var(--gold,#FFC21A);
|
||||
--sc-font:var(--body,Inter,system-ui,sans-serif);--sc-headfont:var(--head,'Chakra Petch',system-ui,sans-serif);--sc-cut:polygon(0 0,calc(100% - 14px) 0,100% 14px,100% 100%,14px 100%,0 calc(100% - 14px));
|
||||
position:fixed;right:18px;bottom:18px;z-index:80;font-family:var(--sc-font)}
|
||||
#scBtn{width:58px;height:58px;border:0;cursor:pointer;background:var(--sc-accent);color:var(--sc-accent-ink);display:flex;align-items:center;justify-content:center;
|
||||
clip-path:polygon(0 0,calc(100% - 12px) 0,100% 12px,100% 100%,12px 100%,0 calc(100% - 12px));box-shadow:0 6px 18px rgba(6,26,102,.35)}
|
||||
#scBtn:hover{background:#C70F18}
|
||||
#scBtn:focus-visible{outline:3px solid var(--sc-gold);outline-offset:3px}
|
||||
#scChat.open #scBtn{background:var(--sc-head)}
|
||||
/* the panel sets display:flex, which would beat the hidden attribute: closing must win */
|
||||
#scPanel[hidden]{display:none}
|
||||
#scPanel{position:absolute;right:0;bottom:72px;width:370px;max-width:calc(100vw - 32px);height:540px;max-height:calc(100vh - 110px);display:flex;flex-direction:column;
|
||||
background:var(--sc-bg);color:var(--sc-ink);clip-path:var(--sc-cut);border:1px solid var(--sc-line);box-shadow:0 18px 48px rgba(6,26,102,.3)}
|
||||
.sc-head{display:flex;align-items:flex-start;gap:10px;padding:14px 16px;background:var(--sc-head);color:var(--sc-head-ink);border-bottom:3px solid var(--sc-gold)}
|
||||
.sc-head>div{flex:1;min-width:0}
|
||||
.sc-title{display:block;font-family:var(--sc-headfont);font-size:18px;letter-spacing:.02em}
|
||||
.sc-sub{display:block;font-size:12.5px;opacity:.8}
|
||||
#scClose{background:transparent;border:0;color:inherit;font-size:26px;line-height:1;cursor:pointer;padding:0 2px}
|
||||
.sc-msgs{flex:1;overflow-y:auto;padding:14px;display:flex;flex-direction:column;gap:9px}
|
||||
.sc-m{max-width:88%;padding:9px 12px;font-size:14.5px;line-height:1.45;word-wrap:break-word;overflow-wrap:anywhere}
|
||||
.sc-m.bot{align-self:flex-start;background:var(--sc-bot);color:var(--sc-ink);clip-path:polygon(0 0,100% 0,100% 100%,8px 100%,0 calc(100% - 8px))}
|
||||
.sc-m.me{align-self:flex-end;background:var(--sc-me);color:var(--sc-me-ink);clip-path:polygon(0 0,calc(100% - 8px) 0,100% 8px,100% 100%,0 100%)}
|
||||
.sc-m a{color:inherit;text-decoration:underline}
|
||||
.sc-m.wait{opacity:.6}
|
||||
.sc-cta{display:inline-block;background:var(--sc-accent);color:var(--sc-accent-ink)!important;text-decoration:none!important;font-weight:700;padding:8px 14px;
|
||||
clip-path:polygon(0 0,calc(100% - 8px) 0,100% 8px,100% 100%,8px 100%,0 calc(100% - 8px))}
|
||||
.sc-handoff{background:transparent!important;padding:0!important}
|
||||
.sc-topics{display:flex;flex-wrap:wrap;gap:6px;padding:0 14px 8px}
|
||||
.sc-topics button{background:var(--sc-chip);color:var(--sc-chip-ink);border:1px solid var(--sc-gold);font:600 12.5px var(--sc-font);padding:5px 10px;cursor:pointer}
|
||||
.sc-input{display:flex;gap:8px;padding:10px 12px;border-top:1px solid var(--sc-line)}
|
||||
.sc-input input{flex:1;min-width:0;border:1px solid var(--sc-line);padding:10px 12px;font:15px var(--sc-font);color:var(--sc-ink);background:#fff}
|
||||
.sc-input input:focus{outline:2px solid var(--blue,#1F66FF);outline-offset:-1px}
|
||||
.sc-input button{background:var(--sc-accent);color:var(--sc-accent-ink);border:0;font:700 14px var(--sc-font);padding:0 16px;cursor:pointer;
|
||||
clip-path:polygon(0 0,calc(100% - 8px) 0,100% 8px,100% 100%,8px 100%,0 calc(100% - 8px))}
|
||||
.sc-human{display:block;text-align:center;font-size:12.5px;color:var(--sc-sub);padding:0 0 10px}
|
||||
@media (max-width:600px){#scChat{right:12px;bottom:12px}#scBtn{width:52px;height:52px}#scPanel{bottom:64px;height:calc(100vh - 100px)}}
|
||||
/* WebWorthIt look */
|
||||
#scChat{--sc-ink:#0E2A22;--sc-sub:#3E5149;--sc-head:#0E2A22;--sc-accent:#E2541B;--sc-me:#163A2F;--sc-bot:#E6ECE7;--sc-line:#C9D3CC;--sc-chip:#F3F5F1;--sc-chip-ink:#0E2A22;--sc-gold:#F0A27F;
|
||||
--sc-font:'IBM Plex Sans',system-ui,sans-serif;--sc-headfont:Archivo,system-ui,sans-serif;--sc-cut:none}
|
||||
#scChat #scBtn{clip-path:none;border-radius:50%;box-shadow:0 6px 18px rgba(14,42,34,.35)}
|
||||
#scChat #scBtn:hover{background:#B23E10}
|
||||
#scChat #scPanel{clip-path:none;border-radius:18px;overflow:hidden}
|
||||
#scChat .sc-m.bot,#scChat .sc-m.me{clip-path:none;border-radius:14px}#scChat [class*="sc-"]{clip-path:none}#scChat .sc-chip,#scChat button{border-radius:10px}
|
||||
@@ -0,0 +1,72 @@
|
||||
// Site assistant widget (2026-11-15): a round button bottom right, a panel that asks /api/chat. The look is this site's own,
|
||||
// in /assets/chat.css (colors and fonts from the site's stylesheet). When an answer cannot help, or the visitor asks for a
|
||||
// person, it offers "Open network support": InstantAdPay's support desk, which already knows the question and the site.
|
||||
// The SAME file ships in ViralAdBlitz, DownlineHydra, 5xYourTeam, Viral Banner Blitz, Downline Banners and Stack POL.
|
||||
(function () {
|
||||
if (window.__siteChat || /^\/admin/.test(location.pathname)) return;
|
||||
window.__siteChat = 1;
|
||||
var css = document.createElement('link'); css.rel = 'stylesheet'; css.href = '/assets/chat.css?v=20261115d'; document.head.appendChild(css);
|
||||
var NAME = 'this site', TOPICS = [];
|
||||
var root = document.createElement('div'); root.id = 'scChat';
|
||||
root.innerHTML = '<button id="scBtn" type="button" aria-label="Ask a question" aria-expanded="false">'
|
||||
+ '<svg viewBox="0 0 24 24" width="26" height="26" aria-hidden="true"><path fill="currentColor" d="M4 4h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H9l-5 4v-4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2zm3 6.5a1.5 1.5 0 1 0 0 .01zm5 0a1.5 1.5 0 1 0 0 .01zm5 0a1.5 1.5 0 1 0 0 .01z"/></svg></button>'
|
||||
+ '<div id="scPanel" role="dialog" aria-label="Questions" hidden>'
|
||||
+ '<div class="sc-head"><div><b class="sc-title" id="scTitle">Ask a question</b><span class="sc-sub">Straight answers about this site and the network</span></div>'
|
||||
+ '<button id="scClose" type="button" aria-label="Close">×</button></div>'
|
||||
+ '<div class="sc-msgs" id="scMsgs" aria-live="polite"></div>'
|
||||
+ '<div class="sc-topics" id="scTopics"></div>'
|
||||
+ '<form class="sc-input" id="scForm"><input id="scIn" autocomplete="off" maxlength="600" placeholder="Type your question" aria-label="Your question">'
|
||||
+ '<button type="submit" id="scSend">Send</button></form>'
|
||||
+ '<a class="sc-human" id="scHuman" href="https://instantadpay.com/support" target="_blank" rel="noopener">Need a person? Open network support</a>'
|
||||
+ '</div>';
|
||||
document.body.appendChild(root);
|
||||
var $ = function (id) { return document.getElementById(id); };
|
||||
var msgs = $('scMsgs'), input = $('scIn'), panel = $('scPanel'), btn = $('scBtn');
|
||||
var history = [], greeted = false, support = 'https://instantadpay.com/support';
|
||||
fetch('/api/chat/config').then(function (r) { return r.json(); }).then(function (c) {
|
||||
if (c.name) { NAME = c.name; $('scTitle').textContent = 'Ask ' + c.name; }
|
||||
if (c.support) { support = c.support; $('scHuman').href = c.support; }
|
||||
TOPICS = c.topics || [];
|
||||
}).catch(function () {});
|
||||
|
||||
function esc(s) { return String(s).replace(/[&<>"]/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"' }[c]; }); }
|
||||
function add(text, who) {
|
||||
var d = document.createElement('div'); d.className = 'sc-m ' + who;
|
||||
d.innerHTML = esc(text).replace(/(https?:\/\/[^\s<]+[^\s<.,;:!?)])/g, '<a href="$1" target="_blank" rel="noopener">$1</a>');
|
||||
msgs.appendChild(d); msgs.scrollTop = msgs.scrollHeight; return d;
|
||||
}
|
||||
function offer(link) {
|
||||
var old = msgs.querySelector('.sc-handoff'); if (old) old.remove();
|
||||
var d = document.createElement('div'); d.className = 'sc-m bot sc-handoff';
|
||||
var a = document.createElement('a'); a.className = 'sc-cta'; a.href = link || support; a.target = '_blank'; a.rel = 'noopener'; a.textContent = 'Open network support';
|
||||
d.appendChild(a); msgs.appendChild(d); msgs.scrollTop = msgs.scrollHeight;
|
||||
}
|
||||
function open() {
|
||||
panel.hidden = false; btn.setAttribute('aria-expanded', 'true'); root.className = 'open';
|
||||
if (!greeted) {
|
||||
greeted = true;
|
||||
add('Hi. Ask me how ' + NAME + ' works, what it costs, how payouts work, or about any other site in the network. Straight answers, no income hype.', 'bot');
|
||||
var t = $('scTopics'); TOPICS.slice(0, 4).forEach(function (q) {
|
||||
var b = document.createElement('button'); b.type = 'button'; b.textContent = q; b.addEventListener('click', function () { input.value = q; send(); }); t.appendChild(b);
|
||||
});
|
||||
}
|
||||
setTimeout(function () { input.focus(); }, 50);
|
||||
}
|
||||
function close() { panel.hidden = true; btn.setAttribute('aria-expanded', 'false'); root.className = ''; }
|
||||
btn.addEventListener('click', function () { panel.hidden ? open() : close(); });
|
||||
$('scClose').addEventListener('click', close);
|
||||
document.addEventListener('keydown', function (e) { if (e.key === 'Escape' && !panel.hidden) close(); });
|
||||
async function send() {
|
||||
var q = input.value.trim(); if (!q) return;
|
||||
input.value = ''; $('scTopics').innerHTML = '';
|
||||
add(q, 'me'); var wait = add('...', 'bot wait');
|
||||
try {
|
||||
var r = await (await fetch('/api/chat', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: q, history: history.slice(-6) }) })).json();
|
||||
wait.remove();
|
||||
add(r.reply || r.error || 'Something went wrong. Try again in a moment.', 'bot');
|
||||
history.push(q, r.reply || '');
|
||||
if (r.handoff) offer(r.support);
|
||||
} catch (e) { wait.remove(); add('I could not reach the assistant just now. Try again in a moment, or open network support.', 'bot'); offer(); }
|
||||
}
|
||||
$('scForm').addEventListener('submit', function (e) { e.preventDefault(); send(); });
|
||||
})();
|
||||
@@ -0,0 +1,62 @@
|
||||
// Shared page parts: header, staging line, footer (network row from /api/network-sites, legal links, the public-info + opinion line),
|
||||
// ad slots (each third-party tag runs inside its own iframe, /f/n.html; never inside a scorecard, findings or a report body).
|
||||
var WWI = (function () {
|
||||
'use strict';
|
||||
var $ = function (id) { return document.getElementById(id); };
|
||||
var esc = function (s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; }); };
|
||||
var cfg = null;
|
||||
function getConfig() { if (!cfg) cfg = fetch('/api/config').then(function (r) { return r.json(); }).catch(function () { return {}; }); return cfg; }
|
||||
function post(url, body) { return fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) }).then(function (r) { return r.json().then(function (j) { j._status = r.status; return j; }); }); }
|
||||
var MARK = '<svg width="34" height="34" viewBox="0 0 34 34" aria-hidden="true"><circle cx="14" cy="14" r="10" fill="none" stroke="#0E2A22" stroke-width="2.5"></circle><path d="M8 16 L12 12 L15 15 L20 9" fill="none" stroke="#E2541B" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M21.5 21.5 L30 30" stroke="#0E2A22" stroke-width="3" stroke-linecap="round"></path></svg>';
|
||||
function header() {
|
||||
var h = document.createElement('div'); h.className = 'hdr';
|
||||
h.innerHTML = '<div class="wrap"><a class="brand" href="/">' + MARK + '<span>WebWorthIt</span></a>'
|
||||
+ '<nav class="nav" aria-label="Main"><a href="/#check">Run a check</a><a href="/#scoring">How scoring works</a><a href="/#network">Our own contracts</a><a href="/#reports">Deep reports</a><a href="/#ec">Earners Corner</a></nav>'
|
||||
+ '<a id="signin" class="btn dark" href="/sso/start?mode=go&to=%2Fmy">Sign in with the network</a></div>';
|
||||
document.body.insertBefore(h, document.body.firstChild);
|
||||
getConfig().then(function (c) {
|
||||
if (c.staging) { var s = document.createElement('div'); s.className = 'staging'; s.textContent = 'STAGING: test site. Payments arrive at launch. Nothing here moves money.'; document.body.insertBefore(s, document.body.firstChild); }
|
||||
if (c.member) { var a = $('signin'); a.href = '/my'; a.textContent = c.member.username ? '@' + c.member.username : 'My checks'; }
|
||||
});
|
||||
}
|
||||
var NET = [['iap', 'InstantAdPay', 'https://instantadpay.com'], ['linkspin', 'LinkSpin', 'https://linkspin.app'], ['dlb', 'Downline Banners', 'https://downlinebanners.com'],
|
||||
['vbb', 'Viral Banner Blitz', 'https://viralbannerblitz.com'], ['viraladblitz', 'ViralAdBlitz', 'https://viraladblitz.com'], ['downlinehydra', 'DownlineHydra', 'https://downlinehydra.com'],
|
||||
['fivex', '5xYourTeam', 'https://5xyourteam.com'], ['stackpol', 'Stack POL', 'https://stackpol.com'], ['earnerscorner', 'Earners Corner', 'https://earnerscorner.com']].map(function (a) { return { id: a[0], name: a[1], url: a[2] }; });
|
||||
var HERE = { id: 'webworthit', name: 'WebWorthIt', url: 'https://webworthit.com' };
|
||||
function netLine(el) {
|
||||
var paint = function (list) {
|
||||
el.innerHTML = '<b>Part of the network</b> · One account across the network: ' + list.map(function (s) {
|
||||
return s.id === 'webworthit' ? '<span class="here" aria-current="page">' + esc(s.name) + '</span>' : '<a href="' + esc(s.go || s.url) + '" target="_blank" rel="noopener nofollow">' + esc(s.name) + '</a>';
|
||||
}).join(' · ');
|
||||
};
|
||||
paint(NET.concat([HERE]));
|
||||
fetch('/api/network-sites').then(function (r) { return r.json(); }).then(function (l) { if (Array.isArray(l) && l.length) paint(l.some(function (s) { return s.id === 'webworthit'; }) ? l : l.concat([HERE])); }).catch(function () {});
|
||||
}
|
||||
function footer() {
|
||||
slot(null, 'foot', 728, 90, true);
|
||||
var f = document.createElement('footer'); f.className = 'foot';
|
||||
f.innerHTML = '<div class="wrap"><div class="top"><span>WebWorthIt is part of the Crypto Team Build Network. Every check uses only public information anyone can review on their own. Scores are our opinion, not financial advice. We score code and chain records, not people.</span><span class="mono">webworthit.com</span></div>'
|
||||
+ '<p style="margin:0"><a href="/terms">Terms and Conditions</a> · <a href="/privacy">Privacy Policy</a> · <a href="/disclaimer">Disclaimer</a> · <a href="/rubric">The rubric</a> · <a href="https://instantadpay.com/support?from=webworthit" target="_blank" rel="noopener">Support</a></p>'
|
||||
+ '<p style="margin:0">© 2026 TrustClickz</p><p class="netline" style="margin:0"></p></div>';
|
||||
document.body.appendChild(f);
|
||||
netLine(f.querySelector('.netline'));
|
||||
var s = document.createElement('script'); s.src = '/assets/chat.js?v=1'; s.defer = true; document.body.appendChild(s);
|
||||
var l = document.createElement('link'); l.rel = 'stylesheet'; l.href = '/assets/chat.css?v=1'; document.head.appendChild(l);
|
||||
}
|
||||
// an ad slot: <div class="slot"> with the small "Advertisement" label and an iframe to our own frame page, which loads the LinkSpin zone.
|
||||
// after = element to insert after (null = before the footer). Placement key -> zone id comes from WWI_ZONES (server); no zone, no slot.
|
||||
function slot(after, key, w, h, beforeFooter) {
|
||||
getConfig().then(function (c) {
|
||||
var z = c.zones && c.zones[key]; if (!z) return;
|
||||
var narrow = window.innerWidth < 760 && w > 320; var ww = narrow ? 320 : w, hh = narrow ? 50 : h;
|
||||
var zn = narrow && c.zones[key + 'm'] ? c.zones[key + 'm'] : z;
|
||||
var d = document.createElement('div'); d.className = 'slot wrap'; d.setAttribute('data-zone', key);
|
||||
d.innerHTML = '<div class="lab">Advertisement</div><iframe title="Advertisement" loading="lazy" width="' + ww + '" height="' + hh + '" sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox allow-same-origin" src="/f/n.html?z=' + encodeURIComponent(zn) + '"></iframe>';
|
||||
if (after && after.parentNode) after.parentNode.insertBefore(d, after.nextSibling);
|
||||
else if (beforeFooter) { var f = document.querySelector('footer.foot'); if (f) f.parentNode.insertBefore(d, f); else document.body.appendChild(d); }
|
||||
});
|
||||
}
|
||||
var short = function (a) { return a && a.length === 42 ? a.slice(0, 6) + '...' + a.slice(-4) : a; };
|
||||
return { $: $, esc: esc, getConfig: getConfig, post: post, header: header, footer: footer, slot: slot, short: short };
|
||||
})();
|
||||
document.addEventListener('DOMContentLoaded', function () { WWI.header(); WWI.footer(); });
|
||||
@@ -0,0 +1,97 @@
|
||||
// Front page: the free check form, live progress + result, pricing (staging: payments arrive at launch), vouchers, the staging
|
||||
// test code, the member share box, and the "Network, checked" table filled from public checks.
|
||||
(function () {
|
||||
'use strict';
|
||||
var $ = WWI.$, esc = WWI.esc;
|
||||
var live = $('live'), current = null, timer = null;
|
||||
function setErr(t) { $('formErr').textContent = t || ''; }
|
||||
function showFree(c) { $('freeLeft').textContent = c.unlocked ? ' Test code active: no daily limit.' : (c.freeLeft != null ? ' Free checks left today: ' + c.freeLeft + ' of ' + c.freePerDay + '.' : ''); }
|
||||
function credits(c) { var cr = c.credits || {}; $('creditLine').textContent = (cr.deep || cr.free_extra) ? 'On this ' + (c.member ? 'account' : 'browser') + ': ' + (cr.deep || 0) + ' deep report' + (cr.deep === 1 ? '' : 's') + ', ' + (cr.free_extra || 0) + ' extra free check' + (cr.free_extra === 1 ? '' : 's') + '.' : ''; }
|
||||
function refresh() {
|
||||
return fetch('/api/config').then(function (r) { return r.json(); }).then(function (c) {
|
||||
showFree(c); credits(c);
|
||||
if (c.staging) { $('testBox').classList.remove('hide'); $('testIn').classList.toggle('hide', !!c.unlocked); $('testOn').classList.toggle('hide', !c.unlocked); }
|
||||
if (c.member && c.member.refLink) { $('shareBox').classList.remove('hide'); $('refLink').value = c.member.refLink; }
|
||||
if (!c.staging) document.querySelectorAll('[data-buy]').forEach(function (b) { b.textContent = b.getAttribute('data-buy') === 'deep10' ? 'Buy 10 reports' : 'Buy one report'; });
|
||||
return c;
|
||||
});
|
||||
}
|
||||
function poll(id) {
|
||||
clearTimeout(timer);
|
||||
fetch('/api/check/' + id).then(function (r) { return r.json(); }).then(function (v) {
|
||||
if (v.error && !v.id) { live.innerHTML = '<div class="notice">' + esc(v.error) + '</div>'; return; }
|
||||
current = v; live.classList.remove('hide'); Render.draw(live, v); wireDeep();
|
||||
if (v.status === 'done' && !$('liveSlotDone')) { var m = document.createElement('i'); m.id = 'liveSlotDone'; m.hidden = true; live.appendChild(m); WWI.slot($('liveSlot'), 'result', 728, 90); }
|
||||
if (v.status === 'queued' || v.status === 'running') timer = setTimeout(function () { poll(id); }, 2500);
|
||||
else refresh();
|
||||
}).catch(function () { timer = setTimeout(function () { poll(id); }, 5000); });
|
||||
}
|
||||
function start(body) {
|
||||
setErr(''); $('runBtn').disabled = true;
|
||||
return WWI.post('/api/check', body).then(function (j) {
|
||||
$('runBtn').disabled = false;
|
||||
if (!j.id) { setErr(j.error || 'The check could not start.'); return null; }
|
||||
try { history.replaceState(null, '', '/?c=' + j.id + '#result'); } catch (e) {}
|
||||
live.classList.remove('hide'); live.innerHTML = '<div class="steps">Starting...</div>'; live.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
poll(j.id); return j;
|
||||
}).catch(function () { $('runBtn').disabled = false; setErr('The check could not start. Try again.'); });
|
||||
}
|
||||
$('checkForm').addEventListener('submit', function (e) {
|
||||
e.preventDefault();
|
||||
var w = $('site').value.trim(), a = $('target').value.trim();
|
||||
if (!w && !a) return setErr('Fill in a website, a contract address, or both.');
|
||||
if (a && !/^0x[0-9a-fA-F]{40}$/.test(a)) return setErr('A contract address is 0x followed by 40 letters and numbers.');
|
||||
start({ website: w, address: a, chain: $('chain').value, kind: 'free' });
|
||||
});
|
||||
function wireDeep() {
|
||||
live.querySelectorAll('[data-deep]').forEach(function (b) {
|
||||
if (b._w) return; b._w = 1;
|
||||
b.addEventListener('click', function () {
|
||||
var msg = live.querySelector('[data-deepmsg]');
|
||||
b.disabled = true;
|
||||
WWI.post('/api/check', { website: current.website || '', address: current.address || '', chain: current.chain, kind: 'deep', from: current.id, watch: $('watch').checked }).then(function (j) {
|
||||
b.disabled = false;
|
||||
if (!j.id) { msg.textContent = j.error || 'The deep report could not start.'; if (j._status === 402) $('reports').scrollIntoView({ behavior: 'smooth' }); return; }
|
||||
try { history.replaceState(null, '', '/?c=' + j.id + '#result'); } catch (e) {}
|
||||
poll(j.id); live.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
$('redeemBtn').addEventListener('click', function () {
|
||||
var code = $('voucher').value.trim(); if (!code) return;
|
||||
WWI.post('/api/redeem', { code: code }).then(function (j) {
|
||||
$('voucherMsg').textContent = j.ok ? 'Added ' + j.amount + (j.kind === 'deep' ? ' deep report' : ' extra free check') + (j.amount === 1 ? '' : 's') + '.' : (j.error || 'That code did not work.');
|
||||
refresh();
|
||||
});
|
||||
});
|
||||
$('testBtn').addEventListener('click', function () {
|
||||
WWI.post('/api/unlock', { code: $('testCode').value.trim() }).then(function (j) { $('testMsg').textContent = j.ok ? 'Unlocked for 30 days on this browser.' : (j.error || 'That code is not right.'); refresh(); });
|
||||
});
|
||||
$('lockBtn').addEventListener('click', function () { WWI.post('/api/lock', {}).then(function () { $('testMsg').textContent = 'Locked.'; refresh(); }); });
|
||||
document.querySelectorAll('[data-test]').forEach(function (b) {
|
||||
b.addEventListener('click', function () {
|
||||
WWI.post('/api/test-purchase', { item: b.getAttribute('data-test') }).then(function (j) {
|
||||
if (!j.ok) { $('testMsg').textContent = j.error || 'Not recorded.'; return; }
|
||||
var s = j.split || {}; var paid = (s.levels || []).filter(function (l) { return l.username; });
|
||||
$('testMsg').textContent = 'Recorded (no money moved). Would pay: ' + (paid.length ? paid.map(function (l) { return 'L' + l.level + ' @' + l.username + ' $' + l.usd.toFixed(2); }).join(', ') + ', ' : 'no qualified sponsor, ') + 'company $' + Number(s.company).toFixed(2) + '.';
|
||||
refresh();
|
||||
});
|
||||
});
|
||||
});
|
||||
$('copyRef').addEventListener('click', function () { try { navigator.clipboard.writeText($('refLink').value); $('copyRef').textContent = 'Copied'; } catch (e) { $('refLink').select(); } });
|
||||
var sample = document.querySelector('img[data-sample]'); if (sample) sample.addEventListener('error', function () { sample.remove(); });
|
||||
// network table: the public deep reports of our own contracts
|
||||
fetch('/api/network-checks').then(function (r) { return r.json(); }).then(function (j) {
|
||||
(j.checks || []).forEach(function (c) {
|
||||
var row = document.querySelector('[data-net="' + c.address + '"]'); if (!row || row._done) return;
|
||||
if (c.kind !== 'deep' && (j.checks || []).some(function (x) { return x.address === c.address && x.kind === 'deep'; })) return;
|
||||
row._done = 1;
|
||||
row.querySelector('[data-score]').innerHTML = '<a style="color:#F0A27F;font-weight:600" href="/c/' + esc(c.id) + '">' + esc(c.grade || 'Report') + (c.overall != null ? ' (' + c.overall + '/100)' : '') + ', full report</a>';
|
||||
});
|
||||
}).catch(function () {});
|
||||
WWI.slot($('heroSlot'), 'hero', 728, 90);
|
||||
WWI.slot($('howSlot'), 'how', 728, 90);
|
||||
refresh();
|
||||
var q = new URLSearchParams(location.search).get('c'); if (q && /^[A-Za-z0-9]{12}$/.test(q)) poll(q);
|
||||
})();
|
||||
@@ -0,0 +1,20 @@
|
||||
// /my: signed-in member: checks, credits, the share box. Signed out: the network sign-in button.
|
||||
(function () {
|
||||
'use strict';
|
||||
var out = WWI.$('out'), esc = WWI.esc;
|
||||
fetch('/api/me').then(function (r) { return r.json(); }).then(function (j) {
|
||||
if (!j.member) {
|
||||
out.innerHTML = '<div class="card"><span class="t">Sign in with the network</span><span class="b">Use your InstantAdPay or LinkSpin account: one account across the network. Signing in never asks you to connect a wallet.</span>'
|
||||
+ (j.sso ? '<a class="btn dark" style="align-self:flex-start" href="/sso/start?mode=go&to=%2Fmy">Sign in with the network</a>' : '<span class="notice">Network sign-in is not switched on for this staging site yet.</span>') + '</div>';
|
||||
return;
|
||||
}
|
||||
var m = j.member;
|
||||
out.innerHTML = '<div class="card"><span class="t">' + (m.username ? '@' + esc(m.username) : 'Signed in') + '</span><span class="b">' + (m.wallet ? 'Wallet ' + esc(m.wallet) + '. ' : '') + (m.sponsor ? 'Sponsor @' + esc(m.sponsor) + '. ' : '') + 'Deep report credits: ' + ((j.credits || {}).deep || 0) + '.</span><button id="out1" class="btn line" style="align-self:flex-start" type="button">Sign out</button></div>'
|
||||
+ (m.refLink ? '<div class="card" style="border:2px solid var(--good)"><span class="t">Share WebWorthIt</span><span class="b">Your referral link. When someone you referred buys a report, you earn 20% as their direct sponsor, plus 5% on levels 2 to 5 of your team. You earn only when people choose to buy.</span><div style="display:flex;gap:10px;flex-wrap:wrap"><input id="ref" class="code" readonly style="flex:1 1 320px" value="' + esc(m.refLink) + '"><button id="cp" class="btn dark" type="button">Copy link</button></div></div>' : '')
|
||||
+ '<div class="card"><span class="t">Your checks</span>' + ((j.checks || []).length ? '<div class="tblwrap"><table class="t"><thead><tr><th>When</th><th>Kind</th><th>What</th><th>Status</th></tr></thead><tbody>' + j.checks.map(function (c) { return '<tr><td>' + new Date(c.created).toLocaleString('en-US', { timeZone: 'America/Chicago' }) + ' CT</td><td>' + esc(c.kind) + '</td><td><a href="/c/' + esc(c.id) + '">' + esc(c.website || WWI.short(c.address) || c.id) + '</a></td><td>' + esc(c.status) + '</td></tr>'; }).join('') + '</tbody></table></div>' : '<span class="b">No checks yet. <a href="/#check">Run one</a>.</span>') + '</div>'
|
||||
+ '<div class="card"><span class="t">Redeem a voucher</span><div style="display:flex;gap:10px;flex-wrap:wrap"><input id="v" class="code" placeholder="VOUCHER CODE" style="flex:1 1 180px"><button id="vb" class="btn dark" type="button">Redeem</button></div><span id="vm" class="b"></span></div>';
|
||||
WWI.$('out1').addEventListener('click', function () { WWI.post('/api/signout').then(function () { location.href = '/'; }); });
|
||||
var cp = WWI.$('cp'); if (cp) cp.addEventListener('click', function () { try { navigator.clipboard.writeText(WWI.$('ref').value); cp.textContent = 'Copied'; } catch (e) {} });
|
||||
WWI.$('vb').addEventListener('click', function () { WWI.post('/api/redeem', { code: WWI.$('v').value.trim() }).then(function (r) { WWI.$('vm').textContent = r.ok ? 'Added ' + r.amount + (r.kind === 'deep' ? ' deep report(s).' : ' extra free check(s).') : (r.error || 'That code did not work.'); }); });
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,85 @@
|
||||
// Draws a check: progress steps while it runs, then the scorecard (free) or the full report (deep).
|
||||
// Facts (tagged, linked) and opinion (scores, grade, verdict) are kept apart, with the opinion line under every scorecard and grade.
|
||||
// No ad is ever drawn inside this output.
|
||||
var Render = (function () {
|
||||
'use strict';
|
||||
var esc = WWI.esc;
|
||||
var CATS = [['control', 'Control and upgradeability', 25], ['custody', 'Custody and exit paths', 25], ['economics', 'Economic design', 20], ['insiders', 'Insider flows', 15], ['disclosure', 'Disclosure vs code', 10], ['trajectory', 'Trajectory', 5]];
|
||||
var OPINION = 'Scores and grade are our opinion, based on our published rubric applied to the public facts below.';
|
||||
function link(text, ex) {
|
||||
var s = esc(text);
|
||||
if (!ex) return s;
|
||||
return s.replace(/0x[0-9a-fA-F]{64}(?![0-9a-fA-F])/g, function (h) { return '<a class="src" href="' + ex + '/tx/' + h + '" target="_blank" rel="noopener nofollow">' + h.slice(0, 10) + '...' + h.slice(-6) + '</a>'; })
|
||||
.replace(/0x[0-9a-fA-F]{40}(?![0-9a-fA-F])/g, function (a) { return '<a class="src" href="' + ex + '/address/' + a + '" target="_blank" rel="noopener nofollow">' + a.slice(0, 6) + '...' + a.slice(-4) + '</a>'; });
|
||||
}
|
||||
function steps(v) {
|
||||
return '<div class="steps" aria-live="polite"><b class="disp">' + (v.status === 'queued' ? 'Waiting for a free worker' + (v.queuePos >= 0 ? ' (' + (v.queuePos + 1) + ' ahead)' : '') : v.status === 'running' ? 'Checking now' : v.status === 'failed' ? 'The check stopped' : 'Steps') + '</b>'
|
||||
+ v.steps.map(function (s) { return '<div class="step ' + esc(s.state) + '"><span class="dot"></span><div><div>' + esc(s.name) + (s.state === 'skipped' ? ' (skipped)' : '') + '</div>' + (s.note ? '<div class="nt">' + esc(s.note) + '</div>' : '') + '</div></div>'; }).join('')
|
||||
+ (v.error ? '<div class="notice">' + esc(v.error) + '</div>' : '') + '</div>';
|
||||
}
|
||||
function gradeCls(g) { return !g ? '' : /Low/.test(g) ? 'low' : /Moderate/.test(g) ? 'mod' : ''; }
|
||||
function scorecard(v, ex) {
|
||||
var r = v.report, g = v.grade || {};
|
||||
var rows = CATS.map(function (c) {
|
||||
var s = (r.scores || {})[c[0]] || {}; var n = Math.max(0, Math.min(10, Number(s.score) || 0));
|
||||
return '<span>' + esc(c[1]) + ' <span style="color:var(--mut)">(' + c[2] + ')</span></span><div class="bar"><i class="' + (n >= 7 ? '' : n >= 4 ? 'mid' : 'lo') + '" style="width:' + n * 10 + '%"></i></div><span class="mono" style="font-weight:500">' + n + '</span>'
|
||||
+ (s.why ? '<div class="why">' + link(s.why, ex) + (s.tag ? ' <span class="tag ' + esc(s.tag) + '">' + esc(s.tag) + '</span>' : '') + '</div>' : '');
|
||||
}).join('');
|
||||
var flags = (g.flags || []).map(function (f) { return '<div class="find"><span class="tag ' + esc(f.tag) + '">' + esc(f.tag) + '</span><span>' + link(f.text, ex) + ' <span style="color:var(--mut);font-size:13px">(' + esc(f.source) + ')</span></span></div>'; }).join('');
|
||||
var finds = (r.top_findings || []).map(function (f) { return '<div class="find"><span class="tag ' + esc(f.tag) + '">' + esc(f.tag) + '</span><span>' + link(f.text, ex) + '</span></div>'; }).join('');
|
||||
return '<div style="display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap"><span class="disp" style="font-weight:700;font-size:20px">Scorecard</span><span style="font-size:13px;color:var(--mut)">0 = safest, 10 = worst · weight in brackets</span></div>'
|
||||
+ '<div class="scores">' + rows + '</div>'
|
||||
+ '<span class="opinion">' + OPINION + (g.overall != null ? ' Weighted total ' + g.overall + ' of 100.' : '') + '</span>'
|
||||
+ (r.verdict ? '<div><b>Our verdict (opinion):</b> ' + link(r.verdict, ex) + '</div>' : '')
|
||||
+ (flags ? '<div class="finds"><span class="disp" style="font-weight:700;font-size:17px">Critical flags</span>' + flags + '</div>' : '')
|
||||
+ '<div class="finds"><span class="disp" style="font-weight:700;font-size:17px">Top findings (public facts)</span>' + finds + '</div>';
|
||||
}
|
||||
function factsBlock(v, ex) {
|
||||
return '<div class="finds"><span class="disp" style="font-weight:700;font-size:17px">Facts read straight from the chain</span>'
|
||||
+ (v.facts || []).map(function (f) { return '<div class="find"><span class="tag ' + esc(f.tag) + '">' + esc(f.tag) + '</span><span>' + link(f.text, ex) + (f.source ? ' <a class="src" style="font-size:13px" href="' + esc(f.source) + '" target="_blank" rel="noopener nofollow">source</a>' : '') + '</span></div>'; }).join('') + '</div>';
|
||||
}
|
||||
function deepSections(r, ex) {
|
||||
var out = '';
|
||||
var sec = function (t, body) { if (body) out += '<div class="card" style="gap:8px"><span class="disp" style="font-weight:700;font-size:19px">' + esc(t) + '</span>' + body + '</div>'; };
|
||||
var tagOf = function (o) { return o && o.tag ? ' <span class="tag ' + esc(o.tag) + '">' + esc(o.tag) + '</span>' : ''; };
|
||||
var str = function (x) { return typeof x === 'string' ? link(x, ex) : x == null ? '' : link(JSON.stringify(x), ex); };
|
||||
if (r.plain_summary) sec('In plain words', '<p style="margin:0">' + link(r.plain_summary, ex) + '</p>');
|
||||
if (r.drain_capability) { var d = r.drain_capability; sec('Can one wallet move the money or change the rules?', typeof d === 'string' ? '<p style="margin:0">' + str(d) + '</p>' : '<p style="margin:0">' + str(d.answer) + tagOf(d) + '</p>' + (d.who ? '<p style="margin:0"><b>Who:</b> ' + str(d.who) + '</p>' : '') + (d.how ? '<p style="margin:0"><b>How:</b> ' + str(d.how) + '</p>' : '') + (d.evidence ? '<p style="margin:0"><b>Evidence:</b> ' + str(d.evidence) + '</p>' : '')); }
|
||||
if (Array.isArray(r.exit_paths_ranked) && r.exit_paths_ranked.length) sec('Every exit path, ranked', '<div class="tblwrap"><table class="t"><thead><tr><th>#</th><th>Path</th><th>Who</th><th>Possible now</th><th>Happened</th><th>Tag</th></tr></thead><tbody>' + r.exit_paths_ranked.map(function (x, i) { return '<tr><td>' + (i + 1) + '</td><td>' + str(x.path) + '</td><td>' + str(x.who) + '</td><td>' + str(x.possible_now) + '</td><td>' + str(x.happened) + '</td><td><span class="tag ' + esc(x.tag) + '">' + esc(x.tag) + '</span></td></tr>'; }).join('') + '</tbody></table></div>');
|
||||
if (r.money) { var m = r.money; sec('The money trail', (m.summary ? '<p style="margin:0">' + str(m.summary) + '</p>' : '') + ['balances_now', 'total_in', 'total_out'].map(function (k) { return m[k] ? '<div class="kv"><span>' + k.replace(/_/g, ' ') + '</span><span>' + str(m[k]) + '</span></div>' : ''; }).join('') + (Array.isArray(m.where_out_went) && m.where_out_went.length ? '<div class="tblwrap"><table class="t"><thead><tr><th>Wallet</th><th>Amount</th><th>Note</th><th>Tag</th></tr></thead><tbody>' + m.where_out_went.map(function (x) { return '<tr><td>' + str(x.address) + '</td><td>' + str(x.amount) + '</td><td>' + str(x.note) + '</td><td><span class="tag ' + esc(x.tag) + '">' + esc(x.tag) + '</span></td></tr>'; }).join('') + '</tbody></table></div>' : '')); }
|
||||
if (Array.isArray(r.insiders) && r.insiders.length) sec('Operator and deployment-set wallets', '<div class="tblwrap"><table class="t"><thead><tr><th>Wallet</th><th>Role</th><th>Received</th><th>Owns</th><th>Tag</th></tr></thead><tbody>' + r.insiders.map(function (x) { return '<tr><td>' + str(x.address) + '</td><td>' + str(x.role) + '</td><td>' + str(x.received) + '</td><td>' + str(x.owns) + '</td><td><span class="tag ' + esc(x.tag) + '">' + esc(x.tag) + '</span></td></tr>'; }).join('') + '</tbody></table></div>');
|
||||
if (r.refund_or_promise_math) sec('The promise math', '<p style="margin:0">' + str(r.refund_or_promise_math) + '</p>');
|
||||
if (r.approvals) sec('Wallet approvals at risk', '<p style="margin:0">' + str(r.approvals) + '</p>');
|
||||
if (Array.isArray(r.unknowns) && r.unknowns.length) sec('What the evidence cannot answer', '<ul style="margin:0;padding-left:20px">' + r.unknowns.map(function (x) { return '<li>' + str(x) + '</li>'; }).join('') + '</ul>');
|
||||
return out;
|
||||
}
|
||||
function done(v) {
|
||||
var ex = v.chainRead && v.chainRead.explorer;
|
||||
var g = v.grade || {};
|
||||
var title = (v.label || (v.chainRead && v.chainRead.name) || (v.site && v.site.title) || (v.address ? WWI.short(v.address) : v.website) || 'Check');
|
||||
var meta = [v.address ? '<a class="src" href="' + ex + '/address/' + esc(v.address) + '" target="_blank" rel="noopener nofollow">' + esc(WWI.short(v.address)) + '</a>' : null,
|
||||
v.chainRead ? 'read ' + esc(v.chainRead.time) + ' · block ' + Number(v.chainRead.block).toLocaleString('en-US') : null].filter(Boolean).join(' · ');
|
||||
var head = '<div class="res-head"><div style="display:flex;flex-direction:column;gap:6px"><span class="eyebrow">' + (v.kind === 'deep' ? 'Deep report' : 'Free check') + '</span>'
|
||||
+ '<h2 class="sec">' + esc(title) + (v.chainName ? ' <span style="font-weight:500;color:var(--mut)">on ' + esc(v.chainName) + '</span>' : '') + '</h2>'
|
||||
+ '<span class="mono" style="font-size:14px;color:var(--ink2)">' + meta + '</span></div>'
|
||||
+ (g.grade ? '<div class="gradebox ' + gradeCls(g.grade) + '"><div class="g">' + esc(g.grade) + '</div><div class="n">' + (g.forced_by_flag ? 'One critical flag caps the grade at High, whatever the other scores. ' : '') + 'Our opinion, from the published rubric applied to the public facts.</div></div>' : '') + '</div>';
|
||||
var main = '';
|
||||
if (v.report) main += scorecard(v, ex);
|
||||
else main += '<div class="notice">' + esc((v.factcheck && v.factcheck.note) || 'No written report for this check.') + '</div>';
|
||||
main += factsBlock(v, ex);
|
||||
if (v.pickedNote) main += '<div style="font-size:14px;color:var(--ink2)"><b>Contract:</b> ' + link(v.pickedNote, ex) + '</div>';
|
||||
if (v.chainRead && v.chainRead.window) main += '<div style="font-size:14px;color:var(--ink2)"><b>Range read:</b> blocks ' + v.chainRead.window.from + ' to ' + v.chainRead.window.to + (v.chainRead.window.complete_history ? ', the complete history since deployment.' : ', a partial window (' + esc(v.chainRead.window.from_time_ct || '') + ' onward).') + ((v.chainRead.gaps || []).length ? ' Some ranges could not be read: see the facts marked UNKNOWN.' : '') + '</div>';
|
||||
var side = '<div class="card" style="padding:0;overflow:hidden;gap:0"><div class="shot">' + (v.hasShot ? '<img alt="Screenshot of the project website taken by our own browser" src="/api/check/' + v.id + '/shot.jpg">' : '[No website screenshot for this check]') + '</div>'
|
||||
+ '<div style="padding:16px 18px;display:flex;flex-direction:column;gap:6px;font-size:14px"><span style="font-weight:600">Website claims vs code</span><span style="color:var(--ink2)">' + (v.report && v.report.site_vs_code ? link(v.report.site_vs_code, ex) : v.website ? 'No comparison in this check.' : 'No website was entered.') + '</span>'
|
||||
+ (v.website ? '<span class="src" style="font-size:13px">' + esc(v.website) + '</span>' : '') + '</div></div>';
|
||||
if (v.kind === 'free') side += '<div class="card dk"><span class="disp" style="font-weight:700;font-size:18px">In the deep report</span><span class="b" style="font-size:14px">Every exit path ranked · the full money trail with named wallets · the operator wallet ring · the promise math worked out · wallet approvals at risk · the upgrade timeline with transaction links · what the evidence cannot answer</span><button class="btn org" type="button" data-deep="' + v.id + '">Get the deep report</button><span class="b" style="font-size:13px" data-deepmsg></span></div>';
|
||||
side += '<div class="card" style="font-size:14px;gap:6px"><span style="font-weight:600">Check details</span>'
|
||||
+ (v.timings ? '<div class="kv"><span>Time taken</span><span>' + Math.round(v.timings.total_s) + ' s</span></div>' : '')
|
||||
+ (v.factcheck ? '<div class="kv"><span>Fact check</span><span>' + (v.factcheck.passed ? 'passed' : 'not passed') + '</span></div>' : '')
|
||||
+ '<a href="/c/' + v.id + '">Permanent link to this check</a>' + (v.address ? '<a href="/api/check/' + v.id + '/evidence" target="_blank" rel="noopener">The evidence pack the report was written from</a>' : '') + '</div>';
|
||||
var deep = v.kind === 'deep' && v.report ? '<div style="display:flex;flex-direction:column;gap:16px">' + deepSections(v.report, ex) + '<span class="opinion">' + OPINION + '</span></div>' : '';
|
||||
return head + '<div class="res-body"><div class="res-main">' + main + '</div><div class="res-side">' + side + '</div></div>' + deep;
|
||||
}
|
||||
function draw(el, v) { el.innerHTML = v.status === 'done' ? done(v) : steps(v); }
|
||||
return { draw: draw, OPINION: OPINION, link: link };
|
||||
})();
|
||||
@@ -0,0 +1,14 @@
|
||||
// /c/<id>: one check, polled until it is done. No ads inside the report body.
|
||||
(function () {
|
||||
'use strict';
|
||||
var id = location.pathname.split('/')[2], live = WWI.$('live'), t = null;
|
||||
function poll() {
|
||||
fetch('/api/check/' + id).then(function (r) { return r.json(); }).then(function (v) {
|
||||
if (!v.id) { live.innerHTML = '<div class="notice">' + WWI.esc(v.error || 'Not found') + '</div>'; return; }
|
||||
Render.draw(live, v);
|
||||
live.querySelectorAll('[data-deep]').forEach(function (b) { b.addEventListener('click', function () { location.href = '/?c=' + id + '#reports'; }); });
|
||||
if (v.status === 'queued' || v.status === 'running') t = setTimeout(poll, 2500);
|
||||
}).catch(function () { t = setTimeout(poll, 5000); });
|
||||
}
|
||||
poll();
|
||||
})();
|
||||
@@ -0,0 +1,2 @@
|
||||
// legal pages: one 300-wide slot beside the text (wide screens only); never inside a report
|
||||
(function () { var a = document.getElementById('sideSlot'); if (a && window.innerWidth >= 980) { var d = document.createElement('div'); a.appendChild(d); WWI.slot(d, 'side', 300, 250); } })();
|
||||
@@ -0,0 +1,119 @@
|
||||
/* WebWorthIt look (mockup Main.dc.html, 2026-11-16): paper green, deep forest ink, signal orange. Archivo + IBM Plex Sans/Mono. */
|
||||
:root{--bg:#F3F5F1;--ink:#0E2A22;--ink2:#3E5149;--mut:#5B7067;--line:#C9D3CC;--line2:#E0E6E1;--band:#E6ECE7;--card:#FFFFFF;--deep:#0E2A22;--deep2:#163A2F;--deepline:#2D5446;
|
||||
--on:#EEF3EF;--on2:#C5D3CA;--on3:#A9BEB1;--acc:#E2541B;--acc2:#B23E10;--peach:#F0A27F;--amber:#C98A12;--good:#1F6B4F;--good2:#8FD3B1}
|
||||
*{box-sizing:border-box}
|
||||
html{-webkit-text-size-adjust:100%}
|
||||
body{margin:0;background:var(--bg);color:var(--ink);font-family:'IBM Plex Sans',system-ui,sans-serif;font-size:16px;line-height:1.55}
|
||||
a{color:var(--ink)}a:hover{color:var(--acc)}
|
||||
.disp{font-family:Archivo,sans-serif}
|
||||
.mono{font-family:'IBM Plex Mono',monospace}
|
||||
.wrap{max-width:1200px;margin:0 auto;padding-left:24px;padding-right:24px}
|
||||
@media (max-width:640px){.wrap{padding-left:16px;padding-right:16px}}
|
||||
.eyebrow{font-family:'IBM Plex Mono',monospace;font-size:13px;letter-spacing:.12em;text-transform:uppercase;color:var(--mut)}
|
||||
h1,h2,h3{font-family:Archivo,sans-serif;margin:0;letter-spacing:-.01em}
|
||||
h2.sec{font-size:38px;text-wrap:balance}
|
||||
@media (max-width:640px){h2.sec{font-size:30px}}
|
||||
.staging{background:#FCE6DC;color:#8F3110;text-align:center;font-size:13px;padding:6px 12px;font-family:'IBM Plex Mono',monospace}
|
||||
/* header */
|
||||
.hdr{border-bottom:1px solid var(--line);background:var(--bg)}
|
||||
.hdr .wrap{padding-top:18px;padding-bottom:18px;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:16px}
|
||||
.brand{display:flex;align-items:center;gap:10px;text-decoration:none}
|
||||
.brand span{font-family:Archivo,sans-serif;font-weight:800;font-size:22px;letter-spacing:-.01em}
|
||||
.nav{display:flex;flex-wrap:wrap;gap:22px;font-weight:500;font-size:15px}
|
||||
.nav a{text-decoration:none}
|
||||
.btn{display:inline-block;text-decoration:none;border-radius:6px;font-weight:600;font-size:15px;padding:11px 18px;border:0;cursor:pointer;font-family:inherit}
|
||||
.btn.dark{background:var(--deep);color:var(--bg)}.btn.dark:hover{color:#fff;background:#1b4536}
|
||||
.btn.org{background:var(--acc);color:#fff;font-family:Archivo,sans-serif;font-weight:700;font-size:17px;padding:14px 24px}.btn.org:hover{background:#c94512;color:#fff}
|
||||
.btn.line{background:#fff;color:var(--ink);border:2px solid var(--ink)}
|
||||
.btn[disabled]{opacity:.55;cursor:not-allowed}
|
||||
/* hero */
|
||||
.hero{background:var(--deep);color:var(--on)}
|
||||
.hero .wrap{padding-top:72px;padding-bottom:64px;display:flex;flex-wrap:wrap;gap:48px;align-items:center}
|
||||
.hero .main{flex:999 1 560px;min-width:0;display:flex;flex-direction:column;gap:22px}
|
||||
.hero .side{flex:1 1 340px;min-width:0;display:flex;flex-direction:column;gap:14px}
|
||||
.hero h1{font-weight:800;font-size:58px;line-height:1.04;letter-spacing:-.02em;text-wrap:balance}
|
||||
@media (max-width:640px){.hero h1{font-size:38px}.hero .wrap{padding-top:44px}}
|
||||
.hero p.lead{margin:0;font-size:19px;max-width:600px;color:var(--on2)}
|
||||
.hero .kick{font-family:'IBM Plex Mono',monospace;font-size:13px;letter-spacing:.12em;text-transform:uppercase;color:var(--peach)}
|
||||
.form{display:flex;flex-direction:column;gap:12px;background:var(--deep2);border:1px solid var(--deepline);border-radius:10px;padding:18px}
|
||||
.form label{font-size:14px;font-weight:600;color:var(--on)}
|
||||
.form label span{font-weight:400;color:var(--on3)}
|
||||
.form input[type=url],.form input[type=text],.form select{min-width:0;font-family:'IBM Plex Mono',monospace;font-size:15px;padding:14px;border-radius:6px;border:1px solid #3E6A5A;background:var(--bg);color:var(--ink)}
|
||||
.form select{font-family:'IBM Plex Sans',sans-serif}
|
||||
.form .row{display:flex;flex-wrap:wrap;gap:10px}.form .row input{flex:1 1 320px}
|
||||
.form .fine{font-size:13px;color:var(--on3)}
|
||||
.form .err{color:#FFB599;font-size:14px;min-height:0}
|
||||
.qs{display:flex;flex-direction:column;gap:10px}.qs div{display:flex;gap:12px;align-items:baseline}.qs b{font-family:'IBM Plex Mono',monospace;color:var(--peach);font-weight:400}
|
||||
/* cards */
|
||||
.grid3{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:20px}
|
||||
.card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:24px;display:flex;flex-direction:column;gap:10px}
|
||||
.card.dk{background:var(--deep);color:var(--on);border:0}
|
||||
.card .t{font-family:Archivo,sans-serif;font-weight:700;font-size:21px}
|
||||
.card .b{color:var(--ink2)}.card.dk .b{color:var(--on2)}
|
||||
.card .k{font-family:'IBM Plex Mono',monospace;font-size:13px;letter-spacing:.1em;text-transform:uppercase;color:var(--mut)}
|
||||
.card .k.red{color:var(--acc2)}.card.dk .k{color:var(--peach)}
|
||||
.sec-pad{padding-top:64px;padding-bottom:64px;display:flex;flex-direction:column;gap:28px}
|
||||
.band{background:var(--band);border-top:1px solid var(--line);border-bottom:1px solid var(--line)}
|
||||
.dkband{background:var(--deep);color:var(--on)}
|
||||
/* result */
|
||||
.res-head{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:flex-end;gap:16px}
|
||||
.gradebox{display:flex;align-items:center;gap:14px;border:2px solid var(--acc);border-radius:10px;padding:14px 20px;background:#fff}
|
||||
.gradebox .g{font-family:Archivo,sans-serif;font-weight:800;font-size:30px;color:var(--acc2)}
|
||||
.gradebox.low{border-color:var(--good)}.gradebox.low .g{color:var(--good)}
|
||||
.gradebox.mod{border-color:var(--amber)}.gradebox.mod .g{color:#8a5d06}
|
||||
.gradebox .n{font-size:14px;max-width:260px;color:var(--ink2)}
|
||||
.res-body{display:flex;flex-wrap:wrap;gap:24px}
|
||||
.res-main{flex:999 1 560px;min-width:0;background:#fff;border:1px solid var(--line);border-radius:12px;padding:26px;display:flex;flex-direction:column;gap:18px}
|
||||
.res-side{flex:1 1 340px;min-width:0;display:flex;flex-direction:column;gap:20px}
|
||||
.scores{display:grid;grid-template-columns:minmax(0,1fr) minmax(70px,220px) 32px;gap:10px 16px;align-items:center}
|
||||
.bar{height:10px;background:var(--band);border-radius:5px}.bar i{display:block;height:10px;border-radius:5px;background:var(--acc)}.bar i.mid{background:var(--amber)}.bar i.lo{background:var(--good)}
|
||||
.why{grid-column:1/-1;font-size:13px;color:var(--ink2);margin:-4px 0 4px}
|
||||
.opinion{font-size:13px;color:var(--ink2);background:#F7F9F6;border-left:3px solid var(--line);padding:8px 12px}
|
||||
.finds{border-top:1px solid var(--line2);padding-top:16px;display:flex;flex-direction:column;gap:12px}
|
||||
.find{display:flex;gap:12px;align-items:flex-start}
|
||||
.tag{font-family:'IBM Plex Mono',monospace;font-size:11px;font-weight:500;letter-spacing:.06em;background:var(--deep);color:#fff;padding:3px 7px;border-radius:4px;white-space:nowrap}
|
||||
.tag.INFERRED{background:var(--mut)}.tag.UNKNOWN{background:#fff;color:var(--ink);border:1px solid var(--ink)}
|
||||
.find a,.src{word-break:break-all}
|
||||
.shot{height:200px;background:repeating-linear-gradient(135deg,#E6ECE7 0 12px,#DCE4DE 12px 24px);display:flex;align-items:center;justify-content:center;color:var(--ink2);font-family:'IBM Plex Mono',monospace;font-size:13px;text-align:center;padding:16px;overflow:hidden}
|
||||
.shot img{width:100%;height:100%;object-fit:cover;object-position:top}
|
||||
.steps{display:flex;flex-direction:column;gap:8px;background:#fff;border:1px solid var(--line);border-radius:12px;padding:20px}
|
||||
.step{display:flex;gap:10px;align-items:baseline}.step .dot{width:10px;height:10px;border-radius:50%;background:var(--line);flex:0 0 10px;transform:translateY(1px)}
|
||||
.step.running .dot{background:var(--acc);animation:pulse 1s infinite alternate}.step.done .dot{background:var(--good)}.step.failed .dot{background:var(--acc2)}.step.skipped .dot{background:#fff;border:1px solid var(--mut)}
|
||||
.step .nt{font-size:13px;color:var(--ink2)}
|
||||
@keyframes pulse{from{opacity:.35}to{opacity:1}}
|
||||
.notice{background:#FFF6E5;border:1px solid #E9C98A;border-radius:10px;padding:14px 16px;font-size:14px}
|
||||
.kv{display:flex;justify-content:space-between;gap:10px;border-bottom:1px solid var(--line2);padding-bottom:6px}
|
||||
.addr{font-family:'IBM Plex Mono',monospace;font-size:13px;word-break:break-all}
|
||||
table.t{width:100%;border-collapse:collapse;font-size:14px}table.t th,table.t td{text-align:left;padding:8px 10px;border-top:1px solid var(--line2);vertical-align:top}
|
||||
.tblwrap{overflow-x:auto;border:1px solid var(--line);border-radius:12px;background:#fff}
|
||||
.dkband .tblwrap{border-color:var(--deepline);background:transparent}
|
||||
.dkband table.t td,.dkband table.t th{border-top-color:var(--deepline)}
|
||||
.dkband thead tr{background:var(--deep2)}
|
||||
.ph{color:var(--on3)}
|
||||
.pill{font-family:'IBM Plex Mono',monospace;font-size:12px;background:#FCE6DC;color:#8F3110;padding:4px 8px;border-radius:4px}
|
||||
/* pricing */
|
||||
.price{flex:1 1 300px;min-width:0;background:#fff;border:1px solid var(--line);border-radius:12px;padding:26px;display:flex;flex-direction:column;gap:14px}
|
||||
.price .amt{font-family:Archivo,sans-serif;font-weight:800;font-size:46px}
|
||||
.price.hot{border:2px solid var(--acc)}
|
||||
.price.dk{background:var(--deep);color:var(--on);border:0}
|
||||
.flexw{display:flex;flex-wrap:wrap;gap:20px}
|
||||
/* ad slots: neutral names on purpose */
|
||||
.slot{margin:24px auto;text-align:center;max-width:100%}
|
||||
.slot .lab{font-size:11px;color:var(--mut);letter-spacing:.06em;margin-bottom:4px;font-family:'IBM Plex Mono',monospace}
|
||||
.slot iframe{border:0;max-width:100%;display:block;margin:0 auto;background:transparent}
|
||||
.legal-grid{display:flex;gap:32px;align-items:flex-start}
|
||||
.legal-grid main{flex:1 1 auto;min-width:0;max-width:760px}
|
||||
.legal-grid aside{flex:0 0 300px}
|
||||
@media (max-width:980px){.legal-grid aside{display:none}}
|
||||
.legal h1{font-size:clamp(32px,5vw,46px);margin:8px 0 16px}
|
||||
.legal h2{font-size:22px;margin:28px 0 8px}
|
||||
.legal p,.legal li{color:var(--ink2)}
|
||||
/* footer */
|
||||
.foot{border-top:1px solid var(--line);margin-top:24px}
|
||||
.foot .wrap{padding-top:32px;padding-bottom:40px;display:flex;flex-direction:column;gap:10px;font-size:14px;color:var(--ink2)}
|
||||
.foot .top{display:flex;flex-wrap:wrap;justify-content:space-between;gap:16px}
|
||||
.foot a{color:var(--ink2)}
|
||||
.netline .here{font-weight:600;color:var(--ink)}
|
||||
input.code{font-family:'IBM Plex Mono',monospace;font-size:15px;padding:11px;border-radius:6px;border:1px solid var(--line);min-width:0}
|
||||
.hide{display:none!important}
|
||||
pre.ev{white-space:pre-wrap;word-break:break-all;font-size:12px;background:#fff;border:1px solid var(--line);border-radius:8px;padding:12px;max-height:520px;overflow:auto}
|
||||
@@ -0,0 +1,23 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Disclaimer | WebWorthIt</title>
|
||||
<meta name="description" content="WebWorthIt uses only public information. Scores are our opinion, not financial advice.">
|
||||
<meta name="theme-color" content="#0E2A22">
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Archivo:wght@500;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap">
|
||||
<link rel="stylesheet" href="/assets/wwi.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap legal-grid" style="padding-top:40px;padding-bottom:56px"><main class="legal"><p class="eyebrow">Updated November 16, 2026</p><h1>Disclaimer</h1>
|
||||
<p><b>Public information only.</b> Every WebWorthIt check uses only public information that anyone could look up on their own: public blockchain records, verified or decompiled public contract code, and the project's public website. We do not access private data, we do not hack anything, we do not sign in to or interact with the project, and we do not move funds. A check is read-only.</p>
|
||||
<p><b>Facts and opinion are kept apart.</b> Our findings are public facts, each one tagged and linked to its on-chain or website source. The scores, the grade (for example "High risk") and the verdict are our opinion, formed by applying our published rubric to those public facts. Scores are never for sale: there are no badges to buy and no paid removals.</p>
|
||||
<p><b>Not advice.</b> A report is information about code and on-chain records. It is not financial advice and it is not a judgment of any person. Nothing on this site tells you to join, leave, buy, sell or withdraw. Make your own decision, with your own research.</p>
|
||||
<p><b>Code and records, not people.</b> We describe what a contract can do and what the chain shows. We do not say anything about the intentions or character of anyone behind a project. A project can reply to its check in its public thread.</p>
|
||||
<p><b>Limits.</b> Our tools read public nodes, which can fail or return less than the full history. Function names for unverified code come from public signature databases and are marked INFERRED. What we cannot see is marked UNKNOWN.</p></main><aside id="sideSlot" aria-label="Advertisement"></aside></div>
|
||||
<script src="/assets/common.js?v=1"></script>
|
||||
<script src="/assets/side.js?v=1"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,4 @@
|
||||
<!doctype html>
|
||||
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Advertisement</title>
|
||||
<style>html,body{margin:0;padding:0;background:transparent;overflow:hidden;display:flex;justify-content:center}</style></head>
|
||||
<body><script src="/f/n.js"></script></body></html>
|
||||
@@ -0,0 +1,3 @@
|
||||
// The ad frame: loads one LinkSpin zone (z.js) inside this iframe only, async, so it can never block or restyle the page around it.
|
||||
(function () { var z = new URLSearchParams(location.search).get('z'); if (!/^ls-[a-z0-9]{4,12}$/.test(z || '')) return;
|
||||
var s = document.createElement('script'); s.async = true; s.src = 'https://linkspin.app/z.js'; s.setAttribute('data-zone', z); document.body.appendChild(s); })();
|
||||
@@ -0,0 +1,268 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>WebWorthIt: check before you join</title>
|
||||
<meta name="description" content="Paste a smart contract address or a project website and see who controls the money, where it went and whether the promises match the code. Public information only, read-only.">
|
||||
<meta name="theme-color" content="#0E2A22">
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Archivo:wght@500;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap">
|
||||
<link rel="stylesheet" href="/assets/wwi.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
<div style="background: #F3F5F1; color: #0E2A22; font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 16px; line-height: 1.55">
|
||||
<!-- hero / check -->
|
||||
<div id="check" style="background: #0E2A22; color: #EEF3EF">
|
||||
<div style="max-width: 1200px; margin: 0 auto; padding: 72px 24px 64px; display: flex; flex-wrap: wrap; gap: 48px; align-items: center">
|
||||
<div style="flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 22px">
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: #F0A27F">Contract and website check</span>
|
||||
<h1 style="margin: 0; font-family: Archivo, sans-serif; font-weight: 800; font-size: 58px; line-height: 1.04; letter-spacing: -0.02em; text-wrap: balance">Know who controls the money before you send yours.</h1>
|
||||
<p style="margin: 0; font-size: 19px; max-width: 600px; color: #C5D3CA">The sales page tells you what the project wants you to hear. The contract tells you what can actually happen to your deposit. Paste the address or the website and see it in plain English, before you join.</p>
|
||||
<form id="checkForm" novalidate style="display: flex; flex-direction: column; gap: 12px; background: #163A2F; border: 1px solid #2D5446; border-radius: 10px; padding: 18px">
|
||||
<label for="site" style="font-size: 14px; font-weight: 600; color: #EEF3EF">Project website</label>
|
||||
<input id="site" name="website" type="url" autocomplete="url" inputmode="url" placeholder="https://the-project-website.com" style="min-width: 0; font-family: 'IBM Plex Mono', monospace; font-size: 15px; padding: 14px; border-radius: 6px; border: 1px solid #3E6A5A; background: #F3F5F1; color: #0E2A22">
|
||||
<label for="target" style="font-size: 14px; font-weight: 600; color: #EEF3EF">Smart contract address <span style="font-weight: 400; color: #A9BEB1">(leave blank and we'll look for it on the website)</span></label>
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 10px">
|
||||
<input id="target" name="address" type="text" autocomplete="off" spellcheck="false" placeholder="0x... (optional)" style="flex: 1 1 320px; min-width: 0; font-family: 'IBM Plex Mono', monospace; font-size: 15px; padding: 14px; border-radius: 6px; border: 1px solid #3E6A5A; background: #F3F5F1; color: #0E2A22">
|
||||
<select id="chain" name="chain" aria-label="Chain" style="font-size: 15px; padding: 14px; border-radius: 6px; border: 1px solid #3E6A5A; background: #F3F5F1; color: #0E2A22">
|
||||
<option value="bsc">BNB Chain</option><option value="polygon">Polygon</option><option value="eth">Ethereum</option><option value="base">Base</option>
|
||||
</select>
|
||||
</div>
|
||||
<button id="runBtn" type="submit" style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 17px; padding: 14px 24px; border-radius: 6px; border: 0; background: #E2541B; color: #FFFFFF; cursor: pointer">Run free check</button>
|
||||
<span style="font-size: 13px; color: #A9BEB1">Fill in one or both. With both, we compare what the website promises against what the code does. 3 free checks a day. Read-only: a check never asks you to connect a wallet.</span>
|
||||
<span id="formErr" role="alert" style="color: #FFB599; font-size: 14px"></span><span id="freeLeft" style="font-size: 13px; color: #A9BEB1"></span>
|
||||
</form>
|
||||
</div>
|
||||
<div style="flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 14px">
|
||||
<div style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: #A9BEB1; letter-spacing: 0.08em; text-transform: uppercase">What every check answers</div>
|
||||
<div style="display: flex; flex-direction: column; gap: 10px">
|
||||
<div style="display: flex; gap: 12px; align-items: baseline"><span style="font-family: 'IBM Plex Mono', monospace; color: #F0A27F">01</span><span>Can one wallet change the code or take the funds?</span></div>
|
||||
<div style="display: flex; gap: 12px; align-items: baseline"><span style="font-family: 'IBM Plex Mono', monospace; color: #F0A27F">02</span><span>Where has the money actually gone, wallet by wallet?</span></div>
|
||||
<div style="display: flex; gap: 12px; align-items: baseline"><span style="font-family: 'IBM Plex Mono', monospace; color: #F0A27F">03</span><span>Are payouts funded only by people joining later?</span></div>
|
||||
<div style="display: flex; gap: 12px; align-items: baseline"><span style="font-family: 'IBM Plex Mono', monospace; color: #F0A27F">04</span><span>Does the website promise what the code delivers?</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="heroSlot"></div>
|
||||
<!-- live result -->
|
||||
<div id="live" class="wrap hide" style="padding-top: 48px; padding-bottom: 8px; display: flex; flex-direction: column; gap: 24px"></div>
|
||||
<div id="liveSlot"></div>
|
||||
<!-- problem / agitate / solve -->
|
||||
<div style="max-width: 1200px; margin: 0 auto; padding: 64px 24px 8px; display: flex; flex-direction: column; gap: 28px">
|
||||
<h2 style="margin: 0; font-family: Archivo, sans-serif; font-size: 38px; letter-spacing: -0.01em; text-wrap: balance; max-width: 820px">Most people check an opportunity after the money is gone. By then the contract can't be changed back.</h2>
|
||||
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px">
|
||||
<div style="background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 10px">
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: #5B7067">How it usually goes</span>
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 21px">You hear about it from someone you trust</span>
|
||||
<span style="color: #3E5149">The page shows a refund promise and a smart contract, so it looks safe. Almost nobody reads the contract, and the people promoting it usually haven't either.</span>
|
||||
</div>
|
||||
<div style="background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 10px">
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: #B23E10">What the contract said</span>
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 21px">One key could swap the rules</span>
|
||||
<span style="color: #3E5149">In the real example below, one personal wallet can replace the code in a single transaction, with 3,632.30 USDT behind it. The promised refund is paid in a credit that can only buy more entries.</span>
|
||||
</div>
|
||||
<div style="background: #0E2A22; color: #EEF3EF; border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 10px">
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: #F0A27F">What a report changes</span>
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 21px">You see it before you send a cent</span>
|
||||
<span style="color: #C5D3CA">Who can move the money, where it has gone so far, and whether the promises match the code. Then you decide with facts instead of hope.</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- sample result -->
|
||||
<div style="max-width: 1200px; margin: 0 auto; padding: 64px 24px; display: flex; flex-direction: column; gap: 28px">
|
||||
<div style="display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px">
|
||||
<div style="display: flex; flex-direction: column; gap: 6px">
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: #5B7067">Sample free check, a real contract (example)</span>
|
||||
<h2 style="margin: 0; font-family: Archivo, sans-serif; font-size: 38px; letter-spacing: -0.01em">3xSusu Vault <span style="font-weight: 500; color: #5B7067">on BNB Chain</span></h2>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 14px; color: #3E5149">0x152d…976e · read 2026-11-16 9:30 AM CST · block 133,946,636</span>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 14px; border: 2px solid #E2541B; border-radius: 10px; padding: 14px 20px; background: #FFFFFF">
|
||||
<div style="font-family: Archivo, sans-serif; font-weight: 800; font-size: 30px; color: #B23E10">High risk</div>
|
||||
<div style="font-size: 14px; max-width: 230px; color: #3E5149">One critical flag caps the grade at High, whatever the other scores.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 24px">
|
||||
<!-- scorecard -->
|
||||
<div style="flex: 999 1 560px; min-width: 0; background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; padding: 26px; display: flex; flex-direction: column; gap: 18px">
|
||||
<div style="display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap"><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 20px">Scorecard</span><span style="font-size: 13px; color: #5B7067">0 = safest, 10 = worst · weight in brackets</span></div>
|
||||
|
||||
<div style="display: grid; grid-template-columns: minmax(0, 1fr) minmax(70px, 220px) 32px; gap: 10px 16px; align-items: center">
|
||||
<span>Control and upgradeability <span style="color: #5B7067">(25)</span></span>
|
||||
<div style="height: 10px; background: #E6ECE7; border-radius: 5px"><div style="width: 100%; height: 10px; background: #E2541B; border-radius: 5px"></div></div>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-weight: 500">10</span>
|
||||
<span>Custody and exit paths <span style="color: #5B7067">(25)</span></span>
|
||||
<div style="height: 10px; background: #E6ECE7; border-radius: 5px"><div style="width: 80%; height: 10px; background: #E2541B; border-radius: 5px"></div></div>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-weight: 500">8</span>
|
||||
<span>Economic design <span style="color: #5B7067">(20)</span></span>
|
||||
<div style="height: 10px; background: #E6ECE7; border-radius: 5px"><div style="width: 90%; height: 10px; background: #E2541B; border-radius: 5px"></div></div>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-weight: 500">9</span>
|
||||
<span>Insider flows <span style="color: #5B7067">(15)</span></span>
|
||||
<div style="height: 10px; background: #E6ECE7; border-radius: 5px"><div style="width: 80%; height: 10px; background: #E2541B; border-radius: 5px"></div></div>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-weight: 500">8</span>
|
||||
<span>Disclosure vs code <span style="color: #5B7067">(10)</span></span>
|
||||
<div style="height: 10px; background: #E6ECE7; border-radius: 5px"><div style="width: 70%; height: 10px; background: #C98A12; border-radius: 5px"></div></div>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-weight: 500">7</span>
|
||||
<span>Trajectory <span style="color: #5B7067">(5)</span></span>
|
||||
<div style="height: 10px; background: #E6ECE7; border-radius: 5px"><div style="width: 50%; height: 10px; background: #C98A12; border-radius: 5px"></div></div>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-weight: 500">5</span>
|
||||
</div>
|
||||
|
||||
<span style="font-size: 13px; color: #3E5149">Scores and grade are our opinion, based on our published rubric applied to the public facts below.</span>
|
||||
<div style="border-top: 1px solid #E0E6E1; padding-top: 16px; display: flex; flex-direction: column; gap: 12px">
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 17px">Top findings</span>
|
||||
<div style="display: flex; gap: 12px; align-items: flex-start"><span style="font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; background: #0E2A22; color: #FFFFFF; padding: 3px 7px; border-radius: 4px; white-space: nowrap">VERIFIED</span><span>One personal wallet (owner 0x3133…2a79) can replace the contract's code in a single transaction. No timelock, no multisig. It has already done so twice, the second time after about 588 entries were in.</span></div>
|
||||
<div style="display: flex; gap: 12px; align-items: flex-start"><span style="font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; background: #0E2A22; color: #FFFFFF; padding: 3px 7px; border-radius: 4px; white-space: nowrap">VERIFIED</span><span>3,632.30 USDT sits in the vault today. All 29,057.70 USDT paid out so far matches the published split exactly: nothing has been drained.</span></div>
|
||||
<div style="display: flex; gap: 12px; align-items: flex-start"><span style="font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; background: #0E2A22; color: #FFFFFF; padding: 3px 7px; border-radius: 4px; white-space: nowrap">VERIFIED</span><span>The "buyback" wallet owns 455 of 1,419 positions and has received 4,098.25 USDT from them.</span></div>
|
||||
<div style="display: flex; gap: 12px; align-items: flex-start"><span style="font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; background: #5B7067; color: #FFFFFF; padding: 3px 7px; border-radius: 4px; white-space: nowrap">INFERRED</span><span>The refund pool covers about 27 refunds at 52.5 SUSU each. The first refunds come due 2026-11-27.</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- site snapshot + locked -->
|
||||
<div style="flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 20px">
|
||||
<div style="background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; overflow: hidden">
|
||||
<div style="height: 200px; background: repeating-linear-gradient(135deg, #E6ECE7 0 12px, #DCE4DE 12px 24px); display: flex; align-items: center; justify-content: center; color: #3E5149; font-family: 'IBM Plex Mono', monospace; font-size: 13px; text-align: center; padding: 16px"><img src="/art/sample-3xsusu.jpg" alt="Screenshot of the 3xSusu website taken by our own headless browser" style="width: 100%; height: 100%; object-fit: cover; object-position: top" data-sample>[Project website screenshot, taken by our own headless browser]</div>
|
||||
<div style="padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px">
|
||||
<span style="font-weight: 600">Website claims vs code</span>
|
||||
<span style="color: #3E5149">Claims a 100% refund plus 50%. The code pays it in SUSU credit that can only be spent back into new entries.</span>
|
||||
</div>
|
||||
</div>
|
||||
<div style="background: #0E2A22; color: #EEF3EF; border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 12px">
|
||||
<div style="display: flex; align-items: center; gap: 10px"><svg width="18" height="18" viewBox="0 0 18 18" aria-hidden="true"><rect x="3" y="8" width="12" height="8" rx="1.5" fill="none" stroke="#F0A27F" stroke-width="1.8"></rect><path d="M6 8 V5.5 a3 3 0 0 1 6 0 V8" fill="none" stroke="#F0A27F" stroke-width="1.8"></path></svg><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 18px">In the deep report</span></div>
|
||||
<span style="font-size: 14px; color: #C5D3CA">Every exit path ranked · the full money trail with named wallets · the operator wallet ring · the refund math worked out · wallet approvals at risk · the upgrade timeline with transaction links · what the evidence cannot answer</span>
|
||||
<a href="#reports" style="text-decoration: none; background: #E2541B; color: #FFFFFF; text-align: center; padding: 13px; border-radius: 6px; font-weight: 600">See deep report prices</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- how scoring works -->
|
||||
<div id="scoring" style="background: #E6ECE7; border-top: 1px solid #C9D3CC; border-bottom: 1px solid #C9D3CC">
|
||||
<div style="max-width: 1200px; margin: 0 auto; padding: 64px 24px; display: flex; flex-direction: column; gap: 28px">
|
||||
<h2 style="margin: 0; font-family: Archivo, sans-serif; font-size: 38px; letter-spacing: -0.01em">How a check works</h2>
|
||||
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px">
|
||||
<div style="background: #FFFFFF; border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 10px"><span style="font-family: 'IBM Plex Mono', monospace; color: #B23E10; font-size: 14px">Step 1</span><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 21px">Read the chain</span><span style="color: #3E5149">Proxy and owner roles, every upgrade, every token in and out, who owns the positions, wallet approvals. Read-only, straight from public nodes.</span></div>
|
||||
<div style="background: #FFFFFF; border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 10px"><span style="font-family: 'IBM Plex Mono', monospace; color: #B23E10; font-size: 14px">Step 2</span><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 21px">Score it in public</span><span style="color: #3E5149">Six weighted categories from a rubric anyone can read. Anything the team hid counts against the project, and the report says so.</span></div>
|
||||
<div style="background: #FFFFFF; border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 10px"><span style="font-family: 'IBM Plex Mono', monospace; color: #B23E10; font-size: 14px">Step 3</span><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 21px">Tag every claim</span><span style="color: #3E5149">VERIFIED means seen on chain with a transaction link. INFERRED comes from code or simulation. UNKNOWN is stated, never guessed.</span></div>
|
||||
</div>
|
||||
<p style="margin: 0; font-size: 15px; color: #3E5149">Scores are never for sale. There are no badges to buy and no paid removals. A project can reply to its check on Earners Corner.</p>
|
||||
<div id="howSlot"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- deep reports pricing -->
|
||||
<div id="reports" style="max-width: 1200px; margin: 0 auto; padding: 64px 24px; display: flex; flex-direction: column; gap: 28px">
|
||||
<div style="display: flex; flex-direction: column; gap: 8px">
|
||||
<h2 style="margin: 0; font-family: Archivo, sans-serif; font-size: 38px; letter-spacing: -0.01em; text-wrap: balance">An ounce of prevention costs less than one entry</h2>
|
||||
<p style="margin: 0; color: #3E5149; max-width: 680px">One entry into the sample program above costs 35 USDT. A deep report on it costs $10. Once a deposit is in a contract, nobody can undo it. A report you read first can stop you from making it.</p>
|
||||
</div>
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 20px; align-items: stretch">
|
||||
<div style="flex: 1 1 260px; min-width: 0; border: 1px dashed #B23E10; border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 6px"><span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: #B23E10">Finding out after you join</span><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 20px">Whatever you put in, plus your team's trust</span><span style="color: #3E5149; font-size: 15px">If you recruited people into it, they lose with you.</span></div>
|
||||
<div style="flex: 1 1 260px; min-width: 0; border: 2px solid #1F6B4F; border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 6px"><span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: #1F6B4F">Finding out before you join</span><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 20px">$10, ready in minutes</span><span style="color: #3E5149; font-size: 15px">Join with your eyes open, or walk away with your money still yours.</span></div>
|
||||
</div>
|
||||
<p style="margin: 0; color: #3E5149; font-size: 14px">One-time payments on Polygon. No subscriptions. Pay with SafePal or any other crypto wallet.</p>
|
||||
<p style="margin: 0; color: #3E5149; font-size: 14px">Sponsors earn 20% when someone they referred buys, plus 5% on levels 2 to 5. Only members who have bought here themselves receive a share; anyone who has not is passed over. You earn only when people choose to buy.</p>
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 20px">
|
||||
<div style="flex: 1 1 300px; min-width: 0; background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; padding: 26px; display: flex; flex-direction: column; gap: 14px">
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 20px">One deep report</span>
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 800; font-size: 46px">$10</span>
|
||||
<span style="color: #3E5149">The full report on one contract and its website, ready in minutes.</span>
|
||||
<button type="button" style="margin-top: auto; font-weight: 600; font-size: 16px; padding: 13px; border-radius: 6px; border: 2px solid #0E2A22; background: #FFFFFF; color: #0E2A22; cursor: pointer" data-buy="deep1" disabled>Payments arrive at launch</button>
|
||||
</div>
|
||||
<div style="flex: 1 1 300px; min-width: 0; background: #FFFFFF; border: 2px solid #E2541B; border-radius: 12px; padding: 26px; display: flex; flex-direction: column; gap: 14px">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; gap: 10px"><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 20px">10 deep reports</span><span style="font-family: 'IBM Plex Mono', monospace; font-size: 12px; background: #FCE6DC; color: #8F3110; padding: 4px 8px; border-radius: 4px">Best for team leaders</span></div>
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 800; font-size: 46px">$79</span>
|
||||
<span style="color: #3E5149">$7.90 a report, 2 reports free. Use them any time on any contract your team asks about.</span>
|
||||
<button type="button" style="margin-top: auto; font-weight: 600; font-size: 16px; padding: 13px; border-radius: 6px; border: 0; background: #E2541B; color: #FFFFFF; cursor: pointer" data-buy="deep10" disabled>Payments arrive at launch</button>
|
||||
</div>
|
||||
<div style="flex: 1 1 300px; min-width: 0; background: #0E2A22; color: #EEF3EF; border-radius: 12px; padding: 26px; display: flex; flex-direction: column; gap: 14px">
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: #F0A27F">Add at checkout</span>
|
||||
<label style="display: flex; gap: 12px; align-items: flex-start; font-size: 16px"><input id="watch" type="checkbox" checked style="width: 22px; height: 22px; margin-top: 3px; accent-color: #E2541B"><span><strong>Watch alerts, $9</strong> for 3 months on this contract. We message you the moment the owner upgrades the code, pauses withdrawals, changes a split or the vault balance drops sharply.</span></label>
|
||||
<span style="font-size: 13px; color: #A9BEB1">One payment. It stops by itself after 3 months. Alerts start at launch.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 20px">
|
||||
<div style="flex: 1 1 300px; min-width: 0; background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 10px">
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 18px">Have a voucher?</span>
|
||||
<span style="color: #3E5149; font-size: 14px">Vouchers add deep reports or extra free checks to this browser, or to your account when you are signed in.</span>
|
||||
<div style="display: flex; gap: 10px; flex-wrap: wrap"><input id="voucher" class="code" placeholder="VOUCHER CODE" style="flex: 1 1 180px"><button id="redeemBtn" class="btn dark" type="button">Redeem</button></div>
|
||||
<span id="voucherMsg" style="font-size: 14px; color: #3E5149"></span><span id="creditLine" style="font-size: 14px; color: #1F6B4F"></span>
|
||||
</div>
|
||||
<div id="testBox" class="hide" style="flex: 1 1 300px; min-width: 0; background: #FCE6DC; border: 1px dashed #B23E10; border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 10px">
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 18px">Staging test code</span>
|
||||
<span style="color: #3E5149; font-size: 14px">For testing only. It unlocks deep reports and test purchases that record who would be paid. No money moves.</span>
|
||||
<div id="testIn" style="display: flex; gap: 10px; flex-wrap: wrap"><input id="testCode" class="code" placeholder="test code" autocomplete="off" style="flex: 1 1 180px"><button id="testBtn" class="btn dark" type="button">Unlock</button></div>
|
||||
<div id="testOn" class="hide" style="display: flex; gap: 10px; flex-wrap: wrap"><button class="btn line" type="button" data-test="deep1">Test purchase: 1 report</button><button class="btn line" type="button" data-test="deep10">Test purchase: 10 reports</button><button id="lockBtn" class="btn" type="button" style="background: transparent; text-decoration: underline">Lock</button></div>
|
||||
<span id="testMsg" style="font-size: 14px; color: #3E5149"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="shareBox" class="hide" style="background: #FFFFFF; border: 2px solid #1F6B4F; border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 10px">
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 18px">Share WebWorthIt</span>
|
||||
<span style="color: #3E5149; font-size: 14px">Your referral link. When someone you referred buys a report, you earn 20% as their direct sponsor, plus 5% on levels 2 to 5 of your team. You earn only when people choose to buy.</span>
|
||||
<div style="display: flex; gap: 10px; flex-wrap: wrap"><input id="refLink" class="code" readonly style="flex: 1 1 320px"><button id="copyRef" class="btn dark" type="button">Copy link</button></div>
|
||||
</div>
|
||||
<!-- payment contract scanned -->
|
||||
<div style="background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; padding: 26px; display: flex; flex-wrap: wrap; gap: 24px; align-items: center">
|
||||
<div style="flex: 999 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 8px">
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: #5B7067">The contract that takes your payment, checked by the same tool</span>
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 24px">WebWorthIt payment contract on Polygon</span>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 14px; color: #3E5149">[address published at launch] · source verified on Polygonscan · placeholder until launch</span>
|
||||
<span style="color: #3E5149">Not upgradeable. No owner withdraw or sweep function. Every payment is split in the same transaction and shows on a public ledger.</span>
|
||||
</div>
|
||||
<div style="flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 8px; font-size: 15px">
|
||||
<div style="display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid #E0E6E1; padding-bottom: 6px"><span>Can one wallet change it?</span><strong style="color: #1F6B4F">No</strong></div>
|
||||
<div style="display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid #E0E6E1; padding-bottom: 6px"><span>Can anyone sweep funds?</span><strong style="color: #1F6B4F">No</strong></div>
|
||||
<div style="display: flex; justify-content: space-between; gap: 10px"><span>Full check</span><span style="color: #5B7067">[scorecard at launch]</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- network checked -->
|
||||
<div id="network" style="background: #0E2A22; color: #EEF3EF">
|
||||
<div style="max-width: 1200px; margin: 0 auto; padding: 64px 24px; display: flex; flex-direction: column; gap: 26px">
|
||||
<div style="display: flex; flex-direction: column; gap: 8px">
|
||||
<h2 style="margin: 0; font-family: Archivo, sans-serif; font-size: 38px; letter-spacing: -0.01em">Network, checked</h2>
|
||||
<p style="margin: 0; color: #C5D3CA; max-width: 720px">We run the same check on every contract in our own network and publish the result, good or bad. Rescanned every week.</p>
|
||||
<p style="margin: 0; color: #A9BEB1; font-size: 13px">Each grade is our opinion, from the published rubric applied to the public facts in the linked report.</p>
|
||||
</div>
|
||||
<div style="overflow-x: auto; border: 1px solid #2D5446; border-radius: 12px">
|
||||
<table style="width: 100%; min-width: 720px; border-collapse: collapse; font-size: 15px">
|
||||
<thead><tr style="text-align: left; background: #163A2F"><th style="padding: 14px 16px; font-weight: 600">Site</th><th style="padding: 14px 16px; font-weight: 600">Contract</th><th style="padding: 14px 16px; font-weight: 600">Source</th><th style="padding: 14px 16px; font-weight: 600">Check</th></tr></thead>
|
||||
<tbody>
|
||||
<tr style="border-top: 1px solid #2D5446" data-net="0x36f6ccc8752dce1c84e06b65f07df30e8a4707d7"><td style="padding: 13px 16px">Viral Banner Blitz</td><td style="padding: 13px 16px; font-family: 'IBM Plex Mono', monospace"><a style="color: #EEF3EF" href="https://polygonscan.com/address/0x36F6ccc8752DcE1c84e06b65f07dF30e8a4707D7" target="_blank" rel="noopener nofollow">0x36F6…D7D7</a></td><td style="padding: 13px 16px; color: #8FD3B1" data-src>Verified</td><td style="padding: 13px 16px; color: #A9BEB1" data-score>[scorecard at launch]</td></tr>
|
||||
<tr style="border-top: 1px solid #2D5446" data-net="0xb58447b0ce9a38ad0e7d41a074febee696452905"><td style="padding: 13px 16px">ViralAdBlitz</td><td style="padding: 13px 16px; font-family: 'IBM Plex Mono', monospace"><a style="color: #EEF3EF" href="https://polygonscan.com/address/0xb58447b0CE9a38Ad0e7d41a074FEbee696452905" target="_blank" rel="noopener nofollow">0xb584…2905</a></td><td style="padding: 13px 16px; color: #8FD3B1" data-src>Verified</td><td style="padding: 13px 16px; color: #A9BEB1" data-score>[scorecard at launch]</td></tr>
|
||||
<tr style="border-top: 1px solid #2D5446" data-net="0xed07ad7150ecba62689cf2480729753f2fa44e90"><td style="padding: 13px 16px">DownlineHydra</td><td style="padding: 13px 16px; font-family: 'IBM Plex Mono', monospace"><a style="color: #EEF3EF" href="https://polygonscan.com/address/0xEd07Ad7150ecBa62689Cf2480729753F2Fa44e90" target="_blank" rel="noopener nofollow">0xEd07…4e90</a></td><td style="padding: 13px 16px; color: #8FD3B1" data-src>Verified</td><td style="padding: 13px 16px; color: #A9BEB1" data-score>[scorecard at launch]</td></tr>
|
||||
<tr style="border-top: 1px solid #2D5446" data-net="0x83bb982d8b485de1a24e7d313765dda48d5abc74"><td style="padding: 13px 16px">5xYourTeam</td><td style="padding: 13px 16px; font-family: 'IBM Plex Mono', monospace"><a style="color: #EEF3EF" href="https://polygonscan.com/address/0x83Bb982d8B485De1a24E7D313765dDA48D5aBc74" target="_blank" rel="noopener nofollow">0x83Bb…bc74</a></td><td style="padding: 13px 16px; color: #8FD3B1" data-src>Verified</td><td style="padding: 13px 16px; color: #A9BEB1" data-score>[scorecard at launch]</td></tr>
|
||||
<tr style="border-top: 1px solid #2D5446"><td style="padding: 13px 16px">Downline Banners</td><td style="padding: 13px 16px; font-family: 'IBM Plex Mono', monospace">0x6c77…9f9b</td><td style="padding: 13px 16px; color: #A9BEB1">[check at launch]</td><td style="padding: 13px 16px; color: #A9BEB1">[scorecard at launch]</td></tr>
|
||||
<tr style="border-top: 1px solid #2D5446"><td style="padding: 13px 16px">InstantAdPay, LinkSpin</td><td style="padding: 13px 16px; font-family: 'IBM Plex Mono', monospace">[addresses]</td><td style="padding: 13px 16px; color: #A9BEB1">[check at launch]</td><td style="padding: 13px 16px; color: #A9BEB1">[scorecard at launch]</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- earners corner -->
|
||||
<div id="ec" style="max-width: 1200px; margin: 0 auto; padding: 64px 24px; display: flex; flex-wrap: wrap; gap: 32px">
|
||||
<div style="flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 12px">
|
||||
<h2 style="margin: 0; font-family: Archivo, sans-serif; font-size: 38px; letter-spacing: -0.01em">Discussed on Earners Corner</h2>
|
||||
<p style="margin: 0; color: #3E5149">Every public check gets one thread on Earners Corner, updated when we rescan. Titles state facts, never labels. The project can answer in the same thread.</p>
|
||||
<span style="font-weight: 600; color: #5B7067">Open the Contract Checks topic [placeholder: opens at launch]</span>
|
||||
</div>
|
||||
<div style="flex: 999 1 560px; min-width: 0; background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; display: flex; flex-direction: column">
|
||||
<div style="padding: 16px 20px; border-bottom: 1px solid #E0E6E1; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap"><span style="font-weight: 600">3xSusu Vault (BNB Chain) contract check: code can be changed by one wallet</span><span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: #5B7067">High risk · updated Nov 16 [placeholder]</span></div>
|
||||
<div style="padding: 16px 20px; border-bottom: 1px solid #E0E6E1; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap"><span style="font-weight: 600">[Next public check]</span><span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: #5B7067">[grade · date]</span></div>
|
||||
<div style="padding: 16px 20px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap"><span style="font-weight: 600">[Next public check]</span><span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: #5B7067">[grade · date]</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="/assets/common.js?v=1"></script>
|
||||
<script src="/assets/render.js?v=1"></script>
|
||||
<script src="/assets/index.js?v=1"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,21 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>My checks | WebWorthIt</title>
|
||||
<meta name="description" content="Your WebWorthIt checks and referral link.">
|
||||
<meta name="theme-color" content="#0E2A22">
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Archivo:wght@500;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap">
|
||||
<link rel="stylesheet" href="/assets/wwi.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap" style="padding-top:40px;padding-bottom:40px;display:flex;flex-direction:column;gap:20px">
|
||||
<h1 style="font-size:40px">My checks</h1>
|
||||
<div id="out"><p>Loading...</p></div>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=1"></script>
|
||||
<script src="/assets/my.js?v=1"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,39 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Privacy Policy | WebWorthIt</title>
|
||||
<meta name="description" content="What WebWorthIt stores and why. Public information only; we never ask anyone to connect a wallet to run a check.">
|
||||
<meta name="theme-color" content="#0E2A22">
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Archivo:wght@500;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap">
|
||||
<link rel="stylesheet" href="/assets/wwi.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap legal-grid" style="padding-top:40px;padding-bottom:56px"><main class="legal"><p class="eyebrow">Updated November 16, 2026</p><h1>Privacy Policy</h1>
|
||||
<p>TrustClickz runs WebWorthIt. This page says what we keep and why, in plain words.</p>
|
||||
<h2>What we store</h2>
|
||||
<ul>
|
||||
<li><b>The checks you run.</b> The website and the contract address you entered, the chain, the time, and the result we produced.</li>
|
||||
<li><b>A hashed version of your IP address.</b> We use it only to count the 3 free checks a day. We store a one-way hash, never the raw address.</li>
|
||||
<li><b>Screenshots of public pages.</b> When you enter a website, our own browser opens that public page and saves a screenshot, so the report shows what the page said at that time.</li>
|
||||
<li><b>If you sign in with the network:</b> your network email, username and the wallet address on your network account, so your checks, vouchers and referral link follow you. When you buy, the sponsor line that would be paid is recorded with the sale.</li>
|
||||
<li><b>Vouchers and test codes</b> you redeem, with the time, so a code is used only as often as it allows.</li>
|
||||
<li><b>A browser cookie</b> that keeps your vouchers and settings on this browser, and a cookie that remembers who referred you (30 days).</li>
|
||||
</ul>
|
||||
<h2>What we never do</h2>
|
||||
<ul>
|
||||
<li>We never ask anyone to connect a wallet to run a check. A check is read-only.</li>
|
||||
<li>We never access private data about a project or a person. Every WebWorthIt check uses only public information that anyone could look up on their own: public blockchain records, verified or decompiled public contract code, and the project's public website. We do not access private data, we do not hack anything, we do not sign in to or interact with the project, and we do not move funds. A check is read-only.</li>
|
||||
<li>We do not sell personal data.</li>
|
||||
</ul>
|
||||
<h2>Sharing</h2>
|
||||
<p>Your WebWorthIt account is part of the network: your username, wallet and sponsor are shared with the network hub so one account works on every network site. Checks you run are private to you unless you share the link. Checks of our own network contracts are published on purpose.</p>
|
||||
<h2>Your choices</h2>
|
||||
<p>Ask network support to delete your data. The network hub removes it from every network site, except what the blockchain or the law keeps.</p>
|
||||
<p>Questions: <a href="https://instantadpay.com/support?from=webworthit">network support</a>. WebWorthIt is run by TrustClickz.</p></main><aside id="sideSlot" aria-label="Advertisement"></aside></div>
|
||||
<script src="/assets/common.js?v=1"></script>
|
||||
<script src="/assets/side.js?v=1"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,22 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Check | WebWorthIt</title>
|
||||
<meta name="description" content="A WebWorthIt check: public facts with sources, and our opinion from the published rubric.">
|
||||
<meta name="theme-color" content="#0E2A22">
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Archivo:wght@500;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap">
|
||||
<link rel="stylesheet" href="/assets/wwi.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap" style="padding-top:40px;padding-bottom:40px;display:flex;flex-direction:column;gap:24px">
|
||||
<div id="live" style="display:flex;flex-direction:column;gap:24px"><div class="steps">Loading the check...</div></div>
|
||||
<p style="margin:0"><a href="/#check">Run another check</a></p>
|
||||
</main>
|
||||
<script src="/assets/common.js?v=1"></script>
|
||||
<script src="/assets/render.js?v=1"></script>
|
||||
<script src="/assets/report.js?v=1"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,93 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>The rubric | WebWorthIt</title>
|
||||
<meta name="description" content="The published rubric WebWorthIt applies to public facts to form its opinion.">
|
||||
<meta name="theme-color" content="#0E2A22">
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Archivo:wght@500;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap">
|
||||
<link rel="stylesheet" href="/assets/wwi.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap legal-grid" style="padding-top:40px;padding-bottom:56px"><main class="legal"><p class="eyebrow">The published rubric</p><h1>How a check is scored</h1><p>Our findings are public facts, each one tagged and linked to its on-chain or website source. The scores, the grade (for example "High risk") and the verdict are our opinion, formed by applying our published rubric to those public facts.</p><p>Score each category 0 to 10 (10 = worst), then weight. A single "critical" red flag caps the overall</p>
|
||||
<p>grade at High risk whatever the total. Every score must cite evidence tagged VERIFIED (on chain, tx/block),</p>
|
||||
<p>INFERRED (bytecode/decompile/simulation) or UNKNOWN. Unknown counts against the project: if the team</p>
|
||||
<p>hid it, assume the worse case and say so.</p>
|
||||
<h2>1. Control and upgradeability (weight 25)</h2>
|
||||
<p>Raises risk:</p>
|
||||
<ul>
|
||||
<li>Upgradeable proxy (UUPS or Transparent) whose upgrade right sits with a single EOA (critical)</li>
|
||||
<li>Upgrades already used after launch, especially after money arrived (each one is a reset of everything audited)</li>
|
||||
<li>No timelock, no multisig, no on-chain delay or announcement event before upgrade</li>
|
||||
<li>Implementation source unverified (critical when combined with upgradeability)</li>
|
||||
<li>Owner can pause the functions members use to get money out (refund/claim/withdraw)</li>
|
||||
<li>Owner can change fee splits, recipients, limits or token addresses after launch</li>
|
||||
<li>Controller wallets are EIP-7702 delegated EOAs (code you also need to review)</li>
|
||||
<p>Lowers risk:</p>
|
||||
<li>Immutable contract, or ownership renounced (verify owner() = 0 and no other role can upgrade)</li>
|
||||
<li>Upgrade/admin held by a Safe with a meaningful threshold plus a timelock of at least 48 h</li>
|
||||
<li>Verified source matching the deployed bytecode</li>
|
||||
</ul>
|
||||
<h2>2. Custody and exit paths (weight 25)</h2>
|
||||
<p>List every path by which tokens can leave the contract and who can trigger each. Raises risk:</p>
|
||||
<ul>
|
||||
<li>Any owner/admin sweep, rescue, withdraw, setRecipient or arbitrary-call function (critical)</li>
|
||||
<li>Members' unlimited token approvals to an upgradeable spender (the code behind the spender can change)</li>
|
||||
<li>Refund/claim promises that the reserve cannot cover (compare liability vs balance)</li>
|
||||
<li>Member balances held as a non-transferable internal token that can only be "spent" back into the scheme</li>
|
||||
<p>Lowers risk:</p>
|
||||
<li>Members can withdraw their own principal at any time, unpausable, without a gate</li>
|
||||
<li>Exact accounting: outflows = sum of rule-based splits, no unexplained outflows (check with tokenflow)</li>
|
||||
</ul>
|
||||
<h2>3. Economic design (weight 20)</h2>
|
||||
<p>Raises risk:</p>
|
||||
<ul>
|
||||
<li>Returns funded only by later entrants (matrix/cycler/"3x"): payouts trigger only on new entries</li>
|
||||
<li>Advertised multiple (e.g. "3x") needs N later entries per position; compute N and the growth needed</li>
|
||||
<li>Fallback/refund funded by a small slice per entry (e.g. $1 per $35) while the liability grows per position</li>
|
||||
<li>"Company buy" / system buyback positions owned by an operator wallet that also collects payouts</li>
|
||||
<p>Lowers risk:</p>
|
||||
<li>An external revenue source exists and is visible on chain</li>
|
||||
<li>Reserve fully covers stated refund obligations at today's numbers</li>
|
||||
</ul>
|
||||
<h2>4. Insider flows (weight 15)</h2>
|
||||
<p>Raises risk:</p>
|
||||
<ul>
|
||||
<li>Share of outflows going to deployer-configured wallets (platform, admin, buyback, default referrer)</li>
|
||||
<li>Insider wallets funding each other or a shared sink, or cycling money back in as "entries"</li>
|
||||
<li>Insider wallets sending to exchanges/bridges/mixers soon after receipt (label only when confirmed)</li>
|
||||
<li>Operator-owned positions inflating the entry count or "activity"</li>
|
||||
<p>Lowers risk:</p>
|
||||
<li>Fixed, small, disclosed fees to a single published treasury</li>
|
||||
</ul>
|
||||
<h2>5. Disclosure vs code (weight 10)</h2>
|
||||
<p>Raises risk:</p>
|
||||
<ul>
|
||||
<li>Claims of "ownerless", "decentralized", "cannot be changed" while an owner can upgrade (critical)</li>
|
||||
<li>Guarantee-like language (refund 100% + 50%) that the code meets only partly or in a non-cash token</li>
|
||||
<li>No verified source, no audit, anonymous team</li>
|
||||
<p>Lowers risk:</p>
|
||||
<li>Docs match code paths, amounts and conditions</li>
|
||||
</ul>
|
||||
<h2>6. Trajectory (weight 5)</h2>
|
||||
<ul>
|
||||
<li>Daily/weekly inflow trend: growing, flat, slowing. In a recruitment-funded design, slowing inflow means</li>
|
||||
<p> later entrants' positions stall and refund liabilities mature.</p>
|
||||
<li>Age of the contract versus refund windows (when do the first obligations fall due?)</li>
|
||||
</ul>
|
||||
<h2>Red flags that each force "High risk"</h2>
|
||||
<ul>
|
||||
<li>Single-EOA upgrade or sweep right over member funds</li>
|
||||
<li>Unverified implementation behind an upgradeable proxy</li>
|
||||
<li>"Ownerless/decentralized" marketing while an owner key controls upgrades</li>
|
||||
<li>Payouts that exist only when new money enters</li>
|
||||
<li>Refund/guarantee liability larger than the reserve that backs it</li>
|
||||
</ul>
|
||||
<h2>Grade bands</h2>
|
||||
<p>0 to 25 Low, 26 to 50 Moderate, 51 to 75 Elevated, 76 to 100 High (or forced High by a red flag).</p></main><aside id="sideSlot" aria-label="Advertisement"></aside></div>
|
||||
<script src="/assets/common.js?v=1"></script>
|
||||
<script src="/assets/side.js?v=1"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,33 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Terms and Conditions | WebWorthIt</title>
|
||||
<meta name="description" content="Terms for using WebWorthIt, a read-only contract and website check run by TrustClickz.">
|
||||
<meta name="theme-color" content="#0E2A22">
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Archivo:wght@500;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap">
|
||||
<link rel="stylesheet" href="/assets/wwi.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap legal-grid" style="padding-top:40px;padding-bottom:56px"><main class="legal"><p class="eyebrow">Updated November 16, 2026</p><h1>Terms and Conditions</h1>
|
||||
<p>These terms cover your use of WebWorthIt, run by TrustClickz. By using the site you accept them.</p>
|
||||
<h2>What a check is</h2>
|
||||
<p>Every WebWorthIt check uses only public information that anyone could look up on their own: public blockchain records, verified or decompiled public contract code, and the project's public website. We do not access private data, we do not hack anything, we do not sign in to or interact with the project, and we do not move funds. A check is read-only.</p>
|
||||
<p>Our findings are public facts, each one tagged and linked to its on-chain or website source. The scores, the grade (for example "High risk") and the verdict are our opinion, formed by applying our published rubric to those public facts.</p>
|
||||
<p>A report is information about code and on-chain records. It is not financial advice and it is not a judgment of any person. A project can reply to its check in its public thread.</p>
|
||||
<h2>Accuracy</h2>
|
||||
<p>We check every address, transaction and number in a written report against the evidence our tools read. A report that does not pass that check is not shown; only the facts read straight from the chain are shown. Public nodes can fail or limit what they return, so every report says which block range was read and what could not be read. Blockchain records change all the time: a report describes the state at the block it names.</p>
|
||||
<h2>Free checks, deep reports and vouchers</h2>
|
||||
<ul><li>Every visitor gets 3 free checks a day.</li><li>Deep reports, report packs and watch alerts are one-time payments. No subscriptions.</li><li>Vouchers add reports or free checks as stated on the voucher, may expire, and have no cash value.</li><li>Sponsor rewards: when someone a member referred buys, the sponsor line is paid as published on the site (20% to the direct sponsor, 5% on levels 2 to 5). You are paid only when people choose to buy. Voucher redemptions pay nothing.</li></ul>
|
||||
<h2>Fair use</h2>
|
||||
<p>Do not use the site to attack, overload or scrape other services, and do not enter sites or addresses you have no reason to check. We may limit or refuse checks to keep the service working for everyone.</p>
|
||||
<h2>No warranty</h2>
|
||||
<p>WebWorthIt is provided as it is. To the extent the law allows, TrustClickz is not liable for decisions you make with or without a report. See the <a href="/disclaimer">Disclaimer</a>.</p>
|
||||
<h2>Contact</h2>
|
||||
<p><a href="https://instantadpay.com/support?from=webworthit">Network support</a>.</p></main><aside id="sideSlot" aria-label="Advertisement"></aside></div>
|
||||
<script src="/assets/common.js?v=1"></script>
|
||||
<script src="/assets/side.js?v=1"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,200 @@
|
||||
// Report writer + fact gate. One OpenRouter call per report (one retry when the fact check fails).
|
||||
// Free check: DeepSeek v4.1 Flash, short scorecard. Deep report: Opus 5.5, the full shape from the cost test (D:/tmp/wwi-cost/run.py).
|
||||
// HARD RULE (Marty): nothing invented. Every address, tx hash and number in the written report must be in the evidence (or plain
|
||||
// arithmetic of evidence numbers). A report that fails twice is not shown: the deterministic facts are shown instead, with a note.
|
||||
// Scores, grade and verdict are OPINION (our rubric applied to the public facts); findings are facts with tags and sources.
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const RUBRIC = fs.readFileSync(path.join(__dirname, 'chain', 'rubric.md'), 'utf8');
|
||||
const MODELS = { free: process.env.FREE_MODEL || 'deepseek/deepseek-v4.1-flash', deep: process.env.DEEP_MODEL || 'anthropic/claude-opus-5.5' };
|
||||
const CATS = [
|
||||
['control', 'Control and upgradeability', 25], ['custody', 'Custody and exit paths', 25], ['economics', 'Economic design', 20],
|
||||
['insiders', 'Insider flows', 15], ['disclosure', 'Disclosure vs code', 10], ['trajectory', 'Trajectory', 5]];
|
||||
const BANNED = [[/\bscam(s|med|mer|mers)?\b/gi, 'high-risk scheme'], [/\bponzi\b/gi, 'recruitment-funded'], [/\brug[ -]?pull(s|ed|ing)?\b/gi, 'drain of funds'],
|
||||
[/\bfraud(ulent|ster|sters|s)?\b/gi, 'misleading'], [/\bguaranteed\b/gi, 'promised'], [/\bget rich\b/gi, 'earn'], [/\bfree money\b/gi, 'unearned payouts'],
|
||||
[/\bpassive income\b/gi, 'payouts'], [/\b100% safe\b/gi, 'without risk'], [/\bdouble your\b/gi, 'grow your']];
|
||||
const ADVICE = /(\bget out\b|\bpull (your|all) (money|funds)\b|\bwithdraw (now|immediately|everything)\b|\bdo not (invest|join|deposit|buy)\b|\bdon'?t (invest|join|deposit|buy)\b|\bstay away\b|\bavoid (this|it|the project)\b|\byou should (not )?(invest|join|buy|deposit|sell|exit)\b|\brun\b(?= away))/i;
|
||||
|
||||
function clean(s) {
|
||||
if (typeof s !== 'string') return s;
|
||||
let t = s.replace(/\s*\u2014\s*/g, ', ').replace(/(\d)\s*\u2013\s*(\d)/g, '$1 to $2').replace(/\s*\u2013\s*/g, ', ').replace(/\u2012|\u2015/g, '-');
|
||||
for (const [re, rep] of BANNED) t = t.replace(re, rep);
|
||||
// strip advice sentences ("get out", "do not invest" ...): a report gives facts and our opinion of risk, never instructions
|
||||
t = t.split(/(?<=[.!?])\s+/).filter(x => !ADVICE.test(x)).join(' ');
|
||||
return t.replace(/,\s*,/g, ',').replace(/\s{2,}/g, ' ').trim();
|
||||
}
|
||||
function deepClean(o) {
|
||||
if (typeof o === 'string') return clean(o);
|
||||
if (Array.isArray(o)) return o.map(deepClean);
|
||||
if (o && typeof o === 'object') { const r = {}; for (const [k, v] of Object.entries(o)) r[k] = deepClean(v); return r; }
|
||||
return o;
|
||||
}
|
||||
const hasBanned = s => BANNED.some(([re]) => { re.lastIndex = 0; return re.test(s); }) || /[\u2014\u2013]/.test(s);
|
||||
|
||||
const SYSTEM = `You are a smart-contract risk analyst for WebWorthIt, writing for a non-technical crypto buyer.
|
||||
You get an evidence pack produced by read-only chain tools, and sometimes the text of the project's public website.
|
||||
Rules you must follow:
|
||||
- Use only the evidence. Never invent an address, a transaction, a number, a name or a date. If something is not in the evidence, say it is UNKNOWN.
|
||||
- Copy numbers exactly as the pack shows them. Use the "Precomputed counts" section for every count: never recount events or upgrades yourself. An Upgraded event inside the deployment transaction is not an upgrade.
|
||||
- If you compute a number (a sum, a difference, a share), show the arithmetic with the pack numbers, e.g. "3,632.30 of 32,690.00".
|
||||
- Tag every claim VERIFIED (read on chain: storage, eth_call, logs, transactions), INFERRED (from code names, decompiled or simulated behaviour, or the website text) or UNKNOWN.
|
||||
- Neutral, factual wording about code and records. You judge code and on-chain records, never people. No advice to act (never tell anyone to join, leave, buy, sell or withdraw).
|
||||
- Never use these words or phrases: scam, ponzi, rug pull, fraud, guaranteed, get rich, free money, passive income, 100% safe, double your. Never use em dashes or en dashes.
|
||||
- Wallet wording if needed: "SafePal or any other crypto wallet".
|
||||
- Scores follow the rubric: 0 = safest, 10 = worst. Anything hidden or unreadable counts against the project, and you say so.`;
|
||||
|
||||
const SCORE_SHAPE = `"scores": {"control": {"score": 0-10, "why": "...", "tag": "VERIFIED|INFERRED|UNKNOWN"}, "custody": {...}, "economics": {...}, "insiders": {...}, "disclosure": {...}, "trajectory": {...}},
|
||||
"critical_flags": ["only red flags from the rubric list that the evidence supports, each one short"]`;
|
||||
|
||||
function taskFree(pack, site) {
|
||||
return `RUBRIC:\n${RUBRIC}\n\nEVIDENCE PACK:\n${pack}\n\n${site ? 'PROJECT WEBSITE (public page text, read by our browser):\n' + site + '\n\n' : ''}Write the FREE CHECK scorecard as JSON with exactly these keys:
|
||||
- "verdict": one plain sentence about what the code and records show (no advice)
|
||||
- ${SCORE_SHAPE}
|
||||
- "top_findings": [{"tag": "VERIFIED|INFERRED|UNKNOWN", "text": "one or two plain sentences, with the evidence address or tx where it helps"}] (3 to 5 items, most important first)
|
||||
- "site_vs_code": one or two sentences comparing what the website says with what the code does, or "" when there is no website text
|
||||
Return only the JSON.`;
|
||||
}
|
||||
function taskDeep(pack, site) {
|
||||
return `RUBRIC:\n${RUBRIC}\n\nEVIDENCE PACK:\n${pack}\n\n${site ? 'PROJECT WEBSITE (public page text, read by our browser):\n' + site + '\n\n' : ''}Write the DEEP REPORT as JSON with these keys:
|
||||
- "verdict": one plain sentence (no advice)
|
||||
- ${SCORE_SHAPE}
|
||||
- "top_findings": [{"tag", "text"}] (4 to 6 items)
|
||||
- "drain_capability": can any wallet move the money or change the rules in one transaction? who, how, evidence (object: {"answer", "who", "how", "evidence", "tag"})
|
||||
- "exit_paths_ranked": [{"path", "who", "possible_now", "happened", "tag"}]
|
||||
- "money": {"summary", "balances_now", "total_in", "total_out", "where_out_went": [{"address", "amount", "note", "tag"}]}
|
||||
- "insiders": [{"address", "role", "received", "owns", "tag"}] (operator-controlled or deployment-set wallets the evidence names)
|
||||
- "refund_or_promise_math": if the website or code makes a refund or payout promise, can it be met? show the arithmetic from the pack, else say UNKNOWN
|
||||
- "approvals": what wallet approvals to this contract put holders at risk right now
|
||||
- "site_vs_code": what the website says vs what the code does
|
||||
- "unknowns": [what the evidence cannot answer]
|
||||
- "plain_summary": 150 to 250 words a member could read
|
||||
Return only the JSON.`;
|
||||
}
|
||||
|
||||
async function callModel(kind, messages, key) {
|
||||
const body = { model: MODELS[kind], messages, max_tokens: kind === 'deep' ? 16000 : 3000, usage: { include: true }, temperature: 0.1 };
|
||||
if (/deepseek/.test(MODELS[kind])) body.reasoning = { enabled: false };
|
||||
let last;
|
||||
for (let attempt = 0; attempt < 3; attempt++) {
|
||||
try {
|
||||
const r = await fetch('https://openrouter.ai/api/v1/chat/completions', { method: 'POST', signal: AbortSignal.timeout(600000),
|
||||
headers: { Authorization: 'Bearer ' + key, 'Content-Type': 'application/json', 'X-Title': 'WebWorthIt staging', 'HTTP-Referer': 'https://wwi.saasy.top' }, body: JSON.stringify(body) });
|
||||
const j = await r.json();
|
||||
if (r.status >= 500 || r.status === 429) { last = new Error('openrouter ' + r.status); await new Promise(z => setTimeout(z, 4000 * (attempt + 1))); continue; }
|
||||
if (!r.ok || !j.choices) throw new Error('openrouter ' + r.status + ': ' + JSON.stringify(j.error || j).slice(0, 200));
|
||||
const u = j.usage || {};
|
||||
return { text: j.choices[0].message.content || '', cost: Number(u.cost) || 0, tin: u.prompt_tokens || 0, tout: u.completion_tokens || 0, model: j.model || MODELS[kind], finish: j.choices[0].finish_reason };
|
||||
} catch (e) { last = e; if (/openrouter 4\d\d/.test(e.message)) throw e; await new Promise(z => setTimeout(z, 4000 * (attempt + 1))); }
|
||||
}
|
||||
throw last;
|
||||
}
|
||||
function parseJson(t) {
|
||||
t = String(t || '').trim().replace(/^```(?:json)?\s*/i, '').replace(/```\s*$/, '');
|
||||
const a = t.indexOf('{'), b = t.lastIndexOf('}'); if (a < 0 || b < a) throw new Error('no JSON object in the model reply');
|
||||
return JSON.parse(t.slice(a, b + 1));
|
||||
}
|
||||
|
||||
// ---- fact check (port of D:/tmp/wwi-cost/factcheck.py, stricter: blocks instead of listing) ----
|
||||
function numbersIn(s) {
|
||||
const out = []; const re = /(?<![0-9a-zA-Z_.])(\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+\.\d+|\d+)(?![0-9a-zA-Z_])/g; let m;
|
||||
while ((m = re.exec(s))) out.push({ raw: m[1], v: Number(m[1].replace(/,/g, '')), at: m.index });
|
||||
return out;
|
||||
}
|
||||
function allowedSet(src, keyNums) {
|
||||
const set = new Set();
|
||||
const add = v => { if (!isFinite(v)) return; for (const d of [0, 1, 2, 3, 4]) set.add(Number(v.toFixed(d))); };
|
||||
for (const n of numbersIn(src)) add(n.v);
|
||||
const k = [...new Set(keyNums.filter(x => isFinite(x) && x !== 0))].slice(0, 350);
|
||||
for (let i = 0; i < k.length; i++) for (let j = 0; j < k.length; j++) {
|
||||
const a = k[i], b = k[j];
|
||||
add(a + b); add(Math.abs(a - b)); if (b) { add(a / b); add(a / b * 100); } if (i <= j) add(a * b);
|
||||
}
|
||||
return set;
|
||||
}
|
||||
function stringsOf(o, skipKeys) {
|
||||
const out = [];
|
||||
const walk = (x, k) => { if (skipKeys.has(k)) return; if (typeof x === 'string') out.push(x); else if (Array.isArray(x)) x.forEach(y => walk(y, k)); else if (x && typeof x === 'object') for (const [kk, v] of Object.entries(x)) walk(v, kk); };
|
||||
walk(o, ''); return out;
|
||||
}
|
||||
function factcheck(report, evidenceText, keyNums) {
|
||||
const src = evidenceText.toLowerCase() + '\n' + RUBRIC.toLowerCase();
|
||||
const allowed = allowedSet(src, keyNums);
|
||||
const texts = stringsOf(report, new Set(['tag'])); const all = texts.join('\n');
|
||||
const low = all.toLowerCase();
|
||||
const bad = [];
|
||||
for (const a of new Set(low.match(/0x[0-9a-f]{64}(?![0-9a-f])/g) || [])) if (!src.includes(a)) bad.push({ kind: 'tx', item: a });
|
||||
for (const a of new Set((low.replace(/0x[0-9a-f]{64}/g, '').match(/0x[0-9a-f]{40}(?![0-9a-f])/g) || []))) if (!src.includes(a)) bad.push({ kind: 'address', item: a });
|
||||
for (const s of new Set(low.match(/0x[0-9a-f]{3,10}(?:\u2026|\.\.\.?)[0-9a-f]{3,10}/g) || [])) {
|
||||
const [a, b] = s.split(/\u2026|\.\.\.?/);
|
||||
if (!new RegExp(a + '[0-9a-f]*' + b + '(?![0-9a-f])').test(src)) bad.push({ kind: 'short address', item: s });
|
||||
}
|
||||
const stripped = all.replace(/0x[0-9a-fA-F]+/g, ' ').replace(/\b\d{4}-\d{2}-\d{2}\b/g, ' ').replace(/\b\d{1,2}:\d{2}\b/g, ' ');
|
||||
for (const n of numbersIn(stripped)) {
|
||||
const v = n.v;
|
||||
if (!n.raw.includes('.') && !n.raw.includes(',') && v < 10) continue; // small counts and scores
|
||||
if (!n.raw.includes('.') && !n.raw.includes(',') && v >= 1990 && v <= 2035) continue; // years
|
||||
if (allowed.has(v) || allowed.has(Number(v.toFixed(2)))) continue;
|
||||
// a rounded form of an allowed value (3,632 for 3,632.30, 29.06k style excluded)
|
||||
let near = false;
|
||||
if (v >= 100) for (const a of [v - 1, v, v + 1]) if (allowed.has(Math.round(a))) { near = true; break; }
|
||||
if (!near && n.raw.includes('.')) { const d = n.raw.split('.')[1].length; for (const x of [v - Math.pow(10, -d), v + Math.pow(10, -d)]) if (allowed.has(Number(x.toFixed(d)))) near = true; }
|
||||
if (near) continue;
|
||||
const i = stripped.indexOf(n.raw); bad.push({ kind: 'number', item: n.raw, context: stripped.slice(Math.max(0, i - 60), i + 40).replace(/\s+/g, ' ') });
|
||||
}
|
||||
const banned = texts.filter(hasBanned).length;
|
||||
return { ok: bad.length === 0 && banned === 0, problems: bad.slice(0, 40), problem_count: bad.length, banned_strings: banned, checked_strings: texts.length };
|
||||
}
|
||||
|
||||
// ---- opinion: overall from the six category scores (weights from the rubric) + forced High on any critical flag ----
|
||||
function grade(report, E) {
|
||||
let total = 0, have = 0;
|
||||
for (const [k, , w] of CATS) { const s = report.scores && report.scores[k]; const v = s && Number(s.score); if (isFinite(v)) { total += Math.max(0, Math.min(10, v)) * w / 10; have += w; } }
|
||||
const overall = have ? Math.round(total * 100 / have) : null;
|
||||
const flags = [];
|
||||
const ctl = (E && E.controllers) || {};
|
||||
const eoaUp = (E && E.can_upgrade || []).filter(a => /^EOA/.test((ctl[a] || {}).type || ''));
|
||||
if (eoaUp.length) flags.push({ text: 'One personal wallet can replace the code in a single transaction (' + eoaUp.join(', ') + ').', tag: 'VERIFIED', source: 'rubric red flag 1' });
|
||||
const v = (E && E.verification) || {};
|
||||
if (E && E.proxy && E.proxy.upgradeable && !(v.implementation && v.implementation.match)) flags.push({ text: 'The implementation behind the upgradeable proxy has no verified source on Sourcify.', tag: 'VERIFIED', source: 'rubric red flag 2' });
|
||||
for (const f of report.critical_flags || []) if (typeof f === 'string' && f.trim()) flags.push({ text: f.trim(), tag: 'INFERRED', source: 'model, from the rubric list' });
|
||||
let band = overall == null ? null : overall <= 25 ? 'Low risk' : overall <= 50 ? 'Moderate risk' : overall <= 75 ? 'Elevated risk' : 'High risk';
|
||||
const forced = flags.length > 0 && band !== 'High risk';
|
||||
if (flags.length) band = 'High risk';
|
||||
return { overall, grade: band, forced_by_flag: forced, flags };
|
||||
}
|
||||
const TAGS = new Set(['VERIFIED', 'INFERRED', 'UNKNOWN']);
|
||||
function normalize(report) {
|
||||
const fixTag = o => { if (o && typeof o === 'object') { if ('tag' in o) { const t = String(o.tag || '').toUpperCase().split(/[^A-Z]/)[0]; o.tag = TAGS.has(t) ? t : 'UNKNOWN'; } for (const v of Object.values(o)) if (v && typeof v === 'object') fixTag(v); } };
|
||||
fixTag(report);
|
||||
if (!Array.isArray(report.top_findings)) report.top_findings = [];
|
||||
return report;
|
||||
}
|
||||
|
||||
async function write({ kind, pack, siteText, facts, evidence, key }) {
|
||||
const keyNums = [];
|
||||
const walk = x => { if (typeof x === 'number') keyNums.push(x); else if (Array.isArray(x)) x.forEach(walk); else if (x && typeof x === 'object') Object.values(x).forEach(walk); };
|
||||
walk({ money: evidence.money, approvals: evidence.approvals, positions: evidence.positions, counts: evidence.counts, txs: evidence.txs, values: evidence.values, age: evidence.age_days, wallets: evidence.wallets, native: evidence.native_balance });
|
||||
const site = siteText ? siteText.slice(0, kind === 'deep' ? 12000 : 6000) : '';
|
||||
const evidenceText = pack + '\n' + site + '\n' + JSON.stringify(facts);
|
||||
const messages = [{ role: 'system', content: SYSTEM }, { role: 'user', content: (kind === 'deep' ? taskDeep : taskFree)(pack, site) }];
|
||||
const runs = []; let cost = 0, tin = 0, tout = 0, model = MODELS[kind];
|
||||
for (let attempt = 0; attempt < 2; attempt++) {
|
||||
let rep, fc, raw;
|
||||
try {
|
||||
const r = await callModel(kind, messages, key); cost += r.cost; tin += r.tin; tout += r.tout; model = r.model; raw = r.text;
|
||||
rep = normalize(deepClean(parseJson(r.text)));
|
||||
fc = factcheck(rep, evidenceText, keyNums);
|
||||
} catch (e) { fc = { ok: false, error: String(e.message).slice(0, 300), problems: [] }; }
|
||||
runs.push({ attempt: attempt + 1, ok: fc.ok, problems: fc.problems, error: fc.error, banned: fc.banned_strings });
|
||||
if (fc.ok) return { ok: true, report: rep, grade: grade(rep, evidence), factcheck: { passed: true, runs }, cost, tin, tout, model };
|
||||
if (attempt === 0 && raw) {
|
||||
messages.push({ role: 'assistant', content: raw });
|
||||
messages.push({ role: 'user', content: 'Our fact check could not find these items in the evidence: ' + JSON.stringify((fc.problems || []).slice(0, 25)) +
|
||||
(fc.banned_strings ? ' Some text also used a banned word or a dash.' : '') + ' Rewrite the whole JSON. Use only addresses, transaction hashes and numbers that appear in the evidence pack, or show the arithmetic from pack numbers. Return only the JSON.' });
|
||||
}
|
||||
}
|
||||
return { ok: false, report: null, grade: null, factcheck: { passed: false, runs, note: 'The written report did not pass our fact check twice, so it is not shown. Only facts read directly from the chain are shown below.' }, cost, tin, tout, model };
|
||||
}
|
||||
module.exports = { write, factcheck, clean, deepClean, grade, CATS, MODELS, hasBanned };
|
||||
@@ -0,0 +1,324 @@
|
||||
// WebWorthIt: a read-only contract + website risk check (staging at wwi.saasy.top, Marty 2026-11-16).
|
||||
// POST /api/check queues a job (jobs.js) and returns an id; GET /api/check/:id shows the steps and the result.
|
||||
// Free check = short scorecard (DeepSeek v4.1 Flash). Deep report = full report (Opus 5.5), unlocked in staging by the test code
|
||||
// (WWI_TEST_CODE) or a voucher. NO real payments in staging: the pricing buttons say "Payments arrive at launch".
|
||||
// Findings are public facts (tagged, with sources); scores, grade and verdict are our opinion from the published rubric.
|
||||
// Network: hub sign-in (networksso.js, HUB_SSO=on), sponsor line from the hub (hubline.js), hub events (hubevents.js),
|
||||
// network footer (netsites.js), site assistant (chatbot.js + chatcore/kb/netkb, NETKB=0 in staging).
|
||||
'use strict';
|
||||
const http = require('http');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
const DATA_DIR = process.env.DATA_DIR || path.join(__dirname, 'data');
|
||||
fs.mkdirSync(DATA_DIR, { recursive: true });
|
||||
const docstore = require('./docstore'); docstore.install(DATA_DIR);
|
||||
const db = require('./db');
|
||||
const jobs = require('./jobs');
|
||||
const website = require('./website');
|
||||
const sponsor = require('./sponsor');
|
||||
const networksso = require('./networksso');
|
||||
const hubpeople = require('./hubpeople');
|
||||
const hubevents = require('./hubevents');
|
||||
const netsites = require('./netsites');
|
||||
const chatbot = require('./chatbot');
|
||||
|
||||
const PORT = Number(process.env.PORT || 3000);
|
||||
const STAGING = process.env.STAGING === '1';
|
||||
const SITE_HOST = process.env.SITE_HOST || 'webworthit.com';
|
||||
const IS_PROD = process.env.NODE_ENV === 'production';
|
||||
const PUB = path.join(__dirname, 'public');
|
||||
const FREE_PER_DAY = 3;
|
||||
const SECRET = (() => {
|
||||
if (process.env.SESSION_SECRET) return process.env.SESSION_SECRET;
|
||||
const f = path.join(DATA_DIR, '.secret'); try { return fs.readFileSync(f, 'utf8').trim(); } catch (e) {}
|
||||
const s = crypto.randomBytes(32).toString('hex'); try { fs.writeFileSync(f, s, { mode: 0o600 }); } catch (e) {} return s;
|
||||
})();
|
||||
const hmac = s => crypto.createHmac('sha256', SECRET).update(s).digest('hex');
|
||||
const ADDR_RE = /^0x[0-9a-fA-F]{40}$/;
|
||||
const NAME_RE = /^[A-Za-z0-9_.-]{1,40}$/;
|
||||
const ID_RE = /^[A-Za-z0-9]{12}$/;
|
||||
// ad zones: LinkSpin zone ids by placement (WWI_ZONES JSON, e.g. {"hero":"ls-xxxx","result":"ls-..","how":"ls-..","foot":"ls-..","side":"ls-.."}). Empty = no ad shown.
|
||||
const ZONES = (() => { try { const z = JSON.parse(process.env.WWI_ZONES || '{}'); return Object.fromEntries(Object.entries(z).filter(([k, v]) => /^[a-z]{2,12}$/.test(k) && /^ls-[a-z0-9]{4,12}$/.test(v))); } catch (e) { return {}; } })();
|
||||
|
||||
const MIME = { '.html': 'text/html; charset=utf-8', '.css': 'text/css', '.js': 'text/javascript', '.png': 'image/png', '.jpg': 'image/jpeg', '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.json': 'application/json', '.txt': 'text/plain; charset=utf-8', '.xml': 'application/xml' };
|
||||
const CSP = "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: https:; connect-src 'self'; font-src 'self' https://fonts.gstatic.com; frame-src 'self'; form-action 'self'; base-uri 'self'; frame-ancestors 'self'";
|
||||
// the ad frame page (/f/n.html) is the only place a third-party tag runs, inside its own iframe
|
||||
const CSP_FRAME = "default-src 'none'; script-src 'self' https://linkspin.app; img-src https: data:; style-src 'unsafe-inline'; connect-src https://linkspin.app; frame-src https:; base-uri 'none'; frame-ancestors 'self'";
|
||||
const headers = (extra, csp) => Object.assign({ 'Content-Security-Policy': csp || CSP, 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'X-Frame-Options': 'SAMEORIGIN' }, STAGING ? { 'X-Robots-Tag': 'noindex, nofollow' } : {}, extra || {});
|
||||
function json(res, code, obj, extra) { res.writeHead(code, headers(Object.assign({ 'Content-Type': 'application/json', 'Cache-Control': 'no-store' }, extra))); res.end(JSON.stringify(obj)); }
|
||||
function sendFile(res, file, extra, csp) {
|
||||
fs.readFile(file, (err, data) => {
|
||||
if (err) { res.writeHead(404, headers({ 'Content-Type': 'text/plain' })); return res.end('Not found'); }
|
||||
const ext = path.extname(file).toLowerCase();
|
||||
res.writeHead(200, headers(Object.assign({ 'Content-Type': MIME[ext] || 'application/octet-stream', 'Cache-Control': ext === '.html' ? 'no-store' : 'public, max-age=600' }, extra), csp));
|
||||
res.end(data);
|
||||
});
|
||||
}
|
||||
function readBody(req) {
|
||||
return new Promise(resolve => { const ch = []; let n = 0;
|
||||
req.on('data', c => { n += c.length; if (n > 64 * 1024) { req.destroy(); return; } ch.push(c); });
|
||||
req.on('end', () => { try { const b = Buffer.concat(ch).toString('utf8'); resolve(b ? JSON.parse(b) : {}); } catch (e) { resolve({}); } }); req.on('error', () => resolve({})); });
|
||||
}
|
||||
function readRaw(req) { return new Promise(resolve => { const ch = []; let n = 0; req.on('data', c => { n += c.length; if (n < 512 * 1024) ch.push(c); }); req.on('end', () => resolve(Buffer.concat(ch))); req.on('error', () => resolve(Buffer.alloc(0))); }); }
|
||||
function cookies(req) { const o = {}; for (const p of (req.headers.cookie || '').split(';')) { const i = p.indexOf('='); if (i > 0) { try { o[p.slice(0, i).trim()] = decodeURIComponent(p.slice(i + 1).trim()); } catch (e) {} } } return o; }
|
||||
const cookie = (name, val, age, httpOnly) => name + '=' + encodeURIComponent(val) + '; Path=/; SameSite=Lax; Max-Age=' + age + (httpOnly ? '; HttpOnly' : '') + (IS_PROD ? '; Secure' : '');
|
||||
function ip(req) { const x = String(req.headers['x-forwarded-for'] || '').split(',').map(s => s.trim()).filter(Boolean); return (x.length ? x[x.length - 1] : String(req.socket.remoteAddress || '')).replace(/^::ffff:/, ''); }
|
||||
const ipHash = req => hmac('ip|' + ip(req)).slice(0, 24);
|
||||
const buckets = new Map();
|
||||
function limited(req, name, max, ms) { const k = name + ':' + ip(req); const now = Date.now(); let b = buckets.get(k); if (!b || now - b.t > ms) { b = { t: now, n: 0 }; buckets.set(k, b); } if (buckets.size > 50000) buckets.clear(); return ++b.n > max; }
|
||||
const isAdmin = req => { const t = String(process.env.ADMIN_TOKEN || ''); const g = String(req.headers['x-admin-token'] || ''); return t.length >= 16 && g.length === t.length && crypto.timingSafeEqual(Buffer.from(g), Buffer.from(t)); };
|
||||
const today = () => new Date().toLocaleDateString('en-CA', { timeZone: 'America/Chicago' });
|
||||
const signed = v => v + '.' + hmac('c|' + v).slice(0, 32);
|
||||
const unsign = s => { const i = String(s || '').lastIndexOf('.'); if (i < 0) return null; const v = s.slice(0, i); return signed(v) === s ? v : null; };
|
||||
|
||||
// ---- who is asking: a network member (session) or a browser (holder token) ----
|
||||
async function member(req) {
|
||||
const sid = cookies(req)['wwi.sid']; if (!sid || !/^[a-f0-9]{48}$/.test(sid)) return null;
|
||||
const s = await db.one('SELECT s.email, s.created, m.username, m.wallet, m.hub_id, m.sponsor FROM sessions s LEFT JOIN members m ON m.email = s.email WHERE s.id = ? AND s.expires > ?', [sid, Date.now()]);
|
||||
return s || null;
|
||||
}
|
||||
function holderOf(req, m) { if (m) return 'm:' + m.email; const t = unsign(cookies(req)['wwi.t']); return t ? 't:' + t : null; }
|
||||
const unlocked = req => unsign(cookies(req)['wwi.unlock']) === 'test';
|
||||
async function freeLeft(req) { const r = await db.one('SELECT n FROM daily_free WHERE day = ? AND ip_hash = ?', [today(), ipHash(req)]); return Math.max(0, FREE_PER_DAY - (r ? r.n : 0)); }
|
||||
async function creditsOf(holder) { if (!holder) return { deep: 0, free_extra: 0 }; return (await db.one('SELECT deep, free_extra FROM credits WHERE holder = ?', [holder])) || { deep: 0, free_extra: 0 }; }
|
||||
|
||||
// ---- network sign-in (hub provider; pairwise fallback is off unless NETWORK_SSO_SECRET is set AND the peer lists this site) ----
|
||||
networksso.init({ self: 'webworthit', hubSite: 'webworthit', peer: 'iap', peerBase: () => String(process.env.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, ''),
|
||||
from: { iap: () => String(process.env.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, ''), linkspin: () => String(process.env.LS_URL || 'https://linkspin.app').replace(/\/+$/, '') },
|
||||
isProd: IS_PROD, dataDir: DATA_DIR, defaultPath: '/my', db: { enabled: () => true, q: (s, a) => db.q(s, a) },
|
||||
member: async req => { const m = await member(req); return m ? { email: m.email } : null; },
|
||||
accept: async email => (email ? { ok: true } : { fallback: 'no email in the token' }),
|
||||
signIn: async (email, req, v) => {
|
||||
email = String(email || '').trim().toLowerCase(); if (!email) return null;
|
||||
let p = null; const r = await hubpeople.resolve({ email }).catch(() => ({ ok: false })); if (r.ok && r.person && !r.person.blocked) p = r.person;
|
||||
if (r.ok && r.person && r.person.blocked) return null;
|
||||
const username = p && p.username ? String(p.username) : (v && v.name && NAME_RE.test(v.name) ? v.name : null);
|
||||
const wallet = (p && hubpeople.wallet(p)) || (v && v.wallet && ADDR_RE.test(v.wallet) ? v.wallet.toLowerCase() : null);
|
||||
await db.q('INSERT INTO members (email, hub_id, username, wallet, sponsor, created, last_seen) VALUES (?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE hub_id = COALESCE(VALUES(hub_id), hub_id), username = COALESCE(VALUES(username), username), wallet = COALESCE(VALUES(wallet), wallet), sponsor = COALESCE(VALUES(sponsor), sponsor), last_seen = VALUES(last_seen)',
|
||||
[email, p ? p.id || null : null, username, wallet, p && p.sponsor ? p.sponsor.username || null : null, Date.now(), Date.now()]);
|
||||
const sid = crypto.randomBytes(24).toString('hex');
|
||||
await db.q('INSERT INTO sessions (id, email, created, expires) VALUES (?,?,?,?)', [sid, email, Date.now(), Date.now() + 30 * 86400000]);
|
||||
return cookie('wwi.sid', sid, 30 * 86400, true);
|
||||
},
|
||||
landing: to => to, signinPath: to => '/my?signin=1&to=' + encodeURIComponent(to || '/my') });
|
||||
hubevents.init({ dataDir: DATA_DIR, site: 'webworthit', end: async who => {
|
||||
const rows = await db.q('SELECT s.id, s.email, s.created, m.hub_id, m.wallet FROM sessions s LEFT JOIN members m ON m.email = s.email');
|
||||
const ids = rows.filter(s => s.created < who.before && who.match({ email: s.email, hubId: s.hub_id, wallet: s.wallet, address: s.wallet })).map(s => s.id);
|
||||
if (ids.length) await db.q('DELETE FROM sessions WHERE id IN (?)', [ids]);
|
||||
return ids.length;
|
||||
} });
|
||||
|
||||
// ---- views ----
|
||||
const SHORT = a => a ? a.slice(0, 6) + '...' + a.slice(-4) : '';
|
||||
function publicView(c, opts) {
|
||||
const steps = c.steps_json ? JSON.parse(c.steps_json) : {};
|
||||
const rep = c.report_json ? JSON.parse(c.report_json) : null;
|
||||
const E = c.evidence_json ? JSON.parse(c.evidence_json) : null;
|
||||
const site = c.site_json ? JSON.parse(c.site_json) : null;
|
||||
const v = { id: c.id, kind: c.kind, status: c.status, created: c.created, website: c.website, chain: c.chain, chainName: (jobs.CHAINS[c.chain] || {}).name, address: c.address,
|
||||
pickedNote: c.picked_note, steps: jobs.STEPS.map(k => Object.assign({ key: k, name: jobs.STEP_NAMES[k] }, steps[k] || { state: 'waiting' })), queuePos: jobs.qpos(c.id),
|
||||
error: c.status === 'failed' ? c.error : null, label: c.public_label, isPublic: !!c.is_public };
|
||||
if (c.status !== 'done') return v;
|
||||
v.timings = c.timings_json ? JSON.parse(c.timings_json) : null;
|
||||
v.cost = Number(c.cost_usd) || 0; v.model = c.model;
|
||||
v.facts = c.facts_json ? JSON.parse(c.facts_json) : [];
|
||||
v.factcheck = c.factcheck_json ? JSON.parse(c.factcheck_json) : null;
|
||||
v.site = site; v.hasShot = !!(site && site.ok);
|
||||
if (E) v.chainRead = { block: E.read_at && E.read_at.block, time: E.read_at && E.read_at.time_ct, window: E.window, explorer: E.explorer, gaps: E.gaps, notes: E.notes, isContract: E.is_contract, kind: E.kind, name: Object.values(E.verification || {}).map(x => x.name).filter(Boolean)[0] || null };
|
||||
if (rep) {
|
||||
v.grade = rep.grade;
|
||||
const r = rep.report;
|
||||
if (c.kind === 'free' || !opts.full) v.report = { verdict: r.verdict, scores: r.scores, top_findings: r.top_findings, site_vs_code: r.site_vs_code };
|
||||
else v.report = r;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
async function startCheck(req, res, b, m) {
|
||||
const kind = b.kind === 'deep' ? 'deep' : 'free';
|
||||
let site = b.website ? website.normalizeUrl(b.website) : null;
|
||||
if (b.website && !site) return json(res, 400, { error: 'That website address does not look right. Use the full address, like https://example.com' });
|
||||
const address = String(b.address || '').trim();
|
||||
if (address && !ADDR_RE.test(address)) return json(res, 400, { error: 'A contract address is 0x followed by 40 letters and numbers.' });
|
||||
const chain = jobs.CHAINS[b.chain] ? b.chain : 'bsc';
|
||||
if (!site && !address) return json(res, 400, { error: 'Fill in a website, a contract address, or both.' });
|
||||
if (site && !(await website.hostOk(new URL(site).hostname))) return json(res, 400, { error: 'That website is not a public internet address.' });
|
||||
if (limited(req, 'check', 12, 60 * 60000)) return json(res, 429, { error: 'Too many checks from this connection in the last hour. Try again later.' });
|
||||
const holder = holderOf(req, m); const ih = ipHash(req);
|
||||
let via = null;
|
||||
if (kind === 'free') {
|
||||
if (!unlocked(req)) {
|
||||
const left = await freeLeft(req);
|
||||
if (left <= 0) {
|
||||
const cr = await creditsOf(holder);
|
||||
if (!(cr.free_extra > 0)) return json(res, 429, { error: 'You have used your 3 free checks for today. They come back tomorrow (Central time).', freeLeft: 0 });
|
||||
await db.q('UPDATE credits SET free_extra = free_extra - 1, updated = ? WHERE holder = ? AND free_extra > 0', [Date.now(), holder]); via = 'voucher credit';
|
||||
} else {
|
||||
await db.q('INSERT INTO daily_free (day, ip_hash, n) VALUES (?,?,1) ON DUPLICATE KEY UPDATE n = n + 1', [today(), ih]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const cr = await creditsOf(holder);
|
||||
if (cr.deep > 0) {
|
||||
const r = await db.q('UPDATE credits SET deep = deep - 1, updated = ? WHERE holder = ? AND deep > 0', [Date.now(), holder]); if (!r.affectedRows) return json(res, 409, { error: 'No deep report credit left.' }); via = 'credit';
|
||||
} else if (unlocked(req)) via = 'test_code';
|
||||
else return json(res, 402, { error: STAGING ? 'Deep reports need the staging test code or a voucher. Payments arrive at launch.' : 'Deep reports need a payment or a voucher.' });
|
||||
}
|
||||
const id = jobs.newId();
|
||||
await db.q('INSERT INTO checks (id, created, ip_hash, holder, member, kind, website, chain, address, status, steps_json, parent_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)',
|
||||
[id, Date.now(), ih, holder, m ? m.email : null, kind, site, chain, address ? address.toLowerCase() : null, 'queued', '{}', ID_RE.test(b.from || '') ? b.from : null]);
|
||||
if (kind === 'deep' && via === 'test_code') {
|
||||
const ref = unsign(cookies(req)['wwi.ref']);
|
||||
await sponsor.record({ buyer: m ? { email: m.email, username: m.username, wallet: m.wallet } : null, ref, item: 'deep1', via: 'test_code', checkId: id, note: 'staging test-code deep report' }).catch(e => console.error('sponsor record', e.message));
|
||||
if (b.watch) await sponsor.record({ buyer: m ? { email: m.email, username: m.username, wallet: m.wallet } : null, ref, item: 'watch', via: 'test_code', checkId: id, note: 'staging test-code watch add-on (alerts arrive at launch)' }).catch(() => {});
|
||||
}
|
||||
jobs.enqueue(id);
|
||||
return json(res, 200, { id, kind, via });
|
||||
}
|
||||
|
||||
const PAGES = { '/': 'index.html', '/my': 'my.html', '/admin': 'admin.html', '/privacy': 'privacy.html', '/terms': 'terms.html', '/disclaimer': 'disclaimer.html', '/rubric': 'rubric.html' };
|
||||
|
||||
const server = http.createServer(async (req, res) => {
|
||||
let u; try { u = new URL(req.url, 'http://x'); } catch (e) { res.writeHead(400); return res.end(); }
|
||||
const p = u.pathname;
|
||||
try {
|
||||
if (p === '/health') return json(res, 200, { ok: true, store: docstore.isOn() ? 'mysql' : 'files', jobs: { running: jobs.running(), queued: jobs.queued() } });
|
||||
if (req.method === 'GET' && await networksso.page(req, res, u)) return;
|
||||
if (req.method === 'GET' && (p.startsWith('/sso/') || p.startsWith('/go/') || p === '/api/sso/status') && await networksso.handle(req, res, u)) return;
|
||||
if ((p.startsWith('/api/chat') || p.startsWith('/api/admin/kb')) && await chatbot.handle(req, res, p, u, { json, readBody, isAdmin })) return;
|
||||
if (p === '/api/hub/events' && req.method === 'POST') { const raw = await readRaw(req); const r = await hubevents.receive(req.headers, raw); return json(res, r.status, r.body); }
|
||||
if (p === '/api/network-sites' && req.method === 'GET') return netsites.handle(req, res);
|
||||
|
||||
// pages
|
||||
if (req.method === 'GET' && (PAGES[p] || /^\/c\/[A-Za-z0-9]{12}$/.test(p))) {
|
||||
const set = [];
|
||||
const ck = cookies(req);
|
||||
if (!unsign(ck['wwi.t'])) set.push(cookie('wwi.t', signed(crypto.randomBytes(12).toString('hex')), 365 * 86400, true));
|
||||
const ref = u.searchParams.get('ref');
|
||||
if (ref && NAME_RE.test(ref)) set.push(cookie('wwi.ref', signed(ref.toLowerCase()), 30 * 86400, true));
|
||||
return sendFile(res, path.join(PUB, PAGES[p] || 'report.html'), set.length ? { 'Set-Cookie': set } : null);
|
||||
}
|
||||
if (req.method === 'GET' && (p === '/f/n.html' || p === '/f/n.js')) return sendFile(res, path.join(PUB, 'f', p.slice(3)), { 'Cache-Control': 'public, max-age=600' }, CSP_FRAME);
|
||||
if (req.method === 'GET' && (p.startsWith('/assets/') || p.startsWith('/art/') || p === '/robots.txt' || p === '/favicon.ico')) {
|
||||
const f = path.normalize(path.join(PUB, p === '/favicon.ico' ? 'art/mark.svg' : p)); if (!f.startsWith(PUB)) { res.writeHead(403); return res.end(); }
|
||||
return sendFile(res, f);
|
||||
}
|
||||
|
||||
// api
|
||||
if (p === '/api/config' && req.method === 'GET') {
|
||||
const m = await member(req); const holder = holderOf(req, m); const cr = await creditsOf(holder);
|
||||
return json(res, 200, { staging: STAGING, freeLeft: unlocked(req) ? null : await freeLeft(req), freePerDay: FREE_PER_DAY, unlocked: unlocked(req), credits: cr,
|
||||
member: m ? { username: m.username, wallet: m.wallet ? SHORT(m.wallet) : null, sponsor: m.sponsor, refLink: m.username ? 'https://' + SITE_HOST + '/?ref=' + encodeURIComponent(m.username) : null } : null,
|
||||
sso: networksso.hubOn(), zones: ZONES, prices: sponsor.ITEMS, sponsorPct: { levels: sponsor.LEVEL_PCT, company: sponsor.COMPANY_PCT } });
|
||||
}
|
||||
if (p === '/api/check' && req.method === 'POST') { const b = await readBody(req); return startCheck(req, res, b, await member(req)); }
|
||||
let mm;
|
||||
if ((mm = /^\/api\/check\/([A-Za-z0-9]{12})$/.exec(p)) && req.method === 'GET') {
|
||||
const c = await db.one('SELECT * FROM checks WHERE id = ?', [mm[1]]); if (!c) return json(res, 404, { error: 'No check with that id.' });
|
||||
return json(res, 200, publicView(c, { full: true }));
|
||||
}
|
||||
if ((mm = /^\/api\/check\/([A-Za-z0-9]{12})\/shot\.jpg$/.exec(p)) && req.method === 'GET') {
|
||||
const s = await db.one('SELECT mime, bytes FROM screenshots WHERE check_id = ?', [mm[1]]); if (!s) { res.writeHead(404, headers()); return res.end(); }
|
||||
res.writeHead(200, headers({ 'Content-Type': s.mime, 'Cache-Control': 'public, max-age=86400' })); return res.end(s.bytes);
|
||||
}
|
||||
if ((mm = /^\/api\/check\/([A-Za-z0-9]{12})\/evidence$/.exec(p)) && req.method === 'GET') {
|
||||
const c = await db.one('SELECT pack_md FROM checks WHERE id = ?', [mm[1]]); if (!c || !c.pack_md) return json(res, 404, { error: 'No evidence pack for this check.' });
|
||||
res.writeHead(200, headers({ 'Content-Type': 'text/plain; charset=utf-8', 'Cache-Control': 'no-store' })); return res.end(c.pack_md);
|
||||
}
|
||||
if (p === '/api/network-checks' && req.method === 'GET') {
|
||||
const rows = await db.q("SELECT id, kind, chain, address, public_label, report_json, finished FROM checks WHERE is_public = 1 AND status = 'done' ORDER BY finished DESC LIMIT 60");
|
||||
return json(res, 200, { checks: rows.map(r => { const g = r.report_json ? JSON.parse(r.report_json).grade : null; return { id: r.id, kind: r.kind, chain: r.chain, address: r.address, label: r.public_label, grade: g ? g.grade : null, overall: g ? g.overall : null, finished: r.finished }; }) });
|
||||
}
|
||||
if (p === '/api/unlock' && req.method === 'POST') {
|
||||
if (limited(req, 'unlock', 8, 15 * 60000)) return json(res, 429, { error: 'Too many tries. Wait 15 minutes.' });
|
||||
const b = await readBody(req); const code = String(b.code || '').trim(); const want = String(process.env.WWI_TEST_CODE || '');
|
||||
if (!want || code.length !== want.length || !crypto.timingSafeEqual(Buffer.from(code), Buffer.from(want))) return json(res, 403, { error: 'That code is not right.' });
|
||||
await db.q('INSERT INTO unlock_codes (code_hash, label, created, uses) VALUES (?,?,?,1) ON DUPLICATE KEY UPDATE uses = uses + 1', [crypto.createHash('sha256').update(code).digest('hex'), 'WWI_TEST_CODE', Date.now()]);
|
||||
return json(res, 200, { ok: true }, { 'Set-Cookie': cookie('wwi.unlock', signed('test'), 30 * 86400, true) });
|
||||
}
|
||||
if (p === '/api/lock' && req.method === 'POST') return json(res, 200, { ok: true }, { 'Set-Cookie': cookie('wwi.unlock', '', 0, true) });
|
||||
if (p === '/api/redeem' && req.method === 'POST') {
|
||||
if (limited(req, 'redeem', 6, 15 * 60000)) return json(res, 429, { error: 'Too many tries. Wait 15 minutes.' });
|
||||
const b = await readBody(req); const code = String(b.code || '').trim().toUpperCase();
|
||||
if (!/^[A-Z0-9-]{4,40}$/.test(code)) return json(res, 400, { error: 'That code is not right.' });
|
||||
const m = await member(req); const holder = holderOf(req, m); if (!holder) return json(res, 400, { error: 'Reload the page and try again.' });
|
||||
const pc = await db.one('SELECT * FROM promo_codes WHERE code = ?', [code]);
|
||||
if (!pc || pc.disabled) return json(res, 404, { error: 'That code is not right.' });
|
||||
if (pc.expires && pc.expires < Date.now()) return json(res, 410, { error: 'That code has expired.' });
|
||||
if (pc.per_holder_once && await db.one('SELECT id FROM promo_redemptions WHERE code = ? AND holder = ?', [code, holder])) return json(res, 409, { error: 'You already used this code.' });
|
||||
const r = await db.q('UPDATE promo_codes SET uses = uses + 1 WHERE code = ? AND uses < max_uses AND disabled = 0', [code]);
|
||||
if (!r.affectedRows) return json(res, 410, { error: 'That code has been used up.' });
|
||||
const col = pc.kind === 'deep' ? 'deep' : 'free_extra';
|
||||
await db.q('INSERT INTO credits (holder, ' + col + ', updated) VALUES (?,?,?) ON DUPLICATE KEY UPDATE ' + col + ' = ' + col + ' + VALUES(' + col + '), updated = VALUES(updated)', [holder, pc.amount, Date.now()]);
|
||||
await db.q('INSERT INTO promo_redemptions (code, holder, at, kind, amount, ip_hash) VALUES (?,?,?,?,?,?)', [code, holder, Date.now(), pc.kind, pc.amount, ipHash(req)]);
|
||||
return json(res, 200, { ok: true, kind: pc.kind, amount: pc.amount, credits: await creditsOf(holder) });
|
||||
}
|
||||
if (p === '/api/test-purchase' && req.method === 'POST') {
|
||||
if (!unlocked(req)) return json(res, 403, { error: 'Payments arrive at launch.' });
|
||||
const b = await readBody(req); const item = sponsor.ITEMS[b.item] ? b.item : null; if (!item || item === 'watch') return json(res, 400, { error: 'Unknown item.' });
|
||||
const m = await member(req); const holder = holderOf(req, m);
|
||||
const r = await sponsor.record({ buyer: m ? { email: m.email, username: m.username, wallet: m.wallet } : null, ref: unsign(cookies(req)['wwi.ref']), item, via: 'test_code', note: 'staging test purchase' });
|
||||
const n = item === 'deep10' ? 10 : 1;
|
||||
await db.q('INSERT INTO credits (holder, deep, updated) VALUES (?,?,?) ON DUPLICATE KEY UPDATE deep = deep + VALUES(deep), updated = VALUES(updated)', [holder, n, Date.now()]);
|
||||
return json(res, 200, { ok: true, credits: await creditsOf(holder), split: r.split });
|
||||
}
|
||||
if (p === '/api/me' && req.method === 'GET') {
|
||||
const m = await member(req); if (!m) return json(res, 200, { member: null, sso: networksso.hubOn() });
|
||||
const checks = await db.q('SELECT id, kind, website, chain, address, status, created FROM checks WHERE member = ? ORDER BY created DESC LIMIT 30', [m.email]);
|
||||
return json(res, 200, { member: { username: m.username, wallet: m.wallet ? SHORT(m.wallet) : null, sponsor: m.sponsor, refLink: m.username ? 'https://' + SITE_HOST + '/?ref=' + encodeURIComponent(m.username) : null }, checks, credits: await creditsOf(holderOf(req, m)) });
|
||||
}
|
||||
if (p === '/api/signout' && req.method === 'POST') {
|
||||
const sid = cookies(req)['wwi.sid']; if (sid) await db.q('DELETE FROM sessions WHERE id = ?', [sid]);
|
||||
return json(res, 200, { ok: true }, { 'Set-Cookie': [cookie('wwi.sid', '', 0, true), networksso.offCookie()] });
|
||||
}
|
||||
|
||||
// admin
|
||||
if (p.startsWith('/api/admin/')) {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'Admin token needed.' });
|
||||
if (p === '/api/admin/overview' && req.method === 'GET') {
|
||||
const checks = await db.q('SELECT id, created, kind, website, chain, address, status, step, model, cost_usd, tokens_in, tokens_out, pack_chars, timings_json, error, is_public, public_label, member, factcheck_json IS NOT NULL fc FROM checks ORDER BY created DESC LIMIT 200');
|
||||
const purchases = await db.q('SELECT * FROM purchases ORDER BY at DESC LIMIT 200');
|
||||
const promos = await db.q('SELECT * FROM promo_codes ORDER BY created DESC');
|
||||
const redemptions = await db.q('SELECT * FROM promo_redemptions ORDER BY at DESC LIMIT 300');
|
||||
const cost = await db.one('SELECT COUNT(*) n, SUM(cost_usd) usd FROM checks');
|
||||
return json(res, 200, { checks, purchases: purchases.map(x => Object.assign(x, { line: JSON.parse(x.line_json || 'null'), split: JSON.parse(x.split_json || 'null') })), promos, redemptions, cost, staging: STAGING, zones: ZONES, sso: networksso.hubOn(), hub: hubpeople.view ? hubpeople.view() : null });
|
||||
}
|
||||
if (p === '/api/admin/promo' && req.method === 'POST') {
|
||||
const b = await readBody(req);
|
||||
const code = String(b.code || crypto.randomBytes(5).toString('hex')).trim().toUpperCase();
|
||||
if (!/^[A-Z0-9-]{4,40}$/.test(code)) return json(res, 400, { error: 'Code: 4 to 40 letters, numbers or dashes.' });
|
||||
const kind = b.kind === 'deep' ? 'deep' : 'free'; const amount = Math.max(1, Math.min(100, parseInt(b.amount, 10) || 1)); const maxUses = Math.max(1, Math.min(100000, parseInt(b.maxUses, 10) || 1));
|
||||
const exp = b.expires ? Date.parse(b.expires) : null;
|
||||
await db.q('INSERT INTO promo_codes (code, kind, amount, max_uses, per_holder_once, expires, note, created) VALUES (?,?,?,?,?,?,?,?)', [code, kind, amount, maxUses, b.perHolderOnce === false ? 0 : 1, isFinite(exp) ? exp : null, String(b.note || '').slice(0, 300), Date.now()]);
|
||||
return json(res, 200, { ok: true, code });
|
||||
}
|
||||
if (p === '/api/admin/promo/disable' && req.method === 'POST') { const b = await readBody(req); await db.q('UPDATE promo_codes SET disabled = ? WHERE code = ?', [b.enable ? 0 : 1, String(b.code || '').toUpperCase()]); return json(res, 200, { ok: true }); }
|
||||
if (p === '/api/admin/publish' && req.method === 'POST') { const b = await readBody(req); await db.q('UPDATE checks SET is_public = ?, public_label = ? WHERE id = ?', [b.public ? 1 : 0, String(b.label || '').slice(0, 120) || null, String(b.id || '')]); return json(res, 200, { ok: true }); }
|
||||
if (p === '/api/admin/check' && req.method === 'POST') {
|
||||
// admin-run check (network scorecards): no daily limit, deep allowed, optional public label; nothing is paid or recorded as a sale
|
||||
const b = await readBody(req); const kind = b.kind === 'deep' ? 'deep' : 'free';
|
||||
if (!ADDR_RE.test(String(b.address || '')) && !b.website) return json(res, 400, { error: 'address or website' });
|
||||
const id = jobs.newId();
|
||||
await db.q('INSERT INTO checks (id, created, ip_hash, holder, kind, website, chain, address, status, steps_json, is_public, public_label) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)',
|
||||
[id, Date.now(), 'admin', 'admin', kind, b.website ? website.normalizeUrl(b.website) : null, jobs.CHAINS[b.chain] ? b.chain : 'bsc', b.address ? String(b.address).toLowerCase() : null, 'queued', '{}', b.public ? 1 : 0, b.label ? String(b.label).slice(0, 120) : null]);
|
||||
jobs.enqueue(id); return json(res, 200, { id });
|
||||
}
|
||||
return json(res, 404, { error: 'Not found' });
|
||||
}
|
||||
if (req.method === 'GET' && !p.startsWith('/api/')) return sendFile(res, path.join(PUB, '404.html'));
|
||||
return json(res, 404, { error: 'Not found' });
|
||||
} catch (e) {
|
||||
console.error('request', p, e);
|
||||
if (!res.headersSent) json(res, 500, { error: 'Something went wrong on our side.' }); else try { res.end(); } catch (x) {}
|
||||
}
|
||||
});
|
||||
|
||||
(async () => {
|
||||
await docstore.init({ splits: [] });
|
||||
await db.init(process.env.DOCSTORE_URL);
|
||||
await chatbot.init();
|
||||
await jobs.resume();
|
||||
process.on('SIGTERM', () => { docstore.drain(8000).finally(() => process.exit(0)); });
|
||||
server.listen(PORT, () => console.log('WebWorthIt on :' + PORT + (STAGING ? ' (staging)' : '') + ', store ' + (docstore.isOn() ? 'MySQL' : 'files') + ', hub sign-in ' + (networksso.hubOn() ? 'on' : 'off')));
|
||||
})().catch(e => { console.error('boot failed', e); process.exit(1); });
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
// Sponsor rewards at point of sale (Marty CONFIRMED 2026-11-16): level 1 (direct sponsor) 20%, levels 2 to 5 at 5% each,
|
||||
// company 60%, on every paid item ($10 deep report, $79 10-pack, $9 watch alerts).
|
||||
// Sponsor line = the network hub line (hubline.js), the one source of truth. A visitor who is not signed in but came through
|
||||
// ?ref=<username> gets that member as their direct sponsor, then that member's own hub line above.
|
||||
// Pass-up: the ViralAdBlitz rule (VABShop.sol): walking up from the direct sponsor, a person who has never bought here is passed
|
||||
// over and the share goes to the next person who has; the first 5 qualified people within MAX_DEPTH places get levels 1 to 5.
|
||||
// A level share nobody qualifies for goes to the company (as in VABShop). No self-commission: the buyer is never in their own line.
|
||||
// Voucher redemptions pay nothing. STAGING: nothing is paid; the line is recorded on each test purchase and shown to the admin.
|
||||
'use strict';
|
||||
const db = require('./db');
|
||||
const hubline = require('./hubline');
|
||||
|
||||
const LEVEL_PCT = [20, 5, 5, 5, 5]; const COMPANY_PCT = 60; const MAX_DEPTH = 20;
|
||||
const ITEMS = { deep1: { usd: 10, name: 'One deep report' }, deep10: { usd: 79, name: '10 deep reports' }, watch: { usd: 9, name: 'Watch alerts, 3 months' } };
|
||||
|
||||
async function qualified(p) {
|
||||
const r = await db.one("SELECT COUNT(*) n FROM purchases WHERE via <> 'voucher' AND ((buyer_username IS NOT NULL AND buyer_username = ?) OR (buyer_wallet IS NOT NULL AND buyer_wallet = ?))",
|
||||
[p.username || '\u0000', p.wallet || '\u0000']);
|
||||
return Number(r.n) > 0;
|
||||
}
|
||||
|
||||
// buyer = { username, wallet, email } (signed-in member) or null; ref = username from the ?ref cookie
|
||||
async function lineFor(buyer, ref) {
|
||||
let raw = [], src = 'none', ok = true;
|
||||
if (buyer && (buyer.username || buyer.wallet)) {
|
||||
const l = await hubline.lineOf(buyer.username ? { ref: buyer.username } : { wallet: buyer.wallet }, MAX_DEPTH);
|
||||
ok = l.ok; raw = l.line || []; src = 'hub line of the buyer';
|
||||
if (!raw.length && ref && (!buyer.username || ref.toLowerCase() !== buyer.username.toLowerCase())) {
|
||||
const r = await hubline.lineOf({ ref }, MAX_DEPTH - 1); ok = r.ok;
|
||||
if (r.person) raw = [{ depth: 1, id: r.person.id, username: r.person.username, wallet: r.person.wallet }].concat((r.line || []).map(x => Object.assign({}, x, { depth: x.depth + 1 })));
|
||||
src = 'referral link (?ref=' + ref + '), buyer has no hub sponsor';
|
||||
}
|
||||
} else if (ref) {
|
||||
const r = await hubline.lineOf({ ref }, MAX_DEPTH - 1); ok = r.ok;
|
||||
if (r.person) raw = [{ depth: 1, id: r.person.id, username: r.person.username, wallet: r.person.wallet || null }].concat((r.line || []).map(x => Object.assign({}, x, { depth: x.depth + 1 })));
|
||||
src = 'referral link (?ref=' + ref + ')';
|
||||
}
|
||||
const me = buyer ? [buyer.username && buyer.username.toLowerCase(), buyer.wallet && buyer.wallet.toLowerCase()].filter(Boolean) : [];
|
||||
const line = [];
|
||||
for (const p of raw) {
|
||||
const self = me.includes(String(p.username || '').toLowerCase()) || me.includes(String(p.wallet || '').toLowerCase());
|
||||
line.push({ depth: p.depth, username: p.username || null, wallet: p.wallet || null, self, qualified: self ? false : await qualified(p) });
|
||||
}
|
||||
return { ok, source: src, line };
|
||||
}
|
||||
|
||||
function split(usd, line, via) {
|
||||
const out = { usd, via, levels: [], company: 0, note: '' };
|
||||
if (via === 'voucher') { out.note = 'Voucher redemption: no payment, nobody is paid.'; return out; }
|
||||
const q = line.filter(p => p.qualified && !p.self).slice(0, 5);
|
||||
let given = 0;
|
||||
LEVEL_PCT.forEach((pct, i) => {
|
||||
const p = q[i]; const amt = Math.round(usd * pct) / 100;
|
||||
if (p) { out.levels.push({ level: i + 1, pct, usd: amt, username: p.username, wallet: p.wallet, place: p.depth }); given += amt; }
|
||||
else out.levels.push({ level: i + 1, pct, usd: amt, username: null, to: 'company (nobody qualified within ' + MAX_DEPTH + ' places)' });
|
||||
});
|
||||
out.company = Math.round((usd - given) * 100) / 100;
|
||||
out.note = 'Staging: recorded only, nothing paid.';
|
||||
return out;
|
||||
}
|
||||
|
||||
async function record({ buyer, ref, item, via, checkId, note }) {
|
||||
const it = ITEMS[item]; if (!it) throw new Error('unknown item');
|
||||
const l = await lineFor(buyer, ref).catch(e => ({ ok: false, source: 'error ' + e.message, line: [] }));
|
||||
const s = split(it.usd, l.line, via);
|
||||
await db.q('INSERT INTO purchases (at, buyer, buyer_username, buyer_wallet, item, usd, via, check_id, ref, line_json, split_json, note, real_money) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,0)',
|
||||
[Date.now(), buyer ? buyer.email || null : null, buyer ? buyer.username || null : null, buyer ? buyer.wallet || null : null, item, it.usd, via, checkId || null, ref || null,
|
||||
JSON.stringify(l), JSON.stringify(s), note || null]);
|
||||
return { line: l, split: s };
|
||||
}
|
||||
module.exports = { record, lineFor, split, ITEMS, LEVEL_PCT, COMPANY_PCT, MAX_DEPTH };
|
||||
@@ -0,0 +1,100 @@
|
||||
"""Builds public/index.html from the approved mockup (tools/mockup-Main.dc.html, Marty 2026-11-16): same copy, colours, fonts and
|
||||
sections; the header and footer come from assets/common.js; the form, pricing buttons, live result and network table are wired.
|
||||
Run: python tools/build-index.py"""
|
||||
import re, os
|
||||
H = os.path.dirname(os.path.abspath(__file__))
|
||||
src = open(os.path.join(H, 'mockup-Main.dc.html'), encoding='utf8').read()
|
||||
a = src.index('<!-- hero / check -->'); b = src.index('<!-- footer -->')
|
||||
body = src[a:b]
|
||||
|
||||
def rep(old, new, count=1):
|
||||
global body
|
||||
assert old in body, old[:80]
|
||||
body = body.replace(old, new, count)
|
||||
|
||||
# form
|
||||
rep('<form style="', '<form id="checkForm" novalidate style="')
|
||||
rep('<input id="site" type="url"', '<input id="site" name="website" type="url" autocomplete="url" inputmode="url"')
|
||||
rep('<input id="target" type="text"', '<input id="target" name="address" type="text" autocomplete="off" spellcheck="false"')
|
||||
rep('<select aria-label="Chain"', '<select id="chain" name="chain" aria-label="Chain"')
|
||||
rep('<option>BNB Chain</option><option>Polygon</option><option>Ethereum</option><option>Base</option>',
|
||||
'<option value="bsc">BNB Chain</option><option value="polygon">Polygon</option><option value="eth">Ethereum</option><option value="base">Base</option>')
|
||||
rep('<button type="button" style="font-family: Archivo', '<button id="runBtn" type="submit" style="font-family: Archivo')
|
||||
rep('3 free checks a day. Read-only: a check never asks you to connect a wallet.</span>',
|
||||
'3 free checks a day. Read-only: a check never asks you to connect a wallet.</span>\n<span id="formErr" role="alert" style="color: #FFB599; font-size: 14px"></span><span id="freeLeft" style="font-size: 13px; color: #A9BEB1"></span>')
|
||||
# live result goes right after the hero
|
||||
rep('<!-- problem / agitate / solve -->', '<div id="heroSlot"></div>\n<!-- live result -->\n<div id="live" class="wrap hide" style="padding-top: 48px; padding-bottom: 8px; display: flex; flex-direction: column; gap: 24px"></div>\n<div id="liveSlot"></div>\n<!-- problem / agitate / solve -->')
|
||||
# sample label
|
||||
rep('Sample free check, a real contract</span>', 'Sample free check, a real contract (example)</span>')
|
||||
rep('<a href="#reports" style="text-decoration: none; background: #E2541B; color: #FFFFFF; text-align: center; padding: 13px; border-radius: 6px; font-weight: 600">Get the deep report</a>',
|
||||
'<a href="#reports" style="text-decoration: none; background: #E2541B; color: #FFFFFF; text-align: center; padding: 13px; border-radius: 6px; font-weight: 600">See deep report prices</a>')
|
||||
rep('[Project website screenshot, taken by our own headless browser]', '<img src="/art/sample-3xsusu.jpg" alt="Screenshot of the 3xSusu website taken by our own headless browser" style="width: 100%; height: 100%; object-fit: cover; object-position: top" data-sample>[Project website screenshot, taken by our own headless browser]')
|
||||
# how-it-works band: ad slot at its end
|
||||
rep('A project can reply to its check on Earners Corner.</p>', 'A project can reply to its check on Earners Corner.</p>\n<div id="howSlot"></div>')
|
||||
# pricing: staging buttons, sponsor line, voucher + test-code boxes
|
||||
rep('<p style="margin: 0; color: #3E5149; font-size: 14px">One-time payments on Polygon. No subscriptions. Pay with SafePal or any other crypto wallet.</p>',
|
||||
'<p style="margin: 0; color: #3E5149; font-size: 14px">One-time payments on Polygon. No subscriptions. Pay with SafePal or any other crypto wallet.</p>\n'
|
||||
'<p style="margin: 0; color: #3E5149; font-size: 14px">Sponsors earn 20% when someone they referred buys, plus 5% on levels 2 to 5. Only members who have bought here themselves receive a share; anyone who has not is passed over. You earn only when people choose to buy.</p>')
|
||||
rep('cursor: pointer">Buy one report</button>', 'cursor: pointer" data-buy="deep1" disabled>Payments arrive at launch</button>')
|
||||
rep('cursor: pointer">Buy 10 reports</button>', 'cursor: pointer" data-buy="deep10" disabled>Payments arrive at launch</button>')
|
||||
rep('<input type="checkbox" checked style=', '<input id="watch" type="checkbox" checked style=')
|
||||
rep('<span style="font-size: 13px; color: #A9BEB1">One payment. It stops by itself after 3 months.</span>',
|
||||
'<span style="font-size: 13px; color: #A9BEB1">One payment. It stops by itself after 3 months. Alerts start at launch.</span>')
|
||||
rep('<!-- payment contract scanned -->', '''<div style="display: flex; flex-wrap: wrap; gap: 20px">
|
||||
<div style="flex: 1 1 300px; min-width: 0; background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 10px">
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 18px">Have a voucher?</span>
|
||||
<span style="color: #3E5149; font-size: 14px">Vouchers add deep reports or extra free checks to this browser, or to your account when you are signed in.</span>
|
||||
<div style="display: flex; gap: 10px; flex-wrap: wrap"><input id="voucher" class="code" placeholder="VOUCHER CODE" style="flex: 1 1 180px"><button id="redeemBtn" class="btn dark" type="button">Redeem</button></div>
|
||||
<span id="voucherMsg" style="font-size: 14px; color: #3E5149"></span><span id="creditLine" style="font-size: 14px; color: #1F6B4F"></span>
|
||||
</div>
|
||||
<div id="testBox" class="hide" style="flex: 1 1 300px; min-width: 0; background: #FCE6DC; border: 1px dashed #B23E10; border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 10px">
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 18px">Staging test code</span>
|
||||
<span style="color: #3E5149; font-size: 14px">For testing only. It unlocks deep reports and test purchases that record who would be paid. No money moves.</span>
|
||||
<div id="testIn" style="display: flex; gap: 10px; flex-wrap: wrap"><input id="testCode" class="code" placeholder="test code" autocomplete="off" style="flex: 1 1 180px"><button id="testBtn" class="btn dark" type="button">Unlock</button></div>
|
||||
<div id="testOn" class="hide" style="display: flex; gap: 10px; flex-wrap: wrap"><button class="btn line" type="button" data-test="deep1">Test purchase: 1 report</button><button class="btn line" type="button" data-test="deep10">Test purchase: 10 reports</button><button id="lockBtn" class="btn" type="button" style="background: transparent; text-decoration: underline">Lock</button></div>
|
||||
<span id="testMsg" style="font-size: 14px; color: #3E5149"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="shareBox" class="hide" style="background: #FFFFFF; border: 2px solid #1F6B4F; border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 10px">
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 18px">Share WebWorthIt</span>
|
||||
<span style="color: #3E5149; font-size: 14px">Your referral link. When someone you referred buys a report, you earn 20% as their direct sponsor, plus 5% on levels 2 to 5 of your team. You earn only when people choose to buy.</span>
|
||||
<div style="display: flex; gap: 10px; flex-wrap: wrap"><input id="refLink" class="code" readonly style="flex: 1 1 320px"><button id="copyRef" class="btn dark" type="button">Copy link</button></div>
|
||||
</div>
|
||||
<!-- payment contract scanned -->''')
|
||||
rep('[address published at launch] · source verified on Polygonscan', '[address published at launch] · source verified on Polygonscan · placeholder until launch')
|
||||
rep('<a href="#c" style="font-weight: 600">View its scorecard</a>', '<span style="color: #5B7067">[scorecard at launch]</span>')
|
||||
# network table: full addresses, filled from /api/network-checks
|
||||
NET = [('Viral Banner Blitz', 'polygon', '0x36F6ccc8752DcE1c84e06b65f07dF30e8a4707D7', '0x36F6…D7D7'), ('ViralAdBlitz', 'polygon', '0xb58447b0CE9a38Ad0e7d41a074FEbee696452905', '0xb584…2905'),
|
||||
('DownlineHydra', 'polygon', '0xEd07Ad7150ecBa62689Cf2480729753F2Fa44e90', '0xEd07…4e90'), ('5xYourTeam', 'polygon', '0x83Bb982d8B485De1a24E7D313765dDA48D5aBc74', '0x83Bb…bc74')]
|
||||
for name, ch, full, sh in NET:
|
||||
old = re.search(r'<tr style="border-top: 1px solid #2D5446"><td style="padding: 13px 16px">%s</td>.*?</tr>' % re.escape(name), body).group(0)
|
||||
body = body.replace(old, '<tr style="border-top: 1px solid #2D5446" data-net="%s"><td style="padding: 13px 16px">%s</td><td style="padding: 13px 16px; font-family: \'IBM Plex Mono\', monospace"><a style="color: #EEF3EF" href="https://polygonscan.com/address/%s" target="_blank" rel="noopener nofollow">%s</a></td><td style="padding: 13px 16px; color: #8FD3B1" data-src>Verified</td><td style="padding: 13px 16px; color: #A9BEB1" data-score>[scorecard at launch]</td></tr>' % (full.lower(), name, full, sh))
|
||||
rep('<p style="margin: 0; color: #C5D3CA; max-width: 720px">We run the same check on every contract in our own network and publish the result, good or bad. Rescanned every week.</p>',
|
||||
'<p style="margin: 0; color: #C5D3CA; max-width: 720px">We run the same check on every contract in our own network and publish the result, good or bad. Rescanned every week.</p>\n<p style="margin: 0; color: #A9BEB1; font-size: 13px">Each grade is our opinion, from the published rubric applied to the public facts in the linked report.</p>')
|
||||
rep('<a href="#ec-topic" style="font-weight: 600">Open the Contract Checks topic</a>', '<span style="font-weight: 600; color: #5B7067">Open the Contract Checks topic [placeholder: opens at launch]</span>')
|
||||
rep('High risk · updated Nov 16</span>', 'High risk · updated Nov 16 [placeholder]</span>')
|
||||
assert '—' not in body
|
||||
head = '''<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>WebWorthIt: check before you join</title>
|
||||
<meta name="description" content="Paste a smart contract address or a project website and see who controls the money, where it went and whether the promises match the code. Public information only, read-only.">
|
||||
<meta name="theme-color" content="#0E2A22">
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Archivo:wght@500;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap">
|
||||
<link rel="stylesheet" href="/assets/wwi.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
<div style="background: #F3F5F1; color: #0E2A22; font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 16px; line-height: 1.55">
|
||||
'''
|
||||
tail = '''</div>
|
||||
<script src="/assets/common.js?v=1"></script>
|
||||
<script src="/assets/render.js?v=1"></script>
|
||||
<script src="/assets/index.js?v=1"></script>
|
||||
</body>
|
||||
</html>
|
||||
'''
|
||||
open(os.path.join(H, '..', 'public', 'index.html'), 'w', encoding='utf8', newline='\n').write(head + body + tail)
|
||||
print('ok', len(head + body + tail))
|
||||
@@ -0,0 +1,136 @@
|
||||
"""Builds the static pages (report permalink, my checks, admin, legal pages, rubric, 404) with one shared head.
|
||||
Plain readable wording, no em dashes, none of the banned words, no postal address (Marty 2026-11-16). Run: python tools/build-pages.py"""
|
||||
import os, html
|
||||
H = os.path.dirname(os.path.abspath(__file__)); PUB = os.path.join(H, '..', 'public')
|
||||
UPDATED = 'November 16, 2026'
|
||||
|
||||
|
||||
def page(title, desc, body, scripts=('common.js',), legal=False):
|
||||
sc = ''.join('<script src="/assets/%s?v=1"></script>\n' % s for s in scripts)
|
||||
main = body
|
||||
if legal:
|
||||
main = ('<div class="wrap legal-grid" style="padding-top:40px;padding-bottom:56px"><main class="legal">%s</main><aside id="sideSlot" aria-label="Advertisement"></aside></div>' % body)
|
||||
return '''<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>%s | WebWorthIt</title>
|
||||
<meta name="description" content="%s">
|
||||
<meta name="theme-color" content="#0E2A22">
|
||||
<link rel="icon" type="image/svg+xml" href="/art/mark.svg">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Archivo:wght@500;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap">
|
||||
<link rel="stylesheet" href="/assets/wwi.css?v=1">
|
||||
</head>
|
||||
<body>
|
||||
%s
|
||||
%s</body>
|
||||
</html>
|
||||
''' % (html.escape(title), html.escape(desc), main, sc + ('<script src="/assets/side.js?v=1"></script>\n' if legal else ''))
|
||||
|
||||
|
||||
PUBLIC_LINE = ('Every WebWorthIt check uses only public information that anyone could look up on their own: public blockchain records, '
|
||||
'verified or decompiled public contract code, and the project\'s public website. We do not access private data, we do not hack anything, '
|
||||
'we do not sign in to or interact with the project, and we do not move funds. A check is read-only.')
|
||||
OPINION_LINE = ('Our findings are public facts, each one tagged and linked to its on-chain or website source. The scores, the grade (for example "High risk") '
|
||||
'and the verdict are our opinion, formed by applying our published rubric to those public facts.')
|
||||
ADVICE_LINE = 'A report is information about code and on-chain records. It is not financial advice and it is not a judgment of any person.'
|
||||
REPLY_LINE = 'A project can reply to its check in its public thread.'
|
||||
|
||||
privacy = '''<p class="eyebrow">Updated %s</p><h1>Privacy Policy</h1>
|
||||
<p>TrustClickz runs WebWorthIt. This page says what we keep and why, in plain words.</p>
|
||||
<h2>What we store</h2>
|
||||
<ul>
|
||||
<li><b>The checks you run.</b> The website and the contract address you entered, the chain, the time, and the result we produced.</li>
|
||||
<li><b>A hashed version of your IP address.</b> We use it only to count the 3 free checks a day. We store a one-way hash, never the raw address.</li>
|
||||
<li><b>Screenshots of public pages.</b> When you enter a website, our own browser opens that public page and saves a screenshot, so the report shows what the page said at that time.</li>
|
||||
<li><b>If you sign in with the network:</b> your network email, username and the wallet address on your network account, so your checks, vouchers and referral link follow you. When you buy, the sponsor line that would be paid is recorded with the sale.</li>
|
||||
<li><b>Vouchers and test codes</b> you redeem, with the time, so a code is used only as often as it allows.</li>
|
||||
<li><b>A browser cookie</b> that keeps your vouchers and settings on this browser, and a cookie that remembers who referred you (30 days).</li>
|
||||
</ul>
|
||||
<h2>What we never do</h2>
|
||||
<ul>
|
||||
<li>We never ask anyone to connect a wallet to run a check. A check is read-only.</li>
|
||||
<li>We never access private data about a project or a person. %s</li>
|
||||
<li>We do not sell personal data.</li>
|
||||
</ul>
|
||||
<h2>Sharing</h2>
|
||||
<p>Your WebWorthIt account is part of the network: your username, wallet and sponsor are shared with the network hub so one account works on every network site. Checks you run are private to you unless you share the link. Checks of our own network contracts are published on purpose.</p>
|
||||
<h2>Your choices</h2>
|
||||
<p>Ask network support to delete your data. The network hub removes it from every network site, except what the blockchain or the law keeps.</p>
|
||||
<p>Questions: <a href="https://instantadpay.com/support?from=webworthit">network support</a>. WebWorthIt is run by TrustClickz.</p>''' % (UPDATED, PUBLIC_LINE)
|
||||
|
||||
terms = '''<p class="eyebrow">Updated %s</p><h1>Terms and Conditions</h1>
|
||||
<p>These terms cover your use of WebWorthIt, run by TrustClickz. By using the site you accept them.</p>
|
||||
<h2>What a check is</h2>
|
||||
<p>%s</p>
|
||||
<p>%s</p>
|
||||
<p>%s %s</p>
|
||||
<h2>Accuracy</h2>
|
||||
<p>We check every address, transaction and number in a written report against the evidence our tools read. A report that does not pass that check is not shown; only the facts read straight from the chain are shown. Public nodes can fail or limit what they return, so every report says which block range was read and what could not be read. Blockchain records change all the time: a report describes the state at the block it names.</p>
|
||||
<h2>Free checks, deep reports and vouchers</h2>
|
||||
<ul><li>Every visitor gets 3 free checks a day.</li><li>Deep reports, report packs and watch alerts are one-time payments. No subscriptions.</li><li>Vouchers add reports or free checks as stated on the voucher, may expire, and have no cash value.</li><li>Sponsor rewards: when someone a member referred buys, the sponsor line is paid as published on the site (20%% to the direct sponsor, 5%% on levels 2 to 5). You are paid only when people choose to buy. Voucher redemptions pay nothing.</li></ul>
|
||||
<h2>Fair use</h2>
|
||||
<p>Do not use the site to attack, overload or scrape other services, and do not enter sites or addresses you have no reason to check. We may limit or refuse checks to keep the service working for everyone.</p>
|
||||
<h2>No warranty</h2>
|
||||
<p>WebWorthIt is provided as it is. To the extent the law allows, TrustClickz is not liable for decisions you make with or without a report. See the <a href="/disclaimer">Disclaimer</a>.</p>
|
||||
<h2>Contact</h2>
|
||||
<p><a href="https://instantadpay.com/support?from=webworthit">Network support</a>.</p>''' % (UPDATED, PUBLIC_LINE, OPINION_LINE, ADVICE_LINE, REPLY_LINE)
|
||||
|
||||
disclaimer = '''<p class="eyebrow">Updated %s</p><h1>Disclaimer</h1>
|
||||
<p><b>Public information only.</b> %s</p>
|
||||
<p><b>Facts and opinion are kept apart.</b> %s Scores are never for sale: there are no badges to buy and no paid removals.</p>
|
||||
<p><b>Not advice.</b> %s Nothing on this site tells you to join, leave, buy, sell or withdraw. Make your own decision, with your own research.</p>
|
||||
<p><b>Code and records, not people.</b> We describe what a contract can do and what the chain shows. We do not say anything about the intentions or character of anyone behind a project. %s</p>
|
||||
<p><b>Limits.</b> Our tools read public nodes, which can fail or return less than the full history. Function names for unverified code come from public signature databases and are marked INFERRED. What we cannot see is marked UNKNOWN.</p>''' % (UPDATED, PUBLIC_LINE, OPINION_LINE, ADVICE_LINE, REPLY_LINE)
|
||||
|
||||
rubric_md = open(os.path.join(H, '..', 'chain', 'rubric.md'), encoding='utf8').read()
|
||||
def md(s):
|
||||
out = []; inlist = False
|
||||
for line in s.splitlines():
|
||||
if line.startswith('# '): continue
|
||||
if line.startswith('## '):
|
||||
if inlist: out.append('</ul>'); inlist = False
|
||||
out.append('<h2>%s</h2>' % html.escape(line[3:])); continue
|
||||
if line.startswith('- ') or (line[:2].isdigit() if line else False) or (line[:1].isdigit() and line[1:3] == '. '):
|
||||
if not inlist: out.append('<ul>'); inlist = True
|
||||
out.append('<li>%s</li>' % html.escape(line.split(' ', 1)[1]).replace('`', '')); continue
|
||||
if inlist and line.strip() == '': out.append('</ul>'); inlist = False; continue
|
||||
if line.strip(): out.append('<p>%s</p>' % html.escape(line).replace('`', ''))
|
||||
if inlist: out.append('</ul>')
|
||||
return '\n'.join(out)
|
||||
rubric = ('<p class="eyebrow">The published rubric</p><h1>How a check is scored</h1><p>%s</p>' % html.escape(OPINION_LINE)) + md(rubric_md)
|
||||
|
||||
report = '''<main class="wrap" style="padding-top:40px;padding-bottom:40px;display:flex;flex-direction:column;gap:24px">
|
||||
<div id="live" style="display:flex;flex-direction:column;gap:24px"><div class="steps">Loading the check...</div></div>
|
||||
<p style="margin:0"><a href="/#check">Run another check</a></p>
|
||||
</main>'''
|
||||
|
||||
my = '''<main class="wrap" style="padding-top:40px;padding-bottom:40px;display:flex;flex-direction:column;gap:20px">
|
||||
<h1 style="font-size:40px">My checks</h1>
|
||||
<div id="out"><p>Loading...</p></div>
|
||||
</main>'''
|
||||
|
||||
admin = '''<main class="wrap" style="padding-top:32px;padding-bottom:40px;display:flex;flex-direction:column;gap:20px">
|
||||
<h1 style="font-size:36px">WebWorthIt admin</h1>
|
||||
<div id="tok" class="card"><span>Admin token</span><div style="display:flex;gap:10px;flex-wrap:wrap"><input id="token" class="code" type="password" style="flex:1 1 300px"><button id="save" class="btn dark" type="button">Open</button></div></div>
|
||||
<div id="out"></div>
|
||||
</main>'''
|
||||
|
||||
nf = '''<main class="wrap" style="padding-top:64px;padding-bottom:64px"><h1 style="font-size:40px">Page not found</h1><p><a href="/">Back to WebWorthIt</a></p></main>'''
|
||||
|
||||
files = {
|
||||
'privacy.html': page('Privacy Policy', 'What WebWorthIt stores and why. Public information only; we never ask anyone to connect a wallet to run a check.', privacy, legal=True),
|
||||
'terms.html': page('Terms and Conditions', 'Terms for using WebWorthIt, a read-only contract and website check run by TrustClickz.', terms, legal=True),
|
||||
'disclaimer.html': page('Disclaimer', 'WebWorthIt uses only public information. Scores are our opinion, not financial advice.', disclaimer, legal=True),
|
||||
'rubric.html': page('The rubric', 'The published rubric WebWorthIt applies to public facts to form its opinion.', rubric, legal=True),
|
||||
'report.html': page('Check', 'A WebWorthIt check: public facts with sources, and our opinion from the published rubric.', report, ('common.js', 'render.js', 'report.js')),
|
||||
'my.html': page('My checks', 'Your WebWorthIt checks and referral link.', my, ('common.js', 'my.js')),
|
||||
'admin.html': page('Admin', 'WebWorthIt admin.', admin, ('common.js', 'admin.js')),
|
||||
'404.html': page('Not found', 'Page not found.', nf),
|
||||
}
|
||||
for k, v in files.items():
|
||||
assert '—' not in v and '–' not in v, k
|
||||
for bad in ('Green Valley', 'Moody', '35004'): assert bad not in v
|
||||
open(os.path.join(PUB, k), 'w', encoding='utf8', newline='\n').write(v)
|
||||
print('ok', list(files))
|
||||
@@ -0,0 +1,276 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WebWorthIt: check before you join</title>
|
||||
<script src="./support.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<x-dc>
|
||||
<helmet>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Archivo:wght@500;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap">
|
||||
<style>
|
||||
body{margin:0;background:#F3F5F1}
|
||||
a{color:#0E2A22}a:hover{color:#E2541B}
|
||||
</style>
|
||||
</helmet>
|
||||
<div style="background: #F3F5F1; color: #0E2A22; font-family: 'IBM Plex Sans', system-ui, sans-serif; font-size: 16px; line-height: 1.55">
|
||||
|
||||
<!-- header -->
|
||||
<div style="border-bottom: 1px solid #C9D3CC; background: #F3F5F1">
|
||||
<div style="max-width: 1200px; margin: 0 auto; padding: 18px 24px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px">
|
||||
<div style="display: flex; align-items: center; gap: 10px">
|
||||
<svg width="34" height="34" viewBox="0 0 34 34" aria-hidden="true"><circle cx="14" cy="14" r="10" fill="none" stroke="#0E2A22" stroke-width="2.5"></circle><path d="M8 16 L12 12 L15 15 L20 9" fill="none" stroke="#E2541B" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M21.5 21.5 L30 30" stroke="#0E2A22" stroke-width="3" stroke-linecap="round"></path></svg>
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 800; font-size: 22px; letter-spacing: -0.01em">WebWorthIt</span>
|
||||
</div>
|
||||
<nav aria-label="Main" style="display: flex; flex-wrap: wrap; gap: 22px; font-weight: 500; font-size: 15px">
|
||||
<a href="#check" style="text-decoration: none">Run a check</a>
|
||||
<a href="#scoring" style="text-decoration: none">How scoring works</a>
|
||||
<a href="#network" style="text-decoration: none">Our own contracts</a>
|
||||
<a href="#reports" style="text-decoration: none">Deep reports</a>
|
||||
<a href="#ec" style="text-decoration: none">Earners Corner</a>
|
||||
</nav>
|
||||
<a href="#signin" style="text-decoration: none; background: #0E2A22; color: #F3F5F1; padding: 11px 18px; border-radius: 6px; font-weight: 600; font-size: 15px">Sign in with the network</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- hero / check -->
|
||||
<div id="check" style="background: #0E2A22; color: #EEF3EF">
|
||||
<div style="max-width: 1200px; margin: 0 auto; padding: 72px 24px 64px; display: flex; flex-wrap: wrap; gap: 48px; align-items: center">
|
||||
<div style="flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 22px">
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: #F0A27F">Contract and website check</span>
|
||||
<h1 style="margin: 0; font-family: Archivo, sans-serif; font-weight: 800; font-size: 58px; line-height: 1.04; letter-spacing: -0.02em; text-wrap: balance">Know who controls the money before you send yours.</h1>
|
||||
<p style="margin: 0; font-size: 19px; max-width: 600px; color: #C5D3CA">The sales page tells you what the project wants you to hear. The contract tells you what can actually happen to your deposit. Paste the address or the website and see it in plain English, before you join.</p>
|
||||
<form style="display: flex; flex-direction: column; gap: 12px; background: #163A2F; border: 1px solid #2D5446; border-radius: 10px; padding: 18px">
|
||||
<label for="site" style="font-size: 14px; font-weight: 600; color: #EEF3EF">Project website</label>
|
||||
<input id="site" type="url" placeholder="https://the-project-website.com" style="min-width: 0; font-family: 'IBM Plex Mono', monospace; font-size: 15px; padding: 14px; border-radius: 6px; border: 1px solid #3E6A5A; background: #F3F5F1; color: #0E2A22">
|
||||
<label for="target" style="font-size: 14px; font-weight: 600; color: #EEF3EF">Smart contract address <span style="font-weight: 400; color: #A9BEB1">(leave blank and we'll look for it on the website)</span></label>
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 10px">
|
||||
<input id="target" type="text" placeholder="0x... (optional)" style="flex: 1 1 320px; min-width: 0; font-family: 'IBM Plex Mono', monospace; font-size: 15px; padding: 14px; border-radius: 6px; border: 1px solid #3E6A5A; background: #F3F5F1; color: #0E2A22">
|
||||
<select aria-label="Chain" style="font-size: 15px; padding: 14px; border-radius: 6px; border: 1px solid #3E6A5A; background: #F3F5F1; color: #0E2A22">
|
||||
<option>BNB Chain</option><option>Polygon</option><option>Ethereum</option><option>Base</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="button" style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 17px; padding: 14px 24px; border-radius: 6px; border: 0; background: #E2541B; color: #FFFFFF; cursor: pointer">Run free check</button>
|
||||
<span style="font-size: 13px; color: #A9BEB1">Fill in one or both. With both, we compare what the website promises against what the code does. 3 free checks a day. Read-only: a check never asks you to connect a wallet.</span>
|
||||
</form>
|
||||
</div>
|
||||
<div style="flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 14px">
|
||||
<div style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: #A9BEB1; letter-spacing: 0.08em; text-transform: uppercase">What every check answers</div>
|
||||
<div style="display: flex; flex-direction: column; gap: 10px">
|
||||
<div style="display: flex; gap: 12px; align-items: baseline"><span style="font-family: 'IBM Plex Mono', monospace; color: #F0A27F">01</span><span>Can one wallet change the code or take the funds?</span></div>
|
||||
<div style="display: flex; gap: 12px; align-items: baseline"><span style="font-family: 'IBM Plex Mono', monospace; color: #F0A27F">02</span><span>Where has the money actually gone, wallet by wallet?</span></div>
|
||||
<div style="display: flex; gap: 12px; align-items: baseline"><span style="font-family: 'IBM Plex Mono', monospace; color: #F0A27F">03</span><span>Are payouts funded only by people joining later?</span></div>
|
||||
<div style="display: flex; gap: 12px; align-items: baseline"><span style="font-family: 'IBM Plex Mono', monospace; color: #F0A27F">04</span><span>Does the website promise what the code delivers?</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- problem / agitate / solve -->
|
||||
<div style="max-width: 1200px; margin: 0 auto; padding: 64px 24px 8px; display: flex; flex-direction: column; gap: 28px">
|
||||
<h2 style="margin: 0; font-family: Archivo, sans-serif; font-size: 38px; letter-spacing: -0.01em; text-wrap: balance; max-width: 820px">Most people check an opportunity after the money is gone. By then the contract can't be changed back.</h2>
|
||||
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px">
|
||||
<div style="background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 10px">
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: #5B7067">How it usually goes</span>
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 21px">You hear about it from someone you trust</span>
|
||||
<span style="color: #3E5149">The page shows a refund promise and a smart contract, so it looks safe. Almost nobody reads the contract, and the people promoting it usually haven't either.</span>
|
||||
</div>
|
||||
<div style="background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 10px">
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: #B23E10">What the contract said</span>
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 21px">One key could swap the rules</span>
|
||||
<span style="color: #3E5149">In the real example below, one personal wallet can replace the code in a single transaction, with 3,632.30 USDT behind it. The promised refund is paid in a credit that can only buy more entries.</span>
|
||||
</div>
|
||||
<div style="background: #0E2A22; color: #EEF3EF; border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 10px">
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: #F0A27F">What a report changes</span>
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 21px">You see it before you send a cent</span>
|
||||
<span style="color: #C5D3CA">Who can move the money, where it has gone so far, and whether the promises match the code. Then you decide with facts instead of hope.</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- sample result -->
|
||||
<div style="max-width: 1200px; margin: 0 auto; padding: 64px 24px; display: flex; flex-direction: column; gap: 28px">
|
||||
<div style="display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px">
|
||||
<div style="display: flex; flex-direction: column; gap: 6px">
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: #5B7067">Sample free check, a real contract</span>
|
||||
<h2 style="margin: 0; font-family: Archivo, sans-serif; font-size: 38px; letter-spacing: -0.01em">3xSusu Vault <span style="font-weight: 500; color: #5B7067">on BNB Chain</span></h2>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 14px; color: #3E5149">0x152d…976e · read 2026-11-16 9:30 AM CST · block 133,946,636</span>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 14px; border: 2px solid #E2541B; border-radius: 10px; padding: 14px 20px; background: #FFFFFF">
|
||||
<div style="font-family: Archivo, sans-serif; font-weight: 800; font-size: 30px; color: #B23E10">High risk</div>
|
||||
<div style="font-size: 14px; max-width: 230px; color: #3E5149">One critical flag caps the grade at High, whatever the other scores.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 24px">
|
||||
<!-- scorecard -->
|
||||
<div style="flex: 999 1 560px; min-width: 0; background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; padding: 26px; display: flex; flex-direction: column; gap: 18px">
|
||||
<div style="display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap"><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 20px">Scorecard</span><span style="font-size: 13px; color: #5B7067">0 = safest, 10 = worst · weight in brackets</span></div>
|
||||
|
||||
<div style="display: grid; grid-template-columns: minmax(0, 1fr) minmax(70px, 220px) 32px; gap: 10px 16px; align-items: center">
|
||||
<span>Control and upgradeability <span style="color: #5B7067">(25)</span></span>
|
||||
<div style="height: 10px; background: #E6ECE7; border-radius: 5px"><div style="width: 100%; height: 10px; background: #E2541B; border-radius: 5px"></div></div>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-weight: 500">10</span>
|
||||
<span>Custody and exit paths <span style="color: #5B7067">(25)</span></span>
|
||||
<div style="height: 10px; background: #E6ECE7; border-radius: 5px"><div style="width: 80%; height: 10px; background: #E2541B; border-radius: 5px"></div></div>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-weight: 500">8</span>
|
||||
<span>Economic design <span style="color: #5B7067">(20)</span></span>
|
||||
<div style="height: 10px; background: #E6ECE7; border-radius: 5px"><div style="width: 90%; height: 10px; background: #E2541B; border-radius: 5px"></div></div>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-weight: 500">9</span>
|
||||
<span>Insider flows <span style="color: #5B7067">(15)</span></span>
|
||||
<div style="height: 10px; background: #E6ECE7; border-radius: 5px"><div style="width: 80%; height: 10px; background: #E2541B; border-radius: 5px"></div></div>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-weight: 500">8</span>
|
||||
<span>Disclosure vs code <span style="color: #5B7067">(10)</span></span>
|
||||
<div style="height: 10px; background: #E6ECE7; border-radius: 5px"><div style="width: 70%; height: 10px; background: #C98A12; border-radius: 5px"></div></div>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-weight: 500">7</span>
|
||||
<span>Trajectory <span style="color: #5B7067">(5)</span></span>
|
||||
<div style="height: 10px; background: #E6ECE7; border-radius: 5px"><div style="width: 50%; height: 10px; background: #C98A12; border-radius: 5px"></div></div>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-weight: 500">5</span>
|
||||
</div>
|
||||
|
||||
<span style="font-size: 13px; color: #3E5149">Scores and grade are our opinion, based on our published rubric applied to the public facts below.</span>
|
||||
<div style="border-top: 1px solid #E0E6E1; padding-top: 16px; display: flex; flex-direction: column; gap: 12px">
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 17px">Top findings</span>
|
||||
<div style="display: flex; gap: 12px; align-items: flex-start"><span style="font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; background: #0E2A22; color: #FFFFFF; padding: 3px 7px; border-radius: 4px; white-space: nowrap">VERIFIED</span><span>One personal wallet (owner 0x3133…2a79) can replace the contract's code in a single transaction. No timelock, no multisig. It has already done so twice, the second time after about 588 entries were in.</span></div>
|
||||
<div style="display: flex; gap: 12px; align-items: flex-start"><span style="font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; background: #0E2A22; color: #FFFFFF; padding: 3px 7px; border-radius: 4px; white-space: nowrap">VERIFIED</span><span>3,632.30 USDT sits in the vault today. All 29,057.70 USDT paid out so far matches the published split exactly: nothing has been drained.</span></div>
|
||||
<div style="display: flex; gap: 12px; align-items: flex-start"><span style="font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; background: #0E2A22; color: #FFFFFF; padding: 3px 7px; border-radius: 4px; white-space: nowrap">VERIFIED</span><span>The "buyback" wallet owns 455 of 1,419 positions and has received 4,098.25 USDT from them.</span></div>
|
||||
<div style="display: flex; gap: 12px; align-items: flex-start"><span style="font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; background: #5B7067; color: #FFFFFF; padding: 3px 7px; border-radius: 4px; white-space: nowrap">INFERRED</span><span>The refund pool covers about 27 refunds at 52.5 SUSU each. The first refunds come due 2026-11-27.</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- site snapshot + locked -->
|
||||
<div style="flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 20px">
|
||||
<div style="background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; overflow: hidden">
|
||||
<div style="height: 200px; background: repeating-linear-gradient(135deg, #E6ECE7 0 12px, #DCE4DE 12px 24px); display: flex; align-items: center; justify-content: center; color: #3E5149; font-family: 'IBM Plex Mono', monospace; font-size: 13px; text-align: center; padding: 16px">[Project website screenshot, taken by our own headless browser]</div>
|
||||
<div style="padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px">
|
||||
<span style="font-weight: 600">Website claims vs code</span>
|
||||
<span style="color: #3E5149">Claims a 100% refund plus 50%. The code pays it in SUSU credit that can only be spent back into new entries.</span>
|
||||
</div>
|
||||
</div>
|
||||
<div style="background: #0E2A22; color: #EEF3EF; border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 12px">
|
||||
<div style="display: flex; align-items: center; gap: 10px"><svg width="18" height="18" viewBox="0 0 18 18" aria-hidden="true"><rect x="3" y="8" width="12" height="8" rx="1.5" fill="none" stroke="#F0A27F" stroke-width="1.8"></rect><path d="M6 8 V5.5 a3 3 0 0 1 6 0 V8" fill="none" stroke="#F0A27F" stroke-width="1.8"></path></svg><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 18px">In the deep report</span></div>
|
||||
<span style="font-size: 14px; color: #C5D3CA">Every exit path ranked · the full money trail with named wallets · the operator wallet ring · the refund math worked out · wallet approvals at risk · the upgrade timeline with transaction links · what the evidence cannot answer</span>
|
||||
<a href="#reports" style="text-decoration: none; background: #E2541B; color: #FFFFFF; text-align: center; padding: 13px; border-radius: 6px; font-weight: 600">Get the deep report</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- how scoring works -->
|
||||
<div id="scoring" style="background: #E6ECE7; border-top: 1px solid #C9D3CC; border-bottom: 1px solid #C9D3CC">
|
||||
<div style="max-width: 1200px; margin: 0 auto; padding: 64px 24px; display: flex; flex-direction: column; gap: 28px">
|
||||
<h2 style="margin: 0; font-family: Archivo, sans-serif; font-size: 38px; letter-spacing: -0.01em">How a check works</h2>
|
||||
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px">
|
||||
<div style="background: #FFFFFF; border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 10px"><span style="font-family: 'IBM Plex Mono', monospace; color: #B23E10; font-size: 14px">Step 1</span><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 21px">Read the chain</span><span style="color: #3E5149">Proxy and owner roles, every upgrade, every token in and out, who owns the positions, wallet approvals. Read-only, straight from public nodes.</span></div>
|
||||
<div style="background: #FFFFFF; border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 10px"><span style="font-family: 'IBM Plex Mono', monospace; color: #B23E10; font-size: 14px">Step 2</span><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 21px">Score it in public</span><span style="color: #3E5149">Six weighted categories from a rubric anyone can read. Anything the team hid counts against the project, and the report says so.</span></div>
|
||||
<div style="background: #FFFFFF; border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 10px"><span style="font-family: 'IBM Plex Mono', monospace; color: #B23E10; font-size: 14px">Step 3</span><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 21px">Tag every claim</span><span style="color: #3E5149">VERIFIED means seen on chain with a transaction link. INFERRED comes from code or simulation. UNKNOWN is stated, never guessed.</span></div>
|
||||
</div>
|
||||
<p style="margin: 0; font-size: 15px; color: #3E5149">Scores are never for sale. There are no badges to buy and no paid removals. A project can reply to its check on Earners Corner.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- deep reports pricing -->
|
||||
<div id="reports" style="max-width: 1200px; margin: 0 auto; padding: 64px 24px; display: flex; flex-direction: column; gap: 28px">
|
||||
<div style="display: flex; flex-direction: column; gap: 8px">
|
||||
<h2 style="margin: 0; font-family: Archivo, sans-serif; font-size: 38px; letter-spacing: -0.01em; text-wrap: balance">An ounce of prevention costs less than one entry</h2>
|
||||
<p style="margin: 0; color: #3E5149; max-width: 680px">One entry into the sample program above costs 35 USDT. A deep report on it costs $10. Once a deposit is in a contract, nobody can undo it. A report you read first can stop you from making it.</p>
|
||||
</div>
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 20px; align-items: stretch">
|
||||
<div style="flex: 1 1 260px; min-width: 0; border: 1px dashed #B23E10; border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 6px"><span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: #B23E10">Finding out after you join</span><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 20px">Whatever you put in, plus your team's trust</span><span style="color: #3E5149; font-size: 15px">If you recruited people into it, they lose with you.</span></div>
|
||||
<div style="flex: 1 1 260px; min-width: 0; border: 2px solid #1F6B4F; border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 6px"><span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: #1F6B4F">Finding out before you join</span><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 20px">$10, ready in minutes</span><span style="color: #3E5149; font-size: 15px">Join with your eyes open, or walk away with your money still yours.</span></div>
|
||||
</div>
|
||||
<p style="margin: 0; color: #3E5149; font-size: 14px">One-time payments on Polygon. No subscriptions. Pay with SafePal or any other crypto wallet.</p>
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 20px">
|
||||
<div style="flex: 1 1 300px; min-width: 0; background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; padding: 26px; display: flex; flex-direction: column; gap: 14px">
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 20px">One deep report</span>
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 800; font-size: 46px">$10</span>
|
||||
<span style="color: #3E5149">The full report on one contract and its website, ready in minutes.</span>
|
||||
<button type="button" style="margin-top: auto; font-weight: 600; font-size: 16px; padding: 13px; border-radius: 6px; border: 2px solid #0E2A22; background: #FFFFFF; color: #0E2A22; cursor: pointer">Buy one report</button>
|
||||
</div>
|
||||
<div style="flex: 1 1 300px; min-width: 0; background: #FFFFFF; border: 2px solid #E2541B; border-radius: 12px; padding: 26px; display: flex; flex-direction: column; gap: 14px">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; gap: 10px"><span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 20px">10 deep reports</span><span style="font-family: 'IBM Plex Mono', monospace; font-size: 12px; background: #FCE6DC; color: #8F3110; padding: 4px 8px; border-radius: 4px">Best for team leaders</span></div>
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 800; font-size: 46px">$79</span>
|
||||
<span style="color: #3E5149">$7.90 a report, 2 reports free. Use them any time on any contract your team asks about.</span>
|
||||
<button type="button" style="margin-top: auto; font-weight: 600; font-size: 16px; padding: 13px; border-radius: 6px; border: 0; background: #E2541B; color: #FFFFFF; cursor: pointer">Buy 10 reports</button>
|
||||
</div>
|
||||
<div style="flex: 1 1 300px; min-width: 0; background: #0E2A22; color: #EEF3EF; border-radius: 12px; padding: 26px; display: flex; flex-direction: column; gap: 14px">
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: #F0A27F">Add at checkout</span>
|
||||
<label style="display: flex; gap: 12px; align-items: flex-start; font-size: 16px"><input type="checkbox" checked style="width: 22px; height: 22px; margin-top: 3px; accent-color: #E2541B"><span><strong>Watch alerts, $9</strong> for 3 months on this contract. We message you the moment the owner upgrades the code, pauses withdrawals, changes a split or the vault balance drops sharply.</span></label>
|
||||
<span style="font-size: 13px; color: #A9BEB1">One payment. It stops by itself after 3 months.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- payment contract scanned -->
|
||||
<div style="background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; padding: 26px; display: flex; flex-wrap: wrap; gap: 24px; align-items: center">
|
||||
<div style="flex: 999 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 8px">
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: #5B7067">The contract that takes your payment, checked by the same tool</span>
|
||||
<span style="font-family: Archivo, sans-serif; font-weight: 700; font-size: 24px">WebWorthIt payment contract on Polygon</span>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace; font-size: 14px; color: #3E5149">[address published at launch] · source verified on Polygonscan</span>
|
||||
<span style="color: #3E5149">Not upgradeable. No owner withdraw or sweep function. Every payment is split in the same transaction and shows on a public ledger.</span>
|
||||
</div>
|
||||
<div style="flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 8px; font-size: 15px">
|
||||
<div style="display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid #E0E6E1; padding-bottom: 6px"><span>Can one wallet change it?</span><strong style="color: #1F6B4F">No</strong></div>
|
||||
<div style="display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid #E0E6E1; padding-bottom: 6px"><span>Can anyone sweep funds?</span><strong style="color: #1F6B4F">No</strong></div>
|
||||
<div style="display: flex; justify-content: space-between; gap: 10px"><span>Full check</span><a href="#c" style="font-weight: 600">View its scorecard</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- network checked -->
|
||||
<div id="network" style="background: #0E2A22; color: #EEF3EF">
|
||||
<div style="max-width: 1200px; margin: 0 auto; padding: 64px 24px; display: flex; flex-direction: column; gap: 26px">
|
||||
<div style="display: flex; flex-direction: column; gap: 8px">
|
||||
<h2 style="margin: 0; font-family: Archivo, sans-serif; font-size: 38px; letter-spacing: -0.01em">Network, checked</h2>
|
||||
<p style="margin: 0; color: #C5D3CA; max-width: 720px">We run the same check on every contract in our own network and publish the result, good or bad. Rescanned every week.</p>
|
||||
</div>
|
||||
<div style="overflow-x: auto; border: 1px solid #2D5446; border-radius: 12px">
|
||||
<table style="width: 100%; min-width: 720px; border-collapse: collapse; font-size: 15px">
|
||||
<thead><tr style="text-align: left; background: #163A2F"><th style="padding: 14px 16px; font-weight: 600">Site</th><th style="padding: 14px 16px; font-weight: 600">Contract</th><th style="padding: 14px 16px; font-weight: 600">Source</th><th style="padding: 14px 16px; font-weight: 600">Check</th></tr></thead>
|
||||
<tbody>
|
||||
<tr style="border-top: 1px solid #2D5446"><td style="padding: 13px 16px">Viral Banner Blitz</td><td style="padding: 13px 16px; font-family: 'IBM Plex Mono', monospace">0x36F6…D7D7</td><td style="padding: 13px 16px; color: #8FD3B1">Verified</td><td style="padding: 13px 16px; color: #A9BEB1">[scorecard at launch]</td></tr>
|
||||
<tr style="border-top: 1px solid #2D5446"><td style="padding: 13px 16px">ViralAdBlitz</td><td style="padding: 13px 16px; font-family: 'IBM Plex Mono', monospace">0xb584…2905</td><td style="padding: 13px 16px; color: #8FD3B1">Verified</td><td style="padding: 13px 16px; color: #A9BEB1">[scorecard at launch]</td></tr>
|
||||
<tr style="border-top: 1px solid #2D5446"><td style="padding: 13px 16px">DownlineHydra</td><td style="padding: 13px 16px; font-family: 'IBM Plex Mono', monospace">0xEd07…4e90</td><td style="padding: 13px 16px; color: #8FD3B1">Verified</td><td style="padding: 13px 16px; color: #A9BEB1">[scorecard at launch]</td></tr>
|
||||
<tr style="border-top: 1px solid #2D5446"><td style="padding: 13px 16px">5xYourTeam</td><td style="padding: 13px 16px; font-family: 'IBM Plex Mono', monospace">0x83Bb…bc74</td><td style="padding: 13px 16px; color: #8FD3B1">Verified</td><td style="padding: 13px 16px; color: #A9BEB1">[scorecard at launch]</td></tr>
|
||||
<tr style="border-top: 1px solid #2D5446"><td style="padding: 13px 16px">Downline Banners</td><td style="padding: 13px 16px; font-family: 'IBM Plex Mono', monospace">0x6c77…9f9b</td><td style="padding: 13px 16px; color: #A9BEB1">[check at launch]</td><td style="padding: 13px 16px; color: #A9BEB1">[scorecard at launch]</td></tr>
|
||||
<tr style="border-top: 1px solid #2D5446"><td style="padding: 13px 16px">InstantAdPay, LinkSpin</td><td style="padding: 13px 16px; font-family: 'IBM Plex Mono', monospace">[addresses]</td><td style="padding: 13px 16px; color: #A9BEB1">[check at launch]</td><td style="padding: 13px 16px; color: #A9BEB1">[scorecard at launch]</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- earners corner -->
|
||||
<div id="ec" style="max-width: 1200px; margin: 0 auto; padding: 64px 24px; display: flex; flex-wrap: wrap; gap: 32px">
|
||||
<div style="flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 12px">
|
||||
<h2 style="margin: 0; font-family: Archivo, sans-serif; font-size: 38px; letter-spacing: -0.01em">Discussed on Earners Corner</h2>
|
||||
<p style="margin: 0; color: #3E5149">Every public check gets one thread on Earners Corner, updated when we rescan. Titles state facts, never labels. The project can answer in the same thread.</p>
|
||||
<a href="#ec-topic" style="font-weight: 600">Open the Contract Checks topic</a>
|
||||
</div>
|
||||
<div style="flex: 999 1 560px; min-width: 0; background: #FFFFFF; border: 1px solid #C9D3CC; border-radius: 12px; display: flex; flex-direction: column">
|
||||
<div style="padding: 16px 20px; border-bottom: 1px solid #E0E6E1; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap"><span style="font-weight: 600">3xSusu Vault (BNB Chain) contract check: code can be changed by one wallet</span><span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: #5B7067">High risk · updated Nov 16</span></div>
|
||||
<div style="padding: 16px 20px; border-bottom: 1px solid #E0E6E1; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap"><span style="font-weight: 600">[Next public check]</span><span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: #5B7067">[grade · date]</span></div>
|
||||
<div style="padding: 16px 20px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap"><span style="font-weight: 600">[Next public check]</span><span style="font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: #5B7067">[grade · date]</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- footer -->
|
||||
<div style="border-top: 1px solid #C9D3CC">
|
||||
<div style="max-width: 1200px; margin: 0 auto; padding: 32px 24px 40px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; font-size: 14px; color: #3E5149">
|
||||
<span>WebWorthIt is part of the Crypto Team Build Network. Every check uses only public information anyone can review on their own. Scores are our opinion, not financial advice. We score code and chain records, not people.</span>
|
||||
<span style="font-family: 'IBM Plex Mono', monospace">webworthit.com</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</x-dc>
|
||||
<script type="text/x-dc" data-dc-script data-props='{"$preview":{"width":1440,"height":5200}}'>
|
||||
class Component extends DCLogic {
|
||||
renderVals() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
// Website read: our own headless Chromium opens the public page (no sign-in, no clicks on wallet buttons, no forms), takes a
|
||||
// screenshot, keeps the visible text, and looks for contract addresses and chain hints in the page, its links and its scripts.
|
||||
// Read-only and public: the browser never connects a wallet and never submits anything.
|
||||
// Private network targets are refused (no localhost, no 10/8, 172.16/12, 192.168/16, 169.254/16, ::1, fc00::/7).
|
||||
'use strict';
|
||||
const dns = require('dns').promises;
|
||||
const net = require('net');
|
||||
|
||||
const EXPLORERS = { 'bscscan.com': 'bsc', 'polygonscan.com': 'polygon', 'etherscan.io': 'eth', 'basescan.org': 'base' };
|
||||
const CHAIN_WORDS = { bsc: /\b(bnb ?chain|bsc|binance smart chain|bep-?20|pancakeswap)\b/gi, polygon: /\b(polygon|matic|\bpol\b|polygonscan)\b/gi,
|
||||
eth: /\b(ethereum|erc-?20|etherscan|mainnet eth)\b/gi, base: /\b(base chain|on base|base network|basescan|coinbase base)\b/gi };
|
||||
const ADDR_RE = /0x[a-fA-F0-9]{40}(?![a-fA-F0-9])/g;
|
||||
const COMMON = new Set(['0x0000000000000000000000000000000000000000', '0x000000000000000000000000000000000000dead',
|
||||
'0x55d398326f99059ff775485246999027b3197955', '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d', '0xe9e7cea3dcd96aee6a24b63ae6d6e53fba8a9b56',
|
||||
'0xc2132d05d31c914a87c6611c10748aeb04b58e8f', '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359', '0x2791bca1f2de4661ed88a30c99a7a9449aa84174',
|
||||
'0xdac17f958d2ee523a2206206994597c13d831ec7', '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
|
||||
'0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c', '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270', '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||
'0x4200000000000000000000000000000000000006', '0x10ed43c718714eb63d5aa57b78b54704e256024e', '0xca11bde05977b3631167028862be2a173976ca11']);
|
||||
|
||||
function privateIp(ip) {
|
||||
if (net.isIPv4(ip)) {
|
||||
const p = ip.split('.').map(Number);
|
||||
return p[0] === 10 || p[0] === 127 || p[0] === 0 || (p[0] === 172 && p[1] >= 16 && p[1] <= 31) || (p[0] === 192 && p[1] === 168) || (p[0] === 169 && p[1] === 254) || (p[0] === 100 && p[1] >= 64 && p[1] <= 127) || p[0] >= 224;
|
||||
}
|
||||
const l = ip.toLowerCase();
|
||||
return l === '::1' || l === '::' || l.startsWith('fc') || l.startsWith('fd') || l.startsWith('fe80') || l.startsWith('::ffff:127.') || l.startsWith('::ffff:10.') || l.startsWith('::ffff:192.168.');
|
||||
}
|
||||
const dnsCache = new Map();
|
||||
async function hostOk(host) {
|
||||
host = String(host || '').toLowerCase();
|
||||
if (!host || host === 'localhost' || host.endsWith('.local') || host.endsWith('.internal')) return false;
|
||||
if (net.isIP(host)) return !privateIp(host);
|
||||
if (dnsCache.has(host)) return dnsCache.get(host);
|
||||
let ok = false;
|
||||
try { const a = await dns.lookup(host, { all: true }); ok = a.length > 0 && a.every(x => !privateIp(x.address)); } catch (e) { ok = false; }
|
||||
dnsCache.set(host, ok); if (dnsCache.size > 5000) dnsCache.clear();
|
||||
return ok;
|
||||
}
|
||||
|
||||
function normalizeUrl(u) {
|
||||
u = String(u || '').trim(); if (!u) return null;
|
||||
if (!/^https?:\/\//i.test(u)) u = 'https://' + u;
|
||||
try { const x = new URL(u); if (!/^https?:$/.test(x.protocol)) return null; x.hash = ''; return x.toString(); } catch (e) { return null; }
|
||||
}
|
||||
|
||||
// human-readable ABI strings in the site's own code ("function name(uint256 a) view returns (address)") -> ABI JSON
|
||||
function parseHumanAbi(src) {
|
||||
const out = []; const seen = new Set();
|
||||
const re = /["'`](function|event) ([A-Za-z_][A-Za-z0-9_]*)\(([^)"'`]*)\)([^"'`]{0,200})["'`]/g; let m;
|
||||
const types = s => s.split(',').map(x => x.trim()).filter(Boolean).map(x => ({ type: x.split(/\s+/)[0].replace(/^uint$/, 'uint256').replace(/^int$/, 'int256'), indexed: /\bindexed\b/.test(x) }));
|
||||
while ((m = re.exec(src)) && out.length < 400) {
|
||||
const key = m[1] + m[2] + m[3]; if (seen.has(key)) continue; seen.add(key);
|
||||
const ins = types(m[3]); if (ins.some(t => !/^(address|bool|string|bytes\d*|u?int\d*|tuple|\w+\[\d*\])$/.test(t.type))) continue;
|
||||
const f = { type: m[1], name: m[2], inputs: ins.map(t => m[1] === 'event' ? { type: t.type, indexed: t.indexed } : { type: t.type }) };
|
||||
if (m[1] === 'function') { const r = /returns\s*\(([^)]*)\)/.exec(m[4] || ''); f.outputs = r ? types(r[1]).map(t => ({ type: t.type })) : []; }
|
||||
out.push(f);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
async function scan(url, opts) {
|
||||
const { chromium } = require('playwright-core');
|
||||
const res = { url, ok: false, title: null, text: '', addresses: [], chainHints: {}, explorerLinks: [], abi: [], notes: [], screenshot: null };
|
||||
const u = new URL(url);
|
||||
if (!await hostOk(u.hostname)) { res.notes.push('The website address is not a public internet host, so it was not opened.'); return res; }
|
||||
const browser = await chromium.launch({ executablePath: process.env.CHROMIUM_PATH || '/usr/bin/chromium', args: ['--no-sandbox', '--disable-dev-shm-usage', '--disable-gpu'] });
|
||||
let scripts = ''; let scriptBytes = 0;
|
||||
try {
|
||||
const ctx = await browser.newContext({ viewport: { width: 1280, height: 860 }, userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0 Safari/537.36 WebWorthIt-check',
|
||||
javaScriptEnabled: true, acceptDownloads: false, permissions: [] });
|
||||
await ctx.route('**/*', async route => {
|
||||
try {
|
||||
const ru = new URL(route.request().url());
|
||||
if (!/^https?:$/.test(ru.protocol) || !await hostOk(ru.hostname)) return route.abort();
|
||||
const t = route.request().resourceType(); if (t === 'media' || t === 'font') return route.abort();
|
||||
return route.continue();
|
||||
} catch (e) { return route.abort(); }
|
||||
});
|
||||
const page = await ctx.newPage();
|
||||
page.on('dialog', d => d.dismiss().catch(() => {}));
|
||||
page.on('response', async r => {
|
||||
try {
|
||||
if (r.request().resourceType() !== 'script' || scriptBytes > 6e6) return;
|
||||
const b = await r.text(); scriptBytes += b.length; scripts += '\n' + b.slice(0, 2e6);
|
||||
} catch (e) {}
|
||||
});
|
||||
let resp = null;
|
||||
try { resp = await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 }); } catch (e) { res.notes.push('The page did not finish loading in 30 seconds: ' + String(e.message).split('\n')[0].slice(0, 120)); }
|
||||
await page.waitForLoadState('networkidle', { timeout: 8000 }).catch(() => {});
|
||||
await page.waitForTimeout(1500);
|
||||
res.status = resp ? resp.status() : null;
|
||||
res.finalUrl = page.url();
|
||||
res.title = (await page.title().catch(() => '')).slice(0, 200);
|
||||
res.text = String(await page.evaluate(() => document.body ? document.body.innerText : '').catch(() => '')).replace(/\n{3,}/g, '\n\n').slice(0, 20000);
|
||||
const html = String(await page.content().catch(() => '')).slice(0, 3e6);
|
||||
const links = await page.evaluate(() => Array.from(document.querySelectorAll('a[href]')).map(a => a.href).slice(0, 2000)).catch(() => []);
|
||||
const shot = await page.screenshot({ type: 'jpeg', quality: 72, fullPage: false }).catch(() => null);
|
||||
if (shot) res.screenshot = shot;
|
||||
// addresses: where they appear decides how likely each one is the project contract
|
||||
const score = new Map();
|
||||
const bump = (a, n, why) => { a = a.toLowerCase(); if (COMMON.has(a)) return; const s = score.get(a) || { address: a, score: 0, seen: new Set() }; s.score += n; s.seen.add(why); score.set(a, s); };
|
||||
for (const l of links) {
|
||||
let lu; try { lu = new URL(l); } catch (e) { continue; }
|
||||
const host = lu.hostname.replace(/^www\./, ''); const ch = EXPLORERS[host];
|
||||
const m = lu.pathname.match(/\/(address|token)\/(0x[a-fA-F0-9]{40})/);
|
||||
if (ch && m) { res.explorerLinks.push({ chain: ch, address: m[2].toLowerCase(), url: l.slice(0, 300) }); bump(m[2], 6, 'explorer link (' + host + ')'); res.chainHints[ch] = (res.chainHints[ch] || 0) + 3; }
|
||||
}
|
||||
for (const a of res.text.match(ADDR_RE) || []) bump(a, 3, 'visible text');
|
||||
for (const a of html.match(ADDR_RE) || []) bump(a, 1, 'page HTML');
|
||||
for (const a of (scripts.match(ADDR_RE) || []).slice(0, 3000)) bump(a, 0.5, 'site scripts');
|
||||
for (const [ch, re] of Object.entries(CHAIN_WORDS)) { const n = (res.text.match(re) || []).length; if (n) res.chainHints[ch] = (res.chainHints[ch] || 0) + n; }
|
||||
res.addresses = [...score.values()].sort((a, b) => b.score - a.score).slice(0, 25).map(s => ({ address: s.address, score: Math.round(s.score * 10) / 10, seen: [...s.seen] }));
|
||||
res.abi = parseHumanAbi(scripts + html);
|
||||
res.ok = true;
|
||||
} finally { await browser.close().catch(() => {}); }
|
||||
return res;
|
||||
}
|
||||
module.exports = { scan, normalizeUrl, hostOk, parseHumanAbi, COMMON };
|
||||
Reference in New Issue
Block a user