chore(backend): Rename machine auth verification methods - #7347

Merged
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods
Dec 2, 2025
Merged

chore(backend): Rename machine auth verification methods#7347
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods

Conversation

@wobsoriano

@wobsorianowobsoriano commented Dec 2, 2025

Copy link
Copy Markdown
Member

Description

Unifies machine token verification method naming across all three machine authentication APIs. Previously, each API had a different method name for verification:

  • client.apiKeys.verifySecret()
  • client.m2m.verifyToken()
  • client.idPOAuthAccessToken.verifyAccessToken() (We dont have docs for this, but exposed publicly)

This PR introduces a consistent verify() method for all three APIs while deprecating the existing methods for backwards compatibility.

Resolves USER-4130

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:

Summary by CodeRabbit

  • New Features

    • Unified verification: a single verify() method now handles verification for machine tokens, API keys, and OAuth access tokens to simplify usage.
  • Deprecations

    • Older verification methods are deprecated; migrate to verify() to ensure forward compatibility and receive deprecation notices.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot

changeset-botBot commented Dec 2, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c8b3223

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

This PR includes changesets to release 11 packages
NameType
@clerk/backendMinor
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

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

@vercel

vercelBot commented Dec 2, 2025

Copy link
Copy Markdown

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

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentDec 2, 2025 8:34pm

@coderabbitai

coderabbitaiBot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change unifies machine-token verification method names across the backend package by introducing verify() methods and providing deprecated wrappers (verifyToken, verifyAccessToken, verifySecret) that delegate to verify(). Tests and internal callers were updated and a changeset records the minor version bump.

Changes

Cohort / File(s)Summary
Changeset
.changeset/spotty-wasps-smoke.md
Added a changeset entry bumping @clerk/backend with description "Rename machine auth verification methods".
API endpoints
packages/backend/src/api/endpoints/M2MTokenApi.ts, packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts, packages/backend/src/api/endpoints/APIKeysApi.ts
Added new verify(...) public methods. Added deprecated wrappers verifyToken(...), verifyAccessToken(...), and verifySecret(...) that call verify(...) and emit deprecation warnings.
Token verification logic
packages/backend/src/tokens/verify.ts
Updated callers to use the new verify() methods for M2M, OAuth access tokens, and API keys instead of the old method names.
Tests
packages/backend/src/api/__tests__/M2MTokenApi.test.ts, packages/backend/src/api/__tests__/factory.test.ts
Updated test suites and call sites to invoke apiClient.*.verify(...) instead of the previous method names; expectations and flows unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check each API endpoint for consistent deprecation message formatting and proper deprecated import/use.
  • Verify the deprecated wrappers correctly delegate arguments and return values (including error paths).
  • Ensure all internal call sites (e.g., tokens/verify.ts) match the new signatures and tests reflect intended behavior.

Poem

🐰 I bounced through code with joyful cheer,
Old names whispering, "We'll still be near."
Now verify() hops into the light,
Deprecated friends waved out of sight,
A tidy trail of carrot-coded delight 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe PR title accurately describes the main change: renaming machine auth verification methods across three APIs to unify them under verify().
Linked Issues check✅ PassedThe PR successfully implements all coding requirements from USER-4130: adds verify() methods to APIKeysAPI, M2MTokenApi, and IdPOAuthAccessTokenApi, deprecates existing methods for backwards compatibility, and updates all call sites.
Out of Scope Changes check✅ PassedAll changes are directly related to the objective of renaming verification methods. No out-of-scope changes detected.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rob/user-4130-rename-verification-methods

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (1)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/spotty-wasps-smoke.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-newBot commented Dec 2, 2025

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7347

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7347

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7347

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7347

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7347

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7347

@clerk/upgrade

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

@clerk/vue

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

commit: c8b3223

@coderabbitaicoderabbitaiBot 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.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)

98-111: Add explicit return type and JSDoc documentation.

This public API method is missing an explicit return type annotation and JSDoc documentation.

As per coding guidelines, apply this diff to add the return type:

