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

feat(backend,nextjs): Machine-to-Machine #4875

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jakobevangelista
Copy link
Member

@jakobevangelista jakobevangelista commented Jan 11, 2025

Description

Adds machine to machine. Dx guide here

The spicy changes are in /backend/src/tokens/request.ts and /nextjs/src/server/clerkMiddleware.ts.

The changes to authenticate request adds the MachineAuthenticated and MachineUnauthenticated objects and the logic required.

In nextjs middleware specifically, I check the JWT sub claim in middleware and if it's prefixed with mch_ , pass entity: machine to authenticateRequest. There's a few alternatives but that's the meat and potatoes of this. Discussion here Introducing entity: any

The changes in the other fullstack frameworks are just to satisfy ts. The primary changes are for /backend and /nextjs.

The backend sdk helper to generate tokens is prefixed with __internal_ because we wanted to initially roll it out internally.

Also unsure about using non null assertions lol

Re-write error messages in request.ts

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

vercel bot commented Jan 11, 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 Jan 23, 2025 6:09am

Copy link

changeset-bot bot commented Jan 11, 2025

🦋 Changeset detected

Latest commit: 95ce1be

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

This PR includes changesets to release 10 packages
Name Type
@clerk/backend Minor
@clerk/nextjs Minor
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/remix Patch
@clerk/tanstack-start Patch
@clerk/testing 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

@jakobevangelista jakobevangelista changed the title feat: Machine-to-Machine feat(backend,nextjs): Machine-to-Machine Jan 11, 2025
@jakobevangelista
Copy link
Member Author

!snapshot

1 similar comment
@alexcarpenter
Copy link
Member

!snapshot

@clerk-cookie
Copy link
Collaborator

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

Package Version
@clerk/astro 2.1.7-snapshot.v20250122203406
@clerk/backend 1.22.0-snapshot.v20250122203406
@clerk/chrome-extension 2.1.11-snapshot.v20250122203406
@clerk/clerk-js 5.44.0-snapshot.v20250122203406
@clerk/clerk-expo 2.6.10-snapshot.v20250122203406
@clerk/express 1.3.34-snapshot.v20250122203406
@clerk/fastify 2.1.7-snapshot.v20250122203406
@clerk/nextjs 6.10.0-snapshot.v20250122203406
@clerk/nuxt 1.0.3-snapshot.v20250122203406
@clerk/react-router 0.1.8-snapshot.v20250122203406
@clerk/remix 4.4.9-snapshot.v20250122203406
@clerk/tanstack-start 0.8.8-snapshot.v20250122203406
@clerk/testing 1.4.7-snapshot.v20250122203406

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

npm i @clerk/astro@2.1.7-snapshot.v20250122203406 --save-exact

@clerk/backend

npm i @clerk/backend@1.22.0-snapshot.v20250122203406 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@2.1.11-snapshot.v20250122203406 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.44.0-snapshot.v20250122203406 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@2.6.10-snapshot.v20250122203406 --save-exact

@clerk/express

npm i @clerk/express@1.3.34-snapshot.v20250122203406 --save-exact

@clerk/fastify

npm i @clerk/fastify@2.1.7-snapshot.v20250122203406 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@6.10.0-snapshot.v20250122203406 --save-exact

@clerk/nuxt

npm i @clerk/nuxt@1.0.3-snapshot.v20250122203406 --save-exact

@clerk/react-router

npm i @clerk/react-router@0.1.8-snapshot.v20250122203406 --save-exact

@clerk/remix

npm i @clerk/remix@4.4.9-snapshot.v20250122203406 --save-exact

@clerk/tanstack-start

npm i @clerk/tanstack-start@0.8.8-snapshot.v20250122203406 --save-exact

@clerk/testing

npm i @clerk/testing@1.4.7-snapshot.v20250122203406 --save-exact

@jakobevangelista
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

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

Package Version
@clerk/astro 2.1.7-snapshot.v20250122212140
@clerk/backend 1.22.0-snapshot.v20250122212140
@clerk/chrome-extension 2.1.11-snapshot.v20250122212140
@clerk/clerk-js 5.44.0-snapshot.v20250122212140
@clerk/clerk-expo 2.6.10-snapshot.v20250122212140
@clerk/express 1.3.34-snapshot.v20250122212140
@clerk/fastify 2.1.7-snapshot.v20250122212140
@clerk/nextjs 6.10.0-snapshot.v20250122212140
@clerk/nuxt 1.0.3-snapshot.v20250122212140
@clerk/react-router 0.1.8-snapshot.v20250122212140
@clerk/remix 4.4.9-snapshot.v20250122212140
@clerk/tanstack-start 0.8.8-snapshot.v20250122212140
@clerk/testing 1.4.7-snapshot.v20250122212140

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

npm i @clerk/astro@2.1.7-snapshot.v20250122212140 --save-exact

@clerk/backend

npm i @clerk/backend@1.22.0-snapshot.v20250122212140 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@2.1.11-snapshot.v20250122212140 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.44.0-snapshot.v20250122212140 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@2.6.10-snapshot.v20250122212140 --save-exact

@clerk/express

npm i @clerk/express@1.3.34-snapshot.v20250122212140 --save-exact

@clerk/fastify

npm i @clerk/fastify@2.1.7-snapshot.v20250122212140 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@6.10.0-snapshot.v20250122212140 --save-exact

@clerk/nuxt

npm i @clerk/nuxt@1.0.3-snapshot.v20250122212140 --save-exact

@clerk/react-router

npm i @clerk/react-router@0.1.8-snapshot.v20250122212140 --save-exact

@clerk/remix

npm i @clerk/remix@4.4.9-snapshot.v20250122212140 --save-exact

@clerk/tanstack-start

npm i @clerk/tanstack-start@0.8.8-snapshot.v20250122212140 --save-exact

@clerk/testing

npm i @clerk/testing@1.4.7-snapshot.v20250122212140 --save-exact

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.

3 participants