Skip to content

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

Open
wobsoriano wants to merge 4 commits into
rob/verify-token-oauth-errorfrom
rob/verify-token-deprecate-header-type
Open

wobsoriano wants to merge 4 commits into
rob/verify-token-oauth-errorfrom
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:

@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 2, 2026 1:37am UTC
mosaic-docs Ready Ready Preview Dec 2, 2026 1:37am UTC
swingset Ready Ready Preview Dec 2, 2026 1:37am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change deprecates the headerType option on verifyToken() and documents that the function verifies session and JWT template tokens with the JWT header type. The documentation identifies OAuth access tokens, M2M tokens, and OIDC ID tokens as unsupported, and directs OAuth verification to authenticateRequest(). 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 reports that verifyToken() fails for OAuth access tokens with certain headerType values. This change deprecates that option and gives the same OAuth verification guidance.

Possibly related PRs

  • clerk/javascript#11034: Both PRs address OAuth access-token handling in verifyToken() and direct callers to authenticateRequest().
  • clerk/javascript#11074: Both PRs address OAuth access-token handling in verifyToken() and provide the same replacement guidance.

Suggested reviewers: nikosdouvlis, sarahsoutoul

Merge Risk: Minimal · up to b949d

This change deprecates the headerType option on verifyToken and improves its documentation and types. Runtime verification behavior is unchanged, so merge risk is minimal.

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 summary, the index.ts and verify.ts changes, and the PR objectives all describe this …
Description check Passed The description explains why headerType is deprecated on verifyToken(), points OAuth access-token callers to authenticateRequest(), and describes the export change to VerifyTokenOptions. It matches th…
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 summary, the index.ts and verify.ts changes, and the PR objectives all describe this deprecation. The chore(backend) prefix is a conventional-commit type and does not affect relevance.

Full details: Description check

Explanation

The description explains why headerType is deprecated on verifyToken(), points OAuth access-token callers to authenticateRequest(), and describes the export change to VerifyTokenOptions. It matches the changeset and the PR objectives.

  • 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 70c63e4 and b949de2.

Files selected for processing: 2

  • .changeset/verify-token-deprecate-header-type.md
  • 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. 3 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.

@changeset-bot

changeset-bot Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b949de2

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 2 commits December 2, 2026 09:35
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: b949de2

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-12-02T01:41:27.066Z

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.34.0
Recommended bump: MINOR → 3.35.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 Promise<JwtPayload>), and the parameter type change from an inline expanded object to AllowUndefined<VerifyTokenOptions> resolves to the same shape (all optional properties), so no well-typed consumer is broken.

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) (90%): The change omits headerType from VerifyJwtOptions and re-adds it as an optional headerType?: string | string[] directly on VerifyTokenOptions; since VerifyTokenOptions is used only as a function input parameter (in verifyToken), adding an optional property to an input type is non-breaking, and the structural shape of headerType is preserved as optional.


Report generated by Break Check

Last ran on b949de2.

This branch was successfully deployed

2 active deployments
Preview – swingset — b949de2a Deployed Dec 2, 2026 by vercel[bot]
Preview – clerk-js-sandbox — b949de2a Deployed Dec 2, 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.

1 participant