@protobase/cli 0.61.0 → 0.62.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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.61.0";
2
+ var version = "0.62.0";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.61.0",
3
+ "version": "0.62.0",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -42,12 +42,12 @@
42
42
  "dependencies": {
43
43
  "@better-auth/core": "^1.7.12",
44
44
  "@hono/node-server": "^2.1.3",
45
- "@protobase/config": "0.61.0",
46
- "@protobase/layout": "0.61.0",
47
- "@protobase/query": "0.61.0",
48
- "@protobase/schema": "0.61.0",
49
- "@protobase/server": "0.61.0",
50
- "@protobase/ui": "0.61.0",
45
+ "@protobase/config": "0.62.0",
46
+ "@protobase/layout": "0.62.0",
47
+ "@protobase/query": "0.62.0",
48
+ "@protobase/schema": "0.62.0",
49
+ "@protobase/server": "0.62.0",
50
+ "@protobase/ui": "0.62.0",
51
51
  "@react-email/render": "^2.1.0",
52
52
  "@scalar/hono-api-reference": "^0.12.10",
53
53
  "@tailwindcss/vite": "^4.3.3",
@@ -7,6 +7,7 @@ Decide who may read and change which records and fields.
7
7
  - [Roles and capabilities](../reference/access.md#capabilities): Roles defined in code grant capabilities per resource and action. A project with roles denies anything not granted.
8
8
  - [Field and row limits](../reference/access.md#capabilities): A role can be limited to listed fields and to rows that match a filter. A field added later stays hidden from that role until it is listed, and the server does not start with a limit on a field or resource that does not exist.
9
9
  - [Capability checks](../reference/access.md#wildcards-in-has-can-and-holds): Your code asks whether a user holds one capability, or all of a wildcard such as `vms.*`, and a check that could pass by accident is refused.
10
+ - [Named grants for secrets](../reference/access.md#resources-that-need-named-grants): A resource that holds secrets, such as webhook subscriptions, can be left out of wildcards like `*.read`, so only admins and roles that name it reach it.
10
11
  - [Field rules](../reference/access.md#field-rules-or-field-lists): Single fields, such as a cost price, can be hidden from every role that lacks a given capability.
11
12
  - [Owned records](../reference/data-config.md#access): Users can be limited to the records they own, or that their team owns, through an owner field. The server does not start when that field cannot hold the users' ids.
12
13
  - [Rules on the stored record](../reference/data-config.md#access): A rule can read the record as it is stored, such as one that refuses changes to a locked invoice.
@@ -37,11 +37,23 @@ A field is readable when the role's list allows it and the field's own [rule](#f
37
37
 
38
38
  ### Wildcards in has, can and holds
39
39
 
40
- A wildcard in a role grants everything it stands for: `*.read` reads every resource. What a check asks for is different, so the checks take wildcards in one place only:
40
+ A wildcard in a role grants everything it stands for: `*.read` reads every resource, except those that hold secrets and take only [named grants](#resources-that-need-named-grants). What a check asks for is different, so the checks take wildcards in one place only:
41
41
 
42
42
  - `roles.has(user, 'vms.update')` and `roles.can('vms.update')` ask for one capability, in any scope or limit the role holds it. They refuse a wildcard, at compile time and when called, since `vms.*` would pass for a role holding only `vms.read`: ask for each capability instead.
43
43
  - `roles.holds(user, 'vms.*')` asks for all of it, in every row and field: a role holding `*` or `vms.*` passes, one holding `vms.read`, `*.read`, `vms.update.own` or a `vms.update` limited to fields or rows does not. A scope asks for those rows at least: `orders.read.own` passes for a role holding `orders.read.own`, `orders.read` or `*.read`. API functions' `capability` is checked this way.
44
44
 
45
+ ### Resources that need named grants
46
+
47
+ A resource with `.explicitGrants()` is left out of wildcards over resources: only `*` itself and capabilities that name it, such as `webhook_subscriptions.read` or `webhook_subscriptions.*`, grant it, never `*.read` or `*.*`. A role written as "read everything" then reads nothing of it. The [webhook resources](webhooks.md#subscriptions-in-the-admin-app) are such resources, since their URLs and secrets let whoever reads them call the receivers. Mark a resource of your own this way when its records hold secrets.
48
+
49
+ ```ts
50
+ defineRoles({
51
+ admin: ['*'],
52
+ viewer: ['*.read'], // reads no webhook subscription
53
+ integrations: ['*.read', 'webhook_subscriptions.*', 'webhook_deliveries.read', 'webhook_deliveries.update'],
54
+ })
55
+ ```
56
+
45
57
  ## Anonymous access
46
58
 
47
59
  The role `anonymous` is what a request without a token acts as. A project without it answers such requests `401`, as always.
@@ -69,6 +69,7 @@ export const repairs = resource('repairs')
69
69
  | `.validate((record) => issues)` | A rule over the whole record, run after the field checks on every create and update. It returns `[{ field, message }]` or `undefined`; issues answer `400` with the field named. |
70
70
  | `.access({ ... })` | Rules per operation. See [Access](#access). |
71
71
  | `.events((e, r) => [...])` | What changes of its records mean, such as `orders.created`, captured in the database for every write. See [Events](events.md). |
72
+ | `.explicitGrants()` | Leaves the resource out of role wildcards such as `*.read`: only `*` and capabilities that name it grant it. For resources whose records hold secrets. See [Resources that need named grants](access.md#resources-that-need-named-grants). |
72
73
  | `.history()` | Keeps every change of its records with who made it, shown on the record page and listed for admins as Activity. See [Record history](history.md). |
73
74
  | `.comments()` | Lets whoever may read a record comment on it and @mention others who may, who are emailed; shown on the record page and listed for admins. See [Record comments](comments.md). |
74
75
 
@@ -116,7 +116,7 @@ It adds two pages, over a `webhooks` schema that [`protobase migration`](cli.md#
116
116
  - **Webhook subscriptions** (`webhook_subscriptions`, the table `webhooks.subscriptions`): a name, the events (`orders.created orders.large`, or `orders.*`), the URL, a filter, extra headers, full or thin payload, and whether it is enabled. The server sets the tenant and the owner, the person who made it, and makes the secret, which only a [reveal](api.md#sensitive-fields-and-audit) shows. Saving checks the events and the filter against the resources, and refuses a URL whose host is a private, loopback or link-local address.
117
117
  - **Webhook deliveries** (`webhook_deliveries`, a view over the delivery jobs): the deliveries that wait for their next try or failed for good, with their last error. A delivery leaves the list once it succeeds.
118
118
 
119
- Both are scoped to the tenant like any resource with `.tenant()`, and their access decides who may do what: `webhook_subscriptions.create`, `webhook_deliveries.update` and so on, as for the app's own resources.
119
+ Both are scoped to the tenant like any resource with `.tenant()`, and their access decides who may do what: `webhook_subscriptions.create`, `webhook_deliveries.update` and so on, as for the app's own resources. A role's wildcard over resources, such as `*.read`, grants none of them: their URLs and secrets let whoever reads them call the receivers, so with roles only admins (`*`) and roles that [name them](access.md#resources-that-need-named-grants) manage webhook subscriptions.
120
120
 
121
121
  A subscription made here **delivers as its owner**, with the role they act with now in its tenant (the [active role](auth.md#active-role) they last chose, else their first): only records and fields it may read. Letting people make subscriptions therefore grants them nothing they could not read already. The roles are read from the app's sign-in; a project that signs people in otherwise exports its own, `async ({ id, tenant }) => [...]`, as the default of `webhooks/owner-roles.ts`.
122
122