You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
chore(backend): deprecate the headerType option of verifyToken - #11076
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.
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>
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.
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: 4
Check name
Status
Explanation
Title check
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
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
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.
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.
Typing the export with VerifyTokenOptions dropped the `| undefined` the
inlined types had, which rejected `{ secretKey: process.env.CLERK_SECRET_KEY }`
under exactOptionalPropertyTypes.
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.
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.
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Stacked on #11074.
verifyToken()accepts aheaderTypeoption, which suggests it can verify other kinds of Clerk tokens, such as OAuth access tokens withtyp: 'at+jwt'. It can't. It only verifies session tokens and JWT template tokens, which always have theJWTheader type, soheaderTypecan only make verification fail.headerTypeis now deprecated onverifyToken(), with a note pointing toauthenticateRequest(request, { acceptsToken: 'oauth_token' })for OAuth access tokens. It still works as before.verifyJwt()keepsheaderType. TheverifyToken()JSDoc now says which tokens it verifies.The published types of
verifyTokenfrom@clerk/backendinlined its options and dropped their docs, so editors never showed the existingjwksCacheTtlInMsdeprecation either. The export now usesVerifyTokenOptions, so both deprecations and the option docs show up.Refs #11026
🤖 Generated with Claude under Rob's supervision.
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change