diff --git a/infra/docker-compose.yml b/infra/docker-compose.yml index dcced8bd..a4cf04c7 100644 --- a/infra/docker-compose.yml +++ b/infra/docker-compose.yml @@ -106,7 +106,7 @@ services: - '9000:9000' # web interface - '1100:1100' # POP3 db: - image: supabase/postgres:latest + image: supabase/postgres:15.1.1.66 ports: - '5432:5432' command: postgres -c config_file=/etc/postgresql/postgresql.conf diff --git a/supabase_auth/_async/gotrue_client.py b/supabase_auth/_async/gotrue_client.py index 3e93d005..1fe60de7 100644 --- a/supabase_auth/_async/gotrue_client.py +++ b/supabase_auth/_async/gotrue_client.py @@ -61,9 +61,11 @@ Options, Provider, Session, + SignInAnonymouslyCredentials, SignInWithOAuthCredentials, SignInWithPasswordCredentials, SignInWithPasswordlessCredentials, + SignInWithSSOCredentials, SignOutOptions, SignUpWithPasswordCredentials, Subscription, @@ -149,6 +151,34 @@ async def initialize_from_url(self, url: str) -> None: # Public methods + async def sign_in_anonymously( + self, credentials: Union[SignInAnonymouslyCredentials, None] = None + ) -> AuthResponse: + """ + Creates a new anonymous user. + """ + self._remove_session() + if credentials is None: + credentials = {"options": {}} + options = credentials.get("options", {}) + data = options.get("data") or {} + captcha_token = options.get("captcha_token") + response = self._request( + "POST", + "signup", + body={ + "data": data, + "gotrue_meta_security": { + "captcha_token": captcha_token, + }, + }, + xform=parse_auth_response, + ) + if response.session: + self._save_session(response.session) + self._notify_all_subscribers("SIGNED_IN", response.session) + return response + async def sign_up( self, credentials: SignUpWithPasswordCredentials, diff --git a/supabase_auth/_sync/gotrue_client.py b/supabase_auth/_sync/gotrue_client.py index ec8e22f3..6a8c764f 100644 --- a/supabase_auth/_sync/gotrue_client.py +++ b/supabase_auth/_sync/gotrue_client.py @@ -61,9 +61,11 @@ Options, Provider, Session, + SignInAnonymouslyCredentials, SignInWithOAuthCredentials, SignInWithPasswordCredentials, SignInWithPasswordlessCredentials, + SignInWithSSOCredentials, SignOutOptions, SignUpWithPasswordCredentials, Subscription, @@ -149,6 +151,34 @@ def initialize_from_url(self, url: str) -> None: # Public methods + def sign_in_anonymously( + self, credentials: Union[SignInAnonymouslyCredentials, None] = None + ) -> AuthResponse: + """ + Creates a new anonymous user. + """ + self._remove_session() + if credentials is None: + credentials = {"options": {}} + options = credentials.get("options", {}) + data = options.get("data") or {} + captcha_token = options.get("captcha_token") + response = self._request( + "POST", + "signup", + body={ + "data": data, + "gotrue_meta_security": { + "captcha_token": captcha_token, + }, + }, + xform=parse_auth_response, + ) + if response.session: + self._save_session(response.session) + self._notify_all_subscribers("SIGNED_IN", response.session) + return response + def sign_up( self, credentials: SignUpWithPasswordCredentials, diff --git a/supabase_auth/types.py b/supabase_auth/types.py index ee260b04..53877eba 100644 --- a/supabase_auth/types.py +++ b/supabase_auth/types.py @@ -348,6 +348,15 @@ class SignInWithSSOOptions(TypedDict): skip_http_redirect: NotRequired[bool] +class SignInAnonymouslyCredentials(TypedDict): + options: NotRequired[SignInAnonymouslyCredentialsOptions] + + +class SignInAnonymouslyCredentialsOptions(TypedDict): + data: NotRequired[Any] + captcha_token: NotRequired[str] + + class VerifyOtpParamsOptions(TypedDict): redirect_to: NotRequired[str] captcha_token: NotRequired[str]