Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 2x 2x 7x 7x 7x | import { NextResponse } from "next/server";
import { issueChallenge } from "@/lib/app-attest";
import { createRateLimiter } from "@/lib/rate-limit";
export const dynamic = "force-dynamic";
const limiter = createRateLimiter({
windowMs: 60_000,
perKey: 10,
inTotal: 600,
});
/**
* POST /api/app-accounts/challenge
*
* The value the Klarbefund app has Apple attest before it may create an
* account (ADR-054). Answers without a session, because the person has no
* account yet; it hands out nothing but a signed, five-minute challenge.
*/
export async function POST(request: Request) {
const address = request.headers.get("x-forwarded-for")?.split(",")[0]?.trim();
Iif (!limiter.allow(address || "unknown")) {
return NextResponse.json(
{ error: "Too many requests, try again in a minute" },
{ status: 429 },
);
}
return NextResponse.json({ challenge: issueChallenge() });
}
|