supabase_auth 2.5.0__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.0 → supabase_auth-2.5.2}/PKG-INFO +1 -1
  2. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/pyproject.toml +4 -4
  3. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/__init__.py +1 -1
  4. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_async/gotrue_client.py +39 -11
  5. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_sync/gotrue_client.py +32 -10
  6. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/helpers.py +5 -0
  7. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/types.py +7 -0
  8. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/LICENSE +0 -0
  9. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/README.md +0 -0
  10. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_async/__init__.py +0 -0
  11. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_async/gotrue_admin_api.py +0 -0
  12. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_async/gotrue_admin_mfa_api.py +0 -0
  13. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_async/gotrue_base_api.py +0 -0
  14. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_async/gotrue_mfa_api.py +0 -0
  15. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_async/storage.py +0 -0
  16. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_sync/__init__.py +0 -0
  17. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_sync/api.py +0 -0
  18. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_sync/client.py +0 -0
  19. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_sync/gotrue_admin_api.py +0 -0
  20. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_sync/gotrue_admin_mfa_api.py +0 -0
  21. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_sync/gotrue_base_api.py +0 -0
  22. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_sync/gotrue_mfa_api.py +0 -0
  23. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/_sync/storage.py +0 -0
  24. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/constants.py +0 -0
  25. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/errors.py +0 -0
  26. {supabase_auth-2.5.0 → supabase_auth-2.5.2}/supabase_auth/http_clients.py +0 -0
  27. {supabase_auth-2.5.0 → 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.0
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.0"
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"
@@ -20,7 +20,7 @@ httpx = ">=0.23,<0.28"
20
20
  pydantic = ">=1.10,<3"
21
21
 
22
22
  [tool.poetry.dev-dependencies]
23
- pytest = "^8.2.1"
23
+ pytest = "^8.2.2"
24
24
  flake8 = "^5.0.4"
25
25
  black = "^24.4.2"
26
26
  isort = "^5.12.0"
@@ -28,9 +28,9 @@ 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.4.0"
31
+ Faker = "^25.9.1"
32
32
  unasync-cli = "^0.0.9"
33
- python-semantic-release = "^9.8.1"
33
+ python-semantic-release = "^9.8.3"
34
34
 
35
35
  [tool.poetry.group.dev.dependencies]
36
36
  pygithub = ">=1.57,<3.0"
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "2.5.0"
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
  )
@@ -191,8 +193,9 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
191
193
  phone = credentials.get("phone")
192
194
  password = credentials.get("password")
193
195
  options = credentials.get("options", {})
194
- redirect_to = options.get("redirect_to")
196
+ redirect_to = options.get("redirect_to") or options.get("email_redirect_to")
195
197
  data = options.get("data") or {}
198
+ channel = options.get("channel", "sms")
196
199
  captcha_token = options.get("captcha_token")
197
200
  if email:
198
201
  response = await self._request(
@@ -217,6 +220,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
217
220
  "phone": phone,
218
221
  "password": password,
219
222
  "data": data,
223
+ "channel": channel,
220
224
  "gotrue_meta_security": {
221
225
  "captcha_token": captcha_token,
222
226
  },
@@ -364,10 +368,14 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
364
368
  params["redirect_to"] = redirect_to
365
369
  if scopes:
366
370
  params["scopes"] = scopes
367
- 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
+ )
368
374
  return OAuthResponse(provider=provider, url=url)
369
375
 
370
- async def link_identity(self, credentials):
376
+ async def link_identity(
377
+ self, credentials: SignInWithOAuthCredentials
378
+ ) -> OAuthResponse:
371
379
  provider = credentials.get("provider")
372
380
  options = credentials.get("options", {})
373
381
  redirect_to = options.get("redirect_to")
@@ -377,23 +385,40 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
377
385
  params["redirect_to"] = redirect_to
378
386
  if scopes:
379
387
  params["scopes"] = scopes
380
- 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
+ )
381
392
 
382
- url = await self._get_url_for_provider(provider, params)
383
- 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)
384
404
 
385
405
  async def get_user_identities(self):
386
- response = self.get_user()
406
+ response = await self.get_user()
387
407
  return (
388
408
  IdentitiesResponse(identities=response.user.identities)
389
409
  if response.user
390
410
  else AuthSessionMissingError()
391
411
  )
392
412
 
393
- 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
+
394
418
  return await self._request(
395
- "POST",
396
- f"/user/identities/{identity.id}",
419
+ "DELETE",
420
+ f"user/identities/{identity.identity_id}",
421
+ jwt=session.access_token,
397
422
  )
398
423
 
