-
Notifications
You must be signed in to change notification settings - Fork 461
feat(ui): Brand known OAuth clients on the consent screen #9158
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
Open
alexcarpenter
wants to merge
5
commits into
main
Choose a base branch
from
oauth-consent-claude-logo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+230
−30
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f126dd2
feat(ui): Brand known OAuth clients on the consent screen
alexcarpenter a3c090a
fix(ui): Keep OAuth brand marks out of the shared ui-common chunk
alexcarpenter f45f800
feat(ui): Unify OAuth consent logo container and label brand marks
alexcarpenter 9050952
Apply suggestion from @alexcarpenter
alexcarpenter 38c4632
Merge branch 'main' into oauth-consent-claude-logo
alexcarpenter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@clerk/ui': patch | ||
| --- | ||
|
|
||
| The OAuth consent screen now shows a recognizable brand mark for well-known OAuth clients (Claude, ChatGPT) when the requesting application has not uploaded its own logo. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/ui/src/components/OAuthConsent/__tests__/knownClients.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { getKnownOAuthClient } from '../knownClients'; | ||
|
|
||
| describe('getKnownOAuthClient', () => { | ||
| it('resolves Claude from its registrable domains', () => { | ||
| expect(getKnownOAuthClient('claude.ai')?.name).toBe('Claude'); | ||
| expect(getKnownOAuthClient('claude.com')?.name).toBe('Claude'); | ||
| expect(getKnownOAuthClient('anthropic.com')?.name).toBe('Claude'); | ||
| }); | ||
|
|
||
| it('resolves ChatGPT from its registrable domains', () => { | ||
| expect(getKnownOAuthClient('chatgpt.com')?.name).toBe('ChatGPT'); | ||
| expect(getKnownOAuthClient('openai.com')?.name).toBe('ChatGPT'); | ||
| }); | ||
|
|
||
| it('is case-insensitive and trims surrounding whitespace', () => { | ||
| expect(getKnownOAuthClient(' Claude.AI ')?.name).toBe('Claude'); | ||
| }); | ||
|
|
||
| it('returns undefined for empty, nullish, or unknown domains', () => { | ||
| expect(getKnownOAuthClient('')).toBeUndefined(); | ||
| expect(getKnownOAuthClient(null)).toBeUndefined(); | ||
| expect(getKnownOAuthClient(undefined)).toBeUndefined(); | ||
| expect(getKnownOAuthClient('example.com')).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('does not match a subdomain string that is not the registrable domain', () => { | ||
| // Matching is exact on the PSL-resolved registrable domain, so a look-alike | ||
| // host must not borrow the branding. | ||
| expect(getKnownOAuthClient('claude.ai.evil.com')).toBeUndefined(); | ||
| expect(getKnownOAuthClient('notclaude.ai')).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('provides an icon component for matched clients', () => { | ||
| expect(getKnownOAuthClient('claude.ai')?.icon).toBeDefined(); | ||
| expect(getKnownOAuthClient('chatgpt.com')?.icon).toBeDefined(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // @ts-nocheck | ||
| /** | ||
| * Brand marks for recognized OAuth clients. These live in the component | ||
| * directory (not `src/icons`) on purpose: the `ui-common` rspack cacheGroup | ||
| * captures everything outside `/components`, so keeping them here bundles the | ||
| * marks into the lazy `oauthConsent` chunk instead of the shared chunk that | ||
| * loads on every component. The `@ts-nocheck` mirrors `icons/index.ts`: `.svg` | ||
| * modules are resolved by the bundler (svgr), not by tsc. | ||
| */ | ||
| export { default as Claude } from './claude.svg'; | ||
| export { default as OpenAI } from './openai.svg'; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import type React from 'react'; | ||
|
|
||
| import type { ThemableCssProp } from '@/ui/styledSystem'; | ||
|
|
||
| import { Claude, OpenAI } from './brandIcons'; | ||
|
|
||
| /** | ||
| * A curated OAuth client we can recognize and brand on the consent screen. | ||
| * Matching is keyed on the registrable redirect domain (the trusted, | ||
| * backend-resolved signal), never on the app-owner-set name or homepage. | ||
| */ | ||
| type KnownOAuthClient = { | ||
| name: string; | ||
| icon: React.ComponentType; | ||
| /** | ||
| * Overrides the default badge icon tint. Omit for icons that carry their own | ||
| * fill (e.g. a fixed brand color). | ||
| */ | ||
| iconSx?: ThemableCssProp; | ||
| /** Registrable domains (PSL-resolved) that identify this client. */ | ||
| domains: string[]; | ||
| }; | ||
|
|
||
| const KNOWN_OAUTH_CLIENTS: KnownOAuthClient[] = [ | ||
| { name: 'Claude', icon: Claude, domains: ['claude.ai', 'claude.com', 'anthropic.com'] }, | ||
| { | ||
| name: 'ChatGPT', | ||
| icon: OpenAI, | ||
| iconSx: t => ({ color: t.colors.$colorForeground }), | ||
| domains: ['chatgpt.com', 'openai.com'], | ||
| }, | ||
| ]; | ||
|
|
||
| /** | ||
| * Resolves a known OAuth client from its registrable redirect domain, or | ||
| * `undefined` when the domain is empty or unrecognized. | ||
| */ | ||
| export function getKnownOAuthClient(domain?: string | null): KnownOAuthClient | undefined { | ||
| if (!domain) { | ||
| return undefined; | ||
| } | ||
| const normalized = domain.trim().toLowerCase(); | ||
| return KNOWN_OAUTH_CLIENTS.find(client => client.domains.includes(normalized)); | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
sed -n '500,580p' packages/ui/src/components/OAuthConsent/__tests__/OAuthConsent.test.tsxRepository: clerk/javascript
Length of output: 2681
🏁 Script executed:
Repository: clerk/javascript
Length of output: 2681
🏁 Script executed:
Repository: clerk/javascript
Length of output: 50373
🏁 Script executed:
Repository: clerk/javascript
Length of output: 33642
🏁 Script executed:
Repository: clerk/javascript
Length of output: 50373
🏁 Script executed:
Repository: clerk/javascript
Length of output: 14571
🏁 Script executed:
Repository: clerk/javascript
Length of output: 12052
🏁 Script executed:
Repository: clerk/javascript
Length of output: 7486
🏁 Script executed:
Repository: clerk/javascript
Length of output: 6436
🏁 Script executed:
Repository: clerk/javascript
Length of output: 7493
🏁 Script executed:
Repository: clerk/javascript
Length of output: 6629
🏁 Script executed:
Repository: clerk/javascript
Length of output: 230
🏁 Script executed:
Repository: clerk/javascript
Length of output: 2583
🏁 Script executed:
Repository: clerk/javascript
Length of output: 2530
Drop the
as anycast here.bindCreateFixtures('OAuthConsent')already supplies the component name; pass a typedOAuthConsentPropsvalue for the fixture context instead.🤖 Prompt for AI Agents
Source: Coding guidelines