Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(admin): SDP admin page + pricing/dispatch/providers updates
nirholas4ac79683e173
diff --git a/api/_lib/pump-pricing.js b/api/_lib/pump-pricing.jsindex e58754b74..53d638135 100644--- a/api/_lib/pump-pricing.js+++ b/api/_lib/pump-pricing.js@@ -67,11 +67,25 @@ export function x402AmountForTool(toolName) {/*** Returns the active subscription row for (mint, payerWallet, toolName) if one- * exists and has not expired. `toolName=null` matches any unrestricted- * subscription. Returns null otherwise.+ * exists, has not expired, AND was paid at least `minAmountAtomics`.+ * `toolName=null` matches any unrestricted subscription. Returns null otherwise.+ *+ * The amount floor is essential: the payer chooses both `amount_usdc` and+ * `duration_seconds` when prepping an invoice, so without it a caller could pay+ * a fraction of a cent and unlock a tool priced per-call for as long as they+ * like. Callers MUST pass the tool's advertised price (as an atomic-unit string)+ * so a confirmed-but-underpaid invoice never satisfies the gate. Defaults to '0'+ * only for callers that have no price (free tools), which never reach this path.*/-export async function findActiveSubscription({ mint, network = 'mainnet', payerWallet, toolName }) {+export async function findActiveSubscription({+ mint,+ network = 'mainnet',+ payerWallet,+ toolName,+ minAmountAtomics = '0',+}) {if (!mint || !payerWallet) return null;+ const floor = String(minAmountAtomics ?? '0');const [row] = await sql`select p.id, p.invoice_id, p.amount_atomics, p.end_time, p.tool_namefrom pump_agent_payments p@@ -81,6 +95,7 @@ export async function findActiveSubscription({ mint, network = 'mainnet', payerWand p.payer_wallet = ${payerWallet}and p.status = 'confirmed'and p.end_time > now()+ and p.amount_atomics >= ${floor}::numericand (p.tool_name is null or p.tool_name = ${toolName || null})order by p.end_time desclimit 1diff --git a/api/_lib/rate-limit.js b/api/_lib/rate-limit.jsindex 164a225e1..54b16633d 100644--- a/api/_lib/rate-limit.js+++ b/api/_lib/rate-limit.js@@ -185,6 +185,14 @@ export const limits = {// shared key's quota from being drained by one caller. Generous enough for an// interactive dashboard; reads are not cached so this gates every origin hit.sdpIp: (ip) => getLimiter('sdp:ip', { limit: 60, window: '1 m' }).limit(ip),+ // Avatar custodial-wallet payouts (api/agent/send-sol). The per-send USD cap+ // and per-IP limit bound a single call, but neither bounds total daily outflow+ // if the demo token leaks or many IPs are used. This wallet-wide daily ceiling+ // (keyed on the wallet pubkey, not the caller) caps aggregate payouts to+ // N × per-send-cap per day. Critical → fails closed in prod without Redis so a+ // missing limiter can never silently uncap a money-moving endpoint.+ avatarPayoutDaily: (walletAddr) =>+ getLimiter('avatar:payout:daily', { limit: 50, window: '24 h', critical: true }).limit(walletAddr),mcpUser: (userId) => getLimiter('mcp:user', { limit: 1200, window: '1 m' }).limit(userId),mcpIp: (ip) => getLimiter('mcp:ip', { limit: 600, window: '1 m' }).limit(ip),// Paid MCP tools — each call runs real compute (glTF validation / inspectiondiff --git a/api/_lib/sdp.js b/api/_lib/sdp.jsindex 9a7314ec6..892a977ce 100644--- a/api/_lib/sdp.js+++ b/api/_lib/sdp.js@@ -180,31 +180,32 @@ export function sdpCreateWallet(payload, idempotencyKey) {});}-export function sdpListIssuances(query) {- return sdpCall('v1/issuance', { query });+export function sdpListTokens(query) {+ return sdpCall('v1/issuance/tokens', { query });}-export function sdpCreateIssuance(payload, idempotencyKey) {- return sdpCall('v1/issuance', {+export function sdpCreateToken(payload, idempotencyKey) {+ return sdpCall('v1/issuance/tokens', {method: 'POST',body: payload,headers: idempotencyKey ? { 'idempotency-key': idempotencyKey } : {},});}-export function sdpListPayments(query) {- return sdpCall('v1/payments', { query });+export function sdpListTransfers(query) {+ return sdpCall('v1/payments/transfers', { query });}-export function sdpCreatePayment(payload, idempotencyKey) {- return sdpCall('v1/payments', {+export function sdpCreateTransfer(payload, idempotencyKey) {+ return sdpCall('v1/payments/transfers', {method: 'POST',body: payload,headers: idempotencyKey ? { 'idempotency-key': idempotencyKey } : {},});}-// Screen an address or transaction against the SDP compliance providers.-export function sdpScreenCompliance(payload) {- return sdpCall('v1/compliance/screen', { method: 'POST', body: payload });+// Screen a Solana address against the SDP compliance providers.+// payload: { address, network?, intent? }.+export function sdpScreenAddress(payload) {+ return sdpCall('v1/compliance/address-screenings', { method: 'POST', body: payload });}diff --git a/api/_mcp/dispatch.js b/api/_mcp/dispatch.jsindex 612281e44..3b63d8f8c 100644--- a/api/_mcp/dispatch.js+++ b/api/_mcp/dispatch.js@@ -1,6 +1,6 @@import { hasScope } from '../_lib/auth.js';import { recordEvent, logger } from '../_lib/usage.js';-import { priceFor, findActiveSubscription, resolveBillingMint } from '../_lib/pump-pricing.js';+import { priceFor, findActiveSubscription, resolveBillingMint, x402AmountForTool } from '../_lib/pump-pricing.js';import { declareMcpDiscovery } from '../_lib/x402/bazaar-helpers.js';import { sanitizeToolError } from '../_lib/mcp-error-sanitize.js';import { TOOL_CATALOG, TOOLS } from './catalog.js';@@ -155,6 +155,9 @@ async function onToolCall(params, auth, started, req) {network: process.env.PUMP_DEFAULT_NETWORK || 'mainnet',payerWallet,toolName: name,+ // Only a subscription that paid at least this tool's advertised+ // price counts — a confirmed-but-underpaid invoice must not unlock it.+ minAmountAtomics: x402AmountForTool(name) || '0',});if (!sub) {throw rpcError(-32402, 'payment required for this tool', {diff --git a/api/a-og.js b/api/a-og.jsindex 5ac852cd1..b73f479fc 100644--- a/api/a-og.js+++ b/api/a-og.js@@ -64,9 +64,16 @@ export default wrap(async (req, res) => {// an actual PNG/JPG (better social preview than SVG text card).// Only redirect for http(s) URLs — crawlers won't follow ipfs:// or// gateway URLs from random hosts reliably.+ //+ // Route through our same-origin image proxy (api/img) rather than 302-ing+ // straight to the manifest host. agent.image comes from on-chain metadata an+ // attacker controls, so a direct redirect is an open redirect (phishing under+ // our domain) and an unguarded fetch target. /api/img re-fetches through the+ // SSRF-pinned fetcher and only serves responses whose content-type is image/*,+ // so the browser only ever lands on three.ws and never on an arbitrary host.if (agent.image && /^https?:\/\//i.test(agent.image)) {res.statusCode = 302;- res.setHeader('location', agent.image);+ res.setHeader('location', `/api/img?url=${encodeURIComponent(agent.image)}`);res.setHeader('cache-control', CACHE_REDIR);res.end();return;diff --git a/api/agent/send-sol.js b/api/agent/send-sol.jsindex 21d499014..0db74440e 100644--- a/api/agent/send-sol.js+++ b/api/agent/send-sol.js@@ -125,6 +125,15 @@ export default wrap(async (req, res) => {return error(res, 400, 'amount_too_small', 'amount rounds to zero lamports');}+ // Wallet-wide daily payout ceiling (defense in depth on top of the per-send+ // cap + per-IP limit): bounds total outflow if the demo token leaks or a+ // caller rotates IPs. Keyed on the wallet pubkey so it's a single shared+ // budget. Checked here — after all validation — so failed requests don't burn it.+ const daily = await limits.avatarPayoutDaily(cfg.address);+ if (!daily.success) {+ return rateLimited(res, daily, 'avatar wallet has hit its daily payout limit, try again later');+ }+const connection = getConnection(cfg.rpcUrl);const keypair = loadAvatarKeypair(process.env.AVATAR_WALLET_SECRET);diff --git a/chat/src/providers.js b/chat/src/providers.jsindex cbb379609..03c099a8d 100644--- a/chat/src/providers.js+++ b/chat/src/providers.js@@ -378,10 +378,12 @@ export const priorityOrder = [},{exactly: [- 'claude-3-7-sonnet-20250219',- 'claude-3-5-sonnet-20241022',- 'claude-3-5-haiku-20241022',- 'claude-3-opus-20240229',+ 'claude-fable-5',+ 'claude-mythos-5',+ 'claude-opus-4-7',+ 'claude-opus-4-6',+ 'claude-sonnet-4-6',+ 'claude-haiku-4-5-20251001',],},{ exactly: ['deepseek/deepseek-r1', 'deepseek/deepseek-chat'] },diff --git a/public/admin/index.html b/public/admin/index.htmlindex 2b38365cc..68fd0fdb2 100644--- a/public/admin/index.html+++ b/public/admin/index.html@@ -105,6 +105,7 @@<a class="nav-item active" data-tab="overview" onclick="switchTab('overview')">Overview</a><a class="nav-item" data-tab="users" onclick="switchTab('users')">Users</a><a class="nav-item" href="/admin/news">News</a>+ <a class="nav-item" href="/admin/sdp">Solana Platform</a><a class="nav-item" href="/dashboard/">Dashboard</a></nav><main class="main">diff --git a/public/admin/sdp.html b/public/admin/sdp.htmlnew file mode 100644index 000000000..8d67db537--- /dev/null+++ b/public/admin/sdp.html@@ -0,0 +1,492 @@+<!doctype html>+<html lang="en">+<head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width,initial-scale=1" />+ <title>Solana Developer Platform · three.ws admin</title>+ <link rel="icon" href="/favicon.ico" />+ <style>+ :root { color-scheme: dark; --accent: #14f195; --accent2: #9945ff; }+ * { box-sizing: border-box; margin: 0; padding: 0; }+ body { font: 14px/1.5 -apple-system,system-ui,'Segoe UI',sans-serif; background: #090909; color: #ccc; min-height: 100vh; }+ a { color: #888; text-decoration: none; }+ a:hover { text-decoration: underline; }+ code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }++ .layout { display: flex; min-height: 100vh; }+ .sidebar { width: 200px; background: #0e0e0e; border-right: 1px solid #1f1f1f; padding: 20px 0; flex-shrink: 0; }+ .sidebar-brand { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); padding: 0 20px 8px; display: block; }+ .sidebar-sub { font-size: 10px; color: #555; padding: 0 20px 16px; display: block; }+ .nav-item { display: block; padding: 9px 20px; color: #888; cursor: pointer; border-left: 2px solid transparent; font-size: 13px; }+ .nav-item:hover { color: #eee; background: #131313; text-decoration: none; }+ .nav-item.active { color: #eee; border-left-color: var(--accent); background: #131313; }+ .nav-sep { height: 1px; background: #1a1a1a; margin: 12px 20px; }+ .main { flex: 1; padding: 32px; overflow-y: auto; }++ .page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }+ .page-title { font-size: 20px; color: #eee; font-weight: 600; }+ .user-chip { font-size: 12px; color: #666; }+ .page-desc { font-size: 13px; color: #666; margin-bottom: 24px; max-width: 720px; }++ .stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 12px; margin-bottom: 24px; }+ .stat-card { background: #101010; border: 1px solid #1f1f1f; border-radius: 10px; padding: 16px; }+ .stat-label { font-size: 11px; color: #555; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }+ .stat-value { font-size: 20px; color: #eee; font-weight: 600; word-break: break-word; }+ .stat-sub { font-size: 11px; color: #555; margin-top: 4px; }++ .section { background: #101010; border: 1px solid #1f1f1f; border-radius: 10px; margin-bottom: 20px; }+ .section-head { padding: 14px 18px; border-bottom: 1px solid #1f1f1f; display: flex; align-items: center; gap: 12px; }+ .section-title { font-size: 14px; color: #eee; font-weight: 500; }+ .section-body { padding: 0; }++ table { width: 100%; border-collapse: collapse; font-size: 13px; }+ th { text-align: left; padding: 10px 16px; color: #555; font-weight: 500; border-bottom: 1px solid #1b1b1b; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }+ td { padding: 10px 16px; border-bottom: 1px solid #121212; color: #aaa; vertical-align: middle; }+ tr:last-child td { border-bottom: none; }+ tbody tr:hover td { background: #121212; }++ .badge { display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 500; }+ .badge-ok { background: rgba(20,241,149,.12); color: #14f195; }+ .badge-warn { background: rgba(255,180,0,.12); color: #ffb400; }+ .badge-err { background: rgba(255,70,70,.15); color: #ff6060; }+ .badge-muted { background: #1b1b1b; color: #888; }+ .badge-net { background: rgba(153,69,255,.14); color: #b98cff; }++ .controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }+ input[type=text], input[type=number], select, textarea {+ padding: 8px 12px; background: #0c0c0c; border: 1px solid #2b2b2b; border-radius: 7px;+ color: #eee; font-size: 13px; outline: none; font-family: inherit;+ }+ input:focus, select:focus, textarea:focus { border-color: var(--accent); }+ .btn { padding: 8px 16px; border: 0; border-radius: 7px; font-size: 13px; font-weight: 500; cursor: pointer; transition: opacity .15s, transform .05s; }+ .btn:active { transform: translateY(1px); }+ .btn-primary { background: var(--accent); color: #062; }+ .btn-ghost { background: #1a1a1a; color: #ccc; border: 1px solid #2b2b2b; }+ .btn-sm { padding: 5px 12px; font-size: 12px; }+ .btn:disabled { opacity: .45; cursor: default; }++ .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 14px; padding: 18px; }+ .field { display: flex; flex-direction: column; gap: 5px; }+ .field label { font-size: 11px; color: #777; text-transform: uppercase; letter-spacing: .05em; }+ .field .hint { font-size: 11px; color: #555; }+ .field.full { grid-column: 1 / -1; }+ .form-actions { padding: 0 18px 18px; display: flex; gap: 10px; align-items: center; }++ .empty { padding: 36px 18px; text-align: center; color: #666; font-size: 13px; }+ .empty strong { color: #aaa; display: block; margin-bottom: 6px; font-size: 14px; }+ .spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #333; border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }+ @keyframes spin { to { transform: rotate(360deg); } }++ .banner { border-radius: 9px; padding: 12px 16px; font-size: 13px; margin-bottom: 20px; display: flex; gap: 10px; align-items: flex-start; }+ .banner-warn { background: rgba(255,180,0,.08); border: 1px solid rgba(255,180,0,.25); color: #e8c477; }+ .banner-info { background: rgba(20,241,149,.06); border: 1px solid rgba(20,241,149,.2); color: #8fe7c0; }+ .banner code { color: inherit; background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 4px; }++ .msg { font-size: 13px; min-height: 18px; }+ .msg.ok { color: #14f195; }+ .msg.err { color: #ff6060; }++ .json-out { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; color: #9fd; background: #0c0c0c; border: 1px solid #1f1f1f; border-radius: 8px; padding: 14px; margin: 0 18px 18px; max-height: 360px; overflow: auto; }+ .mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; color: #8aa; }+ </style>+</head>+<body>+<div class="layout">+ <nav class="sidebar">+ <span class="sidebar-brand">Solana Platform</span>+ <span class="sidebar-sub">SDP · platform.solana.com</span>+ <a class="nav-item active" data-tab="overview" onclick="switchTab('overview')">Overview</a>+ <a class="nav-item" data-tab="wallets" onclick="switchTab('wallets')">Wallets</a>+ <a class="nav-item" data-tab="tokens" onclick="switchTab('tokens')">Token issuance</a>+ <a class="nav-item" data-tab="transfers" onclick="switchTab('transfers')">Payments</a>+ <a class="nav-item" data-tab="compliance" onclick="switchTab('compliance')">Compliance</a>+ <div class="nav-sep"></div>+ <a class="nav-item" href="/admin/">← Admin home</a>+ <a class="nav-item" href="/api/sdp/openapi.json" target="_blank" rel="noopener">API reference ↗</a>+ </nav>+ <main class="main">+ <div class="page-header">+ <span class="page-title" id="page-title">Overview</span>+ <span class="user-chip" id="user-chip"></span>+ </div>+ <div class="page-desc" id="page-desc"></div>+ <div id="tab"></div>+ </main>+</div>++<script type="module">+// All SDP traffic goes through the same-origin proxy at /api/sdp/* — the+// SDP_API_KEY never reaches the browser. Mutating calls rely on the SameSite+// session cookie + the proxy's same-origin guard (no CSRF token needed there);+// requireAdmin still gates every key-bearing route server-side.+const SDP = '/api/sdp';++async function sdpGet(path, query) {+ const qs = query ? '?' + new URLSearchParams(query) : '';+ const r = await fetch(`${SDP}/${path}${qs}`, { credentials: 'include' });+ return { status: r.status, body: await r.json().catch(() => null) };+}+async function sdpPost(path, body) {+ const r = await fetch(`${SDP}/${path}`, {+ method: 'POST', credentials: 'include',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify(body),+ });+ return { status: r.status, body: await r.json().catch(() => null) };+}++// SDP wraps successes as { data, meta } and errors as { error: { code, message } }.+const unwrap = (b) => (b && typeof b === 'object' && 'data' in b ? b.data : b);+const errOf = (b) => b?.error?.message || b?.error_description || b?.message || 'request failed';+function asList(body, key) {+ const u = unwrap(body);+ if (Array.isArray(u)) return u;+ if (u && Array.isArray(u[key])) return u[key];+ return [];+}++const esc = (s) => String(s ?? '').replace(/[&<>"]/g, (c) => ({ '&':'&','<':'<','>':'>','"':'"' }[c]));+const short = (a, n = 6) => (a ? `${a.slice(0, n)}…${a.slice(-4)}` : '—');+const fmtDate = (iso) => (iso ? new Date(iso).toLocaleString('en-US', { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }) : '—');+function statusBadge(s) {+ const v = String(s || '').toLowerCase();+ const cls = ['active','confirmed','finalized','completed','ok','ready','deployed'].includes(v) ? 'badge-ok'+ : ['pending','processing','draft','activating','settling','awaiting_payment','paused'].includes(v) ? 'badge-warn'+ : ['failed','expired','error'].includes(v) ? 'badge-err' : 'badge-muted';+ return `<span class="badge ${cls}">${esc(s || '—')}</span>`;+}+const el = () => document.getElementById('tab');+const loading = () => { el().innerHTML = '<div class="empty"><span class="spinner"></span></div>'; };+function configHint() {+ return `<div class="empty"><strong>Solana Developer Platform isn't configured</strong>+ Set <code>SDP_API_KEY</code> (and optionally <code>SDP_API_BASE</code>) in the deployment env to enable+ wallets, issuance, payments, and compliance. The health check below works without a key.</div>`;+}+function errBlock(status, body) {+ if (status === 503) return configHint();+ return `<div class="empty"><strong>Request failed (${status})</strong>${esc(errOf(body))}</div>`;+}++const state = { tab: 'overview', configured: null };++const DESCS = {+ overview: 'Connection health and configuration for the Solana Foundation enterprise platform — custodial wallets, SPL token issuance, payments, and compliance.',+ wallets: 'Custodial signing wallets managed by the configured provider (local, Fireblocks, Privy, Turnkey, Coinbase CDP, and others).',+ tokens: 'SPL / Token-2022 mints created and managed through the platform. Create here; deploy and mint from the platform dashboard.',+ transfers: 'On-chain SOL and SPL transfers, screened and executed by the platform.',+ compliance: 'Screen a Solana address against the platform\'s configured compliance providers before allowlisting or paying it.',+};++function switchTab(tab) {+ state.tab = tab;+ document.querySelectorAll('.nav-item[data-tab]').forEach((n) => n.classList.toggle('active', n.dataset.tab === tab));+ document.getElementById('page-title').textContent =+ { overview: 'Overview', wallets: 'Wallets', tokens: 'Token issuance', transfers: 'Payments', compliance: 'Compliance' }[tab];+ document.getElementById('page-desc').textContent = DESCS[tab];+ ({ overview: loadOverview, wallets: loadWallets, tokens: loadTokens, transfers: loadTransfers, compliance: loadCompliance }[tab])();+}+window.switchTab = switchTab;++// ── Overview ─────────────────────────────────────────────────────────────────+async function loadOverview() {+ loading();+ const health = await sdpGet('health');+ // Probe an authenticated route to learn whether the deployment has a key:+ // 503 => no SDP_API_KEY; 401/403 => admin/permission issue; 2xx => live.+ const probe = await sdpGet('v1/wallets', { pageSize: 1 });+ state.configured = probe.status !== 503;++ const h = unwrap(health.body) || {};+ const healthy = health.status >= 200 && health.status < 300;+ const cards = [+ card('Connection', healthy ? '<span class="badge badge-ok">reachable</span>' : '<span class="badge badge-err">unreachable</span>', h.timestamp ? fmtDate(h.timestamp) : ''),+ card('API key', state.configured ? '<span class="badge badge-ok">configured</span>' : '<span class="badge badge-warn">not set</span>', state.configured ? 'SDP_API_KEY present' : 'set SDP_API_KEY'),+ card('Status', esc(h.status || (healthy ? 'ok' : '—'))),+ card('Environment', esc(h.environment || '—'), h.version ? `v${esc(h.version)}` : ''),+ ];++ let banner = '';+ if (!state.configured) {+ banner = `<div class="banner banner-warn"><span>⚠</span><div>The platform API key isn't set, so wallet / issuance / payment / compliance routes return a designed <code>503</code>. Add <code>SDP_API_KEY</code> to the deployment env to go live. Health below confirms the upstream is reachable either way.</div></div>`;+ } else if (probe.status === 401 || probe.status === 403) {+ banner = `<div class="banner banner-warn"><span>⚠</span><div>The key is set, but this admin session can't read wallets (${probe.status}). Check the API key's scopes/permissions on the platform.</div></div>`;+ } else {+ banner = `<div class="banner banner-info"><span>✓</span><div>Live. Wallets, issuance, payments, and compliance are reachable under this origin.</div></div>`;+ }++ el().innerHTML = `${banner}<div class="stat-grid">${cards.join('')}</div>+ <div class="section">+ <div class="section-head"><span class="section-title">Raw health response</span></div>+ <div class="json-out">${esc(JSON.stringify(health.body, null, 2))}</div>+ </div>`;+}+function card(label, value, sub = '') {+ return `<div class="stat-card"><div class="stat-label">${label}</div><div class="stat-value">${value}</div>${sub ? `<div class="stat-sub">${sub}</div>` : ''}</div>`;+}++// ── Wallets ──────────────────────────────────────────────────────────────────+async function loadWallets() {+ loading();+ const res = await sdpGet('v1/wallets');+ if (res.status < 200 || res.status >= 300) { el().innerHTML = errBlock(res.status, res.body); return; }+ const wallets = asList(res.body, 'wallets');+ const rows = wallets.map((w) => `<tr>+ <td>${esc(w.label || '—')}</td>+ <td><code class="mono">${short(w.publicKey, 8)}</code></td>+ <td>${esc(w.provider || '—')}</td>+ <td>${esc(w.purpose || '—')}</td>+ <td>${statusBadge(w.status)}</td>+ <td class="mono">${fmtDate(w.createdAt)}</td>+ </tr>`).join('');++ el().innerHTML = `+ <div class="section">+ <div class="section-head"><span class="section-title">Create wallet</span></div>+ <div class="form-grid">+ <div class="field"><label>Provider</label>+ <select id="w-provider">+ <option value="">default (project)</option>+ <option value="local">local</option>+ <option value="fireblocks">fireblocks</option>+ <option value="privy">privy</option>+ <option value="turnkey">turnkey</option>+ <option value="coinbase_cdp">coinbase_cdp</option>+ <option value="dfns">dfns</option>+ <option value="anchorage">anchorage</option>+ <option value="para">para</option>+ <option value="utila">utila</option>+ </select>+ </div>+ <div class="field"><label>Label</label><input type="text" id="w-label" maxlength="100" placeholder="Treasury" /></div>+ <div class="field"><label>Purpose</label>+ <select id="w-purpose">+ <option value="">—</option>+ <option value="root">root</option>+ <option value="mint_authority">mint_authority</option>+ <option value="freeze_authority">freeze_authority</option>+ <option value="fee_payer">fee_payer</option>+ <option value="transfer">transfer</option>+ </select>+ </div>+ </div>+ <div class="form-actions">+ <button class="btn btn-primary" id="w-create">Create wallet</button>+ <span class="msg" id="w-msg"></span>+ </div>+ </div>+ <div class="section">+ <div class="section-head"><span class="section-title">Wallets</span><span class="badge badge-muted" style="margin-left:auto">${wallets.length}</span></div>+ <div class="section-body">${+ rows ? `<table><thead><tr><th>Label</th><th>Public key</th><th>Provider</th><th>Purpose</th><th>Status</th><th>Created</th></tr></thead><tbody>${rows}</tbody></table>`+ : '<div class="empty"><strong>No wallets yet</strong>Create your first custodial wallet above.</div>'+ }</div>+ </div>`;++ document.getElementById('w-create').onclick = async (e) => {+ const msg = document.getElementById('w-msg');+ const payload = {};+ const provider = document.getElementById('w-provider').value;+ const label = document.getElementById('w-label').value.trim();+ const purpose = document.getElementById('w-purpose').value;+ if (provider) payload.provider = provider;+ if (label) payload.label = label;+ if (purpose) payload.purpose = purpose;+ e.target.disabled = true; msg.className = 'msg'; msg.textContent = 'Creating…';+ const r = await sdpPost('v1/wallets', payload);+ e.target.disabled = false;+ if (r.status >= 200 && r.status < 300) { msg.className = 'msg ok'; msg.textContent = 'Created.'; setTimeout(loadWallets, 600); }+ else { msg.className = 'msg err'; msg.textContent = errOf(r.body); }+ };+}++// ── Token issuance ───────────────────────────────────────────────────────────+async function loadTokens() {+ loading();+ const res = await sdpGet('v1/issuance/tokens');+ if (res.status < 200 || res.status >= 300) { el().innerHTML = errBlock(res.status, res.body); return; }+ const tokens = asList(res.body, 'tokens');+ const rows = tokens.map((t) => `<tr>+ <td>${esc(t.name)} <span class="badge badge-muted">${esc(t.symbol)}</span></td>+ <td>${t.mintAddress ? `<code class="mono">${short(t.mintAddress, 8)}</code>` : '<span style="color:#555">undeployed</span>'}</td>+ <td>${esc(t.template || 'custom')}</td>+ <td class="mono">${esc(t.decimals)}</td>+ <td>${esc(t.totalSupply ?? '0')}${t.maxSupply ? ` / ${esc(t.maxSupply)}` : ''}</td>+ <td>${statusBadge(t.status)}</td>+ </tr>`).join('');++ el().innerHTML = `+ <div class="section">+ <div class="section-head"><span class="section-title">Create token</span></div>+ <div class="form-grid">+ <div class="field"><label>Name</label><input type="text" id="t-name" maxlength="100" placeholder="US Dollar Coin" /></div>+ <div class="field"><label>Symbol</label><input type="text" id="t-symbol" maxlength="10" placeholder="USDC" /></div>+ <div class="field"><label>Template</label>+ <select id="t-template">+ <option value="stablecoin">stablecoin</option>+ <option value="arcade">arcade</option>+ <option value="tokenized-security">tokenized-security</option>+ <option value="custom" selected>custom</option>+ </select>+ </div>+ <div class="field"><label>Decimals</label><input type="number" id="t-decimals" min="0" max="18" placeholder="6" /></div>+ <div class="field full"><label>Description <span class="hint">optional</span></label><input type="text" id="t-desc" maxlength="500" placeholder="What this token represents" /></div>+ </div>+ <div class="form-actions">+ <button class="btn btn-primary" id="t-create">Create token</button>+ <span class="msg" id="t-msg"></span>+ </div>+ </div>+ <div class="section">+ <div class="section-head"><span class="section-title">Tokens</span><span class="badge badge-muted" style="margin-left:auto">${tokens.length}</span></div>+ <div class="section-body">${+ rows ? `<table><thead><tr><th>Token</th><th>Mint</th><th>Template</th><th>Decimals</th><th>Supply</th><th>Status</th></tr></thead><tbody>${rows}</tbody></table>`+ : '<div class="empty"><strong>No tokens yet</strong>Create a token above, then deploy and mint from the platform dashboard.</div>'+ }</div>+ </div>`;++ document.getElementById('t-create').onclick = async (e) => {+ const msg = document.getElementById('t-msg');+ const name = document.getElementById('t-name').value.trim();+ const symbol = document.getElementById('t-symbol').value.trim();+ if (!name || !symbol) { msg.className = 'msg err'; msg.textContent = 'Name and symbol are required.'; return; }+ const payload = { name, symbol, template: document.getElementById('t-template').value };+ const dec = document.getElementById('t-decimals').value;+ const desc = document.getElementById('t-desc').value.trim();+ if (dec !== '') payload.decimals = Number(dec);+ if (desc) payload.description = desc;+ e.target.disabled = true; msg.className = 'msg'; msg.textContent = 'Creating…';+ const r = await sdpPost('v1/issuance/tokens', payload);+ e.target.disabled = false;+ if (r.status >= 200 && r.status < 300) { msg.className = 'msg ok'; msg.textContent = 'Created.'; setTimeout(loadTokens, 600); }+ else { msg.className = 'msg err'; msg.textContent = errOf(r.body); }+ };+}++// ── Payments / transfers ──────────────────────────────────────────────────────+async function loadTransfers() {+ loading();+ const res = await sdpGet('v1/payments/transfers', { pageSize: 25 });+ if (res.status < 200 || res.status >= 300) { el().innerHTML = errBlock(res.status, res.body); return; }+ const transfers = asList(res.body, 'transfers');+ const rows = transfers.map((t) => `<tr>+ <td><code class="mono">${esc(t.id)}</code></td>+ <td>${esc(t.direction || '—')}</td>+ <td><code class="mono">${short(t.destination, 6)}</code></td>+ <td>${esc(t.amount ?? '—')} ${esc(t.token === 'So11111111111111111111111111111111111111112' ? 'SOL' : (t.token ? short(t.token, 4) : ''))}</td>+ <td>${statusBadge(t.status)}</td>+ <td>${t.signature ? `<a class="mono" href="https://solscan.io/tx/${esc(t.signature)}" target="_blank" rel="noopener">${short(t.signature, 6)} ↗</a>` : '<span style="color:#555">—</span>'}</td>+ <td class="mono">${fmtDate(t.createdAt)}</td>+ </tr>`).join('');++ el().innerHTML = `+ <div class="section">+ <div class="section-head"><span class="section-title">New transfer</span></div>+ <div class="form-grid">+ <div class="field"><label>Source wallet ID</label><input type="text" id="x-source" placeholder="wal_… or public key" /></div>+ <div class="field"><label>Destination address</label><input type="text" id="x-dest" placeholder="base58 Solana address" /></div>+ <div class="field"><label>Token</label><input type="text" id="x-token" value="SOL" placeholder="SOL or mint address" /></div>+ <div class="field"><label>Amount</label><input type="text" id="x-amount" placeholder="1.5" /></div>+ <div class="field full"><label>Memo <span class="hint">optional</span></label><input type="text" id="x-memo" maxlength="256" /></div>+ </div>+ <div class="form-actions">+ <button class="btn btn-primary" id="x-create">Send transfer</button>+ <span class="msg" id="x-msg"></span>+ </div>+ </div>+ <div class="section">+ <div class="section-head"><span class="section-title">Recent transfers</span><span class="badge badge-muted" style="margin-left:auto">${transfers.length}</span></div>+ <div class="section-body">${+ rows ? `<table><thead><tr><th>ID</th><th>Dir</th><th>Destination</th><th>Amount</th><th>Status</th><th>Signature</th><th>Created</th></tr></thead><tbody>${rows}</tbody></table>`+ : '<div class="empty"><strong>No transfers yet</strong>Send your first transfer above.</div>'+ }</div>+ </div>`;++ document.getElementById('x-create').onclick = async (e) => {+ const msg = document.getElementById('x-msg');+ const source = document.getElementById('x-source').value.trim();+ const destination = document.getElementById('x-dest').value.trim();+ const token = document.getElementById('x-token').value.trim();+ const amount = document.getElementById('x-amount').value.trim();+ const memo = document.getElementById('x-memo').value.trim();+ if (!source || !destination || !token || !amount) { msg.className = 'msg err'; msg.textContent = 'Source, destination, token, and amount are required.'; return; }+ const payload = { source, destination, token, amount };+ if (memo) payload.memo = memo;+ e.target.disabled = true; msg.className = 'msg'; msg.textContent = 'Submitting…';+ const r = await sdpPost('v1/payments/transfers', payload);+ e.target.disabled = false;+ if (r.status >= 200 && r.status < 300) { msg.className = 'msg ok'; msg.textContent = 'Submitted.'; setTimeout(loadTransfers, 800); }+ else { msg.className = 'msg err'; msg.textContent = errOf(r.body); }+ };+}++// ── Compliance ────────────────────────────────────────────────────────────────+async function loadCompliance() {+ el().innerHTML = `+ <div class="section">+ <div class="section-head"><span class="section-title">Screen an address</span></div>+ <div class="form-grid">+ <div class="field full"><label>Solana address</label><input type="text" id="c-addr" placeholder="base58 address to screen" /></div>+ <div class="field"><label>Network</label><input type="text" id="c-net" value="solana" /></div>+ <div class="field"><label>Intent</label>+ <select id="c-intent">+ <option value="unknown" selected>unknown</option>+ <option value="transfer_destination">transfer_destination</option>+ <option value="wallet_address_addition">wallet_address_addition</option>+ </select>+ </div>+ </div>+ <div class="form-actions">+ <button class="btn btn-primary" id="c-run">Screen address</button>+ <span class="msg" id="c-msg"></span>+ </div>+ <div id="c-result"></div>+ </div>`;++ document.getElementById('c-run').onclick = async (e) => {+ const msg = document.getElementById('c-msg');+ const out = document.getElementById('c-result');+ const address = document.getElementById('c-addr').value.trim();+ if (!address) { msg.className = 'msg err'; msg.textContent = 'Enter an address.'; return; }+ const payload = { address, network: document.getElementById('c-net').value.trim() || 'solana', intent: document.getElementById('c-intent').value };+ e.target.disabled = true; msg.className = 'msg'; msg.textContent = 'Screening…'; out.innerHTML = '';+ const r = await sdpPost('v1/compliance/address-screenings', payload);+ e.target.disabled = false;+ if (r.status >= 200 && r.status < 300) {+ msg.className = 'msg ok'; msg.textContent = 'Done.';+ const screening = unwrap(r.body)?.screening || unwrap(r.body);+ const providers = screening?.providers || [];+ const provRows = (Array.isArray(providers) ? providers : []).map((p) => `<tr>+ <td>${esc(p.provider || p.name || '—')}</td>+ <td>${statusBadge(p.decision || p.result || p.status)}</td>+ <td class="mono">${esc(p.risk ?? p.riskScore ?? p.score ?? '—')}</td>+ <td>${esc((p.categories || p.flags || []).join?.(', ') || '—')}</td>+ </tr>`).join('');+ out.innerHTML = provRows+ ? `<table style="margin:0 0 4px"><thead><tr><th>Provider</th><th>Decision</th><th>Risk</th><th>Categories</th></tr></thead><tbody>${provRows}</tbody></table>+ <div class="json-out">${esc(JSON.stringify(r.body, null, 2))}</div>`+ : `<div class="json-out">${esc(JSON.stringify(r.body, null, 2))}</div>`;+ } else if (r.status === 503) {+ msg.className = 'msg'; msg.textContent = '';+ out.innerHTML = configHint();+ } else {+ msg.className = 'msg err'; msg.textContent = errOf(r.body);+ }+ };+}++// ── Auth guard ────────────────────────────────────────────────────────────────+async function boot() {+ // Server-side requireAdmin is the real gate (env-list admins may not carry+ // is_admin in the user object yet still pass on the API). Here we only bounce+ // signed-out visitors; the proxy returns 401/403 for non-admins and the+ // overview banner surfaces that clearly.+ const me = await fetch('/api/auth/me', { credentials: 'include' }).then((r) => r.ok ? r.json() : null).catch(() => null);+ if (!me?.user) { location.replace('/login?next=/admin/sdp'); return; }+ document.getElementById('user-chip').textContent = me.user.display_name || me.user.email || '';+ switchTab('overview');+}+boot();+</script>+<script src="/brand.js" defer></script>+</body>+</html>diff --git a/tests/api-sdp-client.test.js b/tests/api-sdp-client.test.jsindex f5d70a603..4bccfc321 100644--- a/tests/api-sdp-client.test.js+++ b/tests/api-sdp-client.test.js@@ -62,8 +62,8 @@ describe('path allowlist', () => {'v1/wallets','v1/wallets/abc-123','v1/issuance',- 'v1/payments',- 'v1/compliance/screen',+ 'v1/payments/transfers',+ 'v1/compliance/address-screenings','v1/projects',]) {expect(isSdpAllowedPath(p), p).toBe(true);diff --git a/vercel.json b/vercel.jsonindex 5a7415204..d01a5caf1 100644--- a/vercel.json+++ b/vercel.json@@ -74,14 +74,15 @@"headers": {"strict-transport-security": "max-age=63072000; includeSubDomains; preload","x-content-type-options": "nosniff",- "referrer-policy": "strict-origin-when-cross-origin"+ "referrer-policy": "strict-origin-when-cross-origin",+ "content-security-policy": "base-uri 'self'; object-src 'none'"},"continue": true},{"src": "/(login|register|forgot-password|reset-password|account|settings|wallet|pay|paywall|vanity-wallet|eth-vanity|evm-wallet|dashboard|dashboard-next|dashboard-classic)(/.*)?$","headers": {- "content-security-policy": "frame-ancestors 'self'",+ "content-security-policy": "frame-ancestors 'self'; base-uri 'self'; object-src 'none'","x-frame-options": "SAMEORIGIN"},"continue": true@@ -498,6 +499,10 @@"src": "/admin/bulk-launch/?","dest": "/bulk-launch.html"},+ {+ "src": "/admin/sdp/?",+ "dest": "/admin/sdp.html"+ },{"src": "/pump-dashboard/?","dest": "/pump-dashboard.html"@@ -579,7 +584,7 @@{"src": "/walk-embed/?","headers": {- "content-security-policy": "frame-ancestors *",+ "content-security-policy": "frame-ancestors *; base-uri 'self'; object-src 'none'","x-content-type-options": "nosniff","referrer-policy": "strict-origin-when-cross-origin","cross-origin-resource-policy": "cross-origin"@@ -696,7 +701,7 @@{"src": "/embed/avatar","headers": {- "content-security-policy": "frame-ancestors *",+ "content-security-policy": "frame-ancestors *; base-uri 'self'; object-src 'none'","x-content-type-options": "nosniff","referrer-policy": "strict-origin-when-cross-origin","permissions-policy": "microphone=(self), camera=(self), xr-spatial-tracking=*",@@ -707,7 +712,7 @@{"src": "/embed/avatar/([a-z0-9_-]{3,30})","headers": {- "content-security-policy": "frame-ancestors *",+ "content-security-policy": "frame-ancestors *; base-uri 'self'; object-src 'none'","x-content-type-options": "nosniff","referrer-policy": "strict-origin-when-cross-origin","permissions-policy": "microphone=(self), camera=(self), xr-spatial-tracking=*",@@ -742,7 +747,7 @@{"src": "/widget","headers": {- "content-security-policy": "frame-ancestors *",+ "content-security-policy": "frame-ancestors *; base-uri 'self'; object-src 'none'","x-content-type-options": "nosniff","referrer-policy": "strict-origin-when-cross-origin","permissions-policy": "microphone=(self), camera=(self), xr-spatial-tracking=*, autoplay=*",@@ -753,7 +758,7 @@{"src": "/widget/","headers": {- "content-security-policy": "frame-ancestors *",+ "content-security-policy": "frame-ancestors *; base-uri 'self'; object-src 'none'","x-content-type-options": "nosniff","referrer-policy": "strict-origin-when-cross-origin","permissions-policy": "microphone=(self), camera=(self), xr-spatial-tracking=*, autoplay=*",@@ -764,7 +769,7 @@{"src": "/widget\\.html$","headers": {- "content-security-policy": "frame-ancestors *",+ "content-security-policy": "frame-ancestors *; base-uri 'self'; object-src 'none'","x-content-type-options": "nosniff","referrer-policy": "strict-origin-when-cross-origin","permissions-policy": "microphone=(self), camera=(self), xr-spatial-tracking=*, autoplay=*",@@ -1915,7 +1920,7 @@{"src": "/agent/([^/]+)/embed","headers": {- "content-security-policy": "frame-ancestors *",+ "content-security-policy": "frame-ancestors *; base-uri 'self'; object-src 'none'","x-content-type-options": "nosniff","referrer-policy": "strict-origin-when-cross-origin","permissions-policy": "microphone=(self), camera=(self), xr-spatial-tracking=*",@@ -2851,7 +2856,7 @@{"src": "/a/(\\d+)/(\\d+)/embed","headers": {- "content-security-policy": "frame-ancestors *",+ "content-security-policy": "frame-ancestors *; base-uri 'self'; object-src 'none'","x-content-type-options": "nosniff","referrer-policy": "strict-origin-when-cross-origin","permissions-policy": "microphone=(self), camera=(self), xr-spatial-tracking=*"