-
Notifications
You must be signed in to change notification settings - Fork 371
feat(clerk-js): Link to external App page in OAuth Consent #6447
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
… to support linking to external URL
e.g. http://localhost:4000/oauth-consent?scopes=email&oauth-application-name=Cursor+Chat&redirect_uri=https://google.com&logo-url=https://picsum.photos/48/48&app-url=https://google.com
🦋 Changeset detectedLatest commit: ecaab41 The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 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 Git ↗︎
|
📝 WalkthroughWalkthroughThis PR adds optional linking support for OAuth application data and avatars: an optional oAuthApplicationUrl prop is added to __internal_OAuthConsentProps; sandbox app parses oAuthApplicationUrl and oAuthApplicationLogoUrl from URL params; OAuthConsentInternal consumes oAuthApplicationUrl and passes it to ApplicationLogo to render an external link; ApplicationLogo gains isExternal support and Link primitive now uses rel="noopener noreferrer". A VSCode task for running dev:sandbox was also added. No server-side acceptance, validation, or storage of logo_uri/client_uri is included. Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
🪧 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: 1
🔭 Outside diff range comments (1)
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx (1)
46-51
: Confirm Avatar addsrel="noopener noreferrer"
whentarget="_blank"
Clickable logos point to arbitrary third-party domains. To avoid tab-napping, ensure the underlying
<a>
insideAvatar
setsrel="noopener noreferrer"
alongsidetarget="_blank"
.
If the currentAvatar
implementation does not, please patch it and involve the clerk security team.
🧹 Nitpick comments (3)
packages/clerk-js/sandbox/app.ts (1)
335-337
: Guard against empty query-string values before passing to mountIf
logo-url
orapp-url
are present but empty (?logo-url=&app-url=
), we still forward empty strings.__internal_mountOAuthConsent
will interpret these as “value provided”, which may cause broken<img>
sources or empty<a href>
attributes.- oAuthApplicationLogoUrl: searchParams.get('logo-url'), - oAuthApplicationUrl: searchParams.get('app-url'), + oAuthApplicationLogoUrl: searchParams.get('logo-url') || undefined, + oAuthApplicationUrl: searchParams.get('app-url') || undefined,packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx (1)
20-21
: Discrepancy with new prop: make URL optional in hook typings
oAuthApplicationUrl
is optional but you destructure it without a default.
Ifundefined
,Avatar
will still receive the prop (valueundefined
) which forces a re-render in some scenarios and complicates prop-type checks.Consider eliding when falsy:
- externalLinkUrl={oAuthApplicationUrl} + externalLinkUrl={oAuthApplicationUrl ?? undefined}(or omit the prop entirely via spread).
.changeset/sad-turkeys-rhyme.md (1)
6-9
: Reflect security guidance in the changesetBecause hyperlinks to third-party sites are now rendered, mention that
Avatar
sanitises the URL / addsrel="noopener noreferrer"
. This signals consumers that the patch is safe and intentional.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
.changeset/sad-turkeys-rhyme.md
(1 hunks).vscode/tasks.json
(1 hunks)packages/clerk-js/sandbox/app.ts
(1 hunks)packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
(3 hunks)packages/clerk-js/src/ui/elements/Avatar.tsx
(3 hunks)packages/types/src/clerk.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (11)
**/*.{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/clerk-js/sandbox/app.ts
packages/clerk-js/src/ui/elements/Avatar.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
packages/types/src/clerk.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/clerk-js/sandbox/app.ts
packages/clerk-js/src/ui/elements/Avatar.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
packages/types/src/clerk.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/sandbox/app.ts
packages/clerk-js/src/ui/elements/Avatar.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
packages/types/src/clerk.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/sandbox/app.ts
packages/clerk-js/src/ui/elements/Avatar.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
packages/types/src/clerk.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/clerk-js/sandbox/app.ts
packages/clerk-js/src/ui/elements/Avatar.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
packages/types/src/clerk.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/clerk-js/sandbox/app.ts
packages/clerk-js/src/ui/elements/Avatar.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
packages/types/src/clerk.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.Whenever reviewing a pull request, if there are any changes that could impact security, always tag
@clerk/security
in the PR.Security-impacting changes include, but are not limited to:
- Changes to authentication logic or mechanisms (e.g. login, session handling, token issuance)
- Any modification to access control, authorization checks, or role-based permissions
- Introduction or modification of hashing algorithms, signature verification, or cryptographic primitives
- Handling of sensitive data (e.g. passwords, tokens, secrets, PII)
- Integration with external identity providers (e.g. SSO, OAuth, OpenID Connect)
- Modifications to security headers, cookie flags, CORS policies, or CSRF protections
- Bypass mechanisms (e.g. feature flags, testing overrides) that could weaken protections
- Changes to rate limiting, abuse prevention, or input validation
If you're unsure whether a change is security-relevant, err on the side of caution and tag
@clerk/security
.Any time that you tag
@clerk/security
, please do so explicitly in a code comment, rather than within a collapsed section in a coderabbit comment, such as the "recent review details" section. If you do use the team name in any thinking or non-direct-code-comment content, it can be referred to as "clerk security team" to avoid accidentally printing the tag which sends a notification to the team.
Files:
packages/clerk-js/sandbox/app.ts
packages/clerk-js/src/ui/elements/Avatar.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
packages/types/src/clerk.ts
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}
: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/elements/Avatar.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*.{jsx,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}
: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}
: Always use functional components with hooks instead of class components
Follow PascalCase naming for components:UserProfile
,NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/elements/Avatar.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*.tsx
📄 CodeRabbit Inference Engine (.cursor/rules/react.mdc)
**/*.tsx
: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/elements/Avatar.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
.changeset/**
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Automated releases must use Changesets.
Files:
.changeset/sad-turkeys-rhyme.md
🔇 Additional comments (4)
.vscode/tasks.json (1)
1-13
: VSCode task looks fineTask follows VSCode 2.0 schema and scopes execution correctly to
packages/clerk-js
.
No action required.packages/clerk-js/src/ui/elements/Avatar.tsx (3)
18-22
: LGTM! Clear and comprehensive JSDoc documentation.The JSDoc comment clearly describes the prop's purpose and behavior, including the important detail about opening in a new tab.
36-36
: LGTM! Proper prop destructuring.The destructuring follows the established pattern and is properly typed.
74-84
: Good security practices, but consider additional validation and accessibility improvements.The implementation correctly uses
rel="noopener noreferrer"
for security, which prevents the new page from accessingwindow.opener
and blocks referrer information. The trim check is also a good practice.However, consider these improvements:
Security considerations:
- Add URL validation to ensure only valid, safe URLs are accepted
- Consider sanitizing the URL before using it in
href
to prevent XSS- Since this handles external URLs (OAuth app URLs), validate that URLs use safe protocols (https://)
Accessibility improvements:
- Add
aria-label
ortitle
to indicate this is an external link- Consider adding visual indication for external links
{externalLinkUrl && externalLinkUrl.trim() ? ( <a href={externalLinkUrl} target='_blank' rel='noopener noreferrer' + aria-label={`${title}'s external page (opens in new tab)`} > {ImgOrFallback} </a> ) : ( ImgOrFallback )}
@clerk/security - This change introduces external URL handling in the Avatar component, which will be used for OAuth application URLs. Please review the security implications of accepting external URLs without validation.
@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: |
add noreferrer to Link because it is undesirable to share all the consent query params
and just apply isExternal if the link is absolute so this is more flexible
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/clerk-js/src/ui/primitives/Link.tsx (1)
61-67
: Add protocol sanitization to Link’s href for external linksThe
Link
primitive currently rendershref
unfiltered, so maliciousjavascript:
,data:
or other unsafe schemes could slip through whenisExternal
is true. We should leverage the existing utilities inpackages/clerk-js/src/utils/url.ts
to block non-http(s) protocols:• Import and use
hasBannedProtocol
andisDataUri
(orisProblematicUrl
) fromutils/url.ts
.
• Compute a “safe” href before rendering and fall back toundefined
or'#'
if the URL is unsafe.
• Only applytarget="_blank"
/rel="noopener noreferrer"
when the sanitized URL passes the checks.Example diff inside
packages/clerk-js/src/ui/primitives/Link.tsx
:import React from 'react'; +import { hasBannedProtocol, isDataUri } from '../../utils/url'; export const Link = (props: LinkProps): JSX.Element => { const { isExternal, children, href, onClick, ...rest } = props; + // Block unsafe external URL schemes + const safeHref = + href && isExternal && (hasBannedProtocol(href) || isDataUri(href)) + ? undefined + : href; const onClickHandler = onClick ? (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {And update the JSX:
- <a - href={href || ''} + <a + href={safeHref || ''} target={href && isExternal ? '_blank' : undefined} rel={href && isExternal ? 'noopener noreferrer' : undefined}This ensures that any
javascript:
ordata:
URLs are never set on external links.
🧹 Nitpick comments (1)
packages/clerk-js/src/ui/primitives/Link.tsx (1)
61-67
: Optional hardening: add referrerPolicy for explicit no‑referrer behaviorWhile rel="noreferrer" is widely supported, explicitly setting referrerPolicy improves clarity and coverage.
Apply this minimal addition:
target={href && isExternal ? '_blank' : undefined} - rel={href && isExternal ? 'noopener noreferrer' : undefined} + rel={href && isExternal ? 'noopener noreferrer' : undefined} + referrerPolicy={href && isExternal ? 'no-referrer' : undefined}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
(3 hunks)packages/clerk-js/src/ui/elements/Avatar.tsx
(4 hunks)packages/clerk-js/src/ui/primitives/Link.tsx
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
- packages/clerk-js/src/ui/elements/Avatar.tsx
🧰 Additional context used
📓 Path-based instructions (10)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}
: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/primitives/Link.tsx
**/*.{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/clerk-js/src/ui/primitives/Link.tsx
**/*.{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/clerk-js/src/ui/primitives/Link.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/primitives/Link.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/primitives/Link.tsx
**/*.{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/clerk-js/src/ui/primitives/Link.tsx
**/*.{jsx,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}
: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}
: Always use functional components with hooks instead of class components
Follow PascalCase naming for components:UserProfile
,NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/primitives/Link.tsx
**/*.{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/clerk-js/src/ui/primitives/Link.tsx
**/*.tsx
📄 CodeRabbit Inference Engine (.cursor/rules/react.mdc)
**/*.tsx
: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/primitives/Link.tsx
**/*
⚙️ 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/clerk-js/src/ui/primitives/Link.tsx
⏰ 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: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
packages/clerk-js/src/ui/primitives/Link.tsx (1)
66-66
: Add rel="noopener noreferrer" for external links — correct and securePrevents reverse‑tabnabbing and suppresses Referer. Matches best practices for target=_blank external links.
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
(3 hunks)packages/clerk-js/src/ui/primitives/Link.tsx
(1 hunks)packages/types/src/clerk.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/types/src/clerk.ts
- packages/clerk-js/src/ui/primitives/Link.tsx
🧰 Additional context used
📓 Path-based instructions (10)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}
: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*.{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/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*.{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/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*.{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/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*.{jsx,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}
: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}
: Always use functional components with hooks instead of class components
Follow PascalCase naming for components:UserProfile
,NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*.{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/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*.tsx
📄 CodeRabbit Inference Engine (.cursor/rules/react.mdc)
**/*.tsx
: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*
⚙️ 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/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
⏰ 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: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx (1)
49-51
: No change needed for ApplicationLogo’shref
propThe
ApplicationLogo
component is designed to accept anhref
prop and wrap the logo image in your internalRouterLink
implementation—not theAvatar
component—so there is nolinkUrl
API to forward. You can safely ignore the earlier suggestion to rename or map this prop.Likely an incorrect or invalid review comment.
const { scopes, oAuthApplicationName, oAuthApplicationLogoUrl, oAuthApplicationUrl, redirectUrl, onDeny, onAllow } = | ||
useOAuthConsentContext(); |
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.
💡 Verification agent
🧩 Analysis chain
Plumbed oAuthApplicationUrl: confirm typing, sanitization, and policy gating (USER-2011).
Looks good functionally. Please verify:
- Types:
__internal_OAuthConsentProps
anduseOAuthConsentContext
includeoAuthApplicationUrl?: string
. - Security: Only http(s) URLs allowed; no
javascript:
/data:
protocols. - Policy: UI should only receive/show
client_uri
after server-side origin validation againstredirect_uris
(per USER-2011). If not guaranteed upstream, gate display in UI.
Also add tests: with/without URL, absolute vs relative URL, external link opens in new tab with rel="noopener noreferrer"
.
I can add tests and/or a UI guard that hides the link unless http(s)
and policy-validated. Want me to push a patch?
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Confirm types expose oAuthApplicationUrl
rg -n --hidden --glob '!node_modules' 'oAuthApplicationUrl\??:\s*string' packages
# 2) Inspect OAuth consent context to ensure it provides the field
rg -n --hidden --glob '!node_modules' 'useOAuthConsentContext|OAuthConsentContext' packages -A 10
# 3) Check Link/Avatar to ensure only http(s) are allowed and external links use noopener+noreferrer
fd -a 'Link.tsx' packages | xargs -I{} sh -c 'echo "== {};"; rg -n "target|rel|noreferrer|noopener|http|https|javascript:" "{}" -n -A 5 -B 3'
fd -a 'Avatar.tsx' packages | xargs -I{} sh -c 'echo "== {};"; rg -n "linkUrl|Link" "{}" -n -A 10 -B 5'
# 4) Search server/registration code for client_uri origin validation against redirect_uris
rg -n --hidden --glob '!node_modules' 'client_uri|clientUri|oAuthApplicationUrl|redirect_uris|origin|validate' -S
Length of output: 7147
We need to inspect how oAuthApplicationUrl is consumed in OAuthConsent.tsx. Let’s pull its usage context:
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n 'oAuthApplicationUrl' -A5 -B5 packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
Length of output: 1593
Enforce URL Protocol Sanitization and Confirm Server-Side Validation
Even though the new oAuthApplicationUrl?: string
prop is correctly typed and the Link
primitive handles target
/rel
for external URLs, we still need to:
• Prevent malicious schemes (e.g. javascript:
/data:
) in the UI
• Ensure the authorization server has validated client_uri
against the registered redirect_uris
Please update packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
around the two <ApplicationLogo … href={oAuthApplicationUrl} />
usages (lines 49–50 and 66–69):
- Add a local guard that only allows
http://
orhttps://
URLs:const { oAuthApplicationLogoUrl, oAuthApplicationName, oAuthApplicationUrl, ... } = useOAuthConsentContext();
-
const isValidOAuthUrl =
-
oAuthApplicationUrl?.startsWith('http://') ||
-
oAuthApplicationUrl?.startsWith('https://'); // …inside JSX… <ApplicationLogo src={oAuthApplicationLogoUrl} alt={oAuthApplicationName}
-
href={oAuthApplicationUrl}
-
href={isValidOAuthUrl ? oAuthApplicationUrl : undefined} />
2. Confirm and document that the backend enforces origin validation of `client_uri` against the registered `redirect_uris`. If this isn’t already guaranteed, gate the UI link behind that same policy flag.
- Add unit/visual tests for:
- No URL vs. valid HTTP vs. malformed/relative URLs
- External links opening in a new tab with
rel="noopener noreferrer"
🤖 Prompt for AI Agents
In packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx around the
two ApplicationLogo href usages (lines 49–50 and 66–69), the UI must guard
against malicious URL schemes and document backend validation; add a local
sanitizer that only allows href values that start with "http://" or "https://"
(otherwise pass undefined so the logo is not a link), ensure external links use
target="_blank" and rel="noopener noreferrer", and add a comment noting that the
authorization server must validate client_uri against registered redirect_uris
(if the server does not already enforce this, gate the UI link behind the same
server-side policy flag). Also add unit/visual tests covering: no URL, valid
http(s) URL, malformed/relative URL, and that external links open in a new tab
with rel="noopener noreferrer".
…fely open the link in a new window
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: 1
🔭 Outside diff range comments (4)
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx (3)
102-105
: Add JSDoc for the new localization stringsThe component uses hardcoded strings in the Header.Subtitle that should be properly localized. According to the coding guidelines, all user-facing strings must use localization methods.
Update the localization approach:
<Header.Subtitle - localizationKey={`wants to access ${applicationName} on behalf of ${primaryEmailAddress}`} + localizationKey='oauthConsent.subtitle' + localizationOptions={{ applicationName, userEmail: primaryEmailAddress }} />
128-129
: Replace template literals with proper localization keysThese strings use template literals instead of proper localization keys, violating the guideline that all user-facing strings must be localized using provided localization methods.
Replace with proper localization keys:
<Text variant='subtitle' - localizationKey={`This will allow ${oAuthApplicationName} access to:`} + localizationKey='oauthConsent.scopesIntro' + localizationOptions={{ appName: oAuthApplicationName }} /> <Header.Subtitle - localizationKey={`Make sure you trust ${oAuthApplicationName} and that this URL belongs to ${oAuthApplicationName}.`} + localizationKey='oauthConsent.redirectUrlWarning' + localizationOptions={{ appName: oAuthApplicationName }} />Also applies to: 287-289
19-262
: Add comprehensive tests for OAuthConsentInternalThere are currently no existing specs covering the OAuth consent component. Please add unit tests to cover:
- Rendering consent flow with valid
http
/https
redirect URLs- Handling invalid or malicious
redirectUrl
(no external link rendered)- Behavior when no URL is provided (static logo only)
- External application links opening with
target="_blank"
andrel="noopener noreferrer"
- All avatar scenarios:
- Both OAuth app & Clerk app logos present
- Only OAuth app logo
- Only Clerk app logo
- Neither logo present
packages/clerk-js/src/ui/elements/ApplicationLogo.tsx (1)
25-44
: Add tests for ApplicationLogo’s external/internal link logicNo existing tests reference
ApplicationLogo
underpackages/clerk-js/src
. Please create a new test file alongside the component, for example:
- packages/clerk-js/src/ui/elements/ApplicationLogo.test.tsx
Include the following scenarios:
isExternal=true
renders<Link>
withtarget="_blank"
andrel="noopener noreferrer"
isExternal=false
(or undefined) renders<RouterLink>
- Both cases properly pass through
href
,src
, andalt
props
♻️ Duplicate comments (1)
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx (1)
20-21
: Add URL sanitization to prevent malicious schemesThe
oAuthApplicationUrl
is directly passed toApplicationLogo
without validation. This could allow malicious schemes likejavascript:
ordata:
URLs to be executed when users click the logo.As noted in the previous review, add URL protocol validation:
export function OAuthConsentInternal() { const { scopes, oAuthApplicationName, oAuthApplicationLogoUrl, oAuthApplicationUrl, redirectUrl, onDeny, onAllow } = useOAuthConsentContext(); + const isValidOAuthUrl = + oAuthApplicationUrl?.startsWith('http://') || + oAuthApplicationUrl?.startsWith('https://');Then update the
href
prop usage in lines 49-50 and 70-71:- href={oAuthApplicationUrl} + href={isValidOAuthUrl ? oAuthApplicationUrl : undefined}
🧹 Nitpick comments (2)
packages/clerk-js/src/ui/elements/ApplicationLogo.tsx (2)
38-43
: Improve JSDoc documentation for the new isExternal propThe JSDoc is clear but could be more specific about the security implications and relationship to the
href
prop.Enhance the documentation:
/** + * Whether the href should be treated as an external link. - * When true, uses a Link component with target="_blank" and proper security attributes. + * When true, uses a Link component with target="_blank" and rel="noopener noreferrer" for security. - * When false or undefined, uses RouterLink for internal navigation. + * When false or undefined, uses RouterLink for internal navigation within the application. + * Only takes effect when href is provided. */ isExternal?: boolean;
90-105
: Consider extracting logo link logic into a helper componentThe conditional rendering logic for external vs internal links could be extracted into a reusable component to improve readability and maintainability.
Consider creating a helper component:
+const LogoLink: React.FC<{ + logoUrl: string; + isExternal?: boolean; + children: React.ReactNode +}> = ({ logoUrl, isExternal, children }) => { + return isExternal ? ( + <Link focusRing href={logoUrl} isExternal> + {children} + </Link> + ) : ( + <RouterLink focusRing to={logoUrl}> + {children} + </RouterLink> + ); +}; return ( <Flex elementDescriptor={descriptors.logoBox} {...rest} sx={[...]} > {logoUrl ? ( - isExternal ? ( - <Link focusRing href={logoUrl} isExternal> - {image} - </Link> - ) : ( - <RouterLink focusRing to={logoUrl}> - {image} - </RouterLink> - ) + <LogoLink logoUrl={logoUrl} isExternal={isExternal}> + {image} + </LogoLink> ) : ( image )} </Flex> );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
(3 hunks)packages/clerk-js/src/ui/elements/ApplicationLogo.tsx
(3 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}
: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/elements/ApplicationLogo.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*.{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/clerk-js/src/ui/elements/ApplicationLogo.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*.{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/clerk-js/src/ui/elements/ApplicationLogo.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/elements/ApplicationLogo.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/elements/ApplicationLogo.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*.{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/clerk-js/src/ui/elements/ApplicationLogo.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*.{jsx,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}
: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}
: Always use functional components with hooks instead of class components
Follow PascalCase naming for components:UserProfile
,NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/elements/ApplicationLogo.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*.{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/clerk-js/src/ui/elements/ApplicationLogo.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*.tsx
📄 CodeRabbit Inference Engine (.cursor/rules/react.mdc)
**/*.tsx
: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/elements/ApplicationLogo.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
**/*
⚙️ 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/clerk-js/src/ui/elements/ApplicationLogo.tsx
packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx
🧬 Code Graph Analysis (1)
packages/clerk-js/src/ui/elements/ApplicationLogo.tsx (1)
packages/clerk-js/src/ui/primitives/Link.tsx (1)
Link
(57-81)
⏰ 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: Build Packages
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
packages/clerk-js/src/ui/elements/ApplicationLogo.tsx (1)
47-47
: LGTM! Well-implemented external link supportThe implementation correctly:
- Adds the
isExternal
prop to control link behavior- Uses conditional rendering to choose between
Link
(external) andRouterLink
(internal)- Passes
focusRing
to both link types for accessibility- Maintains backward compatibility when
isExternal
is not providedThe external links will benefit from the security attributes (
rel="noopener noreferrer"
) implemented in theLink
primitive.Also applies to: 90-105
href={oAuthApplicationUrl} | ||
isExternal |
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.
Security concern: Unsanitized external URL usage
The oAuthApplicationUrl
is passed directly as href
without validation. According to the PR objectives and USER-2011 requirements, the client_uri should be validated server-side against redirect_uris origins, and the UI should implement additional safety measures.
Apply this security fix:
export function OAuthConsentInternal() {
const { scopes, oAuthApplicationName, oAuthApplicationLogoUrl, oAuthApplicationUrl, redirectUrl, onDeny, onAllow } =
useOAuthConsentContext();
+ // Sanitize OAuth application URL to prevent malicious schemes
+ // Note: Server must validate client_uri origin against registered redirect_uris per USER-2011
+ const isValidOAuthUrl =
+ oAuthApplicationUrl?.startsWith('http://') ||
+ oAuthApplicationUrl?.startsWith('https://');
+ const sanitizedOAuthUrl = isValidOAuthUrl ? oAuthApplicationUrl : undefined;
// Update both ApplicationLogo instances (lines 49-50 and 70-71)
- href={oAuthApplicationUrl}
+ href={sanitizedOAuthUrl}
Also applies to: 70-71
Description
Add support for a Link URL to
<Avatar>
which will wrap the image in an anchor tag.If the given link is absolute, it will open the link in a new window.
Attribute
rel="noopener noreferrer"
is applied to the external link to avoid (in legacy browsers) passing an opener object to the target page, and to avoid sharing sensitive query string parameters.Wire the
Avatar.linkUrl
up to OAuth Application URL so that users can click the Logo of the OAuth App to navigate to the App's homepage.Test in sandbox
http://localhost:4000/oauth-consent?app-url=https%3A%2F%2Fclerk.com&logo-url=http%3A%2F%2Flocalhost%3A3000%2Flogo
Part of USER-2011
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit