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.
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.
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: 4
Check name
Status
Explanation
Title check
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
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
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 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.
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.
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 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.
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.
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