Skip to content

feat(types,shared): JWT v2 - Support new organization claims structure #5549

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

Merged
merged 20 commits into from
Apr 9, 2025

Conversation

octoper
Copy link
Member

@octoper octoper commented Apr 7, 2025

Description

This PR adds support for the new JWT v2 schema and also renames ver claim to v.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Copy link

changeset-bot bot commented Apr 7, 2025

🦋 Changeset detected

Latest commit: c1cb785

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
@clerk/shared Minor
@clerk/types Minor
@clerk/clerk-js Patch
@clerk/backend Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/chrome-extension Patch
@clerk/elements Patch
@clerk/expo-passkeys Patch
@clerk/clerk-expo Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/vue Patch
@clerk/localizations Patch
@clerk/themes Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Apr 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 9, 2025 11:19am

createCheckAuthorization,
validateReverificationConfig,
resolveAuthState,
resolveSignedInAuthStateFromJWTClaims,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙃 maybe use a new module

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if there is a better module to put this, as much of this is tied and the new changes that will be added as part of JWT v2 schema are in a way tied to authorization 🤔

Copy link

@iagodahlem iagodahlem Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could move it to a new module with JWT related things? Although the claims are authorization related, the logic here is not doing any authorization, just mapping the JWT payload to a new format. 🤔

I was also wondering if we shouldn't name this mapping here from claims -> signed in properties to payload -> claims, so claims would always have the same format regardless of the JWTPayload version, and then auth objects or JWT clients can use the claims to build their properties:

const __experimental_resolveClaimsFromJWTPayload = (payload: JwtPayload): JwtClaims

What do you think?

Copy link
Member Author

@octoper octoper Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could move it to a new module with JWT related things? Although the claims are authorization related, the logic here is not doing any authorization, just mapping the JWT payload to a new format.

Hmm yeah that's fair 👍

I was also wondering if we shouldn't name this mapping here from claims -> signed in properties to payload -> claims, so claims would always have the same format regardless of the JWTPayload version

The thing here is that the JWT claims will not be in the same format and it will be different depending on version also, it's also gonna be kinda of confusing when __experimental_resolveClaimsFromJWTPayload returns something different than the actual claims found on the token, that's why I've gone with claims -> signed in properties.

@octoper
Copy link
Member Author

octoper commented Apr 9, 2025

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @octoper - the snapshot version command generated the following package versions:

Package Version
@clerk/agent-toolkit 0.0.20-snapshot.v20250409092045
@clerk/astro 2.6.2-snapshot.v20250409092045
@clerk/backend 1.27.2-snapshot.v20250409092045
@clerk/chrome-extension 2.2.27-snapshot.v20250409092045
@clerk/clerk-js 5.59.3-snapshot.v20250409092045
@clerk/elements 0.23.12-snapshot.v20250409092045
@clerk/clerk-expo 2.9.10-snapshot.v20250409092045
@clerk/expo-passkeys 0.2.4-snapshot.v20250409092045
@clerk/express 1.4.3-snapshot.v20250409092045
@clerk/fastify 2.2.3-snapshot.v20250409092045
@clerk/localizations 3.13.8-snapshot.v20250409092045
@clerk/nextjs 6.14.2-snapshot.v20250409092045
@clerk/nuxt 1.5.3-snapshot.v20250409092045
@clerk/clerk-react 5.26.2-snapshot.v20250409092045
@clerk/react-router 1.2.3-snapshot.v20250409092045
@clerk/remix 4.5.15-snapshot.v20250409092045
@clerk/shared 3.5.0-snapshot.v20250409092045
@clerk/tanstack-react-start 0.13.3-snapshot.v20250409092045
@clerk/testing 1.4.37-snapshot.v20250409092045
@clerk/themes 2.2.30-snapshot.v20250409092045
@clerk/types 4.52.0-snapshot.v20250409092045
@clerk/vue 1.5.2-snapshot.v20250409092045

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/agent-toolkit

npm i @clerk/[email protected] --save-exact

@clerk/astro

npm i @clerk/[email protected] --save-exact

@clerk/backend

npm i @clerk/[email protected] --save-exact

@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/elements

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@clerk/expo-passkeys

npm i @clerk/[email protected] --save-exact