- async verify(params: VerifyM2MTokenParams) {+ async verify(params: VerifyM2MTokenParams): Promise<M2MToken> {

Additionally, add JSDoc documentation above the method:

/** * Verifies a machine-to-machine token. * * @param params - The verification parameters including the token and optional machine secret key. * @returns A promise that resolves to the verified M2M token. */asyncverify(params: VerifyM2MTokenParams): Promise<M2MToken>{
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (7)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts (4 hunks)
  • packages/backend/src/api/__tests__/factory.test.ts (3 hunks)
  • packages/backend/src/api/endpoints/APIKeysApi.ts (2 hunks)
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/M2MTokenApi.ts (3 hunks)
  • packages/backend/src/tokens/verify.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

All code must pass ESLint checks with the project's configuration

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Follow established naming conventions (PascalCase for components, camelCase for variables)

Prefer importing types from @clerk/shared/types instead of the deprecated @clerk/types alias

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{test,spec}.{ts,tsx,js,jsx}: Unit tests are required for all new functionality
Verify proper error handling and edge cases
Include tests for all new features

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec,e2e}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use real Clerk instances for integration tests

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Implement type guards for unknown types using the pattern function isType(value: unknown): value is Type
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details in classes
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like <T extends { id: string }>
Use utility types like Omit, Partial, and Pick for data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @PARAM, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Use const assertions with as const for literal types
Use satisfies operator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
🧬 Code graph analysis (2)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (2)
packages/backend/src/api/resources/IdPOAuthAccessToken.ts (1)
  • IdPOAuthAccessToken (3-33)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (32)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 15, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, shared, clerk-js, RQ)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (8)
.changeset/spotty-wasps-smoke.md (1)

1-5: LGTM! Appropriate version bump for this refactoring.

The minor version bump is correct for this change, as new verify() methods are being introduced while old methods remain functional with deprecation warnings.

packages/backend/src/api/__tests__/M2MTokenApi.test.ts (1)

209-284: LGTM! Tests correctly updated to reflect the renamed API surface.

The test updates properly exercise the new verify() method while maintaining comprehensive coverage of success paths, error handling, and authentication requirements.

packages/backend/src/api/__tests__/factory.test.ts (3)

328-332: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method while maintaining coverage of authorization header behavior.


356-360: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method in the machine secret key scenario.


428-432: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method when prioritizing machine secret key.

packages/backend/src/tokens/verify.ts (3)

196-207: LGTM! Internal implementation correctly updated.

The verifyM2MToken function properly uses the new verify() method. Error handling and return types remain unchanged.


209-220: LGTM! Internal implementation correctly updated.

The verifyOAuthToken function properly uses the new verify() method. Error handling and return types remain unchanged.


222-233: LGTM! Internal implementation correctly updated.

The verifyAPIKey function properly uses the new verify() method. Error handling and return types remain unchanged.

Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/M2MTokenApi.ts
@wobsoriano
wobsoriano enabled auto-merge (squash) December 2, 2025 21:13
@wobsoriano
wobsoriano merged commit d7c336d into mainDec 2, 2025
76 of 79 checks passed
@wobsoriano
wobsoriano deleted the rob/user-4130-rename-verification-methods branch December 2, 2025 21:19
Sign up for freeto 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

@wobsoriano@tmilewski@clerk-cookie
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

chore(backend): Rename machine auth verification methods - #7347

Merged
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods
Dec 2, 2025
Merged

chore(backend): Rename machine auth verification methods#7347
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods

Conversation

@wobsoriano

@wobsorianowobsoriano commented Dec 2, 2025

Copy link
Copy Markdown
Member

Description

Unifies machine token verification method naming across all three machine authentication APIs. Previously, each API had a different method name for verification:

  • client.apiKeys.verifySecret()
  • client.m2m.verifyToken()
  • client.idPOAuthAccessToken.verifyAccessToken() (We dont have docs for this, but exposed publicly)

This PR introduces a consistent verify() method for all three APIs while deprecating the existing methods for backwards compatibility.

Resolves USER-4130

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:

Summary by CodeRabbit

  • New Features

    • Unified verification: a single verify() method now handles verification for machine tokens, API keys, and OAuth access tokens to simplify usage.
  • Deprecations

    • Older verification methods are deprecated; migrate to verify() to ensure forward compatibility and receive deprecation notices.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot

changeset-botBot commented Dec 2, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c8b3223

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

This PR includes changesets to release 11 packages
NameType
@clerk/backendMinor
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

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

@vercel

vercelBot commented Dec 2, 2025

Copy link
Copy Markdown

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

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentDec 2, 2025 8:34pm

@coderabbitai

coderabbitaiBot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change unifies machine-token verification method names across the backend package by introducing verify() methods and providing deprecated wrappers (verifyToken, verifyAccessToken, verifySecret) that delegate to verify(). Tests and internal callers were updated and a changeset records the minor version bump.

Changes

Cohort / File(s)Summary
Changeset
.changeset/spotty-wasps-smoke.md
Added a changeset entry bumping @clerk/backend with description "Rename machine auth verification methods".
API endpoints
packages/backend/src/api/endpoints/M2MTokenApi.ts, packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts, packages/backend/src/api/endpoints/APIKeysApi.ts
Added new verify(...) public methods. Added deprecated wrappers verifyToken(...), verifyAccessToken(...), and verifySecret(...) that call verify(...) and emit deprecation warnings.
Token verification logic
packages/backend/src/tokens/verify.ts
Updated callers to use the new verify() methods for M2M, OAuth access tokens, and API keys instead of the old method names.
Tests
packages/backend/src/api/__tests__/M2MTokenApi.test.ts, packages/backend/src/api/__tests__/factory.test.ts
Updated test suites and call sites to invoke apiClient.*.verify(...) instead of the previous method names; expectations and flows unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check each API endpoint for consistent deprecation message formatting and proper deprecated import/use.
  • Verify the deprecated wrappers correctly delegate arguments and return values (including error paths).
  • Ensure all internal call sites (e.g., tokens/verify.ts) match the new signatures and tests reflect intended behavior.

Poem

🐰 I bounced through code with joyful cheer,
Old names whispering, "We'll still be near."
Now verify() hops into the light,
Deprecated friends waved out of sight,
A tidy trail of carrot-coded delight 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe PR title accurately describes the main change: renaming machine auth verification methods across three APIs to unify them under verify().
Linked Issues check✅ PassedThe PR successfully implements all coding requirements from USER-4130: adds verify() methods to APIKeysAPI, M2MTokenApi, and IdPOAuthAccessTokenApi, deprecates existing methods for backwards compatibility, and updates all call sites.
Out of Scope Changes check✅ PassedAll changes are directly related to the objective of renaming verification methods. No out-of-scope changes detected.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rob/user-4130-rename-verification-methods

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (1)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/spotty-wasps-smoke.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-newBot commented Dec 2, 2025

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7347

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7347

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7347

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7347

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7347

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7347

@clerk/upgrade

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

@clerk/vue

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

commit: c8b3223

@coderabbitaicoderabbitaiBot 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.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)

98-111: Add explicit return type and JSDoc documentation.

This public API method is missing an explicit return type annotation and JSDoc documentation.

As per coding guidelines, apply this diff to add the return type:

- async verify(params: VerifyM2MTokenParams) {+ async verify(params: VerifyM2MTokenParams): Promise<M2MToken> {

Additionally, add JSDoc documentation above the method:

/** * Verifies a machine-to-machine token. * * @param params - The verification parameters including the token and optional machine secret key. * @returns A promise that resolves to the verified M2M token. */asyncverify(params: VerifyM2MTokenParams): Promise<M2MToken>{
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (7)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts (4 hunks)
  • packages/backend/src/api/__tests__/factory.test.ts (3 hunks)
  • packages/backend/src/api/endpoints/APIKeysApi.ts (2 hunks)
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/M2MTokenApi.ts (3 hunks)
  • packages/backend/src/tokens/verify.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

All code must pass ESLint checks with the project's configuration

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Follow established naming conventions (PascalCase for components, camelCase for variables)

Prefer importing types from @clerk/shared/types instead of the deprecated @clerk/types alias

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{test,spec}.{ts,tsx,js,jsx}: Unit tests are required for all new functionality
Verify proper error handling and edge cases
Include tests for all new features

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec,e2e}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use real Clerk instances for integration tests

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Implement type guards for unknown types using the pattern function isType(value: unknown): value is Type
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details in classes
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like <T extends { id: string }>
Use utility types like Omit, Partial, and Pick for data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @PARAM, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Use const assertions with as const for literal types
Use satisfies operator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
🧬 Code graph analysis (2)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (2)
packages/backend/src/api/resources/IdPOAuthAccessToken.ts (1)
  • IdPOAuthAccessToken (3-33)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (32)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 15, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, shared, clerk-js, RQ)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (8)
.changeset/spotty-wasps-smoke.md (1)

1-5: LGTM! Appropriate version bump for this refactoring.

The minor version bump is correct for this change, as new verify() methods are being introduced while old methods remain functional with deprecation warnings.

packages/backend/src/api/__tests__/M2MTokenApi.test.ts (1)

209-284: LGTM! Tests correctly updated to reflect the renamed API surface.

The test updates properly exercise the new verify() method while maintaining comprehensive coverage of success paths, error handling, and authentication requirements.

packages/backend/src/api/__tests__/factory.test.ts (3)

328-332: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method while maintaining coverage of authorization header behavior.


356-360: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method in the machine secret key scenario.


428-432: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method when prioritizing machine secret key.

packages/backend/src/tokens/verify.ts (3)

196-207: LGTM! Internal implementation correctly updated.

The verifyM2MToken function properly uses the new verify() method. Error handling and return types remain unchanged.


209-220: LGTM! Internal implementation correctly updated.

The verifyOAuthToken function properly uses the new verify() method. Error handling and return types remain unchanged.


222-233: LGTM! Internal implementation correctly updated.

The verifyAPIKey function properly uses the new verify() method. Error handling and return types remain unchanged.

Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/M2MTokenApi.ts
@wobsoriano
wobsoriano enabled auto-merge (squash) December 2, 2025 21:13
@wobsoriano
wobsoriano merged commit d7c336d into mainDec 2, 2025
76 of 79 checks passed
@wobsoriano
wobsoriano deleted the rob/user-4130-rename-verification-methods branch December 2, 2025 21:19
Sign up for freeto 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

@wobsoriano@tmilewski@clerk-cookie
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

chore(backend): Rename machine auth verification methods - #7347

Merged
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods
Dec 2, 2025
Merged

chore(backend): Rename machine auth verification methods#7347
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods

Conversation

@wobsoriano

@wobsorianowobsoriano commented Dec 2, 2025

Copy link
Copy Markdown
Member

Description

Unifies machine token verification method naming across all three machine authentication APIs. Previously, each API had a different method name for verification:

  • client.apiKeys.verifySecret()
  • client.m2m.verifyToken()
  • client.idPOAuthAccessToken.verifyAccessToken() (We dont have docs for this, but exposed publicly)

This PR introduces a consistent verify() method for all three APIs while deprecating the existing methods for backwards compatibility.

Resolves USER-4130

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:

Summary by CodeRabbit

  • New Features

    • Unified verification: a single verify() method now handles verification for machine tokens, API keys, and OAuth access tokens to simplify usage.
  • Deprecations

    • Older verification methods are deprecated; migrate to verify() to ensure forward compatibility and receive deprecation notices.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot

changeset-botBot commented Dec 2, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c8b3223

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

This PR includes changesets to release 11 packages
NameType
@clerk/backendMinor
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

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

@vercel

vercelBot commented Dec 2, 2025

Copy link
Copy Markdown

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

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentDec 2, 2025 8:34pm

@coderabbitai

coderabbitaiBot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change unifies machine-token verification method names across the backend package by introducing verify() methods and providing deprecated wrappers (verifyToken, verifyAccessToken, verifySecret) that delegate to verify(). Tests and internal callers were updated and a changeset records the minor version bump.

Changes

Cohort / File(s)Summary
Changeset
.changeset/spotty-wasps-smoke.md
Added a changeset entry bumping @clerk/backend with description "Rename machine auth verification methods".
API endpoints
packages/backend/src/api/endpoints/M2MTokenApi.ts, packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts, packages/backend/src/api/endpoints/APIKeysApi.ts
Added new verify(...) public methods. Added deprecated wrappers verifyToken(...), verifyAccessToken(...), and verifySecret(...) that call verify(...) and emit deprecation warnings.
Token verification logic
packages/backend/src/tokens/verify.ts
Updated callers to use the new verify() methods for M2M, OAuth access tokens, and API keys instead of the old method names.
Tests
packages/backend/src/api/__tests__/M2MTokenApi.test.ts, packages/backend/src/api/__tests__/factory.test.ts
Updated test suites and call sites to invoke apiClient.*.verify(...) instead of the previous method names; expectations and flows unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check each API endpoint for consistent deprecation message formatting and proper deprecated import/use.
  • Verify the deprecated wrappers correctly delegate arguments and return values (including error paths).
  • Ensure all internal call sites (e.g., tokens/verify.ts) match the new signatures and tests reflect intended behavior.

Poem

🐰 I bounced through code with joyful cheer,
Old names whispering, "We'll still be near."
Now verify() hops into the light,
Deprecated friends waved out of sight,
A tidy trail of carrot-coded delight 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe PR title accurately describes the main change: renaming machine auth verification methods across three APIs to unify them under verify().
Linked Issues check✅ PassedThe PR successfully implements all coding requirements from USER-4130: adds verify() methods to APIKeysAPI, M2MTokenApi, and IdPOAuthAccessTokenApi, deprecates existing methods for backwards compatibility, and updates all call sites.
Out of Scope Changes check✅ PassedAll changes are directly related to the objective of renaming verification methods. No out-of-scope changes detected.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rob/user-4130-rename-verification-methods

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (1)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/spotty-wasps-smoke.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-newBot commented Dec 2, 2025

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7347

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7347

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7347

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7347

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7347

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7347

@clerk/upgrade

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

@clerk/vue

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

commit: c8b3223

@coderabbitaicoderabbitaiBot 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.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)

