"use server" import type { OAuthSession } from "@/types"; export async function fetchSession(token: string): Promise { if (!token) return null; try { const response = await fetch( `${process.env.KOTOSOFT_ID_API_URL}/oauth/session/${token}`, { cache: "no-store" } ); if (!response.ok) return null; return await response.json() as OAuthSession; } catch { return null; } } export async function Approve(session: string, allow: boolean): Promise { if (!session) return null; try { const response = await fetch(`${process.env.KOTOSOFT_ID_API_URL}/oauth/session/approve`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ session, allow }), cache: "no-store", }); if (!response.ok) return null; const data = await response.json(); return data.redirect_url ?? null; } catch { return null; } }