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
fix(vanity): keep the certificate and OG routes in step with the drop lifecycle
nirholasfa22f2e2a5a8
diff --git a/api/vanity/cert.js b/api/vanity/cert.jsindex 81f155f44..6172e65f1 100644--- a/api/vanity/cert.js+++ b/api/vanity/cert.js@@ -34,7 +34,10 @@ export default wrap(async (req, res) => {const url = new URL(req.url, 'http://x');const address = (url.searchParams.get('address') || '').trim();- const id = (url.searchParams.get('id') || '').trim();+ // certIds are lowercase hex by construction (deriveCertId), and the registry+ // indexes them verbatim, so an uppercase paste has to be folded down here or the+ // exact-match lookup misses a certificate that is genuinely registered.+ const id = (url.searchParams.get('id') || '').trim().toLowerCase();if (!address && !id) {return error(res, 400, 'missing_param', 'supply ?address=<base58> or ?id=<certId>');@@ -53,16 +56,34 @@ export default wrap(async (req, res) => {return error(res, 502, 'registry_error', err.message);}+ // An id lookup resolves certId → address → the address's CANONICAL record, so a+ // duplicate certificate still finds a record: the one that beat it. Answering+ // "found" alone would let a re-sold duplicate read as the original, which is the+ // exact question this endpoint exists to settle. `queriedIsCanonical` compares+ // the certId that was asked about against the canonical record's own certId.+ const queriedIsCanonical = record && id ? record.certId === id : null;+return json(res,200,{found: !!record,canonical: record || null,- note: record- ? 'This is the canonical (first-issued) proof-of-grind certificate for this address. A certificate with a different certId for the same address is a duplicate/re-sale and is not fresh.'- : 'No certificate is registered for this address. The certificate may still verify offline, but its single-issuance freshness cannot be confirmed by the registry.',+ ...(id ? { queriedCertId: id, queriedIsCanonical } : {}),+ note: certNote({ record, byId: !!id, queriedIsCanonical }),},{ 'cache-control': 'public, max-age=30' },);});++function certNote({ record, byId, queriedIsCanonical }) {+ if (!record) {+ return byId+ ? 'No certificate with that certId is registered. The certificate may still verify offline, but its single-issuance freshness cannot be confirmed by the registry.'+ : 'No certificate is registered for this address. The certificate may still verify offline, but its single-issuance freshness cannot be confirmed by the registry.';+ }+ if (byId && !queriedIsCanonical) {+ return 'The certId you asked about is NOT the canonical certificate for this address. An earlier certificate (returned here) was registered first, so the one you hold is a duplicate/re-sale and is not fresh.';+ }+ return 'This is the canonical (first-issued) proof-of-grind certificate for this address. A certificate with a different certId for the same address is a duplicate/re-sale and is not fresh.';+}diff --git a/api/vanity/drops.js b/api/vanity/drops.jsindex 1acd5aab7..21c0828e0 100644--- a/api/vanity/drops.js+++ b/api/vanity/drops.js@@ -401,7 +401,7 @@ async function rollbackFunding({ record, secretKey, reason }) {// ── POST: create (x402-paid → grind → seal → fund → persist) ─────────────────-async function handleCreate(req, res, url) {+async function handleCreate(req, res) {let body;try {body = await readJson(req);@@ -953,7 +953,7 @@ export default wrap(async (req, res) => {if (req.method === 'POST') {const action = (url.searchParams.get('action') || 'create').toLowerCase();- if (action === 'create') return handleCreate(req, res, url);+ if (action === 'create') return handleCreate(req, res);if (action === 'claim') return handleClaim(req, res);if (action === 'reveal') return handleReveal(req, res);if (action === 'reclaim') return handleReclaim(req, res);diff --git a/api/vanity/og.js b/api/vanity/og.jsindex 7e7d2f5b6..4d0def1a1 100644--- a/api/vanity/og.js+++ b/api/vanity/og.js@@ -13,6 +13,7 @@// No secrets are read or rendered — only the public address + rarity math.import { ImageResponse } from '@vercel/og';+import { limits, clientIp } from '../_lib/rate-limit.js';import { getEntry } from '../_lib/vanity-gallery-store.js';import { appraiseAddress, RARITY_TIERS } from '../../src/solana/vanity/rarity.js';@@ -74,7 +75,7 @@ function statPill(label, value, accent) {};}-function card({ address, pattern, tier, rarityScore, expectedAttempts, mode, bonuses }) {+function card({ address, pattern, tier, rarityScore, expectedAttempts, mode }) {const t = tierMeta(tier);const accent = t.accent;const patternLabel = [pattern?.prefix && `${pattern.prefix}…`, pattern?.suffix && `…${pattern.suffix}`].filter(Boolean).join(' ') || 'no fixed pattern';@@ -163,15 +164,17 @@ export default async function handler(req, res) {return;}+ // Each card is a store read plus a real PNG render, and the CDN only absorbs+ // repeats of the SAME address, so a walk over made-up addresses would render one+ // image per request. Cap it per IP. On the cap we fall back to the static share+ // image rather than a 429 body: a crawler that got a card is what matters, and+ // no-cache means the next request renders the real one.+ const rl = await limits.publicIp(clientIp(req));+ if (!rl.success) return fallbackCard(res);+const url = new URL(req.url, `http://${req.headers.host || 'x'}`);const address = (url.searchParams.get('address') || '').trim();- if (!BASE58_RE.test(address)) {- res.statusCode = 302;- res.setHeader('location', 'https://three.ws/og-image.png');- res.setHeader('cache-control', 'no-cache');- res.end();- return;- }+ if (!BASE58_RE.test(address)) return fallbackCard(res);try {const data = await loadCardData(address);@@ -189,9 +192,15 @@ export default async function handler(req, res) {res.end(Buffer.from(ab));} catch (err) {console.error('[vanity/og]', err?.message || err);- res.statusCode = 302;- res.setHeader('location', 'https://three.ws/og-image.png');- res.setHeader('cache-control', 'no-cache');- res.end();+ fallbackCard(res);}}++// Every path that cannot render a real card sends the crawler to the static site+// share image, uncached so the next attempt re-renders.+function fallbackCard(res) {+ res.statusCode = 302;+ res.setHeader('location', 'https://three.ws/og-image.png');+ res.setHeader('cache-control', 'no-cache');+ res.end();+}