98-111: Add explicit return type and JSDoc documentation.

This public API method is missing an explicit return type annotation and JSDoc documentation.

As per coding guidelines, apply this diff to add the return type:

- async verify(params: VerifyM2MTokenParams) {+ async verify(params: VerifyM2MTokenParams): Promise<M2MToken> {

Additionally, add JSDoc documentation above the method:

/** * Verifies a machine-to-machine token. * * @param params - The verification parameters including the token and optional machine secret key. * @returns A promise that resolves to the verified M2M token. */asyncverify(params: VerifyM2MTokenParams): Promise<M2MToken>{
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (7)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts (4 hunks)
  • packages/backend/src/api/__tests__/factory.test.ts (3 hunks)
  • packages/backend/src/api/endpoints/APIKeysApi.ts (2 hunks)
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/M2MTokenApi.ts (3 hunks)
  • packages/backend/src/tokens/verify.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

All code must pass ESLint checks with the project's configuration

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Follow established naming conventions (PascalCase for components, camelCase for variables)

Prefer importing types from @clerk/shared/types instead of the deprecated @clerk/types alias

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{test,spec}.{ts,tsx,js,jsx}: Unit tests are required for all new functionality
Verify proper error handling and edge cases
Include tests for all new features

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec,e2e}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use real Clerk instances for integration tests

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Implement type guards for unknown types using the pattern function isType(value: unknown): value is Type
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details in classes
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like <T extends { id: string }>
Use utility types like Omit, Partial, and Pick for data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @PARAM, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Use const assertions with as const for literal types
Use satisfies operator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
🧬 Code graph analysis (2)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (2)
packages/backend/src/api/resources/IdPOAuthAccessToken.ts (1)
  • IdPOAuthAccessToken (3-33)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (32)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 15, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, shared, clerk-js, RQ)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (8)
.changeset/spotty-wasps-smoke.md (1)

1-5: LGTM! Appropriate version bump for this refactoring.

The minor version bump is correct for this change, as new verify() methods are being introduced while old methods remain functional with deprecation warnings.

packages/backend/src/api/__tests__/M2MTokenApi.test.ts (1)

209-284: LGTM! Tests correctly updated to reflect the renamed API surface.

The test updates properly exercise the new verify() method while maintaining comprehensive coverage of success paths, error handling, and authentication requirements.

packages/backend/src/api/__tests__/factory.test.ts (3)

328-332: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method while maintaining coverage of authorization header behavior.


356-360: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method in the machine secret key scenario.


428-432: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method when prioritizing machine secret key.

packages/backend/src/tokens/verify.ts (3)

196-207: LGTM! Internal implementation correctly updated.

The verifyM2MToken function properly uses the new verify() method. Error handling and return types remain unchanged.


209-220: LGTM! Internal implementation correctly updated.

The verifyOAuthToken function properly uses the new verify() method. Error handling and return types remain unchanged.


222-233: LGTM! Internal implementation correctly updated.

The verifyAPIKey function properly uses the new verify() method. Error handling and return types remain unchanged.

Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/M2MTokenApi.ts
@wobsoriano
wobsoriano enabled auto-merge (squash) December 2, 2025 21:13
@wobsoriano
wobsoriano merged commit d7c336d into mainDec 2, 2025
76 of 79 checks passed
@wobsoriano
wobsoriano deleted the rob/user-4130-rename-verification-methods branch December 2, 2025 21:19
Sign up for freeto 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

@wobsoriano@tmilewski@clerk-cookie
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

chore(backend): Rename machine auth verification methods - #7347

Merged
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods
Dec 2, 2025
Merged

chore(backend): Rename machine auth verification methods#7347
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods

Conversation

@wobsoriano

@wobsorianowobsoriano commented Dec 2, 2025

Copy link
Copy Markdown
Member

Description

Unifies machine token verification method naming across all three machine authentication APIs. Previously, each API had a different method name for verification:

  • client.apiKeys.verifySecret()
  • client.m2m.verifyToken()
  • client.idPOAuthAccessToken.verifyAccessToken() (We dont have docs for this, but exposed publicly)

This PR introduces a consistent verify() method for all three APIs while deprecating the existing methods for backwards compatibility.

Resolves USER-4130

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:

Summary by CodeRabbit

  • New Features

    • Unified verification: a single verify() method now handles verification for machine tokens, API keys, and OAuth access tokens to simplify usage.
  • Deprecations

    • Older verification methods are deprecated; migrate to verify() to ensure forward compatibility and receive deprecation notices.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot

changeset-botBot commented Dec 2, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c8b3223

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

This PR includes changesets to release 11 packages
NameType
@clerk/backendMinor
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

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

@vercel

vercelBot commented Dec 2, 2025

Copy link
Copy Markdown

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

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentDec 2, 2025 8:34pm

@coderabbitai

coderabbitaiBot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change unifies machine-token verification method names across the backend package by introducing verify() methods and providing deprecated wrappers (verifyToken, verifyAccessToken, verifySecret) that delegate to verify(). Tests and internal callers were updated and a changeset records the minor version bump.

Changes

Cohort / File(s)Summary
Changeset
.changeset/spotty-wasps-smoke.md
Added a changeset entry bumping @clerk/backend with description "Rename machine auth verification methods".
API endpoints
packages/backend/src/api/endpoints/M2MTokenApi.ts, packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts, packages/backend/src/api/endpoints/APIKeysApi.ts
Added new verify(...) public methods. Added deprecated wrappers verifyToken(...), verifyAccessToken(...), and verifySecret(...) that call verify(...) and emit deprecation warnings.
Token verification logic
packages/backend/src/tokens/verify.ts
Updated callers to use the new verify() methods for M2M, OAuth access tokens, and API keys instead of the old method names.
Tests
packages/backend/src/api/__tests__/M2MTokenApi.test.ts, packages/backend/src/api/__tests__/factory.test.ts
Updated test suites and call sites to invoke apiClient.*.verify(...) instead of the previous method names; expectations and flows unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check each API endpoint for consistent deprecation message formatting and proper deprecated import/use.
  • Verify the deprecated wrappers correctly delegate arguments and return values (including error paths).
  • Ensure all internal call sites (e.g., tokens/verify.ts) match the new signatures and tests reflect intended behavior.

Poem

🐰 I bounced through code with joyful cheer,
Old names whispering, "We'll still be near."
Now verify() hops into the light,
Deprecated friends waved out of sight,
A tidy trail of carrot-coded delight 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe PR title accurately describes the main change: renaming machine auth verification methods across three APIs to unify them under verify().
Linked Issues check✅ PassedThe PR successfully implements all coding requirements from USER-4130: adds verify() methods to APIKeysAPI, M2MTokenApi, and IdPOAuthAccessTokenApi, deprecates existing methods for backwards compatibility, and updates all call sites.
Out of Scope Changes check✅ PassedAll changes are directly related to the objective of renaming verification methods. No out-of-scope changes detected.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rob/user-4130-rename-verification-methods

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (1)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/spotty-wasps-smoke.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-newBot commented Dec 2, 2025

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7347

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7347

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7347

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7347

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7347

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7347

@clerk/upgrade

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

@clerk/vue

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

commit: c8b3223

@coderabbitaicoderabbitaiBot 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.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)

