"use client"; import { useEffect, useState } from "react"; export default function SovereignSetup() { const [os, setOs] = useState("unknown"); const [certStatus, setCertStatus] = useState<"idle" | "testing" | "ok" | "fail">("idle"); const [tenantName, setTenantName] = useState("SOVEREIGN TENANT"); useEffect(() => { const ua = navigator.userAgent.toLowerCase(); if (ua.includes("android")) setOs("android"); else if (ua.includes("iphone") || ua.includes("ipad")) setOs("ios"); else if (ua.includes("mac")) setOs("macos"); else if (ua.includes("windows")) setOs("windows"); else if (ua.includes("linux")) setOs("linux"); else setOs("unknown"); // Fetch tenant info fetch("/api/auth/me").then(r => r.json()).then(d => { if (d.tenantName) setTenantName(d.tenantName); }).catch(() => {}); }, []); const testConnection = async () => { setCertStatus("testing"); try { const resp = await fetch("/api/superadmin/xcu-tls-switch"); if (resp.ok) { const data = await resp.json(); const onlineNodes = data.nodes?.filter((n: any) => n.online) || []; setCertStatus(onlineNodes.length > 0 ? "ok" : "fail"); } else { setCertStatus("fail"); } } catch { setCertStatus("fail"); } }; const instructions: Record = { android: { title: "Android", icon: "📱", steps: [ "Tap tombol \"Download CA Certificate\" di bawah", "Buka Settings → Security → Encryption & Credentials", "Tap \"Install a certificate\" → \"CA certificate\"", "Pilih file xcu-sovereign-ca.crt yang baru di-download", "Konfirmasi dengan PIN/Fingerprint", "Selesai! Certificate berlaku 30 tahun" ] }, ios: { title: "iPhone / iPad", icon: "🍎", steps: [ "Tap tombol \"Download CA Certificate\" di bawah", "iOS akan menampilkan \"Profile Downloaded\"", "Buka Settings → General → VPN & Device Management", "Tap profile \"XCU Sovereign CA\" → Install", "Buka Settings → General → About → Certificate Trust Settings", "Enable trust untuk \"XCU Sovereign CA\"", "Selesai! Certificate berlaku 30 tahun" ] }, windows: { title: "Windows", icon: "🖥️", steps: [ "Klik tombol \"Download CA Certificate\" di bawah", "Double-click file xcu-sovereign-ca.crt", "Klik \"Install Certificate...\"", "Pilih \"Local Machine\" → Next", "Pilih \"Place all certificates in the following store\"", "Klik Browse → pilih \"Trusted Root Certification Authorities\"", "Klik Finish → Yes", "Restart browser. Selesai!" ] }, macos: { title: "macOS", icon: "💻", steps: [ "Klik tombol \"Download CA Certificate\" di bawah", "Double-click file xcu-sovereign-ca.crt → Keychain Access terbuka", "Certificate muncul di login keychain", "Double-click certificate → Trust → \"Always Trust\"", "Tutup dialog, masukkan password Mac", "Restart browser. Selesai!" ] }, linux: { title: "Linux", icon: "🐧", steps: [ "Download CA Certificate", "sudo cp xcu-sovereign-ca.crt /usr/local/share/ca-certificates/", "sudo update-ca-certificates", "Restart browser. Selesai!" ] }, unknown: { title: "Device", icon: "🔧", steps: ["Download CA Certificate dan install sesuai OS Anda"] } }; const currentOs = instructions[os] || instructions.unknown; return (
{/* Header */}

Sovereign Security Setup

{tenantName} • Private CA Installation

← Back to Dashboard
{/* Hero Card */}
🛡️

Mode Sovereign Aktif

Tenant ini beroperasi dalam Security Tier SOVEREIGN. Semua koneksi QUIC/WebTransport menggunakan Private CA yang tidak bergantung pada internet global. Setiap device perlu install sertifikat CA 1× saja, berlaku 30 tahun.

{/* Download Section */}

1 Download Certificate

Download CA Certificate
Format: X.509 PEM Validitas: 30 tahun Algorithm: RSA-4096 + SHA-256
{/* OS-Specific Instructions */}

2 Install Certificate

Terdeteksi: {currentOs.icon} {currentOs.title}

{/* OS Tabs */}
{Object.entries(instructions).filter(([k]) => k !== 'unknown').map(([key, val]) => ( ))}
{/* Steps */}
{currentOs.steps.map((step, idx) => (
{idx + 1}

{step}

))}
{/* Connection Test */}

3 Verify Connection

{certStatus === "ok" && (
Koneksi Aman — XCU Engine Online
)} {certStatus === "fail" && (
Koneksi Gagal — Pastikan certificate sudah terinstall
)}
{/* Info */}
XCom ULTRA • Sovereign Security Infrastructure • Private CA • Zero Internet Dependency
); }