🪻 distributed transcription service thistle.dunkirk.sh
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: return error instead of throwing for passkey not found

🪻 Generated with Crush

Co-Authored-By: Crush <crush@charm.land>

+11 -3
+9 -1
src/index.ts
··· 331 331 const body = await req.json(); 332 332 const { response: credentialResponse, challenge } = body; 333 333 334 - const { user } = await verifyAndAuthenticatePasskey( 334 + const result = await verifyAndAuthenticatePasskey( 335 335 credentialResponse, 336 336 challenge, 337 337 ); 338 + 339 + if ("error" in result) { 340 + return new Response(JSON.stringify({ error: result.error }), { 341 + status: 401, 342 + }); 343 + } 344 + 345 + const { user } = result; 338 346 339 347 // Create session 340 348 const ipAddress =
+2 -2
src/lib/passkey.ts
··· 246 246 export async function verifyAndAuthenticatePasskey( 247 247 response: AuthenticationResponseJSON, 248 248 expectedChallenge: string, 249 - ): Promise<{ passkey: Passkey; user: User }> { 249 + ): Promise<{ passkey: Passkey; user: User } | { error: string }> { 250 250 // Validate challenge 251 251 const challengeData = authenticationChallenges.get(expectedChallenge); 252 252 if (!challengeData) { ··· 268 268 .get(response.id); 269 269 270 270 if (!passkey) { 271 - throw new Error("Passkey not found"); 271 + return { error: "Passkey not found" }; 272 272 } 273 273 274 274 const { origin, rpID } = getRPConfig();