supabase_auth 2.11.3__tar.gz → 2.11.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.
Files changed (29) hide show
  1. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/PKG-INFO +1 -1
  2. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/pyproject.toml +3 -3
  3. supabase_auth-2.11.4/supabase_auth/version.py +1 -0
  4. supabase_auth-2.11.3/supabase_auth/_sync/api.py +0 -656
  5. supabase_auth-2.11.3/supabase_auth/_sync/client.py +0 -661
  6. supabase_auth-2.11.3/supabase_auth/version.py +0 -1
  7. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/LICENSE +0 -0
  8. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/README.md +0 -0
  9. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/__init__.py +0 -0
  10. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/_async/__init__.py +0 -0
  11. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/_async/gotrue_admin_api.py +0 -0
  12. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/_async/gotrue_admin_mfa_api.py +0 -0
  13. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/_async/gotrue_base_api.py +0 -0
  14. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/_async/gotrue_client.py +0 -0
  15. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/_async/gotrue_mfa_api.py +0 -0
  16. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/_async/storage.py +0 -0
  17. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/_sync/__init__.py +0 -0
  18. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/_sync/gotrue_admin_api.py +0 -0
  19. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/_sync/gotrue_admin_mfa_api.py +0 -0
  20. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/_sync/gotrue_base_api.py +0 -0
  21. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/_sync/gotrue_client.py +0 -0
  22. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/_sync/gotrue_mfa_api.py +0 -0
  23. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/_sync/storage.py +0 -0
  24. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/constants.py +0 -0
  25. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/errors.py +0 -0
  26. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/helpers.py +0 -0
  27. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/http_clients.py +0 -0
  28. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/timer.py +0 -0
  29. {supabase_auth-2.11.3 → supabase_auth-2.11.4}/supabase_auth/types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: supabase_auth
3
- Version: 2.11.3
3
+ Version: 2.11.4
4
4
  Summary: Python Client Library for Supabase Auth
5
5
  Home-page: https://github.com/supabase/auth-py
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "supabase_auth"
3
- version = "2.11.3" # {x-release-please-version}
3
+ version = "2.11.4" # {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"
@@ -21,14 +21,14 @@ pydantic = ">=1.10,<3"
21
21
 
22
22
  [tool.poetry.dev-dependencies]
23
23
  pytest = "^8.3.4"
24
- flake8 = "^7.1.1"
24
+ flake8 = "^7.1.2"
25
25
  black = "^25.1.0"
26
26
  isort = "^6.0.0"
27
27
  pre-commit = "^4.1.0"
28
28
  pytest-cov = "^6.0.0"
29
29
  pytest-depends = "^1.0.1"
30
30
  pytest-asyncio = "^0.25.3"
31
- Faker = "^35.0.0"
31
+ Faker = "^36.1.1"
32
32
  unasync-cli = "^0.0.9"
33
33
 
34
34
  [tool.poetry.group.dev.dependencies]
