Local web dev previously required scraping a one-time, 5-minute /pair#token URL from dev-runner stdout for every fresh browser context, which made parallel-instance work and agent browser verification painful. The web app now authenticates automatically against eligible dev servers via a guarded dev-only endpoint. Server: POST /api/auth/dev-pairing-token mints a one-time administrative credential (subject dev-auto-bootstrap, hidden from pairing-link listings) only when the server is web-mode, loopback-bound (loopback-browser policy), and configured with a loopback dev URL. Requests must carry an Origin exactly matching the dev origin (survives the Vite proxy, unlike Host) and a loopback Host header (DNS-rebinding defense). Ineligible configs answer an explicit 404 — the handler is always mounted so the SPA/redirect wildcard can't shadow it. Startup: eligible dev servers now open the plain dev URL instead of minting a startup pairing credential the silent path would leave unconsumed in the URL and scrollback. Web: the auth-gate bootstrap silently tries the endpoint when unauthenticated in dev (never in hosted/desktop contexts, never when an explicit #token is present) and falls back to the pairing screen on any failure. import.meta.env.DEV keeps the request out of prod bundles. Extracted host parsing into netHost.ts (auth/http.ts importing the old helper from http.ts would have been a module cycle; the old helper also mishandled Host headers with ports). Docs: AGENTS.md browser-verification section, dev-instance auth notes in scripts.md (plus stale T3CODE_STATE_DIR fix), and a security spec in environment-auth.md. Co-Authored-By: Claude Fable 5 <[email protected]>
57 lines
3.5 KiB
Markdown
57 lines
3.5 KiB
Markdown
# Scripts
|
|
|
|
- `bun run dev` — Starts contracts, server, and web in `turbo watch` mode.
|
|
- `bun run dev:server` — Starts just the WebSocket server (uses Bun TypeScript execution).
|
|
- `bun run dev:web` — Starts just the Vite dev server for the web app.
|
|
- Dev servers store state under `<T3CODE_HOME>/dev` (default `~/.t3/dev`) to keep dev state isolated from desktop/prod state.
|
|
- Override server CLI-equivalent flags from root dev commands with `--`, for example:
|
|
`bun run dev -- --base-dir ~/.t3-2`
|
|
- `bun run start` — Runs the production server (serves built web app as static files).
|
|
- `bun run build` — Builds contracts, web app, and server through Turbo.
|
|
- `bun run typecheck` — Strict TypeScript checks for all packages.
|
|
- `bun run test` — Runs workspace tests.
|
|
- `bun run dist:desktop:artifact -- --platform <mac|linux|win> --target <target> --arch <arch>` — Builds a desktop artifact for a specific platform/target/arch.
|
|
- `bun run dist:desktop:dmg` — Builds a shareable macOS `.dmg` into `./release`.
|
|
- `bun run dist:desktop:dmg:x64` — Builds an Intel macOS `.dmg`.
|
|
- `bun run dist:desktop:linux` — Builds a Linux AppImage into `./release`.
|
|
- `bun run dist:desktop:win` — Builds a Windows NSIS installer into `./release`.
|
|
|
|
## Desktop `.dmg` packaging notes
|
|
|
|
- Default build is unsigned/not notarized for local sharing.
|
|
- The DMG build uses `assets/macos-icon-1024.png` as the production app icon source.
|
|
- Desktop production windows load the bundled UI from `t3code://app/index.html` (not a `127.0.0.1` document URL).
|
|
- Desktop packaging includes `apps/server/dist` (the `t3` backend) and starts it on loopback with an auth token for WebSocket/API traffic.
|
|
- Your tester can still open it on macOS by right-clicking the app and choosing **Open** on first launch.
|
|
- To keep staging files for debugging package contents, run: `bun run dist:desktop:dmg -- --keep-stage`
|
|
- To allow code-signing/notarization when configured in CI/secrets, add: `--signed`.
|
|
- Signed macOS builds also require `T3CODE_APPLE_TEAM_ID` and
|
|
`T3CODE_MACOS_PROVISIONING_PROFILE`. The passkey RP domain is derived from
|
|
`T3CODE_CLERK_PUBLISHABLE_KEY` unless `T3CODE_CLERK_PASSKEY_RP_DOMAINS` overrides it.
|
|
- Windows `--signed` uses Azure Trusted Signing and expects:
|
|
`AZURE_TRUSTED_SIGNING_ENDPOINT`, `AZURE_TRUSTED_SIGNING_ACCOUNT_NAME`,
|
|
`AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME`, and `AZURE_TRUSTED_SIGNING_PUBLISHER_NAME`.
|
|
- Azure authentication env vars are also required (for example service principal with secret):
|
|
`AZURE_TENANT_ID`, `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`.
|
|
|
|
## Running multiple dev instances
|
|
|
|
Set `T3CODE_DEV_INSTANCE` to any value to deterministically shift all dev ports together.
|
|
|
|
- Default ports: server `3773`, web `5733`
|
|
- Shifted ports: `base + offset` (offset is hashed from `T3CODE_DEV_INSTANCE`)
|
|
- Example: `T3CODE_DEV_INSTANCE=branch-a bun run dev:desktop`
|
|
|
|
If you want full control instead of hashing, set `T3CODE_PORT_OFFSET` to a numeric offset.
|
|
|
|
### Authentication across dev instances
|
|
|
|
Local web-dev servers support silent pairing: the web app authenticates
|
|
automatically on load, with no pairing code (see the dev-mode section in
|
|
`docs/cloud/environment-auth.md` for the guards). Additionally, all dev
|
|
instances sharing a `T3CODE_HOME` share the session store and signing secret
|
|
under `<T3CODE_HOME>/dev`, so a browser session created against one instance
|
|
verifies against every other. Cookies are host-scoped: sessions carry across
|
|
ports on the same hostname, but `localhost` and `127.0.0.1` do not share
|
|
cookies — use one hostname consistently.
|