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
+52
View File
@@ -0,0 +1,52 @@
"use server"
import { Consent } from "@/types"
import { cookies } from "next/headers"
export async function getConsents() {
const store = await cookies()
const accessToken = store.get("access_token")?.value
const response = await fetch(
`${process.env.KOTOSOFT_ID_API_URL}/api/v1/me/consents`,
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
}
)
if (!response.ok) return []
var consents = await response.json() as Consent[];
consents.forEach((consent: Consent) => {
if (consent.client_id == process.env.CLIENT_ID) {
consent.isRevokable == false
} else {
consent.isRevokable == true
}
});
return consents
}
export async function revokeConsent(clientId: string) {
const store = await cookies()
const accessToken = store.get("access_token")?.value
const response = await fetch(
`${process.env.KOTOSOFT_ID_API_URL}/api/v1/me/applications/${clientId}`,
{
method: "DELETE",
headers: {
Authorization: `Bearer ${accessToken}`,
},
}
)
if (!response.ok) {
return { success: false }
}
return { success: true }
}