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.

refactor: remove Privy integration and related files; update documentation links

nirholas61aec74778d3
diff --git a/.vercelignore b/.vercelignore
new file mode 100644
index 000000000..623abcef8
--- /dev/null
+++ b/.vercelignore
@@ -0,0 +1,30 @@
+.git
+.github
+.claude
+.husky
+.vscode
+
+tests
+specs
+examples
+prompts
+contracts
+sdk
+chat-plugin
+cz-package
+character-studio
+sims-demo
+3d-demo
+avatar
+
+scripts
+dist-lib
+dist-artifact
+
+public/screenshots
+public/skills.mp4
+
+vitest.config.js
+vite.config.artifact.js
+playwright.config.*
+gitpretty.sh
diff --git a/api/_lib/privy.js b/api/_lib/privy.js
deleted file mode 100644
index 0df6bc207..000000000
--- a/api/_lib/privy.js
+++ /dev/null
@@ -1,91 +0,0 @@
-// Privy JWT verification: JWKS fetch + cache + token verification.
-
-import { jwtVerify, importJWK } from 'jose';
-import { env } from './env.js';
-
-// JWKS cache: Map<kid, publicKey>. Fetched once per PRIVY_APP_ID per 60-minute window.
-const jwksCache = new Map();
-let lastJwksFetch = 0;
-const JWKS_TTL_MS = 60 * 60 * 1000;
-
-async function fetchJwks() {
- const now = Date.now();
- if (jwksCache.size > 0 && now - lastJwksFetch < JWKS_TTL_MS) {
- return;
- }
-
- const appId = env.PRIVY_APP_ID;
- const url = `https://auth.privy.io/api/v1/apps/${appId}/jwks.json`;
- const res = await fetch(url);
- if (!res.ok) {
- throw new Error(`JWKS fetch failed: ${res.status} ${res.statusText}`);
- }
-
- const data = await res.json();
- jwksCache.clear();
- for (const key of data.keys || []) {
- if (key.kid && key.use === 'sig' && key.kty === 'EC') {
- const publicKey = await importJWK(key, 'ES256');
- jwksCache.set(key.kid, publicKey);
- }
- }
- lastJwksFetch = now;
-}
-
-// Verify a Privy identity token.
-// Returns { userId, walletAddress, email, iat, exp } on success.
-export async function verifyPrivyIdToken(token) {
- await fetchJwks();
-
- const appId = env.PRIVY_APP_ID;
- const decoded = jwtDecode(token);
- const kid = decoded.header.kid;
-
- if (!kid) {
- throw new Error('Token missing kid in header');
- }
-
- let publicKey = jwksCache.get(kid);
- if (!publicKey) {
- // Cache miss — refresh JWKS and try again.
- jwksCache.clear();
- lastJwksFetch = 0;
- await fetchJwks();
- publicKey = jwksCache.get(kid);
- }
-
- if (!publicKey) {
- throw new Error(`Key not found in JWKS: ${kid}`);
- }
-
- const { payload } = await jwtVerify(token, publicKey, {
- issuer: 'privy.io',
- audience: appId,
- algorithms: ['ES256'],
- });
-
- // Extract wallet address from linked_accounts
- let walletAddress = null;
- if (payload.linked_accounts && Array.isArray(payload.linked_accounts)) {
- const wallet = payload.linked_accounts.find((acct) => acct.type === 'wallet');
- if (wallet && wallet.address) {
- walletAddress = wallet.address.toLowerCase();
- }
- }
-
- return {
- userId: payload.sub,
- walletAddress,
- email: payload.email || null,
- iat: payload.iat,
- exp: payload.exp,
- };
-}
-
-// Simple JWT header decoder (without verification) to extract kid.
-function jwtDecode(token) {
- const [headerB64] = token.split('.');
- if (!headerB64) throw new Error('Invalid token format');
- const header = JSON.parse(Buffer.from(headerB64, 'base64').toString('utf8'));
- return { header };
-}
diff --git a/api/auth/privy/verify.js b/api/auth/privy/verify.js
deleted file mode 100644
index daf28f0b6..000000000
--- a/api/auth/privy/verify.js
+++ /dev/null
@@ -1,131 +0,0 @@
-// Verify a Privy identity token and issue a 3D-Agent session.
-// POST /api/auth/privy/verify — accepts { idToken }, returns session cookie + user + wallet.
-
-import { z } from 'zod';
-import { sql } from '../../_lib/db.js';
-import { createSession, sessionCookie, destroySession } from '../../_lib/auth.js';
-import { cors, json, method, readJson, wrap, error } from '../../_lib/http.js';
-import { limits, clientIp } from '../../_lib/rate-limit.js';
-import { parse } from '../../_lib/validate.js';
-import { verifyPrivyIdToken } from '../../_lib/privy.js';
-
-const bodySchema = z.object({
- idToken: z.string().min(10).max(5000),
-});
-
-export default wrap(async (req, res) => {
- if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
- if (!method(req, res, ['POST'])) return;
-
- const ip = clientIp(req);
- const rl = await limits.authIp(ip);
- if (!rl.success) return error(res, 429, 'rate_limited', 'too many attempts');
-
- const body = parse(bodySchema, await readJson(req));
-
- // 1. Verify the Privy identity token.
- let privyData;
- try {
- privyData = await verifyPrivyIdToken(body.idToken);
- } catch (err) {
- const msg = err.message || String(err);
- // Distinguish between bad token format, expired, and signature failures.
- if (msg.includes('expired') || msg.includes('JWT expired')) {
- return error(res, 401, 'expired_token', 'token expired');
- }
- if (msg.includes('audience')) {
- return error(res, 401, 'wrong_audience', 'token audience mismatch');
- }
- if (msg.includes('JWKS') || msg.includes('fetch')) {
- // JWKS fetch failure is a server error, not a client token error.
- throw err;
- }
- return error(res, 401, 'invalid_token', 'token verification failed');
- }
-
- // 2. Privy token must have a linked wallet.
- if (!privyData.walletAddress) {
- return error(res, 400, 'no_wallet_linked', 'Privy account has no linked wallet');
- }
-
- // 3. Check that user_wallets.privy_user_id column exists (idempotent migration check).
- let hasPrivyUserIdColumn;
- try {
- const [row] = await sql`
- select exists(
- select 1 from information_schema.columns
- where table_name = 'user_wallets' and column_name = 'privy_user_id'
- ) as exists
- `;
- hasPrivyUserIdColumn = row.exists;
- } catch {
- hasPrivyUserIdColumn = false;
- }
-
- if (!hasPrivyUserIdColumn) {
- return error(
- res,
- 501,
- 'schema_migration_required',
- 'user_wallets.privy_user_id column missing',
- );
- }
-
- // 4. Find or create the user and wallet.
- const addrLower = privyData.walletAddress.toLowerCase();
- const privyUserId = privyData.userId;
-
- let [wallet] = await sql`
- select user_id from user_wallets where address = ${addrLower} limit 1
- `;
- let userId;
-
- if (wallet) {
- userId = wallet.user_id;
- // Update last_used_at and privy_user_id if changed.
- await sql`
- update user_wallets
- set last_used_at = now(), privy_user_id = ${privyUserId}
- where address = ${addrLower}
- `;
- } else {
- // Create a new user. Use Privy email if available; otherwise synthesize one.
- const userEmail = privyData.email || `wallet-${addrLower}@privy.local`;
- const [user] = await sql`
- insert into users (email, display_name, wallet_address)
- values (${userEmail}, ${shortAddr(privyData.walletAddress)}, ${addrLower})
- returning id
- `;
- userId = user.id;
-
- // Link the wallet with privy_user_id.
- await sql`
- insert into user_wallets (user_id, address, chain_id, is_primary, privy_user_id)
- values (${userId}, ${addrLower}, null, true, ${privyUserId})
- `;
- }
-
- // 5. Issue a session.
- await destroySession(req);
- const token = await createSession({
- userId,
- userAgent: req.headers['user-agent'],
- ip,
- });
- res.setHeader('set-cookie', sessionCookie(token));
-
- // 6. Return user + wallet info.
- const [userRow] = await sql`
- select id, email, display_name, plan, avatar_url, created_at
- from users where id = ${userId} limit 1
- `;
-
- return json(res, 200, {
- user: userRow,
- wallet: { address: privyData.walletAddress, chain_id: null },
- });
-});
-
-function shortAddr(addr) {
- return `${addr.slice(0, 6)}…${addr.slice(-4)}`;
-}
diff --git a/package.json b/package.json
index fd0b8801a..d5c80951d 100644
--- a/package.json
+++ b/package.json
@@ -63,7 +63,6 @@
"@metaplex-foundation/umi-bundle-defaults": "^1.5.1",
"@neondatabase/serverless": "^0.10.1",
"@noble/curves": "^2.2.0",
- "@privy-io/js-sdk-core": "latest",
"@sentry/node": "^10.50.0",
"@solana/web3.js": "^1.98.4",
"@upstash/ratelimit": "^2.0.5",
diff --git a/public/dashboard/index.html b/public/dashboard/index.html
index f177893ee..910152e34 100644
--- a/public/dashboard/index.html
+++ b/public/dashboard/index.html
@@ -1111,7 +1111,7 @@
<a href="/features">Features</a>
<a href="/widgets">Widgets</a>
<a href="/studio">Studio</a>
- <a href="/docs/widgets">Docs</a>
+ <a href="/docs">Docs</a>
<a href="/my-agents">My Agents</a>
<a href="/dashboard" class="active" aria-current="page">Dashboard</a>
</nav>
@@ -1177,7 +1177,7 @@
<a href="/features">Features</a>
<a href="/discover">Discover</a>
<a href="/showcase">Showcase</a>
- <a href="/docs/widgets">Docs</a>
+ <a href="/docs">Docs</a>
<a href="https://eips.ethereum.org/EIPS/eip-8004" target="_blank" rel="noopener">ERC-8004</a>
<a href="/legal/privacy">Privacy</a>
<a href="/legal/tos">Terms</a>
diff --git a/public/docs-widgets.html b/public/docs-widgets.html
index 8124349ec..08bea7ffc 100644
--- a/public/docs-widgets.html
+++ b/public/docs-widgets.html
@@ -474,7 +474,7 @@ img-src https://three.ws/ data:;</code></pre>
<a href="/features">Features</a>
<a href="/discover">Discover</a>
<a href="/showcase">Showcase</a>
- <a href="/docs/widgets">Docs</a>
+ <a href="/docs">Docs</a>
<a href="https://eips.ethereum.org/EIPS/eip-8004" target="_blank" rel="noopener">ERC-8004</a>
<a href="/legal/privacy">Privacy</a>
<a href="/legal/tos">Terms</a>
diff --git a/public/settings/index.html b/public/settings/index.html
index 8d70fb6e6..55b986588 100644
--- a/public/settings/index.html
+++ b/public/settings/index.html
@@ -290,7 +290,7 @@
<a href="/features">Features</a>
<a href="/widgets">Widgets</a>
<a href="/studio">Studio</a>
- <a href="/docs/widgets">Docs</a>
+ <a href="/docs">Docs</a>
<a href="/my-agents">My Agents</a>
<a href="/dashboard">Dashboard</a>
<a href="/settings" class="active" aria-current="page">Settings</a>
diff --git a/src/erc8004/privy.js b/src/erc8004/privy.js
deleted file mode 100644
index f1f38f545..000000000
--- a/src/erc8004/privy.js
+++ /dev/null
@@ -1,167 +0,0 @@
-/**
- * Privy wallet integration.
- *
- * Wraps @privy-io/js-sdk-core so users can connect via:
- * - MetaMask, Coinbase Wallet, WalletConnect, etc.
- * - Email → Privy embedded wallet (no browser extension needed)
- * - Social login → embedded wallet
- *
- * Setup:
- * 1. Create a Privy app at https://dashboard.privy.io
- * 2. Set VITE_PRIVY_APP_ID in your .env
- * 3. npm install @privy-io/js-sdk-core
- */
-
-import { BrowserProvider } from 'ethers';
-
-let _privy = null;
-let _initPromise = null;
-let _resolvedAppId = null;
-let _appIdPromise = null;
-
-const BUILD_APP_ID = import.meta.env.VITE_PRIVY_APP_ID || '';
-
-/**
- * Resolve the Privy app ID. Prefers build-time VITE_PRIVY_APP_ID; otherwise
- * fetches /api/config at runtime so ops can rotate the ID without a rebuild.
- */
-async function resolveAppId() {
- if (_resolvedAppId !== null) return _resolvedAppId;
- if (BUILD_APP_ID) {
- _resolvedAppId = BUILD_APP_ID;
- return _resolvedAppId;
- }
- if (_appIdPromise) return _appIdPromise;
-
- _appIdPromise = (async () => {
- try {
- const res = await fetch('/api/config', { credentials: 'include' });
- if (!res.ok) return '';
- const data = await res.json();
- return data.privyAppId || '';
- } catch {
- return '';
- }
- })().then((id) => {
- _resolvedAppId = id;
- return id;
- });
-
- return _appIdPromise;
-}
-
-// ---------------------------------------------------------------------------
-// Init
-// ---------------------------------------------------------------------------
-
-/**
- * Lazily initialize the Privy client. Returns null if no app ID is set.
- */
-export async function initPrivy() {
- if (_privy) return _privy;
- if (_initPromise) return _initPromise;
-
- const appId = await resolveAppId();
- if (!appId) return null;
-
- _initPromise = (async () => {
- try {
- const mod = await import('@privy-io/js-sdk-core');
- const PrivyClient = mod.PrivyClient || mod.default;
- _privy = new PrivyClient({ appId });
- return _privy;
- } catch (err) {
- console.warn('[privy] Failed to load — falling back to injected wallet.', err.message);
- _initPromise = null;
- return null;
- }
- })();
-
- return _initPromise;
-}
-
-// ---------------------------------------------------------------------------
-// Auth
-// ---------------------------------------------------------------------------
-
-/**
- * Login via Privy — opens the Privy auth modal.
- * Supports email, wallet, and social login methods.
- */
-export async function loginWithPrivy() {
- const privy = await initPrivy();
- if (!privy) throw new Error('Privy not configured. Set VITE_PRIVY_APP_ID in .env');
- return privy.login({ loginMethods: ['wallet', 'email', 'google'] });
-}
-
-/**
- * Logout from Privy.
- */
-export async function logoutPrivy() {
- if (_privy?.logout) await _privy.logout();
-}
-
-// ---------------------------------------------------------------------------
-// Wallet
-// ---------------------------------------------------------------------------
-
-/**
- * Connect a wallet through Privy and return an ethers-compatible wallet.
- *
- * If the user isn't logged in to Privy yet, opens the login modal first.
- * Then obtains an EIP-1193 provider (either from the user's external wallet
- * or from Privy's embedded wallet) and wraps it in an ethers BrowserProvider.
- *
- * @returns {Promise<{provider: BrowserProvider, signer: import('ethers').Signer, address: string, chainId: number}>}
- */
-export async function connectWithPrivy() {
- const privy = await initPrivy();
- if (!privy) throw new Error('Privy not configured. Set VITE_PRIVY_APP_ID in .env');
-
- // Authenticate if not already
- if (!privy.authenticated && !privy.user) {
- await privy.login({ loginMethods: ['wallet', 'email'] });
- }
-
- // Get EIP-1193 provider from Privy (works for both embedded + external wallets)
- const eip1193 = await privy.getEthereumProvider();
- if (!eip1193) throw new Error('No wallet available. Please connect a wallet through Privy.');
-
- const provider = new BrowserProvider(eip1193);
- const signer = await provider.getSigner();
- const address = await signer.getAddress();
- const { chainId } = await provider.getNetwork();
-
- return { provider, signer, address, chainId: Number(chainId) };
-}
-
-// ---------------------------------------------------------------------------
-// Helpers
-// ---------------------------------------------------------------------------
-
-/**
- * Whether a Privy app ID is configured.
- *
- * Synchronous best-guess from the build-time value + any runtime value resolved
- * so far. For an accurate runtime answer (forces /api/config fetch on first
- * call) use `isPrivyConfiguredAsync`.
- *
- * @returns {boolean}
- */
-export function isPrivyConfigured() {
- if (_resolvedAppId !== null) return Boolean(_resolvedAppId);
- return Boolean(BUILD_APP_ID);
-}
-
-/**
- * Runtime check that resolves the app ID (build-time or /api/config).
- * @returns {Promise<boolean>}
- */
-export async function isPrivyConfiguredAsync() {
- return Boolean(await resolveAppId());
-}
-
-/** @returns {object|null} The Privy client instance (null if not initialized). */
-export function getPrivy() {
- return _privy;
-}
diff --git a/vite.config.js b/vite.config.js
index 6c7524785..e6ed1a784 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -143,8 +143,19 @@ const appConfig = {
],
},
workbox: {
- maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
- globPatterns: ['**/*.{js,css,ico,png,svg,woff2}'],
+ maximumFileSizeToCacheInBytes: 2 * 1024 * 1024,
+ globPatterns: ['**/*.{js,css,html,ico,woff2}'],
+ globIgnores: [
+ '**/animations/**',
+ '**/avatars/**',
+ '**/screenshots/**',
+ '**/docs/**',
+ '**/og-image.*',
+ '**/three.svg',
+ '**/3d.png',
+ '**/ddd.png',
+ '**/skills.mp4',
+ ],
navigateFallback: null,
skipWaiting: true,
clientsClaim: true,