supakeys 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +9 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -327,7 +327,7 @@ GRANT EXECUTE ON FUNCTION public.log_passkey_audit_event(public.passkey_audit_ev
|
|
|
327
327
|
}
|
|
328
328
|
function getEdgeFunctionCode() {
|
|
329
329
|
return `import { serve } from 'https://deno.land/std@0.208.0/http/server.ts';
|
|
330
|
-
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2.
|
|
330
|
+
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2.49.0';
|
|
331
331
|
import {
|
|
332
332
|
generateAuthenticationOptions,
|
|
333
333
|
generateRegistrationOptions,
|
|
@@ -498,10 +498,11 @@ serve(async (req: Request) => {
|
|
|
498
498
|
const publicKeyHex = '\\\\x' + uint8ArrayToHex(publicKeyBytes);
|
|
499
499
|
|
|
500
500
|
let userId: string;
|
|
501
|
-
const { data:
|
|
501
|
+
const { data: existingUsers } = await supabaseAdmin.auth.admin.listUsers();
|
|
502
|
+
const existingUser = existingUsers?.users?.find((u) => u.email === challenge.email);
|
|
502
503
|
|
|
503
|
-
if (existingUser
|
|
504
|
-
userId = existingUser.
|
|
504
|
+
if (existingUser) {
|
|
505
|
+
userId = existingUser.id;
|
|
505
506
|
} else {
|
|
506
507
|
const { data: newUser } = await supabaseAdmin.auth.admin.createUser({
|
|
507
508
|
email: challenge.email, email_confirm: true
|
|
@@ -551,14 +552,15 @@ serve(async (req: Request) => {
|
|
|
551
552
|
let userEmail = email as string | undefined;
|
|
552
553
|
|
|
553
554
|
if (email) {
|
|
554
|
-
const { data:
|
|
555
|
-
|
|
555
|
+
const { data: users } = await supabaseAdmin.auth.admin.listUsers();
|
|
556
|
+
const user = users?.users?.find((u) => u.email === email);
|
|
557
|
+
if (!user) {
|
|
556
558
|
result = error('CREDENTIAL_NOT_FOUND', 'No passkey found for this email');
|
|
557
559
|
break;
|
|
558
560
|
}
|
|
559
561
|
|
|
560
562
|
const { data: credentials } = await supabaseAdmin.from('passkey_credentials')
|
|
561
|
-
.select('id, transports').eq('user_id', user.
|
|
563
|
+
.select('id, transports').eq('user_id', user.id);
|
|
562
564
|
|
|
563
565
|
if (!credentials?.length) {
|
|
564
566
|
result = error('CREDENTIAL_NOT_FOUND', 'No passkey found for this email');
|