authflow-cli 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +374 -265
  3. package/dist/cli.js +4 -27
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/connect.js +11 -1
  6. package/dist/commands/connect.js.map +1 -1
  7. package/dist/commands/get.d.ts +7 -0
  8. package/dist/commands/get.js +34 -0
  9. package/dist/commands/get.js.map +1 -0
  10. package/dist/commands/init.js +37 -5
  11. package/dist/commands/init.js.map +1 -1
  12. package/dist/commands/list.d.ts +2 -0
  13. package/dist/commands/list.js +44 -0
  14. package/dist/commands/list.js.map +1 -0
  15. package/dist/commands/plan.d.ts +6 -0
  16. package/dist/commands/plan.js +26 -0
  17. package/dist/commands/plan.js.map +1 -0
  18. package/dist/commands/probe.js +1 -0
  19. package/dist/commands/probe.js.map +1 -1
  20. package/dist/commands/register.js +24 -0
  21. package/dist/commands/register.js.map +1 -1
  22. package/dist/commands/rotate-origin-key.d.ts +6 -0
  23. package/dist/commands/rotate-origin-key.js +56 -0
  24. package/dist/commands/rotate-origin-key.js.map +1 -0
  25. package/dist/commands/scaffold.js +31 -31
  26. package/dist/commands/set-connected-account.d.ts +7 -0
  27. package/dist/commands/set-connected-account.js +38 -0
  28. package/dist/commands/set-connected-account.js.map +1 -0
  29. package/dist/commands/set-origin.d.ts +5 -0
  30. package/dist/commands/set-origin.js +55 -19
  31. package/dist/commands/set-origin.js.map +1 -1
  32. package/dist/commands/status.d.ts +10 -0
  33. package/dist/commands/status.js +40 -0
  34. package/dist/commands/status.js.map +1 -0
  35. package/dist/mcp/server.js +58 -7
  36. package/dist/mcp/server.js.map +1 -1
  37. package/dist/program.d.ts +6 -0
  38. package/dist/program.js +46 -0
  39. package/dist/program.js.map +1 -0
  40. package/dist/rail.d.ts +5 -0
  41. package/dist/rail.js +14 -1
  42. package/dist/rail.js.map +1 -1
  43. package/dist/status.d.ts +34 -0
  44. package/dist/status.js +124 -0
  45. package/dist/status.js.map +1 -0
  46. package/dist/surface.d.ts +22 -0
  47. package/dist/surface.js +22 -0
  48. package/dist/surface.js.map +1 -0
  49. package/package.json +56 -56
