import { useState, useEffect } from "react"; import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Github, Globe, MessageSquare, Loader2 } from "lucide-react"; import { useAuth } from "@/lib/auth"; export default function OsLink() { const { user } = useAuth(); const [linkedIdentities, setLinkedIdentities] = useState< Array<{ provider: string; external_id: string; verified_at: string }> >([]); const [loading, setLoading] = useState(false); const providers = [ { name: "Roblox", id: "roblox", icon: Globe, color: "text-red-500" }, { name: "Discord", id: "discord", icon: MessageSquare, color: "text-indigo-500" }, { name: "GitHub", id: "github", icon: Github, color: "text-gray-300" }, ]; const handleLinkStart = async (provider: string) => { if (!user?.id) { alert("Please log in first"); return; } setLoading(true); try { const res = await fetch("/api/os/link/start", { method: "POST", headers: { "Content-Type": "application/json", "x-user-id": user.id }, body: JSON.stringify({ provider }), }); const { redirect_url } = await res.json(); // In production, redirect to OAuth flow alert(`Would redirect to: ${redirect_url}`); } catch (error) { console.error("Link failed:", error); alert("Failed to start linking"); } finally { setLoading(false); } }; const handleUnlink = async (provider: string) => { if (!user?.id) return; try { await fetch("/api/os/link/unlink", { method: "POST", headers: { "Content-Type": "application/json", "x-user-id": user.id }, body: JSON.stringify({ provider }), }); setLinkedIdentities(linkedIdentities.filter((id) => id.provider !== provider)); } catch (error) { console.error("Unlink failed:", error); alert("Failed to unlink identity"); } }; return (
{/* Header */}

Identity Linking

Link your accounts to get verified credentials across the AeThex ecosystem.

💡 What this means: Your proofs are portable. Link once, use everywhere.

{/* Providers */}

Available Platforms

{providers.map((provider) => { const Icon = provider.icon; const isLinked = linkedIdentities.some((id) => id.provider === provider.id); return (

{provider.name}

{isLinked && (

✓ Linked and verified

)}
); })}
{/* Info Cards */}
🔐 Your Privacy We never share your linked identities without your consent. Each platform only sees what you allow. Verified Proofs When you link, we create cryptographically signed proofs of your achievements that you can share. 🔗 Portable Use your verified credentials across any platform that trusts AeThex, without creating new accounts. 🚪 Exit Path If AeThex disappears, your proofs remain valid and your linked accounts are still yours.
{/* How It Works */} How It Works
1

Link Your Account

Connect your Roblox, Discord, or GitHub account securely.

2

Verify Ownership

We confirm you own the account (OAuth, challenge, etc).

3

Get Verified Proofs

Your achievements are signed and portable across platforms.

4

Use Everywhere

Share your proofs with any platform that trusts AeThex OS.

{/* Footer */}

💡 OS attests; platforms decide.

We verify your credentials. Other platforms decide what access to grant.

); }