diff --git a/src/GoTrueClient.ts b/src/GoTrueClient.ts index 4edf4bc1..5c4fbb3e 100644 --- a/src/GoTrueClient.ts +++ b/src/GoTrueClient.ts @@ -2396,7 +2396,6 @@ export default class GoTrueClient { return { data: null, error } } - // TODO: Remove once: https://github.com/supabase/auth/pull/1717 is deployed if (params.factorType === 'phone') { delete data.totp } @@ -2470,7 +2469,7 @@ export default class GoTrueClient { // If we reach here, it means none of the conditions were met return { data: null, error: new Error('Invalid MFA parameters') } }) - // TODO: Fix thsi hack + // TODO: Fix this hack return result } catch (error) { if (isAuthError(error)) { @@ -2532,12 +2531,13 @@ export default class GoTrueClient { return { data: null, error: factorsError } } - if (!factors || !factors.webauthn || factors.webauthn.length === 0) { - // TODO: Come back and fix thsi code + if (!factors || !factors.all || factors.all.length === 0) { + return { data: null, error: new AuthError('No WebAuthn factor found', 400, 'MFA_ERROR') } + } + const webauthnFactor = factors.all.find((factor) => factor.factor_type === 'webauthn') + if (!webauthnFactor) { return { data: null, error: new AuthError('No WebAuthn factor found', 400, 'MFA_ERROR') } } - - const webauthnFactor = factors.webauthn[0] const { data: challengeResponse, error: challengeError } = await this._challenge({ factorId: webauthnFactor.id, diff --git a/src/lib/types.ts b/src/lib/types.ts index ea9638ff..3ffb790d 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -302,9 +302,9 @@ export interface Factor { friendly_name?: string /** - * Type of factor. `totp` and `phone` supported with this version + * Type of factor. `totp`, `webauthn`, and `phone` supported with this version */ - factor_type: 'totp' | 'phone' | string + factor_type: 'totp' | 'phone' | 'webauthn' | string /** Factor's status. */ status: 'verified' | 'unverified'