Skip to content

Commit b1bc0cf

Browse files
committed
feat: route auth by deployment destination
1 parent bebda93 commit b1bc0cf

45 files changed

Lines changed: 452 additions & 100 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/guide/platform/administration/access.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Cloudflare applications for deliberate cleanup. Disabling an Access login method
107107
does not remove the gate.
108108

109109
Users can add another enabled login to their existing account with
110-
`void auth link <connection-id>` or **Account** in the optional
110+
`void account link <connection-id>` or **Account** in the optional
111111
dashboard. Sign in again first if prompted, then authenticate with the additional
112112
provider and confirm the identity shown. Matching email addresses alone do not
113113
link accounts.

‎docs/guide/project-collaboration.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ and run `void project link`.
7777

7878
If the invitation is missing, check the platform and signed-in account. To
7979
switch accounts, set `VOID_API_URL` to the invitation's platform URL, unset
80-
`VOID_TOKEN` if present, then run `void auth logout` and `void auth login` using
80+
`VOID_TOKEN` if present, then run `void account logout` and `void account login` using
8181
the invited email address. For an expired or revoked invitation, ask a project
8282
administrator to invite you again.
8383

‎docs/reference/cli.md‎

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ Use this page as a command reference. If you are setting up a project for the fi
2828
| `void secret sync .env` | Bulk upload secrets from dotenv file |
2929
| `void env check [--remote]` | Validate env.ts schema |
3030
| `void env types` | Regenerate .void/env.d.ts from env.ts |
31-
| `void auth login` | Authenticate with Void |
31+
| `void auth login` | Authenticate with the project’s saved destination, or choose one |
32+
| `void account login` | Authenticate with a Void platform |
3233
| `void cloudflare login` | Authenticate with Cloudflare through Void |
3334
| `void platform install` | Install a company Void platform in Cloudflare |
3435
| `void connect <url>` | Connect the CLI to a Void platform |
@@ -169,9 +170,23 @@ The deployment preference is saved in `.void/project.json`. Connecting to anothe
169170

170171
In a non-interactive shell, supply a URL or explicit target. Cloudflare requires usable credentials and an unambiguous account (`CLOUDFLARE_ACCOUNT_ID` when needed). For a Void platform, provide `VOID_TOKEN` with a matching `VOID_API_URL`, or reuse a valid origin-scoped keychain session. Use `void connect <url> --no-login` to save the verified connection without authenticating; this option is only available for Void platforms.
171172

172-
## Auth
173+
## Authentication
173174

174-
### `void auth login`
175+
`void auth login`, `void auth status`, and `void auth logout` use the destination
176+
saved for the current project by `void init` or `void connect`. If no destination
177+
is saved, interactive commands let you choose Cloudflare or a connected Void
178+
platform. In a non-interactive shell, pass `--platform cloudflare|void` or use
179+
the explicit `void cloudflare` and `void account` commands. Choosing a destination
180+
for authentication does not change the project's deploy target.
181+
182+
`void auth whoami`, `void auth link`, and `void auth token` remain supported for
183+
existing scripts. `whoami` follows the selected destination; `link` and `token`
184+
are Void account operations. Prefer `void auth status`, `void account link`, and
185+
`void account token` in new scripts.
186+
187+
## Void platform account
188+
189+
### `void account login`
175190

176191
Browser login through one of the platform's currently enabled methods. The token is saved in the operating-system keychain, scoped to the platform origin. Login fails closed when no keychain is available instead of writing the token to a plaintext file; headless environments use `VOID_TOKEN` from their secret manager.
177192

@@ -182,22 +197,22 @@ saved login instead, unset `VOID_TOKEN`.
182197

183198
This is optional if you already completed auth during `void connect` or the interactive `void init` flow.
184199

185-
### `void auth link [connection-id]`
200+
### `void account link [connection-id]`
186201

187202
Link another enabled login method to your current account. Sign in again if your
188203
session is no longer recent, complete the additional provider's browser login,
189204
and confirm the displayed identity. With no connection ID, choose an enabled
190205
method interactively. The optional dashboard exposes the same flow in **Account**.
191206

192-
### `void auth logout`
207+
### `void account logout`
193208

194209
Removes saved credentials.
195210

196-
### `void auth whoami`
211+
### `void account whoami`
197212

198213
Prints your current login.
199214

200-
### `void auth token`
215+
### `void account token`
201216

