Skip to content

chore(backend): deprecate the headerType option of verifyToken - #11076

Merged
wobsoriano merged 10 commits into
mainfrom
rob/verify-token-deprecate-header-type
Dec 6, 2026
Merged

wobsoriano merged 10 commits into
mainfrom
rob/verify-token-deprecate-header-type

Conversation

@wobsoriano

Copy link
Copy Markdown
Member

Description

Stacked on #11074.

verifyToken() accepts a headerType option, which suggests it can verify other kinds of Clerk tokens, such as OAuth access tokens with typ: 'at+jwt'. It can't. It only verifies session tokens and JWT template tokens, which always have the JWT header type, so headerType can only make verification fail.

headerType is now deprecated on verifyToken(), with a note pointing to authenticateRequest(request, { acceptsToken: 'oauth_token' }) for OAuth access tokens. It still works as before. verifyJwt() keeps headerType. The verifyToken() JSDoc now says which tokens it verifies.

The published types of verifyToken from @clerk/backend inlined its options and dropped their docs, so editors never showed the existing jwksCacheTtlInMs deprecation either. The export now uses VerifyTokenOptions, so both deprecations and the option docs show up.

Refs #11026

🤖 Generated with Claude under Rob's supervision.

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:

RealAdii and others added 5 commits November 29, 2026 13:07
…h-error

# Conflicts:
#	packages/backend/src/tokens/verify.ts
Keep the existing category check as the only rejection condition and choose the
OAuth message from the token's own typ, so headerType no longer changes which
tokens are rejected or labels non-OAuth tokens as OAuth access tokens.

Co-authored-by: RealAdii <153971735+RealAdii@users.noreply.github.com>
The full message appended "Make sure that this is a valid Clerk-generated JWT."
after telling the caller the token is an OAuth access token, which is a valid
Clerk-generated JWT.

Co-authored-by: RealAdii <153971735+RealAdii@users.noreply.github.com>
@vercel

vercel Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Dec 6, 2026 2:22am UTC
mosaic-docs Ready Ready Preview Dec 6, 2026 2:22am UTC
swingset Error Error Dec 6, 2026 2:22am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

No actionable comments were generated in the recent review.

Walkthrough

The changes document verifyToken() support for session and JWT template tokens, identify OAuth access, M2M, and OIDC ID tokens as unsupported, and direct OAuth access-token callers to authenticateRequest(). The headerType option is marked deprecated. The exported verifyToken wrapper now has an explicit options type and Promise<JwtPayload> return type.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • Issue 11026: The PR deprecates headerType and recommends authenticateRequest() for OAuth access tokens, matching the issue’s proposed replacement. The summaries do not show a change to the reported error text.

Suggested reviewers: sarahsoutoul, nikosdouvlis

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: deprecating the headerType option of verifyToken in @clerk/backend. The changeset includes the deprecation in verify.ts, index.ts, and the changelog. The 'chore' prefi…
Description check Passed The description explains the reason for deprecating headerType on verifyToken(), the replacement via authenticateRequest for OAuth access tokens, the JSDoc update, and the VerifyTokenOptions export ch…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: deprecating the headerType option of verifyToken in @clerk/backend. The changeset includes the deprecation in verify.ts, index.ts, and the changelog. The 'chore' prefix does not affect relevance, so the title is related to the changeset.

Full details: Description check

Explanation

The description explains the reason for deprecating headerType on verifyToken(), the replacement via authenticateRequest for OAuth access tokens, the JSDoc update, and the VerifyTokenOptions export change. It matches the changeset closely.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: This review skipped 6 repositories. Cross-repository analysis may be incomplete. Check linked repository access and settings.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b949de2 and b949de2.

Files selected for processing: 4

  • .changeset/verify-token-oauth-jwt-error.md
  • packages/backend/CHANGELOG.md
  • packages/backend/src/tokens/__tests__/verify.test.ts
  • packages/backend/src/tokens/verify.ts
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. 4 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

@changeset-bot

changeset-bot Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: aab8c68

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

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

Typing the export with VerifyTokenOptions dropped the `| undefined` the
inlined types had, which rejected `{ secretKey: process.env.CLERK_SECRET_KEY }`
under exactOptionalPropertyTypes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Additional comments: 1

packages/backend/src/tokens/verify.ts-40-40: 1

40-40: Major · Security & Privacy · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Include audience validation in the OAuth guidance.

If a resource server follows this example without configuring audience, a valid OAuth JWT intended for another resource can authenticate. The OAuth verifier skips the audience check when no audience is configured. (raw.githubusercontent.com)

Tell callers to set the expected audience. Update the changeset guidance as well.

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 725857d and 70c63e4.

Files selected for processing: 3

  • .changeset/verify-token-deprecate-header-type.md
  • packages/backend/src/index.ts
  • packages/backend/src/tokens/verify.ts
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. 4 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 6 reviews per hour.

wobsoriano and others added 3 commits December 2, 2026 09:35
Co-authored-by: RealAdii <153971735+RealAdii@users.noreply.github.com>
Co-authored-by: RealAdii <153971735+RealAdii@users.noreply.github.com>
@pkg-pr-new

