initial commit

This commit is contained in:
Giovanni Rezcjikov
2026-03-08 14:54:29 +03:00
commit f4e4fb21e3
75 changed files with 7407 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
"use server"
import type { OAuthSession } from "@/types";
export async function getSession(token: string): Promise<OAuthSession | null> {
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<string | null> {
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;
}
}