blob: 228b254e3e9294744bf1ad41fba9b1e8f52b7680 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import { startRegistration, startAuthentication } from "@simplewebauthn/browser";
import { post } from "$lib/utils";
export async function registerPasskey() {
const options = await post("/passkey/register/options", {});
const registration = await startRegistration({ optionsJSON: options });
await post("/passkey/register/verify", registration);
}
export async function loginWithPasskey() {
const { challengeId, ...options } = await post("/passkey/login/options", {});
const authentication = await startAuthentication({ optionsJSON: options });
return { credential: authentication, challengeId };
}
|