supabase_auth 2.22.3__tar.gz → 2.22.4__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.
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/PKG-INFO +1 -1
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/pyproject.toml +16 -1
- supabase_auth-2.22.4/src/supabase_auth/__init__.py +16 -0
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/_async/gotrue_admin_api.py +35 -30
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/_async/gotrue_base_api.py +10 -58
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/_async/gotrue_client.py +177 -152
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/_async/storage.py +2 -1
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/_sync/gotrue_admin_api.py +35 -30
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/_sync/gotrue_base_api.py +10 -58
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/_sync/gotrue_client.py +177 -152
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/_sync/storage.py +2 -1
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/constants.py +4 -6
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/errors.py +20 -5
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/helpers.py +64 -69
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/types.py +28 -7
- supabase_auth-2.22.4/src/supabase_auth/version.py +1 -0
- supabase_auth-2.22.3/src/supabase_auth/__init__.py +0 -16
- supabase_auth-2.22.3/src/supabase_auth/version.py +0 -1
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/README.md +0 -0
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/_async/__init__.py +0 -0
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/_async/gotrue_admin_mfa_api.py +0 -0
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/_async/gotrue_mfa_api.py +0 -0
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/_sync/__init__.py +0 -0
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/_sync/gotrue_admin_mfa_api.py +0 -0
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/_sync/gotrue_mfa_api.py +0 -0
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/http_clients.py +0 -0
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/py.typed +0 -0
- {supabase_auth-2.22.3 → supabase_auth-2.22.4}/src/supabase_auth/timer.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "supabase_auth"
|
|
3
|
-
version = "2.22.
|
|
3
|
+
version = "2.22.4" # {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" }
|
|
@@ -44,6 +44,9 @@ tests = [
|
|
|
44
44
|
lints = [
|
|
45
45
|
"ruff >=0.12.1",
|
|
46
46
|
"unasync >= 0.6.0",
|
|
47
|
+
"python-lsp-server (>=1.12.2,<2.0.0)",
|
|
48
|
+
"pylsp-mypy (>=0.7.0,<0.8.0)",
|
|
49
|
+
"python-lsp-ruff (>=2.2.2,<3.0.0)",
|
|
47
50
|
]
|
|
48
51
|
dev = [{ include-group = "lints" }, {include-group = "tests" }]
|
|
49
52
|
|
|
@@ -76,3 +79,15 @@ asyncio_mode = "auto"
|
|
|
76
79
|
[build-system]
|
|
77
80
|
requires = ["uv_build>=0.8.3,<0.9.0"]
|
|
78
81
|
build-backend = "uv_build"
|
|
82
|
+
|
|
83
|
+
[tool.mypy]
|
|
84
|
+
python_version = "3.9"
|
|
85
|
+
check_untyped_defs = true
|
|
86
|
+
allow_redefinition = true
|
|
87
|
+
follow_untyped_imports = true # for deprecation module that does not have stubs
|
|
88
|
+
|
|
89
|
+
no_warn_no_return = true
|
|
90
|
+
warn_return_any = true
|
|
91
|
+
warn_unused_configs = true
|
|
92
|
+
warn_redundant_casts = true
|
|
93
|
+
warn_unused_ignores = true
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from ._async.gotrue_admin_api import AsyncGoTrueAdminAPI
|
|
4
|
+
from ._async.gotrue_client import AsyncGoTrueClient
|
|
5
|
+
from ._async.storage import (
|
|
6
|
+
AsyncMemoryStorage,
|
|
7
|
+
AsyncSupportedStorage,
|
|
8
|
+
)
|
|
9
|
+
from ._sync.gotrue_admin_api import SyncGoTrueAdminAPI
|
|
10
|
+
from ._sync.gotrue_client import SyncGoTrueClient
|
|
11
|
+
from ._sync.storage import (
|
|
12
|
+
SyncMemoryStorage,
|
|
13
|
+
SyncSupportedStorage,
|
|
14
|
+
)
|
|
15
|
+
from .types import *
|
|
16
|
+
from .version import __version__
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
|
|
3
|
+
from typing import Any, Dict, List, Optional
|
|
4
|
+
|
|
5
|
+
from httpx import QueryParams, Response
|
|
6
|
+
from pydantic import TypeAdapter
|
|
5
7
|
|
|
6
8
|
from ..helpers import (
|
|
7
9
|
is_valid_uuid,
|
|
@@ -21,6 +23,7 @@ from ..types import (
|
|
|
21
23
|
InviteUserByEmailOptions,
|
|
22
24
|
SignOutScope,
|
|
23
25
|
User,
|
|
26
|
+
UserList,
|
|
24
27
|
UserResponse,
|
|
25
28
|
)
|
|
26
29
|
from .gotrue_admin_mfa_api import AsyncGoTrueAdminMFAAPI
|
|
@@ -45,18 +48,19 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
|
|
|
45
48
|
verify=verify,
|
|
46
49
|
proxy=proxy,
|
|
47
50
|
)
|
|
51
|
+
# TODO(@o-santi): why is is this done this way?
|
|
48
52
|
self.mfa = AsyncGoTrueAdminMFAAPI()
|
|
49
|
-
self.mfa.list_factors = self._list_factors
|
|
50
|
-
self.mfa.delete_factor = self._delete_factor
|
|
53
|
+
self.mfa.list_factors = self._list_factors # type: ignore
|
|
54
|
+
self.mfa.delete_factor = self._delete_factor # type: ignore
|
|
51
55
|
|
|
52
56
|
async def sign_out(self, jwt: str, scope: SignOutScope = "global") -> None:
|
|
53
57
|
"""
|
|
54
58
|
Removes a logged-in session.
|
|
55
59
|
"""
|
|
56
|
-
|
|
60
|
+
await self._request(
|
|
57
61
|
"POST",
|
|
58
62
|
"logout",
|
|
59
|
-
query=
|
|
63
|
+
query=QueryParams(scope=scope),
|
|
60
64
|
jwt=jwt,
|
|
61
65
|
no_resolve_json=True,
|
|
62
66
|
)
|
|
@@ -69,19 +73,19 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
|
|
|
69
73
|
"""
|
|
70
74
|
Sends an invite link to an email address.
|
|
71
75
|
"""
|
|
72
|
-
|
|
76
|
+
response = await self._request(
|
|
73
77
|
"POST",
|
|
74
78
|
"invite",
|
|
75
79
|
body={"email": email, "data": options.get("data")},
|
|
76
80
|
redirect_to=options.get("redirect_to"),
|
|
77
|
-
xform=parse_user_response,
|
|
78
81
|
)
|
|
82
|
+
return parse_user_response(response)
|
|
79
83
|
|
|
80
84
|
async def generate_link(self, params: GenerateLinkParams) -> GenerateLinkResponse:
|
|
81
85
|
"""
|
|
82
86
|
Generates email links and OTPs to be sent via a custom email provider.
|
|
83
87
|
"""
|
|
84
|
-
|
|
88
|
+
response = await self._request(
|
|
85
89
|
"POST",
|
|
86
90
|
"admin/generate_link",
|
|
87
91
|
body={
|
|
@@ -92,9 +96,10 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
|
|
|
92
96
|
"data": params.get("options", {}).get("data"),
|
|
93
97
|
},
|
|
94
98
|
redirect_to=params.get("options", {}).get("redirect_to"),
|
|
95
|
-
xform=parse_link_response,
|
|
96
99
|
)
|
|
97
100
|
|
|
101
|
+
return parse_link_response(response)
|
|
102
|
+
|
|
98
103
|
# User Admin API
|
|
99
104
|
|
|
100
105
|
async def create_user(self, attributes: AdminUserAttributes) -> UserResponse:
|
|
@@ -104,30 +109,28 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
|
|
|
104
109
|
This function should only be called on a server.
|
|
105
110
|
Never expose your `service_role` key in the browser.
|
|
106
111
|
"""
|
|
107
|
-
|
|
112
|
+
response = await self._request(
|
|
108
113
|
"POST",
|
|
109
114
|
"admin/users",
|
|
110
115
|
body=attributes,
|
|
111
|
-
xform=parse_user_response,
|
|
112
116
|
)
|
|
117
|
+
return parse_user_response(response)
|
|
113
118
|
|
|
114
|
-
async def list_users(
|
|
119
|
+
async def list_users(
|
|
120
|
+
self, page: Optional[int] = None, per_page: Optional[int] = None
|
|
121
|
+
) -> List[User]:
|
|
115
122
|
"""
|
|
116
123
|
Get a list of users.
|
|
117
124
|
|
|
118
125
|
This function should only be called on a server.
|
|
119
126
|
Never expose your `service_role` key in the browser.
|
|
120
127
|
"""
|
|
121
|
-
|
|
128
|
+
response = await self._request(
|
|
122
129
|
"GET",
|
|
123
130
|
"admin/users",
|
|
124
|
-
query=
|
|
125
|
-
xform=lambda data: (
|
|
126
|
-
[model_validate(User, user) for user in data["users"]]
|
|
127
|
-
if "users" in data
|
|
128
|
-
else []
|
|
129
|
-
),
|
|
131
|
+
query=QueryParams(page=page, per_page=per_page),
|
|
130
132
|
)
|
|
133
|
+
return model_validate(UserList, response.content).users
|
|
131
134
|
|
|
132
135
|
async def get_user_by_id(self, uid: str) -> UserResponse:
|
|
133
136
|
"""
|
|
@@ -138,11 +141,11 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
|
|
|
138
141
|
"""
|
|
139
142
|
self._validate_uuid(uid)
|
|
140
143
|
|
|
141
|
-
|
|
144
|
+
response = await self._request(
|
|
142
145
|
"GET",
|
|
143
146
|
f"admin/users/{uid}",
|
|
144
|
-
xform=parse_user_response,
|
|
145
147
|
)
|
|
148
|
+
return parse_user_response(response)
|
|
146
149
|
|
|
147
150
|
async def update_user_by_id(
|
|
148
151
|
self,
|
|
@@ -156,12 +159,12 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
|
|
|
156
159
|
Never expose your `service_role` key in the browser.
|
|
157
160
|
"""
|
|
158
161
|
self._validate_uuid(uid)
|
|
159
|
-
|
|
162
|
+
response = await self._request(
|
|
160
163
|
"PUT",
|
|
161
164
|
f"admin/users/{uid}",
|
|
162
165
|
body=attributes,
|
|
163
|
-
xform=parse_user_response,
|
|
164
166
|
)
|
|
167
|
+
return parse_user_response(response)
|
|
165
168
|
|
|
166
169
|
async def delete_user(self, id: str, should_soft_delete: bool = False) -> None:
|
|
167
170
|
"""
|
|
@@ -172,18 +175,18 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
|
|
|
172
175
|
"""
|
|
173
176
|
self._validate_uuid(id)
|
|
174
177
|
body = {"should_soft_delete": should_soft_delete}
|
|
175
|
-
|
|
178
|
+
await self._request("DELETE", f"admin/users/{id}", body=body)
|
|
176
179
|
|
|
177
180
|
async def _list_factors(
|
|
178
181
|
self,
|
|
179
182
|
params: AuthMFAAdminListFactorsParams,
|
|
180
183
|
) -> AuthMFAAdminListFactorsResponse:
|
|
181
184
|
self._validate_uuid(params.get("user_id"))
|
|
182
|
-
|
|
185
|
+
response = await self._request(
|
|
183
186
|
"GET",
|
|
184
187
|
f"admin/users/{params.get('user_id')}/factors",
|
|
185
|
-
xform=partial(model_validate, AuthMFAAdminListFactorsResponse),
|
|
186
188
|
)
|
|
189
|
+
return model_validate(AuthMFAAdminListFactorsResponse, response.content)
|
|
187
190
|
|
|
188
191
|
async def _delete_factor(
|
|
189
192
|
self,
|
|
@@ -191,12 +194,14 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
|
|
|
191
194
|
) -> AuthMFAAdminDeleteFactorResponse:
|
|
192
195
|
self._validate_uuid(params.get("user_id"))
|
|
193
196
|
self._validate_uuid(params.get("id"))
|
|
194
|
-
|
|
197
|
+
response = await self._request(
|
|
195
198
|
"DELETE",
|
|
196
199
|
f"admin/users/{params.get('user_id')}/factors/{params.get('id')}",
|
|
197
|
-
xform=partial(model_validate, AuthMFAAdminDeleteFactorResponse),
|
|
198
200
|
)
|
|
201
|
+
return model_validate(AuthMFAAdminDeleteFactorResponse, response.content)
|
|
199
202
|
|
|
200
|
-
def _validate_uuid(self, id: str) -> None:
|
|
203
|
+
def _validate_uuid(self, id: str | None) -> None:
|
|
204
|
+
if id is None:
|
|
205
|
+
raise ValueError("Invalid id, id cannot be none")
|
|
201
206
|
if not is_valid_uuid(id):
|
|
202
207
|
raise ValueError(f"Invalid id, '{id}' is not a valid uuid")
|
|
@@ -2,16 +2,14 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import Any, Callable, Dict, Optional, TypeVar, overload
|
|
4
4
|
|
|
5
|
-
from httpx import Response
|
|
5
|
+
from httpx import HTTPStatusError, QueryParams, Response
|
|
6
6
|
from pydantic import BaseModel
|
|
7
7
|
from typing_extensions import Literal, Self
|
|
8
8
|
|
|
9
|
-
from ..constants import API_VERSION_HEADER_NAME,
|
|
9
|
+
from ..constants import API_VERSION_HEADER_NAME, API_VERSIONS_2024_01_01_NAME
|
|
10
10
|
from ..helpers import handle_exception, model_dump
|
|
11
11
|
from ..http_clients import AsyncClient
|
|
12
12
|
|
|
13
|
-
T = TypeVar("T")
|
|
14
|
-
|
|
15
13
|
|
|
16
14
|
class AsyncGoTrueBaseAPI:
|
|
17
15
|
def __init__(
|
|
@@ -41,7 +39,6 @@ class AsyncGoTrueBaseAPI:
|
|
|
41
39
|
async def close(self) -> None:
|
|
42
40
|
await self._http_client.aclose()
|
|
43
41
|
|
|
44
|
-
@overload
|
|
45
42
|
async def _request(
|
|
46
43
|
self,
|
|
47
44
|
method: Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"],
|
|
@@ -50,65 +47,21 @@ class AsyncGoTrueBaseAPI:
|
|
|
50
47
|
jwt: Optional[str] = None,
|
|
51
48
|
redirect_to: Optional[str] = None,
|
|
52
49
|
headers: Optional[Dict[str, str]] = None,
|
|
53
|
-
query: Optional[
|
|
54
|
-
body: Optional[Any] = None,
|
|
55
|
-
no_resolve_json: Literal[False] = False,
|
|
56
|
-
xform: Callable[[Any], T],
|
|
57
|
-
) -> T: ... # pragma: no cover
|
|
58
|
-
|
|
59
|
-
@overload
|
|
60
|
-
async def _request(
|
|
61
|
-
self,
|
|
62
|
-
method: Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"],
|
|
63
|
-
path: str,
|
|
64
|
-
*,
|
|
65
|
-
jwt: Optional[str] = None,
|
|
66
|
-
redirect_to: Optional[str] = None,
|
|
67
|
-
headers: Optional[Dict[str, str]] = None,
|
|
68
|
-
query: Optional[Dict[str, str]] = None,
|
|
69
|
-
body: Optional[Any] = None,
|
|
70
|
-
no_resolve_json: Literal[True],
|
|
71
|
-
xform: Callable[[Response], T],
|
|
72
|
-
) -> T: ... # pragma: no cover
|
|
73
|
-
|
|
74
|
-
@overload
|
|
75
|
-
async def _request(
|
|
76
|
-
self,
|
|
77
|
-
method: Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"],
|
|
78
|
-
path: str,
|
|
79
|
-
*,
|
|
80
|
-
jwt: Optional[str] = None,
|
|
81
|
-
redirect_to: Optional[str] = None,
|
|
82
|
-
headers: Optional[Dict[str, str]] = None,
|
|
83
|
-
query: Optional[Dict[str, str]] = None,
|
|
84
|
-
body: Optional[Any] = None,
|
|
85
|
-
no_resolve_json: bool = False,
|
|
86
|
-
) -> None: ... # pragma: no cover
|
|
87
|
-
|
|
88
|
-
async def _request(
|
|
89
|
-
self,
|
|
90
|
-
method: Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"],
|
|
91
|
-
path: str,
|
|
92
|
-
*,
|
|
93
|
-
jwt: Optional[str] = None,
|
|
94
|
-
redirect_to: Optional[str] = None,
|
|
95
|
-
headers: Optional[Dict[str, str]] = None,
|
|
96
|
-
query: Optional[Dict[str, str]] = None,
|
|
50
|
+
query: Optional[QueryParams] = None,
|
|
97
51
|
body: Optional[Any] = None,
|
|
98
52
|
no_resolve_json: bool = False,
|
|
99
|
-
|
|
100
|
-
) -> Optional[T]:
|
|
53
|
+
) -> Response:
|
|
101
54
|
url = f"{self._url}/{path}"
|
|
102
55
|
headers = {**self._headers, **(headers or {})}
|
|
103
56
|
if API_VERSION_HEADER_NAME not in headers:
|
|
104
|
-
headers[API_VERSION_HEADER_NAME] =
|
|
57
|
+
headers[API_VERSION_HEADER_NAME] = API_VERSIONS_2024_01_01_NAME
|
|
105
58
|
if "Content-Type" not in headers:
|
|
106
59
|
headers["Content-Type"] = "application/json;charset=UTF-8"
|
|
107
60
|
if jwt:
|
|
108
61
|
headers["Authorization"] = f"Bearer {jwt}"
|
|
109
|
-
query = query or
|
|
62
|
+
query = query or QueryParams()
|
|
110
63
|
if redirect_to:
|
|
111
|
-
query
|
|
64
|
+
query = query.set("redirect_to", redirect_to)
|
|
112
65
|
try:
|
|
113
66
|
response = await self._http_client.request(
|
|
114
67
|
method,
|
|
@@ -117,9 +70,8 @@ class AsyncGoTrueBaseAPI:
|
|
|
117
70
|
params=query,
|
|
118
71
|
json=model_dump(body) if isinstance(body, BaseModel) else body,
|
|
119
72
|
)
|
|
73
|
+
|
|
120
74
|
response.raise_for_status()
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return xform(result)
|
|
124
|
-
except Exception as e:
|
|
75
|
+
return response
|
|
76
|
+
except (HTTPStatusError, RuntimeError) as e:
|
|
125
77
|
raise handle_exception(e)
|