98-111: Add explicit return type and JSDoc documentation.

This public API method is missing an explicit return type annotation and JSDoc documentation.

As per coding guidelines, apply this diff to add the return type:

- async verify(params: VerifyM2MTokenParams) {+ async verify(params: VerifyM2MTokenParams): Promise<M2MToken> {

Additionally, add JSDoc documentation above the method:

/** * Verifies a machine-to-machine token. * * @param params - The verification parameters including the token and optional machine secret key. * @returns A promise that resolves to the verified M2M token. */asyncverify(params: VerifyM2MTokenParams): Promise<M2MToken>{
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (7)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts (4 hunks)
  • packages/backend/src/api/__tests__/factory.test.ts (3 hunks)
  • packages/backend/src/api/endpoints/APIKeysApi.ts (2 hunks)
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/M2MTokenApi.ts (3 hunks)
  • packages/backend/src/tokens/verify.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

All code must pass ESLint checks with the project's configuration

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Follow established naming conventions (PascalCase for components, camelCase for variables)

Prefer importing types from @clerk/shared/types instead of the deprecated @clerk/types alias

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{test,spec}.{ts,tsx,js,jsx}: Unit tests are required for all new functionality
Verify proper error handling and edge cases
Include tests for all new features

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec,e2e}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use real Clerk instances for integration tests

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Implement type guards for unknown types using the pattern function isType(value: unknown): value is Type
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details in classes
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like <T extends { id: string }>
Use utility types like Omit, Partial, and Pick for data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @PARAM, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Use const assertions with as const for literal types
Use satisfies operator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
🧬 Code graph analysis (2)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (2)
packages/backend/src/api/resources/IdPOAuthAccessToken.ts (1)
  • IdPOAuthAccessToken (3-33)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (32)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 15, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, shared, clerk-js, RQ)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (8)
.changeset/spotty-wasps-smoke.md (1)

1-5: LGTM! Appropriate version bump for this refactoring.

The minor version bump is correct for this change, as new verify() methods are being introduced while old methods remain functional with deprecation warnings.

packages/backend/src/api/__tests__/M2MTokenApi.test.ts (1)

209-284: LGTM! Tests correctly updated to reflect the renamed API surface.

The test updates properly exercise the new verify() method while maintaining comprehensive coverage of success paths, error handling, and authentication requirements.

packages/backend/src/api/__tests__/factory.test.ts (3)

328-332: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method while maintaining coverage of authorization header behavior.


356-360: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method in the machine secret key scenario.


428-432: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method when prioritizing machine secret key.

packages/backend/src/tokens/verify.ts (3)

196-207: LGTM! Internal implementation correctly updated.

The verifyM2MToken function properly uses the new verify() method. Error handling and return types remain unchanged.


209-220: LGTM! Internal implementation correctly updated.

The verifyOAuthToken function properly uses the new verify() method. Error handling and return types remain unchanged.


222-233: LGTM! Internal implementation correctly updated.

The verifyAPIKey function properly uses the new verify() method. Error handling and return types remain unchanged.

Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/M2MTokenApi.ts
@wobsoriano
wobsoriano enabled auto-merge (squash) December 2, 2025 21:13
@wobsoriano
wobsoriano merged commit d7c336d into mainDec 2, 2025
76 of 79 checks passed
@wobsoriano
wobsoriano deleted the rob/user-4130-rename-verification-methods branch December 2, 2025 21:19
Sign up for freeto 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

@wobsoriano@tmilewski@clerk-cookie
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

chore(backend): Rename machine auth verification methods - #7347

Merged
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods
Dec 2, 2025
Merged

chore(backend): Rename machine auth verification methods#7347
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods

Conversation

@wobsoriano

@wobsorianowobsoriano commented Dec 2, 2025

Copy link
Copy Markdown
Member

Description

Unifies machine token verification method naming across all three machine authentication APIs. Previously, each API had a different method name for verification:

  • client.apiKeys.verifySecret()
  • client.m2m.verifyToken()
  • client.idPOAuthAccessToken.verifyAccessToken() (We dont have docs for this, but exposed publicly)

This PR introduces a consistent verify() method for all three APIs while deprecating the existing methods for backwards compatibility.

Resolves USER-4130

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:

Summary by CodeRabbit

  • New Features

    • Unified verification: a single verify() method now handles verification for machine tokens, API keys, and OAuth access tokens to simplify usage.
  • Deprecations

    • Older verification methods are deprecated; migrate to verify() to ensure forward compatibility and receive deprecation notices.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot

changeset-botBot commented Dec 2, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c8b3223

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

This PR includes changesets to release 11 packages
NameType
@clerk/backendMinor
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

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

@vercel

vercelBot commented Dec 2, 2025

Copy link
Copy Markdown

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

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentDec 2, 2025 8:34pm

@coderabbitai

coderabbitaiBot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change unifies machine-token verification method names across the backend package by introducing verify() methods and providing deprecated wrappers (verifyToken, verifyAccessToken, verifySecret) that delegate to verify(). Tests and internal callers were updated and a changeset records the minor version bump.

Changes

Cohort / File(s)Summary
Changeset
.changeset/spotty-wasps-smoke.md
Added a changeset entry bumping @clerk/backend with description "Rename machine auth verification methods".
API endpoints
packages/backend/src/api/endpoints/M2MTokenApi.ts, packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts, packages/backend/src/api/endpoints/APIKeysApi.ts
Added new verify(...) public methods. Added deprecated wrappers verifyToken(...), verifyAccessToken(...), and verifySecret(...) that call verify(...) and emit deprecation warnings.
Token verification logic
packages/backend/src/tokens/verify.ts
Updated callers to use the new verify() methods for M2M, OAuth access tokens, and API keys instead of the old method names.
Tests
packages/backend/src/api/__tests__/M2MTokenApi.test.ts, packages/backend/src/api/__tests__/factory.test.ts
Updated test suites and call sites to invoke apiClient.*.verify(...) instead of the previous method names; expectations and flows unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check each API endpoint for consistent deprecation message formatting and proper deprecated import/use.
  • Verify the deprecated wrappers correctly delegate arguments and return values (including error paths).
  • Ensure all internal call sites (e.g., tokens/verify.ts) match the new signatures and tests reflect intended behavior.

Poem

🐰 I bounced through code with joyful cheer,
Old names whispering, "We'll still be near."
Now verify() hops into the light,
Deprecated friends waved out of sight,
A tidy trail of carrot-coded delight 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe PR title accurately describes the main change: renaming machine auth verification methods across three APIs to unify them under verify().
Linked Issues check✅ PassedThe PR successfully implements all coding requirements from USER-4130: adds verify() methods to APIKeysAPI, M2MTokenApi, and IdPOAuthAccessTokenApi, deprecates existing methods for backwards compatibility, and updates all call sites.
Out of Scope Changes check✅ PassedAll changes are directly related to the objective of renaming verification methods. No out-of-scope changes detected.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rob/user-4130-rename-verification-methods

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (1)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/spotty-wasps-smoke.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-newBot commented Dec 2, 2025

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7347

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7347

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7347

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7347

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7347

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7347

@clerk/upgrade

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

@clerk/vue

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

commit: c8b3223

@coderabbitaicoderabbitaiBot 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.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)

