diff --git a/supabase_auth/_async/gotrue_client.py b/supabase_auth/_async/gotrue_client.py index 11e79ce9..e76be9d1 100644 --- a/supabase_auth/_async/gotrue_client.py +++ b/supabase_auth/_async/gotrue_client.py @@ -805,14 +805,14 @@ async def _enroll(self, params: MFAEnrollParams) -> AuthMFAEnrollResponse: raise AuthSessionMissingError() body = { - "friendly_name": params["friendly_name"], - "factor_type": params["factor_type"], + "friendly_name": params.get("friendly_name"), + "factor_type": params.get("factor_type"), } if params["factor_type"] == "phone": - body["phone"] = params["phone"] + body["phone"] = params.get("phone") else: - body["issuer"] = params["issuer"] + body["issuer"] = params.get("issuer") response = await self._request( "POST", diff --git a/supabase_auth/_sync/gotrue_client.py b/supabase_auth/_sync/gotrue_client.py index d45d6c92..de05af55 100644 --- a/supabase_auth/_sync/gotrue_client.py +++ b/supabase_auth/_sync/gotrue_client.py @@ -801,14 +801,14 @@ def _enroll(self, params: MFAEnrollParams) -> AuthMFAEnrollResponse: raise AuthSessionMissingError() body = { - "friendly_name": params["friendly_name"], - "factor_type": params["factor_type"], + "friendly_name": params.get("friendly_name"), + "factor_type": params.get("factor_type"), } if params["factor_type"] == "phone": - body["phone"] = params["phone"] + body["phone"] = params.get("phone") else: - body["issuer"] = params["issuer"] + body["issuer"] = params.get("issuer") response = self._request( "POST", diff --git a/supabase_auth/types.py b/supabase_auth/types.py index 709e17c3..add18e64 100644 --- a/supabase_auth/types.py +++ b/supabase_auth/types.py @@ -4,7 +4,7 @@ from time import time from typing import Any, Callable, Dict, List, Optional, Union -from pydantic import BaseModel, ConfigDict +from pydantic import BaseModel, ConfigDict, Field try: # > 2 @@ -643,7 +643,7 @@ class AuthMFAEnrollResponse(BaseModel): """ Type of MFA factor. Only `totp` supported for now. """ - totp: AuthMFAEnrollResponseTotp + totp: Optional[AuthMFAEnrollResponseTotp] = None """ TOTP enrollment information. """ @@ -680,7 +680,9 @@ class AuthMFAChallengeResponse(BaseModel): """ Timestamp in UNIX seconds when this challenge will no longer be usable. """ - factor_type: Optional[Literal["totp", "phone"]] = None + factor_type: Optional[Literal["totp", "phone"]] = Field( + validation_alias="type", default=None + ) """ Factor Type which generated the challenge """