@clerk/express

npm i @clerk/[email protected] --save-exact

@clerk/fastify

npm i @clerk/[email protected] --save-exact

@clerk/localizations

npm i @clerk/[email protected] --save-exact

@clerk/nextjs

npm i @clerk/[email protected] --save-exact

@clerk/nuxt

npm i @clerk/[email protected] --save-exact

@clerk/clerk-react

npm i @clerk/[email protected] --save-exact

@clerk/react-router

npm i @clerk/[email protected] --save-exact

@clerk/remix

npm i @clerk/[email protected] --save-exact

@clerk/shared

npm i @clerk/[email protected] --save-exact

@clerk/tanstack-react-start

npm i @clerk/[email protected] --save-exact

@clerk/testing

npm i @clerk/[email protected] --save-exact

@clerk/themes

npm i @clerk/[email protected] --save-exact

@clerk/types

npm i @clerk/[email protected] --save-exact

@clerk/vue

npm i @clerk/[email protected] --save-exact

@octoper
Copy link
Member Author

octoper commented Apr 9, 2025

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @octoper - the snapshot version command generated the following package versions:

Package Version
@clerk/agent-toolkit 0.0.20-snapshot.v20250409094437
@clerk/astro 2.6.2-snapshot.v20250409094437
@clerk/backend 1.27.2-snapshot.v20250409094437
@clerk/chrome-extension 2.2.27-snapshot.v20250409094437
@clerk/clerk-js 5.59.3-snapshot.v20250409094437
@clerk/elements 0.23.12-snapshot.v20250409094437
@clerk/clerk-expo 2.9.10-snapshot.v20250409094437
@clerk/expo-passkeys 0.2.4-snapshot.v20250409094437
@clerk/express 1.4.3-snapshot.v20250409094437
@clerk/fastify 2.2.3-snapshot.v20250409094437
@clerk/localizations 3.13.8-snapshot.v20250409094437
@clerk/nextjs 6.14.2-snapshot.v20250409094437
@clerk/nuxt 1.5.3-snapshot.v20250409094437
@clerk/clerk-react 5.26.2-snapshot.v20250409094437
@clerk/react-router 1.2.3-snapshot.v20250409094437
@clerk/remix 4.5.15-snapshot.v20250409094437
@clerk/shared 3.5.0-snapshot.v20250409094437
@clerk/tanstack-react-start 0.13.3-snapshot.v20250409094437
@clerk/testing 1.4.37-snapshot.v20250409094437
@clerk/themes 2.2.30-snapshot.v20250409094437
@clerk/types 4.52.0-snapshot.v20250409094437
@clerk/vue 1.5.2-snapshot.v20250409094437

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/agent-toolkit

npm i @clerk/[email protected] --save-exact

@clerk/astro

npm i @clerk/[email protected] --save-exact

@clerk/backend

npm i @clerk/[email protected] --save-exact

@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/elements

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@clerk/expo-passkeys

npm i @clerk/[email protected] --save-exact

@clerk/express

npm i @clerk/[email protected] --save-exact

@clerk/fastify

npm i @clerk/[email protected] --save-exact

@clerk/localizations

npm i @clerk/[email protected] --save-exact

@clerk/nextjs

npm i @clerk/[email protected] --save-exact

@clerk/nuxt

npm i @clerk/[email protected] --save-exact

@clerk/clerk-react

npm i @clerk/[email protected] --save-exact

@clerk/react-router

npm i @clerk/[email protected] --save-exact

@clerk/remix

npm i @clerk/[email protected] --save-exact

@clerk/shared

npm i @clerk/[email protected] --save-exact

@clerk/tanstack-react-start

npm i @clerk/[email protected] --save-exact

@clerk/testing

npm i @clerk/[email protected] --save-exact

@clerk/themes

npm i @clerk/[email protected] --save-exact

@clerk/types

npm i @clerk/[email protected] --save-exact

@clerk/vue

npm i @clerk/[email protected] --save-exact

@octoper octoper merged commit 3ad3bc8 into main Apr 9, 2025
30 checks passed
@octoper octoper deleted the vaggelis/migrate-to-new-org-claims branch April 9, 2025 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants