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.

fix: pass the bearer token, not the request, to authenticateBearer in agent session mint

nirholas04b866881ebd
diff --git a/api/agent/session.js b/api/agent/session.js
index a9f712707..fb05ea308 100644
--- a/api/agent/session.js
+++ b/api/agent/session.js
@@ -16,7 +16,7 @@
import { SignJWT } from 'jose';
import { cors, json, method, readJson, wrap, error } from '../_lib/http.js';
-import { getSessionUser, authenticateBearer } from '../_lib/auth.js';
+import { getSessionUser, authenticateBearer, extractBearer } from '../_lib/auth.js';
import { env } from '../_lib/env.js';
import { sql } from '../_lib/db.js';
@@ -47,7 +47,10 @@ export default wrap(async (req, res) => {
if (!method(req, res, ['POST'])) return;
const auth = await getSessionUser(req).catch(() => null)
- || await authenticateBearer(req).catch(() => null);
+ // extractBearer yields the token string authenticateBearer expects —
+ // passing the raw request object always threw inside and silently
+ // disabled bearer auth on this endpoint (fail-closed, but a bug).
+ || await authenticateBearer(extractBearer(req)).catch(() => null);
if (!auth?.userId) return error(res, 401, 'unauthorized', 'sign in required');
const body = await readJson(req, res);