supabase_auth 2.32.0__tar.gz → 2.34.0__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 (29) hide show
  1. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/PKG-INFO +10 -4
  2. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/README.md +6 -0
  3. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/pyproject.toml +4 -5
  4. supabase_auth-2.34.0/src/supabase_auth/__init__.py +20 -0
  5. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_async/gotrue_admin_api.py +29 -26
  6. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_async/gotrue_admin_oauth_api.py +1 -3
  7. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_async/gotrue_base_api.py +20 -18
  8. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_async/gotrue_client.py +271 -175
  9. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_async/storage.py +3 -4
  10. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_sync/gotrue_admin_api.py +29 -26
  11. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_sync/gotrue_admin_oauth_api.py +1 -3
  12. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_sync/gotrue_base_api.py +20 -18
  13. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_sync/gotrue_client.py +267 -171
  14. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_sync/storage.py +3 -4
  15. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/constants.py +0 -1
  16. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/errors.py +18 -12
  17. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/helpers.py +44 -70
  18. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/timer.py +14 -6
  19. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/types.py +135 -146
  20. supabase_auth-2.34.0/src/supabase_auth/version.py +1 -0
  21. supabase_auth-2.32.0/src/supabase_auth/__init__.py +0 -16
  22. supabase_auth-2.32.0/src/supabase_auth/version.py +0 -1
  23. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_async/__init__.py +0 -0
  24. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_async/gotrue_admin_mfa_api.py +0 -0
  25. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_async/gotrue_mfa_api.py +0 -0
  26. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_sync/__init__.py +0 -0
  27. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_sync/gotrue_admin_mfa_api.py +0 -0
  28. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/_sync/gotrue_mfa_api.py +0 -0
  29. {supabase_auth-2.32.0 → supabase_auth-2.34.0}/src/supabase_auth/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: supabase-auth
3
- Version: 2.32.0
3
+ Version: 2.34.0
4
4
  Summary: Python Client Library for Supabase Auth
5
5
  Author: Joel Lee
6
6
  Author-email: Joel Lee <joel@joellee.org>
@@ -9,11 +9,11 @@ Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Requires-Dist: httpx[http2]>=0.26,<0.29
12
- Requires-Dist: pydantic>=1.10,<3
13
- Requires-Dist: pyjwt[crypto]>=2.12.0
12
+ Requires-Dist: pydantic>=2.11.7,<3
13
+ Requires-Dist: pyjwt[crypto]>=2.15.1
14
14
  Maintainer: Leonardo Santiago
15
15
  Maintainer-email: Leonardo Santiago <leonardo.santiago@supabase.io>
16
- Requires-Python: >=3.9
16
+ Requires-Python: >=3.11
17
17
  Project-URL: changelog, https://github.com/supabase/supabase-py/tree/main/CHANGELOG.md
18
18
  Project-URL: documentation, https://github.com/supabase/supabase-py/tree/main/src/auth
19
19
  Project-URL: homepage, https://github.com/supabase/supabase-py/tree/main/src/auth
@@ -82,6 +82,12 @@ The other key difference is we do not use pascalCase to encode variable and meth
82
82
 
