useSession().session.lastActiveToken.jwt.claims
has incorrect type
#4874
Labels
needs-triage
A ticket that needs to be triaged by a team member
Preliminary Checks
I have reviewed the documentation: https://clerk.com/docs
I have searched for existing issues: https://github.com/clerk/javascript/issues
I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.
Reproduction
N/A
Publishable key
N/A
Description
useSession
exposes the current token claims (including custom session claims) via:However, the type of this value does not reflect the custom claims defined by the user (ie
CustomJwtSessionClaims
).Proposed Solution
I believe that
useSession
should be using theJwtPayload
type instead of theJWTClaims
type, but it seems to be complicated by the fact that there are two sources of types for JWT stuff, namely the stuff injwt.ts
andjwtv2.ts
.I cannot understand why it is separated like this from the code alone (I suspect
jwtv2.ts
is intended for nodejs environments, andjwt.ts
for the everywhere else).That said, the headers and claims are necessarily the same in all environments, so I think it would make sense to refactor and simplify into:
With that, the
JWT
andJwt
types can refer to the same interfaces for the headers and claims without losing the ability to target different runtime environmentsEnvironment
The text was updated successfully, but these errors were encountered: