-
Notifications
You must be signed in to change notification settings - Fork 0
feat(auth): implement browser capture login flow #2
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
zortos293
wants to merge
6
commits into
capy/scaffold-login-my-games
Choose a base branch
from
capy/browser-login-capture-flow
base: capy/scaffold-login-my-games
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.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
42b0c64
Add manual browser capture flow for Boosteroid authentication
zortos293 22c66f5
fix(auth): preserve first-party dev proxy
zortos293 f6a1902
fix(auth): harden browser capture for turnstile
zortos293 dc3589c
feat(auth): add chrome extension capture flow
zortos293 02c3b2c
fix(auth): secure extension capture pairing
zortos293 3e86c08
feat(desktop): pivot to electron-first client
zortos293 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 |
|---|---|---|
| @@ -1,22 +1,36 @@ | ||
| # Frontend: leave empty when the browser should use same-origin requests. | ||
| # Set only when the frontend is deployed separately from the backend bridge. | ||
| # Renderer/frontend API origin. | ||
| # Leave empty in local Electron development so the renderer keeps using | ||
| # first-party `/auth`, `/me`, and `/library` routes and Vite proxies them to | ||
| # the local Electron bridge. | ||
| # Never point this at `https://cloud.boosteroid.com` or any Boosteroid origin. | ||
| # VITE_API_BASE_URL= | ||
|
|
||
| # Cloudflare Turnstile site key. | ||
| # For local development, use the Cloudflare test key that always passes: | ||
| # VITE_TURNSTILE_SITE_KEY=1x00000000000000000000AA | ||
| # For production, leave unset to use the default production key, | ||
| # or set explicitly: | ||
| # VITE_TURNSTILE_SITE_KEY=0x4AAAAAAB83Vz-GpH08brQi | ||
|
|
||
| # Backend bridge configuration. | ||
| # Electron/local bridge configuration. | ||
| # SERVER_PORT=3001 | ||
| # UPSTREAM_BASE_URL=https://cloud.boosteroid.com | ||
| # SESSION_SECRET=replace-with-a-long-random-secret | ||
| # SESSION_COOKIE_NAME=openstroid_session | ||
| # SESSION_TTL_SECONDS=2592000 | ||
| # COOKIE_SECURE=false | ||
| # APP_ORIGIN=http://localhost:3000 | ||
| # APP_ORIGIN=http://127.0.0.1:3000 | ||
| # AUTH_CAPTURE_ARTIFACT_DIR=/absolute/path/to/OpenStroid/.runtime/auth-captures | ||
| # BROWSER_USER_DATA_DIR=/absolute/path/to/OpenStroid/.runtime/browser-profile | ||
| # BROWSER_LOGIN_TIMEOUT_MS=300000 | ||
| # BROWSER_LOGIN_POLL_INTERVAL_MS=1500 | ||
| # BROWSER_LAUNCH_NAVIGATE_TIMEOUT_MS=30000 | ||
| # BROWSER_HEADLESS=false | ||
| # BROWSER_CHANNEL=chrome | ||
| # BROWSER_EXECUTABLE_PATH=/absolute/path/to/chrome-or-chromium | ||
| # BROWSER_LOCALE=en-US | ||
| # BROWSER_LAUNCH_ARGS=--start-maximized | ||
|
|
||
| # Electron development renderer URL. | ||
| # ELECTRON_RENDERER_URL=http://127.0.0.1:3000 | ||
|
|
||
| # Optional: override the Vite dev proxy target if your local bridge runs elsewhere. | ||
| # BACKEND_PROXY_TARGET=http://127.0.0.1:3001 | ||
|
|
||
| # Optional: override the Vite dev proxy target if your backend runs elsewhere. | ||
| # BACKEND_PROXY_TARGET=http://localhost:3001 | ||
| # Chrome extension local dev: | ||
| # - Load unpacked extension from extension/openstroid-capture/ | ||
| # - In the extension popup, keep the backend URL set to http://127.0.0.1:3001 | ||
| # - Paste the pairing code shown in OpenStroid Desktop into the extension popup before logging in |
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 |
|---|---|---|
|
|
@@ -25,3 +25,4 @@ dist-ssr | |
| .env | ||
|
|
||
| build | ||
| .runtime | ||
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,69 @@ | ||
| import type { AddressInfo } from 'node:net'; | ||
| import { app, BrowserWindow, shell } from 'electron'; | ||
| import { startBridgeServer } from '../server/app.js'; | ||
| import { serverConfig } from '../server/config.js'; | ||
|
|
||
| const DEV_RENDERER_URL = process.env.ELECTRON_RENDERER_URL ?? 'http://127.0.0.1:3000'; | ||
|
|
||
| let bridgePort = serverConfig.port; | ||
|
|
||
| function createMainWindow() { | ||
| const window = new BrowserWindow({ | ||
| width: 1440, | ||
| height: 960, | ||
| minWidth: 1100, | ||
| minHeight: 760, | ||
| title: 'OpenStroid', | ||
| autoHideMenuBar: true, | ||
| backgroundColor: '#11131a', | ||
| webPreferences: { | ||
| contextIsolation: true, | ||
| sandbox: true, | ||
| }, | ||
| }); | ||
|
|
||
| window.webContents.setWindowOpenHandler(({ url }) => { | ||
| void shell.openExternal(url); | ||
| return { action: 'deny' }; | ||
| }); | ||
|
|
||
| if (serverConfig.isProduction) { | ||
| void window.loadURL(`http://127.0.0.1:${bridgePort}`); | ||
| } else { | ||
| void window.loadURL(DEV_RENDERER_URL); | ||
| } | ||
| } | ||
|
|
||
| async function bootstrapDesktopApp() { | ||
| const server = startBridgeServer(serverConfig.port); | ||
| const address = server.address(); | ||
| if (address && typeof address !== 'string') { | ||
| bridgePort = (address as AddressInfo).port; | ||
| } | ||
|
|
||
| createMainWindow(); | ||
|
|
||
| app.on('activate', () => { | ||
| if (BrowserWindow.getAllWindows().length === 0) { | ||
| createMainWindow(); | ||
| } | ||
| }); | ||
|
|
||
| app.on('window-all-closed', () => { | ||
| if (process.platform !== 'darwin') { | ||
| app.quit(); | ||
| } | ||
| }); | ||
|
|
||
| app.on('before-quit', () => { | ||
| server.close(); | ||
| }); | ||
| } | ||
|
|
||
| app.whenReady().then(() => { | ||
| app.setName('OpenStroid'); | ||
| if (process.platform === 'win32') { | ||
| app.setAppUserModelId('ai.capy.openstroid'); | ||
| } | ||
| void bootstrapDesktopApp(); | ||
| }); |
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.
[🟡 Medium] [🔵 Bug]
The setup sequence in @README.md is reversed: the pairing code does not exist until the desktop app starts an extension capture (
startLoginCapture('extension')returnsextensionPairingCodeandLoginPageonly renders it after that call succeeds), so a user following these steps literally cannot complete step 7 before step 8. This breaks the primary documented onboarding flow for the extension path. Swap the steps so capture starts first and the pairing code is entered second.