Skip to content

Commit 28392ee

Browse files
committed
feat: More of requested changes
1 parent dac30f0 commit 28392ee

File tree

25 files changed

+45
-54
lines changed

25 files changed

+45
-54
lines changed

supertokens_python/recipe/session/api/implementation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async def refresh_post(
4343
async def signout_post(
4444
self,
4545
api_options: APIOptions,
46-
session: SessionContainer,
46+
session: Optional[SessionContainer],
4747
user_context: Dict[str, Any],
4848
) -> SignOutOkayResponse:
4949
if session is not None:

supertokens_python/recipe/session/claim_base_classes/primitive_array_claim.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@
2323
SessionClaim,
2424
SessionClaimValidator,
2525
ClaimValidationResult,
26+
JSONPrimitiveList,
2627
)
2728

2829

2930
Primitive = TypeVar("Primitive", bound=JSONPrimitive)
30-
PrimitiveList = TypeVar("PrimitiveList", bound=List[JSONPrimitive])
31+
PrimitiveList = TypeVar("PrimitiveList", bound=JSONPrimitiveList)
3132

3233
_T = TypeVar("_T")
3334

@@ -218,7 +219,7 @@ def excludes_all(
218219
)
219220

220221

221-
class PrimitiveArrayClaim(SessionClaim[PrimitiveList]):
222+
class PrimitiveArrayClaim(SessionClaim[PrimitiveList], Generic[PrimitiveList]):
222223
def __init__(
223224
self,
224225
key: str,

supertokens_python/recipe/session/interfaces.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
)
2828

2929
from supertokens_python.async_to_sync_wrapper import sync
30-
from supertokens_python.types import APIResponse, GeneralErrorResponse, MaybeAwaitable
30+
from supertokens_python.types import APIResponse, MaybeAwaitable
3131
from .exceptions import ClaimValidationError
3232
from .utils import SessionConfig
3333
from ...utils import resolve
@@ -78,6 +78,9 @@ def __init__(
7878
JSONObject = Dict[str, Any]
7979

8080
JSONPrimitive = Union[str, int, bool, None, Dict[str, Any]]
81+
JSONPrimitiveList = Union[
82+
List[str], List[int], List[bool], List[None], List[Dict[str, Any]]
83+
]
8184

8285
FetchValueReturnType = Union[_T, None]
8386

@@ -324,7 +327,7 @@ async def signout_post(
324327
api_options: APIOptions,
325328
session: Optional[SessionContainer],
326329
user_context: Dict[str, Any],
327-
) -> Union[SignOutOkayResponse, GeneralErrorResponse]:
330+
) -> SignOutOkayResponse:
328331
pass
329332

330333
@abstractmethod

supertokens_python/recipe/session/with_jwt/recipe_implementation.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
# under the License.
1414
from __future__ import annotations
1515

16-
from typing import TYPE_CHECKING, Any, Dict, Union
16+
from typing import TYPE_CHECKING, Any, Dict, Union, Optional, List, Callable
1717

1818
# TODO: Missing changes for session_class inside with_jwt? supertokens/supertokens-node#278 (files)
1919

2020
from jwt import decode
2121

22+
from supertokens_python.types import MaybeAwaitable
2223
from supertokens_python.utils import get_timestamp_ms
2324

2425
from .constants import ACCESS_TOKEN_PAYLOAD_JWT_PROPERTY_NAME_KEY
@@ -31,6 +32,7 @@
3132
RecipeInterface,
3233
SessionContainer,
3334
SessionInformationResult,
35+
SessionClaimValidator,
3436
)
3537
from supertokens_python.framework.types import BaseRequest
3638

@@ -91,12 +93,19 @@ async def get_session(
9193
request: BaseRequest,
9294
anti_csrf_check: Union[bool, None],
9395
session_required: bool,
96+
override_global_claim_validators: Optional[
97+
Callable[
98+
[List[SessionClaimValidator], SessionContainer, Dict[str, Any]],
99+
MaybeAwaitable[List[SessionClaimValidator]],
100+
]
101+
],
94102
user_context: Dict[str, Any],
95103
) -> Union[SessionContainer, None]:
96104
session_container = await og_get_session(
97105
request,
98106
anti_csrf_check,
99107
session_required,
108+
override_global_claim_validators,
100109
user_context,
101110
)
102111
if session_container is None:

supertokens_python/recipe/thirdparty/api/implementation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ async def sign_in_up_post(
159159
return SignInUpPostNoEmailGivenByProviderResponse()
160160

161161
signinup_response = await api_options.recipe_implementation.sign_in_up(
162-
provider.id, user_info.user_id, email, email_verified, user_context
162+
provider.id, user_info.user_id, email, user_context
163163
)
164164

165165
if email_verified:

supertokens_python/recipe/thirdparty/asyncio/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ async def sign_in_up(
5757
third_party_id: str,
5858
third_party_user_id: str,
5959
email: str,
60-
email_verified: bool,
6160
user_context: Union[None, Dict[str, Any]] = None,
6261
):
6362
if user_context is None:
6463
user_context = {}
6564
return await ThirdPartyRecipe.get_instance().recipe_implementation.sign_in_up(
66-
third_party_id, third_party_user_id, email, email_verified, user_context
65+
third_party_id, third_party_user_id, email, user_context
6766
)

supertokens_python/recipe/thirdparty/interfaces.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ async def sign_in_up(
6565
third_party_id: str,
6666
third_party_user_id: str,
6767
email: str,
68-
email_verified: bool,
6968
user_context: Dict[str, Any],
7069
) -> SignInUpOkResult:
7170
pass

supertokens_python/recipe/thirdparty/recipe_implementation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,12 @@ async def sign_in_up(
101101
third_party_id: str,
102102
third_party_user_id: str,
103103
email: str,
104-
email_verified: bool,
105104
user_context: Dict[str, Any],
106105
) -> SignInUpOkResult:
107106
data = {
108107
"thirdPartyId": third_party_id,
109108
"thirdPartyUserId": third_party_user_id,
110-
"email": {"id": email, "isVerified": email_verified},
109+
"email": {"id": email},
111110
}
112111
response = await self.querier.send_post_request(
113112
NormalisedURLPath("/recipe/signinup"), data

supertokens_python/recipe/thirdparty/syncio/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,8 @@ def sign_in_up(
5252
third_party_id: str,
5353
third_party_user_id: str,
5454
email: str,
55-
email_verified: bool,
5655
user_context: Union[None, Dict[str, Any]] = None,
5756
):
5857
from supertokens_python.recipe.thirdparty.asyncio import sign_in_up
5958

60-
return sync(
61-
sign_in_up(
62-
third_party_id, third_party_user_id, email, email_verified, user_context
63-
)
64-
)
59+
return sync(sign_in_up(third_party_id, third_party_user_id, email, user_context))

supertokens_python/recipe/thirdpartyemailpassword/asyncio/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,12 @@ async def thirdparty_sign_in_up(
4747
third_party_id: str,
4848
third_party_user_id: str,
4949
email: str,
50-
email_verified: bool,
5150
user_context: Union[None, Dict[str, Any]] = None,
5251
):
5352
if user_context is None:
5453
user_context = {}
5554
return await ThirdPartyEmailPasswordRecipe.get_instance().recipe_implementation.thirdparty_sign_in_up(
56-
third_party_id, third_party_user_id, email, email_verified, user_context
55+
third_party_id, third_party_user_id, email, user_context
5756
)
5857

5958

supertokens_python/recipe/thirdpartyemailpassword/interfaces.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ async def thirdparty_sign_in_up(
9797
third_party_id: str,
9898
third_party_user_id: str,
9999
email: str,
100-
email_verified: bool,
101100
user_context: Dict[str, Any],
102101
) -> ThirdPartySignInUpOkResult:
103102
pass

supertokens_python/recipe/thirdpartyemailpassword/recipeimplementation/implementation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,12 @@ async def thirdparty_sign_in_up(
196196
third_party_id: str,
197197
third_party_user_id: str,
198198
email: str,
199-
email_verified: bool,
200199
user_context: Dict[str, Any],
201200
) -> ThirdPartySignInUpOkResult:
202201
if self.tp_sign_in_up is None:
203202
raise Exception("No thirdparty provider configured")
204203
result = await self.tp_sign_in_up(
205-
third_party_id, third_party_user_id, email, email_verified, user_context
204+
third_party_id, third_party_user_id, email, user_context
206205
)
207206
return ThirdPartySignInUpOkResult(
208207
User(

supertokens_python/recipe/thirdpartyemailpassword/recipeimplementation/third_party_recipe_implementation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,10 @@ async def sign_in_up(
8787
third_party_id: str,
8888
third_party_user_id: str,
8989
email: str,
90-
email_verified: bool,
9190
user_context: Dict[str, Any],
9291
) -> SignInUpOkResult:
9392
result = await self.recipe_implementation.thirdparty_sign_in_up(
94-
third_party_id, third_party_user_id, email, email_verified, user_context
93+
third_party_id, third_party_user_id, email, user_context
9594
)
9695

9796
if result.user.third_party_info is None:

supertokens_python/recipe/thirdpartyemailpassword/syncio/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,14 @@ def thirdparty_sign_in_up(
4949
third_party_id: str,
5050
third_party_user_id: str,
5151
email: str,
52-
email_verified: bool,
5352
user_context: Union[None, Dict[str, Any]] = None,
5453
):
5554
from supertokens_python.recipe.thirdpartyemailpassword.asyncio import (
5655
thirdparty_sign_in_up,
5756
)
5857

5958
return sync(
60-
thirdparty_sign_in_up(
61-
third_party_id, third_party_user_id, email, email_verified, user_context
62-
)
59+
thirdparty_sign_in_up(third_party_id, third_party_user_id, email, user_context)
6360
)
6461

6562

supertokens_python/recipe/thirdpartypasswordless/asyncio/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@ async def thirdparty_sign_in_up(
5050
third_party_id: str,
5151
third_party_user_id: str,
5252
email: str,
53-
email_verified: bool,
5453
user_context: Union[None, Dict[str, Any]] = None,
5554
):
5655
if user_context is None:
5756
user_context = {}
5857
return await ThirdPartyPasswordlessRecipe.get_instance().recipe_implementation.thirdparty_sign_in_up(
59-
third_party_id, third_party_user_id, email, email_verified, user_context
58+
third_party_id, third_party_user_id, email, user_context
6059
)
6160

6261

supertokens_python/recipe/thirdpartypasswordless/interfaces.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ async def thirdparty_sign_in_up(
106106
third_party_id: str,
107107
third_party_user_id: str,
108108
email: str,
109-
email_verified: bool,
110109
user_context: Dict[str, Any],
111110
) -> ThirdPartySignInUpOkResult:
112111
pass

supertokens_python/recipe/thirdpartypasswordless/recipeimplementation/implementation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,12 @@ async def thirdparty_sign_in_up(
242242
third_party_id: str,
243243
third_party_user_id: str,
244244
email: str,
245-
email_verified: bool,
246245
user_context: Dict[str, Any],
247246
) -> SignInUpOkResult:
248247
if self.tp_sign_in_up is None:
249248
raise Exception("No thirdparty provider configured")
250249
return await self.tp_sign_in_up(
251-
third_party_id, third_party_user_id, email, email_verified, user_context
250+
third_party_id, third_party_user_id, email, user_context
252251
)
253252

254253
async def get_user_by_phone_number(

supertokens_python/recipe/thirdpartypasswordless/recipeimplementation/third_party_recipe_implementation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ async def sign_in_up(
9595
third_party_id: str,
9696
third_party_user_id: str,
9797
email: str,
98-
email_verified: bool,
9998
user_context: Dict[str, Any],
10099
) -> SignInUpOkResult:
101100
return await self.recipe_implementation.thirdparty_sign_in_up(
102-
third_party_id, third_party_user_id, email, email_verified, user_context
101+
third_party_id, third_party_user_id, email, user_context
103102
)

supertokens_python/recipe/thirdpartypasswordless/syncio/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,12 @@ def thirdparty_sign_in_up(
4848
third_party_id: str,
4949
third_party_user_id: str,
5050
email: str,
51-
email_verified: bool,
5251
user_context: Union[None, Dict[str, Any]] = None,
5352
):
5453
from ..asyncio import thirdparty_sign_in_up
5554

5655
return sync(
57-
thirdparty_sign_in_up(
58-
third_party_id, third_party_user_id, email, email_verified, user_context
59-
)
56+
thirdparty_sign_in_up(third_party_id, third_party_user_id, email, user_context)
6057
)
6158

6259

tests/auth-react/django3x/mysite/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ def override_session_apis(original_implementation: SessionAPIInterface):
585585

586586
async def signout_post(
587587
api_options: SAPIOptions,
588-
session: SessionContainer,
588+
session: Optional[SessionContainer],
589589
user_context: Dict[str, Any],
590590
):
591591
is_general_error = await check_for_general_error(

tests/auth-react/fastapi-server/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ def override_session_apis(original_implementation: SessionAPIInterface):
637637

638638
async def signout_post(
639639
api_options: SAPIOptions,
640-
session: SessionContainer,
640+
session: Optional[SessionContainer],
641641
user_context: Dict[str, Any],
642642
):
643643
is_general_error = await check_for_general_error(

tests/auth-react/flask-server/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ def override_session_apis(original_implementation: SessionAPIInterface):
607607

608608
async def signout_post(
609609
api_options: SAPIOptions,
610-
session: SessionContainer,
610+
session: Optional[SessionContainer],
611611
user_context: Dict[str, Any],
612612
):
613613
is_general_error = await check_for_general_error(

tests/thirdparty/test_emaildelivery.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ async def test_email_verify_default_backward_compatibility(
142142
)
143143
start_st()
144144

145-
resp = await sign_in_up("supertokens", "test-user-id", "[email protected]", False)
145+
resp = await sign_in_up("supertokens", "test-user-id", "[email protected]")
146146

147147
s = SessionRecipe.get_instance()
148148
if not isinstance(s.recipe_implementation, SessionRecipeImplementation):
@@ -213,7 +213,7 @@ async def test_email_verify_default_backward_compatibility_supress_error(
213213
)
214214
start_st()
215215

216-
resp = await sign_in_up("supertokens", "test-user-id", "[email protected]", False)
216+
resp = await sign_in_up("supertokens", "test-user-id", "[email protected]")
217217

218218
s = SessionRecipe.get_instance()
219219
if not isinstance(s.recipe_implementation, SessionRecipeImplementation):
@@ -292,7 +292,7 @@ async def create_and_send_custom_email(
292292
)
293293
start_st()
294294

295-
resp = await sign_in_up("supertokens", "test-user-id", "[email protected]", False)
295+
resp = await sign_in_up("supertokens", "test-user-id", "[email protected]")
296296

297297
s = SessionRecipe.get_instance()
298298
if not isinstance(s.recipe_implementation, SessionRecipeImplementation):
@@ -367,7 +367,7 @@ async def send_email(
367367
)
368368
start_st()
369369

370-
resp = await sign_in_up("supertokens", "test-user-id", "[email protected]", False)
370+
resp = await sign_in_up("supertokens", "test-user-id", "[email protected]")
371371

372372
s = SessionRecipe.get_instance()
373373
if not isinstance(s.recipe_implementation, SessionRecipeImplementation):
@@ -504,7 +504,7 @@ async def send_email_override(
504504
)
505505
start_st()
506506

507-
resp = await sign_in_up("supertokens", "test-user-id", "[email protected]", False)
507+
resp = await sign_in_up("supertokens", "test-user-id", "[email protected]")
508508

509509
s = SessionRecipe.get_instance()
510510
if not isinstance(s.recipe_implementation, SessionRecipeImplementation):

tests/thirdpartyemailpassword/test_email_delivery.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ async def custom_create_and_send_custom_email(
892892
start_st()
893893

894894
resp = await thirdparty_sign_in_up(
895-
"supertokens", "test-user-id", "[email protected]", False
895+
"supertokens", "test-user-id", "[email protected]"
896896
)
897897
user_id: str = resp.user.user_id # type: ignore
898898

@@ -956,7 +956,7 @@ async def custom_create_and_send_custom_email(
956956
start_st()
957957

958958
resp = await thirdparty_sign_in_up(
959-
"supertokens", "test-user-id", "[email protected]", False
959+
"supertokens", "test-user-id", "[email protected]"
960960
)
961961
user_id: str = resp.user.user_id # type: ignore
962962

0 commit comments

Comments
 (0)