feat: expose getSignInUrl and getSignUpUrl from authkit-js via useClient#75
Conversation
|
Temporary sub-optimal solution: we have vendored out the |
Greptile OverviewGreptile SummaryThis PR exposes two new methods from the underlying The implementation involves two key changes: updating the Important Files Changed
Confidence score: 4/5
Sequence DiagramsequenceDiagram
participant User
participant TauriApp as "Tauri App"
participant AuthKitProvider as "AuthKit Provider"
participant AuthKitJS as "@workos-inc/authkit-js"
participant SystemBrowser as "System Browser"
participant WorkOSAuth as "WorkOS Auth"
User->>TauriApp: "Initiate Sign In"
TauriApp->>AuthKitProvider: "useAuth().getSignInUrl()"
AuthKitProvider->>AuthKitJS: "client.getSignInUrl()"
AuthKitJS-->>AuthKitProvider: "Sign-in URL"
AuthKitProvider-->>TauriApp: "Sign-in URL"
TauriApp->>SystemBrowser: "Open URL in default browser"
SystemBrowser->>WorkOSAuth: "Navigate to WorkOS auth"
User->>WorkOSAuth: "Complete authentication"
WorkOSAuth->>TauriApp: "Redirect to custom URL scheme"
TauriApp->>AuthKitProvider: "Handle redirect callback"
AuthKitProvider->>AuthKitJS: "Process authentication result"
AuthKitJS-->>AuthKitProvider: "User session established"
AuthKitProvider-->>TauriApp: "Authentication complete"
|
There was a problem hiding this comment.
Additional Comments (1)
-
src/provider.tsx, line 134-141 (link)logic: NOOP_CLIENT is missing the newly added
getSignInUrlandgetSignUpUrlmethods. This could cause TypeScript errors or runtime issues during provider initialization.
2 files reviewed, 1 comment
cmatheson
left a comment
There was a problem hiding this comment.
Thanks @K-Mistele, agree we should expose these in authkit-react too.
Context
The following information is provided for context about the problem I am trying to solve, and does not represent shortcomings in the
authkit-reactSDK:I am building a native application using Tauri, which unlike electron does not ship chromium to the user - it uses the system's webview API.
When I call
signIn(), the user is navigated to the WorkOS sign-in page in the Tauri webview, and redirects to the bundled react app on completionNavigating the user to the WorkOS authkit UI in the webview causes several problems:
Problem
We want to solve this issue by redirecting the user from the system's default browser to the user's default browser using tauri's
plugin-opener. However we do not have a way to get the sign-in / sign-up URL viaauthkit-react- we can only callsignIn()orsignUp()which handle the redirect internally to the SDK by settingwindow.location.href.We want to get the URL, and then redirect the user to it in their default browser, and have the callback URL be a custom URL scheme for our app that the app can use to finish the auth flow.
This functionality is available in
authkit-jsviagetSignInUrlandgetSignUpUrl- but for some reason these two methods are not exposed through theuseAuth()hook.Solution
getSignInUrlandgetSignUpUrlthrough theuseAuthhook so that we can get the URL and handle the redirect ourselves.