98-111: Add explicit return type and JSDoc documentation.

This public API method is missing an explicit return type annotation and JSDoc documentation.

As per coding guidelines, apply this diff to add the return type:

- async verify(params: VerifyM2MTokenParams) {+ async verify(params: VerifyM2MTokenParams): Promise<M2MToken> {

Additionally, add JSDoc documentation above the method:

/** * Verifies a machine-to-machine token. * * @param params - The verification parameters including the token and optional machine secret key. * @returns A promise that resolves to the verified M2M token. */asyncverify(params: VerifyM2MTokenParams): Promise<M2MToken>{
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (7)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts (4 hunks)
  • packages/backend/src/api/__tests__/factory.test.ts (3 hunks)
  • packages/backend/src/api/endpoints/APIKeysApi.ts (2 hunks)
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/M2MTokenApi.ts (3 hunks)
  • packages/backend/src/tokens/verify.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

All code must pass ESLint checks with the project's configuration

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Follow established naming conventions (PascalCase for components, camelCase for variables)

Prefer importing types from @clerk/shared/types instead of the deprecated @clerk/types alias

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{test,spec}.{ts,tsx,js,jsx}: Unit tests are required for all new functionality
Verify proper error handling and edge cases
Include tests for all new features

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec,e2e}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use real Clerk instances for integration tests

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Implement type guards for unknown types using the pattern function isType(value: unknown): value is Type
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details in classes
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like <T extends { id: string }>
Use utility types like Omit, Partial, and Pick for data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @PARAM, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Use const assertions with as const for literal types
Use satisfies operator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
🧬 Code graph analysis (2)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (2)
packages/backend/src/api/resources/IdPOAuthAccessToken.ts (1)
  • IdPOAuthAccessToken (3-33)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (32)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 15, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, shared, clerk-js, RQ)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (8)
.changeset/spotty-wasps-smoke.md (1)

1-5: LGTM! Appropriate version bump for this refactoring.

The minor version bump is correct for this change, as new verify() methods are being introduced while old methods remain functional with deprecation warnings.

packages/backend/src/api/__tests__/M2MTokenApi.test.ts (1)

209-284: LGTM! Tests correctly updated to reflect the renamed API surface.

The test updates properly exercise the new verify() method while maintaining comprehensive coverage of success paths, error handling, and authentication requirements.

packages/backend/src/api/__tests__/factory.test.ts (3)

328-332: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method while maintaining coverage of authorization header behavior.


356-360: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method in the machine secret key scenario.


428-432: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method when prioritizing machine secret key.

packages/backend/src/tokens/verify.ts (3)

196-207: LGTM! Internal implementation correctly updated.

The verifyM2MToken function properly uses the new verify() method. Error handling and return types remain unchanged.


209-220: LGTM! Internal implementation correctly updated.

The verifyOAuthToken function properly uses the new verify() method. Error handling and return types remain unchanged.


222-233: LGTM! Internal implementation correctly updated.

The verifyAPIKey function properly uses the new verify() method. Error handling and return types remain unchanged.

Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/M2MTokenApi.ts
@wobsoriano
wobsoriano enabled auto-merge (squash) December 2, 2025 21:13
@wobsoriano
wobsoriano merged commit d7c336d into mainDec 2, 2025
76 of 79 checks passed
@wobsoriano
wobsoriano deleted the rob/user-4130-rename-verification-methods branch December 2, 2025 21:19
Sign up for freeto 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

@wobsoriano@tmilewski@clerk-cookie
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

chore(backend): Rename machine auth verification methods - #7347

Merged
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods
Dec 2, 2025
Merged

chore(backend): Rename machine auth verification methods#7347
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods

Conversation

@wobsoriano

@wobsorianowobsoriano commented Dec 2, 2025

Copy link
Copy Markdown
Member

Description

Unifies machine token verification method naming across all three machine authentication APIs. Previously, each API had a different method name for verification:

  • client.apiKeys.verifySecret()
  • client.m2m.verifyToken()
  • client.idPOAuthAccessToken.verifyAccessToken() (We dont have docs for this, but exposed publicly)

This PR introduces a consistent verify() method for all three APIs while deprecating the existing methods for backwards compatibility.

Resolves USER-4130

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:

Summary by CodeRabbit

  • New Features

    • Unified verification: a single verify() method now handles verification for machine tokens, API keys, and OAuth access tokens to simplify usage.
  • Deprecations

    • Older verification methods are deprecated; migrate to verify() to ensure forward compatibility and receive deprecation notices.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot

changeset-botBot commented Dec 2, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c8b3223

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

This PR includes changesets to release 11 packages
NameType
@clerk/backendMinor
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

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

@vercel

vercelBot commented Dec 2, 2025

Copy link
Copy Markdown

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

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentDec 2, 2025 8:34pm

@coderabbitai

coderabbitaiBot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change unifies machine-token verification method names across the backend package by introducing verify() methods and providing deprecated wrappers (verifyToken, verifyAccessToken, verifySecret) that delegate to verify(). Tests and internal callers were updated and a changeset records the minor version bump.

Changes

Cohort / File(s)Summary
Changeset
.changeset/spotty-wasps-smoke.md
Added a changeset entry bumping @clerk/backend with description "Rename machine auth verification methods".
API endpoints
packages/backend/src/api/endpoints/M2MTokenApi.ts, packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts, packages/backend/src/api/endpoints/APIKeysApi.ts
Added new verify(...) public methods. Added deprecated wrappers verifyToken(...), verifyAccessToken(...), and verifySecret(...) that call verify(...) and emit deprecation warnings.
Token verification logic
packages/backend/src/tokens/verify.ts
Updated callers to use the new verify() methods for M2M, OAuth access tokens, and API keys instead of the old method names.
Tests
packages/backend/src/api/__tests__/M2MTokenApi.test.ts, packages/backend/src/api/__tests__/factory.test.ts
Updated test suites and call sites to invoke apiClient.*.verify(...) instead of the previous method names; expectations and flows unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check each API endpoint for consistent deprecation message formatting and proper deprecated import/use.
  • Verify the deprecated wrappers correctly delegate arguments and return values (including error paths).
  • Ensure all internal call sites (e.g., tokens/verify.ts) match the new signatures and tests reflect intended behavior.

Poem

🐰 I bounced through code with joyful cheer,
Old names whispering, "We'll still be near."
Now verify() hops into the light,
Deprecated friends waved out of sight,
A tidy trail of carrot-coded delight 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe PR title accurately describes the main change: renaming machine auth verification methods across three APIs to unify them under verify().
Linked Issues check✅ PassedThe PR successfully implements all coding requirements from USER-4130: adds verify() methods to APIKeysAPI, M2MTokenApi, and IdPOAuthAccessTokenApi, deprecates existing methods for backwards compatibility, and updates all call sites.
Out of Scope Changes check✅ PassedAll changes are directly related to the objective of renaming verification methods. No out-of-scope changes detected.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rob/user-4130-rename-verification-methods

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (1)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/spotty-wasps-smoke.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-newBot commented Dec 2, 2025

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7347

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7347

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7347

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7347

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7347

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7347

@clerk/upgrade

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

@clerk/vue

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

commit: c8b3223

@coderabbitaicoderabbitaiBot 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.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)

