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 (
Link your accounts to get verified credentials across the AeThex ecosystem.
💡 What this means: Your proofs are portable. Link once, use everywhere.
{provider.name}
{isLinked && (✓ Linked and verified
)}Link Your Account
Connect your Roblox, Discord, or GitHub account securely.
Verify Ownership
We confirm you own the account (OAuth, challenge, etc).
Get Verified Proofs
Your achievements are signed and portable across platforms.
Use Everywhere
Share your proofs with any platform that trusts AeThex OS.
💡 OS attests; platforms decide.
We verify your credentials. Other platforms decide what access to grant.