feat: add WebAuthn Experience API functions to sign-in UI
Adds startWebAuthnAuth and verifyWebAuthnAuth functions that call the Logto Experience API WebAuthn endpoints for passkey MFA verification. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -273,3 +273,28 @@ export async function submitMfa(verificationId: string): Promise<string> {
|
|||||||
await identifyUser(verificationId);
|
await identifyUser(verificationId);
|
||||||
return submitInteraction();
|
return submitInteraction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- WebAuthn MFA Verification ---
|
||||||
|
|
||||||
|
export async function startWebAuthnAuth(): Promise<Record<string, unknown>> {
|
||||||
|
const res = await request('POST', '/verification/web-authn/authentication');
|
||||||
|
if (!res.ok) {
|
||||||
|
const err = await res.json().catch(() => ({}));
|
||||||
|
throw new Error(err.message || `Failed to start passkey authentication (${res.status})`);
|
||||||
|
}
|
||||||
|
const data = await res.json();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function verifyWebAuthnAuth(payload: Record<string, unknown>): Promise<string> {
|
||||||
|
const res = await request('POST', '/verification/web-authn/authentication/verify', payload);
|
||||||
|
if (!res.ok) {
|
||||||
|
const err = await res.json().catch(() => ({}));
|
||||||
|
if (res.status === 422) {
|
||||||
|
throw new Error('Passkey verification failed. Please try again.');
|
||||||
|
}
|
||||||
|
throw new Error(err.message || `Passkey verification failed (${res.status})`);
|
||||||
|
}
|
||||||
|
const data = await res.json();
|
||||||
|
return data.verificationId;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user