Add passkey and magic link authentication

This commit is contained in:
JB
2026-07-25 01:54:33 -04:00
parent 3c9f443499
commit c3244b0c79
31 changed files with 1017 additions and 58 deletions
@@ -0,0 +1,17 @@
import { passkeyContext, storeChallenge } from '$lib/server/auth/passkeys';
import { getDatabase } from '$lib/server/database';
import { generateAuthenticationOptions } from '@simplewebauthn/server';
import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
export const POST: RequestHandler = async ({ url }) => {
const database = await getDatabase();
const context = passkeyContext(url);
const options = await generateAuthenticationOptions({
rpID: context.rpID,
userVerification: 'required',
allowCredentials: []
});
const challengeId = await storeChallenge(database, 'authentication', options.challenge, context);
return json({ options, challengeId });
};