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.

6.1 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="siwx_test.meta_title">x402 SIWX — manual test page</title>
<meta name="robots" content="noindex" />
<style>
	html, body { margin: 0; padding: 0; background: #0e0e0e; color: #e6e8f0; font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif; }
	main { max-width: 760px; margin: 0 auto; padding: 32px 20px 64px; }
	h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
	.sub { color: #8a90a8; font-size: 13px; margin: 0 0 24px; line-height: 1.5; }
	.row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
	.row button {
		flex: 1 1 280px;
		padding: 14px 18px;
		background: #1d1d1d; border: 1px solid #2e2e2e; border-radius: 12px;
		color: #e6e8f0; font-size: 14px; font-weight: 600; cursor: pointer;
		text-align: left; line-height: 1.4;
		transition: border-color 0.12s, background 0.12s;
	}
	.row button:hover { border-color: #0a84ff; background: #252525; }
	.row button small { display: block; font-weight: 400; color: #8a90a8; margin-top: 4px; font-size: 11px; font-family: ui-monospace, Menlo, monospace; }
	.log-head {
		display: flex; align-items: center; justify-content: space-between;
		margin: 28px 0 8px;
	}
	.log-head h2 { font-size: 13px; font-weight: 600; color: #b0b6cc; letter-spacing: 0.04em; text-transform: uppercase; margin: 0; }
	.log-head button {
		background: transparent; border: 1px solid #2e2e2e; color: #8a90a8;
		padding: 4px 10px; border-radius: 6px; font-size: 11px; cursor: pointer;
	}
	.log-head button:hover { color: #e6e8f0; border-color: #5a6378; }
	pre {
		background: #161616; border: 1px solid #272727; border-radius: 10px;
		padding: 14px 16px; font-family: ui-monospace, Menlo, monospace; font-size: 12px;
		line-height: 1.55; color: #b0b6cc; white-space: pre-wrap; word-break: break-word;
		min-height: 200px; max-height: 60vh; overflow: auto; margin: 0;
	}
	pre .siwx { color: #60a5fa; }
	pre .result { color: #4ade80; }
	pre .error { color: #fca5a5; }
	pre .ts { color: #6b7088; }
	.note {
		font-size: 12px; color: #8a90a8; background: #161616; border: 1px solid #272727;
		border-radius: 8px; padding: 10px 12px; margin-top: 24px; line-height: 1.5;
	}
	.note code { font-family: ui-monospace, Menlo, monospace; color: #e6e8f0; }
</style>
</head>
<body>
<main>
	<h1 data-i18n="siwx_test.x402_siwx_manual_test">x402 SIWX — manual test</h1>
	<p class="sub" data-i18n-html="siwx_test.click_a_button_to_open_the_drop">
		Click a button to open the drop-in modal. When the endpoint advertises the
		<code>sign-in-with-x</code> extension, the modal offers "Sign in with wallet"
		as the primary action — the wallet signs a CAIP-122 message, the modal
		retries the endpoint with a <code>SIGN-IN-WITH-X</code> header, and the
		endpoint returns 200 without charging. Without the extension, the modal
		runs the normal pay-with-USDC flow.
	</p>

	<div class="row">
		<button
			data-x402-endpoint="/api/x402/asset-download?slug=pole-dancer-rumba"
			data-x402-method="GET"
			data-x402-merchant="three.ws"
			data-x402-action="Download pole-dancer-rumba.glb" data-i18n-html="siwx_test.buy_glb_pole_dancer_rumba_api_x402">
			Buy GLB · pole-dancer-rumba
			<small>/api/x402/asset-download?slug=pole-dancer-rumba</small>
		</button>
		<button
			data-x402-endpoint="/api/x402/dance-tip?dancer=1&amp;dance=rumba"
			data-x402-method="GET"
			data-x402-merchant="three.ws"
			data-x402-action="Tip dancer · rumba" data-i18n-html="siwx_test.tip_dancer_rumba_api_x402_dance_tip">
			Tip dancer · rumba
			<small>/api/x402/dance-tip?dancer=1&amp;dance=rumba</small>
		</button>
	</div>

	<div class="log-head">
		<h2 data-i18n="siwx_test.event_log">Event log</h2>
		<button id="clear" data-i18n="siwx_test.clear">Clear</button>
	</div>
	<pre id="log">(no events yet — click a button above)</pre>

	<div class="note">
		<strong data-i18n="siwx_test.what_to_look_for">What to look for.</strong> First click on a paid endpoint runs the
		<code>x402:result</code> event (pay flow). After paying once with a given
		wallet, reload the page and click again — if the endpoint opts into SIWX,
		the modal shows "Sign in with wallet". Approving the signature fires
		<code>x402:siwx-signed</code> first, then <code>x402:result</code>, and the
		network tab shows the request hitting the endpoint with a
		<code>SIGN-IN-WITH-X</code> header (no <code>X-PAYMENT</code>).
	</div>
</main>

<script type="module" src="/x402.js"></script>
<script>
	const log = document.getElementById('log');
	let first = true;
	function append(kind, label, detail) {
		if (first) { log.textContent = ''; first = false; }
		const ts = new Date().toISOString().slice(11, 23);
		const head = document.createElement('span');
		head.className = 'ts';
		head.textContent = `[${ts}] `;
		const tag = document.createElement('span');
		tag.className = kind;
		tag.textContent = label;
		const body = document.createTextNode(' ' + JSON.stringify(detail, null, 2) + '\n\n');
		log.appendChild(head);
		log.appendChild(tag);
		log.appendChild(body);
		log.scrollTop = log.scrollHeight;
	}
	document.addEventListener('x402:siwx-signed', (e) => append('siwx', 'x402:siwx-signed', e.detail));
	document.addEventListener('x402:result', (e) => append('result', 'x402:result', e.detail));
	document.addEventListener('x402:error', (e) => append('error', 'x402:error', e.detail));
	document.getElementById('clear').addEventListener('click', () => {
		log.textContent = '(cleared — click a button above)';
		first = true;
	});
</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>