Security key support

This commit is contained in:
Jack Mechem 2026-05-01 14:33:52 -07:00
parent ede90f8c7f
commit c991fe7b6d
6 changed files with 384 additions and 47 deletions

View file

@ -0,0 +1,17 @@
import { NextRequest, NextResponse } from "next/server";
export async function POST(req: NextRequest) {
const body = await req.json();
const res = await fetch("http://localhost:3001/auth/register/finish", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
if (!res.ok) {
return NextResponse.json({ error: "Registration failed" }, { status: 400 });
}
return NextResponse.json(await res.json());
}

View file

@ -0,0 +1,20 @@
import { NextRequest, NextResponse } from "next/server";
export async function POST(req: NextRequest) {
const { username, password } = await req.json();
const res = await fetch("http://localhost:3001/auth/register/start", {
method: "POST",
headers: {
Authorization:
"Basic " +
Buffer.from(`${username}:${password}`).toString("base64"),
},
});
if (!res.ok) {
return NextResponse.json({ error: "Invalid credentials" }, { status: 401 });
}
return NextResponse.json(await res.json());
}