supabase_auth 2.9.2__tar.gz → 2.9.3__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.9.2 → supabase_auth-2.9.3}/PKG-INFO +2 -3
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/pyproject.toml +3 -3
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_async/gotrue_admin_api.py +2 -2
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_async/gotrue_base_api.py +24 -24
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_async/gotrue_client.py +22 -22
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_sync/gotrue_admin_api.py +2 -2
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_sync/gotrue_base_api.py +24 -24
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_sync/gotrue_client.py +22 -22
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/errors.py +3 -3
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/helpers.py +2 -2
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/timer.py +4 -4
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/types.py +32 -32
- supabase_auth-2.9.3/supabase_auth/version.py +1 -0
- supabase_auth-2.9.2/supabase_auth/version.py +0 -1
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/LICENSE +0 -0
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/README.md +0 -0
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/__init__.py +0 -0
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_async/__init__.py +0 -0
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_async/gotrue_admin_mfa_api.py +0 -0
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_async/gotrue_mfa_api.py +0 -0
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_async/storage.py +0 -0
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_sync/__init__.py +0 -0
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_sync/api.py +0 -0
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_sync/client.py +0 -0
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_sync/gotrue_admin_mfa_api.py +0 -0
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_sync/gotrue_mfa_api.py +0 -0
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/_sync/storage.py +0 -0
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/constants.py +0 -0
- {supabase_auth-2.9.2 → supabase_auth-2.9.3}/supabase_auth/http_clients.py +0 -0
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: supabase_auth
|
|
3
|
-
Version: 2.9.
|
|
3
|
+
Version: 2.9.3
|
|
4
4
|
Summary: Python Client Library for Supabase Auth
|
|
5
5
|
Home-page: https://github.com/supabase/auth-py
|
|
6
6
|
License: MIT
|
|
7
7
|
Author: Joel Lee
|
|
8
8
|
Author-email: joel@joellee.org
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.9,<4.0
|
|
10
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
11
11
|
Classifier: Operating System :: OS Independent
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.9
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "supabase_auth"
|
|
3
|
-
version = "2.9.
|
|
3
|
+
version = "2.9.3" # {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"
|
|
@@ -15,7 +15,7 @@ classifiers = [
|
|
|
15
15
|
]
|
|
16
16
|
|
|
17
17
|
[tool.poetry.dependencies]
|
|
18
|
-
python = "^3.
|
|
18
|
+
python = "^3.9"
|
|
19
19
|
httpx = {version = ">=0.26,<0.28", extras = ["http2"]}
|
|
20
20
|
pydantic = ">=1.10,<3"
|
|
21
21
|
|
|
@@ -28,7 +28,7 @@ pre-commit = "^3.4.0"
|
|
|
28
28
|
pytest-cov = "^5.0.0"
|
|
29
29
|
pytest-depends = "^1.0.1"
|
|
30
30
|
pytest-asyncio = "^0.24.0"
|
|
31
|
-
Faker = "^30.
|
|
31
|
+
Faker = "^30.6.0"
|
|
32
32
|
unasync-cli = "^0.0.9"
|
|
33
33
|
|
|
34
34
|
[tool.poetry.group.dev.dependencies]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from functools import partial
|
|
4
|
-
from typing import Dict, List, Optional
|
|
4
|
+
from typing import Dict, List, Optional
|
|
5
5
|
|
|
6
6
|
from ..helpers import model_validate, parse_link_response, parse_user_response
|
|
7
7
|
from ..http_clients import AsyncClient
|
|
@@ -28,7 +28,7 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
|
|
|
28
28
|
*,
|
|
29
29
|
url: str = "",
|
|
30
30
|
headers: Dict[str, str] = {},
|
|
31
|
-
http_client:
|
|
31
|
+
http_client: Optional[AsyncClient] = None,
|
|
32
32
|
verify: bool = True,
|
|
33
33
|
proxy: Optional[str] = None,
|
|
34
34
|
) -> None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import Any, Callable, Dict, Optional, TypeVar,
|
|
3
|
+
from typing import Any, Callable, Dict, Optional, TypeVar, overload
|
|
4
4
|
|
|
5
5
|
from httpx import Response
|
|
6
6
|
from pydantic import BaseModel
|
|
@@ -19,7 +19,7 @@ class AsyncGoTrueBaseAPI:
|
|
|
19
19
|
*,
|
|
20
20
|
url: str,
|
|
21
21
|
headers: Dict[str, str],
|
|
22
|
-
http_client:
|
|
22
|
+
http_client: Optional[AsyncClient],
|
|
23
23
|
verify: bool = True,
|
|
24
24
|
proxy: Optional[str] = None,
|
|
25
25
|
):
|
|
@@ -47,11 +47,11 @@ class AsyncGoTrueBaseAPI:
|
|
|
47
47
|
method: Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"],
|
|
48
48
|
path: str,
|
|
49
49
|
*,
|
|
50
|
-
jwt:
|
|
51
|
-
redirect_to:
|
|
52
|
-
headers:
|
|
53
|
-
query:
|
|
54
|
-
body:
|
|
50
|
+
jwt: Optional[str] = None,
|
|
51
|
+
redirect_to: Optional[str] = None,
|
|
52
|
+
headers: Optional[Dict[str, str]] = None,
|
|
53
|
+
query: Optional[Dict[str, str]] = None,
|
|
54
|
+
body: Optional[Any] = None,
|
|
55
55
|
no_resolve_json: Literal[False] = False,
|
|
56
56
|
xform: Callable[[Any], T],
|
|
57
57
|
) -> T: ... # pragma: no cover
|
|
@@ -62,11 +62,11 @@ class AsyncGoTrueBaseAPI:
|
|
|
62
62
|
method: Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"],
|
|
63
63
|
path: str,
|
|
64
64
|
*,
|
|
65
|
-
jwt:
|
|
66
|
-
redirect_to:
|
|
67
|
-
headers:
|
|
68
|
-
query:
|
|
69
|
-
body:
|
|
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
70
|
no_resolve_json: Literal[True],
|
|
71
71
|
xform: Callable[[Response], T],
|
|
72
72
|
) -> T: ... # pragma: no cover
|
|
@@ -77,11 +77,11 @@ class AsyncGoTrueBaseAPI:
|
|
|
77
77
|
method: Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"],
|
|
78
78
|
path: str,
|
|
79
79
|
*,
|
|
80
|
-
jwt:
|
|
81
|
-
redirect_to:
|
|
82
|
-
headers:
|
|
83
|
-
query:
|
|
84
|
-
body:
|
|
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
85
|
no_resolve_json: bool = False,
|
|
86
86
|
) -> None: ... # pragma: no cover
|
|
87
87
|
|
|
@@ -90,14 +90,14 @@ class AsyncGoTrueBaseAPI:
|
|
|
90
90
|
method: Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"],
|
|
91
91
|
path: str,
|
|
92
92
|
*,
|
|
93
|
-
jwt:
|
|
94
|
-
redirect_to:
|
|
95
|
-
headers:
|
|
96
|
-
query:
|
|
97
|
-
body:
|
|
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,
|
|
97
|
+
body: Optional[Any] = None,
|
|
98
98
|
no_resolve_json: bool = False,
|
|
99
|
-
xform:
|
|
100
|
-
) ->
|
|
99
|
+
xform: Optional[Callable[[Any], T]] = None,
|
|
100
|
+
) -> Optional[T]:
|
|
101
101
|
url = f"{self._url}/{path}"
|
|
102
102
|
headers = {**self._headers, **(headers or {})}
|
|
103
103
|
if API_VERSION_HEADER_NAME not in headers:
|
|
@@ -4,7 +4,7 @@ from contextlib import suppress
|
|
|
4
4
|
from functools import partial
|
|
5
5
|
from json import loads
|
|
6
6
|
from time import time
|
|
7
|
-
from typing import Callable, Dict, List, Optional, Tuple
|
|
7
|
+
from typing import Callable, Dict, List, Optional, Tuple
|
|
8
8
|
from urllib.parse import parse_qs, urlencode, urlparse
|
|
9
9
|
from uuid import uuid4
|
|
10
10
|
|
|
@@ -87,13 +87,13 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
87
87
|
def __init__(
|
|
88
88
|
self,
|
|
89
89
|
*,
|
|
90
|
-
url:
|
|
91
|
-
headers:
|
|
92
|
-
storage_key:
|
|
90
|
+
url: Optional[str] = None,
|
|
91
|
+
headers: Optional[Dict[str, str]] = None,
|
|
92
|
+
storage_key: Optional[str] = None,
|
|
93
93
|
auto_refresh_token: bool = True,
|
|
94
94
|
persist_session: bool = True,
|
|
95
|
-
storage:
|
|
96
|
-
http_client:
|
|
95
|
+
storage: Optional[AsyncSupportedStorage] = None,
|
|
96
|
+
http_client: Optional[AsyncClient] = None,
|
|
97
97
|
flow_type: AuthFlowType = "implicit",
|
|
98
98
|
verify: bool = True,
|
|
99
99
|
proxy: Optional[str] = None,
|
|
@@ -110,8 +110,8 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
110
110
|
self._auto_refresh_token = auto_refresh_token
|
|
111
111
|
self._persist_session = persist_session
|
|
112
112
|
self._storage = storage or AsyncMemoryStorage()
|
|
113
|
-
self._in_memory_session:
|
|
114
|
-
self._refresh_token_timer:
|
|
113
|
+
self._in_memory_session: Optional[Session] = None
|
|
114
|
+
self._refresh_token_timer: Optional[Timer] = None
|
|
115
115
|
self._network_retries = 0
|
|
116
116
|
self._state_change_emitters: Dict[str, Subscription] = {}
|
|
117
117
|
self._flow_type = flow_type
|
|
@@ -134,7 +134,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
134
134
|
|
|
135
135
|
# Initializations
|
|
136
136
|
|
|
137
|
-
async def initialize(self, *, url:
|
|
137
|
+
async def initialize(self, *, url: Optional[str] = None) -> None:
|
|
138
138
|
if url and self._is_implicit_grant_flow(url):
|
|
139
139
|
await self.initialize_from_url(url)
|
|
140
140
|
else:
|
|
@@ -158,7 +158,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
158
158
|
# Public methods
|
|
159
159
|
|
|
160
160
|
async def sign_in_anonymously(
|
|
161
|
-
self, credentials:
|
|
161
|
+
self, credentials: Optional[SignInAnonymouslyCredentials] = None
|
|
162
162
|
) -> AuthResponse:
|
|
163
163
|
"""
|
|
164
164
|
Creates a new anonymous user.
|
|
@@ -591,14 +591,14 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
591
591
|
xform=parse_auth_response,
|
|
592
592
|
)
|
|
593
593
|
|
|
594
|
-
async def get_session(self) ->
|
|
594
|
+
async def get_session(self) -> Optional[Session]:
|
|
595
595
|
"""
|
|
596
596
|
Returns the session, refreshing it if necessary.
|
|
597
597
|
|
|
598
598
|
The session returned can be null if the session is not detected which
|
|
599
599
|
can happen in the event a user is not signed-in or has logged out.
|
|
600
600
|
"""
|
|
601
|
-
current_session:
|
|
601
|
+
current_session: Optional[Session] = None
|
|
602
602
|
if self._persist_session:
|
|
603
603
|
maybe_session = await self._storage.get_item(self._storage_key)
|
|
604
604
|
current_session = self._get_valid_session(maybe_session)
|
|
@@ -620,7 +620,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
620
620
|
else current_session
|
|
621
621
|
)
|
|
622
622
|
|
|
623
|
-
async def get_user(self, jwt:
|
|
623
|
+
async def get_user(self, jwt: Optional[str] = None) -> Optional[UserResponse]:
|
|
624
624
|
"""
|
|
625
625
|
Gets the current user details if there is an existing session.
|
|
626
626
|
|
|
@@ -672,7 +672,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
672
672
|
time_now = round(time())
|
|
673
673
|
expires_at = time_now
|
|
674
674
|
has_expired = True
|
|
675
|
-
session:
|
|
675
|
+
session: Optional[Session] = None
|
|
676
676
|
if access_token and access_token.split(".")[1]:
|
|
677
677
|
payload = self._decode_jwt(access_token)
|
|
678
678
|
exp = payload.get("exp")
|
|
@@ -701,7 +701,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
701
701
|
return AuthResponse(session=session, user=response.user)
|
|
702
702
|
|
|
703
703
|
async def refresh_session(
|
|
704
|
-
self, refresh_token:
|
|
704
|
+
self, refresh_token: Optional[str] = None
|
|
705
705
|
) -> AuthResponse:
|
|
706
706
|
"""
|
|
707
707
|
Returns a new session, regardless of expiry status.
|
|
@@ -743,7 +743,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
743
743
|
|
|
744
744
|
def on_auth_state_change(
|
|
745
745
|
self,
|
|
746
|
-
callback: Callable[[AuthChangeEvent,
|
|
746
|
+
callback: Callable[[AuthChangeEvent, Optional[Session]], None],
|
|
747
747
|
) -> Subscription:
|
|
748
748
|
"""
|
|
749
749
|
Receive a notification every time an auth event happens.
|
|
@@ -889,7 +889,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
889
889
|
current_authentication_methods=[],
|
|
890
890
|
)
|
|
891
891
|
payload = self._decode_jwt(session.access_token)
|
|
892
|
-
current_level:
|
|
892
|
+
current_level: Optional[AuthenticatorAssuranceLevels] = None
|
|
893
893
|
if payload.get("aal"):
|
|
894
894
|
current_level = payload.get("aal")
|
|
895
895
|
verified_factors = [
|
|
@@ -917,7 +917,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
917
917
|
async def _get_session_from_url(
|
|
918
918
|
self,
|
|
919
919
|
url: str,
|
|
920
|
-
) -> Tuple[Session,
|
|
920
|
+
) -> Tuple[Session, Optional[str]]:
|
|
921
921
|
if not self._is_implicit_grant_flow(url):
|
|
922
922
|
raise AuthImplicitGrantRedirectError("Not a valid implicit grant flow url.")
|
|
923
923
|
result = urlparse(url)
|
|
@@ -1062,15 +1062,15 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
1062
1062
|
def _notify_all_subscribers(
|
|
1063
1063
|
self,
|
|
1064
1064
|
event: AuthChangeEvent,
|
|
1065
|
-
session:
|
|
1065
|
+
session: Optional[Session],
|
|
1066
1066
|
) -> None:
|
|
1067
1067
|
for subscription in self._state_change_emitters.values():
|
|
1068
1068
|
subscription.callback(event, session)
|
|
1069
1069
|
|
|
1070
1070
|
def _get_valid_session(
|
|
1071
1071
|
self,
|
|
1072
|
-
raw_session:
|
|
1073
|
-
) ->
|
|
1072
|
+
raw_session: Optional[str],
|
|
1073
|
+
) -> Optional[Session]:
|
|
1074
1074
|
if not raw_session:
|
|
1075
1075
|
return None
|
|
1076
1076
|
data = loads(raw_session)
|
|
@@ -1096,7 +1096,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
1096
1096
|
self,
|
|
1097
1097
|
query_params: Dict[str, List[str]],
|
|
1098
1098
|
name: str,
|
|
1099
|
-
) ->
|
|
1099
|
+
) -> Optional[str]:
|
|
1100
1100
|
return query_params[name][0] if name in query_params else None
|
|
1101
1101
|
|
|
1102
1102
|
def _is_implicit_grant_flow(self, url: str) -> bool:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from functools import partial
|
|
4
|
-
from typing import Dict, List, Optional
|
|
4
|
+
from typing import Dict, List, Optional
|
|
5
5
|
|
|
6
6
|
from ..helpers import model_validate, parse_link_response, parse_user_response
|
|
7
7
|
from ..http_clients import SyncClient
|
|
@@ -28,7 +28,7 @@ class SyncGoTrueAdminAPI(SyncGoTrueBaseAPI):
|
|
|
28
28
|
*,
|
|
29
29
|
url: str = "",
|
|
30
30
|
headers: Dict[str, str] = {},
|
|
31
|
-
http_client:
|
|
31
|
+
http_client: Optional[SyncClient] = None,
|
|
32
32
|
verify: bool = True,
|
|
33
33
|
proxy: Optional[str] = None,
|
|
34
34
|
) -> None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import Any, Callable, Dict, Optional, TypeVar,
|
|
3
|
+
from typing import Any, Callable, Dict, Optional, TypeVar, overload
|
|
4
4
|
|
|
5
5
|
from httpx import Response
|
|
6
6
|
from pydantic import BaseModel
|
|
@@ -19,7 +19,7 @@ class SyncGoTrueBaseAPI:
|
|
|
19
19
|
*,
|
|
20
20
|
url: str,
|
|
21
21
|
headers: Dict[str, str],
|
|
22
|
-
http_client:
|
|
22
|
+
http_client: Optional[SyncClient],
|
|
23
23
|
verify: bool = True,
|
|
24
24
|
proxy: Optional[str] = None,
|
|
25
25
|
):
|
|
@@ -47,11 +47,11 @@ class SyncGoTrueBaseAPI:
|
|
|
47
47
|
method: Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"],
|
|
48
48
|
path: str,
|
|
49
49
|
*,
|
|
50
|
-
jwt:
|
|
51
|
-
redirect_to:
|
|
52
|
-
headers:
|
|
53
|
-
query:
|
|
54
|
-
body:
|
|
50
|
+
jwt: Optional[str] = None,
|
|
51
|
+
redirect_to: Optional[str] = None,
|
|
52
|
+
headers: Optional[Dict[str, str]] = None,
|
|
53
|
+
query: Optional[Dict[str, str]] = None,
|
|
54
|
+
body: Optional[Any] = None,
|
|
55
55
|
no_resolve_json: Literal[False] = False,
|
|
56
56
|
xform: Callable[[Any], T],
|
|
57
57
|
) -> T: ... # pragma: no cover
|
|
@@ -62,11 +62,11 @@ class SyncGoTrueBaseAPI:
|
|
|
62
62
|
method: Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"],
|
|
63
63
|
path: str,
|
|
64
64
|
*,
|
|
65
|
-
jwt:
|
|
66
|
-
redirect_to:
|
|
67
|
-
headers:
|
|
68
|
-
query:
|
|
69
|
-
body:
|
|
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
70
|
no_resolve_json: Literal[True],
|
|
71
71
|
xform: Callable[[Response], T],
|
|
72
72
|
) -> T: ... # pragma: no cover
|
|
@@ -77,11 +77,11 @@ class SyncGoTrueBaseAPI:
|
|
|
77
77
|
method: Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"],
|
|
78
78
|
path: str,
|
|
79
79
|
*,
|
|
80
|
-
jwt:
|
|
81
|
-
redirect_to:
|
|
82
|
-
headers:
|
|
83
|
-
query:
|
|
84
|
-
body:
|
|
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
85
|
no_resolve_json: bool = False,
|
|
86
86
|
) -> None: ... # pragma: no cover
|
|
87
87
|
|
|
@@ -90,14 +90,14 @@ class SyncGoTrueBaseAPI:
|
|
|
90
90
|
method: Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"],
|
|
91
91
|
path: str,
|
|
92
92
|
*,
|
|
93
|
-
jwt:
|
|
94
|
-
redirect_to:
|
|
95
|
-
headers:
|
|
96
|
-
query:
|
|
97
|
-
body:
|
|
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,
|
|
97
|
+
body: Optional[Any] = None,
|
|
98
98
|
no_resolve_json: bool = False,
|
|
99
|
-
xform:
|
|
100
|
-
) ->
|
|
99
|
+
xform: Optional[Callable[[Any], T]] = None,
|
|
100
|
+
) -> Optional[T]:
|
|
101
101
|
url = f"{self._url}/{path}"
|
|
102
102
|
headers = {**self._headers, **(headers or {})}
|
|
103
103
|
if API_VERSION_HEADER_NAME not in headers:
|
|
@@ -4,7 +4,7 @@ from contextlib import suppress
|
|
|
4
4
|
from functools import partial
|
|
5
5
|
from json import loads
|
|
6
6
|
from time import time
|
|
7
|
-
from typing import Callable, Dict, List, Optional, Tuple
|
|
7
|
+
from typing import Callable, Dict, List, Optional, Tuple
|
|
8
8
|
from urllib.parse import parse_qs, urlencode, urlparse
|
|
9
9
|
from uuid import uuid4
|
|
10
10
|
|
|
@@ -87,13 +87,13 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
87
87
|
def __init__(
|
|
88
88
|
self,
|
|
89
89
|
*,
|
|
90
|
-
url:
|
|
91
|
-
headers:
|
|
92
|
-
storage_key:
|
|
90
|
+
url: Optional[str] = None,
|
|
91
|
+
headers: Optional[Dict[str, str]] = None,
|
|
92
|
+
storage_key: Optional[str] = None,
|
|
93
93
|
auto_refresh_token: bool = True,
|
|
94
94
|
persist_session: bool = True,
|
|
95
|
-
storage:
|
|
96
|
-
http_client:
|
|
95
|
+
storage: Optional[SyncSupportedStorage] = None,
|
|
96
|
+
http_client: Optional[SyncClient] = None,
|
|
97
97
|
flow_type: AuthFlowType = "implicit",
|
|
98
98
|
verify: bool = True,
|
|
99
99
|
proxy: Optional[str] = None,
|
|
@@ -110,8 +110,8 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
110
110
|
self._auto_refresh_token = auto_refresh_token
|
|
111
111
|
self._persist_session = persist_session
|
|
112
112
|
self._storage = storage or SyncMemoryStorage()
|
|
113
|
-
self._in_memory_session:
|
|
114
|
-
self._refresh_token_timer:
|
|
113
|
+
self._in_memory_session: Optional[Session] = None
|
|
114
|
+
self._refresh_token_timer: Optional[Timer] = None
|
|
115
115
|
self._network_retries = 0
|
|
116
116
|
self._state_change_emitters: Dict[str, Subscription] = {}
|
|
117
117
|
self._flow_type = flow_type
|
|
@@ -134,7 +134,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
134
134
|
|
|
135
135
|
# Initializations
|
|
136
136
|
|
|
137
|
-
def initialize(self, *, url:
|
|
137
|
+
def initialize(self, *, url: Optional[str] = None) -> None:
|
|
138
138
|
if url and self._is_implicit_grant_flow(url):
|
|
139
139
|
self.initialize_from_url(url)
|
|
140
140
|
else:
|
|
@@ -158,7 +158,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
158
158
|
# Public methods
|
|
159
159
|
|
|
160
160
|
def sign_in_anonymously(
|
|
161
|
-
self, credentials:
|
|
161
|
+
self, credentials: Optional[SignInAnonymouslyCredentials] = None
|
|
162
162
|
) -> AuthResponse:
|
|
163
163
|
"""
|
|
164
164
|
Creates a new anonymous user.
|
|
@@ -585,14 +585,14 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
585
585
|
xform=parse_auth_response,
|
|
586
586
|
)
|
|
587
587
|
|
|
588
|
-
def get_session(self) ->
|
|
588
|
+
def get_session(self) -> Optional[Session]:
|
|
589
589
|
"""
|
|
590
590
|
Returns the session, refreshing it if necessary.
|
|
591
591
|
|
|
592
592
|
The session returned can be null if the session is not detected which
|
|
593
593
|
can happen in the event a user is not signed-in or has logged out.
|
|
594
594
|
"""
|
|
595
|
-
current_session:
|
|
595
|
+
current_session: Optional[Session] = None
|
|
596
596
|
if self._persist_session:
|
|
597
597
|
maybe_session = self._storage.get_item(self._storage_key)
|
|
598
598
|
current_session = self._get_valid_session(maybe_session)
|
|
@@ -614,7 +614,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
614
614
|
else current_session
|
|
615
615
|
)
|
|
616
616
|
|
|
617
|
-
def get_user(self, jwt:
|
|
617
|
+
def get_user(self, jwt: Optional[str] = None) -> Optional[UserResponse]:
|
|
618
618
|
"""
|
|
619
619
|
Gets the current user details if there is an existing session.
|
|
620
620
|
|
|
@@ -666,7 +666,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
666
666
|
time_now = round(time())
|
|
667
667
|
expires_at = time_now
|
|
668
668
|
has_expired = True
|
|
669
|
-
session:
|
|
669
|
+
session: Optional[Session] = None
|
|
670
670
|
if access_token and access_token.split(".")[1]:
|
|
671
671
|
payload = self._decode_jwt(access_token)
|
|
672
672
|
exp = payload.get("exp")
|
|
@@ -694,7 +694,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
694
694
|
self._notify_all_subscribers("TOKEN_REFRESHED", session)
|
|
695
695
|
return AuthResponse(session=session, user=response.user)
|
|
696
696
|
|
|
697
|
-
def refresh_session(self, refresh_token:
|
|
697
|
+
def refresh_session(self, refresh_token: Optional[str] = None) -> AuthResponse:
|
|
698
698
|
"""
|
|
699
699
|
Returns a new session, regardless of expiry status.
|
|
700
700
|
|
|
@@ -735,7 +735,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
735
735
|
|
|
736
736
|
def on_auth_state_change(
|
|
737
737
|
self,
|
|
738
|
-
callback: Callable[[AuthChangeEvent,
|
|
738
|
+
callback: Callable[[AuthChangeEvent, Optional[Session]], None],
|
|
739
739
|
) -> Subscription:
|
|
740
740
|
"""
|
|
741
741
|
Receive a notification every time an auth event happens.
|
|
@@ -881,7 +881,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
881
881
|
current_authentication_methods=[],
|
|
882
882
|
)
|
|
883
883
|
payload = self._decode_jwt(session.access_token)
|
|
884
|
-
current_level:
|
|
884
|
+
current_level: Optional[AuthenticatorAssuranceLevels] = None
|
|
885
885
|
if payload.get("aal"):
|
|
886
886
|
current_level = payload.get("aal")
|
|
887
887
|
verified_factors = [
|
|
@@ -909,7 +909,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
909
909
|
def _get_session_from_url(
|
|
910
910
|
self,
|
|
911
911
|
url: str,
|
|
912
|
-
) -> Tuple[Session,
|
|
912
|
+
) -> Tuple[Session, Optional[str]]:
|
|
913
913
|
if not self._is_implicit_grant_flow(url):
|
|
914
914
|
raise AuthImplicitGrantRedirectError("Not a valid implicit grant flow url.")
|
|
915
915
|
result = urlparse(url)
|
|
@@ -1054,15 +1054,15 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
1054
1054
|
def _notify_all_subscribers(
|
|
1055
1055
|
self,
|
|
1056
1056
|
event: AuthChangeEvent,
|
|
1057
|
-
session:
|
|
1057
|
+
session: Optional[Session],
|
|
1058
1058
|
) -> None:
|
|
1059
1059
|
for subscription in self._state_change_emitters.values():
|
|
1060
1060
|
subscription.callback(event, session)
|
|
1061
1061
|
|
|
1062
1062
|
def _get_valid_session(
|
|
1063
1063
|
self,
|
|
1064
|
-
raw_session:
|
|
1065
|
-
) ->
|
|
1064
|
+
raw_session: Optional[str],
|
|
1065
|
+
) -> Optional[Session]:
|
|
1066
1066
|
if not raw_session:
|
|
1067
1067
|
return None
|
|
1068
1068
|
data = loads(raw_session)
|
|
@@ -1088,7 +1088,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
1088
1088
|
self,
|
|
1089
1089
|
query_params: Dict[str, List[str]],
|
|
1090
1090
|
name: str,
|
|
1091
|
-
) ->
|
|
1091
|
+
) -> Optional[str]:
|
|
1092
1092
|
return query_params[name][0] if name in query_params else None
|
|
1093
1093
|
|
|
1094
1094
|
def _is_implicit_grant_flow(self, url: str) -> bool:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import List, Literal,
|
|
3
|
+
from typing import List, Literal, Optional
|
|
4
4
|
|
|
5
5
|
from typing_extensions import TypedDict
|
|
6
6
|
|
|
@@ -153,14 +153,14 @@ class AuthImplicitGrantRedirectErrorDetails(TypedDict):
|
|
|
153
153
|
|
|
154
154
|
|
|
155
155
|
class AuthImplicitGrantRedirectErrorDict(AuthApiErrorDict):
|
|
156
|
-
details:
|
|
156
|
+
details: Optional[AuthImplicitGrantRedirectErrorDetails]
|
|
157
157
|
|
|
158
158
|
|
|
159
159
|
class AuthImplicitGrantRedirectError(CustomAuthError):
|
|
160
160
|
def __init__(
|
|
161
161
|
self,
|
|
162
162
|
message: str,
|
|
163
|
-
details:
|
|
163
|
+
details: Optional[AuthImplicitGrantRedirectErrorDetails] = None,
|
|
164
164
|
) -> None:
|
|
165
165
|
CustomAuthError.__init__(
|
|
166
166
|
self,
|
|
@@ -8,7 +8,7 @@ import string
|
|
|
8
8
|
from base64 import urlsafe_b64decode
|
|
9
9
|
from datetime import datetime
|
|
10
10
|
from json import loads
|
|
11
|
-
from typing import Any, Dict, Type, TypeVar,
|
|
11
|
+
from typing import Any, Dict, Optional, Type, TypeVar, cast
|
|
12
12
|
|
|
13
13
|
from httpx import HTTPStatusError, Response
|
|
14
14
|
from pydantic import BaseModel
|
|
@@ -68,7 +68,7 @@ def model_dump_json(model: BaseModel) -> str:
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
def parse_auth_response(data: Any) -> AuthResponse:
|
|
71
|
-
session:
|
|
71
|
+
session: Optional[Session] = None
|
|
72
72
|
if (
|
|
73
73
|
"access_token" in data
|
|
74
74
|
and "refresh_token" in data
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
from threading import Timer as _Timer
|
|
3
|
-
from typing import Any, Callable, Coroutine,
|
|
3
|
+
from typing import Any, Callable, Coroutine, Optional, cast
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class Timer:
|
|
7
7
|
def __init__(
|
|
8
8
|
self,
|
|
9
9
|
seconds: float,
|
|
10
|
-
function: Callable[[],
|
|
10
|
+
function: Callable[[], Optional[Coroutine[Any, Any, None]]],
|
|
11
11
|
) -> None:
|
|
12
12
|
self._milliseconds = seconds
|
|
13
13
|
self._function = function
|
|
14
|
-
self._task:
|
|
15
|
-
self._timer:
|
|
14
|
+
self._task: Optional[asyncio.Task] = None
|
|
15
|
+
self._timer: Optional[_Timer] = None
|
|
16
16
|
|
|
17
17
|
def start(self) -> None:
|
|
18
18
|
if asyncio.iscoroutinefunction(self._function):
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
from time import time
|
|
5
|
-
from typing import Any, Callable, Dict, List, Union
|
|
5
|
+
from typing import Any, Callable, Dict, List, Optional, Union
|
|
6
6
|
|
|
7
7
|
from pydantic import BaseModel, ConfigDict
|
|
8
8
|
|
|
@@ -93,14 +93,14 @@ class InviteUserByEmailOptions(TypedDict):
|
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
class AuthResponse(BaseModel):
|
|
96
|
-
user:
|
|
97
|
-
session:
|
|
96
|
+
user: Optional[User] = None
|
|
97
|
+
session: Optional[Session] = None
|
|
98
98
|
|
|
99
99
|
|
|
100
100
|
class AuthOtpResponse(BaseModel):
|
|
101
101
|
user: None = None
|
|
102
102
|
session: None = None
|
|
103
|
-
message_id:
|
|
103
|
+
message_id: Optional[str] = None
|
|
104
104
|
|
|
105
105
|
|
|
106
106
|
class OAuthResponse(BaseModel):
|
|
@@ -125,12 +125,12 @@ class UserResponse(BaseModel):
|
|
|
125
125
|
|
|
126
126
|
|
|
127
127
|
class Session(BaseModel):
|
|
128
|
-
provider_token:
|
|
128
|
+
provider_token: Optional[str] = None
|
|
129
129
|
"""
|
|
130
130
|
The oauth provider token. If present, this can be used to make external API
|
|
131
131
|
requests to the oauth provider used.
|
|
132
132
|
"""
|
|
133
|
-
provider_refresh_token:
|
|
133
|
+
provider_refresh_token: Optional[str] = None
|
|
134
134
|
"""
|
|
135
135
|
The oauth provider refresh token. If present, this can be used to refresh
|
|
136
136
|
the provider_token via the oauth provider's API.
|
|
@@ -146,7 +146,7 @@ class Session(BaseModel):
|
|
|
146
146
|
The number of seconds until the token expires (since it was issued).
|
|
147
147
|
Returned when a login is confirmed.
|
|
148
148
|
"""
|
|
149
|
-
expires_at:
|
|
149
|
+
expires_at: Optional[int] = None
|
|
150
150
|
"""
|
|
151
151
|
A timestamp of when the token will expire. Returned when a login is confirmed.
|
|
152
152
|
"""
|
|
@@ -168,8 +168,8 @@ class UserIdentity(BaseModel):
|
|
|
168
168
|
identity_data: Dict[str, Any]
|
|
169
169
|
provider: str
|
|
170
170
|
created_at: datetime
|
|
171
|
-
last_sign_in_at:
|
|
172
|
-
updated_at:
|
|
171
|
+
last_sign_in_at: Optional[datetime] = None
|
|
172
|
+
updated_at: Optional[datetime] = None
|
|
173
173
|
|
|
174
174
|
|
|
175
175
|
class Factor(BaseModel):
|
|
@@ -181,7 +181,7 @@ class Factor(BaseModel):
|
|
|
181
181
|
"""
|
|
182
182
|
ID of the factor.
|
|
183
183
|
"""
|
|
184
|
-
friendly_name:
|
|
184
|
+
friendly_name: Optional[str] = None
|
|
185
185
|
"""
|
|
186
186
|
Friendly name of the factor, useful to disambiguate between multiple factors.
|
|
187
187
|
"""
|
|
@@ -203,25 +203,25 @@ class User(BaseModel):
|
|
|
203
203
|
app_metadata: Dict[str, Any]
|
|
204
204
|
user_metadata: Dict[str, Any]
|
|
205
205
|
aud: str
|
|
206
|
-
confirmation_sent_at:
|
|
207
|
-
recovery_sent_at:
|
|
208
|
-
email_change_sent_at:
|
|
209
|
-
new_email:
|
|
210
|
-
new_phone:
|
|
211
|
-
invited_at:
|
|
212
|
-
action_link:
|
|
213
|
-
email:
|
|
214
|
-
phone:
|
|
206
|
+
confirmation_sent_at: Optional[datetime] = None
|
|
207
|
+
recovery_sent_at: Optional[datetime] = None
|
|
208
|
+
email_change_sent_at: Optional[datetime] = None
|
|
209
|
+
new_email: Optional[str] = None
|
|
210
|
+
new_phone: Optional[str] = None
|
|
211
|
+
invited_at: Optional[datetime] = None
|
|
212
|
+
action_link: Optional[str] = None
|
|
213
|
+
email: Optional[str] = None
|
|
214
|
+
phone: Optional[str] = None
|
|
215
215
|
created_at: datetime
|
|
216
|
-
confirmed_at:
|
|
217
|
-
email_confirmed_at:
|
|
218
|
-
phone_confirmed_at:
|
|
219
|
-
last_sign_in_at:
|
|
220
|
-
role:
|
|
221
|
-
updated_at:
|
|
222
|
-
identities:
|
|
216
|
+
confirmed_at: Optional[datetime] = None
|
|
217
|
+
email_confirmed_at: Optional[datetime] = None
|
|
218
|
+
phone_confirmed_at: Optional[datetime] = None
|
|
219
|
+
last_sign_in_at: Optional[datetime] = None
|
|
220
|
+
role: Optional[str] = None
|
|
221
|
+
updated_at: Optional[datetime] = None
|
|
222
|
+
identities: Optional[List[UserIdentity]] = None
|
|
223
223
|
is_anonymous: bool = False
|
|
224
|
-
factors:
|
|
224
|
+
factors: Optional[List[Factor]] = None
|
|
225
225
|
|
|
226
226
|
|
|
227
227
|
class UserAttributes(TypedDict):
|
|
@@ -266,7 +266,7 @@ class Subscription(BaseModel):
|
|
|
266
266
|
"""
|
|
267
267
|
The subscriber UUID. This will be set by the client.
|
|
268
268
|
"""
|
|
269
|
-
callback: Callable[[AuthChangeEvent,
|
|
269
|
+
callback: Callable[[AuthChangeEvent, Optional[Session]], None]
|
|
270
270
|
"""
|
|
271
271
|
The function to call every time there is an event.
|
|
272
272
|
"""
|
|
@@ -691,11 +691,11 @@ AuthenticatorAssuranceLevels = Literal["aal1", "aal2"]
|
|
|
691
691
|
|
|
692
692
|
|
|
693
693
|
class AuthMFAGetAuthenticatorAssuranceLevelResponse(BaseModel):
|
|
694
|
-
current_level:
|
|
694
|
+
current_level: Optional[AuthenticatorAssuranceLevels] = None
|
|
695
695
|
"""
|
|
696
696
|
Current AAL level of the session.
|
|
697
697
|
"""
|
|
698
|
-
next_level:
|
|
698
|
+
next_level: Optional[AuthenticatorAssuranceLevels] = None
|
|
699
699
|
"""
|
|
700
700
|
Next possible AAL level for the session. If the next level is higher
|
|
701
701
|
than the current one, the user should go through MFA.
|
|
@@ -778,8 +778,8 @@ class GenerateLinkResponse(BaseModel):
|
|
|
778
778
|
|
|
779
779
|
class DecodedJWTDict(TypedDict):
|
|
780
780
|
exp: NotRequired[int]
|
|
781
|
-
aal: NotRequired[
|
|
782
|
-
amr: NotRequired[
|
|
781
|
+
aal: NotRequired[Optional[AuthenticatorAssuranceLevels]]
|
|
782
|
+
amr: NotRequired[Optional[List[AMREntry]]]
|
|
783
783
|
|
|
784
784
|
|
|
785
785
|
SignOutScope = Literal["global", "local", "others"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.9.3" # {x-release-please-version}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.9.2" # {x-release-please-version}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|