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.6 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" />
	<meta name="robots" content="noindex" />
	<title data-i18n="extension_auth_callback.meta_title">Connecting the Walk Avatar extension · three.ws</title>
	<style>
		:root {
			--bg: #0a0a0a; --surface: #141414; --border: rgba(255,255,255,0.08);
			--text: #fafafa; --text-2: #a1a1aa; --accent: #7dd3fc; --danger: #f87171; --success: #34d399;
		}
		* { box-sizing: border-box; }
		html, body { margin: 0; height: 100%; }
		body {
			background: var(--bg); color: var(--text);
			font-family: 'Inter', system-ui, -apple-system, sans-serif;
			display: flex; align-items: center; justify-content: center;
			min-height: 100vh; padding: 24px;
		}
		.card {
			width: 100%; max-width: 420px; background: var(--surface);
			border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px;
			text-align: center;
		}
		.logo { font-size: 16px; font-weight: 700; margin-bottom: 20px; }
		.logo span { color: var(--accent); }
		.spinner {
			width: 36px; height: 36px; margin: 8px auto 18px;
			border: 3px solid var(--border); border-top-color: var(--accent);
			border-radius: 50%; animation: spin 0.8s linear infinite;
		}
		@keyframes spin { to { transform: rotate(360deg); } }
		.icon { font-size: 38px; line-height: 1; margin-bottom: 12px; }
		h1 { font-size: 17px; margin: 0 0 8px; }
		p { font-size: 13.5px; line-height: 1.55; color: var(--text-2); margin: 0 0 18px; }
		.btn {
			display: inline-block; background: var(--accent); color: #001018;
			border: 0; border-radius: 10px; padding: 11px 20px; font-size: 13.5px;
			font-weight: 600; cursor: pointer; text-decoration: none;
			transition: opacity 0.15s, transform 0.1s;
		}
		.btn:hover { opacity: 0.9; }
		.btn:active { transform: scale(0.98); }
		.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--border); margin-left: 8px; }
		.hidden { display: none; }
		.ok { color: var(--success); }
		.err { color: var(--danger); }
	</style>
</head>
<body>
	<div class="card">
		<div class="logo">three<span data-i18n="extension_auth_callback.ws">.ws</span> · Walk Avatar</div>

		<div id="loading">
			<div class="spinner" role="status" aria-label="Connecting"></div>
			<h1 data-i18n="extension_auth_callback.connecting_your_account">Connecting your account…</h1>
			<p data-i18n="extension_auth_callback.linking_the_walk_avatar_extension_to_your">Linking the Walk Avatar extension to your three.ws avatars.</p>
		</div>

		<div id="success" class="hidden">
			<div class="icon ok" aria-hidden="true">✓</div>
			<h1 data-i18n="extension_auth_callback.you_re_connected">You're connected</h1>
			<p data-i18n="extension_auth_callback.the_extension_now_has_access_to_your">The extension now has access to your avatars. You can close this tab — it'll close itself in a moment.</p>
		</div>

		<div id="need-login" class="hidden">
			<div class="icon" aria-hidden="true">🔑</div>
			<h1 data-i18n="extension_auth_callback.sign_in_to_continue">Sign in to continue</h1>
			<p data-i18n="extension_auth_callback.sign_in_to_three_ws_then_we">Sign in to three.ws, then we'll connect the Walk Avatar extension automatically.</p>
			<a class="btn" href="/login?next=/extension/auth-callback" data-i18n="extension_auth_callback.sign_in">Sign in</a>
		</div>

		<div id="error" class="hidden">
			<div class="icon err" aria-hidden="true">⚠</div>
			<h1 data-i18n="extension_auth_callback.couldn_t_connect">Couldn't connect</h1>
			<p id="error-msg" data-i18n="extension_auth_callback.something_went_wrong_while_linking_the_exten">Something went wrong while linking the extension.</p>
			<button class="btn" id="retry-btn" data-i18n="extension_auth_callback.try_again">Try again</button>
			<a class="btn ghost" href="/login?next=/extension/auth-callback" data-i18n="extension_auth_callback.sign_in_again">Sign in again</a>
		</div>
	</div>

	<script>
		(function () {
			'use strict';
			var $ = function (id) { return document.getElementById(id); };
			function show(which) {
				['loading', 'success', 'need-login', 'error'].forEach(function (k) {
					$(k).classList.toggle('hidden', k !== which);
				});
			}

			// If the URL already carries the minted token, the extension's
			// background worker is reading it from this very URL — just confirm
			// success and stop. (Prevents a re-mint/redirect loop.)
			var params = new URLSearchParams(location.search);
			var state = params.get('state') || '';
			// Keep the extension's one-time state across a sign-in round trip.
			var loginNext = encodeURIComponent('/extension/auth-callback' +
				(state ? '?state=' + encodeURIComponent(state) : ''));
			Array.prototype.forEach.call(document.querySelectorAll('a[href^="/login"]'), function (a) {
				a.setAttribute('href', '/login?next=' + loginNext);
			});
			if (params.get('token')) {
				show('success');
				// Best-effort auto-close once the background worker has captured it.
				setTimeout(function () { window.close(); }, 2500);
				return;
			}

			async function connect() {
				show('loading');
				try {
					var res = await fetch('/api/auth/extension-token', {
						method: 'POST',
						credentials: 'include',
						headers: { 'content-type': 'application/json' },
					});
					if (res.status === 401) { show('need-login'); return; }
					if (!res.ok) {
						var body = await res.json().catch(function () { return {}; });
						throw new Error(body.message || ('HTTP ' + res.status));
					}
					var data = await res.json();
					if (!data || !data.token) throw new Error('No token returned');
					// Hand the token to the extension's background worker by putting
					// it in the URL it is watching, then re-render as success.
					location.replace('/extension/auth-callback?token=' + encodeURIComponent(data.token) +
						'&state=' + encodeURIComponent(state));
				} catch (e) {
					$('error-msg').textContent = (e && e.message)
						? ('Something went wrong: ' + e.message)
						: 'Something went wrong while linking the extension.';
					show('error');
				}
			}

			$('retry-btn').addEventListener('click', connect);
			connect();
		})();
	</script>
	<!-- Runtime i18n: detects locale, swaps annotated copy, mounts <lang-switcher>. -->
	<script type="module" src="/i18n.js"></script>
</body>
</html>