-
Notifications
You must be signed in to change notification settings - Fork 419
chore(backend): Rename machine auth verification methods #7347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: c8b3223 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis change unifies machine-token verification method names across the backend package by introducing Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (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). (5)
Comment |
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
There was a problem hiding this comment.
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. */ async verify(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.
📒 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.tspackages/backend/src/tokens/verify.tspackages/backend/src/api/endpoints/APIKeysApi.tspackages/backend/src/api/__tests__/factory.test.tspackages/backend/src/api/endpoints/M2MTokenApi.tspackages/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.tspackages/backend/src/tokens/verify.tspackages/backend/src/api/endpoints/APIKeysApi.tspackages/backend/src/api/__tests__/factory.test.tspackages/backend/src/api/endpoints/M2MTokenApi.tspackages/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.tspackages/backend/src/tokens/verify.tspackages/backend/src/api/endpoints/APIKeysApi.tspackages/backend/src/api/__tests__/factory.test.tspackages/backend/src/api/endpoints/M2MTokenApi.tspackages/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/typesinstead of the deprecated@clerk/typesalias
Files:
packages/backend/src/api/__tests__/M2MTokenApi.test.tspackages/backend/src/tokens/verify.tspackages/backend/src/api/endpoints/APIKeysApi.tspackages/backend/src/api/__tests__/factory.test.tspackages/backend/src/api/endpoints/M2MTokenApi.tspackages/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.tspackages/backend/src/tokens/verify.tspackages/backend/src/api/endpoints/APIKeysApi.tspackages/backend/src/api/__tests__/factory.test.tspackages/backend/src/api/endpoints/M2MTokenApi.tspackages/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.tspackages/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.tspackages/backend/src/tokens/verify.tspackages/backend/src/api/endpoints/APIKeysApi.tspackages/backend/src/api/__tests__/factory.test.tspackages/backend/src/api/endpoints/M2MTokenApi.tspackages/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.tspackages/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
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Implement type guards forunknowntypes using the patternfunction isType(value: unknown): value is Type
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details in classes
Useprotectedfor inheritance hierarchies
Usepublicexplicitly 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 likeOmit,Partial, andPickfor 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
Useconst assertionswithas constfor literal types
Usesatisfiesoperator 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.tspackages/backend/src/tokens/verify.tspackages/backend/src/api/endpoints/APIKeysApi.tspackages/backend/src/api/__tests__/factory.test.tspackages/backend/src/api/endpoints/M2MTokenApi.tspackages/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
verifyM2MTokenfunction properly uses the newverify()method. Error handling and return types remain unchanged.
209-220: LGTM! Internal implementation correctly updated.The
verifyOAuthTokenfunction properly uses the newverify()method. Error handling and return types remain unchanged.
222-233: LGTM! Internal implementation correctly updated.The
verifyAPIKeyfunction properly uses the newverify()method. Error handling and return types remain unchanged.
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 testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
New Features
Deprecations
✏️ Tip: You can customize this high-level summary in your review settings.