supabase_auth 2.5.1__tar.gz → 2.5.2__tar.gz

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.
Files changed (27) hide show
  1. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/PKG-INFO +1 -1
  2. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/pyproject.toml +2 -2
  3. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/__init__.py +1 -1
  4. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_async/gotrue_client.py +34 -10
  5. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_sync/gotrue_client.py +27 -9
  6. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/helpers.py +5 -0
  7. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/types.py +5 -0
  8. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/LICENSE +0 -0
  9. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/README.md +0 -0
  10. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_async/__init__.py +0 -0
  11. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_async/gotrue_admin_api.py +0 -0
  12. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_async/gotrue_admin_mfa_api.py +0 -0
  13. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_async/gotrue_base_api.py +0 -0
  14. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_async/gotrue_mfa_api.py +0 -0
  15. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_async/storage.py +0 -0
  16. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_sync/__init__.py +0 -0
  17. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_sync/api.py +0 -0
  18. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_sync/client.py +0 -0
  19. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_sync/gotrue_admin_api.py +0 -0
  20. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_sync/gotrue_admin_mfa_api.py +0 -0
  21. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_sync/gotrue_base_api.py +0 -0
  22. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_sync/gotrue_mfa_api.py +0 -0
  23. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/_sync/storage.py +0 -0
  24. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/constants.py +0 -0
  25. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/errors.py +0 -0
  26. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/http_clients.py +0 -0
  27. {supabase_auth-2.5.1 → supabase_auth-2.5.2}/supabase_auth/timer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: supabase_auth
3
- Version: 2.5.1
3
+ Version: 2.5.2
4
4
  Summary: Python Client Library for Supabase Auth
5
5
  Home-page: https://github.com/supabase-community/auth-py
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "supabase_auth"
3
- version = "2.5.1"
3
+ version = "2.5.2"
4
4
  description = "Python Client Library for Supabase Auth"
5
5
  authors = ["Joel Lee <joel@joellee.org>"]
6
6
  homepage = "https://github.com/supabase-community/auth-py"
@@ -28,7 +28,7 @@ pre-commit = "^3.4.0"
28
28
  pytest-cov = "^5.0.0"
29
29
  pytest-depends = "^1.0.1"
30
30
  pytest-asyncio = "^0.23.7"
31
- Faker = "^25.8.0"
31
+ Faker = "^25.9.1"
32
32
  unasync-cli = "^0.0.9"
33
33
  python-semantic-release = "^9.8.3"
34
34
 
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "2.5.1"
3
+ __version__ = "2.5.2"
4
4
 
5
5
  from ._async.gotrue_admin_api import AsyncGoTrueAdminAPI # type: ignore # noqa: F401
6
6
  from ._async.gotrue_client import AsyncGoTrueClient # type: ignore # noqa: F401
@@ -32,6 +32,7 @@ from ..helpers import (
32
32
  model_validate,
33
33
  parse_auth_otp_response,
34
34
  parse_auth_response,
35
+ parse_link_identity_response,
35
36
  parse_sso_response,
36
37
  parse_user_response,
37
38
  )
@@ -70,6 +71,7 @@ from ..types import (
70
71
  SignUpWithPasswordCredentials,
71
72
  Subscription,
72
73
  UserAttributes,
74
+ UserIdentity,
73
75
  UserResponse,
74
76
  VerifyOtpParams,
75
77
  )
@@ -366,10 +368,14 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
366
368
  params["redirect_to"] = redirect_to
367
369
  if scopes:
368
370
  params["scopes"] = scopes
369
- url = await self._get_url_for_provider(provider, params)
371
+ url = await self._get_url_for_provider(
372
+ f"{self._url}/authorize", provider, params
373
+ )
370
374
  return OAuthResponse(provider=provider, url=url)
371
375
 
372
- async def link_identity(self, credentials):
376
+ async def link_identity(
377
+ self, credentials: SignInWithOAuthCredentials
378
+ ) -> OAuthResponse:
373
379
  provider = credentials.get("provider")
374
380
  options = credentials.get("options", {})
375
381
  redirect_to = options.get("redirect_to")
@@ -379,23 +385,40 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
379
385
  params["redirect_to"] = redirect_to
380
386
  if scopes:
381
387
  params["scopes"] = scopes
382
- params["skip_browser_redirect"] = True
388
+ params["skip_http_redirect"] = "true"
389
+ url = await self._get_url_for_provider(
390
+ "user/identities/authorize", provider, params
391
+ )
383
392
 
384
- url = await self._get_url_for_provider(provider, params)
385
- return OAuthResponse(provider=provider, url=url)
393
+ session = await self.get_session()
394
+ if not session:
395
+ raise AuthSessionMissingError()
396
+
397
+ response = await self._request(
398
+ method="GET",
399
+ path=url,
400
+ jwt=session.access_token,
401
+ xform=parse_link_identity_response,
402
+ )
403
+ return OAuthResponse(provider=provider, url=response.url)
386
404
 
387
405
  async def get_user_identities(self):
388
- response = self.get_user()
406
+ response = await self.get_user()
389
407
  return (
390
408
  IdentitiesResponse(identities=response.user.identities)
391
409
  if response.user
392
410
  else AuthSessionMissingError()
393
411
  )
394
412
 
395
- async def unlink_identity(self, identity):
413
+ async def unlink_identity(self, identity: UserIdentity):
414
+ session = await self.get_session()
415
+ if not session:
416
+ raise AuthSessionMissingError()
417
+
396
418
  return await self._request(
397
- "POST",
398
- f"/user/identities/{identity.id}",
419
+ "DELETE",
420
+ f"user/identities/{identity.identity_id}",
421
+ jwt=session.access_token,
399
422
  )
