feat: ci/cd

This commit is contained in:
Giovanni Rezcjikov
2026-03-09 12:50:29 +03:00
parent f4e4fb21e3
commit daaa702dad
21 changed files with 585 additions and 267 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ export async function clearTokens() {
store.delete("refresh_token");
}
async function tryRefresh(): Promise<boolean> {
export async function tryRefresh(): Promise<boolean> {
if (refreshPromise) return refreshPromise;
refreshPromise = (async () => {
+13 -3
View File
@@ -2,6 +2,7 @@
import { Consent } from "@/types"
import { cookies } from "next/headers"
import { clearTokens, tryRefresh } from "./auth"
export async function getConsents() {
const store = await cookies()
@@ -15,15 +16,24 @@ export async function getConsents() {
},
}
)
if (response.status === 401) {
const refreshed = await tryRefresh();
if (!refreshed) {
await clearTokens();
return null;
}
return getConsents();
}
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
consent.isRevokable = false
} else {
consent.isRevokable == true
consent.isRevokable = true
}
});
@@ -35,7 +45,7 @@ export async function revokeConsent(clientId: string) {
const accessToken = store.get("access_token")?.value
const response = await fetch(
`${process.env.KOTOSOFT_ID_API_URL}/api/v1/me/applications/${clientId}`,
`${process.env.KOTOSOFT_ID_API_URL}/api/v1/me/consents/${clientId}`,
{
method: "DELETE",
headers: {