@quickback-dev/cli 0.60.8 → 0.61.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 (70) hide show
  1. package/dist/docs/content.d.ts +7 -0
  2. package/dist/docs/content.d.ts.map +1 -0
  3. package/dist/docs/content.js +737 -0
  4. package/dist/docs/content.js.map +1 -0
  5. package/dist/index.js +1 -1
  6. package/dist/lib/helpers.d.ts +39 -0
  7. package/dist/lib/helpers.d.ts.map +1 -0
  8. package/dist/lib/helpers.js +299 -0
  9. package/dist/lib/helpers.js.map +1 -0
  10. package/dist/lib/wrangler-resources.d.ts +1 -1
  11. package/dist/lib/wrangler-resources.d.ts.map +1 -1
  12. package/dist/lib/wrangler-resources.js +12 -4
  13. package/dist/lib/wrangler-resources.js.map +1 -1
  14. package/dist/skill/docs/api/errors.md +1 -0
  15. package/dist/skill/docs/api/query-params.md +26 -0
  16. package/dist/skill/docs/changelog/index.md +79 -0
  17. package/dist/skill/docs/configure/auth.md +17 -12
  18. package/dist/skill/docs/configure/bindings.md +27 -0
  19. package/dist/skill/docs/configure/domains.md +1 -1
  20. package/dist/skill/docs/configure/index.md +5 -5
  21. package/dist/skill/docs/define/actions/index.md +18 -0
  22. package/dist/skill/docs/define/areas.md +90 -7
  23. package/dist/skill/docs/define/feature.md +88 -27
  24. package/dist/skill/docs/define/fga.md +10 -2
  25. package/dist/skill/docs/define/index.md +7 -1
  26. package/dist/skill/docs/define/scopes.md +1 -1
  27. package/dist/skill/docs/define/security.md +10 -0
  28. package/dist/skill/docs/define/transitions.md +11 -35
  29. package/dist/skill/docs/platform/auth/jwt-optimization.md +15 -3
  30. package/dist/skill/docs/platform/database/d1.md +17 -2
  31. package/dist/skill/docs/platform/database/neon.md +7 -0
  32. package/dist/skill/docs/platform/realtime/index.md +17 -0
  33. package/dist/skill/docs/platform/webhooks/outbound.md +31 -6
  34. package/dist/skill/docs/start/deploy-browser.md +36 -7
  35. package/dist/skill/docs/start/deploy-owner-access.md +11 -0
  36. package/dist/skill/docs/start/first-api.md +16 -0
  37. package/dist/skill/docs/ui/account/features/admin.md +29 -5
  38. package/dist/skill/docs/ui/account/features/index.md +22 -0
  39. package/dist/skill/docs/ui/admin/connecting.md +6 -4
  40. package/dist/skill/docs/ui/admin/index.md +49 -10
  41. package/dist/skill/docs/ui/admin/security.md +6 -7
  42. package/package.json +1 -1
  43. package/src/skill/docs/api/errors.md +1 -0
  44. package/src/skill/docs/api/query-params.md +26 -0
  45. package/src/skill/docs/changelog/index.md +79 -0
  46. package/src/skill/docs/configure/auth.md +17 -12
  47. package/src/skill/docs/configure/bindings.md +27 -0
  48. package/src/skill/docs/configure/domains.md +1 -1
  49. package/src/skill/docs/configure/index.md +5 -5
  50. package/src/skill/docs/define/actions/index.md +18 -0
  51. package/src/skill/docs/define/areas.md +90 -7
  52. package/src/skill/docs/define/feature.md +88 -27
  53. package/src/skill/docs/define/fga.md +10 -2
  54. package/src/skill/docs/define/index.md +7 -1
  55. package/src/skill/docs/define/scopes.md +1 -1
  56. package/src/skill/docs/define/security.md +10 -0
  57. package/src/skill/docs/define/transitions.md +11 -35
  58. package/src/skill/docs/platform/auth/jwt-optimization.md +15 -3
  59. package/src/skill/docs/platform/database/d1.md +17 -2
  60. package/src/skill/docs/platform/database/neon.md +7 -0
  61. package/src/skill/docs/platform/realtime/index.md +17 -0
  62. package/src/skill/docs/platform/webhooks/outbound.md +31 -6
  63. package/src/skill/docs/start/deploy-browser.md +36 -7
  64. package/src/skill/docs/start/deploy-owner-access.md +11 -0
  65. package/src/skill/docs/start/first-api.md +16 -0
  66. package/src/skill/docs/ui/account/features/admin.md +29 -5
  67. package/src/skill/docs/ui/account/features/index.md +22 -0
  68. package/src/skill/docs/ui/admin/connecting.md +6 -4
  69. package/src/skill/docs/ui/admin/index.md +49 -10
  70. package/src/skill/docs/ui/admin/security.md +6 -7
@@ -112,22 +112,61 @@ cms: { domain: "cms.example.com" }
112
112
 
113
113
  This adds a custom domain route to `wrangler.toml`. Both domains serve the same Worker — `api.example.com` for the API, `cms.example.com` for the CMS. The compiler also auto-infers a unified `quickback.example.com` domain where everything is available. See [Multi-Domain Architecture](/configure/domains).
114
114
 
115
- ### Access gate (platform-control-plane by default)
115
+ ### Access gate
116
116
 
117
- CMS access defaults to `access: "admin"` — only `user.role === "appmanager"` (the user-table platform control-plane role) can reach `/cms/*`. When `cms.sysadmin: true`, `user.role === "sysadmin"` is also admitted. Other authenticated users are redirected to `/account/profile`. The gate is enforced at **four layers** — defense in depth:
117
+ `cms.access` answers one question: **can anyone in the organization hierarchy use the CMS, or only a platform sysadmin?**
118
118
 
119
- 1. **Account UI link** — the "Go to CMS" button is hidden for callers outside those roles.
120
- 2. **CMS SPA shell** — the Worker returns `403 Platform operator access required` before serving `index.html` to a non-operator. Unauthenticated requests are redirected to the login page.
121
- 3. **`/api/v1/schema`** — the CMS metadata endpoint checks `ctx.userRole === "appmanager"` (and admits `sysadmin` when enabled) and returns `403` otherwise.
122
- 4. **`custom_view` routes** — the CMS-internal saved-views table is gated on `userRole: ["appmanager"]` (see the [`userRole` access primitive](/define/access#userrole)) rather than org membership.
119
+ | Value | Who gets in |
120
+ |-------|-------------|
121
+ | `"sysadmin"` (default) | Only `user.role === "sysadmin"` — the cross-tenant data-plane tier. They choose a tenant from the org picker. |
122
+ | `"member"` | The above, **plus** any caller holding a membership in an organization, scoped to that organization. |
123
+
124
+ ```typescript
125
+ cms: { access: "member" } // let organization members in
126
+ ```
127
+
128
+ > **`user.role === "appmanager"` does not open the CMS in either mode.** appmanager is the *control plane* — users, organizations, and subscriptions at [`/account/admin`](/ui/account) — and deliberately holds no tenant-data powers. Keeping those separable is the entire point of the appmanager/sysadmin split. An appmanager who is also a member of an organization gets in as that member, on the membership, not on the platform role.
129
+
130
+
131
+ #### Where the gate actually lives
132
+
133
+ The CMS **shell** is served to any signed-in caller. Authorization is decided in the SPA, which renders a screen naming the caller's state and what to do about it — a signed-in user who can't get in is told why, instead of being silently bounced.
134
+
135
+ That is a deliberate trade: the old gate answered a wrong-role caller with a `302` so it couldn't be used to probe roles. The shell is a generic prebuilt bundle with no project data in it, and being unable to distinguish a permissions problem from a broken deploy cost more than the deniability was worth.
136
+
137
+ The gates that carry real data:
138
+
139
+ 1. **`/api/v1/schema`** — the metadata endpoint. Admits `sysadmin`, plus any caller with a membership when `access: "member"`. Otherwise `403` with `CMS_ACCESS_DENIED` and a hint naming the requirement. Without the registry there is no CMS.
140
+ 2. **`custom_view` routes** — saved views follow whoever is admitted: the `sysadmin` tier in `"sysadmin"` mode, org membership *or* sysadmin in `"member"` mode.
141
+ 3. **Account UI link** — the "Go to CMS" button is hidden for callers who wouldn't get in.
123
142
 
124
143
  Your resource API endpoints (`/api/v1/<resource>`) are **not** affected — they continue to use the per-resource `read`, `create`, `update`, `delete`, and `upsert` access rules you defined.
125
144
 
126
- To allow any authenticated user, opt out explicitly:
145
+ > **Breaking in v0.62.** `cms.access` was renamed from `"admin" | "user"`, and both old values meant something different: `"admin"` admitted `appmanager`, and `"user"` admitted *any* authenticated caller — including one belonging to no organization, who then reached a CMS with nothing in it. The old spellings are rejected at compile time rather than aliased, because aliasing would preserve the old behaviour under a familiar name. Migrate `"admin"` → `"sysadmin"`, `"user"` → `"member"`.
127
146
 
128
- ```typescript
129
- cms: { access: "user" }
130
- ```
147
+
148
+ #### What a blocked caller actually sees
149
+
150
+ The shell is served to any signed-in caller, and the SPA resolves one of six states — each its own screen naming what is true and what to do next. Nothing redirects: a signed-in user bounced elsewhere cannot tell a permissions problem from a broken deploy.
151
+
152
+ | State | Screen |
153
+ |-------|--------|
154
+ | Not signed in | Redirect to sign-in (the one redirect that remains — it is where you were going anyway) |
155
+ | `sysadmin`, no tenant chosen | Tenant picker, filterable, with **All organizations** as a first-class choice |
156
+ | `sysadmin`, tenant chosen | The CMS, scoped to that tenant |
157
+ | `appmanager`, `access: "sysadmin"` | *"The CMS shows organization data"* → **Go to admin** |
158
+ | Anyone else, `access: "sysadmin"` | *"This CMS is restricted"* — names the config value that would admit them |
159
+ | `access: "member"`, no membership | *"You're not in any organization yet"* → **View invitations** (an appmanager gets **Go to admin** instead — telling them to ask an admin for an invite when they are the admin is a dead end) |
160
+ | `access: "member"`, one membership | Auto-selected; straight in |
161
+ | `access: "member"`, several | Membership picker |
162
+
163
+ The decision is a pure function (`resolveCmsAccess`), so the table above is tested rather than described.
164
+
165
+ Sysadmin scope lives in the browser and rides every request as `?organizationId=` — it is not part of the session, because a sysadmin holds no membership row for Better Auth to make active. Change it from the sidebar.
166
+
167
+ #### `access: "sysadmin"` without `cms.sysadmin`
168
+
169
+ A sysadmin can still pin a single tenant — `?organizationId=` cross-tenant addressing is admitted for sysadmins unconditionally. The **"All organizations"** unfiltered view is what needs the firewall escape that `cms.sysadmin: true` emits.
131
170
 
132
171
  ### Optional: Skip SPA rebuild
133
172
 
@@ -2,19 +2,18 @@
2
2
 
3
3
  The CMS respects all four Quickback security layers. Every UI element — buttons, form fields, table columns, action menus — adapts based on the current user's role and the security rules defined in your feature files.
4
4
 
5
- ## CMS Access (platform-control-plane by default)
5
+ ## CMS Access
6
6
 
7
- The CMS is restricted to Better Auth platform control-plane users (`user.role === "appmanager"`) by default. If `cms.sysadmin: true` is enabled, `user.role === "sysadmin"` is also admitted. Other authenticated users are redirected to `/account/profile`. To allow any authenticated user, opt out explicitly:
7
+ `cms.access` decides whether the CMS is for platform sysadmins only (`"sysadmin"`, the default) or for organization members too (`"member"`). `user.role === "appmanager"` opens it in neither mode — that tier is the control plane, not the data plane.
8
8
 
9
9
  ```typescript
10
- cms: { access: "user" }
10
+ cms: { access: "member" }
11
11
  ```
12
12
 
13
- Under the default `access: "admin"`, the compiler emits server-side gates on every CMS-facing surface so a non-operator can't reach the CMS even by bypassing the SPA:
13
+ The shell is served to any signed-in caller so the SPA can explain who is and isn't admitted; the gates that carry data are:
14
14
 
15
- 1. **Account UI** — the "Go to CMS" button is hidden.
16
- 2. **CMS SPA shell** — the Worker checks `ctx.userRole === "appmanager"` before serving `index.html`. When `cms.sysadmin: true`, sysadmins are also admitted. Unauthenticated requests are redirected to login; authenticated non-operators get `403 Platform operator access required`.
17
- 3. **`/api/v1/schema`** — the CMS metadata endpoint returns `403` to callers outside those roles.
15
+ 1. **Account UI** — the "Go to CMS" button is hidden for callers who wouldn't get in.
16
+ 2. **`/api/v1/schema`** — the metadata endpoint returns `403` with `CMS_ACCESS_DENIED` and a hint naming the requirement. Without the registry there is no CMS.
18
17
  4. **`custom_view` routes** — the CMS-internal saved-views table uses `userRole: ["appmanager"]` (and, when `cms.sysadmin: true`, also admits `sysadmin`), so saved views can't be read or modified from outside the CMS by non-operator accounts.
19
18
  5. **In-SPA gate** — if any earlier layer is bypassed, the SPA still redirects the user to `/account/profile`.
20
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quickback-dev/cli",
3
- "version": "0.60.8",
3
+ "version": "0.61.0",
4
4
  "description": "CLI for Quickback — define your backend in TypeScript, compile to a fully wired Cloudflare Worker (or Bun / Node) with auth, database, migrations, security, CMS, and Account UI.",
5
5
  "author": "Kardoe Incorporated <paul@kardoe.com>",
6
6
  "license": "MIT",
@@ -98,6 +98,7 @@ Missing or invalid authentication tokens.
98
98
  | `AUTH_EXPIRED` | Token has expired |
99
99
  | `AUTH_RATE_LIMITED` | Too many auth attempts |
100
100
  | `AUTH_SESSION_REQUIRED` | The endpoint requires session (cookie) authentication — returned by `POST /api/v1/token` when called with a JWT, API key, or OAuth bearer, so a stolen or revoked token can't mint its own replacement |
101
+ | `AUTH_REVOCATION_UNAVAILABLE` | **503, retryable.** Only with [`revocationCheck: 'kv'`](/configure/auth#revocationcheck-none--kv--token-revocation-strategy): the bearer's signature verified, but its revocation state could not be read (KV binding missing or unreachable), so it was not trusted. Retry, or authenticate with a session cookie |
101
102
 
102
103
  ### Firewall (403)
103
104
 
@@ -31,6 +31,27 @@ GET /api/v1/jobs?title.like=Engineer
31
31
  GET /api/v1/jobs?department.in=Engineering,Design,Product
32
32
  ```
33
33
 
34
+ ### Unknown filters are rejected, not ignored
35
+
36
+ A filter the handler cannot apply returns `400` (`VALIDATION_INVALID_INPUT`).
37
+ It is never dropped:
38
+
39
+ | Request | Result |
40
+ |---------|--------|
41
+ | `?guestId=g_1` where `guestId` isn't a column | `400` — `Unknown filter field "guestId"` |
42
+ | `?status=open` on a view whose `query.filterable` omits `status` | `400` — `Field "status" is not filterable on this view` |
43
+ | `?title.matches=x` (no such operator) | `400` — `Unknown filter operator "matches"` |
44
+ | `?ssn=123` where `ssn` is masked for your role | `400` — see [Masking](/define/masking) |
45
+
46
+ Silently dropping a predicate would return **every row the firewall allows**
47
+ while still reading as a scoped list — a typo'd or join-table field turns a
48
+ narrow query into a full dump. The same rule closes `?search=` and `?sort=`.
49
+
50
+ > Filtering on a relationship that lives in a join table is not a column filter.
51
+ > `GET /travel-bookings?guestId=...` cannot work when membership is
52
+ > `travel_booking_guests` — expose a view or an `include` for it instead.
53
+
54
+
34
55
  ## Pagination
35
56
 
36
57
  | Parameter | Default | Description |
@@ -110,6 +131,11 @@ GET /api/v1/jobs?sort=title&order=asc
110
131
 
111
132
  When the multi-sort format is detected (comma or `-` prefix), the `order` parameter is ignored.
112
133
 
134
+ A client-supplied `?sort=` naming an unknown column — or one outside a view's
135
+ `query.sortable` — returns `400`, for the same reason unknown filters do: rows
136
+ would come back in some other order that reads as the requested one. A view's
137
+ own `defaultSort` fallback is config, not caller input, and is never rejected.
138
+
113
139
  ## Field Selection
114
140
 
115
141
  Select which columns to return using `?fields=`. Available on LIST and GET routes (not Views — they define their own field set).
@@ -8,6 +8,85 @@ The current release series. Older entries are archived by version range:
8
8
  - [v0.20 – v0.29](/changelog/v0.2x)
9
9
  - [v0.18 and earlier](/changelog/v0.1x)
10
10
 
11
+ ## v0.61.0 — August 12, 2026
12
+
13
+ ### Security: JWT revocation now fails closed when KV is unreachable
14
+
15
+ **Affects projects using `auth.jwt.revocationCheck: 'kv'`** — including every
16
+ project with a `.sealed()` column, which force-enables it.
17
+
18
+ Setting `revocationCheck: 'kv'` asks the verifier to consult current security
19
+ state before trusting a signed bearer. It did the opposite under failure: a
20
+ missing `KV` binding, a failed read, or a corrupt entry all returned "not
21
+ revoked," so a token was accepted during exactly the outage that hid its
22
+ revocation. A banned user's bearer kept working for the rest of its TTL, and
23
+ the one signal that would have caught it was the thing that had broken.
24
+
25
+ The check now returns `active` / `revoked` / `unavailable`, and only `active`
26
+ authenticates the bearer. A corrupt stamp is `unavailable` too — it used to
27
+ parse as `NaN` and compare as "not revoked."
28
+
29
+ **What changes operationally.** A bearer whose revocation state can't be read
30
+ gets a retryable `503 AUTH_REVOCATION_UNAVAILABLE` ([RFC 9457](/api/errors))
31
+ instead of being let through. Recovery is a separate cookie-only request: a
32
+ request carrying `Authorization` has its cookie stripped before session auth,
33
+ so during a KV outage every JWT-bearer request gets the 503 until the client
34
+ retries on its session cookie. One reason-only log line per occurrence carries
35
+ the cause (`missing-binding` / `read-error`) with no token, claim, or KV key in
36
+ it — **alert on it.**
37
+
38
+ This ties bearer-token availability to KV. That is the trade the opt-in now
39
+ makes honestly, and it is the right way round: a revocation check that gives
40
+ up under load is worth nothing. If you want the TTL bound *without* the
41
+ coupling, leave `revocationCheck` at `'none'` and set `expiresIn: 30`.
42
+
43
+ Because the binding is now load-bearing, a project with named `environments`
44
+ must declare `bindings.kv` on **every** target — a compile error naming the
45
+ environment, rather than a 503 discovered after deploy.
46
+
47
+ `revocationCheck: 'none'` output is byte-identical. See
48
+ [`revocationCheck`](/configure/auth#revocationcheck-none--kv--token-revocation-strategy).
49
+
50
+ ### Security: revocation was off by one second
51
+
52
+ **Also affects projects using `auth.jwt.revocationCheck: 'kv'`.**
53
+
54
+ Revocation markers and token mint timestamps were both whole seconds, and the
55
+ check rejected only a token stamped *strictly before* the marker. A token
56
+ minted earlier in the same second as the revocation therefore compared **equal**
57
+ and survived — a sub-second hole in a mechanism whose whole promise is
58
+ "revoked within seconds." Whether an attacker landed in it was a coin flip on
59
+ clock alignment, not on anything defensible.
60
+
61
+ Markers are now epoch milliseconds, tokens carry millisecond companions
62
+ (`iatMs`, and `sctMs` for the relationship-scope proof), and the comparison
63
+ denies a tie. A token minted milliseconds before the revocation is rejected; one
64
+ legitimately re-minted *after* it in that same second is still accepted, which
65
+ is why simply flipping `<` to `<=` on seconds was not the fix.
66
+
67
+ `iat` and `sct` remain standards-compatible unix **seconds** for external
68
+ tooling — the millisecond claims are internal ordering metadata, set by the
69
+ signer from the same clock sample and never accepted from a caller.
70
+
71
+ **Rollout is conservative, not clever.** Marker format is read from an explicit
72
+ version marker, never guessed from magnitude. Where one side is from v0.60.4 or
73
+ earlier — an old token against a new marker, or any token against an old marker
74
+ — there is no sub-second information to compare, so the **entire marker second**
75
+ is revoked. That over-revocation is bounded (old tokens expire within their TTL,
76
+ old markers within the entry lifetime), and it costs the caller a `401` and a
77
+ re-authentication, exactly as any other rejected token does. No action is needed
78
+ upgrading forward.
79
+
80
+ **Do not straddle this release, though.** A worker from before v0.61.0 reads a
81
+ millisecond marker as `NaN` and concludes *not revoked* — it does not recognise
82
+ it as corrupt, so the fail-closed path added above never fires. Rolling back
83
+ across this release, or running two differently-versioned deploy targets against
84
+ one shared KV namespace, means every revocation written by the new version is
85
+ **silently unenforced** by the old one until the entry expires (~19 minutes at
86
+ default settings). Upgrade targets that share a namespace together. If you must
87
+ roll back, treat outstanding bearers as unrevoked for that window: lower
88
+ `expiresIn`, or purge the `qbrev:` keys and re-stamp from the old version.
89
+
11
90
  ## v0.60.4 — August 4, 2026
12
91
 
13
92
  ### Fix: retired-path cleanup was inert in v0.60.1–v0.60.3
@@ -45,7 +45,7 @@ The short version, before the knob-by-knob detail:
45
45
  - **Default: 180-second TTL, auto-refreshed.** Every authenticated call returns a fresh token via the `set-auth-token` header, so the low TTL is invisible to logged-in users. The worst-case window for a stolen or pre-revocation token is 3 minutes — and you can shrink it to 30 seconds with one config line.
46
46
  - **Need revocation faster than the TTL?** Set [`revocationCheck: 'kv'`](#revocationcheck-none--kv--token-revocation-strategy). Revoked tokens are rejected within seconds; revocation stamps are written automatically on user ban, org-member removal, role change, and changes to scope-conferring relationship rows.
47
47
 
48
- Those two knobs — `expiresIn` and `revocationCheck` — cover the vast majority of deployments. The honest residual for the strictest threat models: the KV check revokes per-principal (not per-session), fails open if KV is unreachable (degrading to the TTL bound), and propagates cross-PoP in ~60s. If you need fail-closed, per-session kill semantics, set `expiresIn: 30` for a hard 30-second ceiling — and [tell us about your use case](https://github.com/kardoe/quickback/issues); an opaque-session mode is under consideration.
48
+ Those two knobs — `expiresIn` and `revocationCheck` — cover the vast majority of deployments. The honest residual for the strictest threat models: the KV check revokes per-principal (not per-session) and propagates cross-PoP in ~60s. It **fails closed** — if KV can't be read, the bearer isn't trusted and a bearer-only caller gets a retryable `503`, so enabling it ties bearer availability to KV. If you need per-session kill semantics, set `expiresIn: 30` for a hard 30-second ceiling — and [tell us about your use case](https://github.com/kardoe/quickback/issues); an opaque-session mode is under consideration.
49
49
 
50
50
  ### Behavior recap
51
51
 
@@ -105,11 +105,11 @@ Default `'none'`.
105
105
  | Value | Behavior | Cost per verify |
106
106
  |---|---|---|
107
107
  | `'none'` | No revocation check. Stolen / pre-revocation tokens valid until TTL expires (scope claims: until the carry-forward cap). Use a low `expiresIn` to bound the replay window. | 0 |
108
- | `'kv'` | Fast-path checks per-principal revocation timestamps in the project's existing `KV` binding before trusting a verified token. | 2+ KV reads (~5-15ms, edge-cached) |
108
+ | `'kv'` | Fast-path checks per-principal revocation timestamps in the project's existing `KV` binding before trusting a verified token. Fails closed: an unreadable store means the bearer is not trusted. | 2+ KV reads (~5-15ms, edge-cached) |
109
109
 
110
110
  `'kv'` (v0.45+, **Cloudflare runtime only**) keeps the fast-path stateless against the auth DB (still 0 D1 queries). There is nothing extra to provision — entries ride the `KV` binding every project already has, prefixed `qbrev:` and self-expiring after the maximum token lifetime, so the store never accumulates.
111
111
 
112
- A token is rejected when its mint timestamp (`iat`, or `sct` for the relationship-scope claim) predates the stored timestamp for any principal key it rides on:
112
+ A token is rejected when its mint timestamp (`iat`/`iatMs`, or `sct`/`sctMs` for the relationship-scope claim) is **at or before** the stored timestamp for any principal key it rides on:
113
113
 
114
114
  | Key | Revokes | Written automatically on |
115
115
  |---|---|---|
@@ -122,8 +122,12 @@ A token is rejected when its mint timestamp (`iat`, or `sct` for the relationshi
122
122
  Semantics worth knowing:
123
123
 
124
124
  - **Revoke-on-touch for scopes:** any update or delete of a conferring row stamps the revocation, without evaluating whether the change actually ended the relationship. A false positive just forces a cheap re-prove (`/scope/v1/enter` or a minting namespace route).
125
- - **Fails open:** a missing binding or KV outage skips the check (logged) — revocation degrades to the TTL / carry-forward-cap bound rather than locking every bearer out.
125
+ - **No same-second gap:** markers are stored in epoch milliseconds (written `m<ms>` — an explicit format version, not a magnitude the reader guesses at) and tokens carry millisecond companions (`iatMs` / `sctMs`) alongside the standards-compatible seconds claims, so a token minted a few milliseconds before the revocation is rejected — while one legitimately re-minted *after* it in that same second is still accepted. Tokens and markers written by v0.60.4 or earlier are handled **conservatively**: with no sub-second information on one side, the whole marker second is revoked. That over-revocation is bounded — the last old token expires within its TTL, and the last old marker within the entry lifetime. Like any rejected token it costs the caller a `401`, not a silent recovery: the bearer falls through unauthenticated (its cookie having been stripped, per the next bullet), and the client re-authenticates for a fresh token.
126
+ - **Do not straddle the v0.61.0 upgrade.** A worker from **before** v0.61.0 reads `m<ms>` markers as `NaN` and treats them as *no revocation at all* — not as a corrupt entry. So rolling back across this release, or pointing two differently-versioned deploy targets at one shared KV namespace, means every revocation written by the new version is **silently unenforced** by the old one until the entry expires (`ENTRY_TTL_SECONDS`, ~19 minutes at default settings). Upgrade all targets sharing a namespace together; if you must roll back, treat outstanding bearer tokens as unrevoked for that window — lower `expiresIn`, or purge the `qbrev:` keys and re-stamp from the old version.
127
+ - **Fails closed:** a missing binding, a failed read, or a corrupt entry means the token's revocation state is *unknown* — and an unknown bearer is not authenticated. The caller gets `503 AUTH_REVOCATION_UNAVAILABLE` (RFC 9457, retryable). Recovery is a **separate cookie-only request**: a request carrying `Authorization` has its cookie stripped before session auth, so within that one request there is nothing left to fall back to. Reads are never silently skipped, because the outage that hides a revocation is exactly the moment this check exists for.
128
+ - **Availability coupling:** the flip side of the above. Bearer-token auth now depends on KV being readable. Alert on `AUTH_REVOCATION_UNAVAILABLE`; a sustained rate means the binding is missing on some deployment target, or KV is degraded. Every named environment must declare `bindings.kv` — the compiler rejects a target that doesn't.
126
129
  - **Eventual consistency:** KV propagates cross-PoP in ~60s. "Immediate" means seconds at the writing location, bounded-seconds globally — still far inside the 15-minute carry-forward cap that bounds revocation without this check.
130
+ - **Writes stay best-effort:** the *stamps* are written after the authorization change has already committed (the ban row, the removed membership, the deleted conferring row). A failed stamp does not fail that write — the DB state is the durable cut. It is only the *read* side that fails closed.
127
131
  - **Coverage gap:** batch *hard* deletes don't return rows through the chokepoint; call `revokeScopeTokens` explicitly if you bulk-hard-delete conferring rows.
128
132
 
129
133
  ## Defaults when the JWT surface is enabled
@@ -145,34 +149,35 @@ missing field falls back to its hardcoded value:
145
149
  - **B2C SaaS, mostly browser traffic:** keep defaults. The 180s TTL + auto-refresh model just works.
146
150
  - **Pentest engagement / enterprise compliance:** set `expiresIn: 30`. Tokens stay invisible to logged-in users (auto-refreshed every authed call) but stolen-token windows shrink to 30s.
147
151
  - **CLI-heavy / long-running CI tokens:** `expiresIn: 3600` for one-hour bearer tokens. Pair with `issuer` / `audience` if multiple services consume the same JWT.
148
- - **Need immediate revocation:** set `revocationCheck: 'kv'` (Cloudflare runtime) — revoked tokens are rejected within seconds, and stamps are written automatically on user ban, member removal, role change, and scope-conferring row changes (see the [scope revocation notes](/define/scopes#revocation--ttl)). Or drop TTL to ~30s — similar effect with bounded delay and zero KV reads.
152
+ - **Need immediate revocation:** set `revocationCheck: 'kv'` (Cloudflare runtime) — revoked tokens are rejected within seconds, and stamps are written automatically on user ban, member removal, role change, and scope-conferring row changes (see the [scope revocation notes](/define/scopes#revocation--ttl)). It fails closed, so bearer auth then depends on KV being readable — declare `bindings.kv` on every environment and alert on `AUTH_REVOCATION_UNAVAILABLE`. Or drop TTL to ~30s — similar effect with bounded delay, zero KV reads, and no availability coupling.
149
153
 
150
- ## `auth.loginUrl` / `auth.profileUrl` — external sign-in for consumer Workers
154
+ ## `auth.loginUrl` — external sign-in for consumer Workers
151
155
 
152
- When a Quickback Worker doesn't host its own Account SPA — e.g. an internal-app mesh where one Worker on the parent domain owns identity (`auth.example.com`) and other Workers share cookies — the compiler-emitted CMS access gates need to redirect unauthenticated visitors to the central sign-in surface, not the local `/account/login` (which doesn't exist there).
156
+ When a Quickback Worker doesn't host its own Account SPA — e.g. an internal-app mesh where one Worker on the parent domain owns identity (`auth.example.com`) and other Workers share cookies — the compiler-emitted CMS access gate needs to redirect unauthenticated visitors to the central sign-in surface, not the local `/account/login` (which doesn't exist there).
153
157
 
154
158
  ```ts title="quickback.config.ts"
155
159
  export default defineConfig({
156
160
  // ...
157
161
  auth: {
158
162
  loginUrl: 'https://auth.example.com/login',
159
- profileUrl: 'https://auth.example.com/profile',
160
163
  },
161
164
  });
162
165
  ```
163
166
 
164
- Both fields override compiler-emitted browser redirects in the CMS shell:
165
-
166
167
  - **Unauthenticated visitor hits a CMS route** → `302 → <loginUrl>?redirect=<original-url>`
167
- - **Authenticated user fails the `cms.access: 'admin'` platform-role check** → `302 → <profileUrl>`
168
168
 
169
169
  The `?redirect=…` query param is preserved unchanged so the central sign-in surface can bounce the user back after authentication.
170
170
 
171
+ Signing in is the *only* thing the CMS gate redirects for. A signed-in caller who isn't admitted is served the CMS shell and shown a screen naming what they'd need — see [CMS access](/ui/admin#access-gate). There is no wrong-role redirect, and no `auth.profileUrl`.
172
+
173
+ > **Removed in v0.62:** `auth.profileUrl`. Its only consumer was the CMS wrong-role redirect. The config schema is strict, so a leftover `profileUrl` key now fails the compile — delete it.
174
+
175
+
171
176
  ### Resolution precedence
172
177
 
173
178
  Most-specific wins:
174
179
 
175
- 1. Explicit `auth.loginUrl` / `auth.profileUrl` — the cookie-trusting consumer-Worker case (this section).
180
+ 1. Explicit `auth.loginUrl` — the cookie-trusting consumer-Worker case (this section).
176
181
  2. `https://<account.domain>/login` — inferred when this project hosts its own Account SPA on a custom domain.
177
182
  3. `/account/login` — built-in fallback, when neither knob is set.
178
183
 
@@ -243,6 +243,33 @@ Binding names that clash with compiler-owned bindings are rejected at validation
243
243
 
244
244
  Pick a different name — the generated `env` on the handler side takes whatever binding you pick.
245
245
 
246
+ ## One name, one thing
247
+
248
+ Bindings and vars share a single namespace: `env.DB` is one slot, whatever
249
+ declares it. A name claimed twice within one deploy target fails the compile,
250
+ naming both claimants and what each points at:
251
+
252
+ ```
253
+ Two declarations claim the same name on env: "MEDIA" is claimed by
254
+ [r2_buckets] (studio-media) and by [r2_buckets] (studio-uploads) in the
255
+ top-level config.
256
+ ```
257
+
258
+ This catches what the reserved-name table above cannot — that compares your
259
+ names against compiler-owned ones, never against each other:
260
+
261
+ - two of your own declarations sharing a name (`r2Buckets`, `queueProducers`,
262
+ `services`, `durableObjects`);
263
+ - a [`vars`](/configure/variables) key shadowing a binding — the easy one to
264
+ miss, since a var looks nothing like a binding but lands on the same `env`;
265
+ - collisions inside a named environment's `[env.*]` stanza.
266
+
267
+ Scoped **per target**, so [named environments](/platform/database/d1#named-cloudflare-deployment-environments)
268
+ are unaffected: every target declares the same binding names pointing at its
269
+ own resources, and `ASSETS` is emitted at the top level and in each stanza by
270
+ design. Two identical declarations are redundant rather than ambiguous and are
271
+ allowed — only a name pointing at two *different* things is rejected.
272
+
246
273
  ## See also
247
274
 
248
275
  - [Environment Variables](/configure/variables) — the non-secret `[vars]` / secret split
@@ -88,7 +88,7 @@ The unified domain is useful for development and debugging. You can override it
88
88
  export default {
89
89
  name: "my-app",
90
90
  template: "hono",
91
- cms: { domain: "cms.example.com", access: "admin" },
91
+ cms: { domain: "cms.example.com", access: "sysadmin" },
92
92
  account: {
93
93
  domain: "auth.example.com",
94
94
  adminDomain: "admin.example.com",
@@ -96,7 +96,7 @@ Every optional top-level key the config accepts is listed below. You never have
96
96
  | `domain` | `string` | Primary custom domain (auto-inferred from `cms`/`account`/`api` domains if unset) — see [Domains](/configure/domains) |
97
97
  | `contract` | `{ version?: "v1" \| "v2" }` | Public API/auth contract version. Omit for the backward-compatible v1 default; select v2 for `/api/v2/*` and `/auth/v2/*` across generated routes, Better Auth, OpenAPI, MCP, and discovery. |
98
98
  | `api` | `object` | Dedicated hostname for the selected feature API contract (`/api/v1/*` or `/api/v2/*`); additive alias — see [Domains](/configure/domains) |
99
- | `auth` | `object` | App-level auth settings (`roleHierarchy`, `jwt`, delegated `principals`, `loginUrl`/`profileUrl`, `domain`) — see [Access](/define/access#role-hierarchy) and [Delegated principals](#delegated-principals-contract-v2) |
99
+ | `auth` | `object` | App-level auth settings (`roleHierarchy`, `jwt`, delegated `principals`, `loginUrl`, `domain`) — see [Access](/define/access#role-hierarchy) and [Delegated principals](#delegated-principals-contract-v2) |
100
100
  | `authz` | `object` | Relationship-based authorization (`relationships`, `roles`, `rules`, `tenants`, `permissions`, `arrows`) — see [Access](/define/authz-roles#centrally-defined-access-rules) and [Permissions](/define/permissions). `rules` = named gates (who + `record:` + firewall lanes under one name); `tenants` = named tenant anchors (`{ column, equals }`, referenced as `{ tenant: '<name>' }` in firewalls and `tenant: '<name>'` in auth-view includes). Root `authz` is the GLOBAL vocabulary level — names scoped to one concept belong in that concept's [feature area](/define/areas) (`_area.ts`), and root bodies may reference root-declared names only |
101
101
  | `requires` | `string[]` | Capability floor (fail-closed guard). Declare `['feature-areas']` when the project uses `features/**/_area.ts` — an area-unaware CLI/compiler then refuses the compile instead of silently dropping nested features. See [Feature areas](/define/areas#the-capability-floor-requires-feature-areas) |
102
102
  | `trustedOrigins` | `string[]` | CORS trusted origins for cross-domain auth |
@@ -574,7 +574,7 @@ cms: true,
574
574
  cms: { domain: "cms.example.com" },
575
575
 
576
576
  // With access control (only admins can access CMS)
577
- cms: { domain: "cms.example.com", access: "admin" },
577
+ cms: { domain: "cms.example.com", access: "sysadmin" },
578
578
 
579
579
  // Cross-tenant DB-admin tier — sysadmins see every tenant's data
580
580
  cms: { domain: "cms.example.com", sysadmin: true },
@@ -592,11 +592,11 @@ Quickback's default model assumes every CMS user belongs to at least one organiz
592
592
 
593
593
  `cms: { sysadmin: true }` introduces a separate role tier:
594
594
 
595
- - **Role**: `user.role === "sysadmin"` (set on the Better Auth user table). Distinct from `"appmanager"` — appmanagers keep platform control-plane access (CMS shell, Better Auth admin surfaces, support tooling), while sysadmins get true cross-tenant data access. `ADMIN` is now a rejected legacy pseudo-role; use `userRole: ["appmanager"]` for control-plane gates and `roles: ["SYSADMIN"]` for cross-tenant access.
595
+ - **Role**: `user.role === "sysadmin"` (set on the Better Auth user table). Distinct from `"appmanager"` — appmanagers keep platform control-plane access (Better Auth admin surfaces, organization and user management, support tooling — but NOT the CMS), while sysadmins get true cross-tenant data access. `ADMIN` is now a rejected legacy pseudo-role; use `userRole: ["appmanager"]` for control-plane gates and `roles: ["SYSADMIN"]` for cross-tenant access.
596
596
  - **Firewall**: every `buildFirewallConditions()` emits an `if (ctx.userRole === "sysadmin") return undefined` (or just the soft-delete predicate when present) at the top, so sysadmins see every tenant's rows. See [Firewall escape hatch](/define/firewall#sysadmin-escape-hatch).
597
597
  - **Org listing**: a `GET /auth/v1/admin/list-organizations` endpoint selects directly from the auth-schema `organization` table — every row, every tenant. Sits under Better Auth's admin URL namespace (sibling of `/auth/v1/admin/list-users`) so the URL shape matches BA convention; the handler is Quickback-emitted and gated to `user.role === "sysadmin"` only. For the membership-bound caller's-orgs listing, use BA's own `/auth/v1/organization/list`.
598
598
  - **CMS SPA**: when the user is a sysadmin, the header switcher loads from the cross-tenant endpoint, defaults to "All organizations" (which omits `?organizationId=` and reaches the firewall escape), and pins selected tenants via `?organizationId=` on every API call. Org admins keep the existing membership-based switcher.
599
- - **CMS HTML gate**: admits `userRole === "sysadmin"` alongside `"appmanager"`. Org admins are not locked out when you set `cms.access: "user"`; `cms.access: "admin"` is specifically the platform control-plane gate.
599
+ - **CMS gate**: `cms.access: "sysadmin"` (the default) admits the `sysadmin` tier only; `cms.access: "member"` also admits any caller with an organization membership. `appmanager` opens the CMS in neither mode — see [Access gate](/ui/admin#access-gate).
600
600
 
601
601
  Off by default. Projects that don't enable it get zero behavior change; setting `cms.sysadmin: true` and granting a user `user.role = "sysadmin"` is the only way to unlock the cross-tenant view.
602
602
 
@@ -754,7 +754,7 @@ A complete config with CMS, Account UI, and Admin on separate subdomains:
754
754
  export default {
755
755
  name: "my-app",
756
756
  template: "hono",
757
- cms: { domain: "cms.example.com", access: "admin" },
757
+ cms: { domain: "cms.example.com", access: "sysadmin" },
758
758
  account: {
759
759
  domain: "auth.example.com",
760
760
  adminDomain: "admin.example.com",
@@ -2,6 +2,23 @@
2
2
 
3
3
  Actions are custom API endpoints for business logic beyond CRUD operations. They enable workflows, integrations, and complex operations.
4
4
 
5
+ ## Before you write one — four primitives that may already do it
6
+
7
+ An action is a file you own and maintain. These are declarations the compiler
8
+ owns, and each generates the same real endpoint, OpenAPI operation, and MCP
9
+ tool, on the same firewall/access/guards pipeline. Check all four first — the
10
+ most common needless action is one of these hand-rolled.
11
+
12
+ | If the action would… | Declare instead | Where |
13
+ |---|---|---|
14
+ | check a row's current state, flip a column, stamp who/when | `transitions` on the table — plus `guard`, `stamp`/`clears` (which makes `execute` optional), `idempotent`, `undo`, `onEnter` cascades | [Transitions](/define/transitions) |
15
+ | write a parent row plus its owned children in one call | `changesets` — declare the `owns` boundary; each op still pays the child's own firewall, access, and guards | [Changesets](/define/changesets) |
16
+ | fire a side-effect after a write — denormalize a counter, stamp a column, enqueue a job | `triggers` — SQL triggers cover **every** write path (REST, actions, cron, raw SQL), not just the one route you remembered | [Triggers](/define/triggers) |
17
+ | return the same rows with a different column set per role | `read.views` — its own route, access rule, pagination, and masking | [Views](/define/views) |
18
+
19
+ Write the action for the remainder: third-party calls, multi-step orchestration,
20
+ AI/streaming responses, anything genuinely imperative.
21
+
5
22
  ## Overview
6
23
 
7
24
  Quickback supports two types of actions:
@@ -83,5 +100,6 @@ generated output.
83
100
  - **[Examples](/define/actions/examples)** — end-to-end action files
84
101
 
85
102
  Related: **[Transitions](/define/transitions)** for state-machine policy,
103
+ **[Changesets](/define/changesets)** for aggregate writes,
86
104
  **[Triggers](/define/triggers)** for after-commit hooks, and the
87
105
  **[Actions API](/api/actions)** for calling an action over HTTP.