98-111: Add explicit return type and JSDoc documentation.

This public API method is missing an explicit return type annotation and JSDoc documentation.

As per coding guidelines, apply this diff to add the return type:

- async verify(params: VerifyM2MTokenParams) {+ async verify(params: VerifyM2MTokenParams): Promise<M2MToken> {

Additionally, add JSDoc documentation above the method:

/** * Verifies a machine-to-machine token. * * @param params - The verification parameters including the token and optional machine secret key. * @returns A promise that resolves to the verified M2M token. */asyncverify(params: VerifyM2MTokenParams): Promise<M2MToken>{
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (7)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts (4 hunks)
  • packages/backend/src/api/__tests__/factory.test.ts (3 hunks)
  • packages/backend/src/api/endpoints/APIKeysApi.ts (2 hunks)
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/M2MTokenApi.ts (3 hunks)
  • packages/backend/src/tokens/verify.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

All code must pass ESLint checks with the project's configuration

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Follow established naming conventions (PascalCase for components, camelCase for variables)

Prefer importing types from @clerk/shared/types instead of the deprecated @clerk/types alias

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{test,spec}.{ts,tsx,js,jsx}: Unit tests are required for all new functionality
Verify proper error handling and edge cases
Include tests for all new features

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec,e2e}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use real Clerk instances for integration tests

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Implement type guards for unknown types using the pattern function isType(value: unknown): value is Type
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details in classes
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like <T extends { id: string }>
Use utility types like Omit, Partial, and Pick for data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @PARAM, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Use const assertions with as const for literal types
Use satisfies operator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
🧬 Code graph analysis (2)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (2)
packages/backend/src/api/resources/IdPOAuthAccessToken.ts (1)
  • IdPOAuthAccessToken (3-33)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (32)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 15, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, shared, clerk-js, RQ)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (8)
.changeset/spotty-wasps-smoke.md (1)

1-5: LGTM! Appropriate version bump for this refactoring.

The minor version bump is correct for this change, as new verify() methods are being introduced while old methods remain functional with deprecation warnings.

packages/backend/src/api/__tests__/M2MTokenApi.test.ts (1)

209-284: LGTM! Tests correctly updated to reflect the renamed API surface.

The test updates properly exercise the new verify() method while maintaining comprehensive coverage of success paths, error handling, and authentication requirements.

packages/backend/src/api/__tests__/factory.test.ts (3)

328-332: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method while maintaining coverage of authorization header behavior.


356-360: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method in the machine secret key scenario.


428-432: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method when prioritizing machine secret key.

packages/backend/src/tokens/verify.ts (3)

196-207: LGTM! Internal implementation correctly updated.

The verifyM2MToken function properly uses the new verify() method. Error handling and return types remain unchanged.


209-220: LGTM! Internal implementation correctly updated.

The verifyOAuthToken function properly uses the new verify() method. Error handling and return types remain unchanged.


222-233: LGTM! Internal implementation correctly updated.

The verifyAPIKey function properly uses the new verify() method. Error handling and return types remain unchanged.

Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/M2MTokenApi.ts
@wobsoriano
wobsoriano enabled auto-merge (squash) December 2, 2025 21:13
@wobsoriano
wobsoriano merged commit d7c336d into mainDec 2, 2025
76 of 79 checks passed
@wobsoriano
wobsoriano deleted the rob/user-4130-rename-verification-methods branch December 2, 2025 21:19
Sign up for freeto 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

@wobsoriano@tmilewski@clerk-cookie
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

chore(backend): Rename machine auth verification methods - #7347

Merged
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods
Dec 2, 2025
Merged

chore(backend): Rename machine auth verification methods#7347
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods

Conversation

@wobsoriano

@wobsorianowobsoriano commented Dec 2, 2025

Copy link
Copy Markdown
Member

Description

Unifies machine token verification method naming across all three machine authentication APIs. Previously, each API had a different method name for verification:

  • client.apiKeys.verifySecret()
  • client.m2m.verifyToken()
  • client.idPOAuthAccessToken.verifyAccessToken() (We dont have docs for this, but exposed publicly)

This PR introduces a consistent verify() method for all three APIs while deprecating the existing methods for backwards compatibility.

Resolves USER-4130

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:

Summary by CodeRabbit

  • New Features

    • Unified verification: a single verify() method now handles verification for machine tokens, API keys, and OAuth access tokens to simplify usage.
  • Deprecations

    • Older verification methods are deprecated; migrate to verify() to ensure forward compatibility and receive deprecation notices.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot

changeset-botBot commented Dec 2, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c8b3223

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

This PR includes changesets to release 11 packages
NameType
@clerk/backendMinor
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

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

@vercel

vercelBot commented Dec 2, 2025

Copy link
Copy Markdown

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

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentDec 2, 2025 8:34pm

@coderabbitai

coderabbitaiBot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change unifies machine-token verification method names across the backend package by introducing verify() methods and providing deprecated wrappers (verifyToken, verifyAccessToken, verifySecret) that delegate to verify(). Tests and internal callers were updated and a changeset records the minor version bump.

Changes

Cohort / File(s)Summary
Changeset
.changeset/spotty-wasps-smoke.md
Added a changeset entry bumping @clerk/backend with description "Rename machine auth verification methods".
API endpoints
packages/backend/src/api/endpoints/M2MTokenApi.ts, packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts, packages/backend/src/api/endpoints/APIKeysApi.ts
Added new verify(...) public methods. Added deprecated wrappers verifyToken(...), verifyAccessToken(...), and verifySecret(...) that call verify(...) and emit deprecation warnings.
Token verification logic
packages/backend/src/tokens/verify.ts
Updated callers to use the new verify() methods for M2M, OAuth access tokens, and API keys instead of the old method names.
Tests
packages/backend/src/api/__tests__/M2MTokenApi.test.ts, packages/backend/src/api/__tests__/factory.test.ts
Updated test suites and call sites to invoke apiClient.*.verify(...) instead of the previous method names; expectations and flows unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check each API endpoint for consistent deprecation message formatting and proper deprecated import/use.
  • Verify the deprecated wrappers correctly delegate arguments and return values (including error paths).
  • Ensure all internal call sites (e.g., tokens/verify.ts) match the new signatures and tests reflect intended behavior.

Poem

🐰 I bounced through code with joyful cheer,
Old names whispering, "We'll still be near."
Now verify() hops into the light,
Deprecated friends waved out of sight,
A tidy trail of carrot-coded delight 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe PR title accurately describes the main change: renaming machine auth verification methods across three APIs to unify them under verify().
Linked Issues check✅ PassedThe PR successfully implements all coding requirements from USER-4130: adds verify() methods to APIKeysAPI, M2MTokenApi, and IdPOAuthAccessTokenApi, deprecates existing methods for backwards compatibility, and updates all call sites.
Out of Scope Changes check✅ PassedAll changes are directly related to the objective of renaming verification methods. No out-of-scope changes detected.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rob/user-4130-rename-verification-methods

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (1)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/spotty-wasps-smoke.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-newBot commented Dec 2, 2025

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7347

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7347

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7347

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7347

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7347

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7347

@clerk/upgrade

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

@clerk/vue

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

commit: c8b3223

@coderabbitaicoderabbitaiBot 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.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)

98-111: Add explicit return type and JSDoc documentation.

This public API method is missing an explicit return type annotation and JSDoc documentation.

As per coding guidelines, apply this diff to add the return type:

- async verify(params: VerifyM2MTokenParams) {+ async verify(params: VerifyM2MTokenParams): Promise<M2MToken> {

Additionally, add JSDoc documentation above the method:

/** * Verifies a machine-to-machine token. * * @param params - The verification parameters including the token and optional machine secret key. * @returns A promise that resolves to the verified M2M token. */asyncverify(params: VerifyM2MTokenParams): Promise<M2MToken>{
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (7)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts (4 hunks)
  • packages/backend/src/api/__tests__/factory.test.ts (3 hunks)
  • packages/backend/src/api/endpoints/APIKeysApi.ts (2 hunks)
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/M2MTokenApi.ts (3 hunks)
  • packages/backend/src/tokens/verify.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

All code must pass ESLint checks with the project's configuration

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Follow established naming conventions (PascalCase for components, camelCase for variables)

Prefer importing types from @clerk/shared/types instead of the deprecated @clerk/types alias

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{test,spec}.{ts,tsx,js,jsx}: Unit tests are required for all new functionality
Verify proper error handling and edge cases
Include tests for all new features

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec,e2e}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use real Clerk instances for integration tests

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Implement type guards for unknown types using the pattern function isType(value: unknown): value is Type
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details in classes
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like <T extends { id: string }>
Use utility types like Omit, Partial, and Pick for data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @PARAM, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Use const assertions with as const for literal types
Use satisfies operator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
🧬 Code graph analysis (2)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (2)
packages/backend/src/api/resources/IdPOAuthAccessToken.ts (1)
  • IdPOAuthAccessToken (3-33)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (32)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 15, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, shared, clerk-js, RQ)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (8)
.changeset/spotty-wasps-smoke.md (1)

1-5: LGTM! Appropriate version bump for this refactoring.

The minor version bump is correct for this change, as new verify() methods are being introduced while old methods remain functional with deprecation warnings.

packages/backend/src/api/__tests__/M2MTokenApi.test.ts (1)

209-284: LGTM! Tests correctly updated to reflect the renamed API surface.

The test updates properly exercise the new verify() method while maintaining comprehensive coverage of success paths, error handling, and authentication requirements.

packages/backend/src/api/__tests__/factory.test.ts (3)

328-332: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method while maintaining coverage of authorization header behavior.


356-360: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method in the machine secret key scenario.


428-432: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method when prioritizing machine secret key.

packages/backend/src/tokens/verify.ts (3)

196-207: LGTM! Internal implementation correctly updated.

The verifyM2MToken function properly uses the new verify() method. Error handling and return types remain unchanged.


209-220: LGTM! Internal implementation correctly updated.

The verifyOAuthToken function properly uses the new verify() method. Error handling and return types remain unchanged.


222-233: LGTM! Internal implementation correctly updated.

The verifyAPIKey function properly uses the new verify() method. Error handling and return types remain unchanged.

Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/M2MTokenApi.ts
@wobsoriano
wobsoriano enabled auto-merge (squash) December 2, 2025 21:13
@wobsoriano
wobsoriano merged commit d7c336d into mainDec 2, 2025
76 of 79 checks passed
@wobsoriano
wobsoriano deleted the rob/user-4130-rename-verification-methods branch December 2, 2025 21:19
Sign up for freeto 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

@wobsoriano@tmilewski@clerk-cookie
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

chore(backend): Rename machine auth verification methods - #7347

Merged
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods
Dec 2, 2025
Merged

chore(backend): Rename machine auth verification methods#7347
wobsoriano merged 5 commits into
mainfrom
rob/user-4130-rename-verification-methods

Conversation

@wobsoriano

@wobsorianowobsoriano commented Dec 2, 2025

Copy link
Copy Markdown
Member

Description

Unifies machine token verification method naming across all three machine authentication APIs. Previously, each API had a different method name for verification:

  • client.apiKeys.verifySecret()
  • client.m2m.verifyToken()
  • client.idPOAuthAccessToken.verifyAccessToken() (We dont have docs for this, but exposed publicly)

This PR introduces a consistent verify() method for all three APIs while deprecating the existing methods for backwards compatibility.

Resolves USER-4130

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:

Summary by CodeRabbit

  • New Features

    • Unified verification: a single verify() method now handles verification for machine tokens, API keys, and OAuth access tokens to simplify usage.
  • Deprecations

    • Older verification methods are deprecated; migrate to verify() to ensure forward compatibility and receive deprecation notices.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot

changeset-botBot commented Dec 2, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c8b3223

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

This PR includes changesets to release 11 packages
NameType
@clerk/backendMinor
@clerk/agent-toolkitPatch
@clerk/astroPatch
@clerk/expressPatch
@clerk/fastifyPatch
@clerk/nextjsPatch
@clerk/nuxtPatch
@clerk/react-routerPatch
@clerk/remixPatch
@clerk/tanstack-react-startPatch
@clerk/testingPatch

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

@vercel

vercelBot commented Dec 2, 2025

Copy link
Copy Markdown

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

ProjectDeploymentPreviewCommentsUpdated (UTC)
clerk-js-sandboxReadyReadyPreviewCommentDec 2, 2025 8:34pm

@coderabbitai

coderabbitaiBot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change unifies machine-token verification method names across the backend package by introducing verify() methods and providing deprecated wrappers (verifyToken, verifyAccessToken, verifySecret) that delegate to verify(). Tests and internal callers were updated and a changeset records the minor version bump.

Changes

Cohort / File(s)Summary
Changeset
.changeset/spotty-wasps-smoke.md
Added a changeset entry bumping @clerk/backend with description "Rename machine auth verification methods".
API endpoints
packages/backend/src/api/endpoints/M2MTokenApi.ts, packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts, packages/backend/src/api/endpoints/APIKeysApi.ts
Added new verify(...) public methods. Added deprecated wrappers verifyToken(...), verifyAccessToken(...), and verifySecret(...) that call verify(...) and emit deprecation warnings.
Token verification logic
packages/backend/src/tokens/verify.ts
Updated callers to use the new verify() methods for M2M, OAuth access tokens, and API keys instead of the old method names.
Tests
packages/backend/src/api/__tests__/M2MTokenApi.test.ts, packages/backend/src/api/__tests__/factory.test.ts
Updated test suites and call sites to invoke apiClient.*.verify(...) instead of the previous method names; expectations and flows unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check each API endpoint for consistent deprecation message formatting and proper deprecated import/use.
  • Verify the deprecated wrappers correctly delegate arguments and return values (including error paths).
  • Ensure all internal call sites (e.g., tokens/verify.ts) match the new signatures and tests reflect intended behavior.

Poem

🐰 I bounced through code with joyful cheer,
Old names whispering, "We'll still be near."
Now verify() hops into the light,
Deprecated friends waved out of sight,
A tidy trail of carrot-coded delight 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe PR title accurately describes the main change: renaming machine auth verification methods across three APIs to unify them under verify().
Linked Issues check✅ PassedThe PR successfully implements all coding requirements from USER-4130: adds verify() methods to APIKeysAPI, M2MTokenApi, and IdPOAuthAccessTokenApi, deprecates existing methods for backwards compatibility, and updates all call sites.
Out of Scope Changes check✅ PassedAll changes are directly related to the objective of renaming verification methods. No out-of-scope changes detected.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rob/user-4130-rename-verification-methods

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (1)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/spotty-wasps-smoke.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-newBot commented Dec 2, 2025

Copy link
Copy Markdown

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7347

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7347

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7347

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7347

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7347

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7347

@clerk/upgrade

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

@clerk/vue

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

commit: c8b3223

@coderabbitaicoderabbitaiBot 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.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)

