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.

5.7 KB
Raw Blame
<!doctype html>
<html lang="en">
	<head>
		<script>/* three.ws theme boot — no-flash; runtime in /theme-switcher.js */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1" />
		<title data-i18n="wallet_connect_demo.meta_title">Wallet Connect — QA Demo</title>
		<link rel="stylesheet" href="/wallet-connect.css" />
		<style>
			:root {
				color-scheme: dark;
			}
			body {
				font:
					15px/1.5 system-ui,
					sans-serif;
				background: #000;
				color: #eee;
				margin: 0;
				min-height: 100vh;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				gap: 32px;
				padding: 32px;
			}
			h1 {
				margin: 0;
				font-size: 20px;
			}
			.demo-grid {
				display: grid;
				grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
				gap: 24px;
				width: 100%;
				max-width: 800px;
			}
			.demo-card {
				background: #151515;
				border: 1px solid #232323;
				border-radius: 12px;
				padding: 20px;
				display: flex;
				flex-direction: column;
				gap: 12px;
			}
			.demo-card h2 {
				margin: 0;
				font-size: 14px;
				color: #aaa;
				text-transform: uppercase;
				letter-spacing: 0.06em;
			}
			.log {
				font-size: 12px;
				font-family: monospace;
				color: #666;
				min-height: 40px;
				word-break: break-all;
			}
		</style>
	</head>
	<body>
		<h1 data-i18n="wallet_connect_demo.wallet_connect_qa_demo">Wallet Connect — QA Demo</h1>
		<p style="color: #666; margin: 0; font-size: 13px" data-i18n="wallet_connect_demo.manual_test_page_not_linked_from_site">
			Manual test page — not linked from site nav.
		</p>

		<div class="demo-grid">
			<div class="demo-card">
				<h2 data-i18n="wallet_connect_demo.sign_in">Sign in</h2>
				<div id="mount-signin"></div>
				<div class="log" id="log-signin">State: idle</div>
			</div>
			<div class="demo-card">
				<h2 data-i18n="wallet_connect_demo.link_additional_wallet">Link additional wallet</h2>
				<div id="mount-link"></div>
				<div class="log" id="log-link">State: idle</div>
			</div>
			<div class="demo-card">
				<h2 data-i18n="wallet_connect_demo.register_agent_erc_8004">Register agent (ERC-8004)</h2>
				<div id="mount-agent"></div>
				<div class="log" id="log-agent">State: idle</div>
			</div>
		</div>

		<script type="module">
			const { createConnectWalletButton } = await import(/* @vite-ignore */ '/wallet/connect-button.js');

			const params = new URLSearchParams(location.search);
			// safeNext: inline copy of src/safe-next.js (tests/safe-next.test.js drift-guards it).
function safeNext(raw, fallback = '/dashboard') {
	if (typeof raw !== 'string' || raw.length === 0) return fallback;
	// Require a single leading '/': '//evil.com' is protocol-relative, and a
	// backslash anywhere lets '/\evil.com' normalize to '//evil.com' in the
	// URL parser.
	if (!raw.startsWith('/') || raw.startsWith('//')) return fallback;
	if (raw.includes('\\')) return fallback;
	// Control characters can smuggle a scheme past naive prefix checks.
	// eslint-disable-next-line no-control-regex
	if (/[\u0000-\u001f]/.test(raw)) return fallback;
	return raw;
}
			const next = safeNext(params.get('next'), '/dashboard/');

			function wire(mountId, logId, opts) {
				const mountEl = document.getElementById(mountId);
				const logEl = document.getElementById(logId);
				const ctrl = createConnectWalletButton(mountEl, opts);
				ctrl.addEventListener('change', (e) => {
					const { status, address, error } = e.detail;
					logEl.textContent = `State: ${status}${address ? ` · ${address.slice(0, 6)}…${address.slice(-4)}` : ''}${error ? ` · ${error.message}` : ''}`;
				});
				return ctrl;
			}

			wire('mount-signin', 'log-signin', {
				verifyUrl: '/api/auth/siwe/verify',
				labels: { idle: 'Connect wallet', connected: null },
				onSuccess: () => {
					document.getElementById('log-signin').textContent = 'Success — redirecting…';
					setTimeout(() => (location.href = next), 800);
				},
			});

			wire('mount-link', 'log-link', {
				// Linking uses the per-user link-nonce flow (separate from the login
				// nonce pool), so a login signature can't be replayed to attach a
				// wallet to another account.
				nonceUrl: '/api/auth/wallets/nonce',
				verifyUrl: '/api/auth/wallets',
				messageBuilder: (address, chainId, nonce, { domain, uri, issuedAt, expirationTime }) =>
					[
						`${domain} wants you to sign in with your Ethereum account:`,
						address,
						'',
						'Link this wallet to your three.ws account.',
						'',
						`URI: ${uri}`,
						'Version: 1',
						`Chain ID: ${chainId}`,
						`Nonce: ${nonce}`,
						`Issued At: ${issuedAt}`,
						`Expiration Time: ${expirationTime}`,
					].join('\n'),
				labels: { idle: 'Link wallet', signing: 'Sign to link…', success: 'Wallet linked' },
				onSuccess: () => {
					document.getElementById('log-link').textContent = 'Wallet linked successfully.';
				},
			});

			wire('mount-agent', 'log-agent', {
				verifyUrl: '/api/auth/siwe/verify',
				labels: {
					idle: 'Connect for ERC-8004',
					signing: 'Sign to register…',
					success: 'Ready',
				},
				onSuccess: () => {
					document.getElementById('log-agent').textContent =
						'Connected — ready for on-chain registration.';
				},
			});
		</script>
		<script src="/brand.js" defer></script>
	<!-- Runtime i18n: detects locale, swaps annotated copy, mounts <lang-switcher>. -->
	<script type="module" src="/i18n.js"></script>
</body>
</html>