Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
c59bc45
feat(cli): connect id track, so Track signs people in through ID
xgame92 Nov 29, 2026
8220ceb
docs(cli): say why both of Wrangler's folders are read
xgame92 Nov 29, 2026
e0e2e8b
fix(cli): connect proves what is set before it changes anything
xgame92 Nov 29, 2026
75ced98
docs(cli): what connect proves, what a rerun does, and the workers.de…
xgame92 Nov 29, 2026
4292f12
test(cli): doctor track looks for ID's button by its exact name
xgame92 Nov 29, 2026
0d5493e
fix(cli): connect never guesses what a failed look or a foreign setti…
xgame92 Nov 29, 2026
4b866c7
docs(cli): locks, lost puts, foreign Track settings and what addresse…
xgame92 Nov 29, 2026
53fc4c6
test(cli): a record of the client that does not name a Track setting …
xgame92 Nov 29, 2026
12dae80
fix(cli): ownership only once a put is confirmed, and a restore that …
xgame92 Nov 29, 2026
cfcfcd1
fix(cli): each address loses its credentials alone, and the rerun is …
xgame92 Nov 29, 2026
59ffb95
fix(cli): every "://" loses its userinfo on its own, and name the Win…
xgame92 Nov 29, 2026
4baf21c
style(cli): format the integrated redaction code
xgame92 Nov 29, 2026
0158faa
fix(cli): refresh the ID and Track connection draft
xgame92 Dec 3, 2026
65a538c
Verify Track connection prerequisites and bound child processes
xgame92 Dec 4, 2026
30c9801
Scope historical scanner exceptions to synthetic test fixtures
xgame92 Dec 4, 2026
6106a04
Merge commit '5dd323fb1dabf88d2a85dad60372798403a20ce8' into cli-conn…
xgame92 Dec 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Known synthetic subprocess and connection fixtures in the existing draft history.
0158faa80366165ac20edcd692c71e5ed564652c:packages/cli/test/system.test.ts:generic-api-key:223
e0e2e8b8714bb7f5dacdb99c828a191f54d4a0da:packages/cli/test/system.test.ts:generic-api-key:20
c59bc451dbf1cfeea6e73591a02678e8dd050d0b:packages/cli/test/connect-id-track.test.ts:generic-api-key:31
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Cloudflare account.
to Cloudflare. A value a person must keep is shown once, with words that say so.
4. **A second run finishes the first and does nothing twice.**
5. **The tool holds no logic a product's own deploy lacks.** It runs each product's repository at
a release tag; it does not fork their configuration.
a release tag; it does not fork their configuration. The one exception is `connect`: it does
what both products' self-hosting guides describe by hand to connect them, and nothing more. The
one value it makes is ID's `OIDC_PAIRWISE_SECRET`, as ID's guide says to.
6. **Never run against a Cloudflare account that holds anything you care about** in tests or by
hand. Rehearse only in a separate, empty account.

Expand Down
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@ Cloudflare account and check the deployment.

