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