Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useSession().session.lastActiveToken.jwt.claims has incorrect type #4874

Open
4 tasks done
ijxy opened this issue Jan 10, 2025 · 0 comments
Open
4 tasks done

useSession().session.lastActiveToken.jwt.claims has incorrect type #4874

ijxy opened this issue Jan 10, 2025 · 0 comments
Labels
needs-triage A ticket that needs to be triaged by a team member

Comments

@ijxy
Copy link
Contributor

ijxy commented Jan 10, 2025

Preliminary Checks

Reproduction

N/A

Publishable key

N/A

Description

useSession exposes the current token claims (including custom session claims) via:

const claims = useSession().session.lastActiveToken.jwt.claims;

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 the JwtPayload type instead of the JWTClaims type, but it seems to be complicated by the fact that there are two sources of types for JWT stuff, namely the stuff in jwt.ts and jwtv2.ts.

I cannot understand why it is separated like this from the code alone (I suspect jwtv2.ts is intended for nodejs environments, and jwt.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:

  • a common interface for spec-standard headers
  • a common interface for just spec-standard claims
  • a common interface for just Clerk-standard claims
  • a common interface that combines spec + clerk + user defined claims

With that, the JWT and Jwt types can refer to the same interfaces for the headers and claims without losing the ability to target different runtime environments

Environment

N/A
@ijxy ijxy added the needs-triage A ticket that needs to be triaged by a team member label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage A ticket that needs to be triaged by a team member
Projects
None yet
Development

No branches or pull requests

1 participant