98-111: Add explicit return type and JSDoc documentation.

This public API method is missing an explicit return type annotation and JSDoc documentation.

As per coding guidelines, apply this diff to add the return type:

- async verify(params: VerifyM2MTokenParams) {+ async verify(params: VerifyM2MTokenParams): Promise<M2MToken> {

Additionally, add JSDoc documentation above the method:

/** * Verifies a machine-to-machine token. * * @param params - The verification parameters including the token and optional machine secret key. * @returns A promise that resolves to the verified M2M token. */asyncverify(params: VerifyM2MTokenParams): Promise<M2MToken>{
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

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

📒 Files selected for processing (7)
  • .changeset/spotty-wasps-smoke.md (1 hunks)
  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts (4 hunks)
  • packages/backend/src/api/__tests__/factory.test.ts (3 hunks)
  • packages/backend/src/api/endpoints/APIKeysApi.ts (2 hunks)
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (1 hunks)
  • packages/backend/src/api/endpoints/M2MTokenApi.ts (3 hunks)
  • packages/backend/src/tokens/verify.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

All code must pass ESLint checks with the project's configuration

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Follow established naming conventions (PascalCase for components, camelCase for variables)

Prefer importing types from @clerk/shared/types instead of the deprecated @clerk/types alias

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
packages/**/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{test,spec}.{ts,tsx,js,jsx}: Unit tests are required for all new functionality
Verify proper error handling and edge cases
Include tests for all new features

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
**/*.{test,spec,e2e}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use real Clerk instances for integration tests

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/api/__tests__/factory.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Implement type guards for unknown types using the pattern function isType(value: unknown): value is Type
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details in classes
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like <T extends { id: string }>
Use utility types like Omit, Partial, and Pick for data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @PARAM, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Use const assertions with as const for literal types
Use satisfies operator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...

Files:

  • packages/backend/src/api/__tests__/M2MTokenApi.test.ts
  • packages/backend/src/tokens/verify.ts
  • packages/backend/src/api/endpoints/APIKeysApi.ts
  • packages/backend/src/api/__tests__/factory.test.ts
  • packages/backend/src/api/endpoints/M2MTokenApi.ts
  • packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
🧬 Code graph analysis (2)
packages/backend/src/api/endpoints/M2MTokenApi.ts (1)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
packages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts (2)
packages/backend/src/api/resources/IdPOAuthAccessToken.ts (1)
  • IdPOAuthAccessToken (3-33)
packages/backend/src/util/shared.ts (1)
  • deprecated (1-1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (32)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 15, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, shared, clerk-js, RQ)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (8)
.changeset/spotty-wasps-smoke.md (1)

1-5: LGTM! Appropriate version bump for this refactoring.

The minor version bump is correct for this change, as new verify() methods are being introduced while old methods remain functional with deprecation warnings.

packages/backend/src/api/__tests__/M2MTokenApi.test.ts (1)

209-284: LGTM! Tests correctly updated to reflect the renamed API surface.

The test updates properly exercise the new verify() method while maintaining comprehensive coverage of success paths, error handling, and authentication requirements.

packages/backend/src/api/__tests__/factory.test.ts (3)

328-332: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method while maintaining coverage of authorization header behavior.


356-360: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method in the machine secret key scenario.


428-432: LGTM! Test correctly updated to use the new API.

The test properly exercises the renamed verify() method when prioritizing machine secret key.

packages/backend/src/tokens/verify.ts (3)

196-207: LGTM! Internal implementation correctly updated.

The verifyM2MToken function properly uses the new verify() method. Error handling and return types remain unchanged.


209-220: LGTM! Internal implementation correctly updated.

The verifyOAuthToken function properly uses the new verify() method. Error handling and return types remain unchanged.


222-233: LGTM! Internal implementation correctly updated.

The verifyAPIKey function properly uses the new verify() method. Error handling and return types remain unchanged.

Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/APIKeysApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/IdPOAuthAccessTokenApi.ts
Comment threadpackages/backend/src/api/endpoints/M2MTokenApi.ts
@wobsoriano
wobsoriano enabled auto-merge (squash) December 2, 2025 21:13
@wobsoriano
wobsoriano merged commit d7c336d into mainDec 2, 2025
76 of 79 checks passed
@wobsoriano
wobsoriano deleted the rob/user-4130-rename-verification-methods branch December 2, 2025 21:19
Sign up for freeto 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

@wobsoriano@tmilewski@clerk-cookie