Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

connect-setup.md

138 lines6.2 KB

1# T3 Connect setup
2​
3Deployment and client configuration for T3 Connect. The [architecture note](../internals/t3-connect.md)
4explains the trust boundaries; the [relay README](../../infra/relay/README.md#deployment) owns relay
5provisioning instructions.
6​
7## Public application configuration
8​
9T3 Connect is disabled in a fresh clone. To build against the production deployment, copy the
10repository-root example:
11​
12```sh
13cp .env.example .env
14```
15​
16For another deployment, set these values in the repository-root `.env` or `.env.local`:
17​
18```dotenv
19T3CODE_CLERK_PUBLISHABLE_KEY=<publishable key>
20T3CODE_CLERK_JWT_TEMPLATE=<JWT template name>
21T3CODE_CLERK_CLI_OAUTH_CLIENT_ID=<public OAuth application client ID>
22T3CODE_RELAY_URL=https://relay.example.com
23```
24​
25Process variables take precedence over `.env.local`, then `.env`. Use these canonical names;
26the build loader supplies framework-specific aliases. These values are public identifiers.
27`CLERK_SECRET_KEY` belongs only in the relay's secrets, never in client configuration.
28​
29Client and bundled-server builds embed the public values, so set them before building.
30EAS preview and production environments need the publishable key, JWT template name, and relay URL.
31Bundled servers also accept runtime overrides for operator-managed deployments.
32​
33Copy `infra/relay/.env.example` to `infra/relay/.env` for relay deployment settings.
34Deploy `prod` before personal stages because it owns the retained database that their branches
35depend on. The deploy wrapper writes the resulting relay URL back to the root `.env`.
36​
37## CLI OAuth application
38​
39In Clerk's OAuth applications settings:
40​
411. Create a public OAuth application for the T3 CLI, using authorization-code exchange with PKCE.
422. Allow both redirect URIs: `http://127.0.0.1:34338/callback` and
43 `https://app.t3.codes/connect/callback`. A custom `T3CODE_HOSTED_APP_URL` needs its own
44 `/connect/callback` URL. Headless and SSH authorization depend on the hosted redirect.
453. Enable the `openid`, `profile`, and `email` scopes.
464. Set `T3CODE_CLERK_CLI_OAUTH_CLIENT_ID` to the generated public client ID in local and release
47 build environments.
48​
49## JWT template
50​
51Create a Clerk JWT template named `t3-relay` with claims:
52​
53```json
54{ "aud": "t3-code-relay" }
55```
56​
57Set `T3CODE_CLERK_JWT_TEMPLATE=t3-relay` for clients and
58`CLERK_JWT_AUDIENCE=t3-code-relay` for the relay. The production relay deployment environment
59also defines `CLERK_JWT_TEMPLATE`. The audience stays the same across relay stages; the relay
60URL selects the deployment.
61​
62## Desktop OAuth redirects
63​
64Enable Clerk's Native API and add the desktop redirects to its SSO redirect allowlist:
65​
66```text
67t3code-dev://app/
68t3code://app/
69```
70​
71Add the corresponding origin to the Clerk instance's Backend API `allowed_origins` array.
72Development uses `t3code-dev://app`; production uses `t3code://app`. Update the array with
73`PATCH https://api.clerk.com/v1/instance` using the Clerk secret key, preserving existing entries.
74The Clerk Electron integration handles token
75persistence and system-browser callback delivery.
76​
77## Android native sign-in redirects
78​
79Clerk's native Android SDK uses `clerk://<applicationId>.callback`. In the Clerk instance selected by the app's publishable key, add each supported package to **Native applications > Allowlist for mobile SSO redirect**:
80​
81| Variant | Callback |
82| ----------- | --------------------------------------------- |
83| Development | `clerk://com.t3tools.t3code.dev.callback` |
84| Preview | `clerk://com.t3tools.t3code.preview.callback` |
85| Production | `clerk://com.t3tools.t3code.callback` |
86​
87Preserve existing entries. These callbacks are separate from the `t3code-dev` / `t3code-preview` / `t3code` navigation schemes. A private development build using the production Clerk key still needs its development callback allowed by that instance's administrator; rebuilding the same package does not change the allowlist.
88​
89## Desktop passkeys
90​
91For a production macOS app with bundle ID `com.t3tools.t3code`:
92​
931. Create an explicit macOS App ID in the Apple Developer portal with **Associated Domains**.
942. Create a provisioning profile for that App ID and the distribution signing certificate.
953. In Clerk's Native API settings, add an iOS app with the same Apple Team ID and bundle ID.
96 This setting also configures Electron/macOS passkeys.
974. Check `https://<frontend-api>/.well-known/apple-app-site-association`. Its
98 `webcredentials.apps` must include `<TEAM_ID>.com.t3tools.t3code`.
995. Configure signing as described in the [release runbook](./release.md#2-apple-signing--notarization-setup-macos).
100​
101Local signed builds additionally use:
102​
103```dotenv
104T3CODE_APPLE_TEAM_ID=ABC1234567
105T3CODE_MACOS_PROVISIONING_PROFILE=/absolute/path/to/t3code.provisionprofile
106# Override only when the RP domain differs from the Clerk Frontend API hostname.
107T3CODE_CLERK_PASSKEY_RP_DOMAINS=example.clerk.accounts.dev,clerk.example.com
108```
109​
110Without the override, the build derives the RP domain from the Clerk publishable key.
111After changing Associated Domains, bump the build version before rebuilding. macOS can otherwise
112reuse stale Shared Web Credentials metadata for the same app/version pair.
113​
114The ordinary `dev:desktop` launcher is unsigned and cannot exercise macOS passkeys. For renderer
115HMR, install a signed build, start `vp run dev:web`, and launch the installed executable with the
116actual web and server ports. For example, with the default ports:
117​
118```sh
119VITE_DEV_SERVER_URL=http://127.0.0.1:5733 \
120T3CODE_PORT=13773 \
121 "/Applications/T3 Code (Alpha).app/Contents/MacOS/T3 Code (Alpha)"
122```
123​
124Rebuild the signed app after native dependency, main-process, preload, entitlement, provisioning,
125or signing changes. Renderer edits can reuse it. Verify the installed bundle before testing:
126​
127```sh
128codesign --verify --deep --strict "/Applications/T3 Code (Alpha).app"
129codesign -d --entitlements :- "/Applications/T3 Code (Alpha).app"
130```
131​
132## Restricting sign-ups
133​
134Use Clerk's allowlist for permitted email addresses or domains, or Restricted mode for invitation-only
135sign-up. An enabled empty allowlist blocks all new sign-ups.
136​
137Sign-up restrictions do not revoke an existing account's access. Ban the account in Clerk when
138its active sessions and future sign-ins must be disabled.