@protobase/cli 0.29.0 → 0.29.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.
package/dist/cli/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.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": {
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@hono/node-server": "^2.1.3",
|
|
37
37
|
"@hono/vite-dev-server": "^0.26.1",
|
|
38
|
-
"@protobase/layout": "0.29.
|
|
39
|
-
"@protobase/query": "0.29.
|
|
40
|
-
"@protobase/schema": "0.29.
|
|
41
|
-
"@protobase/server": "0.29.
|
|
42
|
-
"@protobase/ui": "0.29.
|
|
38
|
+
"@protobase/layout": "0.29.1",
|
|
39
|
+
"@protobase/query": "0.29.1",
|
|
40
|
+
"@protobase/schema": "0.29.1",
|
|
41
|
+
"@protobase/server": "0.29.1",
|
|
42
|
+
"@protobase/ui": "0.29.1",
|
|
43
43
|
"@react-email/render": "^2.1.0",
|
|
44
44
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
45
45
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -254,7 +254,7 @@ The guardrails:
|
|
|
254
254
|
- **Permission:** the ID token's `groups` claim must hold the configured group (default `protobase-staff-access`).
|
|
255
255
|
- **A strong, recent sign-in:** the provider must report a passkey or a second step (`amr` with `mfa`, `hwk` or `swk`, or an `acr` from `acrValues`), at most 15 minutes old (`auth_time`; the app asks with `max_age`). The person's own two-factor and passkey requirements do not apply to staff.
|
|
256
256
|
- **A reason**, kept in the log with who signed in as whom.
|
|
257
|
-
- **Short and stoppable:** the session lasts 30 minutes (`sessionMinutes`, at most 240), is never extended, ends with the browser, and "Stop staff session" (`POST /api/auth/staff/stop`) ends it and signs the browser out. An API token it got before
|
|
257
|
+
- **Short and stoppable:** the session lasts 30 minutes (`sessionMinutes`, at most 240), is never extended, ends with the browser, and "Stop staff session" (`POST /api/auth/staff/stop`) ends it and signs the browser out. An API token it got before stops working on its next request, like that of any [ended session](#when-a-token-stops-working).
|
|
258
258
|
- **No takeover:** a staff session cannot change the person's password, email, passkeys, two-factor authentication or sessions, nor save the sign-in policy (`403`, `STAFF_CANNOT_CHANGE_SIGN_IN`).
|
|
259
259
|
- **The app decides:** admins turn staff sign-in off, or have the person emailed each time, with the [sign-in policy](#sign-in-policy).
|
|
260
260
|
- **One way in:** Better Auth's own `/admin/impersonate-user` and `/admin/stop-impersonating` are off (`404`), so app admins cannot sign in as their people.
|
|
@@ -424,7 +424,7 @@ It is Better Auth's organization plugin, with its tables named in snake_case (`o
|
|
|
424
424
|
|
|
425
425
|
**Who gives which role.** Someone may give or take away a member's app role only if they hold it, in that organization or globally, or hold a role whose `grants` list it (`manager` above gives `accountant` without holding it); grants do not chain, and a superuser may give any. Only a superuser changes global roles. The creator of an organization becomes its owner with every app role (`creatorAppRoles`, default `'all'`), so they can give them on; for a role added later, list it in a role owners hold, or run `protobase organizations add-app-role <role> --to owners`.
|
|
426
426
|
|
|
427
|
-
**The organization in the token.** A new session starts in the organization the person last worked in, else their oldest membership. `/api/auth/token` adds `org` (the organization), `org_role` and `app_roles` (the membership's, narrowed to the active role), read when the token is issued
|
|
427
|
+
**The organization in the token.** A new session starts in the organization the person last worked in, else their oldest membership. `/api/auth/token` adds `org` (the organization), `org_role` and `app_roles` (the membership's, narrowed to the active role), read when the token is issued; a removed member's token, or one carrying an app role taken away, [stops working](#when-a-token-stops-working) on its next request. `betterAuthAuthenticator` makes `org` the tenant and `ctx.organization.id`, and adds `app_roles` to the global roles. `POST /api/auth/organization/switch` with `{ organizationId }` moves the session; the next token names the new organization, without signing in again. Someone with a global role may switch into any organization, without being a member, and sees there what those roles allow; each such entry is an `organization.entered` [audit event](api.md#audit-events)). `GET /api/auth/organization/search?query=&offset=` lists every organization for them, ordered by slug, 20 at a time with the `total`, narrowed by text in the name or slug; the Organizations page shows it as All organizations. A list across organizations stays a resource without `.tenant`, readable by the global role.
|
|
428
428
|
|
|
429
429
|
**Invitations.** Better Auth's `POST /api/auth/organization/invite-member` with `{ organizationId, email, role, appRoles }`; inviting again replaces the earlier invitation, and it works for `invitationDays` (default 7). The email links to `{baseURL}/-/invitation?token=…` (`invitationUrl`), with a token signed with `secret`, since members can read invitation ids; without a mailer, the answer carries the `link` to pass on. The link page shows `GET /api/auth/invitation?token=`, accepts with `POST /api/auth/invitation/accept` for someone signed in as the invited address, and makes an account with `POST /api/auth/invitation/sign-up` (`{ token, name, password? }`) for an address without one. The link page and its sign-up serve [invitations to the app](#users-page) too. [Open sign-up](#open-sign-up) is not available with organizations: an invitation is the address someone vouched for.
|
|
430
430
|
|
|
@@ -444,6 +444,22 @@ Sign in at `POST /api/auth/sign-in/email` (or with a code or passkey), then `GET
|
|
|
444
444
|
|
|
445
445
|
`jwtAuthenticator` accepts asymmetric signature algorithms only unless you pass `algorithms` explicitly (the tests do, for HS256), so a token cannot be forged with a public key used as an HMAC secret; Better Auth signs with its own key pair and publishes the public keys at `/api/auth/jwks`. An expired, tampered, wrongly signed or missing token is a `401` problem with `WWW-Authenticate: Bearer`; with an [anonymous role](access.md#anonymous-access)), a missing one on the resources API is served as that role instead.
|
|
446
446
|
|
|
447
|
+
### When a token stops working
|
|
448
|
+
|
|
449
|
+
With `auth`, `betterAuthAuthenticator` checks on every request that the token still stands, so these take effect on the next request every route that authenticates sees (the resources API, `/api/meta`, batches, functions, files and new `/live` streams), not when the token expires:
|
|
450
|
+
|
|
451
|
+
| Change | The token |
|
|
452
|
+
| --- | --- |
|
|
453
|
+
| A ban (`/admin/ban-user`, `protobase users disable`) | is refused until the ban runs out or is lifted; a ban ends the sessions too, so a new token takes signing in again. |
|
|
454
|
+
| A role taken away (`/admin/set-role`, `setUserRole`, a membership's app roles) | carrying that role is refused; the client's retry gets a token from its session with the roles left. A token carrying fewer roles than held keeps working. |
|
|
455
|
+
| The user deleted | is refused. |
|
|
456
|
+
| Signing out, a revoked session, a stopped staff session | of that session is refused; the person's other sessions keep theirs. |
|
|
457
|
+
| Removal from the organization | naming that organization is refused, unless a global role still enters it. |
|
|
458
|
+
|
|
459
|
+
A refused token is a `401`, as an expired one is, and the client retries the request once with a new token from `/api/auth/token`. Tokens carry their session's id in `sid`; one from [`issueToken`](#tokens-for-scripts-and-curl) names none, and is checked against the user alone.
|
|
460
|
+
|
|
461
|
+
The cost is two or three lookups by key in the auth store per request: the session by `sid`, the user by `sub`, and with organizations the membership. Nothing is cached, so every server process sees a change at once. An open `/live` stream was admitted when it connected and keeps running until it closes. With `jwksUrl` instead of `auth`, the API cannot read the auth store and a token works until it expires, as do tokens of [other apps](#users-of-another-app).
|
|
462
|
+
|
|
447
463
|
## Users of another app
|
|
448
464
|
|
|
449
465
|
An API can admit the signed-in users of another Protobase app with the tokens that app issues, so that app's admin app can draw its resources as [remote resources](remote-resources.md)). `betterAuthAuthenticator`'s `apps` lists each such app by its `baseURL`, the issuer of its tokens, with the roles its users' global roles become here:
|
|
@@ -479,7 +495,7 @@ import { issueToken } from '@protobase/server'
|
|
|
479
495
|
const { token, expiresAt } = await issueToken(auth, { email: 'you@example.com', ttlSeconds: 3600 }) // default 15 minutes, at most 24 hours
|
|
480
496
|
```
|
|
481
497
|
|
|
482
|
-
It is signed with the same keys and carries the same claims as a token from `/api/auth/token`, with the role the user last chose, else their first, so the API treats it as any other. Banned and unknown users get an error. There is no HTTP route for this.
|
|
498
|
+
It is signed with the same keys and carries the same claims as a token from `/api/auth/token`, with the role the user last chose, else their first, so the API treats it as any other, and a ban, a role taken away or the user deleted ends it before it expires. Banned and unknown users get an error. There is no HTTP route for this.
|
|
483
499
|
|
|
484
500
|
## Several origins
|
|
485
501
|
|
|
@@ -423,7 +423,7 @@ Run inside a project whose `protobase.config.ts` exports `auth` (Better Auth). T
|
|
|
423
423
|
|
|
424
424
|
The password is typed at a hidden prompt with confirmation, read from stdin with `--password-stdin` (for scripts, e.g. `pass show erp | protobase users create me@example.com --password-stdin`), or generated with `--generate-password` and printed once. `--no-password` makes an account without one, which signs in by [emailed code](auth.md#emailed-sign-in-codes)), passkey or a sign-in provider, as with an app whose [sign-in policy](auth.md#sign-in-policy)) turns passwords off. A password is never accepted as an argument, since it would end up in shell history. `users list` prints email, role and creation date (and `disabled` for banned users), never credentials.
|
|
425
425
|
|
|
426
|
-
`delete` asks you to type the email back (or pass `--yes`), and needs a terminal otherwise. `delete`, `set-role` and `disable` refuse to touch the last admin, so the project cannot lock itself out. `disable` bans the user and revokes their sessions; tokens already issued stop working
|
|
426
|
+
`delete` asks you to type the email back (or pass `--yes`), and needs a terminal otherwise. `delete`, `set-role` and `disable` refuse to touch the last admin, so the project cannot lock itself out. `disable` bans the user and revokes their sessions; tokens already issued stop working on their next request, and `protobase token` refuses disabled users. `enable` lifts the ban. `protobase dev` prints "No users yet. Create the first admin with: protobase users create you@example.com" at startup while the user table is empty.
|
|
427
427
|
|
|
428
428
|
With [organizations](auth.md#organizations)), `--role` is the user's global role (none by default) and `--organization` adds the new user to an organization, with `--org-role` (`owner`, `admin`, or `member`, the default) and `--app-roles` there.
|
|
429
429
|
|