**Status: early.** `gateweave deploy`, `gateweave doctor` and `gateweave update` for Track and ID
are tested against a fake Wrangler, git and pnpm. `deploy track` and `doctor track` were also
rehearsed in a real, empty Cloudflare account. Nothing else exists yet. Run it with
`npx gateweave` (see [Install](#install)).
rehearsed in a real, empty Cloudflare account. `gateweave connect id track` is tested against the
same fakes and its live rehearsal is pending. Run the CLI with `npx gateweave`
(see [Install](#install)).

## Commands

| Command | Purpose |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
| `gateweave deploy track` | Create what Track needs in your Cloudflare account, set its secrets, apply migrations, deploy, and check the result from outside |
| `gateweave deploy id` | The same for ID: Worker, D1 database, logout Queue and RateLimiter Durable Object |
| `gateweave doctor track` | Say what is wrong with a Track deployment, in words |
| `gateweave doctor id` | Say what is wrong with an ID deployment; Track-only checks say they are not checked for ID |
| `gateweave update track` | Bring a Track deployment to a newer release, keeping the names of its Worker, database and bucket |
| `gateweave update id` | Bring an ID deployment to a newer release, keeping the names of its Worker, database and queue |
| Command | Purpose |
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `gateweave deploy track` | Create what Track needs in your Cloudflare account, set its secrets, apply migrations, deploy, and check the result from outside |
| `gateweave deploy id` | The same for ID: Worker, D1 database, logout Queue and RateLimiter Durable Object |
| `gateweave doctor track` | Say what is wrong with a Track deployment, in words |
| `gateweave doctor id` | Say what is wrong with an ID deployment; Track-only checks say they are not checked for ID |
| `gateweave update track` | Bring a Track deployment to a newer release, keeping the names of its Worker, database and bucket |
| `gateweave update id` | Bring an ID deployment to a newer release, keeping the names of its Worker, database and queue |
| `gateweave connect id track` | Set up ID's provider, register Track and configure Track to sign people in through ID |

`connect id track` is described in [the package's README](packages/cli/README.md#gateweave-connect-id-track).

## `gateweave deploy track`

Expand Down
147 changes: 147 additions & 0 deletions packages/cli/README.md

Large diffs are not rendered by default.

94 changes: 94 additions & 0 deletions packages/cli/src/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,100 @@ export async function mcpIsOn(sys: System, address: string): Promise<boolean | n
}
}

/** ID's provider name on Track's button, as in "Continue with Gateweave ID". */
export const ID_PROVIDER_NAME = "Gateweave ID";

/**
* The issuer in ID's `/.well-known/openid-configuration`, which answers only while BETTER_AUTH_URL
* and OIDC_PAIRWISE_SECRET are both set. Null when it does not answer with one.
*/
export async function discoveredIssuer(sys: System, address: string): Promise<string | null> {
try {
const response = await sys.fetch(new URL("/.well-known/openid-configuration", address).href);
if (response.status !== 200) return null;
const issuer = (JSON.parse(response.text) as { issuer?: unknown } | null)?.issuer;
return typeof issuer === "string" && issuer !== "" ? issuer : null;
} catch {
return null;
}
}

/** Track publishes the MCP resource from BETTER_AUTH_URL in its public OAuth metadata. */
export async function confirmsTrackResource(sys: System, address: string): Promise<boolean> {
try {
const response = await sys.fetch(
new URL("/.well-known/oauth-protected-resource", address).href,
{
method: "GET",
},
);
if (response.status !== 200) return false;
const resource = (JSON.parse(response.text) as { resource?: unknown } | null)?.resource;
return resource === `${address}/mcp`;
} catch {
return false;
}
}

const ENTITIES: Record<string, string> = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'" };

/**
* Text as the page shows it: HTML's character references decoded, by name for the five a page
* escapes text with, and by number. "Acme &amp; Co" reads "Acme & Co". One pass, so "&amp;lt;"
* is "&lt;", as a browser shows it.
*/
export function decodeEntities(text: string): string {
return text.replace(/&(?:#(\d+)|#[xX]([0-9a-fA-F]+)|([a-zA-Z]+));/g, (whole, dec, hex, name) => {
if (name !== undefined) return ENTITIES[name] ?? whole;
const code = Number.parseInt(dec ?? hex, dec !== undefined ? 10 : 16);
return code > 0 && code <= 0x10ffff ? String.fromCodePoint(code) : whole;
});
}

/**
* The names on the provider buttons of Track's sign-in page, other than GitHub's. Track shows its
* OpenID Connect button only while OIDC_ISSUER, OIDC_CLIENT_ID and OIDC_CLIENT_SECRET are all set.
* Null when the page did not answer.
*/
export async function providerButtons(sys: System, address: string): Promise<string[] | null> {
try {
const page = await sys.fetch(new URL("/login", address).href);
if (page.status !== 200) return null;
return [...page.text.matchAll(/>\s*Continue with ([^<]+?)\s*</g)]
.map((match) => decodeEntities(match[1] ?? ""))
.filter((name) => name !== "" && name !== "GitHub");
} catch {
return null;
}
}

/**
* The issuer Track names, as its sign-in page's Content-Security-Policy shows it: Track allows
* pictures from GitHub and from the origin of its OIDC_ISSUER, and from nowhere else. The setting
* itself is a secret, which cannot be read back; this is how it shows from outside. An empty list
* when the policy names none, null when the page or its policy could not be had.
*/
export async function pagePolicyIssuers(sys: System, address: string): Promise<string[] | null> {
try {
const page = await sys.fetch(new URL("/login", address).href);
const policy = Object.entries(page.headers).find(
([name]) => name.toLowerCase() === "content-security-policy",
)?.[1];
if (page.status !== 200 || !policy) return null;
const images = policy
.split(";")
.map((directive) => directive.trim().split(/\s+/))
.find(([name]) => name === "img-src");
if (!images) return null;
return images
.slice(1)
.filter((source) => /^https?:\/\//.test(source))
.filter((source) => source !== "https://avatars.githubusercontent.com");
} catch {
return null;
}
}

/**
* Runs every check against the address, retrying each for up to `withinMs` while a new
* `workers.dev` address comes up.
Expand Down
Loading
Loading