package/README.md CHANGED
@@ -1,265 +1,374 @@
1
- # Authflow CLI
2
-
3
- License: Apache-2.0. See [LICENSE](LICENSE).
4
-
5
- Minimal TypeScript CLI for Authflow Rail onboarding. Wraps the public admin and Origin Protocol surfaces so a tenant can register a resource, connect Stripe, mint a local identity header, run the conformance probe, and scaffold the origin sidecar — without reading rail source.
6
-
7
- `authflow mcp` exposes the same operations as an MCP server, so a coding agent can onboard a server against the codebase it already has open. The tenant-facing walkthrough is [Onboard with your agent](../../docs/onboarding/agent.md). Command reference: [`authflow mcp`](#authflow-mcp).
8
-
9
- ## Install
10
-
11
- The command is `authflow`. The npm package is [`authflow-cli`](https://www.npmjs.com/package/authflow-cli) (npm blocked the unscoped name `authflow`). No repo checkout is required:
12
-
13
- ```bash
14
- npx -y -p authflow-cli authflow --help
15
- npx -y -p authflow-cli authflow init --slug video --price 900 --credits 12
16
- ```
17
-
18
- Or install globally and drop the `npx` prefix:
19
-
20
- ```bash
21
- npm install -g authflow-cli
22
- authflow --help
23
- ```
24
-
25
- ## From this repo (development)
26
-
27
- ```bash
28
- cd sdk/cli
29
- npm install
30
- npm run build
31
- npx authflow --help
32
- ```
33
-
34
- During development (no build step):
35
-
36
- ```bash
37
- npx tsx src/cli.ts --help
38
- npm run authflow -- --help
39
- ```
40
-
41
- ## Config
42
-
43
- | Env | Flag | Used by |
44
- | --- | --- | --- |
45
- | `AUTHFLOW_ISSUER` | `--issuer` | all HTTP commands |
46
- | `AUTHFLOW_ADMIN_API_KEY` | `--admin-key` | `init`, `register`, `connect`, `set-origin` (mint with `authflow signup`) |
47
- | `AUTHFLOW_ORIGIN_API_KEY` | `--origin-key` | `mint-header`, `probe` |
48
- | `AUTHFLOW_RESOURCE` / `AUTHFLOW_GATEWAY_URL` | `--gateway-url` / `--receipt` | curl hint on `mint-header` |
49
-
50
- Issuer is the Origin Protocol issuer origin, with no trailing slash: staging is `https://app-rail-railstg-4joi6asiofdcm.azurewebsites.net`, local is typically `https://localhost:7175`. For an already-registered resource it is the `issuer` field of the receipt. See [tenant quickstart §1](../../docs/onboarding/tenant-quickstart.md#environments-and-hostnames).
51
-
52
- ## Commands
53
-
54
- ### `authflow signup`
55
-
56
- Mints a per-tenant admin API key. This is how a creator gets `AUTHFLOW_ADMIN_API_KEY` without the rail operator handing them one.
57
-
58
- ```bash
59
- export AUTHFLOW_ISSUER=https://app-rail-railstg-4joi6asiofdcm.azurewebsites.net
60
- npx -y -p authflow-cli authflow signup --email you@example.com
61
- ```
62
-
63
- The key (`afa_test_` on staging, `afa_live_` in production) is shown once and written to `.env.local` by default. It can only register and manage slugs created with that key. The operator bearer still exists as a super-admin.
64
-
65
- ### `authflow init`
66
-
67
- The whole onboarding path in one command: register the resource, put the origin API key in a secret
68
- store, print the config to paste into your MCP server, and probe the origin if it is already up.
69
-
70
- ```bash
71
- export AUTHFLOW_ISSUER=https://app-rail-railstg-4joi6asiofdcm.azurewebsites.net
72
- export AUTHFLOW_ADMIN_API_KEY=…
73
-
74
- authflow init --slug video --price 900 --credits 12
75
- ```
76
-
77
- Neither a Stripe account nor a deployed origin is required. Both are deferrable, in any order, and
78
- omitting either registers a **draft**: priced and registered, with a receipt you can build against,
79
- but not routable. That is the normal case — you rarely have a connected Stripe account or an origin
80
- URL before you have built anything.
81
-
82
- The receipt's `pending_requirements` lists what is still outstanding:
83
-
84
- | Requirement | Clear it with |
85
- | --- | --- |
86
- | `origin_base_uri` | `authflow set-origin --slug video --origin-url https://…` |
87
- | `connected_account_id` | `authflow connect --slug video` |
88
- | `stripe_onboarding_complete` | finish Stripe's form, then `authflow connect --slug video` again |
89
-
90
- The resource goes live once the list is empty. Add `--connect` to `init` to get the Stripe
91
- onboarding link from the first command instead of running `connect` separately.
92
-
93
- Useful flags:
94
-
95
- | Flag | Default | Meaning |
96
- | --- | --- | --- |
97
- | `--integration <dotnet\|proxy>` | `dotnet` | Which origin config to print |
98
- | `--write-secrets <target>` | `user-secrets` | `user-secrets`, `env-file`, or `keyvault` |
99
- | `--secret-destination <value>` | — | Project dir, env-file path, or vault name |
100
- | `--connected-account <acct>` | — | Attach a Stripe account you already have |
101
- | `--connect` | — | Start Stripe onboarding and print the hosted link |
102
- | `--origin-url <url>` | — | Supply the origin now instead of later |
103
- | `--no-probe` | — | Skip the conformance probe |
104
-
105
- ### `authflow connect`
106
-
107
- Starts or resumes Stripe Connect Standard onboarding and prints the hosted link the creator opens to
108
- complete KYC.
109
-
110
- ```bash
111
- authflow connect --slug video
112
- authflow connect --slug video --wait # poll until Stripe reports the account can take charges
113
- ```
114
-
115
- Account links are single-use and expire in minutes. Re-running is the expected way to get a fresh
116
- one: it resumes the same Stripe account rather than creating another, so retrying never leaves
117
- abandoned accounts behind. Run it again after the form is submitted to confirm `charges_enabled` and
118
- promote the resource.
119
-
120
- ### `authflow set-origin`
121
-
122
- Points a draft at its origin, promoting it to live if nothing else is pending.
123
-
124
- ```bash
125
- authflow set-origin --slug video --origin-url https://video-xyz.azurecontainerapps.io
126
- ```
127
-
128
- Pass the base URI without `/mcp`; the gateway appends it.
129
-
130
- ### `authflow doctor`
131
-
132
- Preflights a rail deployment before you spend time debugging your own origin.
133
-
134
- ```bash
135
- authflow doctor --issuer https://app-rail-railstg-4joi6asiofdcm.azurewebsites.net --slug video
136
- ```
137
-
138
- Checks that the issuer is reachable, that the Origin Protocol keys document is served and
139
- self-consistent (issuer byte-match, protocol version, a usable Ed25519 key, no private key
140
- material), and — with `--slug` — that the resource's PRM document resolves and the gateway answers
141
- an unauthenticated connect with a `401` carrying `resource_metadata`.
142
-
143
- Run this first when anything looks broken. It separates the two failures that are indistinguishable
144
- from the outside: a hostname that is not bound to the rail returns `404` on every path including
145
- `/healthz`, which reads exactly like a broken endpoint. Exit code is non-zero on any failure.
146
-
147
- ### `authflow register`
148
-
149
- ```bash
150
- export AUTHFLOW_ISSUER=https://app-rail-railstg-4joi6asiofdcm.azurewebsites.net
151
- export AUTHFLOW_ADMIN_API_KEY=…
152
- authflow register --file resource.json --out receipt.json
153
- ```
154
-
155
- `resource.json` uses the same snake_case fields as `POST /admin/resources` (see [tenant quickstart](../../docs/onboarding/tenant-quickstart.md) §3):
156
-
157
- ```json
158
- {
159
- "slug": "video",
160
- "origin_base_uri": "https://video-xyz.azurecontainerapps.io",
161
- "display_name": "Snyder Video",
162
- "connected_account_id": "acct_…",
163
- "currency": "usd",
164
- "price_amount_minor": 900,
165
- "credits_per_period": 12,
166
- "price_version": 1
167
- }
168
- ```
169
-
170
- `origin_base_uri` may be `null` or omitted, which registers a draft — see `authflow set-origin`.
171
-
172
- Writes the registration receipt to `--out` (default `receipt.json`). By default that file contains
173
- the one-time `origin_api_key` in plaintext, which is a credential you probably do not want on disk:
174
-
175
- ```bash
176
- authflow register --file resource.json --write-secrets user-secrets --secret-destination ./src/MyMcpServer
177
- ```
178
-
179
- That stores the key and redacts it from the receipt. `env-file` writes `.env.local` (and adds it to
180
- `.gitignore`); `keyvault` calls `az keyvault secret set` and needs `--secret-destination <vault>`.
181
-
182
- Rotate a key later with the admin API: `POST /admin/resources/{slug}/rotate-origin-key`.
183
-
184
- ### `authflow mint-header`
185
-
186
- Dev/staging only (`OriginProtocol:EnableDevEndpoints`). Mints a signed `X-Authflow-Identity` without OAuth.
187
-
188
- ```bash
189
- export AUTHFLOW_ORIGIN_API_KEY=afo_test_…
190
- authflow mint-header --tier standard --ttl 90 --grant-credits 3 --receipt receipt.json
191
- ```
192
-
193
- Prints the header and, when a gateway URL is known, a ready-to-paste `curl` against it.
194
-
195
- ### `authflow probe`
196
-
197
- Asks the rail to probe the registered origin with valid and deliberately broken identity headers.
198
-
199
- ```bash
200
- authflow probe
201
- ```
202
-
203
- Renders a pass/fail table. Exit code is non-zero when any check fails or the origin is unreachable.
204
-
205
- ### `authflow scaffold`
206
-
207
- ```bash
208
- authflow scaffold --receipt receipt.json --upstream http://upstream:3000
209
- ```
210
-
211
- Writes:
212
-
213
- - `.env` — `AUTHFLOW_ISSUER`, `AUTHFLOW_RESOURCE`, `AUTHFLOW_ORIGIN_API_KEY`, `AUTHFLOW_UPSTREAM_BASE_URI`
214
- - `docker-compose.authflow.yml` — `authflow-origin-proxy` in front of an upstream placeholder
215
-
216
- See [origin-proxy.md](../../docs/onboarding/origin-proxy.md) for the forwarded-header contract and the
217
- nonce-cache options.
218
-
219
- ### `authflow mcp`
220
-
221
- Runs the onboarding operations as an MCP server on stdio, so a coding agent can do the onboarding
222
- instead of a human running commands. The agent already has the creator's codebase; what it lacks is
223
- a way to talk to the rail. This supplies exactly that, and nothing more — the server never reads or
224
- writes source files. It hands back an integration plan and the agent applies it.
225
-
226
- Add it to Cursor or Claude Desktop:
227
-
228
- ```json
229
- {
230
- "mcpServers": {
231
- "authflow": {
232
- "command": "npx",
233
- "args": ["-y", "-p", "authflow-cli", "authflow", "mcp"],
234
- "env": {
235
- "AUTHFLOW_ISSUER": "https://app-rail-railstg-4joi6asiofdcm.azurewebsites.net",
236
- "AUTHFLOW_ADMIN_API_KEY": "…"
237
- }
238
- }
239
- }
240
- }
241
- ```
242
-
243
- Tools:
244
-
245
- | Tool | Does |
246
- | --- | --- |
247
- | `authflow_signup` | Mint a per-tenant admin API key (no existing credential) |
248
- | `authflow_doctor` | Preflight the rail; distinguishes a bad hostname from an outage |
249
- | `authflow_register_resource` | Register and price a resource; optionally store the key in a secret store |
250
- | `authflow_get_resource` | Current receipt, `status`, and `pending_requirements` |
251
- | `authflow_integration_plan` | Config, snippets, verification steps, and invariants for `dotnet`, `typescript`, `python`, or `proxy` |
252
- | `authflow_start_stripe_connect` | Hosted Stripe onboarding link; resumable |
253
- | `authflow_set_connected_account` | Attach an existing `acct_…` |
254
- | `authflow_set_origin` | Supply the origin and promote to live |
255
- | `authflow_probe` | Conformance probe against the origin |
256
- | `authflow_mint_test_header` | Signed identity header for local verifier testing |
257
- | `authflow_rotate_origin_key` | Rotate the origin API key (invalidates the old one immediately) |
258
-
259
- Every tool takes `issuer` and `admin_key` optionally, falling back to the environment, so credentials
260
- stay in the MCP client config rather than in the conversation. `write_secrets` is available on both
261
- tools that issue a key; prefer it, because a key returned in a tool result is a credential in a chat
262
- transcript.
263
-
264
- Authentication is a per-tenant `afa_` admin API key from `authflow signup` (or `authflow_signup`).
265
- The operator bearer still works as a super-admin. Per-creator OAuth is not required for onboarding.
1
+ # Authflow CLI
2
+
3
+ License: Apache-2.0. See [LICENSE](LICENSE).
4
+
5
+ Minimal TypeScript CLI for Authflow Rail onboarding. Wraps the public admin and Origin Protocol surfaces so a tenant can register a resource, connect Stripe, mint a local identity header, run the conformance probe, and scaffold the origin sidecar — without reading rail source.
6
+
7
+ `authflow mcp` exposes the same operations as an MCP server, so a coding agent can onboard a server against the codebase it already has open. The tenant-facing walkthrough is [Onboard with your agent](../../docs/onboarding/agent.md). Command reference: [`authflow mcp`](#authflow-mcp).
8
+
9
+ ## Install
10
+
11
+ The command is `authflow`. The npm package is [`authflow-cli`](https://www.npmjs.com/package/authflow-cli) (npm blocked the unscoped name `authflow`). No repo checkout is required:
12
+
13
+ ```bash
14
+ npx -y -p authflow-cli authflow --help
15
+ npx -y -p authflow-cli authflow init --slug video --price 900 --credits 12
16
+ ```
17
+
18
+ Or install globally and drop the `npx` prefix:
19
+
20
+ ```bash
21
+ npm install -g authflow-cli
22
+ authflow --help
23
+ ```
24
+
25
+ ## From this repo (development)
26
+
27
+ ```bash
28
+ cd sdk/cli
29
+ npm install
30
+ npm run build
31
+ npx authflow --help
32
+ ```
33
+
34
+ During development (no build step):
35
+
36
+ ```bash
37
+ npx tsx src/cli.ts --help
38
+ npm run authflow -- --help
39
+ ```
40
+
41
+ ## Config
42
+
43
+ | Env | Flag | Used by |
44
+ | --- | --- | --- |
45
+ | `AUTHFLOW_ISSUER` | `--issuer` | all HTTP commands |
46
+ | `AUTHFLOW_ADMIN_API_KEY` | `--admin-key` | `init`, `register`, `connect`, `set-connected-account`, `set-origin`, `status`, `get`, `list`, `plan`, `rotate-origin-key` (mint with `authflow signup`) |
47
+ | `AUTHFLOW_ORIGIN_API_KEY` | `--origin-key` | `mint-header`, `probe`, `set-origin` (for its probe) |
48
+ | `AUTHFLOW_RESOURCE` / `AUTHFLOW_GATEWAY_URL` | `--gateway-url` / `--receipt` | curl hint on `mint-header` |
49
+
50
+ Issuer is the Origin Protocol issuer origin, with no trailing slash: staging is `https://staging.rails.authflow.ai`, local is typically `https://localhost:7175`. For an already-registered resource it is the `issuer` field of the receipt. See [tenant quickstart §1](../../docs/onboarding/tenant-quickstart.md#environments-and-hostnames).
51
+
52
+ ## Commands
53
+
54
+ ### `authflow signup`
55
+
56
+ Mints a per-tenant admin API key. This is how a creator gets `AUTHFLOW_ADMIN_API_KEY` without the rail operator handing them one.
57
+
58
+ ```bash
59
+ export AUTHFLOW_ISSUER=https://staging.rails.authflow.ai
60
+ npx -y -p authflow-cli authflow signup --email you@example.com
61
+ ```
62
+
63
+ The key (`afa_test_` on staging, `afa_live_` in production) is shown once and written to `.env.local` by default. It can only register and manage slugs created with that key. The operator bearer still exists as a super-admin.
64
+
65
+ ### `authflow init`
66
+
67
+ The whole onboarding path in one command: register the resource, put the origin API key in a secret
68
+ store, print the config to paste into your MCP server, and probe the origin if it is already up.
69
+
70
+ ```bash
71
+ export AUTHFLOW_ISSUER=https://staging.rails.authflow.ai
72
+ export AUTHFLOW_ADMIN_API_KEY=…
73
+
74
+ authflow init --slug video --price 900 --credits 12
75
+ ```
76
+
77
+ Neither a Stripe account nor a deployed origin is required. Both are deferrable, in any order, and
78
+ omitting either registers a **draft**: priced and registered, with a receipt you can build against,
79
+ but not routable. That is the normal case — you rarely have a connected Stripe account or an origin
80
+ URL before you have built anything.
81
+
82
+ The receipt's `pending_requirements` lists what is still outstanding:
83
+
84
+ | Requirement | Clear it with |
85
+ | --- | --- |
86
+ | `origin_base_uri` | `authflow set-origin --slug video --origin-url https://…` |
87
+ | `connected_account_id` | `authflow connect --slug video` (hosted KYC) or `authflow set-connected-account --slug video --account acct_…` (you already have the id) |
88
+ | `stripe_onboarding_complete` | finish Stripe's form, then `authflow connect --slug video` again |
89
+
90
+ Re-running `init` against a slug this admin key already owns resumes it: `409 slug_owned_by_caller`
91
+ is not a dead end. `--connected-account` and `--origin-url` then attach instead of failing. A slug
92
+ owned by someone else still returns `slug_taken`.
93
+
94
+ The resource goes live once the list is empty. Add `--connect` to `init` to get the Stripe
95
+ onboarding link from the first command instead of running `connect` separately.
96
+
97
+ Useful flags:
98
+
99
+ | Flag | Default | Meaning |
100
+ | --- | --- | --- |
101
+ | `--integration <dotnet\|proxy>` | `dotnet` | Which origin config to print |
102
+ | `--write-secrets <target>` | `user-secrets` | `user-secrets`, `env-file`, or `keyvault` |
103
+ | `--secret-destination <value>` | — | Project dir, env-file path, or vault name |
104
+ | `--connected-account <acct>` | — | Attach a Stripe account you already have |
105
+ | `--connect` | — | Start Stripe onboarding and print the hosted link |
106
+ | `--origin-url <url>` | — | Supply the origin now instead of later |
107
+ | `--no-probe` | — | Skip the conformance probe |
108
+
109
+ ### `authflow connect`
110
+
111
+ Starts or resumes Stripe Connect Standard onboarding and prints the hosted link the creator opens to
112
+ complete KYC.
113
+
114
+ ```bash
115
+ authflow connect --slug video
116
+ authflow connect --slug video --wait # poll until Stripe reports the account can take charges
117
+ authflow connect --slug video --connected-account acct_… # attach an account you already have
118
+ ```
119
+
120
+ Account links are single-use and expire in minutes. Re-running is the expected way to get a fresh
121
+ one: it resumes the same Stripe account rather than creating another, so retrying never leaves
122
+ abandoned accounts behind. Run it again after the form is submitted to confirm `charges_enabled` and
123
+ promote the resource.
124
+
125
+ `--connected-account` skips hosted KYC and is the same PUT as `authflow set-connected-account`.
126
+
127
+ ### `authflow set-connected-account`
128
+
129
+ Attach a Stripe Standard account id the platform already has. This is the CLI twin of
130
+ `authflow_set_connected_account` and of `PUT /admin/resources/{slug}/connected-account`. Use it when
131
+ `connect` would otherwise start a new hosted onboarding you do not need.
132
+
133
+ ```bash
134
+ authflow set-connected-account --slug video --account acct_…
135
+ ```
136
+
137
+ ### `authflow set-origin`
138
+
139
+ Points a draft at its origin, promoting it to live if nothing else is pending, then runs the
140
+ conformance probe.
141
+
142
+ ```bash
143
+ authflow set-origin --slug video --origin-url https://video-xyz.azurecontainerapps.io
144
+ ```
145
+
146
+ Pass the base URI without `/mcp`; the gateway appends it.
147
+
148
+ The probe runs automatically because this is the moment the resource starts accepting traffic, and a
149
+ closing "remember to verify" is a step that gets skipped. It needs `AUTHFLOW_ORIGIN_API_KEY` (or
150
+ `--origin-key`) — the admin key cannot stand in, because the probe authenticates as the origin. If
151
+ the key is not available the command says so and completes; `--no-probe` skips it deliberately.
152
+
153
+ The command also prints the client MCP config for the gateway URL. Use it verbatim: an MCP client
154
+ pointed at the origin's own hostname gets `403 invalid_origin_identity`, which is the origin
155
+ correctly refusing an unsigned request, not an auth bug.
156
+
157
+ ### `authflow status`
158
+
159
+ Where onboarding actually got to, and the command that clears each remaining step.
160
+
161
+ ```bash
162
+ authflow status --slug video
163
+ ```
164
+
165
+ ```
166
+ resource: video
167
+ status: draft
168
+ gateway: https://staging.rails.authflow.ai/video/mcp
169
+
170
+ [x] resource registered
171
+ [ ] origin URI set
172
+ no origin — the gateway has nowhere to forward to
173
+ next: authflow set-origin --slug video --origin-url https://your-origin.example
174
+ [ ] Stripe connected
175
+ no connected account — nothing can be charged
176
+ next: authflow connect --slug video (or authflow set-connected-account --slug video --account acct_…)
177
+ [ ] Stripe onboarding complete
178
+ no connected account — attach one before Stripe can confirm charges
179
+ next: authflow connect --slug video (or authflow set-connected-account --slug video --account acct_…)
180
+ ```
181
+
182
+ "Stripe onboarding complete" is ticked only when this resource has an account attached **and** Stripe
183
+ has not listed `stripe_onboarding_complete` as pending. No account is not "charges enabled."
184
+
185
+ Use it to resume an onboarding whose earlier steps may or may not have finished — a deploy that got
186
+ backgrounded, a terminal that was closed. `doctor` answers "is the rail up", which is a different
187
+ question: the rail can be perfectly healthy while a resource sits half-configured and rejects every
188
+ request. Exit code is non-zero until the resource can take paid traffic, so it works as a deploy
189
+ gate. `--json` emits the report for scripting.
190
+
191
+ ### `authflow plan`
192
+
193
+ Prints the same framework-specific origin integration plan as `authflow_integration_plan`.
194
+
195
+ ```bash
196
+ authflow plan --slug video --framework dotnet
197
+ ```
198
+
199
+ `--framework` is one of `dotnet`, `typescript`, `python`, or `proxy`.
200
+
201
+ ### `authflow get` / `authflow list`
202
+
203
+ ```bash
204
+ authflow get --slug video # one receipt, plus the client MCP config
205
+ authflow list # every resource this admin key owns
206
+ ```
207
+
208
+ `list` is the recovery path for a forgotten slug, which `get` cannot be — it needs the slug you are
209
+ trying to remember. If a registration reported the slug was taken and it is not in `list`, another
210
+ tenant owns it and you need a different name; slugs are global because they are the gateway path
211
+ segment.
212
+
213
+ ### `authflow rotate-origin-key`
214
+
215
+ ```bash
216
+ authflow rotate-origin-key --slug video --write-secrets user-secrets
217
+ ```
218
+
219
+ The recovery path for a lost origin API key, which is shown only once. The previous key stops working
220
+ the moment the command returns, so update the origin's secret store immediately or its usage reports
221
+ and probes will start failing.
222
+
223
+ ### `authflow doctor`
224
+
225
+ Preflights a rail deployment before you spend time debugging your own origin.
226
+
227
+ ```bash
228
+ authflow doctor --issuer https://staging.rails.authflow.ai --slug video
229
+ ```
230
+
231
+ Checks that the issuer is reachable, that the Origin Protocol keys document is served and
232
+ self-consistent (issuer byte-match, protocol version, a usable Ed25519 key, no private key
233
+ material), and — with `--slug` — that the resource's PRM document resolves and the gateway answers
234
+ an unauthenticated connect with a `401` carrying `resource_metadata`.
235
+
236
+ Run this first when anything looks broken. It separates the two failures that are indistinguishable
237
+ from the outside: a hostname that is not bound to the rail returns `404` on every path including
238
+ `/healthz`, which reads exactly like a broken endpoint. Exit code is non-zero on any failure.
239
+
240
+ ### `authflow register`
241
+
242
+ ```bash
243
+ export AUTHFLOW_ISSUER=https://staging.rails.authflow.ai
244
+ export AUTHFLOW_ADMIN_API_KEY=…
245
+ authflow register --file resource.json --out receipt.json
246
+ ```
247
+
248
+ `resource.json` uses the same snake_case fields as `POST /admin/resources` (see [tenant quickstart](../../docs/onboarding/tenant-quickstart.md) §3):
249
+
250
+ ```json
251
+ {
252
+ "slug": "video",
253
+ "origin_base_uri": "https://video-xyz.azurecontainerapps.io",
254
+ "display_name": "Snyder Video",
255
+ "connected_account_id": "acct_…",
256
+ "currency": "usd",
257
+ "price_amount_minor": 900,
258
+ "credits_per_period": 12,
259
+ "price_version": 1
260
+ }
261
+ ```
262
+
263
+ `origin_base_uri` may be `null` or omitted, which registers a draft — see `authflow set-origin`.
264
+
265
+ Writes the registration receipt to `--out` (default `receipt.json`). The one-time `origin_api_key` is
266
+ **not** written to that file: receipts get committed, pasted into issues, and handed to agents, and
267
+ the key is a live bearer credential for the usage endpoint. It is printed to the terminal instead, so
268
+ nothing is lost. `--keep-secret-in-receipt` restores the old behaviour if you really need it.
269
+
270
+ Better still, have the CLI store it for you:
271
+
272
+ ```bash
273
+ authflow register --file resource.json --write-secrets user-secrets --secret-destination ./src/MyMcpServer
274
+ ```
275
+
276
+ `env-file` writes `.env.local` (and adds it to `.gitignore`); `keyvault` calls
277
+ `az keyvault secret set` and needs `--secret-destination <vault>`.
278
+
279
+ Lost the key? `authflow rotate-origin-key --slug <slug>`.
280
+
281
+ Registration also prints the client MCP config and, for a draft, the remaining steps — a registered
282
+ resource is not yet a reachable one, and from the outside the two are indistinguishable.
283
+
284
+ ### `authflow mint-header`
285
+
286
+ Dev/staging only (`OriginProtocol:EnableDevEndpoints`). Mints a signed `X-Authflow-Identity` without OAuth.
287
+
288
+ ```bash
289
+ export AUTHFLOW_ORIGIN_API_KEY=afo_test_…
290
+ authflow mint-header --tier standard --ttl 90 --grant-credits 3 --receipt receipt.json
291
+ ```
292
+
293
+ Prints the header and, when a gateway URL is known, a ready-to-paste `curl` against it.
294
+
295
+ ### `authflow probe`
296
+
297
+ Asks the rail to probe the registered origin with valid and deliberately broken identity headers.
298
+
299
+ ```bash
300
+ authflow probe
301
+ authflow probe --slug video
302
+ ```
303
+
304
+ The origin API key is bound to one resource, so `--slug` is optional and ignored. It exists so a
305
+ documented `authflow probe --slug …` does not fail. Renders a pass/fail table. Exit code is
306
+ non-zero when any check fails or the origin is unreachable.
307
+
308
+ ### `authflow scaffold`
309
+
310
+ ```bash
311
+ authflow scaffold --receipt receipt.json --upstream http://upstream:3000
312
+ ```
313
+
314
+ Writes:
315
+
316
+ - `.env` — `AUTHFLOW_ISSUER`, `AUTHFLOW_RESOURCE`, `AUTHFLOW_ORIGIN_API_KEY`, `AUTHFLOW_UPSTREAM_BASE_URI`
317
+ - `docker-compose.authflow.yml` — `authflow-origin-proxy` in front of an upstream placeholder
318
+
319
+ See [origin-proxy.md](../../docs/onboarding/origin-proxy.md) for the forwarded-header contract and the
320
+ nonce-cache options.
321
+
322
+ ### `authflow mcp`
323
+
324
+ Runs the onboarding operations as an MCP server on stdio, so a coding agent can do the onboarding
325
+ instead of a human running commands. The agent already has the creator's codebase; what it lacks is
326
+ a way to talk to the rail. This supplies exactly that, and nothing more — the server never reads or
327
+ writes source files. It hands back an integration plan and the agent applies it.
328
+
329
+ Add it to Cursor or Claude Desktop:
330
+
331
+ ```json
332
+ {
333
+ "mcpServers": {
334
+ "authflow": {
335
+ "command": "npx",
336
+ "args": ["-y", "-p", "authflow-cli", "authflow", "mcp"],
337
+ "env": {
338
+ "AUTHFLOW_ISSUER": "https://staging.rails.authflow.ai",
339
+ "AUTHFLOW_ADMIN_API_KEY": "…"
340
+ }
341
+ }
342
+ }
343
+ }
344
+ ```
345
+
346
+ Tools:
347
+
348
+ | Tool | Does |
349
+ | --- | --- |
350
+ | `authflow_signup` | Mint a per-tenant admin API key (no existing credential) |
351
+ | `authflow_doctor` | Preflight the rail; distinguishes a bad hostname from an outage |
352
+ | `authflow_register_resource` | Register and price a resource; optionally store the key in a secret store |
353
+ | `authflow_get_resource` | Current receipt, `status`, and `pending_requirements` |
354
+ | `authflow_list_resources` | Every resource this key owns — how an agent recovers an unknown slug |
355
+ | `authflow_status` | Per-step readiness with the command that clears each one; use it to resume |
356
+ | `authflow_integration_plan` | Config, snippets, verification steps, and invariants for `dotnet`, `typescript`, `python`, or `proxy` |
357
+ | `authflow_start_stripe_connect` | Hosted Stripe onboarding link; resumable |
358
+ | `authflow_set_connected_account` | Attach an existing `acct_…` |
359
+ | `authflow_set_origin` | Supply the origin and promote to live |
360
+ | `authflow_probe` | Conformance probe against the origin |
361
+ | `authflow_mint_test_header` | Signed identity header for local verifier testing |
362
+ | `authflow_rotate_origin_key` | Rotate the origin API key (invalidates the old one immediately) |
363
+
364
+ Every tool takes `issuer` and `admin_key` optionally, falling back to the environment, so credentials
365
+ stay in the MCP client config rather than in the conversation. `write_secrets` is available on both
366
+ tools that issue a key; prefer it, because a key returned in a tool result is a credential in a chat
367
+ transcript.
368
+
369
+ Every receipt a tool returns carries `client_mcp_config` — the config for reaching the resource
370
+ through the gateway. Hand the user that, never the origin's hostname, which rejects unsigned requests
371
+ by design.
372
+
373
+ Authentication is a per-tenant `afa_` admin API key from `authflow signup` (or `authflow_signup`).
374
+ The operator bearer still works as a super-admin. Per-creator OAuth is not required for onboarding.