400
423
 
401
424
  async def sign_in_with_otp(
@@ -975,6 +998,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
975
998
 
976
999
  async def _get_url_for_provider(
977
1000
  self,
1001
+ url: str,
978
1002
  provider: Provider,
979
1003
  params: Dict[str, str],
980
1004
  ) -> str:
@@ -992,7 +1016,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
992
1016
 
993
1017
  params["provider"] = provider
994
1018
  query = urlencode(params)
995
- return f"{self._url}/authorize?{query}"
1019
+ return f"{url}?{query}"
996
1020
 
997
1021
  def _decode_jwt(self, jwt: str) -> DecodedJWTDict:
998
1022
  """
@@ -32,6 +32,7 @@ from ..helpers import (
32
32
  model_validate,
33
33
  parse_auth_otp_response,
34
34
  parse_auth_response,
35
+ parse_link_identity_response,
35
36
  parse_sso_response,
36
37
  parse_user_response,
37
38
  )
@@ -70,6 +71,7 @@ from ..types import (
70
71
  SignUpWithPasswordCredentials,
71
72
  Subscription,
72
73
  UserAttributes,
74
+ UserIdentity,
73
75
  UserResponse,
74
76
  VerifyOtpParams,
75
77
  )
@@ -366,10 +368,10 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
366
368
  params["redirect_to"] = redirect_to
367
369
  if scopes:
368
370
  params["scopes"] = scopes
369
- url = self._get_url_for_provider(provider, params)
371
+ url = self._get_url_for_provider(f"{self._url}/authorize", provider, params)
370
372
  return OAuthResponse(provider=provider, url=url)
371
373
 
372
- def link_identity(self, credentials):
374
+ def link_identity(self, credentials: SignInWithOAuthCredentials) -> OAuthResponse:
373
375
  provider = credentials.get("provider")
374
376
  options = credentials.get("options", {})
375
377
  redirect_to = options.get("redirect_to")
@@ -379,10 +381,20 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
379
381
  params["redirect_to"] = redirect_to
380
382
  if scopes:
381
383
  params["scopes"] = scopes
382
- params["skip_browser_redirect"] = True
384
+ params["skip_http_redirect"] = "true"
385
+ url = self._get_url_for_provider("user/identities/authorize", provider, params)
383
386
 
384
- url = self._get_url_for_provider(provider, params)
385
- return OAuthResponse(provider=provider, url=url)
387
+ session = self.get_session()
388
+ if not session:
389
+ raise AuthSessionMissingError()
390
+
391
+ response = self._request(
392
+ method="GET",
393
+ path=url,
394
+ jwt=session.access_token,
395
+ xform=parse_link_identity_response,
396
+ )
397
+ return OAuthResponse(provider=provider, url=response.url)
386
398
 
387
399
  def get_user_identities(self):
388
400
  response = self.get_user()
@@ -392,10 +404,15 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
392
404
  else AuthSessionMissingError()
393
405
  )
394
406
 
395
- def unlink_identity(self, identity):
407
+ def unlink_identity(self, identity: UserIdentity):
408
+ session = self.get_session()
409
+ if not session:
410
+ raise AuthSessionMissingError()
411
+
396
412
  return self._request(
397
- "POST",
398
- f"/user/identities/{identity.id}",
413
+ "DELETE",
414
+ f"user/identities/{identity.identity_id}",
415
+ jwt=session.access_token,
399
416
  )
400
417
 
401
418
  def sign_in_with_otp(
@@ -973,6 +990,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
973
990
 
974
991
  def _get_url_for_provider(
975
992
  self,
993
+ url: str,
976
994
  provider: Provider,
977
995
  params: Dict[str, str],
978
996
  ) -> str:
@@ -988,7 +1006,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
988
1006
 
989
1007
  params["provider"] = provider
990
1008
  query = urlencode(params)
991
- return f"{self._url}/authorize?{query}"
1009
+ return f"{url}?{query}"
992
1010
 
993
1011
  def _decode_jwt(self, jwt: str) -> DecodedJWTDict:
994
1012
  """
@@ -17,6 +17,7 @@ from .types import (
17
17
  AuthResponse,
18
18
  GenerateLinkProperties,
19
19
  GenerateLinkResponse,
20
+ LinkIdentityResponse,
20
21
  Session,
21
22
  SSOResponse,
22
23
  User,
@@ -77,6 +78,10 @@ def parse_auth_otp_response(data: Any) -> AuthOtpResponse:
77
78
  return model_validate(AuthOtpResponse, data)
78
79
 
79
80
 
81
+ def parse_link_identity_response(data: Any) -> LinkIdentityResponse:
82
+ return model_validate(LinkIdentityResponse, data)
83
+
84
+
80
85
  def parse_link_response(data: Any) -> GenerateLinkResponse:
81
86
  properties = GenerateLinkProperties(
82
87
  action_link=data.get("action_link"),
@@ -104,6 +104,10 @@ class SSOResponse(BaseModel):
104
104
  url: str
105
105
 
106
106
 
107
+ class LinkIdentityResponse(BaseModel):
108
+ url: str
109
+
110
+
107
111
  class IdentitiesResponse(BaseModel):
108
112
  identities: List[UserIdentity]
109
113
 
@@ -151,6 +155,7 @@ class Session(BaseModel):
151
155
 
152
156
  class UserIdentity(BaseModel):
153
157
  id: str
158
+ identity_id: str
154
159
  user_id: str
155
160
  identity_data: Dict[str, Any]
156
161
  provider: str
File without changes
File without changes