From 4a19c35000bfe3be6d6390b606c5d50b58843748 Mon Sep 17 00:00:00 2001 From: Patryk Kalinowski Date: Fri, 14 Jun 2024 17:01:43 +0200 Subject: [PATCH] fix legacy email auth's finalizeAuth (#24) --- src/utils/useEmailAuth.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/useEmailAuth.ts b/src/utils/useEmailAuth.ts index 3b201f5..78a474c 100644 --- a/src/utils/useEmailAuth.ts +++ b/src/utils/useEmailAuth.ts @@ -28,8 +28,11 @@ export function useEmailAuth({ onSuccess }: { onSuccess: (idToken: string) => vo try { const sessionHash = await sequence.getSessionHash() - const { idToken } = await sequence.email.finalizeAuth({ instance, answer, email, sessionHash }) - onSuccess(idToken) + const identity = await sequence.email.finalizeAuth({ instance, answer, email, sessionHash }) + if (!('idToken' in identity)) { + throw new Error("invalid identity returned by finalizeAuth") + } + onSuccess(identity.idToken) } catch (e: any) { setError(e.message || "Unknown error") } finally {