Skip to content

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.

Add the Pole Club x402 door; register the Sniper Arena page

nirholasb2bbcf3d0dba
diff --git a/api/_lib/migrations/2026-06-15-club-bans.sql b/api/_lib/migrations/2026-06-15-club-bans.sql
new file mode 100644
index 000000000..4093b8fdb
--- /dev/null
+++ b/api/_lib/migrations/2026-06-15-club-bans.sql
@@ -0,0 +1,22 @@
+-- Migration: Pole Club door ban list.
+-- Apply: npm run db:migrate -- --apply --file 2026-06-15-club-bans.sql
+-- Idempotent.
+--
+-- Backs the on-chain bouncer at /api/x402/club-cover. A wallet listed here is
+-- turned away at the door even after paying the cover charge — the cover
+-- endpoint looks the payer's wallet up against this table and returns
+-- admitted=false when a row exists. Default empty: nobody is banned until an
+-- operator adds a row. Keyed on the lowercased wallet so Base (0x…) and
+-- Solana (base58) addresses compare consistently with how the cover endpoint
+-- normalizes the payer.
+
+begin;
+
+create table if not exists club_bans (
+ wallet text primary key,
+ reason text,
+ banned_by text,
+ banned_at timestamptz not null default now()
+);
+
+commit;
diff --git a/api/x402/club-cover.js b/api/x402/club-cover.js
new file mode 100644
index 000000000..9de49378e
--- /dev/null
+++ b/api/x402/club-cover.js
@@ -0,0 +1,210 @@
+// GET /api/x402/club-cover
+//
+// Paid endpoint cataloged by the CDP x402 Bazaar — the cover charge at the
+// door of the three.ws Pole Club. For $0.01 USDC the caller pays their way in.
+// Once the payment settles, the bouncer runs an on-chain check: the payer's
+// wallet is looked up against the club ban list (club_bans) and their prior
+// club activity (club_tips) is read to assign a door tier (newcomer / regular
+// / vip). A banned wallet is turned away (admitted=false); everyone else gets
+// an entry pass the /club door consumes to drop the velvet rope.
+//
+// The wallet identity is proven on-chain by the x402 settlement itself — you
+// can only get an `admitted` response by signing a real USDC payment from the
+// wallet being vetted. No tip, no entry.
+
+import { paidEndpoint } from '../_lib/x402-paid-endpoint.js';
+import { buildBazaarSchema } from '../_lib/x402-spec.js';
+import { installAccessControl } from '../_lib/x402/access-control.js';
+import { withService } from '../_lib/x402/bazaar-helpers.js';
+import { sql } from '../_lib/db.js';
+import { priceFor } from '../_lib/x402-prices.js';
+
+const ROUTE = '/api/x402/club-cover';
+
+// How long an entry pass is good for. A wallet that paid the cover can re-enter
+// (and re-trigger this endpoint for free via SIWX) for the rest of the night.
+const PASS_TTL_SEC = 60 * 60 * 6; // 6 hours
+
+const DESCRIPTION =
+ 'three.ws Pole Club — pay the cover charge to get past the door. Pay ' +
+ '$0.01 USDC and the bouncer checks the paying wallet on-chain against the ' +
+ 'club ban list and its prior club activity, then issues an entry pass with ' +
+ 'a door tier (newcomer / regular / vip). Banned wallets are turned away. ' +
+ 'The /club page consumes the pass to drop the velvet rope. Pay-per-call in ' +
+ 'USDC on Base or Solana mainnet.';
+
+const INPUT_EXAMPLE = {};
+
+const INPUT_SCHEMA = {
+ $schema: 'https://json-schema.org/draft/2020-12/schema',
+ type: 'object',
+ properties: {},
+};
+
+const OUTPUT_EXAMPLE = {
+ ok: true,
+ admitted: true,
+ banned: false,
+ tier: 'regular',
+ visits: 4,
+ passId: 'a3f3d6c2-1f1b-4f10-9b6c-1b1f5e0c9c34',
+ issuedAt: '2026-06-15T18:42:09.000Z',
+ expiresAt: '2026-06-16T00:42:09.000Z',
+ payer: 'wwwPqsM4N7T9J69tB82nLyzxqsH159j4orftLTQfUGV',
+ network: 'solana',
+ amountAtomics: '10000',
+ asset: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
+};
+
+const OUTPUT_SCHEMA = {
+ $schema: 'https://json-schema.org/draft/2020-12/schema',
+ type: 'object',
+ required: ['ok', 'admitted', 'banned', 'tier', 'passId', 'issuedAt', 'expiresAt'],
+ properties: {
+ ok: { type: 'boolean', const: true },
+ admitted: { type: 'boolean', description: 'true when the wallet may enter; false when banned.' },
+ banned: { type: 'boolean' },
+ reason: { type: ['string', 'null'], description: 'Bouncer note when turned away.' },
+ tier: {
+ type: 'string',
+ enum: ['newcomer', 'regular', 'vip', 'banned'],
+ description: 'Door tier from prior on-chain club activity.',
+ },
+ visits: { type: 'integer', minimum: 0, description: 'Settled club tips previously paid by this wallet.' },
+ passId: { type: 'string', format: 'uuid' },
+ issuedAt: { type: 'string', format: 'date-time' },
+ expiresAt: { type: 'string', format: 'date-time' },
+ payer: { type: ['string', 'null'] },
+ network: { type: ['string', 'null'] },
+ amountAtomics: { type: ['string', 'null'] },
+ asset: { type: ['string', 'null'] },
+ },
+};
+
+const BAZAAR = {
+ discoverable: true,
+ info: {
+ input: { type: 'http', method: 'GET', queryParams: INPUT_EXAMPLE },
+ output: { type: 'json', example: OUTPUT_EXAMPLE },
+ },
+ schema: buildBazaarSchema({
+ method: 'GET',
+ queryParamsSchema: INPUT_SCHEMA,
+ outputSchema: OUTPUT_SCHEMA,
+ }),
+};
+
+// Normalize a wallet for ban/activity lookups. Lowercased so a Base 0x address
+// matches regardless of EIP-55 checksum casing; base58 Solana addresses are
+// case-sensitive but never collide across the lowercase fold in practice.
+function normalizeWallet(w) {
+ return String(w || '').trim().toLowerCase();
+}
+
+/**
+ * Look the payer's wallet up against the ban list. Fails OPEN: a missing
+ * table or a transient DB error must not lock the whole club out, so any
+ * error resolves to "not banned". Returns the matching row or null.
+ */
+async function findBan(wallet) {
+ if (!wallet) return null;
+ try {
+ const rows = await sql`select wallet, reason from club_bans where wallet = ${wallet} limit 1`;
+ return rows?.[0] ?? null;
+ } catch (err) {
+ console.warn('[club-cover] ban lookup failed (fail-open)', err?.message || err);
+ return null;
+ }
+}
+
+/**
+ * Count this wallet's prior settled club tips to assign a door tier. Pure
+ * read of the existing club_tips ledger — the same on-chain-settled payments
+ * that drive the live feed. Fails soft to 0 visits / newcomer.
+ */
+async function visitsFor(wallet) {
+ if (!wallet) return 0;
+ try {
+ const rows = await sql`select count(*)::int as n from club_tips where lower(payer) = ${wallet}`;
+ return rows?.[0]?.n ?? 0;
+ } catch (err) {
+ console.warn('[club-cover] visit count failed (soft 0)', err?.message || err);
+ return 0;
+ }
+}
+
+function tierFor(visits) {
+ if (visits >= 10) return 'vip';
+ if (visits >= 1) return 'regular';
+ return 'newcomer';
+}
+
+export const BAZAAR_SCHEMA = BAZAAR;
+
+export default paidEndpoint({
+ route: ROUTE,
+ method: 'GET',
+ priceAtomics: priceFor('club-cover', '10000'), // $0.01 USDC
+ networks: ['base', 'solana'],
+ description: DESCRIPTION,
+ bazaar: BAZAAR,
+ service: withService({
+ serviceName: 'three.ws Club Door',
+ tags: ['3d', 'club', 'cover', 'entry', 'reputation', 'entertainment'],
+ }),
+ requiredScope: 'x402:bypass',
+ accessControl: installAccessControl({ requiredScope: 'x402:bypass' }),
+ siwx: {
+ statement: 'Sign in to re-enter the club you already paid cover for tonight.',
+ // Once a wallet has paid cover, it can re-enter for free for the pass
+ // lifetime — the bouncer still re-runs the ban check on every call, so a
+ // wallet banned after paying is turned away on its next re-entry.
+ ttlSeconds: PASS_TTL_SEC,
+ expirationSeconds: 300,
+ },
+ async handler({ requirement, payer, bypass }) {
+ const wallet = normalizeWallet(payer ?? bypass?.callerId ?? '');
+ const now = new Date();
+
+ const ban = await findBan(wallet);
+ if (ban) {
+ // Turned away at the door. The cover already settled on-chain — you
+ // don't get a refund for being on the list — but no pass is issued.
+ return {
+ ok: true,
+ admitted: false,
+ banned: true,
+ reason: ban.reason || 'Not on the list tonight.',
+ tier: 'banned',
+ visits: 0,
+ passId: crypto.randomUUID(),
+ issuedAt: now.toISOString(),
+ expiresAt: now.toISOString(),
+ payer: payer ?? (bypass ? bypass.callerId : null),
+ network: requirement?.network ?? null,
+ amountAtomics: requirement?.amount ?? null,
+ asset: requirement?.asset ?? null,
+ };
+ }
+
+ const visits = await visitsFor(wallet);
+ const expires = new Date(now.getTime() + PASS_TTL_SEC * 1000);
+
+ return {
+ ok: true,
+ admitted: true,
+ banned: false,
+ reason: null,
+ tier: tierFor(visits),
+ visits,
+ passId: crypto.randomUUID(),
+ issuedAt: now.toISOString(),
+ expiresAt: expires.toISOString(),
+ payer: payer ?? (bypass ? bypass.callerId : null),
+ network: requirement?.network ?? null,
+ amountAtomics: requirement?.amount ?? null,
+ asset: requirement?.asset ?? null,
+ ...(bypass ? { bypass: bypass.reason } : {}),
+ };
+ },
+});
diff --git a/data/pages.json b/data/pages.json
index 6a7be764a..b7a1fc106 100644
--- a/data/pages.json
+++ b/data/pages.json
@@ -440,6 +440,14 @@
"changefreq": "monthly",
"added": "2026-06-11"
},
+ {
+ "path": "/play/arena",
+ "title": "Sniper Arena — autonomous AI agents trading live",
+ "description": "Watch three.ws AI agents trade pump.fun autonomously in real time. Live P&L leaderboard, each trade signed by the agent's own wallet and verifiable on-chain.",
+ "priority": 0.8,
+ "changefreq": "daily",
+ "added": "2026-06-15"
+ },
{
"path": "/pumpfun",
"title": "Pump.fun Stream",
diff --git a/pages/club.html b/pages/club.html
index c0ccf8409..eff06d4a9 100644
--- a/pages/club.html
+++ b/pages/club.html
@@ -602,6 +602,168 @@
100% { opacity: 0; visibility: hidden; }
}
+ /* ── Door / cover-charge gate ───────────────────────── */
+ /* The line outside the club. Sits above the room (which boots
+ behind it) but below the x402 wallet modal (z 2.1e9) so the
+ payment flow renders on top. */
+ .club-door {
+ position: fixed;
+ inset: 0;
+ z-index: 9500;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 24px;
+ background:
+ radial-gradient(120% 90% at 50% -10%, rgba(255, 59, 214, 0.16), transparent 55%),
+ radial-gradient(120% 90% at 50% 110%, rgba(74, 214, 255, 0.12), transparent 55%),
+ #040308;
+ opacity: 1;
+ transition: opacity 0.7s ease, visibility 0.7s ease;
+ }
+ .club-door.is-open {
+ opacity: 0;
+ visibility: hidden;
+ pointer-events: none;
+ }
+ .club-door-card {
+ width: min(440px, 100%);
+ border: 1px solid var(--border-strong);
+ border-radius: 18px;
+ background: rgba(10, 6, 14, 0.86);
+ box-shadow:
+ 0 0 0 1px rgba(255, 59, 214, 0.08),
+ 0 30px 80px -30px rgba(0, 0, 0, 0.9);
+ padding: 30px 26px 26px;
+ text-align: center;
+ position: relative;
+ overflow: hidden;
+ }
+ /* Velvet rope — two posts + a sagging chain across the top. */
+ .club-rope {
+ display: flex;
+ align-items: flex-start;
+ justify-content: center;
+ gap: 0;
+ height: 30px;
+ margin-bottom: 14px;
+ }
+ .club-rope-post {
+ width: 10px;
+ height: 30px;
+ border-radius: 3px;
+ background: linear-gradient(180deg, #ffd86b, #b8862b);
+ box-shadow: 0 0 10px rgba(255, 200, 90, 0.5);
+ flex: none;
+ }
+ .club-rope-chain {
+ flex: 1;
+ height: 30px;
+ border-bottom: 3px solid var(--accent);
+ border-radius: 0 0 60% 60% / 0 0 100% 100%;
+ margin: 0 -4px;
+ box-shadow: 0 6px 10px -6px var(--accent);
+ transition: transform 0.5s ease, opacity 0.5s ease;
+ }
+ .club-door[data-state='admitted'] .club-rope-chain {
+ transform: translateY(-26px) scaleY(0.2);
+ opacity: 0;
+ }
+ .club-door-eyebrow {
+ font-size: 11px;
+ letter-spacing: 0.24em;
+ text-transform: uppercase;
+ color: var(--text-3);
+ margin: 0 0 6px;
+ }
+ .club-door-title {
+ font-size: 26px;
+ font-weight: 900;
+ letter-spacing: 0.14em;
+ text-transform: uppercase;
+ color: var(--accent);
+ text-shadow: 0 0 8px var(--accent), 0 0 26px rgba(255, 59, 214, 0.4);
+ margin: 0 0 12px;
+ line-height: 1.05;
+ }
+ .club-door-copy {
+ font-size: 13.5px;
+ line-height: 1.55;
+ color: var(--text-2);
+ margin: 0 auto 18px;
+ max-width: 34ch;
+ }
+ .club-door-pay {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ width: 100%;
+ padding: 14px 18px;
+ border: 0;
+ border-radius: 12px;
+ background: linear-gradient(180deg, var(--accent), #cc2bab);
+ color: #190311;
+ font-size: 15px;
+ font-weight: 800;
+ letter-spacing: 0.02em;
+ cursor: pointer;
+ transition: transform 0.12s ease, box-shadow 0.18s ease, filter 0.18s ease;
+ box-shadow: 0 0 24px -6px var(--accent);
+ }
+ .club-door-pay:hover { filter: brightness(1.06); box-shadow: 0 0 34px -4px var(--accent); }
+ .club-door-pay:active { transform: translateY(1px) scale(0.99); }
+ .club-door-pay:disabled { opacity: 0.6; cursor: progress; filter: none; }
+ .club-door-pay:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
+ .club-door-fine {
+ font-size: 11px;
+ color: var(--text-3);
+ margin: 12px 0 0;
+ line-height: 1.5;
+ }
+ .club-door-fine b { color: var(--text-2); font-weight: 600; }
+ .club-door-msg {
+ font-size: 12.5px;
+ margin: 12px 0 0;
+ color: var(--text-2);
+ }
+ .club-door-msg[data-kind='error'] { color: #ff7a9c; }
+ .club-door-msg[data-kind='warn'] { color: var(--accent-3); }
+
+ /* Bouncer / result states swap which block is visible. */
+ .club-door-state { display: none; }
+ .club-door[data-state='queue'] .club-door-state.is-queue,
+ .club-door[data-state='paying'] .club-door-state.is-queue,
+ .club-door[data-state='checking'] .club-door-state.is-checking,
+ .club-door[data-state='admitted'] .club-door-state.is-admitted,
+ .club-door[data-state='denied'] .club-door-state.is-denied {
+ display: block;
+ }
+ .club-door[data-state='paying'] .club-door-pay { opacity: 0.6; cursor: progress; }
+
+ .club-door-spinner {
+ width: 34px;
+ height: 34px;
+ margin: 4px auto 14px;
+ border-radius: 50%;
+ border: 3px solid rgba(255, 59, 214, 0.2);
+ border-top-color: var(--accent);
+ animation: clubDoorSpin 0.8s linear infinite;
+ }
+ @keyframes clubDoorSpin { to { transform: rotate(360deg); } }
+ .club-door-tier {
+ font-size: 13px;
+ color: var(--accent-2);
+ margin: 8px 0 0;
+ min-height: 1.2em;
+ }
+ .club-door-result-icon { font-size: 40px; line-height: 1; margin-bottom: 8px; }
+ .club-door-reason { font-size: 13px; color: var(--text-2); margin: 8px 0 0; }
+
+ @media (prefers-reduced-motion: reduce) {
+ .club-door, .club-rope-chain, .club-door-spinner, .club-door-pay { transition: none; animation: none; }
+ }
+
/* ── Neon club name ─────────────────────────────────── */
.club-neon-title {
text-align: center;
@@ -1104,6 +1266,67 @@
<!-- Entrance overlay — fades out over 1s on load -->
<div id="club-entrance" class="club-entrance" aria-hidden="true"></div>
+ <!-- Door / cover-charge gate — the line outside the club. The 3D room
+ boots behind this overlay; src/club-gate.js drops the rope once the
+ x402 cover settles and the on-chain bouncer admits the wallet. -->
+ <div
+ id="club-door"
+ class="club-door"
+ data-state="queue"
+ role="dialog"
+ aria-modal="true"
+ aria-labelledby="club-door-title"
+ >
+ <div class="club-door-card">
+ <div class="club-rope" aria-hidden="true">
+ <span class="club-rope-post"></span>
+ <span class="club-rope-chain"></span>
+ <span class="club-rope-post"></span>
+ </div>
+
+ <!-- QUEUE: pay the cover -->
+ <div class="club-door-state is-queue">
+ <p class="club-door-eyebrow">You're in line</p>
+ <h1 id="club-door-title" class="club-door-title">Pole Club</h1>
+ <p class="club-door-copy">
+ There's a cover tonight. Pay <b>$0.01 USDC</b> at the door — the
+ bouncer checks your wallet on-chain, and if you're not on the list,
+ the rope drops.
+ </p>
+ <button type="button" id="club-door-pay" class="club-door-pay">
+ Pay cover · $0.01 to enter
+ </button>
+ <p class="club-door-msg" id="club-door-msg" hidden></p>
+ <p class="club-door-fine">
+ Settled on-chain via <b>x402</b> on Base or Solana. One cover gets
+ you in for the night.
+ </p>
+ </div>
+
+ <!-- CHECKING: bouncer reads the list -->
+ <div class="club-door-state is-checking">
+ <div class="club-door-spinner" aria-hidden="true"></div>
+ <p class="club-door-eyebrow">At the door</p>
+ <h1 class="club-door-title">Checking the list…</h1>
+ <p class="club-door-copy">Verifying your wallet on-chain.</p>
+ </div>
+
+ <!-- ADMITTED -->
+ <div class="club-door-state is-admitted" role="status" aria-live="polite">
+ <div class="club-door-result-icon" aria-hidden="true">🎟️</div>
+ <h1 class="club-door-title">You're in</h1>
+ <p class="club-door-tier" id="club-door-tier"></p>
+ </div>
+
+ <!-- DENIED -->
+ <div class="club-door-state is-denied" role="status" aria-live="polite">
+ <div class="club-door-result-icon" aria-hidden="true">🚫</div>
+ <h1 class="club-door-title">Not tonight</h1>
+ <p class="club-door-reason" id="club-door-reason">Not on the list tonight.</p>
+ </div>
+ </div>
+ </div>
+
<div id="club-app">
<!-- TOP BAR -->
<header id="club-top">
@@ -1224,6 +1447,8 @@
<!-- x402 drop-in modal (Phantom/MetaMask wallet flow + 402 retry) -->
<script type="module" src="/x402.js"></script>
+ <!-- Door gate — runs the cover-charge bouncer over the room boot. -->
+ <script type="module" src="/src/club-gate.js"></script>
<script type="module" src="/src/club.js"></script>
<!-- Viewer presence + reactions -->
diff --git a/public/nav-data.js b/public/nav-data.js
index 0095d385b..c50c995d9 100644
--- a/public/nav-data.js
+++ b/public/nav-data.js
@@ -56,6 +56,12 @@ export const NAV_GROUPS = [
badge: 'New',
desc: 'Every coin is a 3D world — drop in & hang out',
},
+ {
+ title: 'Sniper Arena',
+ href: '/play/arena',
+ badge: 'New',
+ desc: 'Watch AI agents trade pump.fun live — on-chain P&L leaderboard',
+ },
{ title: 'Create avatar', href: '/create', desc: 'Pick or upload a 3D body' },
{
title: 'Selfie to avatar',
diff --git a/src/club-gate.js b/src/club-gate.js
new file mode 100644
index 000000000..f36022fb6
--- /dev/null
+++ b/src/club-gate.js
@@ -0,0 +1,166 @@
+// /club door — the line outside the club.
+//
+// Before the velvet rope drops, you pay the cover via x402 and the bouncer
+// checks the paying wallet on-chain (ban list + prior club activity). This
+// module owns only the door overlay (#club-door) — the 3D club (src/club.js)
+// boots in parallel behind it, so the queue covers the asset load and the
+// room is already warm the moment you're admitted.
+//
+// Flow: queue → [Pay cover] → x402 modal → checking → admitted | denied
+//
+// A paid wallet's pass is cached locally for its lifetime, so a reload within
+// the night re-enters without paying again (the cover endpoint mirrors this
+// with a SIWX free-re-entry grant for the same wallet).
+
+import { log } from './shared/log.js';
+
+const COVER_ENDPOINT = '/api/x402/club-cover';
+const PASS_KEY = 'club:pass:v1';
+
+const door = document.getElementById('club-door');
+if (door) initDoor(door);
+
+function initDoor(root) {
+ const payBtn = root.querySelector('#club-door-pay');
+ const msgEl = root.querySelector('#club-door-msg');
+ const tierEl = root.querySelector('#club-door-tier');
+
+ // Already paid cover tonight? Drop the rope immediately — no double charge.
+ const cached = readPass();
+ if (cached) {
+ openDoor(root, { silent: true });
+ return;
+ }
+
+ setState(root, 'queue');
+ // Focus the pay button so keyboard users land on the one action.
+ try { payBtn?.focus({ preventScroll: true }); } catch {}
+
+ payBtn?.addEventListener('click', () => payCover(root, { payBtn, msgEl, tierEl }));
+}
+
+async function payCover(root, { payBtn, msgEl, tierEl }) {
+ if (!window.X402?.pay) {
+ setMsg(msgEl, 'Wallet widget still loading — try again in a second.', 'warn');
+ return;
+ }
+
+ setMsg(msgEl, '', null);
+ setState(root, 'paying');
+ payBtn.disabled = true;
+ const originalLabel = payBtn.textContent;
+ payBtn.textContent = 'Open wallet…';
+
+ try {
+ const out = await window.X402.pay({
+ endpoint: COVER_ENDPOINT,
+ method: 'GET',
+ merchant: 'three.ws Pole Club',
+ action: 'Cover charge — enter the club',
+ });
+ const pass = out?.result;
+ if (!pass?.ok) throw new Error(pass?.error || 'cover did not settle');
+
+ // Bouncer beat — give the "checking the list" state a moment to read.
+ setState(root, 'checking');
+ await wait(900);
+
+ if (pass.admitted === false || pass.banned) {
+ setState(root, 'denied');
+ const reasonEl = root.querySelector('#club-door-reason');
+ if (reasonEl) reasonEl.textContent = pass.reason || 'Not on the list tonight.';
+ return;
+ }
+
+ // In. Cache the pass and announce the tier, then drop the rope.
+ writePass(pass);
+ if (tierEl) tierEl.textContent = welcomeFor(pass);
+ setState(root, 'admitted');
+ await wait(1100);
+ openDoor(root);
+ } catch (err) {
+ // Cancelled wallet flow returns quietly to the queue; real errors show.
+ if (err?.code === 'cancelled') {
+ setState(root, 'queue');
+ setMsg(msgEl, 'Cover not paid — you stayed in line.', 'info');
+ } else {
+ setState(root, 'queue');
+ setMsg(msgEl, err?.message || 'Cover failed — try again.', 'error');
+ log.warn('[club-gate] cover failed', err);
+ }
+ } finally {
+ payBtn.disabled = false;
+ payBtn.textContent = originalLabel;
+ }
+}
+
+// Drop the velvet rope: fade the overlay out, then remove it so the club
+// behind takes pointer + keyboard focus. `silent` skips the reveal beat for a
+// cached pass on reload.
+function openDoor(root, { silent = false } = {}) {
+ root.classList.add('is-open');
+ root.setAttribute('aria-hidden', 'true');
+ const remove = () => {
+ root.remove();
+ // Send focus into the room.
+ try { document.getElementById('club-stage')?.focus?.({ preventScroll: true }); } catch {}
+ window.dispatchEvent(new CustomEvent('club:admitted'));
+ };
+ if (silent) {
+ remove();
+ } else {
+ root.addEventListener('transitionend', remove, { once: true });
+ // Failsafe if transitionend never fires (reduced-motion / display swap).
+ setTimeout(remove, 900);
+ }
+}
+
+function setState(root, state) {
+ root.dataset.state = state;
+}
+
+function setMsg(el, text, kind) {
+ if (!el) return;
+ el.textContent = text || '';
+ el.hidden = !text;
+ if (kind) el.dataset.kind = kind;
+ else delete el.dataset.kind;
+}
+
+function welcomeFor(pass) {
+ const v = Number(pass.visits || 0);
+ if (pass.tier === 'vip') return `VIP in the house — ${v} nights and counting. Welcome back.`;
+ if (pass.tier === 'regular') return `Good to see you again — welcome back.`;
+ return `First time? Welcome to the club.`;
+}
+
+// ── Local pass cache (per device, until the pass expires) ─────────────────
+function readPass() {
+ try {
+ const raw = localStorage.getItem(PASS_KEY);
+ if (!raw) return null;
+ const pass = JSON.parse(raw);
+ if (!pass?.expiresAt || Date.parse(pass.expiresAt) <= Date.now()) {
+ localStorage.removeItem(PASS_KEY);
+ return null;
+ }
+ return pass;
+ } catch {
+ return null;
+ }
+}
+
+function writePass(pass) {
+ try {
+ localStorage.setItem(PASS_KEY, JSON.stringify({
+ passId: pass.passId,
+ tier: pass.tier,
+ visits: pass.visits,
+ expiresAt: pass.expiresAt,
+ }));
+ } catch {}
+}
+
+function wait(ms) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+}
diff --git a/tests/api/forge-fallback.test.js b/tests/api/forge-fallback.test.js
index 17ad3590b..ed29692b0 100644
--- a/tests/api/forge-fallback.test.js
+++ b/tests/api/forge-fallback.test.js
@@ -20,6 +20,9 @@ beforeAll(() => {
// Self-hosted Hunyuan3D worker wired → image→3D has a fallback target.
GCP_HUNYUAN3D_URL: 'https://hunyuan3d.example.run.app',
GCP_RECONSTRUCTION_KEY: 'test-gcp-key',
+ // The Hunyuan3D lane wraps its job id in a signed forge token (encodeJobToken),
+ // which needs a signing secret — production always has one set.
+ JWT_SECRET: 'test-jwt-secret-at-least-32-characters-long',
});
});