SPB Git

Repository Public

route.ts 861 B 21 lines typescript

1import { z } from "zod";2import type { AuthenticationResponseJSON } from "@simplewebauthn/server";3import { apiSession, json } from "@/lib/auth";4import { reauthVerify } from "@/lib/webauthn";5import { credentialSchema, gate, handle, readBody } from "../../../_lib";67export const runtime = "nodejs";8export const dynamic = "force-dynamic";910export async function POST(req: Request) {11  return handle(async () => {12    const g = await gate(req, "reauth-verify", 10);13    if (g.error) return g.error;14    const s = await apiSession(req);15    if (s.error) return s.error;16    const body = await readBody(req, z.object({ response: credentialSchema }));17    const r = await reauthVerify({ session: s.session, response: body.response as unknown as AuthenticationResponseJSON, ctx: g.ctx });18    return json({ ok: true, reauthAt: r.reauthAt.toISOString() });19  });20}21
Files main
Menu

Theme