399
424
  async def sign_in_with_otp(
@@ -419,6 +444,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
419
444
  email_redirect_to = options.get("email_redirect_to")
420
445
  should_create_user = options.get("create_user", True)
421
446
  data = options.get("data")
447
+ channel = options.get("channel", "sms")
422
448
  captcha_token = options.get("captcha_token")
423
449
  if email:
424
450
  return await self._request(
@@ -443,6 +469,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
443
469
  "phone": phone,
444
470
  "data": data,
445
471
  "create_user": should_create_user,
472
+ "channel": channel,
446
473
  "gotrue_meta_security": {
447
474
  "captcha_token": captcha_token,
448
475
  },
@@ -971,6 +998,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
971
998
 
972
999
  async def _get_url_for_provider(
973
1000
  self,
1001
+ url: str,
974
1002
  provider: Provider,
975
1003
  params: Dict[str, str],
976
1004
  ) -> str:
@@ -988,7 +1016,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
988
1016
 
989
1017
  params["provider"] = provider
990
1018
  query = urlencode(params)
991
- return f"{self._url}/authorize?{query}"
1019
+ return f"{url}?{query}"
992
1020
 
993
1021
  def _decode_jwt(self, jwt: str) -> DecodedJWTDict:
994
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
  )
@@ -191,8 +193,9 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
191
193
  phone = credentials.get("phone")
192
194
  password = credentials.get("password")
193
195
  options = credentials.get("options", {})
194
- redirect_to = options.get("redirect_to")
196
+ redirect_to = options.get("redirect_to") or options.get("email_redirect_to")
195
197
  data = options.get("data") or {}
198
+ channel = options.get("channel", "sms")
196
199
  captcha_token = options.get("captcha_token")
197
200
  if email:
198
201
  response = self._request(
@@ -217,6 +220,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
217
220
  "phone": phone,
218
221
  "password": password,
219
222
  "data": data,
223
+ "channel": channel,
220
224
  "gotrue_meta_security": {
221
225
  "captcha_token": captcha_token,
222
226
  },
@@ -364,10 +368,10 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
364
368
  params["redirect_to"] = redirect_to
365
369
  if scopes:
366
370
  params["scopes"] = scopes
367
- url = self._get_url_for_provider(provider, params)
371
+ url = self._get_url_for_provider(f"{self._url}/authorize", provider, params)
368
372
  return OAuthResponse(provider=provider, url=url)
369
373
 
370
- def link_identity(self, credentials):
374
+ def link_identity(self, credentials: SignInWithOAuthCredentials) -> OAuthResponse:
371
375
  provider = credentials.get("provider")
372
376
  options = credentials.get("options", {})
373
377
  redirect_to = options.get("redirect_to")
@@ -377,10 +381,20 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
377
381
  params["redirect_to"] = redirect_to
378
382
  if scopes:
379
383
  params["scopes"] = scopes
380
- params["skip_browser_redirect"] = True
384
+ params["skip_http_redirect"] = "true"
385
+ url = self._get_url_for_provider("user/identities/authorize", provider, params)
381
386
 
382
- url = self._get_url_for_provider(provider, params)
383
- 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)
384
398
 
385
399
  def get_user_identities(self):
386
400
  response = self.get_user()
@@ -390,10 +404,15 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
390
404
  else AuthSessionMissingError()
391
405
  )
392
406
 
393
- 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
+
394
412
  return self._request(
395
- "POST",
396
- f"/user/identities/{identity.id}",
413
+ "DELETE",
414
+ f"user/identities/{identity.identity_id}",
415
+ jwt=session.access_token,
397
416
  )
398
417
 
399
418
  def sign_in_with_otp(
@@ -419,6 +438,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
419
438
  email_redirect_to = options.get("email_redirect_to")
420
439
  should_create_user = options.get("create_user", True)
421
440
  data = options.get("data")
441
+ channel = options.get("channel", "sms")
422
442
  captcha_token = options.get("captcha_token")
423
443
  if email:
424
444
  return self._request(
@@ -443,6 +463,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
443
463
  "phone": phone,
444
464
  "data": data,
445
465
  "create_user": should_create_user,
466
+ "channel": channel,
446
467
  "gotrue_meta_security": {
447
468
  "captcha_token": captcha_token,
448
469
  },
@@ -969,6 +990,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
969
990
 
970
991
  def _get_url_for_provider(
971
992
  self,
993
+ url: str,
972
994
  provider: Provider,
973
995
  params: Dict[str, str],
974
996
  ) -> str:
@@ -984,7 +1006,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
984
1006
 
985
1007
  params["provider"] = provider
986
1008
  query = urlencode(params)
987
- return f"{self._url}/authorize?{query}"
1009
+ return f"{url}?{query}"
988
1010
 
989
1011
  def _decode_jwt(self, jwt: str) -> DecodedJWTDict:
990
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
@@ -260,6 +265,7 @@ class SignUpWithEmailAndPasswordCredentials(TypedDict):
260
265
  class SignUpWithPhoneAndPasswordCredentialsOptions(TypedDict):
261
266
  data: NotRequired[Any]
262
267
  captcha_token: NotRequired[str]
268
+ channel: NotRequired[Literal["sms", "whatsapp"]]
263
269
 
264
270
 
265
271
  class SignUpWithPhoneAndPasswordCredentials(TypedDict):
@@ -313,6 +319,7 @@ class SignInWithPhoneAndPasswordlessCredentialsOptions(TypedDict):
313
319
  should_create_user: NotRequired[bool]
314
320
  data: NotRequired[Any]
315
321
  captcha_token: NotRequired[str]
322
+ channel: NotRequired[Literal["sms", "whatsapp"]]
316
323
 
317
324
 
318
325
  class SignInWithPhoneAndPasswordlessCredentials(TypedDict):
File without changes
File without changes