83
83
  Also, the `supabase_auth` library for Python parses the date-time string into `datetime` Python objects. The [JS client](https://github.com/supabase/gotrue-js) keeps the date-time as strings.
84
84
 
85
+ ## Supabase Service Compatibility
86
+
87
+ `supabase_auth` only guarantees compatibility with the [latest Supabase Auth release](https://github.com/supabase/auth/releases). Older Supabase Auth releases are supported on a best-effort basis, but compatibility is not guaranteed.
88
+
89
+ If you self-host Supabase Auth, we recommend upgrading to the latest release when upgrading this SDK.
90
+
85
91
  ## Usage
86
92
 
87
93
  The library provides both synchronous and asynchronous clients. Here are some examples:
@@ -60,6 +60,12 @@ The other key difference is we do not use pascalCase to encode variable and meth
60
60
 
61
61
  Also, the `supabase_auth` library for Python parses the date-time string into `datetime` Python objects. The [JS client](https://github.com/supabase/gotrue-js) keeps the date-time as strings.
62
62
 
63
+ ## Supabase Service Compatibility
64
+
65
+ `supabase_auth` only guarantees compatibility with the [latest Supabase Auth release](https://github.com/supabase/auth/releases). Older Supabase Auth releases are supported on a best-effort basis, but compatibility is not guaranteed.
66
+
67
+ If you self-host Supabase Auth, we recommend upgrading to the latest release when upgrading this SDK.
68
+
63
69
  ## Usage
64
70
 
65
71
  The library provides both synchronous and asynchronous clients. Here are some examples:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "supabase_auth"
3
- version = "2.32.0" # {x-release-please-version}
3
+ version = "2.34.0" # {x-release-please-version}
4
4
  description = "Python Client Library for Supabase Auth"
5
5
  authors = [
6
6
  {name = "Joel Lee", email = "joel@joellee.org" }
@@ -15,11 +15,11 @@ classifiers = [
15
15
  "License :: OSI Approved :: MIT License",
16
16
  "Operating System :: OS Independent",
17
17
  ]
18
- requires-python = ">=3.9"
18
+ requires-python = ">=3.11"
19
19
  dependencies = [
20
20
  "httpx[http2] >=0.26,<0.29",
21
- "pydantic >=1.10,<3",
22
- "pyjwt[crypto] >=2.12.0",
21
+ "pydantic >=2.11.7,<3",
22
+ "pyjwt[crypto] >=2.15.1",
23
23
  ]
24
24
 
25
25
  [project.urls]
@@ -59,7 +59,6 @@ requires = ["uv_build>=0.8.3,<0.9.0"]
59
59
  build-backend = "uv_build"
60
60
 
61
61
  [tool.mypy]
62
- python_version = "3.9"
63
62
  check_untyped_defs = true
64
63
  allow_redefinition = true
65
64
  follow_untyped_imports = true # for deprecation module that does not have stubs
@@ -0,0 +1,20 @@
1
+ from __future__ import annotations
2
+
3
+ from ._async.gotrue_admin_api import AsyncGoTrueAdminAPI as AsyncGoTrueAdminAPI
4
+ from ._async.gotrue_client import AsyncGoTrueClient as AsyncGoTrueClient
5
+ from ._async.storage import (
6
+ AsyncMemoryStorage as AsyncMemoryStorage,
7
+ )
8
+ from ._async.storage import (
9
+ AsyncSupportedStorage as AsyncSupportedStorage,
10
+ )
11
+ from ._sync.gotrue_admin_api import SyncGoTrueAdminAPI as SyncGoTrueAdminAPI
12
+ from ._sync.gotrue_client import SyncGoTrueClient as SyncGoTrueClient
13
+ from ._sync.storage import (
14
+ SyncMemoryStorage as SyncMemoryStorage,
15
+ )
16
+ from ._sync.storage import (
17
+ SyncSupportedStorage as SyncSupportedStorage,
18
+ )
19
+ from .types import *
20
+ from .version import __version__ as __version__
@@ -1,11 +1,8 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Dict, List, Optional
4
-
5
3
  from httpx import AsyncClient, QueryParams
6
4
 
7
5
  from ..helpers import (
8
- model_validate,
9
6
  parse_link_response,
10
7
  parse_user_response,
11
8
  validate_uuid,
@@ -41,10 +38,10 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
41
38
  self,
42
39
  *,
43
40
  url: str = "",
44
- headers: Optional[Dict[str, str]] = None,
45
- http_client: Optional[AsyncClient] = None,
41
+ headers: dict[str, str] | None = None,
42
+ http_client: AsyncClient | None = None,
46
43
  verify: bool = True,
47
- proxy: Optional[str] = None,
44
+ proxy: str | None = None,
48
45
  ) -> None:
49
46
  http_headers = headers or {}
50
47
  AsyncGoTrueBaseAPI.__init__(
@@ -57,15 +54,15 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
57
54
  )
58
55
  # TODO(@o-santi): why is is this done this way?
59
56
  self.mfa = AsyncGoTrueAdminMFAAPI()
60
- self.mfa.list_factors = self._list_factors # type: ignore
61
- self.mfa.delete_factor = self._delete_factor # type: ignore
57
+ self.mfa.list_factors = self._list_factors # type: ignore[method-assign]
58
+ self.mfa.delete_factor = self._delete_factor # type: ignore[method-assign]
62
59
  self.oauth = AsyncGoTrueAdminOAuthAPI()
63
- self.oauth.list_clients = self._list_oauth_clients # type: ignore
64
- self.oauth.create_client = self._create_oauth_client # type: ignore
65
- self.oauth.get_client = self._get_oauth_client # type: ignore
66
- self.oauth.update_client = self._update_oauth_client # type: ignore
67
- self.oauth.delete_client = self._delete_oauth_client # type: ignore
68
- self.oauth.regenerate_client_secret = self._regenerate_oauth_client_secret # type: ignore
60
+ self.oauth.list_clients = self._list_oauth_clients # type: ignore[method-assign]
61
+ self.oauth.create_client = self._create_oauth_client # type: ignore[method-assign]
62
+ self.oauth.get_client = self._get_oauth_client # type: ignore[method-assign]
63
+ self.oauth.update_client = self._update_oauth_client # type: ignore[method-assign]
64
+ self.oauth.delete_client = self._delete_oauth_client # type: ignore[assignment, method-assign]
65
+ self.oauth.regenerate_client_secret = self._regenerate_oauth_client_secret # type: ignore[method-assign]
69
66
 
70
67
  async def sign_out(self, jwt: str, scope: SignOutScope = "global") -> None:
71
68
  """
@@ -76,13 +73,12 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
76
73
  "logout",
77
74
  query=QueryParams(scope=scope),
78
75
  jwt=jwt,
79
- no_resolve_json=True,
80
76
  )
81
77
 
82
78
  async def invite_user_by_email(
83
79
  self,
84
80
  email: str,
85
- options: Optional[InviteUserByEmailOptions] = None,
81
+ options: InviteUserByEmailOptions | None = None,
86
82
  ) -> UserResponse:
87
83
  """
88
84
  Sends an invite link to an email address.
@@ -132,8 +128,8 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
132
128
  return parse_user_response(response)
133
129
 
134
130
  async def list_users(
135
- self, page: Optional[int] = None, per_page: Optional[int] = None
136
- ) -> List[User]:
131
+ self, page: int | None = None, per_page: int | None = None
132
+ ) -> list[User]:
137
133
  """
138
134
  Get a list of users.
139
135
 
@@ -145,7 +141,7 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
145
141
  "admin/users",
146
142
  query=QueryParams(page=page, per_page=per_page),
147
143
  )
148
- return model_validate(UserList, response.content).users
144
+ return UserList.model_validate_json(response.content).users
149
145
 
150
146
  async def get_user_by_id(self, uid: str) -> UserResponse:
151
147
  """
@@ -213,7 +209,7 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
213
209
  "DELETE",
214
210
  f"admin/users/{params.get('user_id')}/factors/{params.get('id')}",
215
211
  )
216
- return model_validate(AuthMFAAdminDeleteFactorResponse, response.content)
212
+ return AuthMFAAdminDeleteFactorResponse.model_validate_json(response.content)
217
213
 
218
214
  async def _list_oauth_clients(
219
215
  self,
@@ -234,10 +230,9 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
234
230
  "GET",
235
231
  "admin/oauth/clients",
236
232
  query=query,
237
- no_resolve_json=True,
238
233
  )
239
234
 
240
- result = model_validate(OAuthClientListResponse, response.content)
235
+ result = OAuthClientListResponse.model_validate_json(response.content)
241
236
 
242
237
  # Parse pagination headers
243
238
  total = response.headers.get("x-total-count")
@@ -277,7 +272,9 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
277
272
  body=params,
278
273
  )
279
274
 
280
- return OAuthClientResponse(client=model_validate(OAuthClient, response.content))
275
+ return OAuthClientResponse(
276
+ client=OAuthClient.model_validate_json(response.content)
277
+ )
281
278
 
282
279
  async def _get_oauth_client(
283
280
  self,
@@ -295,7 +292,9 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
295
292
  "GET",
296
293
  f"admin/oauth/clients/{client_id}",
297
294
  )
298
- return OAuthClientResponse(client=model_validate(OAuthClient, response.content))
295
+ return OAuthClientResponse(
296
+ client=OAuthClient.model_validate_json(response.content)
297
+ )
299
298
 
300
299
  async def _update_oauth_client(
301
300
  self,
@@ -315,7 +314,9 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
315
314
  f"admin/oauth/clients/{client_id}",
316
315
  body=params,
317
316
  )
318
- return OAuthClientResponse(client=model_validate(OAuthClient, response.content))
317
+ return OAuthClientResponse(
318
+ client=OAuthClient.model_validate_json(response.content)
319
+ )
319
320
 
320
321
  async def _delete_oauth_client(
321
322
  self,
@@ -350,4 +351,6 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
350
351
  "POST",
351
352
  f"admin/oauth/clients/{client_id}/regenerate_secret",
352
353
  )
353
- return OAuthClientResponse(client=model_validate(OAuthClient, response.content))
354
+ return OAuthClientResponse(
355
+ client=OAuthClient.model_validate_json(response.content)
356
+ )
@@ -1,5 +1,3 @@
1
- from typing import Optional
2
-
3
1
  from ..types import (
4
2
  CreateOAuthClientParams,
5
3
  OAuthClientListResponse,
@@ -17,7 +15,7 @@ class AsyncGoTrueAdminOAuthAPI:
17
15
 
18
16
  async def list_clients(
19
17
  self,
20
- params: Optional[PageParams] = None,
18
+ params: PageParams | None = None,
21
19
  ) -> OAuthClientListResponse:
22
20
  """
23
21
  Lists all OAuth clients with optional pagination.
@@ -1,13 +1,12 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Any, Dict, Optional
3
+ from typing import Any, Literal, Self
4
4
 
5
- from httpx import AsyncClient, HTTPStatusError, QueryParams, Response
5
+ from httpx import AsyncClient, HTTPStatusError, QueryParams, RequestError, Response
6
6
  from pydantic import BaseModel
7
- from typing_extensions import Literal, Self
8
7
 
9
8
  from ..constants import API_VERSION_HEADER_NAME, API_VERSIONS_2024_01_01_NAME
10
- from ..helpers import handle_exception, model_dump
9
+ from ..helpers import handle_exception
11
10
 
12
11
 
13
12
  class AsyncGoTrueBaseAPI:
@@ -15,13 +14,17 @@ class AsyncGoTrueBaseAPI:
15
14
  self,
16
15
  *,
17
16
  url: str,
18
- headers: Dict[str, str],
19
- http_client: Optional[AsyncClient],
17
+ headers: dict[str, str],
18
+ http_client: AsyncClient | None,
20
19
  verify: bool = True,
21
- proxy: Optional[str] = None,
20
+ proxy: str | None = None,
22
21
  ) -> None:
23
- self._url = url
24
- self._headers = headers
22
+ self._url = url.rstrip("/")
23
+ # Copy: callers pass a dict they keep mutating, and GoTrueClient hands
24
+ # its own `_headers` to the admin API. Sharing the object means a later
25
+ # `_headers["Authorization"] = <user token>` silently downgrades every
26
+ # other holder of that dict.
27
+ self._headers = dict(headers)
25
28
  self._http_client = http_client or AsyncClient(
26
29
  verify=bool(verify),
27
30
  proxy=proxy,
@@ -43,12 +46,11 @@ class AsyncGoTrueBaseAPI:
43
46
  method: Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"],
44
47
  path: str,
45
48
  *,
46
- jwt: Optional[str] = None,
47
- redirect_to: Optional[str] = None,
48
- headers: Optional[Dict[str, str]] = None,
49
- query: Optional[QueryParams] = None,
50
- body: Optional[Any] = None,
51
- no_resolve_json: bool = False,
49
+ jwt: str | None = None,
50
+ redirect_to: str | None = None,
51
+ headers: dict[str, str] | None = None,
52
+ query: QueryParams | None = None,
53
+ body: Any | None = None,
52
54
  ) -> Response:
53
55
  url = f"{self._url}/{path}"
54
56
  headers = {**self._headers, **(headers or {})}
@@ -67,10 +69,10 @@ class AsyncGoTrueBaseAPI:
67
69
  url,
68
70
  headers=headers,
69
71
  params=query,
70
- json=model_dump(body) if isinstance(body, BaseModel) else body,
72
+ json=body.model_dump() if isinstance(body, BaseModel) else body,
71
73
  )
72
74
 
73
75
  response.raise_for_status()
74
76
  return response
75
- except (HTTPStatusError, RuntimeError) as e:
76
- raise handle_exception(e) # noqa
77
+ except (HTTPStatusError, RequestError, RuntimeError) as e:
78
+ raise handle_exception(e) from e