Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 469
fix(electron,shared,ui): keep Clerk navigation inside the Electron renderer#9530
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
4 commits
Select commit
Hold shift + click to select a range
5fac41b
fix(electron,shared,ui): keep Clerk navigation inside the Electron reβ¦
jeremy-clerk e19feaa
fix(ui): route an OAuth transfer to the sign-up continue step over a β¦
jeremy-clerk efb8fec
test(ui): cover hash stripping in transport sign-up step URLs
jeremy-clerk 2909850
test(e2e): route the electron template through history instead of relβ¦
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,9 @@ | ||
| --- | ||
| '@clerk/electron': patch | ||
| '@clerk/shared': patch | ||
| '@clerk/ui': patch | ||
| --- | ||
| Keep Clerk's navigation inside the renderer. `ClerkProvider` now always supplies `routerPush`/`routerReplace`, so Clerk routes through your application's router when you provide one, and never navigates the window to an internal `/CLERK-ROUTER/VIRTUAL/...` path β which no custom protocol handler can serve, and which reloaded the renderer and dropped the user out of sign-in. | ||
| Applications that worked around this by passing no-op router functions, or by filtering `CLERK-ROUTER/VIRTUAL` out themselves, can remove those workarounds. |
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 | ||
| --- | ||
| Route an OAuth transfer to the sign-up continue step when sign-in uses a native OAuth transport. The callback previously navigated with hash-style URLs (`<sign-up-url>#/continue`) that the in-place component router cannot resolve, landing transferred sign-ups on the start card where submitting created a fresh sign-up without the verified external account. |
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
71 changes: 71 additions & 0 deletions
71 packages/electron/src/react/__tests__/ClerkProvider.test.tsx
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
56 changes: 53 additions & 3 deletions
56 packages/ui/src/components/SignIn/__tests__/buildOAuthCallbackParams.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 |
|---|---|---|
| @@ -55,22 +55,72 @@ describe('buildSignInOAuthTransportCallbackParams', () => { | ||
| unsafeMetadata: { a: 1 }, | ||
| } as any; | ||
| const origin = window.location.origin; | ||
| expect(buildSignInOAuthTransportCallbackParams(ctx)).toEqual({ | ||
| signUpUrl: '/sign-up', | ||
| signInUrl: '/sign-in', | ||
| signInForceRedirectUrl: '/after-in', | ||
| signUpForceRedirectUrl: '/after-up', | ||
| continueSignUpUrl: '/continue', | ||
| transferable: true, | ||
| firstFactorUrl: 'factor-one', | ||
| secondFactorUrl: 'factor-two', | ||
| resetPasswordUrl: 'reset-password', | ||
| // Relative to the SignIn start route; the sign-up gate URL stays absolute (combined-aware). | ||
| signInProtectCheckUrl: 'protect-check', | ||
| signUpProtectCheckUrl: '/sign-up-protect-check', | ||
| // Sign-up steps are path routes on the sign-up component; hash-style URLs would lose their | ||
| // hash in the virtual router and land a transferred sign-up on the start card. | ||
| continueSignUpUrl: `${origin}/sign-up/continue`, | ||
| verifyEmailAddressUrl: `${origin}/sign-up/verify-email-address`, | ||
| verifyPhoneNumberUrl: `${origin}/sign-up/verify-phone-number`, | ||
| signUpProtectCheckUrl: `${origin}/sign-up/protect-check`, | ||
| unsafeMetadata: { a: 1 }, | ||
| }); | ||
| }); | ||
| it('targets the virtual sign-up routes for modal transport callbacks', () => { | ||
| const ctx = { | ||
| signUpUrl: '/CLERK-ROUTER/VIRTUAL/sign-up', | ||
| signInUrl: '/CLERK-ROUTER/VIRTUAL/sign-in', | ||
| } as any; | ||
| const params = buildSignInOAuthTransportCallbackParams(ctx); | ||
| const origin = window.location.origin; | ||
| expect(params.continueSignUpUrl).toBe(`${origin}/CLERK-ROUTER/VIRTUAL/sign-up/continue`); | ||
| expect(params.verifyEmailAddressUrl).toBe(`${origin}/CLERK-ROUTER/VIRTUAL/sign-up/verify-email-address`); | ||
| expect(params.verifyPhoneNumberUrl).toBe(`${origin}/CLERK-ROUTER/VIRTUAL/sign-up/verify-phone-number`); | ||
| expect(params.signUpProtectCheckUrl).toBe(`${origin}/CLERK-ROUTER/VIRTUAL/sign-up/protect-check`); | ||
| }); | ||
| it('drops a hash fragment from signUpUrl when building sign-up step URLs', () => { | ||
| const ctx = { | ||
| signUpUrl: '/sign-up#/continue', | ||
| signInUrl: '/sign-in', | ||
| } as any; | ||
| const params = buildSignInOAuthTransportCallbackParams(ctx); | ||
| const origin = window.location.origin; | ||
| expect(params.continueSignUpUrl).toBe(`${origin}/sign-up/continue`); | ||
| expect(params.verifyEmailAddressUrl).toBe(`${origin}/sign-up/verify-email-address`); | ||
| expect(params.verifyPhoneNumberUrl).toBe(`${origin}/sign-up/verify-phone-number`); | ||
| expect(params.signUpProtectCheckUrl).toBe(`${origin}/sign-up/protect-check`); | ||
| }); | ||
| it('targets the embedded create subtree in the combined flow', () => { | ||
| const ctx = { | ||
| signUpUrl: '/sign-in#/create', | ||
| signInUrl: '/sign-in', | ||
| isCombinedFlow: true, | ||
| } as any; | ||
| const params = buildSignInOAuthTransportCallbackParams(ctx); | ||
| expect(params.continueSignUpUrl).toBe('create/continue'); | ||
| expect(params.verifyEmailAddressUrl).toBe('create/verify-email-address'); | ||
| expect(params.verifyPhoneNumberUrl).toBe('create/verify-phone-number'); | ||
| expect(params.signUpProtectCheckUrl).toBe('create/protect-check'); | ||
| }); | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| }); | ||
| describe('buildSignUpOAuthCallbackParams', () => { | ||
16 changes: 16 additions & 0 deletions
16 packages/ui/src/components/SignIn/buildOAuthCallbackParams.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
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.
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.
Uh oh!
There was an error while loading. Please reload this page.