@protobase/cli 0.86.0 → 0.86.1

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.86.0";
2
+ var version = "0.86.1";
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.86.0",
3
+ "version": "0.86.1",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -43,13 +43,13 @@
43
43
  "dependencies": {
44
44
  "@better-auth/core": "^1.7.12",
45
45
  "@hono/node-server": "^2.1.3",
46
- "@protobase/config": "0.86.0",
47
- "@protobase/layout": "0.86.0",
48
- "@protobase/query": "0.86.0",
49
- "@protobase/schema": "0.86.0",
50
- "@protobase/server": "0.86.0",
51
- "@protobase/ui": "0.86.0",
52
- "@protobase/workflows": "0.86.0",
46
+ "@protobase/config": "0.86.1",
47
+ "@protobase/layout": "0.86.1",
48
+ "@protobase/query": "0.86.1",
49
+ "@protobase/schema": "0.86.1",
50
+ "@protobase/server": "0.86.1",
51
+ "@protobase/ui": "0.86.1",
52
+ "@protobase/workflows": "0.86.1",
53
53
  "@react-email/render": "^2.1.0",
54
54
  "@scalar/hono-api-reference": "^0.12.10",
55
55
  "@sentry/vite-plugin": "^11.10.0",
@@ -39,5 +39,6 @@ Sign-in methods, users, roles, organizations and tokens.
39
39
  - [Changing the secret](../reference/auth.md#changing-the-secret): The app's secret can change while the signing keys keep signing, by listing the old secret beside the new one.
40
40
  - [Tokens for scripts](../reference/auth.md#tokens-for-scripts-and-curl): A token for an existing user, for scripts and curl, in any organization they work in.
41
41
  - [Personal access tokens](../reference/personal-access-tokens.md): People make long-lived tokens on their account page for a script to call the API as them, see when each was last used, and revoke any of them. The app keeps only each token's hash.
42
+ - [OAuth tokens for the API](../reference/auth.md#oauth-tokens-for-the-api) (beta): A phone, watch or other app of your own signs people in through the app's own sign-in and calls the API as them with a bearer token, until they disconnect it.
42
43
  - [Several origins](../reference/auth.md#several-origins): One app works on several domains, such as its own address and a custom domain.
43
44
  - [Sign-in rate limits](../reference/auth.md#client-addresses): Sign-in and code requests are limited per client address, also behind a proxy.
@@ -222,7 +222,7 @@ The rules behind these steps are described under [Access](#access).
222
222
 
223
223
  Real login is the app's [sign-in](auth.md). Lower level:
224
224
 
225
- `authenticate(request)` returns `{ user: { id, roles }, tenant? }` or throws `unauthorized(...)` (a `401` problem), or `new MissingCredentials(...)` (also a `401`) when the request carries no credential at all. Shipped: `jwtAuthenticator({ jwksUrl | keys, issuer?, audience?, rolesClaim?, tenantClaim?, tenant? })`, which verifies a bearer token with `jose` (`sub` is the user id; `tenant` fixes the tenant instead of reading a claim), and the authenticator of the app's sign-in on top of it, which `authenticate` in the config sets ([Tokens and roles](auth.md#tokens-and-roles)); an authenticator of the project's own is the default export of `auth/authenticate.ts`. No code path treats a request as a user without verifying a credential; the one exception is the [anonymous role](access.md#anonymous-access), which the resources API gives a request that has none, when the project defines it.
225
+ `authenticate(request)` returns `{ user: { id, roles }, tenant? }` or throws `unauthorized(...)` (a `401` problem), or `new MissingCredentials(...)` (also a `401`) when the request carries no credential at all. Shipped: `jwtAuthenticator({ jwksUrl | keys, issuer?, audience?, rolesClaim?, tenantClaim?, tenant? })`, which verifies a bearer token with `jose` (`sub` is the user id; `tenant` fixes the tenant instead of reading a claim) and refuses a token bound to a key (`cnf`), which only a proof of that key may use, and the authenticator of the app's sign-in on top of it, which `authenticate` in the config sets ([Tokens and roles](auth.md#tokens-and-roles)) and which also takes [OAuth access tokens for the API](auth.md#oauth-tokens-for-the-api); an authenticator of the project's own is the default export of `auth/authenticate.ts`. No code path treats a request as a user without verifying a credential; the one exception is the [anonymous role](access.md#anonymous-access), which the resources API gives a request that has none, when the project defines it.
226
226
 
227
227
  ## CORS
228
228
 
@@ -780,7 +780,7 @@ auth: { mcp: { path: '/api/mcp', connectPage: '/-/connect' } }
780
780
  - `path` is the MCP endpoint's path on the origin of the app's `url`, its OAuth resource (default `/api/mcp`); `connectPage` is the connect page's path (default `/-/connect`, for a UI at the root). A client's metadata document is fetched through a transport that refuses private and reserved addresses.
781
781
  - It needs an https `url`, or localhost. Every store has the OAuth tables (see [migrations](#migrations)), so turning MCP on or off needs no migration. Turning it off drops nothing: the clients and grants stay, and work again once MCP is on, so disconnect the clients first to forget them. While MCP is off, ending a person's sessions, banning them or setting their password disconnects none of their clients. Clients connect through the origin of `url` only, whatever [other origins](#several-origins) the app has. Changing `path` makes every client connect again.
782
782
  - Clients find the provider at `/.well-known/oauth-protected-resource` and `/.well-known/oauth-authorization-server`, register at `/api/auth/oauth2/register` (dynamic registration) or are known by an https client id that names their metadata document (CIMD), and are asked for nothing per client. Back-channel logout, a key set URL at registration (`jwks_uri`) and the client credentials grant are refused, though a client with a metadata document may publish its keys on its own origin, and the provider's client management, userinfo, logout and consent endpoints are closed.
783
- - The scopes are `mcp` and `offline_access`, which is added when a client leaves it out. Access tokens last 15 minutes, carry the MCP resource as their audience and `typ: at+jwt`, and work for MCP only: the app's API refuses them, and the MCP endpoint refuses the app's own tokens. Refresh tokens roll for 30 days. The MCP endpoint verifies them, and checks on every request that the person still allows the client, still exists unbanned and still holds each role the token carries, so a disconnected client, a ban, a lowered role or a deleted user stops its access tokens at the next request rather than at their expiry; a lookup that fails refuses the request. A client that binds its tokens to a key (DPoP) sends a proof with each, checked against the resource's URL.
783
+ - The scopes are `mcp` and `offline_access`, which is added when a client leaves it out. Access tokens last 15 minutes, carry the MCP resource as their audience and `typ: at+jwt`, and work for MCP only: the app's API refuses them, and the MCP endpoint refuses the app's own tokens. Tokens for the API are [another resource](#oauth-tokens-for-the-api). Refresh tokens roll for 30 days. The MCP endpoint verifies them, and checks on every request that the person still allows the client, still exists unbanned and still holds each role the token carries, so a disconnected client, a ban, a lowered role or a deleted user stops its access tokens at the next request rather than at their expiry; a lookup that fails refuses the request. A client that binds its tokens to a key (DPoP) sends a proof with each, checked against the resource's URL.
784
784
  - A grant keeps the role and organization the person worked in when they allowed the client. A refresh is refused once they no longer hold that role or may no longer enter that organization, once the [sign-in policy](#sign-in-policy) requires something they have not set up, and while they are banned; access tokens already issued last out their 15 minutes. A grant made without a role is refused.
785
785
  - Someone who has not set up what the sign-in policy requires is sent to the setup page first. Staff signed in as a person cannot allow a client, nor disconnect one. An account whose address is not verified cannot connect a client until it signs in once with an emailed code: a provider sign-up whose provider did not vouch for the address, or a password account created before Protobase created accounts verified. With password-only sign-in, or without mail, it cannot.
786
786
  - The connect page shows the client's name as the client's own claim, who published it for a client with an https id, where the code goes (a website by its host, an app on this computer by its port, or an app on the device by its whole address), and the signed-in address. It cannot be used inside another site's frame, and Allow takes a click only once the page has been in front for half a second. `protobase serve` and `protobase dev` send `X-Frame-Options: DENY` and `Content-Security-Policy: frame-ancestors 'none'` with every page of the UI; a host that serves `public/` itself should send them too. A host's own consent screen arms its Allow button the same way with the guard `@protobase/ui` exports (see [the plugin API](plugins.md#api)).
@@ -788,6 +788,24 @@ auth: { mcp: { path: '/api/mcp', connectPage: '/-/connect' } }
788
788
  - Signing out everywhere, signing out the other devices, a password change, a password reset, an admin ending the person's sessions, banning them, setting their password or marking their address unverified, and `protobase users disable` disconnect every client and forget which were allowed, so each has to ask again; enabling a disabled user brings none back. Through the [endpoints for supabase-js](#supabase-js-and-supabasessr) the same holds for signing out with the `global` or `others` scope and for every new password set with `PUT /user`, since a password reset ends there too. Signing out of one browser, or a session expiring, disconnects nothing.
789
789
  - A refresh token presented again after it was rotated, outside the provider's 30-second window for a retried request, is taken for stolen: that client is disconnected for the person, its access tokens stop at the next request, and it has to ask again. Their other clients keep working.
790
790
 
791
+ ### OAuth tokens for the API
792
+
793
+ :::caution[Beta]
794
+ It needs `mcp` on, so the app serves its MCP endpoint too, and the API takes these tokens as bearer tokens only.
795
+ :::
796
+
797
+ With `oauth.api`, the same provider gives clients access tokens for the app's API, so an app of your own, such as a phone or watch app, signs people in through the app's own sign-in and calls the API as them with `Authorization: Bearer <token>`.
798
+
799
+ ```ts
800
+ auth: { mcp: true, oauth: { api: true } }
801
+ ```
802
+
803
+ - The API is the resource `/api` on the origin of the app's `url`, such as `https://app.example.com/api`. A client asks for it with that `resource` parameter (RFC 8707) at authorize; without one, its token is for MCP as before. A client registered before `oauth.api` was on cannot ask for it, and registers again.
804
+ - The person signs in and allows the client on the connect page, as for an MCP client. The token acts as them, with the role and organization they worked in when they allowed it, under the same access rules as their own token. MCP's write approval does not apply to the API, so the API refuses MCP's tokens and the MCP endpoint refuses the API's.
805
+ - Access tokens last 15 minutes and refresh for 30 days. On every request the API checks what the MCP endpoint checks: that the person still allows the client, still exists unbanned and still holds the token's role, so disconnecting the client on the account page, a ban, a lowered role or a deletion stops its tokens at the next request. Turning `oauth.api` off makes the API refuse them at once.
806
+ - Notifications and calls refuse these tokens, as they refuse an MCP client's.
807
+ - <gap>The app's API cannot take DPoP-bound access tokens because checking a proof against the API's URLs is not implemented.</gap> A token bound to a key is refused when it is sent as a bearer token.
808
+
791
809
  ## Several origins
792
810
 
793
811
  An app can be served on more than one origin, such as its platform address and the customer's own domain. `auth.origins` lists the others; it defaults to `PROTOBASE_ORIGINS`, which a platform sets:
@@ -306,6 +306,17 @@ Turns on the OAuth provider for MCP clients, and with it the MCP endpoint: a cli
306
306
  export default defineConfig({ auth: { mcp: true } })
307
307
  ```
308
308
 
309
+ ## auth.oauth
310
+
311
+ - **Type:** `{ api?: boolean }`
312
+ - **Default:** off
313
+
314
+ What the OAuth provider of [`auth.mcp`](#authmcp) serves besides MCP. `api: true` lets clients get access tokens for the app's API, such as a phone or watch app that signs people in on the connect page, which the API takes as `Authorization: Bearer <token>`. Needs `auth.mcp`; the server refuses to start without it. See [OAuth tokens for the API](../auth.md#oauth-tokens-for-the-api).
315
+
316
+ ```ts
317
+ export default defineConfig({ auth: { mcp: true, oauth: { api: true } } })
318
+ ```
319
+
309
320
  ## auth.personalAccessTokens
310
321
 
311
322
  - **Type:** `{ prefix: string }`