-
Notifications
You must be signed in to change notification settings - Fork 377
feat(backend): Add TypeDoc comments to OAuth Application endpoints #6378
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
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds five new OAuth application fields across the backend SDK: JSON contract (OAuthApplicationJSON) gains client_uri, client_image_url, dynamically_registered, consent_screen_enabled, and pkce_required. The OAuthApplication class’s constructor is extended to include corresponding readonly properties (clientUri, clientImageUrl, dynamicallyRegistered, consentScreenEnabled, pkceRequired). The fromJSON factory maps the new JSON fields into the constructor before the existing public flag. No other files or logic paths are modified. Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 0
🔭 Outside diff range comments (1)
packages/backend/src/api/resources/OAuthApplication.ts (1)
90-90
: Add explicit return type to public static factoryProject guidelines require explicit return types for public APIs.
-static fromJSON(data: OAuthApplicationJSON) { +static fromJSON(data: OAuthApplicationJSON): OAuthApplication {
🧹 Nitpick comments (6)
packages/backend/src/api/resources/JSON.ts (1)
323-327
: Add TSDoc for the newly added OAuthApplicationJSON fieldsThese types are exported and part of the public API surface. Adding brief comments will improve generated docs and keep parity with the class docs added in OAuthApplication.ts.
Apply something along these lines:
client_id: string; - client_uri: string | null; - client_image_url: string | null; - dynamically_registered: boolean; - consent_screen_enabled: boolean; - pkce_required: boolean; + /** The public-facing URL of the OAuth application, often shown on consent screens. */ + client_uri: string | null; + /** URL to the application's icon/logo. */ + client_image_url: string | null; + /** Whether this application was created via dynamic client registration (RFC 7591). */ + dynamically_registered: boolean; + /** Whether a consent screen is shown in the auth flow. Cannot be disabled for dynamically registered apps. */ + consent_screen_enabled: boolean; + /** Whether PKCE is required for this application. */ + pkce_required: boolean;packages/backend/src/api/resources/OAuthApplication.ts (5)
3-5
: Good addition of the class-level docsNice, concise overview. Consider linking to the BAPI reference for discoverability.
Example tweak:
/** - * The Backend `OAuthApplication` object holds information about an OAuth application. + * The Backend `OAuthApplication` object holds information about an OAuth application. + * See: https://clerk.com/docs/reference/backend-api/tag/oauth-applications */
16-18
: Remove “new” from property descriptionsThese properties describe an OAuth application resource in any state, not just right after creation. The “new” qualifier is misleading.
- * The name of the new OAuth application. + * The name of the OAuth application. @@ - * Scopes for the new OAuth application. + * Scopes configured for the OAuth application. @@ - * An array of redirect URIs of the new OAuth application. + * The list of redirect URIs configured for the OAuth application.Also applies to: 48-51, 52-55
44-47
: Clarify relationship between public clients and PKCEThe current text suggests PKCE can be used if the client is public, which is true but underspecified given the new pkceRequired flag. Tighten the language to avoid confusion.
- * Indicates whether the client is public. If true, the Proof Key of Code Exchange (PKCE) flow can be used. + * Indicates whether the client is public (cannot safely keep a client secret). + * Public clients must use PKCE; confidential clients may also use PKCE.
96-101
: Defensive defaults for newly added fields (back-compat with older backends)If any existing installations don’t yet return these properties, the runtime values would be undefined. Default them to safe values.
- data.client_uri, - data.client_image_url, - data.dynamically_registered, - data.consent_screen_enabled, - data.pkce_required, + data.client_uri ?? null, + data.client_image_url ?? null, + data.dynamically_registered ?? false, + data.consent_screen_enabled ?? false, + data.pkce_required ?? false,If the BAPI guarantees they’re always present, keeping the current mapping is fine. Otherwise, these defaults prevent undefined from leaking into the public API at runtime.
90-113
: Add unit tests for JSON mapping of new fieldsNo tests in this PR. Add a test that feeds an OAuthApplicationJSON with the new fields and asserts the resulting instance properties, plus a test where the new fields are omitted (if you adopt defensive defaults).
I can scaffold a Jest test like:
- constructs a minimal OAuthApplicationJSON,
- calls OAuthApplication.fromJSON,
- asserts clientUri/clientImageUrl/dynamicallyRegistered/consentScreenEnabled/pkceRequired mapping.
Would you like me to draft it?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
packages/backend/src/api/resources/JSON.ts
(1 hunks)packages/backend/src/api/resources/OAuthApplication.ts
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
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
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/backend/src/api/resources/JSON.ts
packages/backend/src/api/resources/OAuthApplication.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/backend/src/api/resources/JSON.ts
packages/backend/src/api/resources/OAuthApplication.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/backend/src/api/resources/JSON.ts
packages/backend/src/api/resources/OAuthApplication.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/backend/src/api/resources/JSON.ts
packages/backend/src/api/resources/OAuthApplication.ts
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{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
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/backend/src/api/resources/JSON.ts
packages/backend/src/api/resources/OAuthApplication.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/backend/src/api/resources/JSON.ts
packages/backend/src/api/resources/OAuthApplication.ts
**/*
⚙️ CodeRabbit Configuration File
If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.
Files:
packages/backend/src/api/resources/JSON.ts
packages/backend/src/api/resources/OAuthApplication.ts
🧬 Code Graph Analysis (1)
packages/backend/src/api/resources/OAuthApplication.ts (1)
packages/backend/src/index.ts (1)
OAuthApplication
(132-132)
⏰ 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). (1)
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (3)
packages/backend/src/api/resources/JSON.ts (1)
323-329
: Confirm backend guarantees for new booleans to avoid runtime undefinedThe interface marks the new flags as required booleans. If any older environments omit them, runtime values can be undefined despite the TS type. Ensure the Backend API always returns these fields; otherwise consider defaulting in the consumer (see fromJSON suggestion) or marking them optional here.
Would you like a follow-up PR to align either JSON defaults or consumer defaults based on the BAPI guarantee?
packages/backend/src/api/resources/OAuthApplication.ts (2)
7-88
: No external instantiations – constructor only used internally
Verified thatnew OAuthApplication(…)
is only called inside the class’s ownfromJSON
method and nowhere else in the codebase. Since there are no external call sites, this change to the positional parameters cannot break consumer code.
7-88
: No change needed: keep barereadonly
per existing convention.We inspected the repository and found that backend resource classes consistently use constructor parameter properties without an explicit
public
modifier. The brief instances ofpublic readonly
are confined to theclerk-js
package, not the backend API resources. To stay aligned with local style, leave the constructor parameters as-is.
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.
seems correct to me! great job :)
@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: |
Description
What does this solve?
Linear: https://linear.app/clerk/issue/DOCS-10504/document-oauth-applications-js-backend-sdk-endpoints
Currently, the clerk docs don't have any information around the OAuth applications JS Backend SDK endpoints. This PR adds documentation for the backend OAuthApplication object type. This PR works in conjunction with this one here: clerk/clerk-docs#2447.
Used the following links for information:
What changed?
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit