supabase_auth 2.11.4__tar.gz → 2.12.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.
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/PKG-INFO +94 -31
- supabase_auth-2.12.2/README.md +159 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/pyproject.toml +13 -11
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/_async/gotrue_admin_api.py +18 -2
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/_async/gotrue_client.py +121 -21
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/_sync/gotrue_admin_api.py +18 -2
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/_sync/gotrue_client.py +121 -21
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/constants.py +1 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/errors.py +11 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/helpers.py +62 -26
- supabase_auth-2.12.2/supabase_auth/py.typed +0 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/types.py +60 -6
- supabase_auth-2.12.2/supabase_auth/version.py +1 -0
- supabase_auth-2.11.4/README.md +0 -98
- supabase_auth-2.11.4/supabase_auth/version.py +0 -1
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/LICENSE +0 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/__init__.py +0 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/_async/__init__.py +0 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/_async/gotrue_admin_mfa_api.py +0 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/_async/gotrue_base_api.py +0 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/_async/gotrue_mfa_api.py +0 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/_async/storage.py +0 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/_sync/__init__.py +0 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/_sync/gotrue_admin_mfa_api.py +0 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/_sync/gotrue_base_api.py +0 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/_sync/gotrue_mfa_api.py +0 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/_sync/storage.py +0 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.2}/supabase_auth/http_clients.py +0 -0
- {supabase_auth-2.11.4 → supabase_auth-2.12.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.
|
|
3
|
+
Version: 2.12.2
|
|
4
4
|
Summary: Python Client Library for Supabase Auth
|
|
5
5
|
Home-page: https://github.com/supabase/auth-py
|
|
6
6
|
License: MIT
|
|
@@ -17,29 +17,24 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
18
18
|
Requires-Dist: httpx[http2] (>=0.26,<0.29)
|
|
19
19
|
Requires-Dist: pydantic (>=1.10,<3)
|
|
20
|
+
Requires-Dist: pyjwt (>=2.10.1,<3.0.0)
|
|
21
|
+
Requires-Dist: pytest-mock (>=3.14.0,<4.0.0)
|
|
20
22
|
Project-URL: Documentation, https://github.com/supabase/auth-py
|
|
21
23
|
Project-URL: Repository, https://github.com/supabase/auth-py
|
|
22
24
|
Description-Content-Type: text/markdown
|
|
23
25
|
|
|
24
26
|
# Auth-py
|
|
25
27
|
|
|
26
|
-
[](https://opensource.org/licenses/MIT)
|
|
27
28
|
[](https://github.com/supabase-community/gotrue-py/actions/workflows/ci.yml)
|
|
28
29
|
[](https://pypi.org/project/gotrue)
|
|
29
30
|
[](https://pypi.org/project/gotrue)
|
|
30
|
-
[](https://github.com/supabase-community/gotrue-py/commits)
|
|
32
|
-
[](https://github.com/supabase-community/gotrue-py/commits)
|
|
33
|
-
[](https://github.com/supabase-community/gotrue-py/stargazers)
|
|
34
|
-
[](https://github.com/supabase-community/gotrue-py/network/members)
|
|
35
|
-
[](https://github.com/supabase-community/gotrue-py)
|
|
36
|
-
[](https://github.com/supabase-community/gotrue-py/graphs/contributors)
|
|
31
|
+
[](https://coveralls.io/github/supabase/auth-py?branch=main)
|
|
37
32
|
|
|
38
33
|
This is a Python port of the [supabase js gotrue client](https://github.com/supabase/gotrue-js). The current state is that there is a features parity but with small differences that are mentioned in the section **Differences to the JS client**. As of December 14th, we renamed to repo from `gotrue-py` to `auth-py` to mirror the changes in the JavaScript library.
|
|
39
34
|
|
|
40
35
|
## Installation
|
|
41
36
|
|
|
42
|
-
|
|
37
|
+
The package can be installed using pip or poetry:
|
|
43
38
|
|
|
44
39
|
### Poetry
|
|
45
40
|
|
|
@@ -53,6 +48,19 @@ poetry add supabase_auth
|
|
|
53
48
|
pip install supabase_auth
|
|
54
49
|
```
|
|
55
50
|
|
|
51
|
+
## Features
|
|
52
|
+
|
|
53
|
+
- Full feature parity with the JavaScript client
|
|
54
|
+
- Support for both synchronous and asynchronous operations
|
|
55
|
+
- MFA (Multi-Factor Authentication) support
|
|
56
|
+
- OAuth and SSO integration
|
|
57
|
+
- Magic link and OTP authentication
|
|
58
|
+
- Phone number authentication
|
|
59
|
+
- Anonymous sign-in
|
|
60
|
+
- Session management with auto-refresh
|
|
61
|
+
- JWT token handling and verification
|
|
62
|
+
- User management and profile updates
|
|
63
|
+
|
|
56
64
|
## Differences to the JS client
|
|
57
65
|
|
|
58
66
|
It should be noted there are differences to the [JS client](https://github.com/supabase/gotrue-js). If you feel particulaly strongly about them and want to motivate a change, feel free to make a GitHub issue and we can discuss it there.
|
|
@@ -71,11 +79,11 @@ The other key difference is we do not use pascalCase to encode variable and meth
|
|
|
71
79
|
|
|
72
80
|
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.
|
|
73
81
|
|
|
74
|
-
## Usage
|
|
82
|
+
## Usage
|
|
75
83
|
|
|
76
|
-
|
|
84
|
+
The library provides both synchronous and asynchronous clients. Here are some examples:
|
|
77
85
|
|
|
78
|
-
|
|
86
|
+
### Synchronous Client
|
|
79
87
|
|
|
80
88
|
```python
|
|
81
89
|
from supabase_auth import SyncGoTrueClient
|
|
@@ -85,38 +93,93 @@ headers = {
|
|
|
85
93
|
# ... any other headers you might need.
|
|
86
94
|
}
|
|
87
95
|
client: SyncGoTrueClient = SyncGoTrueClient(url="www.genericauthwebsite.com", headers=headers)
|
|
88
|
-
```
|
|
89
96
|
|
|
90
|
-
|
|
97
|
+
# Sign up with email and password
|
|
98
|
+
user = client.sign_up(email="example@gmail.com", password="*********")
|
|
91
99
|
|
|
92
|
-
|
|
93
|
-
user
|
|
94
|
-
```
|
|
100
|
+
# Sign in with email and password
|
|
101
|
+
user = client.sign_in_with_password(email="example@gmail.com", password="*********")
|
|
95
102
|
|
|
96
|
-
|
|
103
|
+
# Sign in with magic link
|
|
104
|
+
user = client.sign_in_with_otp(email="example@gmail.com")
|
|
97
105
|
|
|
98
|
-
|
|
99
|
-
user
|
|
106
|
+
# Sign in with phone number
|
|
107
|
+
user = client.sign_in_with_otp(phone="+1234567890")
|
|
108
|
+
|
|
109
|
+
# Sign in with OAuth
|
|
110
|
+
user = client.sign_in_with_oauth(provider="google")
|
|
111
|
+
|
|
112
|
+
# Sign out
|
|
113
|
+
client.sign_out()
|
|
114
|
+
|
|
115
|
+
# Get current user
|
|
116
|
+
user = client.get_user()
|
|
117
|
+
|
|
118
|
+
# Update user profile
|
|
119
|
+
user = client.update_user({"data": {"name": "John Doe"}})
|
|
100
120
|
```
|
|
101
121
|
|
|
102
|
-
|
|
122
|
+
### Asynchronous Client
|
|
103
123
|
|
|
104
124
|
```python
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
125
|
+
from supabase_auth import AsyncGoTrueClient
|
|
126
|
+
|
|
127
|
+
headers = {
|
|
128
|
+
"apiKey": "my-mega-awesome-api-key",
|
|
129
|
+
# ... any other headers you might need.
|
|
130
|
+
}
|
|
131
|
+
client: AsyncGoTrueClient = AsyncGoTrueClient(url="www.genericauthwebsite.com", headers=headers)
|
|
132
|
+
|
|
133
|
+
async def main():
|
|
134
|
+
# Sign up with email and password
|
|
135
|
+
user = await client.sign_up(email="example@gmail.com", password="*********")
|
|
136
|
+
|
|
137
|
+
# Sign in with email and password
|
|
138
|
+
user = await client.sign_in_with_password(email="example@gmail.com", password="*********")
|
|
139
|
+
|
|
140
|
+
# Sign in with magic link
|
|
141
|
+
user = await client.sign_in_with_otp(email="example@gmail.com")
|
|
142
|
+
|
|
143
|
+
# Sign in with phone number
|
|
144
|
+
user = await client.sign_in_with_otp(phone="+1234567890")
|
|
145
|
+
|
|
146
|
+
# Sign in with OAuth
|
|
147
|
+
user = await client.sign_in_with_oauth(provider="google")
|
|
148
|
+
|
|
149
|
+
# Sign out
|
|
150
|
+
await client.sign_out()
|
|
151
|
+
|
|
152
|
+
# Get current user
|
|
153
|
+
user = await client.get_user()
|
|
154
|
+
|
|
155
|
+
# Update user profile
|
|
156
|
+
user = await client.update_user({"data": {"name": "John Doe"}})
|
|
157
|
+
|
|
158
|
+
# Run the async code
|
|
159
|
+
import asyncio
|
|
160
|
+
asyncio.run(main())
|
|
108
161
|
```
|
|
109
162
|
|
|
110
|
-
|
|
163
|
+
### MFA Support
|
|
164
|
+
|
|
165
|
+
The library includes support for Multi-Factor Authentication:
|
|
111
166
|
|
|
112
167
|
```python
|
|
113
|
-
#
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
168
|
+
# List MFA factors
|
|
169
|
+
factors = client.mfa.list_factors()
|
|
170
|
+
|
|
171
|
+
# Enroll a new MFA factor
|
|
172
|
+
enrolled_factor = client.mfa.enroll({"factor_type": "totp"})
|
|
173
|
+
|
|
174
|
+
# Challenge and verify MFA
|
|
175
|
+
challenge = client.mfa.challenge({"factor_id": "factor_id"})
|
|
176
|
+
verified = client.mfa.verify({"factor_id": "factor_id", "code": "123456"})
|
|
177
|
+
|
|
178
|
+
# Unenroll a factor
|
|
179
|
+
client.mfa.unenroll({"factor_id": "factor_id"})
|
|
117
180
|
```
|
|
118
181
|
|
|
119
182
|
## Contributions
|
|
120
183
|
|
|
121
|
-
We would be immensely grateful for any contributions to this project.
|
|
184
|
+
We would be immensely grateful for any contributions to this project.
|
|
122
185
|
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Auth-py
|
|
2
|
+
|
|
3
|
+
[](https://github.com/supabase-community/gotrue-py/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/gotrue)
|
|
5
|
+
[](https://pypi.org/project/gotrue)
|
|
6
|
+
[](https://coveralls.io/github/supabase/auth-py?branch=main)
|
|
7
|
+
|
|
8
|
+
This is a Python port of the [supabase js gotrue client](https://github.com/supabase/gotrue-js). The current state is that there is a features parity but with small differences that are mentioned in the section **Differences to the JS client**. As of December 14th, we renamed to repo from `gotrue-py` to `auth-py` to mirror the changes in the JavaScript library.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
The package can be installed using pip or poetry:
|
|
13
|
+
|
|
14
|
+
### Poetry
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
poetry add supabase_auth
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Pip
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install supabase_auth
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- Full feature parity with the JavaScript client
|
|
29
|
+
- Support for both synchronous and asynchronous operations
|
|
30
|
+
- MFA (Multi-Factor Authentication) support
|
|
31
|
+
- OAuth and SSO integration
|
|
32
|
+
- Magic link and OTP authentication
|
|
33
|
+
- Phone number authentication
|
|
34
|
+
- Anonymous sign-in
|
|
35
|
+
- Session management with auto-refresh
|
|
36
|
+
- JWT token handling and verification
|
|
37
|
+
- User management and profile updates
|
|
38
|
+
|
|
39
|
+
## Differences to the JS client
|
|
40
|
+
|
|
41
|
+
It should be noted there are differences to the [JS client](https://github.com/supabase/gotrue-js). If you feel particulaly strongly about them and want to motivate a change, feel free to make a GitHub issue and we can discuss it there.
|
|
42
|
+
|
|
43
|
+
Firstly, feature pairity is not 100% with the [JS client](https://github.com/supabase/gotrue-js). In most cases we match the methods and attributes of the [JS client](https://github.com/supabase/gotrue-js) and api classes, but is some places (e.g for browser specific code) it didn't make sense to port the code line for line.
|
|
44
|
+
|
|
45
|
+
There is also a divergence in terms of how errors are raised. In the [JS client](https://github.com/supabase/gotrue-js), the errors are returned as part of the object, which the user can choose to process in whatever way they see fit. In this Python client, we raise the errors directly where they originate, as it was felt this was more Pythonic and adhered to the idioms of the language more directly.
|
|
46
|
+
|
|
47
|
+
In JS we return the error, but in Python we just raise it.
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
const { data, error } = client.sign_up(...)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The other key difference is we do not use pascalCase to encode variable and method names. Instead we use the snake_case convention adopted in the Python language.
|
|
54
|
+
|
|
55
|
+
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.
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
The library provides both synchronous and asynchronous clients. Here are some examples:
|
|
60
|
+
|
|
61
|
+
### Synchronous Client
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from supabase_auth import SyncGoTrueClient
|
|
65
|
+
|
|
66
|
+
headers = {
|
|
67
|
+
"apiKey": "my-mega-awesome-api-key",
|
|
68
|
+
# ... any other headers you might need.
|
|
69
|
+
}
|
|
70
|
+
client: SyncGoTrueClient = SyncGoTrueClient(url="www.genericauthwebsite.com", headers=headers)
|
|
71
|
+
|
|
72
|
+
# Sign up with email and password
|
|
73
|
+
user = client.sign_up(email="example@gmail.com", password="*********")
|
|
74
|
+
|
|
75
|
+
# Sign in with email and password
|
|
76
|
+
user = client.sign_in_with_password(email="example@gmail.com", password="*********")
|
|
77
|
+
|
|
78
|
+
# Sign in with magic link
|
|
79
|
+
user = client.sign_in_with_otp(email="example@gmail.com")
|
|
80
|
+
|
|
81
|
+
# Sign in with phone number
|
|
82
|
+
user = client.sign_in_with_otp(phone="+1234567890")
|
|
83
|
+
|
|
84
|
+
# Sign in with OAuth
|
|
85
|
+
user = client.sign_in_with_oauth(provider="google")
|
|
86
|
+
|
|
87
|
+
# Sign out
|
|
88
|
+
client.sign_out()
|
|
89
|
+
|
|
90
|
+
# Get current user
|
|
91
|
+
user = client.get_user()
|
|
92
|
+
|
|
93
|
+
# Update user profile
|
|
94
|
+
user = client.update_user({"data": {"name": "John Doe"}})
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Asynchronous Client
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from supabase_auth import AsyncGoTrueClient
|
|
101
|
+
|
|
102
|
+
headers = {
|
|
103
|
+
"apiKey": "my-mega-awesome-api-key",
|
|
104
|
+
# ... any other headers you might need.
|
|
105
|
+
}
|
|
106
|
+
client: AsyncGoTrueClient = AsyncGoTrueClient(url="www.genericauthwebsite.com", headers=headers)
|
|
107
|
+
|
|
108
|
+
async def main():
|
|
109
|
+
# Sign up with email and password
|
|
110
|
+
user = await client.sign_up(email="example@gmail.com", password="*********")
|
|
111
|
+
|
|
112
|
+
# Sign in with email and password
|
|
113
|
+
user = await client.sign_in_with_password(email="example@gmail.com", password="*********")
|
|
114
|
+
|
|
115
|
+
# Sign in with magic link
|
|
116
|
+
user = await client.sign_in_with_otp(email="example@gmail.com")
|
|
117
|
+
|
|
118
|
+
# Sign in with phone number
|
|
119
|
+
user = await client.sign_in_with_otp(phone="+1234567890")
|
|
120
|
+
|
|
121
|
+
# Sign in with OAuth
|
|
122
|
+
user = await client.sign_in_with_oauth(provider="google")
|
|
123
|
+
|
|
124
|
+
# Sign out
|
|
125
|
+
await client.sign_out()
|
|
126
|
+
|
|
127
|
+
# Get current user
|
|
128
|
+
user = await client.get_user()
|
|
129
|
+
|
|
130
|
+
# Update user profile
|
|
131
|
+
user = await client.update_user({"data": {"name": "John Doe"}})
|
|
132
|
+
|
|
133
|
+
# Run the async code
|
|
134
|
+
import asyncio
|
|
135
|
+
asyncio.run(main())
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### MFA Support
|
|
139
|
+
|
|
140
|
+
The library includes support for Multi-Factor Authentication:
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
# List MFA factors
|
|
144
|
+
factors = client.mfa.list_factors()
|
|
145
|
+
|
|
146
|
+
# Enroll a new MFA factor
|
|
147
|
+
enrolled_factor = client.mfa.enroll({"factor_type": "totp"})
|
|
148
|
+
|
|
149
|
+
# Challenge and verify MFA
|
|
150
|
+
challenge = client.mfa.challenge({"factor_id": "factor_id"})
|
|
151
|
+
verified = client.mfa.verify({"factor_id": "factor_id", "code": "123456"})
|
|
152
|
+
|
|
153
|
+
# Unenroll a factor
|
|
154
|
+
client.mfa.unenroll({"factor_id": "factor_id"})
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Contributions
|
|
158
|
+
|
|
159
|
+
We would be immensely grateful for any contributions to this project.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "supabase_auth"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.12.2" # {x-release-please-version}
|
|
4
4
|
description = "Python Client Library for Supabase Auth"
|
|
5
5
|
authors = ["Joel Lee <joel@joellee.org>"]
|
|
6
6
|
homepage = "https://github.com/supabase/auth-py"
|
|
@@ -11,25 +11,27 @@ license = "MIT"
|
|
|
11
11
|
classifiers = [
|
|
12
12
|
"Programming Language :: Python :: 3",
|
|
13
13
|
"License :: OSI Approved :: MIT License",
|
|
14
|
-
"Operating System :: OS Independent"
|
|
14
|
+
"Operating System :: OS Independent",
|
|
15
15
|
]
|
|
16
16
|
|
|
17
17
|
[tool.poetry.dependencies]
|
|
18
18
|
python = "^3.9"
|
|
19
|
-
httpx = {version = ">=0.26,<0.29", extras = ["http2"]}
|
|
19
|
+
httpx = { version = ">=0.26,<0.29", extras = ["http2"] }
|
|
20
20
|
pydantic = ">=1.10,<3"
|
|
21
|
+
pyjwt = "^2.10.1"
|
|
22
|
+
pytest-mock = "^3.14.0"
|
|
21
23
|
|
|
22
24
|
[tool.poetry.dev-dependencies]
|
|
23
|
-
pytest = "^8.
|
|
24
|
-
flake8 = "^7.
|
|
25
|
+
pytest = "^8.4.1"
|
|
26
|
+
flake8 = "^7.3.0"
|
|
25
27
|
black = "^25.1.0"
|
|
26
|
-
isort = "^6.0.
|
|
27
|
-
pre-commit = "^4.
|
|
28
|
-
pytest-cov = "^6.
|
|
28
|
+
isort = "^6.0.1"
|
|
29
|
+
pre-commit = "^4.2.0"
|
|
30
|
+
pytest-cov = "^6.2.1"
|
|
29
31
|
pytest-depends = "^1.0.1"
|
|
30
|
-
pytest-asyncio = "^0.
|
|
31
|
-
Faker = "^
|
|
32
|
-
unasync-cli = "
|
|
32
|
+
pytest-asyncio = "^1.0.0"
|
|
33
|
+
Faker = "^37.4.0"
|
|
34
|
+
unasync-cli = { git = "https://github.com/supabase-community/unasync-cli.git", branch = "main" }
|
|
33
35
|
|
|
34
36
|
[tool.poetry.group.dev.dependencies]
|
|
35
37
|
pygithub = ">=1.57,<3.0"
|
|
@@ -3,7 +3,12 @@ from __future__ import annotations
|
|
|
3
3
|
from functools import partial
|
|
4
4
|
from typing import Dict, List, Optional
|
|
5
5
|
|
|
6
|
-
from ..helpers import
|
|
6
|
+
from ..helpers import (
|
|
7
|
+
is_valid_uuid,
|
|
8
|
+
model_validate,
|
|
9
|
+
parse_link_response,
|
|
10
|
+
parse_user_response,
|
|
11
|
+
)
|
|
7
12
|
from ..http_clients import AsyncClient
|
|
8
13
|
from ..types import (
|
|
9
14
|
AdminUserAttributes,
|
|
@@ -131,6 +136,8 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
|
|
|
131
136
|
This function should only be called on a server.
|
|
132
137
|
Never expose your `service_role` key in the browser.
|
|
133
138
|
"""
|
|
139
|
+
self._validate_uuid(uid)
|
|
140
|
+
|
|
134
141
|
return await self._request(
|
|
135
142
|
"GET",
|
|
136
143
|
f"admin/users/{uid}",
|
|
@@ -148,6 +155,7 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
|
|
|
148
155
|
This function should only be called on a server.
|
|
149
156
|
Never expose your `service_role` key in the browser.
|
|
150
157
|
"""
|
|
158
|
+
self._validate_uuid(uid)
|
|
151
159
|
return await self._request(
|
|
152
160
|
"PUT",
|
|
153
161
|
f"admin/users/{uid}",
|
|
@@ -162,6 +170,7 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
|
|
|
162
170
|
This function should only be called on a server.
|
|
163
171
|
Never expose your `service_role` key in the browser.
|
|
164
172
|
"""
|
|
173
|
+
self._validate_uuid(id)
|
|
165
174
|
body = {"should_soft_delete": should_soft_delete}
|
|
166
175
|
return await self._request("DELETE", f"admin/users/{id}", body=body)
|
|
167
176
|
|
|
@@ -169,6 +178,7 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
|
|
|
169
178
|
self,
|
|
170
179
|
params: AuthMFAAdminListFactorsParams,
|
|
171
180
|
) -> AuthMFAAdminListFactorsResponse:
|
|
181
|
+
self._validate_uuid(params.get("user_id"))
|
|
172
182
|
return await self._request(
|
|
173
183
|
"GET",
|
|
174
184
|
f"admin/users/{params.get('user_id')}/factors",
|
|
@@ -179,8 +189,14 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
|
|
|
179
189
|
self,
|
|
180
190
|
params: AuthMFAAdminDeleteFactorParams,
|
|
181
191
|
) -> AuthMFAAdminDeleteFactorResponse:
|
|
192
|
+
self._validate_uuid(params.get("user_id"))
|
|
193
|
+
self._validate_uuid(params.get("id"))
|
|
182
194
|
return await self._request(
|
|
183
195
|
"DELETE",
|
|
184
|
-
f"admin/users/{params.get('user_id')}/factors/{params.get('
|
|
196
|
+
f"admin/users/{params.get('user_id')}/factors/{params.get('id')}",
|
|
185
197
|
xform=partial(model_validate, AuthMFAAdminDeleteFactorResponse),
|
|
186
198
|
)
|
|
199
|
+
|
|
200
|
+
def _validate_uuid(self, id: str) -> None:
|
|
201
|
+
if not is_valid_uuid(id):
|
|
202
|
+
raise ValueError(f"Invalid id, '{id}' is not a valid uuid")
|