-
Notifications
You must be signed in to change notification settings - Fork 9
fix(desktop): isolate profile auth schemes #484
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,12 +76,15 @@ export const STORAGE_DIR_NAME = | |
|
|
||
| /** | ||
| * OAuth deep-link protocol (see cloud-auth/client.ts): brand-owned when a brand identity is | ||
| * embedded, split per channel so a development build never fights the installed release over | ||
| * embedded, split per channel and profile so concurrently running identities never fight over | ||
| * the OS-global scheme. | ||
| */ | ||
| export const CLOUD_AUTH_SCHEME = | ||
| const CLOUD_AUTH_SCHEME_BASE = | ||
| BRAND_BASE?.authScheme ?? (CHANNEL === 'development' ? 'linkcode-dev' : 'linkcode'); | ||
|
|
||
| export const CLOUD_AUTH_SCHEME = | ||
| PROFILE === undefined ? CLOUD_AUTH_SCHEME_BASE : `${CLOUD_AUTH_SCHEME_BASE}-${PROFILE}`; | ||
|
Comment on lines
+85
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a packaged release, development-shell, or branded app runs with a profile, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On macOS this scheme can never be registered. Electron's docs are explicit: "you can only register protocols that have been added to your app's Technical details# Profile-suffixed deep-link scheme is unregistrable on macOS
## Affected sites
- `apps/desktop/src/main/constants.ts:85-86` — derives `<base>-<profile>` at launch time; nothing declares it to the OS.
- `apps/desktop/electron-builder.release.yml` / `electron-builder.devshell.yml` — `protocols:` lists only `linkcode` / `linkcode-dev`; these are baked at package time and cannot know the runtime `--profile`.
- `apps/desktop/src/main/cloud-auth/client.ts:59-62` (`claimDeepLink`) and `node_modules/@better-auth/electron/dist/client.mjs` (`registerProtocolScheme`) — both call `app.setAsDefaultProtocolClient`; the latter only `console.error`s on a `false` return.
- `docs/DEVELOPMENT.md:325` — the added claim "OAuth callbacks return to the matching app" does not hold on macOS.
## Required outcome
- A packaged macOS build launched with `--profile=<name>` must either receive its OAuth/billing callback, or fail loudly and predictably rather than dead-ending.
- The docs must not claim per-profile callback routing on a platform where it cannot work.
## Suggested approach (optional)
- Confirm the behavior on a packaged macOS build (`pnpm run package:devshell`, launch with a profile, watch the `setAsDefaultProtocolClient` return value) before choosing a fix — Windows registers at runtime and is unaffected, so this is macOS-specific.
- Options, roughly in increasing cost: keep the base scheme on `darwin` and disambiguate the profile inside the callback URL; declare a small reserved set of profile schemes in the `protocols:` blocks; or scope the suffix to the platforms where runtime registration works and document the macOS limitation.
## Open questions for the human
- Is a packaged macOS build with a profile a supported configuration, or is the profile flow dev-shell/Windows only? |
||
|
|
||
| /** The channel's workspace directory (`~/LinkCode`, `~/LinkCode Development`) — shared across | ||
| * that channel's profiles on purpose, but never across channels (CODE-460). Must agree with the | ||
| * daemon's `chatWorkspaceRoot()`, which derives the same name from its own resolved channel. */ | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
The
-separator is inside the profile charset, so it reintroduces the collision this change exists to remove: release channel +--profile=devyieldslinkcode-dev, byte-identical to the development channel's default scheme (--profile=dev-alphalikewise aliases dev-channel-alpha). Both names passPROFILE_NAME_PATTERN. Every other identity axis picks a separator the profile charset forbids —.for the state dir andAPP_ID,(name)forAPP_NAMEand the keyring service — for exactly this reason.Technical details