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.

feat: holder-pass + multiplayer room updates, marketplace and nav refinements

nirholasd9f7dd07be55
diff --git a/api/_lib/holder-pass.js b/api/_lib/holder-pass.js
index 553c3bd94..ca8c2cc7b 100644
--- a/api/_lib/holder-pass.js
+++ b/api/_lib/holder-pass.js
@@ -34,6 +34,14 @@ let _warned = false;
function secret() {
const s = process.env.HOLDER_PASS_SECRET;
if (s) return s;
+ // Fail closed in production: minting passes with a publicly-known secret would
+ // let anyone forge entry into a coin's holder world. The endpoint returns 500
+ // instead (wrap() catches this), which is the correct fail-closed behaviour.
+ if (process.env.NODE_ENV === 'production') {
+ throw new Error(
+ '[holder-pass] HOLDER_PASS_SECRET is required in production — refusing to mint passes with the dev secret.',
+ );
+ }
if (!_warned) {
_warned = true;
console.warn(
@@ -63,6 +71,9 @@ export function signHolderPass({ mint, wallet, usd }) {
mint,
wallet,
usd: Math.round((Number(usd) || 0) * 100) / 100,
+ // The floor this pass was gated on, signed so the game server can display
+ // the real requirement without trusting a client-supplied value.
+ minUsd: HOLDER_MIN_USD,
tier: 'holders',
iat: now,
exp: now + PASS_TTL_S,
diff --git a/api/play-og.js b/api/play-og.js
index f838716ae..29e37ba0e 100644
--- a/api/play-og.js
+++ b/api/play-og.js
@@ -69,8 +69,13 @@ export default async function handler(req) {
const ticker = coin?.symbol ? `$${String(coin.symbol).replace(/^\$/, '')}` : null;
const name = coin?.name || (mint ? 'this coin' : 'any coin');
- const mcap = formatMarketCap(coin?.marketCap);
- const image = coin?.image || null;
+ // /api/pump/coin returns the raw pump.fun body — match the same field
+ // fallbacks the in-world client uses (coincommunities.js) so the share card
+ // actually populates instead of always rendering the blank/zero state.
+ const mcap = formatMarketCap(
+ coin?.usd_market_cap || coin?.market_cap_usd || coin?.market_cap || coin?.marketCap || 0,
+ );
+ const image = coin?.image_uri || coin?.image || coin?.imageUri || null;
const heading = ticker ? `Walk into ${ticker}` : 'Walk into any coin';
diff --git a/multiplayer/src/block-store.js b/multiplayer/src/block-store.js
index 72fc08b7b..b66ccdb4b 100644
--- a/multiplayer/src/block-store.js
+++ b/multiplayer/src/block-store.js
@@ -156,6 +156,14 @@ class BlockStore {
}
}
}
+
+ // Flush every world that still holds in-memory state. Called on process
+ // shutdown (SIGTERM on redeploy) so builds whose debounce timer hasn't fired
+ // yet aren't lost between the last edit and the instance going away.
+ async flushAll() {
+ if (!this._redisReady) return;
+ await Promise.allSettled([...this._mem.keys()].map((coin) => this.flush(coin)));
+ }
}
// One store shared by every WalkRoom instance in the process — that shared
diff --git a/multiplayer/src/holder-pass.js b/multiplayer/src/holder-pass.js
index 9d0a553c1..7dd95918f 100644
--- a/multiplayer/src/holder-pass.js
+++ b/multiplayer/src/holder-pass.js
@@ -15,6 +15,12 @@ let _warned = false;
function secret() {
const s = process.env.HOLDER_PASS_SECRET;
if (s) return s;
+ // Fail closed in production: never verify against a publicly-known secret.
+ if (process.env.NODE_ENV === 'production') {
+ throw new Error(
+ '[holder-pass] HOLDER_PASS_SECRET is required in production — refusing to verify passes with the dev secret.',
+ );
+ }
if (!_warned) {
_warned = true;
console.warn(
@@ -45,7 +51,7 @@ function safeEqual(a, b) {
* Verify a holder pass and return its payload, or null if the token is missing,
* malformed, tampered with, or expired.
* @param {unknown} token
- * @returns {{ mint: string, wallet: string, usd: number, tier: string, iat: number, exp: number } | null}
+ * @returns {{ mint: string, wallet: string, usd: number, minUsd?: number, tier: string, iat: number, exp: number } | null}
*/
export function verifyHolderPass(token) {
if (typeof token !== 'string' || token.length < 16 || token.length > 4096) return null;
@@ -64,6 +70,20 @@ export function verifyHolderPass(token) {
if (!payload || typeof payload !== 'object') return null;
if (payload.tier !== 'holders') return null;
if (typeof payload.exp !== 'number' || payload.exp * 1000 < Date.now()) return null;
- if (typeof payload.mint !== 'string') return null;
+ // Reject passes issued in the future (clock skew / forged iat) and ones whose
+ // lifetime exceeds the issuer's TTL — a defence against a tampered exp slipping
+ // past the HMAC if the secret ever leaks.
+ const now = Date.now() / 1000;
+ if (typeof payload.iat !== 'number' || payload.iat > now + 60) return null;
+ if (payload.exp - payload.iat > 15 * 60) return null;
+ if (typeof payload.mint !== 'string' || !payload.mint) return null;
+ // onAuth stores these on client.userData and drives in-world affordances off
+ // them, so they must be present and well-typed, not merely signed.
+ if (typeof payload.wallet !== 'string' || !payload.wallet) return null;
+ if (typeof payload.usd !== 'number' || !Number.isFinite(payload.usd) || payload.usd < 0) return null;
+ // minUsd is signed by the issuer; if present it must be a sane number (the
+ // game server displays it as the gate requirement). Tolerate its absence so a
+ // pass minted by an older signer during a rollout still verifies.
+ if (payload.minUsd != null && (typeof payload.minUsd !== 'number' || !Number.isFinite(payload.minUsd) || payload.minUsd < 0)) return null;
return payload;
}
diff --git a/multiplayer/src/index.js b/multiplayer/src/index.js
index c4af3c909..0d85c0af8 100644
--- a/multiplayer/src/index.js
+++ b/multiplayer/src/index.js
@@ -21,6 +21,7 @@ import { monitor } from '@colyseus/monitor';
import { WalkRoom } from './rooms/WalkRoom.js';
import { GameRoom } from './rooms/GameRoom.js';
+import { blockStore } from './block-store.js';
const PORT = Number(process.env.PORT || 2567);
const HOST = process.env.HOST || '0.0.0.0';
@@ -35,6 +36,17 @@ const ALLOWED_ORIGINS = (
.map((s) => s.trim())
.filter(Boolean);
+// Fail fast on an insecure production config. Without a real shared secret the
+// holder gate is forgeable by anyone (both this process and the Vercel signer
+// fall back to a public dev secret otherwise), so refuse to boot prod without it
+// rather than silently shipping a bypassable gate.
+if (process.env.NODE_ENV === 'production' && !process.env.HOLDER_PASS_SECRET) {
+ console.error(
+ '[multiplayer] FATAL: HOLDER_PASS_SECRET is required in production — the holder gate would be forgeable. Refusing to start.',
+ );
+ process.exit(1);
+}
+
const app = express();
// Liveness probes for the host platform (Fly/Railway/Render).
@@ -137,6 +149,19 @@ gameServer
process.exit(1);
});
+// Keep the single instance alive through an isolated fault. A throw inside one
+// onMessage handler, or an unawaited rejection deep in a dependency, would
+// otherwise take down the whole process (min=1/max=1) and every connected
+// player with it. We log loudly and keep serving — the offending message/room
+// is lost, the server is not. (A crash-loop on a corrupt state would still be
+// caught by the host's health check.)
+process.on('uncaughtException', (err) => {
+ console.error('[multiplayer] uncaughtException (kept alive):', err);
+});
+process.on('unhandledRejection', (reason) => {
+ console.error('[multiplayer] unhandledRejection (kept alive):', reason);
+});
+
// Clean shutdown on SIGTERM/SIGINT so deploys don't drop sessions abruptly.
const shutdown = async (signal) => {
console.log(`[multiplayer] ${signal} received — shutting down`);
@@ -145,6 +170,13 @@ const shutdown = async (signal) => {
} catch (err) {
console.error('[multiplayer] shutdown error:', err);
}
+ // Belt-and-suspenders: persist any world whose debounced save hadn't fired
+ // before the room disposed, so a redeploy never drops the last few edits.
+ try {
+ await blockStore.flushAll();
+ } catch (err) {
+ console.error('[multiplayer] final block flush error:', err);
+ }
process.exit(0);
};
process.on('SIGTERM', () => shutdown('SIGTERM'));
diff --git a/multiplayer/src/rooms/GameRoom.js b/multiplayer/src/rooms/GameRoom.js
index b5469f61a..4cc196b4d 100644
Binary files a/multiplayer/src/rooms/GameRoom.js and b/multiplayer/src/rooms/GameRoom.js differ
diff --git a/multiplayer/src/rooms/WalkRoom.js b/multiplayer/src/rooms/WalkRoom.js
index 31f760fc2..3407952b6 100644
--- a/multiplayer/src/rooms/WalkRoom.js
+++ b/multiplayer/src/rooms/WalkRoom.js
@@ -124,8 +124,11 @@ export class WalkRoom extends Room {
const tier = cleanTier(options?.tier);
if (tier !== 'holders') return true; // open General world
+ // A holder world must name a real coin. Throw (rather than return false) so
+ // every holder-gate refusal reaches the client as a `holder_pass`-prefixed
+ // error its gate UI routes on — a uniform denial contract.
const coin = cleanCoin(options?.coin);
- if (!coin) return false; // a holder world must name a real coin
+ if (!coin) throw new Error('holder_pass_required');
const pass = verifyHolderPass(options?.holderPass);
if (!pass) {
@@ -136,9 +139,10 @@ export class WalkRoom extends Room {
if (pass.mint !== coin || pass.tier !== 'holders') {
throw new Error('holder_pass_mismatch');
}
- // Carry the priced holding through to onJoin so the player's verified value
- // can drive in-world affordances without a second lookup.
- client.userData = { holderUsd: pass.usd, holderWallet: pass.wallet };
+ // Carry the verified holding + signed floor through to onJoin/onCreate so
+ // in-world affordances and the displayed requirement come from the pass,
+ // never from unsigned client options.
+ client.userData = { holderUsd: pass.usd, holderWallet: pass.wallet, holderMinUsd: pass.minUsd };
return true;
}
@@ -166,8 +170,15 @@ export class WalkRoom extends Room {
// world leaves both blank/zero.
this.state.tier = cleanTier(options?.tier);
if (this.state.tier === 'holders') {
- const min = Number(options?.holderMinUsd);
- this.state.holderMinUsd = Number.isFinite(min) && min > 0 ? min : 8;
+ // The displayed floor comes from the signed pass (the issuer's real
+ // HOLDER_MIN_USD), not the client's unsigned `holderMinUsd` option which a
+ // malicious first-joiner could otherwise use to misstate the requirement
+ // for everyone in the room. Fall back to the server's own env, then 8.
+ const signed = verifyHolderPass(options?.holderPass)?.minUsd;
+ const envMin = Number(process.env.HOLDER_MIN_USD);
+ this.state.holderMinUsd = Number.isFinite(signed) && signed > 0
+ ? signed
+ : (Number.isFinite(envMin) && envMin > 0 ? envMin : 8);
}
// Persisted-build key. General and Holders are separate worlds for the same
// coin, so their voxel builds must persist independently — otherwise the two
@@ -242,10 +253,16 @@ export class WalkRoom extends Room {
);
}
- onDispose() {
+ async onDispose() {
// Persist the final build so the community's creation survives the room
- // being torn down when the last player leaves.
- blockStore.flush(this.worldKey).catch(() => {});
+ // being torn down when the last player leaves. Awaited (Colyseus waits on
+ // the returned promise) so the Redis write lands before the room is gone —
+ // fire-and-forget here would race the process exiting on a redeploy.
+ try {
+ await blockStore.flush(this.worldKey);
+ } catch (err) {
+ console.warn(`[walk_world ${this.roomId}] final flush failed:`, err?.message);
+ }
console.log(`[walk_world ${this.roomId}] disposed`);
}
diff --git a/public/features.json b/public/features.json
index a89de9db5..ae246d4cc 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-05-31T04:41:48.080Z",
+ "generated_at": "2026-05-31T04:49:17.186Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/public/nav.html b/public/nav.html
index 45b82845e..971b91f42 100644
--- a/public/nav.html
+++ b/public/nav.html
@@ -82,7 +82,7 @@
<a href="/marketplace" role="menuitem">Marketplace</a>
</li>
<li class="nav-item" role="none">
- <a href="/skills" class="nav-link-with-badge" role="menuitem"
+ <a href="/marketplace?tab=skills" class="nav-link-with-badge" role="menuitem"
>Skills<span class="nav-badge">NEW</span></a
>
</li>
@@ -116,7 +116,7 @@
>
</li>
<li role="none">
- <a href="/skills" role="menuitem"
+ <a href="/marketplace?tab=skills" role="menuitem"
><span class="nav-mi-title">Skills<span class="nav-pill" aria-hidden="true">NEW</span></span
><span class="nav-mi-sub">Browse agent tool packs and capabilities</span></a
>
diff --git a/src/marketplace.js b/src/marketplace.js
index 6dcbd5a0b..869f12655 100644
--- a/src/marketplace.js
+++ b/src/marketplace.js
@@ -4448,9 +4448,17 @@ function bindEvents() {
$('skills-search')?.addEventListener('input', (e) => {
clearTimeout(skillsSearchTimer);
skillsSearchTimer = setTimeout(() => {
- skillsState.q = e.target.value.trim();
- renderSkillsGrid();
- }, 150);
+ const next = e.target.value.trim();
+ if (next === skillsState.q) return;
+ skillsState.q = next;
+ loadSkillsTab(true);
+ }, 250);
+ });
+ $('skills-sort')?.addEventListener('change', (e) => {
+ const next = e.target.value;
+ if (next === skillsState.sort) return;
+ skillsState.sort = next;
+ loadSkillsTab(true);
});
document.querySelectorAll('[data-skill-filter]').forEach((chip) => {
chip.addEventListener('click', () => {
diff --git a/vite.config.js b/vite.config.js
index 79784df82..109c2ce0b 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -223,6 +223,7 @@ const appConfig = {
handle: resolve(__dirname, 'pages/handle.html'),
'a-embed': resolve(__dirname, 'pages/a-embed.html'),
'a-edit': resolve(__dirname, 'pages/a-edit.html'),
+ 'a-me': resolve(__dirname, 'pages/a-me.html'),
'pump-live': resolve(__dirname, 'pages/pump-live.html'),
'pump-dashboard': resolve(__dirname, 'pages/pump-dashboard.html'),
'pump-visualizer': resolve(__dirname, 'pages/pump-visualizer.html'),