@protobase/cli 0.105.0 → 0.105.2
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.105.
|
|
3
|
+
"version": "0.105.2",
|
|
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.105.
|
|
47
|
-
"@protobase/layout": "0.105.
|
|
48
|
-
"@protobase/query": "0.105.
|
|
49
|
-
"@protobase/schema": "0.105.
|
|
50
|
-
"@protobase/server": "0.105.
|
|
51
|
-
"@protobase/ui": "0.105.
|
|
52
|
-
"@protobase/workflows": "0.105.
|
|
46
|
+
"@protobase/config": "0.105.2",
|
|
47
|
+
"@protobase/layout": "0.105.2",
|
|
48
|
+
"@protobase/query": "0.105.2",
|
|
49
|
+
"@protobase/schema": "0.105.2",
|
|
50
|
+
"@protobase/server": "0.105.2",
|
|
51
|
+
"@protobase/ui": "0.105.2",
|
|
52
|
+
"@protobase/workflows": "0.105.2",
|
|
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",
|
|
@@ -19,6 +19,7 @@ Sign-in methods, users, roles, organizations and tokens.
|
|
|
19
19
|
- [Changing the address](../reference/auth.md#changing-the-address): People move their account to a new email address from the account page, once they enter the code sent there.
|
|
20
20
|
- [Deleting the account](../reference/auth.md#deleting-the-account): People delete their own account from the account page, after confirming it, in the web app and the mobile app. On by default; an app whose accounts an organization's admins manage turns it off.
|
|
21
21
|
- [Open sign-up](../reference/auth.md#open-sign-up): Anyone can create an account after confirming an emailed code.
|
|
22
|
+
- [Sign-up with the address only](../reference/auth.md#sign-up-with-the-address-only): Open sign-up can ask for nothing but the address, so the emailed sign-in code makes a new person's account on the spot; an invited address still gets the roles it was invited with.
|
|
22
23
|
- [Sign-up for email domains](../reference/auth.md#sign-up-for-email-domains): Open sign-up can take only addresses at your company's email domains, so colleagues make their own account and everyone else still needs an invitation.
|
|
23
24
|
- [Passkeys](../reference/auth.md#passkeys): People sign in with their device's face or fingerprint unlock, or with a security key.
|
|
24
25
|
- [Two-factor authentication](../reference/auth.md#two-factor-authentication): A second step with an authenticator app, backup codes or emailed codes.
|
|
@@ -173,7 +173,7 @@ export { usersPage } from '@protobase/layout' // at /accounts, for admins
|
|
|
173
173
|
export const accountMenu = userMenu((m) => [m.page('accounts', { label: 'Users', icon: 'users' })])
|
|
174
174
|
```
|
|
175
175
|
|
|
176
|
-
New apps have it already. Leave the export out to drop it, or make a page of your own around the [`Users` block](blocks.md#users). It works with or without [organizations](#organizations): an invitation to the app makes an account with the roles the admin ticked, from the same link page and sign-up as an organization's invitation, and someone with an account just signs in. Listing, creating, roles and blocking are Better Auth's admin endpoints (`/api/auth/admin/list-users`, `create-user`, `set-role`, `ban-user`, `unban-user`), whose roles go as a list; the rest are Protobase's, for admins only:
|
|
176
|
+
New apps have it already. Leave the export out to drop it, or make a page of your own around the [`Users` block](blocks.md#users). It works with or without [organizations](#organizations): an invitation to the app makes an account with the roles the admin ticked, from the same link page and sign-up as an organization's invitation, or from [open sign-up](#open-sign-up) with the invited address, and someone with an account just signs in. Listing, creating, roles and blocking are Better Auth's admin endpoints (`/api/auth/admin/list-users`, `create-user`, `set-role`, `ban-user`, `unban-user`), whose roles go as a list; the rest are Protobase's, for admins only:
|
|
177
177
|
|
|
178
178
|
| Endpoint | Does |
|
|
179
179
|
| --- | --- |
|
|
@@ -336,7 +336,7 @@ auth: { signInFirst: 'emailCode' }
|
|
|
336
336
|
```
|
|
337
337
|
|
|
338
338
|
- A code works for 10 minutes, once, and three wrong tries end it; asking again sends a new one and the old one stops working. Codes are stored hashed.
|
|
339
|
-
- It
|
|
339
|
+
- It creates no account, unless [open sign-up asks for the address only](#sign-up-with-the-address-only): an address no account uses gets no code but an email saying so, which suggests signing in with the address the person signed up with. The answer is the same either way, so it does not tell who has an account.
|
|
340
340
|
- Only sign-in codes are mailed this way. The plugin's own email verification and password reset endpoints are off (`404`), and asking for another type of code answers `400`. Its address change is on, as [Changing the address](#changing-the-address) describes.
|
|
341
341
|
- An account with [two-factor authentication](#two-factor-authentication) is asked for its second step after the code too, as after a password.
|
|
342
342
|
- An account created by Protobase 0.3 or earlier, which has a password, is marked verified the first time it uses a code. Otherwise Better Auth would treat the code as taking over an unverified account and delete its password.
|
|
@@ -355,12 +355,29 @@ The sign-in page then offers "Create an account", and so do [sign-in prompts](ui
|
|
|
355
355
|
- It needs mail: without a mailer it is not offered, `GET /api/auth/status` has no `signUp`, and its endpoints answer `404`. Not with [organizations](#organizations), whose people join by invitation.
|
|
356
356
|
- `POST /api/auth/sign-up/send-code` with `{ email }` mails the code. It answers the same whether the address has an account or not; an address that has one is mailed a note saying so instead of a code, with a link to the sign-in page, so nobody can tell from the answer, and no second account is made.
|
|
357
357
|
- `POST /api/auth/sign-up/verify-code` with `{ email, code }` checks the code on its own and answers `{ ticket }`. A code works for 10 minutes, once, and three wrong tries end it; asking again sends a new one. Codes are stored hashed.
|
|
358
|
-
- `POST /api/auth/sign-up/create` with `{ ticket, name, password? }` makes the account for the address whose code was right, and signs in. A ticket works for 30 minutes, once, and is stored hashed; a password the policy refuses leaves it for another try. A used or expired one answers `SIGN_UP_TICKET_INVALID`, and the sign-up starts again with the address.
|
|
358
|
+
- `POST /api/auth/sign-up/create` with `{ ticket, name, password? }` makes the account for the address whose code was right, and signs in. `name` is optional when sign-up [asks for the address only](#sign-up-with-the-address-only). A ticket works for 30 minutes, once, and is stored hashed; a password the policy refuses leaves it for another try. A used or expired one answers `SIGN_UP_TICKET_INVALID`, and the sign-up starts again with the address.
|
|
359
359
|
- The password follows the [sign-in policy](#sign-in-policy) as for an invitation: none while passwords are off, optional while emailed codes are on, 12 characters or more. What the policy requires, such as two-factor authentication, is set up after the first sign-in, as for every account.
|
|
360
|
+
- An address with a pending [invitation to the app](#users-page) gets its account through the invitation: with the roles the admin ticked instead of `role`, and the invitation is used up, as its link would. A revoked or expired invitation counts as none.
|
|
360
361
|
- The three requests are limited per minute and client like sign-in (`signInPerMinute`, default 5), and refused (`NO_ADMIN_YET`) while the store has no user.
|
|
361
362
|
- The `onUserCreated` [hook](#hooks) runs for every account made this way.
|
|
362
363
|
- `createAuthSession` from `@protobase/client` has the three steps as `sendSignUpCode(email)`, `verifySignUpCode(email, code)`, which resolves to the ticket, and `signUp({ ticket, name, password? })`, which resolves to the signed-in user.
|
|
363
364
|
|
|
365
|
+
### Sign-up with the address only
|
|
366
|
+
|
|
367
|
+
An app that needs nothing but a verified address, such as a sign-in server other apps send their people to, has open sign-up ask for the address alone:
|
|
368
|
+
|
|
369
|
+
```ts
|
|
370
|
+
auth: { roles: ['admin', 'member'], signUp: { role: 'member', fields: ['email'] } }
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
- `fields` is what sign-up asks for: `['email', 'name']` by default, or `['email']`. The address is always one of them; any other list stops the app at start with an error.
|
|
374
|
+
- The [emailed sign-in code](#emailed-sign-in-codes) then signs in an address that has an account, and makes the account of one that has none, on the spot, once its code is right: verified, with `role`, and an empty name the person can fill in on the [account page](#account-page). Asking for the code answers the same and mails the same email whether the address has an account or not.
|
|
375
|
+
- An address with a pending [invitation to the app](#users-page) gets its account through it, as with the sign-up page: the invited roles, and the invitation used up. A revoked or expired one counts as none.
|
|
376
|
+
- An address open sign-up does not take, outside [its domains](#sign-up-for-email-domains) or while the store has no user, still gets the no-account email and no account. While the [sign-in policy](#sign-in-policy) turns emailed codes off, asking for one is refused and nothing is made.
|
|
377
|
+
- "Create an account" makes the account as soon as its code is right, without asking a name; while the policy needs a password, because emailed codes are off, the last page asks only for that.
|
|
378
|
+
- `GET /api/auth/status` answers `signUpFields: ["email"]`, and `["email", "name"]` by default, beside `signUp`.
|
|
379
|
+
- Not with [organizations](#organizations), like all open sign-up: their people come in by invitation, and the emailed code never makes an account there.
|
|
380
|
+
|
|
364
381
|
### Sign-up for email domains
|
|
365
382
|
|
|
366
383
|
A company's app can let colleagues make their own account while everyone else still needs an invitation, with the email domains open sign-up takes:
|
|
@@ -610,8 +627,8 @@ auth: { signInProvider: { issuer, clientId, clientSecret, tokenSignIn: true } }
|
|
|
610
627
|
|
|
611
628
|
The client posts `POST /api/auth/sign-in/social` with `{ "provider": "<provider id>", "idToken": { "token": "<ID token>" } }`, as Better Auth's client sends `signIn.social({ provider, idToken: { token } })`, and gets the session cookie with `{ redirect: false, user }`, or `{ twoFactorRedirect: true, twoFactorMethods }` when the [second step](#two-factor-authentication) is due, which it finishes as after a password. Then `GET /api/auth/token` gives it the app's API token as for any session.
|
|
612
629
|
|
|
613
|
-
- **Only this app's own provider:** the app trusts the one provider it is configured with, and a token only for this app. The token must be signed with a key the provider publishes (its discovery's `jwks_uri`) with an asymmetric algorithm, come from the configured issuer, and have this app's client id as its one audience, so a token issued for another app is never accepted here. It must carry a `jti`
|
|
614
|
-
- **Once:** each token signs in once. Its
|
|
630
|
+
- **Only this app's own provider:** the app trusts the one provider it is configured with, and a token only for this app. The token must be signed with a key the provider publishes (its discovery's `jwks_uri`) with an asymmetric algorithm, come from the configured issuer, and have this app's client id as its one audience, so a token issued for another app is never accepted here. It must carry an `email` (a `jti` is not needed), live at most 5 minutes from `iat` to `exp`, and have been issued within the last 5 minutes (30 seconds of clock skew allowed). Otherwise it is refused with `401 INVALID_TOKEN`.
|
|
631
|
+
- **Once:** each token signs in once. Its issuer and the SHA-256 of its claims are kept in the `verification` table until it expires, with no migration, and a second use answers `401 TOKEN_USED`. The claims count, not the token's text, so the same token written another way is refused too, and so is a second token with exactly the same claims.
|
|
615
632
|
- **Who it signs in:** as through the provider's pages, the account linked to the provider's `sub`, else the account with the address the provider vouches for (`email_verified`), which it links. Nobody is signed up (`401`), and a banned person is refused.
|
|
616
633
|
- **Never recent:** the client can mint a fresh session at will, so a session a token began never counts as [recently signed in](#confirming-an-account-change). Adding a passkey, unlinking a provider, making a personal access token or deleting the account asks it to confirm it's them in place first, and it is never a [strong sign-in](#recent-strong-sign-in) until it confirms it's them.
|
|
617
634
|
- **The policy:** **Sign in with ... through the platform** in the [sign-in policy](#sign-in-policy) covers it, so Off refuses it, and so do passkeys being Required. Linking a provider with a token stays refused (`403 TOKEN_SIGN_IN_OFF`).
|
|
@@ -61,10 +61,10 @@ export default defineConfig({ auth: { organizations: { create: 'everyone', invit
|
|
|
61
61
|
|
|
62
62
|
## auth.signUp
|
|
63
63
|
|
|
64
|
-
- **Type:** `{ role: string; domains?: string[] }`
|
|
64
|
+
- **Type:** `{ role: string; domains?: string[]; fields?: ('email' | 'name')[] }`
|
|
65
65
|
- **Default:** off
|
|
66
66
|
|
|
67
|
-
Open sign-up: anyone makes their own account from the sign-in page, with `role`, after proving their address with an emailed code. Needs a mailer. `role` is one of [`roles`](#authroles) and never `admin`. `domains` takes only addresses at those email domains, subdomains included, and `PROTOBASE_SIGN_UP_DOMAINS` replaces it; an empty list leaves sign-up off. Not with organizations. See [Open sign-up](../auth.md#open-sign-up)
|
|
67
|
+
Open sign-up: anyone makes their own account from the sign-in page, with `role`, after proving their address with an emailed code. Needs a mailer. `role` is one of [`roles`](#authroles) and never `admin`. `domains` takes only addresses at those email domains, subdomains included, and `PROTOBASE_SIGN_UP_DOMAINS` replaces it; an empty list leaves sign-up off. `fields` is what it asks for, `['email', 'name']` by default; `['email']` has the emailed sign-in code make the account of a new address. Not with organizations. See [Open sign-up](../auth.md#open-sign-up), [Sign-up for email domains](../auth.md#sign-up-for-email-domains) and [Sign-up with the address only](../auth.md#sign-up-with-the-address-only).
|
|
68
68
|
|
|
69
69
|
```ts
|
|
70
70
|
export default defineConfig({ auth: { roles: ['admin', 'customer'], signUp: { role: 'customer' } } })
|