202217
Copies your human auth token to the system clipboard. It is intended for
203218
interactive troubleshooting and remains subject to login-method revocation. Do
@@ -1300,12 +1315,12 @@ Deploy-on-GitHub works from **any** Void login — Google, GitHub, or other SSO.
13001315
void github link
13011316
```
13021317

1303-
Link your current Void account to a GitHub identity. Opens your browser to authorize Void on GitHub (a localhost + PKCE handshake, the same mechanics as `void auth login`), then binds that GitHub identity to the logged-in account. Requires an authenticated CLI (`void auth login` first).
1318+
Link your current Void account to a GitHub identity. Opens your browser to authorize Void on GitHub (a localhost + PKCE handshake, the same mechanics as `void account login`), then binds that GitHub identity to the logged-in account. Requires an authenticated CLI (`void account login` first).
13041319

13051320
You normally don't need to run this directly — `void github install` runs the link automatically when your account has no GitHub identity yet. Run it on its own to link ahead of time, or to link a GitHub identity without installing the App.
13061321

13071322
::: warning Existing GitHub sign-in
1308-
Void accounts cannot be merged. If the GitHub account you authorize is already linked to a different Void account, including one created through GitHub sign-in, `void github link` is refused with `This GitHub account is already linked to another Void account.` Run `void auth logout` and sign in to that existing account, or authorize a different GitHub account. The command is also refused if your current Void account is already linked to a different GitHub identity. Re-authorizing the GitHub account attached to your current Void account is allowed and reports `GitHub account already linked.`
1323+
Void accounts cannot be merged. If the GitHub account you authorize is already linked to a different Void account, including one created through GitHub sign-in, `void github link` is refused with `This GitHub account is already linked to another Void account.` Run `void account logout` and sign in to that existing account, or authorize a different GitHub account. The command is also refused if your current Void account is already linked to a different GitHub identity. Re-authorizing the GitHub account attached to your current Void account is allowed and reports `GitHub account already linked.`
13091324
:::
13101325

13111326
### `void github install`
@@ -1334,7 +1349,7 @@ Join the GitHub App installations your organization already has. If a teammate i
13341349

13351350
In an interactive terminal you rarely need to run this yourself — `void github connect` runs the same join automatically when no active installations are linked to your account. Running `void github join` yourself matters mainly for non-interactive use (without a TTY, `void github connect` never opens a browser), or to link installations ahead of time.
13361351

1337-
Requires an authenticated CLI (`void auth login` first) and organization-installation sharing enabled on your Void instance; when it is not enabled the command fails closed with a clear message. You can only join installations your GitHub authorization actually returns — you cannot name or join one you cannot access on GitHub.
1352+
Requires an authenticated CLI (`void account login` first) and organization-installation sharing enabled on your Void instance; when it is not enabled the command fails closed with a clear message. You can only join installations your GitHub authorization actually returns — you cannot name or join one you cannot access on GitHub.
13381353

13391354
### `void github connect`
13401355

‎docs/reference/config.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ Use remote D1/KV/R2 bindings during local development instead of local miniflare
217217

218218
**Requirements:**
219219

220-
- Must be logged in (`void auth login`)
220+
- Must be logged in (`void account login`)
221221
- Must have a linked project (`void project link`)
222222
- Only affects D1 (`DB`), KV (`KV`), and R2 (`STORAGE`) bindings
223223

‎packages/void/AGENTS.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ generated entries must preserve the module-boundary rules below.
5858

5959
- **Cloudflare session switching**: Explicit `void cloudflare login` forces a fresh browser sign-in, while automatic authentication reuses valid sessions. Adopted OAuth sessions persist the keyring preference so later compatible CLI logins update the same encrypted store. Environment API credentials block explicit browser login rather than masking it. Status reports identity/auth method and the pinned account separately; login never rewrites the project target. Keep credentials out of all diagnostics.
6060

61+
- **Authentication commands**: `void auth login|status|logout` follows the saved `.void/project.json` deployment platform, or prompts when unset; headless calls need `--platform` or an explicit command. `void account` always targets a Void platform account, and `void cloudflare` always targets Cloudflare. Keep `void auth whoami|link|token` as compatibility shortcuts; `link` and `token` belong only to Void accounts. Auth selection never changes the deployment preference.
62+
6163
- **Repeatable framework wrappers**: `generateWrapper` recognizes current and legacy wrapper entries and preserves the original application across `--skip-build` runs. Compile handlers before replacing the entry, stage the wrapper for an atomic rename, and copy a new original only after an actual new build. A missing or recursively wrapped original requires a rebuild; readiness alone cannot validate the application entry.
6264

6365
- **Framework queue delivery**: Native queue handlers receive the original `MessageBatch`; only managed HTTP delivery serializes it. The generated `/__void/queue` endpoint requires `__VOID_PROXY_TOKEN`, reconstructs `Date` timestamps and first-decision-wins ack/retry methods, and returns per-message decisions even if the consumer throws. Queue-only wrappers must also serve readiness.

‎packages/void/README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ for every command.
1111

1212
Use `void platform config auth` to manage login methods and company signup.
1313
Cloudflare Access protection has separate create/connect controls. Users can
14-
link another enabled login to their account with `void auth link`.
14+
link another enabled login to their account with `void account link`.
1515

1616
## What It Covers
1717

@@ -57,7 +57,8 @@ export default defineConfig({
5757

5858
- `voidPlugin()` — Vite integration, routing, pages mode, codegen, migrations, packaging
5959
- `void prepare` — generate `.void` artifacts for CI, editors, and fresh clones
60-
- `void auth login` — platform auth
60+
- `void auth login` — sign in to the project's saved Cloudflare or Void destination
61+
- `void account login` — platform auth
6162
- `void connect [url]` — choose Cloudflare or a Void platform, sign in, and save the deployment destination
6263
- `void platform *` — list, select, inspect, install, recover, repair, upgrade, disable, and safely uninstall a company platform
6364
- `void deploy` — build and deploy to the saved Cloudflare or Void target

‎packages/void/skills/migrate-vite-cloudflare-to-void/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export default defineConfig({
8383
7. Deploy workflow migration
8484

8585
- Replace old deploy instructions with:
86-
- `void auth login`
86+
- `void account login`
8787
- `void deploy`
8888
- If CI must target a specific project, use:
8989
- `void deploy --project <slug>`

‎packages/void/skills/void/SKILL.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ dedicated Access applications or connect existing ones, including a separate
5959
identity account. Protection setup verifies API/proxy coverage and uses scoped
6060
service credentials for installation and CI. Use `platform config auth protection`
6161
to show, enable, or disable protection; retain the company gate when probes fail.
62-
Users link another enabled method with `void auth link [connection-id]` after
62+
Users link another enabled method with `void account link [connection-id]` after
6363
recent sign-in and explicit browser identity confirmation. For expired first-admin
6464
codes, resume installation or repair completed provisioning. Lost-provider recovery
6565
uses `platform config auth recover` with installation ownership, original recovery
@@ -79,6 +79,8 @@ For Void platform project access, use `void project team`: invite only an email
7979

8080
Use Void commands for every user-facing workflow. Never ask the user to install, authenticate, or run Wrangler directly. Say Cloudflare or Void instead, except when naming literal `wrangler.jsonc` / `wrangler.json` files or `WRANGLER_*` environment variables the user must inspect.
8181

82+
`void auth login|status|logout` follows the saved deploy destination or asks the user to choose; `void account` explicitly manages a Void platform account.
83+
8284
Use `void` in examples and commands in this skill. For first-time setup, prefer `void init` followed by `void deploy`; in an empty directory, install `void` first and let `void init` add the matching Pages adapter and starter dependencies with Vite+ as the default scaffold toolchain. In an existing app, `void init` configures Void in place by adding missing Vite scripts and creating or patching `vite.config.*` with `voidPlugin()`. For Cloudflare deployment, Void uses bundled tooling and secure browser OAuth; init or the first deploy saves the selected `account_id`, and `void cloudflare login|status|logout` manages the session; Void-managed deployment requires an explicitly connected platform. Use `void connect <url>` for an existing platform or `void platform install --plan` to preview a company control plane in the user's Cloudflare account. The core self-hosted platform excludes the dashboard, GitHub App, and build Containers; lifecycle commands are resumable and verify remote, Worker, and R2 ownership before mutations. `void platform disable` gates traffic through installation-owned routing storage and remains disabled through repair or upgrade; `void platform enable` explicitly restores traffic. Safe uninstall retains name-addressed Workers, R2, AI Gateway, external PostgreSQL, and zones for explicit manual cleanup. Direct Cloudflare deploys support native Void apps, static/SPA/SSG output, and Cloudflare builds from TanStack Start, React Router, vinext, SvelteKit, Nuxt, Analog, and Astro. They provision inferred resources, validate and apply migrations, require schema-declared server values in encrypted remote secret storage, upload and probe an immutable Worker Version, then activate and synchronize triggers. Native Void features are Workers Free-compatible by default; `void/sandbox` is an explicit exception because it uses Cloudflare Containers and therefore requires Workers Paid. A Sandbox deploy checks Containers access before provisioning/building, while apps without Sandbox perform no entitlement probe. Versions without preview URLs are staged at 0% and probed through workers.dev using a version override; the same safe fallback applies when Access blocks a generated preview alias but admits the stable Worker hostname. Set `CLOUDFLARE_WORKERS_SUBDOMAIN` in a fresh CI checkout, while local deploys cache it automatically. When Cloudflare Access protects `workers.dev`, use an admitted `CF_ACCESS_CLIENT_ID` / `CF_ACCESS_CLIENT_SECRET` service-token pair for CI, or a short-lived `CF_ACCESS_TOKEN` from `cloudflared` for an interactive local readiness probe. With Cloudflare saved in `.void/project.json`, secret, domain, project status/log/rollback, and remote database commands operate directly on the pinned Worker/account. Logs are a live tail. Rollback restores the selected version's saved schedules, queues, workflows, routes, and domains but never reverses database migrations; versions without complete trigger snapshots use code-only rollback and keep the current routes and schedules. On either deployment platform, auth-enabled `void deploy` preserves an existing `BETTER_AUTH_SECRET` or creates a persistent encrypted secret when missing; always use Void's deployment flow so it can manage that secret safely.
8385

8486
Use `void` and `@void/*` in code examples and package manifests.
@@ -110,7 +112,7 @@ If invoked without a concrete task, do a brief app status check and report:
110112
3. Runtime signals (`void/db`, `void/kv`, `void/storage`, queue usage).
111113
4. Auth signals (`void/auth`, `auth` client imports, OAuth env vars).
112114
5. Deployment platform and optional Void project linkage (`.void/project.json`), plus config readiness (`void.config.ts`, Cloudflare `account_id`, tsconfig extends).
113-
6. Optional health checks (`void auth whoami`, `void db status` when relevant).
115+
6. Optional health checks (`void account whoami`, `void db status` when relevant).
114116

115117
Then ask what to do next.
116118

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type { SubcommandDef } from './subcommand-prompt.ts';
2+
3+
export const accountSubcommands: Array<SubcommandDef> = [
4+
{ name: 'login', description: 'Log in with an enabled platform login method' },
5+
{ name: 'link', description: 'Link another login method to your account' },
6+
{ name: 'logout', description: 'Log out and remove credentials' },
7+
{ name: 'whoami', description: 'Show the logged-in username' },
8+
{ name: 'token', description: 'Copy auth token to clipboard' },
9+
];
10+
11+
export type AccountArgs =
12+
| { subcommand: 'login' | 'logout' | 'whoami' | 'token' }
13+
| { subcommand: 'link'; connectionId?: string };
14+
15+
export function parseAccountArgs(args: Array<string>): AccountArgs {
16+
const [subcommand, extra, trailing] = args;
17+
if (subcommand === 'link') {
18+
if (trailing || (extra !== undefined && !/^[a-z][a-z0-9_-]{0,63}$/.test(extra))) {
19+
throw new Error('account: Usage: void account link [connection-id].');
20+
}
21+
return { subcommand, ...(extra ? { connectionId: extra } : {}) };
22+
}
23+
if (!subcommand || !['login', 'logout', 'whoami', 'token'].includes(subcommand)) {
24+
throw new Error('account: Usage: void account <login|link|logout|whoami|token>.');
25+
}
26+
if (extra) {
27+
throw new Error(`account: Unexpected argument '${extra}'.`);
28+
}
29+
return { subcommand: subcommand as AccountArgs['subcommand'] };
30+
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { execSync } from 'node:child_process';
22
import { log } from '@clack/prompts';
3-
import type { AuthArgs } from './auth-args.ts';
3+
import type { AccountArgs } from './account-args.ts';
44
import { getToken, removeToken } from './auth.ts';
55
import { PlatformClient } from './client.ts';
66
import { runLoginCommand } from './login.ts';
77

8-
export async function runAuthCommand(root: string, args: AuthArgs): Promise<void> {
8+
export async function runAccountCommand(root: string, args: AccountArgs): Promise<void> {
99
switch (args.subcommand) {
1010
case 'login':
1111
return runLoginCommand(root);
@@ -23,7 +23,7 @@ export async function runAuthCommand(root: string, args: AuthArgs): Promise<void
2323
case 'whoami': {
2424
const token = getToken(root);
2525
if (!token) {
26-
log.error('Not logged in. Run `void auth login` first.');
26+
log.error('Not logged in. Run `void account login` first.');
2727
process.exit(1);
2828
}
2929
const client = new PlatformClient(token, { root });
@@ -37,7 +37,7 @@ export async function runAuthCommand(root: string, args: AuthArgs): Promise<void
3737
}
3838
const token = getToken(root);
3939
if (!token) {
40-
log.error('Login failed. Run `void auth login` to try again.');
40+
log.error('Login failed. Run `void account login` to try again.');
4141
process.exit(1);
4242
}
4343
const platform = process.platform;
@@ -51,7 +51,7 @@ export async function runAuthCommand(root: string, args: AuthArgs): Promise<void
5151
execSync(cmd, { input: token });
5252
log.success('Token copied to clipboard.');
5353
} catch {
54-
log.warn('Could not copy to clipboard. Re-run `void login` to generate a new token.');
54+
log.warn('Could not copy to clipboard. Run `void account token` again.');
5555
}
5656
return;
5757
}

0 commit comments

Comments
 (0)