@@ -0,0 +1 @@
1
+ __version__ = "2.11.4" # {x-release-please-version}
@@ -1,656 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import Any, Dict, List, Optional, Union
4
-
5
- from pydantic import parse_obj_as
6
-
7
- from ..exceptions import APIError
8
- from ..helpers import check_response, encode_uri_component
9
- from ..http_clients import SyncClient
10
- from ..types import (
11
- CookieOptions,
12
- LinkType,
13
- Provider,
14
- Session,
15
- User,
16
- UserAttributes,
17
- determine_session_or_user_model_from_response,
18
- )
19
-
20
-
21
- class SyncGoTrueAPI:
22
- def __init__(
23
- self,
24
- *,
25
- url: str,
26
- headers: Dict[str, str],
27
- cookie_options: CookieOptions,
28
- http_client: Optional[SyncClient] = None,
29
- verify: bool = True,
30
- proxy: Optional[str] = None,
31
- ) -> None:
32
- """Initialise API class."""
33
- self.url = url
34
- self.headers = headers
35
- self.cookie_options = cookie_options
36
- self.http_client = http_client or SyncClient(
37
- verify=bool(verify),
38
- proxy=proxy,
39
- follow_redirects=True,
40
- http2=True,
41
- )
42
-
43
- def __enter__(self) -> SyncGoTrueAPI:
44
- return self
45
-
46
- def __exit__(self, exc_t, exc_v, exc_tb) -> None:
47
- self.close()
48
-
49
- def close(self) -> None:
50
- self.http_client.aclose()
51
-
52
- def create_user(self, *, attributes: UserAttributes) -> User:
53
- """Creates a new user.
54
-
55
- This function should only be called on a server.
56
- Never expose your `service_role` key in the browser.
57
-
58
- Parameters
59
- ----------
60
- attributes: UserAttributes
61
- The data you want to create the user with.
62
-
63
- Returns
64
- -------
65
- response : User
66
- The created user
67
-
68
- Raises
69
- ------
70
- APIError
71
- If an error occurs.
72
- """
73
- headers = self.headers
74
- data = attributes.dict()
75
- url = f"{self.url}/admin/users"
76
- response = self.http_client.post(url, json=data, headers=headers)
77
- return User.parse_response(response)
78
-
79
- def list_users(self) -> List[User]:
80
- """Get a list of users.
81
-
82
- This function should only be called on a server.
83
- Never expose your `service_role` key in the browser.
84
-
85
- Returns
86
- -------
87
- response : List[User]
88
- A list of users
89
-
90
- Raises
91
- ------
92
- APIError
93
- If an error occurs.
94
- """
95
- headers = self.headers
96
- url = f"{self.url}/admin/users"
97
- response = self.http_client.get(url, headers=headers)
98
- check_response(response)
99
- users = response.json().get("users")
100
- if users is None:
101
- raise APIError("No users found in response", 400)
102
- if not isinstance(users, list):
103
- raise APIError("Expected a list of users", 400)
104
- return parse_obj_as(List[User], users)
105
-
106
- def sign_up_with_email(
107
- self,
108
- *,
109
- email: str,
110
- password: str,
111
- redirect_to: Optional[str] = None,
112
- data: Optional[Dict[str, Any]] = None,
113
- ) -> Union[Session, User]:
114
- """Creates a new user using their email address.
115
-
116
- Parameters
117
- ----------
118
- email : str
119
- The email address of the user.
120
- password : str
121
- The password of the user.
122
- redirect_to : Optional[str]
123
- A URL or mobile address to send the user to after they are confirmed.
124
- data : Optional[Dict[str, Any]]
125
- Optional user metadata.
126
-
127
- Returns
128
- -------
129
- response : Union[Session, User]
130
- A logged-in session if the server has "autoconfirm" ON
131
- A user if the server has "autoconfirm" OFF
132
-
133
- Raises
134
- ------
135
- APIError
136
- If an error occurs.
137
- """
138
- headers = self.headers
139
- query_string = ""
140
- if redirect_to:
141
- redirect_to_encoded = encode_uri_component(redirect_to)
142
- query_string = f"?redirect_to={redirect_to_encoded}"
143
- data = {"email": email, "password": password, "data": data}
144
- url = f"{self.url}/signup{query_string}"
145
- response = self.http_client.post(url, json=data, headers=headers)
146
- session_or_user_model = determine_session_or_user_model_from_response(response)
147
- return session_or_user_model.parse_response(response)
148
-
149
- def sign_in_with_email(
150
- self,
151
- *,
152
- email: str,
153
- password: str,
154
- redirect_to: Optional[str] = None,
155
- ) -> Session:
156
- """Logs in an existing user using their email address.
157
-
158
- Parameters
159
- ----------
160
- email : str
161
- The email address of the user.
162
- password : str
163
- The password of the user.
164
- redirect_to : Optional[str]
165
- A URL or mobile address to send the user to after they are confirmed.
166
-
167
- Returns
168
- -------
169
- response : Session
170
- A logged-in session
171
-
172
- Raises
173
- ------
174
- APIError
175
- If an error occurs.
176
- """
177
-
178
- headers = self.headers
179
- query_string = "?grant_type=password"
180
- if redirect_to:
181
- redirect_to_encoded = encode_uri_component(redirect_to)
182
- query_string += f"&redirect_to={redirect_to_encoded}"
183
- data = {"email": email, "password": password}
184
- url = f"{self.url}/token{query_string}"
185
- response = self.http_client.post(url, json=data, headers=headers)
186
- return Session.parse_response(response)
187
-
188
- def sign_up_with_phone(
189
- self,
190
- *,
191
- phone: str,
192
- password: str,
193
- data: Optional[Dict[str, Any]] = None,
194
- ) -> Union[Session, User]:
195
- """Signs up a new user using their phone number and a password.
196
-
197
- Parameters
198
- ----------
199
- phone : str
200
- The phone number of the user.
201
- password : str
202
- The password of the user.
203
- data : Optional[Dict[str, Any]]
204
- Optional user metadata.
205
-
206
- Returns
207
- -------
208
- response : Union[Session, User]
209
- A logged-in session if the server has "autoconfirm" ON
210
- A user if the server has "autoconfirm" OFF
211
-
212
- Raises
213
- ------
214
- APIError
215
- If an error occurs.
216
- """
217
- headers = self.headers
218
- data = {"phone": phone, "password": password, "data": data}
219
- url = f"{self.url}/signup"
220
- response = self.http_client.post(url, json=data, headers=headers)
221
- session_or_user_model = determine_session_or_user_model_from_response(response)
222
- return session_or_user_model.parse_response(response)
223
-
224
- def sign_in_with_phone(
225
- self,
226
- *,
227
- phone: str,
228
- password: str,
229
- ) -> Session:
230
- """Logs in an existing user using their phone number and password.
231
-
232
- Parameters
233
- ----------
234
- phone : str
235
- The phone number of the user.
236
- password : str
237
- The password of the user.
238
-
239
- Returns
240
- -------
241
- response : Session
242
- A logged-in session
243
-
244
- Raises
245
- ------
246
- APIError
247
- If an error occurs.
248
- """
249
- data = {"phone": phone, "password": password}
250
- url = f"{self.url}/token?grant_type=password"
251
- headers = self.headers
252
- response = self.http_client.post(url, json=data, headers=headers)
253
- return Session.parse_response(response)
254
-
255
- def send_magic_link_email(
256
- self,
257
- *,
258
- email: str,
259
- create_user: bool,
260
- redirect_to: Optional[str] = None,
261
- ) -> None:
262
- """Sends a magic login link to an email address.
263
-
264
- Parameters
265
- ----------
266
- email : str
267
- The email address of the user.
268
- redirect_to : Optional[str]
269
- A URL or mobile address to send the user to after they are confirmed.
270
-
271
- Raises
272
- ------
273
- APIError
274
- If an error occurs.
275
- """
276
- headers = self.headers
277
- query_string = ""
278
- if redirect_to:
279
- redirect_to_encoded = encode_uri_component(redirect_to)
280
- query_string = f"?redirect_to={redirect_to_encoded}"
281
- data = {"email": email, "create_user": create_user}
282
- url = f"{self.url}/magiclink{query_string}"
283
- response = self.http_client.post(url, json=data, headers=headers)
284
- return check_response(response)
285
-
286
- def send_mobile_otp(self, *, phone: str, create_user: bool) -> None:
287
- """Sends a mobile OTP via SMS. Will register the account if it doesn't already exist
288
-
289
- Parameters
290
- ----------
291
- phone : str
292
- The user's phone number WITH international prefix
293
-
294
- Raises
295
- ------
296
- APIError
297
- If an error occurs.
298
- """
299
- headers = self.headers
300
- data = {"phone": phone, "create_user": create_user}
301
- url = f"{self.url}/otp"
302
- response = self.http_client.post(url, json=data, headers=headers)
303
- return check_response(response)
304
-
305
- def verify_mobile_otp(
306
- self,
307
- *,
308
- phone: str,
309
- token: str,
310
- redirect_to: Optional[str] = None,
311
- ) -> Union[Session, User]:
312
- """Send User supplied Mobile OTP to be verified
313
-
314
- Parameters
315
- ----------
316
- phone : str
317
- The user's phone number WITH international prefix
318
- token : str
319
- Token that user was sent to their mobile phone
320
- redirect_to : Optional[str]
321
- A URL or mobile address to send the user to after they are confirmed.
322
-
323
- Returns
324
- -------
325
- response : Union[Session, User]
326
- A logged-in session if the server has "autoconfirm" ON
327
- A user if the server has "autoconfirm" OFF
328
-
329
- Raises
330
- ------
331
- APIError
332
- If an error occurs.
333
- """
334
- headers = self.headers
335
- data = {
336
- "phone": phone,
337
- "token": token,
338
- "type": "sms",
339
- }
340
- if redirect_to:
341
- redirect_to_encoded = encode_uri_component(redirect_to)
342
- data["redirect_to"] = redirect_to_encoded
343
- url = f"{self.url}/verify"
344
- response = self.http_client.post(url, json=data, headers=headers)
345
- session_or_user_model = determine_session_or_user_model_from_response(response)
346
- return session_or_user_model.parse_response(response)
347
-
348
- def invite_user_by_email(
349
- self,
350
- *,
351
- email: str,
352
- redirect_to: Optional[str] = None,
353
- data: Optional[Dict[str, Any]] = None,
354
- ) -> User:
355
- """Sends an invite link to an email address.
356
-
357
- Parameters
358
- ----------
359
- email : str
360
- The email address of the user.
361
- redirect_to : Optional[str]
362
- A URL or mobile address to send the user to after they are confirmed.
363
- data : Optional[Dict[str, Any]]
364
- Optional user metadata.
365
-
366
- Returns
367
- -------
368
- response : User
369
- A user
370
-
371
- Raises
372
- ------
373
- APIError
374
- If an error occurs.
375
- """
376
- headers = self.headers
377
- query_string = ""
378
- if redirect_to:
379
- redirect_to_encoded = encode_uri_component(redirect_to)
380
- query_string = f"?redirect_to={redirect_to_encoded}"
381
- data = {"email": email, "data": data}
382
- url = f"{self.url}/invite{query_string}"
383
- response = self.http_client.post(url, json=data, headers=headers)
384
- return User.parse_response(response)
385
-
386
- def reset_password_for_email(
387
- self,
388
- *,
389
- email: str,
390
- redirect_to: Optional[str] = None,
391
- ) -> None:
392
- """Sends a reset request to an email address.
393
-
394
- Parameters
395
- ----------
396
- email : str
397
- The email address of the user.
398
- redirect_to : Optional[str]
399
- A URL or mobile address to send the user to after they are confirmed.
400
-
401
- Raises
402
- ------
403
- APIError
404
- If an error occurs.
405
- """
406
- headers = self.headers
407
- query_string = ""
408
- if redirect_to:
409
- redirect_to_encoded = encode_uri_component(redirect_to)
410
- query_string = f"?redirect_to={redirect_to_encoded}"
411
- data = {"email": email}
412
- url = f"{self.url}/recover{query_string}"
413
- response = self.http_client.post(url, json=data, headers=headers)
414
- return check_response(response)
415
-
416
- def _create_request_headers(self, *, jwt: str) -> Dict[str, str]:
417
- """Create temporary object.
418
-
419
- Create a temporary object with all configured headers and adds the
420
- Authorization token to be used on request methods.
421
-
422
- Parameters
423
- ----------
424
- jwt : str
425
- A valid, logged-in JWT.
426
-
427
- Returns
428
- -------
429
- headers : dict of str
430
- The headers required for a successful request statement with the
431
- supabase backend.
432
- """
433
- headers = {**self.headers, "Authorization": f"Bearer {jwt}"}
434
- return headers
435
-
436
- def sign_out(self, *, jwt: str) -> None:
437
- """Removes a logged-in session.
438
-
439
- Parameters
440
- ----------
441
- jwt : str
442
- A valid, logged-in JWT.
443
- """
444
- headers = self._create_request_headers(jwt=jwt)
445
- url = f"{self.url}/logout"
446
- self.http_client.post(url, headers=headers)
447
-
448
- def get_url_for_provider(
449
- self,
450
- *,
451
- provider: Provider,
452
- redirect_to: Optional[str] = None,
453
- scopes: Optional[str] = None,
454
- ) -> str:
455
- """Generates the relevant login URL for a third-party provider.
456
-
457
- Parameters
458
- ----------
459
- provider : Provider
460
- One of the providers supported by GoTrue.
461
- redirect_to : Optional[str]
462
- A URL or mobile address to send the user to after they are confirmed.
463
- scopes : Optional[str]
464
- A space-separated list of scopes granted to the OAuth application.
465
-
466
- Returns
467
- -------
468
- url : str
469
- The URL to redirect the user to.
470
-
471
- Raises
472
- ------
473
- APIError
474
- If an error occurs.
475
- """
476
- url_params = [f"provider={encode_uri_component(provider)}"]
477
- if redirect_to:
478
- redirect_to_encoded = encode_uri_component(redirect_to)
479
- url_params.append(f"redirect_to={redirect_to_encoded}")
480
- if scopes:
481
- url_params.append(f"scopes={encode_uri_component(scopes)}")
482
- return f"{self.url}/authorize?{'&'.join(url_params)}"
483
-
484
- def get_user(self, *, jwt: str) -> User:
485
- """Gets the user details.
486
-
487
- Parameters
488
- ----------
489
- jwt : str
490
- A valid, logged-in JWT.
491
-
492
- Returns
493
- -------
494
- response : User
495
- A user
496
-
497
- Raises
498
- ------
499
- APIError
500
- If an error occurs.
501
- """
502
- headers = self._create_request_headers(jwt=jwt)
503
- url = f"{self.url}/user"
504
- response = self.http_client.get(url, headers=headers)
505
- return User.parse_response(response)
506
-
507
- def update_user(
508
- self,
509
- *,
510
- jwt: str,
511
- attributes: UserAttributes,
512
- ) -> User:
513
- """
514
- Updates the user data.
515
-
516
- Parameters
517
- ----------
518
- jwt : str
519
- A valid, logged-in JWT.
520
- attributes : UserAttributes
521
- The data you want to update.
522
-
523
- Returns
524
- -------
525
- response : User
526
- A user
527
-
528
- Raises
529
- ------
530
- APIError
531
- If an error occurs.
532
- """
533
- headers = self._create_request_headers(jwt=jwt)
534
- data = attributes.dict()
535
- url = f"{self.url}/user"
536
- response = self.http_client.put(url, json=data, headers=headers)
537
- return User.parse_response(response)
538
-
539
- def delete_user(
540
- self, *, uid: str, jwt: str, should_soft_delete: bool = False
541
- ) -> None:
542
- """Delete a user. Requires a `service_role` key.
543
-
544
- This function should only be called on a server.
545
- Never expose your `service_role` key in the browser.
546
-
547
- Parameters
548
- ----------
549
- uid : str
550
- The user uid you want to remove.
551
- jwt : str
552
- A valid, logged-in JWT.
553
- should_soft_delete : bool
554
- If true, then the user will be soft-deleted from the auth schema.
555
-
556
- Returns
557
- -------
558
- response : User
559
- A user
560
-
561
- Raises
562
- ------
563
- APIError
564
- If an error occurs.
565
- """
566
- headers = self._create_request_headers(jwt=jwt)
567
- url = f"{self.url}/admin/users/{uid}"
568
- body = {
569
- "should_soft_delete": should_soft_delete,
570
- }
571
- response = self.http_client.delete(url, json=body, headers=headers)
572
- return check_response(response)
573
-
574
- def refresh_access_token(self, *, refresh_token: str) -> Session:
575
- """Generates a new JWT.
576
-
577
- Parameters
578
- ----------
579
- refresh_token : str
580
- A valid refresh token that was returned on login.
581
-
582
- Returns
583
- -------
584
- response : Session
585
- A session
586
-
587
- Raises
588
- ------
589
- APIError
590
- If an error occurs.
591
- """
592
- data = {"refresh_token": refresh_token}
593
- url = f"{self.url}/token?grant_type=refresh_token"
594
- headers = self.headers
595
- response = self.http_client.post(url, json=data, headers=headers)
596
- return Session.parse_response(response)
597
-
598
- def generate_link(
599
- self,
600
- *,
601
- type: LinkType,
602
- email: str,
603
- password: Optional[str] = None,
604
- redirect_to: Optional[str] = None,
605
- data: Optional[Dict[str, Any]] = None,
606
- ) -> Union[Session, User]:
607
- """
608
- Generates links to be sent via email or other.
609
-
610
- Parameters
611
- ----------
612
- type : LinkType
613
- The link type ("signup" or "magiclink" or "recovery" or "invite").
614
- email : str
615
- The user's email.
616
- password : Optional[str]
617
- User password. For signup only.
618
- redirect_to : Optional[str]
619
- The link type ("signup" or "magiclink" or "recovery" or "invite").
620
- data : Optional[Dict[str, Any]]
621
- Optional user metadata. For signup only.
622
-
623
- Returns
624
- -------
625
- response : Union[Session, User]
626
- A logged-in session if the server has "autoconfirm" ON
627
- A user if the server has "autoconfirm" OFF
628
-
629
- Raises
630
- ------
631
- APIError
632
- If an error occurs.
633
- """
634
- headers = self.headers
635
- data = {
636
- "type": type,
637
- "email": email,
638
- "data": data,
639
- }
640
- if password:
641
- data["password"] = password
642
- if redirect_to:
643
- redirect_to_encoded = encode_uri_component(redirect_to)
644
- data["redirect_to"] = redirect_to_encoded
645
- url = f"{self.url}/admin/generate_link"
646
- response = self.http_client.post(url, json=data, headers=headers)
647
- session_or_user_model = determine_session_or_user_model_from_response(response)
648
- return session_or_user_model.parse_response(response)
649
-
650
- def set_auth_cookie(self, *, req, res):
651
- """Stub for parity with JS api."""
652
- raise NotImplementedError("set_auth_cookie not implemented.")
653
-
654
- def get_user_by_cookie(self, *, req):
655
- """Stub for parity with JS api."""
656
- raise NotImplementedError("get_user_by_cookie not implemented.")