Desktop oAuth integration

Co-authored-by: RagingLightning <RagingLightningCode@gmail.com>
This commit is contained in:
PxlLoewe
2025-05-09 08:36:01 -07:00
parent 1948d34963
commit 654bdfbbaa
8 changed files with 95 additions and 62 deletions

View File

@@ -1,4 +1,5 @@
"use server";
import { generateUUID } from "../../../../helper/uuid";
import { getServerSession } from "../../../api/auth/[...nextauth]/auth";
import { Service } from "../page";
import { PrismaClient } from "@repo/db";
@@ -9,15 +10,7 @@ export const generateToken = async (service: Service) => {
const session = await getServerSession();
if (!session) return null;
const key = await crypto.subtle.generateKey(
{ name: "HMAC", hash: "SHA-256" },
true,
["sign"],
);
const exportedKey = await crypto.subtle.exportKey("raw", key);
const accessToken = Array.from(new Uint8Array(exportedKey))
.map((byte) => byte.toString(16).padStart(2, "0"))
.join("");
const accessToken = generateUUID(16);
const code = await prisma.oAuthToken.create({
data: {