pkg-pr-new Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@11076

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@11076

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@11076

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@11076

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@11076

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@11076

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@11076

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@11076

@clerk/expo-biometrics

npm i https://pkg.pr.new/@clerk/expo-biometrics@11076

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@11076

@clerk/expo-native-components

npm i https://pkg.pr.new/@clerk/expo-native-components@11076

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@11076

@clerk/express

npm i https://pkg.pr.new/@clerk/express@11076

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@11076

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@11076

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@11076

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@11076

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@11076

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@11076

@clerk/react

npm i https://pkg.pr.new/@clerk/react@11076

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@11076

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@11076

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@11076

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@11076

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@11076

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@11076

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@11076

commit: aab8c68

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-12-06T01:40:04.887Z

Summary

Metric Count
Packages analyzed 20
Packages with changes 1
🔴 Breaking changes 0
🟡 Non-breaking changes 2
🟢 Additions 0

🤖 This report was reviewed by claude-sonnet-4-6.


@clerk/backend

Current version: 3.36.0
Recommended bump: MINOR → 3.37.0

🟡 Non-breaking Changes (2)

Modified: verifyToken

- verifyToken: (token: string, options: {
-     audience?: string | string[] | undefined;
-     authorizedParties?: string[] | undefined;
-     clockSkewInMs?: number | undefined;
-     issuer?: string | string[] | undefined;
-     headerType?: string | string[] | undefined;
-     secretKey?: string | undefined;
-     apiUrl?: string | undefined;
-     apiVersion?: string | undefined;
-     jwksCacheTtlInMs?: number | undefined;
-     skipJwksCache?: boolean | undefined;
-     jwtKey?: string | undefined;
- }) => Promise<NonNullable<import("@clerk/shared/types").JwtPayload | undefined>>
+ verifyToken: (token: string, options: AllowUndefined<VerifyTokenOptions>) => Promise<JwtPayload>

Static analyzer: Breaking change in function verifyToken: Return type changed: !Promise:interface<!NonNullable:type<import("@clerk/shared").JwtPayload|undefined>> → !Promise:interface<import("@clerk/shared").JwtPayload>; Parameter options type changed: {audience?:string|string[]|undefined;authorizedParties?:string[]|undefined;clockSkewInMs?:number|undefined;issuer?:string|string[]|undefined;headerType?:string|string[]|undefined;secretKey?:string|undefined;apiUrl?:string|undefined;apiVersion?:string|undefined;jwksCacheTtlInMs?:number|undefined;skipJwksCache?:boolean|undefined;jwtKey?:string|undefined;} → import("@clerk/backend").~AllowUndefined<import("@clerk/backend").VerifyTokenOptions>

🤖 AI review (reclassified as non-breaking) (85%): The return type change from Promise<NonNullable<JwtPayload | undefined>> to Promise<JwtPayload> is structurally equivalent (both resolve to JwtPayload), and the parameter type change to AllowUndefined<VerifyTokenOptions> preserves all previously accepted fields — the headerType property was already present in the baseline expanded shape and remains optional, so existing callers passing any of the prior properties continue to compile correctly.

Modified: VerifyTokenOptions

- export type VerifyTokenOptions = Simplify<Omit<VerifyJwtOptions, 'key'> & Omit<LoadClerkJWKFromRemoteOptions, 'kid'> & {
+ export type VerifyTokenOptions = Simplify<Omit<VerifyJwtOptions, 'key' | 'headerType'> & Omit<LoadClerkJWKFromRemoteOptions, 'kid'> & {
+     headerType?: string | string[];
      jwtKey?: string;
  }>;

Static analyzer: Breaking change in type alias VerifyTokenOptions: Type changed: import("@clerk/shared").Simplify<!Omit:type<import("@clerk/backend").~VerifyJwtOptions,'key'>&!Omit:type<import("@clerk… → import("@clerk/shared").Simplify<!Omit:type<import("@clerk/backend").~VerifyJwtOptions,'headerType'|'key'>&!Omit:type<i…

🤖 AI review (reclassified as non-breaking) (88%): The change omits headerType from VerifyJwtOptions and re-declares it as headerType?: string | string[] directly on VerifyTokenOptions; since headerType was already optional in the prior type (present in the expanded baseline shape as headerType?: string | string[] | undefined), the resulting structural shape is identical — no previously valid consumer object is rejected and no previously present property is removed.


Report generated by Break Check

Last ran on aab8c68.

Base automatically changed from rob/verify-token-oauth-error to main December 6, 2026 00:48
…ecate-header-type

# Conflicts:
#	packages/backend/src/tokens/verify.ts
@wobsoriano
wobsoriano enabled stacked auto-merge (squash) December 6, 2026 01:44
@wobsoriano
wobsoriano merged commit bfd85f8 into main Dec 6, 2026
61 of 63 checks passed
@wobsoriano
wobsoriano deleted the rob/verify-token-deprecate-header-type branch December 6, 2026 01:44

This branch had an error being deployed

1 failed and 1 active deployments
Preview – swingset — aab8c689 Deployed Dec 6, 2026 by vercel[bot]
Preview – clerk-js-sandbox — aab8c689 Deployed Dec 6, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants