Skip to content

feat(dev): add scripts/dev-login.sh — dev-app sign-in without deep links - #216

Closed
Blankll wants to merge 1 commit into
masterfrom
feat/dev-login-script
Closed

Blankll wants to merge 1 commit into
masterfrom
feat/dev-login-script

Conversation

@Blankll

@Blankll Blankll commented Nov 17, 2026

Copy link
Copy Markdown
Member

Problem

npm run tauri dev can never be logged in:

  1. sqlkit:// URL schemes are registered per app bundle — the console's handoff (window.location.href = 'sqlkit://auth?…') always reaches the installed app, never the dev binary (macOS; acknowledged in lib.rs comments).
  2. The dev frontend's WebView localStorage is origin-partitioned (http://localhost:1521 vs the installed app's tauri://localhost), so the persisted login does not carry over either.
  3. The Rust side holds no tokens — every request needs the frontend to pass credentials in, so nothing can be fetched without solving 1/2. Debug builds also default SQLKIT_CONSOLE_API_URL to localhost:5174 (admin vite, no API routes).

Fix

scripts/dev-login.sh bridges the gap through the backend's existing debug-only injection hook (SQLKIT_DEV_AUTH_URL, #[cfg(debug_assertions)]), with two sources sharing one mechanism:

Mode Command Source API target
Prod fast-path scripts/dev-login.sh installed app's WebView localStorage prod console API
Local full-chain scripts/dev-login.sh --api http://localhost:3000 '<sqlkit://auth?…>' pasted handoff link (needs geek-fun/geekfun's new "Copy Link" button + scripts/dev-stack.sh) local console stack

Details:

  • UTF-16LE/BE/UTF-8 decode of WebKit's localStorage account payload; fields URL-encoded (OSS-signed avatar URLs contain &/=)
  • Tokens never printed — they live only in the child process environment; --print-env writes a 0600 sourceable env file instead of launching
  • A pasted link missing token/username/email fails loudly (mirrors parse_auth_from_url) instead of silently logging the app out

Verified

  • paste mode → env file contains the pasted payload + --api target ✓
  • missing-field validation ✓
  • prod extraction → 1321-byte payload against prod API ✓
  • payload shape parses exactly as parse_auth_from_url expects ✓
  • 0600 permissions on env files ✓

Companion PR in geek-fun/geekfun adds the handoff "Copy Link" button and scripts/dev-stack.sh (local postgres+API+admin stack) — together they make the local full-chain flow work end to end.

…p links

`tauri dev` cannot receive the console's sqlkit:// handoff (URL schemes are
registered per app bundle) and the dev frontend's WebView localStorage is
origin-partitioned away from the installed app, so the debug app always
starts logged out and there is no way to complete the login flow in it.

The script bridges that with the backend's debug-only SQLKIT_DEV_AUTH_URL
hook, with two sources sharing one mechanism:

- default: extract the persisted login from the installed production app's
  WebView localStorage (UTF-16LE decode, URL-encode) and target the
  production console API — fast validation of the real entitlement chain;
- paste mode: take a sqlkit://auth?… link copied from the console handoff
  dialog ("Copy Link") and point at a local console stack via --api or
  SQLKIT_CONSOLE_API_URL — full-chain checks against geekfun's
  scripts/dev-stack.sh.

Tokens never reach stdout; they live only in the child process environment.
--print-env writes a sourceable env file (0600) instead of launching.
Missing token/username/email in a pasted link fails loudly (mirrors
parse_auth_from_url) instead of silently logging the app out.
@Blankll

Blankll commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

Retracted — developer tooling should not live in the public repo; keeping it internal.

@Blankll Blankll closed this Nov 17, 2026
@Blankll
Blankll deleted the feat/dev-login-script branch November 17, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant