Add passkey and magic link authentication
This commit is contained in:
@@ -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 });
|
||||
};
|
||||
Reference in New Issue
Block a user