supabase_auth 2.6.1__tar.gz → 2.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/LICENSE +1 -1
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/PKG-INFO +4 -4
- supabase_auth-2.8.0/pyproject.toml +40 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/__init__.py +1 -2
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_async/gotrue_admin_api.py +2 -2
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_async/gotrue_base_api.py +3 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_async/gotrue_client.py +75 -8
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_sync/gotrue_admin_api.py +2 -2
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_sync/gotrue_base_api.py +3 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_sync/gotrue_client.py +75 -8
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/constants.py +10 -1
- supabase_auth-2.8.0/supabase_auth/errors.py +211 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/helpers.py +79 -4
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/types.py +77 -4
- supabase_auth-2.8.0/supabase_auth/version.py +1 -0
- supabase_auth-2.6.1/pyproject.toml +0 -50
- supabase_auth-2.6.1/supabase_auth/errors.py +0 -115
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/README.md +0 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_async/__init__.py +0 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_async/gotrue_admin_mfa_api.py +0 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_async/gotrue_mfa_api.py +0 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_async/storage.py +0 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_sync/__init__.py +0 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_sync/api.py +0 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_sync/client.py +0 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_sync/gotrue_admin_mfa_api.py +0 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_sync/gotrue_mfa_api.py +0 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/_sync/storage.py +0 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/http_clients.py +0 -0
- {supabase_auth-2.6.1 → supabase_auth-2.8.0}/supabase_auth/timer.py +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: supabase_auth
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.8.0
|
|
4
4
|
Summary: Python Client Library for Supabase Auth
|
|
5
|
-
Home-page: https://github.com/supabase
|
|
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
|
|
@@ -17,8 +17,8 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
18
|
Requires-Dist: httpx[http2] (>=0.24,<0.28)
|
|
19
19
|
Requires-Dist: pydantic (>=1.10,<3)
|
|
20
|
-
Project-URL: Documentation, https://github.com/supabase
|
|
21
|
-
Project-URL: Repository, https://github.com/supabase
|
|
20
|
+
Project-URL: Documentation, https://github.com/supabase/auth-py
|
|
21
|
+
Project-URL: Repository, https://github.com/supabase/auth-py
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
|
|
24
24
|
# Auth-py
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "supabase_auth"
|
|
3
|
+
version = "2.8.0" # {x-release-please-version}
|
|
4
|
+
description = "Python Client Library for Supabase Auth"
|
|
5
|
+
authors = ["Joel Lee <joel@joellee.org>"]
|
|
6
|
+
homepage = "https://github.com/supabase/auth-py"
|
|
7
|
+
repository = "https://github.com/supabase/auth-py"
|
|
8
|
+
documentation = "https://github.com/supabase/auth-py"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Programming Language :: Python :: 3",
|
|
13
|
+
"License :: OSI Approved :: MIT License",
|
|
14
|
+
"Operating System :: OS Independent"
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[tool.poetry.dependencies]
|
|
18
|
+
python = "^3.8"
|
|
19
|
+
httpx = {version = ">=0.24,<0.28", extras = ["http2"]}
|
|
20
|
+
pydantic = ">=1.10,<3"
|
|
21
|
+
|
|
22
|
+
[tool.poetry.dev-dependencies]
|
|
23
|
+
pytest = "^8.3.2"
|
|
24
|
+
flake8 = "^5.0.4"
|
|
25
|
+
black = "^24.4.2"
|
|
26
|
+
isort = "^5.12.0"
|
|
27
|
+
pre-commit = "^3.4.0"
|
|
28
|
+
pytest-cov = "^5.0.0"
|
|
29
|
+
pytest-depends = "^1.0.1"
|
|
30
|
+
pytest-asyncio = "^0.24.0"
|
|
31
|
+
Faker = "^28.1.0"
|
|
32
|
+
unasync-cli = "^0.0.9"
|
|
33
|
+
|
|
34
|
+
[tool.poetry.group.dev.dependencies]
|
|
35
|
+
pygithub = ">=1.57,<3.0"
|
|
36
|
+
respx = ">=0.20.2,<0.22.0"
|
|
37
|
+
|
|
38
|
+
[build-system]
|
|
39
|
+
requires = ["poetry-core>=1.0.0"]
|
|
40
|
+
build-backend = "poetry.core.masonry.api"
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
__version__ = "2.6.1"
|
|
4
|
-
|
|
5
3
|
from ._async.gotrue_admin_api import AsyncGoTrueAdminAPI # type: ignore # noqa: F401
|
|
6
4
|
from ._async.gotrue_client import AsyncGoTrueClient # type: ignore # noqa: F401
|
|
7
5
|
from ._async.storage import AsyncMemoryStorage # type: ignore # noqa: F401
|
|
@@ -11,3 +9,4 @@ from ._sync.gotrue_client import SyncGoTrueClient # type: ignore # noqa: F401
|
|
|
11
9
|
from ._sync.storage import SyncMemoryStorage # type: ignore # noqa: F401
|
|
12
10
|
from ._sync.storage import SyncSupportedStorage # type: ignore # noqa: F401
|
|
13
11
|
from .types import * # type: ignore # noqa: F401, F403
|
|
12
|
+
from .version import __version__
|
|
@@ -13,7 +13,7 @@ from ..types import (
|
|
|
13
13
|
AuthMFAAdminListFactorsResponse,
|
|
14
14
|
GenerateLinkParams,
|
|
15
15
|
GenerateLinkResponse,
|
|
16
|
-
|
|
16
|
+
InviteUserByEmailOptions,
|
|
17
17
|
SignOutScope,
|
|
18
18
|
User,
|
|
19
19
|
UserResponse,
|
|
@@ -57,7 +57,7 @@ class AsyncGoTrueAdminAPI(AsyncGoTrueBaseAPI):
|
|
|
57
57
|
async def invite_user_by_email(
|
|
58
58
|
self,
|
|
59
59
|
email: str,
|
|
60
|
-
options:
|
|
60
|
+
options: InviteUserByEmailOptions = {},
|
|
61
61
|
) -> UserResponse:
|
|
62
62
|
"""
|
|
63
63
|
Sends an invite link to an email address.
|
|
@@ -6,6 +6,7 @@ from httpx import 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, API_VERSIONS
|
|
9
10
|
from ..helpers import handle_exception, model_dump
|
|
10
11
|
from ..http_clients import AsyncClient
|
|
11
12
|
|
|
@@ -97,6 +98,8 @@ class AsyncGoTrueBaseAPI:
|
|
|
97
98
|
) -> Union[T, None]:
|
|
98
99
|
url = f"{self._url}/{path}"
|
|
99
100
|
headers = {**self._headers, **(headers or {})}
|
|
101
|
+
if API_VERSION_HEADER_NAME not in headers:
|
|
102
|
+
headers[API_VERSION_HEADER_NAME] = API_VERSIONS["2024-01-01"].get("name")
|
|
100
103
|
if "Content-Type" not in headers:
|
|
101
104
|
headers["Content-Type"] = "application/json;charset=UTF-8"
|
|
102
105
|
if jwt:
|
|
@@ -61,6 +61,7 @@ from ..types import (
|
|
|
61
61
|
OAuthResponse,
|
|
62
62
|
Options,
|
|
63
63
|
Provider,
|
|
64
|
+
ResendCredentials,
|
|
64
65
|
Session,
|
|
65
66
|
SignInAnonymouslyCredentials,
|
|
66
67
|
SignInWithIdTokenCredentials,
|
|
@@ -519,6 +520,41 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
519
520
|
"You must provide either an email or phone number"
|
|
520
521
|
)
|
|
521
522
|
|
|
523
|
+
async def resend(
|
|
524
|
+
self,
|
|
525
|
+
credentials: ResendCredentials,
|
|
526
|
+
) -> AuthOtpResponse:
|
|
527
|
+
"""
|
|
528
|
+
Resends an existing signup confirmation email, email change email, SMS OTP or phone change OTP.
|
|
529
|
+
"""
|
|
530
|
+
email = credentials.get("email")
|
|
531
|
+
phone = credentials.get("phone")
|
|
532
|
+
type = credentials.get("type")
|
|
533
|
+
options = credentials.get("options", {})
|
|
534
|
+
email_redirect_to = options.get("email_redirect_to")
|
|
535
|
+
captcha_token = options.get("captcha_token")
|
|
536
|
+
body = {
|
|
537
|
+
"type": type,
|
|
538
|
+
"gotrue_meta_security": {
|
|
539
|
+
"captcha_token": captcha_token,
|
|
540
|
+
},
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
if email is None and phone is None:
|
|
544
|
+
raise AuthInvalidCredentialsError(
|
|
545
|
+
"You must provide either an email or phone number"
|
|
546
|
+
)
|
|
547
|
+
|
|
548
|
+
body.update({"email": email} if email else {"phone": phone})
|
|
549
|
+
|
|
550
|
+
return await self._request(
|
|
551
|
+
"POST",
|
|
552
|
+
"resend",
|
|
553
|
+
body=body,
|
|
554
|
+
redirect_to=email_redirect_to if email else None,
|
|
555
|
+
xform=parse_auth_otp_response,
|
|
556
|
+
)
|
|
557
|
+
|
|
522
558
|
async def verify_otp(self, params: VerifyOtpParams) -> AuthResponse:
|
|
523
559
|
"""
|
|
524
560
|
Log in a user given a User supplied OTP received via mobile.
|
|
@@ -541,6 +577,18 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
541
577
|
self._notify_all_subscribers("SIGNED_IN", response.session)
|
|
542
578
|
return response
|
|
543
579
|
|
|
580
|
+
async def reauthenticate(self) -> AuthResponse:
|
|
581
|
+
session = await self.get_session()
|
|
582
|
+
if not session:
|
|
583
|
+
raise AuthSessionMissingError()
|
|
584
|
+
|
|
585
|
+
return await self._request(
|
|
586
|
+
"GET",
|
|
587
|
+
"reauthenticate",
|
|
588
|
+
jwt=session.access_token,
|
|
589
|
+
xform=parse_auth_response,
|
|
590
|
+
)
|
|
591
|
+
|
|
544
592
|
async def get_session(self) -> Union[Session, None]:
|
|
545
593
|
"""
|
|
546
594
|
Returns the session, refreshing it if necessary.
|
|
@@ -711,11 +759,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
711
759
|
self._state_change_emitters[unique_id] = subscription
|
|
712
760
|
return subscription
|
|
713
761
|
|
|
714
|
-
async def
|
|
715
|
-
self,
|
|
716
|
-
email: str,
|
|
717
|
-
options: Options = {},
|
|
718
|
-
) -> None:
|
|
762
|
+
async def reset_password_for_email(self, email: str, options: Options = {}) -> None:
|
|
719
763
|
"""
|
|
720
764
|
Sends a password reset request to an email address.
|
|
721
765
|
"""
|
|
@@ -731,20 +775,41 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
731
775
|
redirect_to=options.get("redirect_to"),
|
|
732
776
|
)
|
|
733
777
|
|
|
778
|
+
async def reset_password_email(
|
|
779
|
+
self,
|
|
780
|
+
email: str,
|
|
781
|
+
options: Options = {},
|
|
782
|
+
) -> None:
|
|
783
|
+
"""
|
|
784
|
+
Sends a password reset request to an email address.
|
|
785
|
+
"""
|
|
786
|
+
await self.reset_password_for_email(email, options)
|
|
787
|
+
|
|
734
788
|
# MFA methods
|
|
735
789
|
|
|
736
790
|
async def _enroll(self, params: MFAEnrollParams) -> AuthMFAEnrollResponse:
|
|
737
791
|
session = await self.get_session()
|
|
738
792
|
if not session:
|
|
739
793
|
raise AuthSessionMissingError()
|
|
794
|
+
|
|
795
|
+
body = {
|
|
796
|
+
"friendly_name": params["friendly_name"],
|
|
797
|
+
"factor_type": params["factor_type"],
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
if params["factor_type"] == "phone":
|
|
801
|
+
body["phone"] = params["phone"]
|
|
802
|
+
else:
|
|
803
|
+
body["issuer"] = params["issuer"]
|
|
804
|
+
|
|
740
805
|
response = await self._request(
|
|
741
806
|
"POST",
|
|
742
807
|
"factors",
|
|
743
|
-
body=
|
|
808
|
+
body=body,
|
|
744
809
|
jwt=session.access_token,
|
|
745
810
|
xform=partial(model_validate, AuthMFAEnrollResponse),
|
|
746
811
|
)
|
|
747
|
-
if response.totp.qr_code:
|
|
812
|
+
if params["factor_type"] == "totp" and response.totp.qr_code:
|
|
748
813
|
response.totp.qr_code = f"data:image/svg+xml;utf-8,{response.totp.qr_code}"
|
|
749
814
|
return response
|
|
750
815
|
|
|
@@ -755,6 +820,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
755
820
|
return await self._request(
|
|
756
821
|
"POST",
|
|
757
822
|
f"factors/{params.get('factor_id')}/challenge",
|
|
823
|
+
body={"channel": params["channel"]},
|
|
758
824
|
jwt=session.access_token,
|
|
759
825
|
xform=partial(model_validate, AuthMFAChallengeResponse),
|
|
760
826
|
)
|
|
@@ -807,7 +873,8 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
|
|
|
807
873
|
response = await self.get_user()
|
|
808
874
|
all = response.user.factors or []
|
|
809
875
|
totp = [f for f in all if f.factor_type == "totp" and f.status == "verified"]
|
|
810
|
-
|
|
876
|
+
phone = [f for f in all if f.factor_type == "phone" and f.status == "verified"]
|
|
877
|
+
return AuthMFAListFactorsResponse(all=all, totp=totp, phone=phone)
|
|
811
878
|
|
|
812
879
|
async def _get_authenticator_assurance_level(
|
|
813
880
|
self,
|
|
@@ -13,7 +13,7 @@ from ..types import (
|
|
|
13
13
|
AuthMFAAdminListFactorsResponse,
|
|
14
14
|
GenerateLinkParams,
|
|
15
15
|
GenerateLinkResponse,
|
|
16
|
-
|
|
16
|
+
InviteUserByEmailOptions,
|
|
17
17
|
SignOutScope,
|
|
18
18
|
User,
|
|
19
19
|
UserResponse,
|
|
@@ -57,7 +57,7 @@ class SyncGoTrueAdminAPI(SyncGoTrueBaseAPI):
|
|
|
57
57
|
def invite_user_by_email(
|
|
58
58
|
self,
|
|
59
59
|
email: str,
|
|
60
|
-
options:
|
|
60
|
+
options: InviteUserByEmailOptions = {},
|
|
61
61
|
) -> UserResponse:
|
|
62
62
|
"""
|
|
63
63
|
Sends an invite link to an email address.
|
|
@@ -6,6 +6,7 @@ from httpx import 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, API_VERSIONS
|
|
9
10
|
from ..helpers import handle_exception, model_dump
|
|
10
11
|
from ..http_clients import SyncClient
|
|
11
12
|
|
|
@@ -97,6 +98,8 @@ class SyncGoTrueBaseAPI:
|
|
|
97
98
|
) -> Union[T, None]:
|
|
98
99
|
url = f"{self._url}/{path}"
|
|
99
100
|
headers = {**self._headers, **(headers or {})}
|
|
101
|
+
if API_VERSION_HEADER_NAME not in headers:
|
|
102
|
+
headers[API_VERSION_HEADER_NAME] = API_VERSIONS["2024-01-01"].get("name")
|
|
100
103
|
if "Content-Type" not in headers:
|
|
101
104
|
headers["Content-Type"] = "application/json;charset=UTF-8"
|
|
102
105
|
if jwt:
|
|
@@ -61,6 +61,7 @@ from ..types import (
|
|
|
61
61
|
OAuthResponse,
|
|
62
62
|
Options,
|
|
63
63
|
Provider,
|
|
64
|
+
ResendCredentials,
|
|
64
65
|
Session,
|
|
65
66
|
SignInAnonymouslyCredentials,
|
|
66
67
|
SignInWithIdTokenCredentials,
|
|
@@ -513,6 +514,41 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
513
514
|
"You must provide either an email or phone number"
|
|
514
515
|
)
|
|
515
516
|
|
|
517
|
+
def resend(
|
|
518
|
+
self,
|
|
519
|
+
credentials: ResendCredentials,
|
|
520
|
+
) -> AuthOtpResponse:
|
|
521
|
+
"""
|
|
522
|
+
Resends an existing signup confirmation email, email change email, SMS OTP or phone change OTP.
|
|
523
|
+
"""
|
|
524
|
+
email = credentials.get("email")
|
|
525
|
+
phone = credentials.get("phone")
|
|
526
|
+
type = credentials.get("type")
|
|
527
|
+
options = credentials.get("options", {})
|
|
528
|
+
email_redirect_to = options.get("email_redirect_to")
|
|
529
|
+
captcha_token = options.get("captcha_token")
|
|
530
|
+
body = {
|
|
531
|
+
"type": type,
|
|
532
|
+
"gotrue_meta_security": {
|
|
533
|
+
"captcha_token": captcha_token,
|
|
534
|
+
},
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
if email is None and phone is None:
|
|
538
|
+
raise AuthInvalidCredentialsError(
|
|
539
|
+
"You must provide either an email or phone number"
|
|
540
|
+
)
|
|
541
|
+
|
|
542
|
+
body.update({"email": email} if email else {"phone": phone})
|
|
543
|
+
|
|
544
|
+
return self._request(
|
|
545
|
+
"POST",
|
|
546
|
+
"resend",
|
|
547
|
+
body=body,
|
|
548
|
+
redirect_to=email_redirect_to if email else None,
|
|
549
|
+
xform=parse_auth_otp_response,
|
|
550
|
+
)
|
|
551
|
+
|
|
516
552
|
def verify_otp(self, params: VerifyOtpParams) -> AuthResponse:
|
|
517
553
|
"""
|
|
518
554
|
Log in a user given a User supplied OTP received via mobile.
|
|
@@ -535,6 +571,18 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
535
571
|
self._notify_all_subscribers("SIGNED_IN", response.session)
|
|
536
572
|
return response
|
|
537
573
|
|
|
574
|
+
def reauthenticate(self) -> AuthResponse:
|
|
575
|
+
session = self.get_session()
|
|
576
|
+
if not session:
|
|
577
|
+
raise AuthSessionMissingError()
|
|
578
|
+
|
|
579
|
+
return self._request(
|
|
580
|
+
"GET",
|
|
581
|
+
"reauthenticate",
|
|
582
|
+
jwt=session.access_token,
|
|
583
|
+
xform=parse_auth_response,
|
|
584
|
+
)
|
|
585
|
+
|
|
538
586
|
def get_session(self) -> Union[Session, None]:
|
|
539
587
|
"""
|
|
540
588
|
Returns the session, refreshing it if necessary.
|
|
@@ -703,11 +751,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
703
751
|
self._state_change_emitters[unique_id] = subscription
|
|
704
752
|
return subscription
|
|
705
753
|
|
|
706
|
-
def
|
|
707
|
-
self,
|
|
708
|
-
email: str,
|
|
709
|
-
options: Options = {},
|
|
710
|
-
) -> None:
|
|
754
|
+
def reset_password_for_email(self, email: str, options: Options = {}) -> None:
|
|
711
755
|
"""
|
|
712
756
|
Sends a password reset request to an email address.
|
|
713
757
|
"""
|
|
@@ -723,20 +767,41 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
723
767
|
redirect_to=options.get("redirect_to"),
|
|
724
768
|
)
|
|
725
769
|
|
|
770
|
+
def reset_password_email(
|
|
771
|
+
self,
|
|
772
|
+
email: str,
|
|
773
|
+
options: Options = {},
|
|
774
|
+
) -> None:
|
|
775
|
+
"""
|
|
776
|
+
Sends a password reset request to an email address.
|
|
777
|
+
"""
|
|
778
|
+
self.reset_password_for_email(email, options)
|
|
779
|
+
|
|
726
780
|
# MFA methods
|
|
727
781
|
|
|
728
782
|
def _enroll(self, params: MFAEnrollParams) -> AuthMFAEnrollResponse:
|
|
729
783
|
session = self.get_session()
|
|
730
784
|
if not session:
|
|
731
785
|
raise AuthSessionMissingError()
|
|
786
|
+
|
|
787
|
+
body = {
|
|
788
|
+
"friendly_name": params["friendly_name"],
|
|
789
|
+
"factor_type": params["factor_type"],
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
if params["factor_type"] == "phone":
|
|
793
|
+
body["phone"] = params["phone"]
|
|
794
|
+
else:
|
|
795
|
+
body["issuer"] = params["issuer"]
|
|
796
|
+
|
|
732
797
|
response = self._request(
|
|
733
798
|
"POST",
|
|
734
799
|
"factors",
|
|
735
|
-
body=
|
|
800
|
+
body=body,
|
|
736
801
|
jwt=session.access_token,
|
|
737
802
|
xform=partial(model_validate, AuthMFAEnrollResponse),
|
|
738
803
|
)
|
|
739
|
-
if response.totp.qr_code:
|
|
804
|
+
if params["factor_type"] == "totp" and response.totp.qr_code:
|
|
740
805
|
response.totp.qr_code = f"data:image/svg+xml;utf-8,{response.totp.qr_code}"
|
|
741
806
|
return response
|
|
742
807
|
|
|
@@ -747,6 +812,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
747
812
|
return self._request(
|
|
748
813
|
"POST",
|
|
749
814
|
f"factors/{params.get('factor_id')}/challenge",
|
|
815
|
+
body={"channel": params["channel"]},
|
|
750
816
|
jwt=session.access_token,
|
|
751
817
|
xform=partial(model_validate, AuthMFAChallengeResponse),
|
|
752
818
|
)
|
|
@@ -799,7 +865,8 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
|
|
|
799
865
|
response = self.get_user()
|
|
800
866
|
all = response.user.factors or []
|
|
801
867
|
totp = [f for f in all if f.factor_type == "totp" and f.status == "verified"]
|
|
802
|
-
|
|
868
|
+
phone = [f for f in all if f.factor_type == "phone" and f.status == "verified"]
|
|
869
|
+
return AuthMFAListFactorsResponse(all=all, totp=totp, phone=phone)
|
|
803
870
|
|
|
804
871
|
def _get_authenticator_assurance_level(
|
|
805
872
|
self,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from datetime import datetime
|
|
3
4
|
from typing import Dict
|
|
4
5
|
|
|
5
|
-
from . import __version__
|
|
6
|
+
from .version import __version__
|
|
6
7
|
|
|
7
8
|
GOTRUE_URL = "http://localhost:9999"
|
|
8
9
|
DEFAULT_HEADERS: Dict[str, str] = {
|
|
@@ -12,3 +13,11 @@ EXPIRY_MARGIN = 10 # seconds
|
|
|
12
13
|
MAX_RETRIES = 10
|
|
13
14
|
RETRY_INTERVAL = 2 # deciseconds
|
|
14
15
|
STORAGE_KEY = "supabase.auth.token"
|
|
16
|
+
|
|
17
|
+
API_VERSION_HEADER_NAME = "X-Supabase-Api-Version"
|
|
18
|
+
API_VERSIONS = {
|
|
19
|
+
"2024-01-01": {
|
|
20
|
+
"timestamp": datetime.timestamp(datetime.strptime("2024-01-01", "%Y-%m-%d")),
|
|
21
|
+
"name": "2024-01-01",
|
|
22
|
+
},
|
|
23
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import List, Literal, Union
|
|
4
|
+
|
|
5
|
+
from typing_extensions import TypedDict
|
|
6
|
+
|
|
7
|
+
ErrorCode = Literal[
|
|
8
|
+
"unexpected_failure",
|
|
9
|
+
"validation_failed",
|
|
10
|
+
"bad_json",
|
|
11
|
+
"email_exists",
|
|
12
|
+
"phone_exists",
|
|
13
|
+
"bad_jwt",
|
|
14
|
+
"not_admin",
|
|
15
|
+
"no_authorization",
|
|
16
|
+
"user_not_found",
|
|
17
|
+
"session_not_found",
|
|
18
|
+
"flow_state_not_found",
|
|
19
|
+
"flow_state_expired",
|
|
20
|
+
"signup_disabled",
|
|
21
|
+
"user_banned",
|
|
22
|
+
"provider_email_needs_verification",
|
|
23
|
+
"invite_not_found",
|
|
24
|
+
"bad_oauth_state",
|
|
25
|
+
"bad_oauth_callback",
|
|
26
|
+
"oauth_provider_not_supported",
|
|
27
|
+
"unexpected_audience",
|
|
28
|
+
"single_identity_not_deletable",
|
|
29
|
+
"email_conflict_identity_not_deletable",
|
|
30
|
+
"identity_already_exists",
|
|
31
|
+
"email_provider_disabled",
|
|
32
|
+
"phone_provider_disabled",
|
|
33
|
+
"too_many_enrolled_mfa_factors",
|
|
34
|
+
"mfa_factor_name_conflict",
|
|
35
|
+
"mfa_factor_not_found",
|
|
36
|
+
"mfa_ip_address_mismatch",
|
|
37
|
+
"mfa_challenge_expired",
|
|
38
|
+
"mfa_verification_failed",
|
|
39
|
+
"mfa_verification_rejected",
|
|
40
|
+
"insufficient_aal",
|
|
41
|
+
"captcha_failed",
|
|
42
|
+
"saml_provider_disabled",
|
|
43
|
+
"manual_linking_disabled",
|
|
44
|
+
"sms_send_failed",
|
|
45
|
+
"email_not_confirmed",
|
|
46
|
+
"phone_not_confirmed",
|
|
47
|
+
"reauth_nonce_missing",
|
|
48
|
+
"saml_relay_state_not_found",
|
|
49
|
+
"saml_relay_state_expired",
|
|
50
|
+
"saml_idp_not_found",
|
|
51
|
+
"saml_assertion_no_user_id",
|
|
52
|
+
"saml_assertion_no_email",
|
|
53
|
+
"user_already_exists",
|
|
54
|
+
"sso_provider_not_found",
|
|
55
|
+
"saml_metadata_fetch_failed",
|
|
56
|
+
"saml_idp_already_exists",
|
|
57
|
+
"sso_domain_already_exists",
|
|
58
|
+
"saml_entity_id_mismatch",
|
|
59
|
+
"conflict",
|
|
60
|
+
"provider_disabled",
|
|
61
|
+
"user_sso_managed",
|
|
62
|
+
"reauthentication_needed",
|
|
63
|
+
"same_password",
|
|
64
|
+
"reauthentication_not_valid",
|
|
65
|
+
"otp_expired",
|
|
66
|
+
"otp_disabled",
|
|
67
|
+
"identity_not_found",
|
|
68
|
+
"weak_password",
|
|
69
|
+
"over_request_rate_limit",
|
|
70
|
+
"over_email_send_rate_limit",
|
|
71
|
+
"over_sms_send_rate_limit",
|
|
72
|
+
"bad_code_verifier",
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class AuthError(Exception):
|
|
77
|
+
def __init__(self, message: str, code: ErrorCode) -> None:
|
|
78
|
+
Exception.__init__(self, message)
|
|
79
|
+
self.message = message
|
|
80
|
+
self.name = "AuthError"
|
|
81
|
+
self.code = code
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class AuthApiErrorDict(TypedDict):
|
|
85
|
+
name: str
|
|
86
|
+
message: str
|
|
87
|
+
status: int
|
|
88
|
+
code: ErrorCode
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class AuthApiError(AuthError):
|
|
92
|
+
def __init__(self, message: str, status: int, code: ErrorCode) -> None:
|
|
93
|
+
AuthError.__init__(self, message, code)
|
|
94
|
+
self.name = "AuthApiError"
|
|
95
|
+
self.status = status
|
|
96
|
+
self.code = code
|
|
97
|
+
|
|
98
|
+
def to_dict(self) -> AuthApiErrorDict:
|
|
99
|
+
return {
|
|
100
|
+
"name": self.name,
|
|
101
|
+
"message": self.message,
|
|
102
|
+
"status": self.status,
|
|
103
|
+
"code": self.code,
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class AuthUnknownError(AuthError):
|
|
108
|
+
def __init__(self, message: str, original_error: Exception) -> None:
|
|
109
|
+
AuthError.__init__(self, message, None)
|
|
110
|
+
self.name = "AuthUnknownError"
|
|
111
|
+
self.original_error = original_error
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class CustomAuthError(AuthError):
|
|
115
|
+
def __init__(self, message: str, name: str, status: int, code: ErrorCode) -> None:
|
|
116
|
+
AuthError.__init__(self, message, code)
|
|
117
|
+
self.name = name
|
|
118
|
+
self.status = status
|
|
119
|
+
|
|
120
|
+
def to_dict(self) -> AuthApiErrorDict:
|
|
121
|
+
return {
|
|
122
|
+
"name": self.name,
|
|
123
|
+
"message": self.message,
|
|
124
|
+
"status": self.status,
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class AuthSessionMissingError(CustomAuthError):
|
|
129
|
+
def __init__(self) -> None:
|
|
130
|
+
CustomAuthError.__init__(
|
|
131
|
+
self,
|
|
132
|
+
"Auth session missing!",
|
|
133
|
+
"AuthSessionMissingError",
|
|
134
|
+
400,
|
|
135
|
+
None,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class AuthInvalidCredentialsError(CustomAuthError):
|
|
140
|
+
def __init__(self, message: str) -> None:
|
|
141
|
+
CustomAuthError.__init__(
|
|
142
|
+
self,
|
|
143
|
+
message,
|
|
144
|
+
"AuthInvalidCredentialsError",
|
|
145
|
+
400,
|
|
146
|
+
None,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
class AuthImplicitGrantRedirectErrorDetails(TypedDict):
|
|
151
|
+
error: str
|
|
152
|
+
code: str
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class AuthImplicitGrantRedirectErrorDict(AuthApiErrorDict):
|
|
156
|
+
details: Union[AuthImplicitGrantRedirectErrorDetails, None]
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class AuthImplicitGrantRedirectError(CustomAuthError):
|
|
160
|
+
def __init__(
|
|
161
|
+
self,
|
|
162
|
+
message: str,
|
|
163
|
+
details: Union[AuthImplicitGrantRedirectErrorDetails, None] = None,
|
|
164
|
+
) -> None:
|
|
165
|
+
CustomAuthError.__init__(
|
|
166
|
+
self,
|
|
167
|
+
message,
|
|
168
|
+
"AuthImplicitGrantRedirectError",
|
|
169
|
+
500,
|
|
170
|
+
None,
|
|
171
|
+
)
|
|
172
|
+
self.details = details
|
|
173
|
+
|
|
174
|
+
def to_dict(self) -> AuthImplicitGrantRedirectErrorDict:
|
|
175
|
+
return {
|
|
176
|
+
"name": self.name,
|
|
177
|
+
"message": self.message,
|
|
178
|
+
"status": self.status,
|
|
179
|
+
"details": self.details,
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
class AuthRetryableError(CustomAuthError):
|
|
184
|
+
def __init__(self, message: str, status: int) -> None:
|
|
185
|
+
CustomAuthError.__init__(
|
|
186
|
+
self,
|
|
187
|
+
message,
|
|
188
|
+
"AuthRetryableError",
|
|
189
|
+
status,
|
|
190
|
+
None,
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class AuthWeakPasswordError(CustomAuthError):
|
|
195
|
+
def __init__(self, message: str, status: int, reasons: List[str]) -> None:
|
|
196
|
+
CustomAuthError.__init__(
|
|
197
|
+
self,
|
|
198
|
+
message,
|
|
199
|
+
"AuthWeakPasswordError",
|
|
200
|
+
status,
|
|
201
|
+
"weak_password",
|
|
202
|
+
)
|
|
203
|
+
self.reasons = reasons
|
|
204
|
+
|
|
205
|
+
def to_dict(self) -> AuthApiErrorDict:
|
|
206
|
+
return {
|
|
207
|
+
"name": self.name,
|
|
208
|
+
"message": self.message,
|
|
209
|
+
"status": self.status,
|
|
210
|
+
"reasons": self.reasons,
|
|
211
|
+
}
|
|
@@ -2,16 +2,25 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import base64
|
|
4
4
|
import hashlib
|
|
5
|
+
import re
|
|
5
6
|
import secrets
|
|
6
7
|
import string
|
|
7
8
|
from base64 import urlsafe_b64decode
|
|
9
|
+
from datetime import datetime
|
|
8
10
|
from json import loads
|
|
9
11
|
from typing import Any, Dict, Type, TypeVar, Union, cast
|
|
10
12
|
|
|
11
|
-
from httpx import HTTPStatusError
|
|
13
|
+
from httpx import HTTPStatusError, Response
|
|
12
14
|
from pydantic import BaseModel
|
|
13
15
|
|
|
14
|
-
from .
|
|
16
|
+
from .constants import API_VERSION_HEADER_NAME, API_VERSIONS
|
|
17
|
+
from .errors import (
|
|
18
|
+
AuthApiError,
|
|
19
|
+
AuthError,
|
|
20
|
+
AuthRetryableError,
|
|
21
|
+
AuthUnknownError,
|
|
22
|
+
AuthWeakPasswordError,
|
|
23
|
+
)
|
|
15
24
|
from .types import (
|
|
16
25
|
AuthOtpResponse,
|
|
17
26
|
AuthResponse,
|
|
@@ -114,6 +123,10 @@ def get_error_message(error: Any) -> str:
|
|
|
114
123
|
return next((error[prop] for prop in props if filter(prop)), str(error))
|
|
115
124
|
|
|
116
125
|
|
|
126
|
+
def get_error_code(error: Any) -> str:
|
|
127
|
+
return error.get("error_code", None) if isinstance(error, dict) else None
|
|
128
|
+
|
|
129
|
+
|
|
117
130
|
def looks_like_http_status_error(exception: Exception) -> bool:
|
|
118
131
|
return isinstance(exception, HTTPStatusError)
|
|
119
132
|
|
|
@@ -128,8 +141,51 @@ def handle_exception(exception: Exception) -> AuthError:
|
|
|
128
141
|
return AuthRetryableError(
|
|
129
142
|
get_error_message(error), error.response.status_code
|
|
130
143
|
)
|
|
131
|
-
|
|
132
|
-
|
|
144
|
+
data = error.response.json()
|
|
145
|
+
|
|
146
|
+
error_code = None
|
|
147
|
+
response_api_version = parse_response_api_version(error.response)
|
|
148
|
+
|
|
149
|
+
if (
|
|
150
|
+
response_api_version
|
|
151
|
+
and datetime.timestamp(response_api_version)
|
|
152
|
+
>= API_VERSIONS.get("2024-01-01").get("timestamp")
|
|
153
|
+
and isinstance(data, dict)
|
|
154
|
+
and data
|
|
155
|
+
and isinstance(data.get("code"), str)
|
|
156
|
+
):
|
|
157
|
+
error_code = data.get("code")
|
|
158
|
+
elif (
|
|
159
|
+
isinstance(data, dict) and data and isinstance(data.get("error_code"), str)
|
|
160
|
+
):
|
|
161
|
+
error_code = data.get("error_code")
|
|
162
|
+
|
|
163
|
+
if error_code is None:
|
|
164
|
+
if (
|
|
165
|
+
isinstance(data, dict)
|
|
166
|
+
and data
|
|
167
|
+
and isinstance(data.get("weak_password"), dict)
|
|
168
|
+
and data.get("weak_password")
|
|
169
|
+
and isinstance(data.get("weak_password"), list)
|
|
170
|
+
and len(data.get("weak_password"))
|
|
171
|
+
):
|
|
172
|
+
return AuthWeakPasswordError(
|
|
173
|
+
get_error_message(data),
|
|
174
|
+
error.response.status_code,
|
|
175
|
+
data.get("weak_password").get("reasons"),
|
|
176
|
+
)
|
|
177
|
+
elif error_code == "weak_password":
|
|
178
|
+
return AuthWeakPasswordError(
|
|
179
|
+
get_error_message(data),
|
|
180
|
+
error.response.status_code,
|
|
181
|
+
data.get("weak_password", {}).get("reasons", {}),
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
return AuthApiError(
|
|
185
|
+
get_error_message(data),
|
|
186
|
+
error.response.status_code or 500,
|
|
187
|
+
error_code,
|
|
188
|
+
)
|
|
133
189
|
except Exception as e:
|
|
134
190
|
return AuthUnknownError(get_error_message(error), e)
|
|
135
191
|
|
|
@@ -163,3 +219,22 @@ def generate_pkce_challenge(code_verifier):
|
|
|
163
219
|
sha256_hash = hashlib.sha256(verifier_bytes).digest()
|
|
164
220
|
|
|
165
221
|
return base64.urlsafe_b64encode(sha256_hash).rstrip(b"=").decode("utf-8")
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
API_VERSION_REGEX = r"^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$"
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def parse_response_api_version(response: Response):
|
|
228
|
+
api_version = response.headers.get(API_VERSION_HEADER_NAME)
|
|
229
|
+
|
|
230
|
+
if not api_version:
|
|
231
|
+
return None
|
|
232
|
+
|
|
233
|
+
if re.search(API_VERSION_REGEX, api_version) is None:
|
|
234
|
+
return None
|
|
235
|
+
|
|
236
|
+
try:
|
|
237
|
+
dt = datetime.strptime(api_version, "%Y-%m-%d")
|
|
238
|
+
return dt
|
|
239
|
+
except Exception as e:
|
|
240
|
+
return None
|
|
@@ -4,7 +4,7 @@ from datetime import datetime
|
|
|
4
4
|
from time import time
|
|
5
5
|
from typing import Any, Callable, Dict, List, Union
|
|
6
6
|
|
|
7
|
-
from pydantic import BaseModel
|
|
7
|
+
from pydantic import BaseModel, ConfigDict
|
|
8
8
|
|
|
9
9
|
try:
|
|
10
10
|
# > 2
|
|
@@ -26,14 +26,17 @@ Provider = Literal[
|
|
|
26
26
|
"discord",
|
|
27
27
|
"facebook",
|
|
28
28
|
"figma",
|
|
29
|
+
"fly",
|
|
29
30
|
"github",
|
|
30
31
|
"gitlab",
|
|
31
32
|
"google",
|
|
32
33
|
"kakao",
|
|
33
34
|
"keycloak",
|
|
34
35
|
"linkedin",
|
|
36
|
+
"linkedin_oidc",
|
|
35
37
|
"notion",
|
|
36
38
|
"slack",
|
|
39
|
+
"slack_oidc",
|
|
37
40
|
"spotify",
|
|
38
41
|
"twitch",
|
|
39
42
|
"twitter",
|
|
@@ -80,6 +83,11 @@ class AMREntry(BaseModel):
|
|
|
80
83
|
|
|
81
84
|
|
|
82
85
|
class Options(TypedDict):
|
|
86
|
+
redirect_to: NotRequired[str]
|
|
87
|
+
captcha_token: NotRequired[str]
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class InviteUserByEmailOptions(TypedDict):
|
|
83
91
|
redirect_to: NotRequired[str]
|
|
84
92
|
data: NotRequired[Any]
|
|
85
93
|
|
|
@@ -177,7 +185,7 @@ class Factor(BaseModel):
|
|
|
177
185
|
"""
|
|
178
186
|
Friendly name of the factor, useful to disambiguate between multiple factors.
|
|
179
187
|
"""
|
|
180
|
-
factor_type: Union[Literal["totp"], str]
|
|
188
|
+
factor_type: Union[Literal["totp", "phone"], str]
|
|
181
189
|
"""
|
|
182
190
|
Type of factor. Only `totp` supported with this version but may change in
|
|
183
191
|
future versions.
|
|
@@ -229,6 +237,28 @@ class AdminUserAttributes(UserAttributes, TypedDict):
|
|
|
229
237
|
email_confirm: NotRequired[bool]
|
|
230
238
|
phone_confirm: NotRequired[bool]
|
|
231
239
|
ban_duration: NotRequired[Union[str, Literal["none"]]]
|
|
240
|
+
role: NotRequired[str]
|
|
241
|
+
"""
|
|
242
|
+
The `role` claim set in the user's access token JWT.
|
|
243
|
+
|
|
244
|
+
When a user signs up, this role is set to `authenticated` by default. You should only modify the `role` if you need to provision several levels of admin access that have different permissions on individual columns in your database.
|
|
245
|
+
|
|
246
|
+
Setting this role to `service_role` is not recommended as it grants the user admin privileges.
|
|
247
|
+
"""
|
|
248
|
+
password_hash: NotRequired[str]
|
|
249
|
+
"""
|
|
250
|
+
The `password_hash` for the user's password.
|
|
251
|
+
|
|
252
|
+
Allows you to specify a password hash for the user. This is useful for migrating a user's password hash from another service.
|
|
253
|
+
|
|
254
|
+
Supports bcrypt and argon2 password hashes.
|
|
255
|
+
"""
|
|
256
|
+
id: NotRequired[str]
|
|
257
|
+
"""
|
|
258
|
+
The `id` for the user.
|
|
259
|
+
|
|
260
|
+
Allows you to overwrite the default `id` set for the user.
|
|
261
|
+
"""
|
|
232
262
|
|
|
233
263
|
|
|
234
264
|
class Subscription(BaseModel):
|
|
@@ -351,6 +381,30 @@ SignInWithPasswordlessCredentials = Union[
|
|
|
351
381
|
]
|
|
352
382
|
|
|
353
383
|
|
|
384
|
+
class ResendEmailCredentialsOptions(TypedDict):
|
|
385
|
+
email_redirect_to: NotRequired[str]
|
|
386
|
+
captcha_token: NotRequired[str]
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
class ResendEmailCredentials(TypedDict):
|
|
390
|
+
type: Literal["signup", "email_change"]
|
|
391
|
+
email: str
|
|
392
|
+
options: NotRequired[ResendEmailCredentialsOptions]
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
class ResendPhoneCredentialsOptions(TypedDict):
|
|
396
|
+
captcha_token: NotRequired[str]
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
class ResendPhoneCredentials(TypedDict):
|
|
400
|
+
type: Literal["sms", "phone_change"]
|
|
401
|
+
phone: str
|
|
402
|
+
options: NotRequired[ResendPhoneCredentialsOptions]
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
ResendCredentials = Union[ResendEmailCredentials, ResendPhoneCredentials]
|
|
406
|
+
|
|
407
|
+
|
|
354
408
|
class SignInWithOAuthCredentialsOptions(TypedDict):
|
|
355
409
|
redirect_to: NotRequired[str]
|
|
356
410
|
scopes: NotRequired[str]
|
|
@@ -467,9 +521,10 @@ GenerateLinkType = Literal[
|
|
|
467
521
|
|
|
468
522
|
|
|
469
523
|
class MFAEnrollParams(TypedDict):
|
|
470
|
-
factor_type: Literal["totp"]
|
|
524
|
+
factor_type: Literal["totp", "phone"]
|
|
471
525
|
issuer: NotRequired[str]
|
|
472
526
|
friendly_name: NotRequired[str]
|
|
527
|
+
phone: str
|
|
473
528
|
|
|
474
529
|
|
|
475
530
|
class MFAUnenrollParams(TypedDict):
|
|
@@ -514,6 +569,7 @@ class MFAChallengeParams(TypedDict):
|
|
|
514
569
|
"""
|
|
515
570
|
ID of the factor to be challenged.
|
|
516
571
|
"""
|
|
572
|
+
channel: NotRequired[Literal["sms", "whatsapp"]]
|
|
517
573
|
|
|
518
574
|
|
|
519
575
|
class MFAChallengeAndVerifyParams(TypedDict):
|
|
@@ -575,7 +631,7 @@ class AuthMFAEnrollResponse(BaseModel):
|
|
|
575
631
|
"""
|
|
576
632
|
ID of the factor that was just enrolled (in an unverified state).
|
|
577
633
|
"""
|
|
578
|
-
type: Literal["totp"]
|
|
634
|
+
type: Literal["totp", "phone"]
|
|
579
635
|
"""
|
|
580
636
|
Type of MFA factor. Only `totp` supported for now.
|
|
581
637
|
"""
|
|
@@ -583,6 +639,15 @@ class AuthMFAEnrollResponse(BaseModel):
|
|
|
583
639
|
"""
|
|
584
640
|
TOTP enrollment information.
|
|
585
641
|
"""
|
|
642
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
643
|
+
friendly_name: str
|
|
644
|
+
"""
|
|
645
|
+
Friendly name of the factor, useful for distinguishing between factors
|
|
646
|
+
"""
|
|
647
|
+
phone: str
|
|
648
|
+
"""
|
|
649
|
+
Phone number of the MFA factor in E.164 format. Used to send messages
|
|
650
|
+
"""
|
|
586
651
|
|
|
587
652
|
|
|
588
653
|
class AuthMFAUnenrollResponse(BaseModel):
|
|
@@ -601,6 +666,10 @@ class AuthMFAChallengeResponse(BaseModel):
|
|
|
601
666
|
"""
|
|
602
667
|
Timestamp in UNIX seconds when this challenge will no longer be usable.
|
|
603
668
|
"""
|
|
669
|
+
factor_type: Literal["totp", "phone"]
|
|
670
|
+
"""
|
|
671
|
+
Factor Type which generated the challenge
|
|
672
|
+
"""
|
|
604
673
|
|
|
605
674
|
|
|
606
675
|
class AuthMFAListFactorsResponse(BaseModel):
|
|
@@ -612,6 +681,10 @@ class AuthMFAListFactorsResponse(BaseModel):
|
|
|
612
681
|
"""
|
|
613
682
|
Only verified TOTP factors. (A subset of `all`.)
|
|
614
683
|
"""
|
|
684
|
+
phone: List[Factor]
|
|
685
|
+
"""
|
|
686
|
+
Only verified Phone factors. (A subset of `all`.)
|
|
687
|
+
"""
|
|
615
688
|
|
|
616
689
|
|
|
617
690
|
AuthenticatorAssuranceLevels = Literal["aal1", "aal2"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.8.0" # {x-release-please-version}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
[tool.poetry]
|
|
2
|
-
name = "supabase_auth"
|
|
3
|
-
version = "2.6.1"
|
|
4
|
-
description = "Python Client Library for Supabase Auth"
|
|
5
|
-
authors = ["Joel Lee <joel@joellee.org>"]
|
|
6
|
-
homepage = "https://github.com/supabase-community/auth-py"
|
|
7
|
-
repository = "https://github.com/supabase-community/auth-py"
|
|
8
|
-
documentation = "https://github.com/supabase-community/auth-py"
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
license = "MIT"
|
|
11
|
-
classifiers = [
|
|
12
|
-
"Programming Language :: Python :: 3",
|
|
13
|
-
"License :: OSI Approved :: MIT License",
|
|
14
|
-
"Operating System :: OS Independent"
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
[tool.poetry.dependencies]
|
|
18
|
-
python = "^3.8"
|
|
19
|
-
httpx = {version = ">=0.24,<0.28", extras = ["http2"]}
|
|
20
|
-
pydantic = ">=1.10,<3"
|
|
21
|
-
|
|
22
|
-
[tool.poetry.dev-dependencies]
|
|
23
|
-
pytest = "^8.3.1"
|
|
24
|
-
flake8 = "^5.0.4"
|
|
25
|
-
black = "^24.4.2"
|
|
26
|
-
isort = "^5.12.0"
|
|
27
|
-
pre-commit = "^3.4.0"
|
|
28
|
-
pytest-cov = "^5.0.0"
|
|
29
|
-
pytest-depends = "^1.0.1"
|
|
30
|
-
pytest-asyncio = "^0.23.8"
|
|
31
|
-
Faker = "^26.0.0"
|
|
32
|
-
unasync-cli = "^0.0.9"
|
|
33
|
-
python-semantic-release = "^9.8.6"
|
|
34
|
-
|
|
35
|
-
[tool.poetry.group.dev.dependencies]
|
|
36
|
-
pygithub = ">=1.57,<3.0"
|
|
37
|
-
|
|
38
|
-
[tool.semantic_release]
|
|
39
|
-
version_variables = ["supabase_auth/__init__.py:__version__"]
|
|
40
|
-
version_toml = ["pyproject.toml:tool.poetry.version"]
|
|
41
|
-
major_on_zero = false
|
|
42
|
-
commit_message = "chore(release): bump version to v{version}"
|
|
43
|
-
build_command = "curl -sSL https://install.python-poetry.org | python - && export PATH=\"/github/home/.local/bin:$PATH\" && poetry install && poetry build"
|
|
44
|
-
upload_to_vcs_release = true
|
|
45
|
-
branch = "main"
|
|
46
|
-
changelog_components = "semantic_release.changelog.changelog_headers,semantic_release.changelog.compare_url"
|
|
47
|
-
|
|
48
|
-
[build-system]
|
|
49
|
-
requires = ["poetry-core>=1.0.0"]
|
|
50
|
-
build-backend = "poetry.core.masonry.api"
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import Union
|
|
4
|
-
|
|
5
|
-
from typing_extensions import TypedDict
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class AuthError(Exception):
|
|
9
|
-
def __init__(self, message: str) -> None:
|
|
10
|
-
Exception.__init__(self, message)
|
|
11
|
-
self.message = message
|
|
12
|
-
self.name = "AuthError"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class AuthApiErrorDict(TypedDict):
|
|
16
|
-
name: str
|
|
17
|
-
message: str
|
|
18
|
-
status: int
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class AuthApiError(AuthError):
|
|
22
|
-
def __init__(self, message: str, status: int) -> None:
|
|
23
|
-
AuthError.__init__(self, message)
|
|
24
|
-
self.name = "AuthApiError"
|
|
25
|
-
self.status = status
|
|
26
|
-
|
|
27
|
-
def to_dict(self) -> AuthApiErrorDict:
|
|
28
|
-
return {
|
|
29
|
-
"name": self.name,
|
|
30
|
-
"message": self.message,
|
|
31
|
-
"status": self.status,
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class AuthUnknownError(AuthError):
|
|
36
|
-
def __init__(self, message: str, original_error: Exception) -> None:
|
|
37
|
-
AuthError.__init__(self, message)
|
|
38
|
-
self.name = "AuthUnknownError"
|
|
39
|
-
self.original_error = original_error
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
class CustomAuthError(AuthError):
|
|
43
|
-
def __init__(self, message: str, name: str, status: int) -> None:
|
|
44
|
-
AuthError.__init__(self, message)
|
|
45
|
-
self.name = name
|
|
46
|
-
self.status = status
|
|
47
|
-
|
|
48
|
-
def to_dict(self) -> AuthApiErrorDict:
|
|
49
|
-
return {
|
|
50
|
-
"name": self.name,
|
|
51
|
-
"message": self.message,
|
|
52
|
-
"status": self.status,
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
class AuthSessionMissingError(CustomAuthError):
|
|
57
|
-
def __init__(self) -> None:
|
|
58
|
-
CustomAuthError.__init__(
|
|
59
|
-
self,
|
|
60
|
-
"Auth session missing!",
|
|
61
|
-
"AuthSessionMissingError",
|
|
62
|
-
400,
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
class AuthInvalidCredentialsError(CustomAuthError):
|
|
67
|
-
def __init__(self, message: str) -> None:
|
|
68
|
-
CustomAuthError.__init__(
|
|
69
|
-
self,
|
|
70
|
-
message,
|
|
71
|
-
"AuthInvalidCredentialsError",
|
|
72
|
-
400,
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
class AuthImplicitGrantRedirectErrorDetails(TypedDict):
|
|
77
|
-
error: str
|
|
78
|
-
code: str
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
class AuthImplicitGrantRedirectErrorDict(AuthApiErrorDict):
|
|
82
|
-
details: Union[AuthImplicitGrantRedirectErrorDetails, None]
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
class AuthImplicitGrantRedirectError(CustomAuthError):
|
|
86
|
-
def __init__(
|
|
87
|
-
self,
|
|
88
|
-
message: str,
|
|
89
|
-
details: Union[AuthImplicitGrantRedirectErrorDetails, None] = None,
|
|
90
|
-
) -> None:
|
|
91
|
-
CustomAuthError.__init__(
|
|
92
|
-
self,
|
|
93
|
-
message,
|
|
94
|
-
"AuthImplicitGrantRedirectError",
|
|
95
|
-
500,
|
|
96
|
-
)
|
|
97
|
-
self.details = details
|
|
98
|
-
|
|
99
|
-
def to_dict(self) -> AuthImplicitGrantRedirectErrorDict:
|
|
100
|
-
return {
|
|
101
|
-
"name": self.name,
|
|
102
|
-
"message": self.message,
|
|
103
|
-
"status": self.status,
|
|
104
|
-
"details": self.details,
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
class AuthRetryableError(CustomAuthError):
|
|
109
|
-
def __init__(self, message: str, status: int) -> None:
|
|
110
|
-
CustomAuthError.__init__(
|
|
111
|
-
self,
|
|
112
|
-
message,
|
|
113
|
-
"AuthRetryableError",
|
|
114
|
-
status,
|
|
115
|
-
)
|
|
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
|