Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 470
feat(*): add OAuth device verification flow#9518
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
308e8dd
feat(clerk-js,ui,shared,react): add OAuth device verification compone…
jeremy-clerk f1bce47
Merge remote-tracking branch 'origin/main' into jw/oauth-device-verif…
jeremy-clerk 8b52cb7
fix(js): make device verification release-safe
jeremy-clerk aa68708
fix(*): address device verification review feedback
jeremy-clerk a734a12
fix(shared): preserve device decision lock across reset
jeremy-clerk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
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,13 @@ | ||
| --- | ||
| '@clerk/astro': minor | ||
| '@clerk/clerk-js': minor | ||
| '@clerk/localizations': minor | ||
| '@clerk/nextjs': minor | ||
| '@clerk/nuxt': minor | ||
| '@clerk/react': minor | ||
| '@clerk/shared': minor | ||
| '@clerk/ui': minor | ||
| '@clerk/vue': minor | ||
| --- | ||
| Add an authenticated OAuth device verification component and workflow hook for approving or denying OAuth Device Authorization Grant requests. |
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
11 changes: 11 additions & 0 deletions
11 packages/astro/src/astro-components/interactive/OAuthDeviceVerification.astro
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 @@ | ||
| --- | ||
| import type { OAuthDeviceVerificationProps } from '@clerk/shared/types'; | ||
| type Props = OAuthDeviceVerificationProps; | ||
| import InternalUIComponentRenderer from './InternalUIComponentRenderer.astro'; | ||
| --- | ||
| <InternalUIComponentRenderer | ||
| {...Astro.props} | ||
| component='oauth-device-verification' | ||
| /> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { render } from '@testing-library/react'; | ||
| import { afterEach, describe, expect, it, vi } from 'vitest'; | ||
| import { $clerk, $csrState } from '../../stores/internal'; | ||
| import { OAuthDeviceVerification } from '../uiComponents'; | ||
| describe('<OAuthDeviceVerification />', () => { | ||
| afterEach(() => { | ||
| $clerk.set(null); | ||
| $csrState.set({ | ||
| isLoaded: false, | ||
| client: undefined, | ||
| user: undefined, | ||
| session: undefined, | ||
| organization: undefined, | ||
| }); | ||
| }); | ||
| it('updates the mounted component when its appearance changes', () => { | ||
| const mount = vi.fn(); | ||
| const unmount = vi.fn(); | ||
| const updateProps = vi.fn(); | ||
| $clerk.set({ | ||
| __internal_mountOAuthDeviceVerification: mount, | ||
| __internal_unmountOAuthDeviceVerification: unmount, | ||
| __internal_updateProps: updateProps, | ||
| } as any); | ||
| $csrState.set({ | ||
| isLoaded: true, | ||
| client: undefined, | ||
| user: undefined, | ||
| session: undefined, | ||
| organization: undefined, | ||
| }); | ||
| const firstAppearance = {}; | ||
| const secondAppearance = {}; | ||
| const { rerender } = render(<OAuthDeviceVerification appearance={firstAppearance} />); | ||
| rerender(<OAuthDeviceVerification appearance={secondAppearance} />); | ||
| expect(mount).toHaveBeenCalledOnce(); | ||
| expect(updateProps).toHaveBeenCalledOnce(); | ||
| expect(updateProps).toHaveBeenCalledWith({ | ||
| node: expect.any(HTMLDivElement), | ||
| props: { appearance: secondAppearance }, | ||
| }); | ||
| }); | ||
| }); |
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 |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import type { | ||
| GoogleOneTapProps, | ||
| OAuthConsentProps, | ||
| OAuthDeviceVerificationProps, | ||
| OrganizationListProps, | ||
| OrganizationProfileProps, | ||
| OrganizationSwitcherProps, | ||
| @@ -207,3 +208,14 @@ export const OAuthConsent = withClerk(({ clerk, ...props }: WithClerkProp<OAuthC | ||
| /> | ||
| ); | ||
| }, 'OAuthConsent'); | ||
| export const OAuthDeviceVerification = withClerk(({ clerk, ...props }: WithClerkProp<OAuthDeviceVerificationProps>) => { | ||
| return ( | ||
| <Portal | ||
| mount={clerk?.__internal_mountOAuthDeviceVerification} | ||
| unmount={clerk?.__internal_unmountOAuthDeviceVerification} | ||
| updateProps={(clerk as any)?.__internal_updateProps} | ||
| props={props} | ||
| /> | ||
| ); | ||
| }, 'OAuthDeviceVerification'); | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
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
181 changes: 180 additions & 1 deletion
181 packages/clerk-js/src/core/modules/oauthApplication/__tests__/OAuthApplication.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
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Adding this mapping exposes a mixed-version failure in the shared dynamic mount call: its optional chain guards the Clerk object, but it still calls an undefined method when
@clerk/astroruns with a pinned or preloaded ClerkJS version from before this API. That throws insidemountAllClerkAstroJSComponents(), and because mounting runs before function replay and listener registration, one unsupported component aborts the rest of Astro initialization. React already feature-detects this exact case. Could we guard the selected method and add a loaded-old-ClerkJS test so this component no-ops or warns without breaking the remaining Clerk state setup?~ 🤖