Skip to content

Commit ceb19b1

Browse files
committed
fix: Manually test the SDK and fix bugs
1 parent 515cad2 commit ceb19b1

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
],
100100
keywords="",
101101
install_requires=[
102-
"PyJWT>=2.0.0 ,<3.0.0",
102+
"PyJWT>=2.6.0 ,<3.0.0",
103103
"httpx>=0.15.0 ,<0.24.0",
104104
"pycryptodome==3.10.*",
105105
"tldextract==3.1.0",

supertokens_python/recipe/session/access_token.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def get_info_from_access_token(
8282
)
8383
payload = jwt.decode( # type: ignore
8484
jwt_info.raw_token_string,
85-
matching_key,
85+
matching_key.key, # type: ignore
8686
algorithms=["RS256"],
8787
options={"verify_signature": True, "verify_exp": True},
8888
)

supertokens_python/recipe/session/jwks.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def get_latest_keys(self) -> List[PyJWK]:
7070

7171
return all_keys
7272

73-
def get_matching_key_from_jwt(self, token: str) -> str:
73+
def get_matching_key_from_jwt(self, token: str) -> PyJWK:
7474
header = decode_token(token, options={"verify_signature": False})["header"]
7575
kid: str = header["kid"] # type: ignore
7676

@@ -80,15 +80,15 @@ def get_matching_key_from_jwt(self, token: str) -> str:
8080
assert self.jwk_set is not None
8181

8282
try:
83-
return self.jwk_set[kid].key # type: ignore
84-
except KeyError:
83+
return self.jwk_set[kid] # type: ignore
84+
except IndexError:
8585
if not self.is_cooling_down():
8686
# One more attempt to fetch the latest keys
8787
# and then try to find the key again.
8888
self.reload()
8989
try:
90-
return str(self.jwk_set[kid].key) # type: ignore
91-
except KeyError:
90+
return self.jwk_set[kid] # type: ignore
91+
except IndexError:
9292
pass
9393

9494
raise JWKSKeyNotFoundError("No key found for the given kid")

supertokens_python/recipe/session/recipe_implementation.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ def __init__(self, querier: Querier, config: SessionConfig, app_info: AppInfo):
5959
self.config = config
6060
self.app_info = app_info
6161

62-
@property
63-
def JWK_clients(self) -> List[JWKClient]:
64-
return [
62+
self.JWK_clients = [
6563
JWKClient(
6664
uri,
6765
cooldown_duration=JWKRequestCooldownInMs,
@@ -238,6 +236,7 @@ async def get_session(
238236
self,
239237
self.config,
240238
access_token_str,
239+
# FIXME: expiry time cannot be None
241240
build_front_token(response.session.userId, expiry_time, payload),
242241
None, # refresh_token
243242
anti_csrf_token,

supertokens_python/recipe/session/session_functions.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ def __init__(
6161

6262
class GetSessionAPIResponseSession:
6363
def __init__(
64-
self, handle: str, userId: str, userDataInJWT: Dict[str, Any], expiryTime: int
64+
self,
65+
handle: str,
66+
userId: str,
67+
userDataInJWT: Dict[str, Any],
68+
expiryTime: Optional[int] = None,
6569
) -> None:
6670
self.handle = handle
6771
self.userId = userId
@@ -175,8 +179,8 @@ async def get_session(
175179

176180
payload = parsed_access_token.payload
177181

178-
time_created = payload["timeCreated"]
179-
expiry_time = payload["expiryTime"]
182+
time_created = payload.get("timeCreated")
183+
expiry_time = payload.get("expiryTime")
180184

181185
if not isinstance(time_created, int) or not isinstance(expiry_time, int):
182186
raise e
@@ -276,8 +280,7 @@ async def get_session(
276280
GetSessionAPIResponseSession(
277281
response["session"]["handle"],
278282
response["session"]["userId"],
279-
response["session"]["userData"],
280-
response["session"]["expiresAt"],
283+
response["session"]["userDataInJWT"],
281284
),
282285
GetSessionAPIResponseAccessToken(
283286
response["accessToken"]["token"],

0 commit comments

Comments
 (0)