@protobase/cli 0.48.0 → 0.49.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/build/config-bundle.js +6 -1
- package/dist/build/entry-code.js +30 -17
- package/dist/cli/package.js +1 -1
- package/dist/config/build-project.js +73 -0
- package/dist/config/called-config.js +11 -0
- package/dist/config/config-defaults.js +33 -0
- package/dist/config/env-values.js +20 -0
- package/dist/config/lazy-imports.js +18 -0
- package/dist/config/merge-config.js +72 -0
- package/dist/config/project-files.js +48 -0
- package/dist/config/project-parts.js +201 -0
- package/dist/config/read-config.js +31 -0
- package/dist/config/source-config.js +37 -0
- package/dist/dev/create-db.js +2 -2
- package/dist/dev/entry.js +9 -10
- package/dist/dev/project.js +23 -47
- package/dist/main.js +3 -3
- package/dist/migration/load-project.js +34 -34
- package/dist/migration/parts.js +2 -2
- package/dist/migration/summary.js +2 -2
- package/dist/mobile/api-origin.js +4 -4
- package/dist/mobile/load-project.js +13 -12
- package/dist/mobile/register.js +1 -1
- package/dist/mobile/run.js +1 -1
- package/dist/organizations/register.js +1 -1
- package/dist/project/error-reporter.js +3 -3
- package/dist/project/import-project-file.js +4 -2
- package/dist/project/load-bundle-project.js +16 -25
- package/dist/project/load-data-config.js +1 -1
- package/dist/project/pg-db.js +10 -4
- package/dist/project/placeholder-secret.js +2 -2
- package/dist/project/project-admin.js +12 -11
- package/dist/serve/create-admin.js +9 -4
- package/dist/serve/host-module-ids.js +1 -0
- package/dist/serve/host-modules.js +3 -1
- package/dist/serve/lifecycle.js +17 -13
- package/dist/serve/load-bundle.js +41 -11
- package/dist/serve/mobile-release.js +1 -1
- package/dist/serve/serve-bundle.js +3 -3
- package/dist/supabase/auth-config.js +33 -28
- package/dist/supabase/config-jobs.js +28 -27
- package/dist/supabase/config-object.js +25 -0
- package/dist/supabase/cron-job-file.js +13 -14
- package/dist/supabase/cron-jobs-write.js +6 -12
- package/dist/supabase/cron-plan.js +3 -51
- package/dist/supabase/project-files.js +4 -9
- package/dist/supabase/report.js +3 -3
- package/dist/users/load-auth.js +16 -15
- package/dist/worker/start-worker.js +18 -15
- package/package.json +8 -6
- package/skills/protobase/SKILL.md +8 -1
- package/skills/protobase/references/features/notifications.md +1 -1
- package/skills/protobase/references/features/sign-in-and-accounts.md +2 -0
- package/skills/protobase/references/features/start-a-project.md +9 -0
- package/skills/protobase/references/getting-started.md +14 -14
- package/skills/protobase/references/guides/api-functions.md +4 -4
- package/skills/protobase/references/guides/deploy.md +8 -8
- package/skills/protobase/references/guides/existing-database.md +11 -31
- package/skills/protobase/references/guides/export-a-list.md +1 -1
- package/skills/protobase/references/guides/field-type.md +1 -1
- package/skills/protobase/references/guides/first-composed-page.md +1 -1
- package/skills/protobase/references/guides/first-plugin.md +2 -2
- package/skills/protobase/references/guides/import-records.md +1 -1
- package/skills/protobase/references/guides/mobile-app.md +5 -3
- package/skills/protobase/references/guides/personal-setting.md +1 -1
- package/skills/protobase/references/guides/plugin-build.md +1 -1
- package/skills/protobase/references/guides/push-notifications.md +7 -8
- package/skills/protobase/references/guides/record-card.md +1 -1
- package/skills/protobase/references/guides/remote-resources.md +23 -32
- package/skills/protobase/references/guides/theme-an-app.md +1 -1
- package/skills/protobase/references/reference/access.md +3 -3
- package/skills/protobase/references/reference/ai.md +1 -9
- package/skills/protobase/references/reference/api.md +16 -16
- package/skills/protobase/references/reference/app-identity.md +9 -10
- package/skills/protobase/references/reference/architecture.md +4 -4
- package/skills/protobase/references/reference/assistant.md +6 -6
- package/skills/protobase/references/reference/auth.md +139 -86
- package/skills/protobase/references/reference/blocks.md +1 -1
- package/skills/protobase/references/reference/bottom-bar.md +2 -2
- package/skills/protobase/references/reference/cli.md +42 -92
- package/skills/protobase/references/reference/client.md +2 -2
- package/skills/protobase/references/reference/comments.md +0 -8
- package/skills/protobase/references/reference/config/admin-app.md +62 -0
- package/skills/protobase/references/reference/config/api.md +164 -0
- package/skills/protobase/references/reference/config/app.md +112 -0
- package/skills/protobase/references/reference/config/files.md +99 -0
- package/skills/protobase/references/reference/config/jobs-and-events.md +267 -0
- package/skills/protobase/references/reference/config/sign-in.md +396 -0
- package/skills/protobase/references/reference/config.md +170 -0
- package/skills/protobase/references/reference/custom-components.md +2 -2
- package/skills/protobase/references/reference/data-config.md +4 -4
- package/skills/protobase/references/reference/email.md +36 -37
- package/skills/protobase/references/reference/events.md +1 -1
- package/skills/protobase/references/reference/files.md +18 -23
- package/skills/protobase/references/reference/forms.md +5 -17
- package/skills/protobase/references/reference/history.md +2 -3
- package/skills/protobase/references/reference/installable-app.md +1 -1
- package/skills/protobase/references/reference/jobs.md +53 -56
- package/skills/protobase/references/reference/languages.md +4 -2
- package/skills/protobase/references/reference/mcp.md +10 -10
- package/skills/protobase/references/reference/notifications.md +26 -24
- package/skills/protobase/references/reference/plugins.md +11 -14
- package/skills/protobase/references/reference/remote-resources.md +18 -24
- package/skills/protobase/references/reference/sidebar.md +2 -2
- package/skills/protobase/references/reference/supabase-realtime.md +1 -1
- package/skills/protobase/references/reference/supabase-rest.md +1 -1
- package/skills/protobase/references/reference/supabase-storage.md +1 -1
- package/skills/protobase/references/reference/ui-config.md +20 -22
- package/skills/protobase/references/reference/user-menu.md +1 -1
- package/skills/protobase/references/reference/versioning.md +1 -1
- package/skills/protobase/references/reference/webhooks.md +6 -7
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
<!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/reference/config/sign-in.md: run `bun run docs:skill`, do not edit. -->
|
|
2
|
+
|
|
3
|
+
# Sign-in options
|
|
4
|
+
|
|
5
|
+
The config keys of sign-in, auth and authenticate, each with its type, default and environment variable, and the files where sign-in's hooks, mailer, mail templates and an authenticator of the project's own go.
|
|
6
|
+
|
|
7
|
+
The keys of sign-in and of how the API verifies tokens, in [`protobase.config.ts`](../config.md). The app's URL, secrets and name, which sign-in uses, are the top-level [`url`, `secret`, `previousSecrets` and `name`](app.md). How sign-in works is in [Login with Better Auth](../auth.md).
|
|
8
|
+
|
|
9
|
+
## auth
|
|
10
|
+
|
|
11
|
+
- **Type:** `AuthConfig | false`
|
|
12
|
+
- **Default:** on, with the defaults below; off when [`authenticate.jwksUrl`](#authenticatejwksurl) trusts an auth server elsewhere
|
|
13
|
+
|
|
14
|
+
Sign-in, with its store in the app's own database. `false` turns it off; an app without sign-in then verifies tokens with [`authenticate`](#authenticate) or `auth/authenticate.ts`.
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
export default defineConfig({ auth: { roles: ['admin', 'sales'], signInFirst: 'emailCode' } })
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Sign-in runs the project's own code from these files, each loaded when Protobase builds sign-in:
|
|
21
|
+
|
|
22
|
+
- `auth/hooks.ts`: the hooks, as named exports typed with `AuthHooks` from `@protobase/server`: `generateUserId`, `onUserCreated`, `generateOrganizationId`, `onOrganizationCreated`, `beforeOrganizationDeleted` and `organizationHooks`. Each gets the app's database, `{ db }`, as its last argument. See [Hooks](../auth.md#hooks).
|
|
23
|
+
- `auth/mailer.ts`: a mailer of the project's own for sign-in's mail, as its default export, in place of the SMTP mailer. See [Email](../email.md).
|
|
24
|
+
- `emails/`: the templates of sign-in's mail. See [Templates](../email.md#templates).
|
|
25
|
+
|
|
26
|
+
With [extensions](../config.md#extensions), the hooks and the mailer are those of the last folder whose config sets `auth`.
|
|
27
|
+
|
|
28
|
+
## auth.roles
|
|
29
|
+
|
|
30
|
+
- **Type:** `string[] | Record<string, string | { label: string; grants?: string[] }>`
|
|
31
|
+
- **Default:** `['admin', 'user']`
|
|
32
|
+
|
|
33
|
+
The roles users can hold. `admin` is always included. With [`organizations`](#authorganizations), give each a label, and optionally the other roles its holders may also give members. The capabilities each role has are `config/roles.ts`'s (see [Access](../access.md)). See [Roles](../auth.md#roles).
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
export default defineConfig({
|
|
37
|
+
auth: { roles: { manager: { label: 'Manager', grants: ['sales'] }, sales: 'Sales' }, organizations: true },
|
|
38
|
+
})
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## auth.defaultRole
|
|
42
|
+
|
|
43
|
+
- **Type:** `string`
|
|
44
|
+
- **Default:** none; with exactly one role besides `admin`, that role
|
|
45
|
+
|
|
46
|
+
The role of a user created without one. Without a default, and with more than one role besides `admin`, creating a user without a role is an error that asks for one.
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
export default defineConfig({ auth: { roles: ['admin', 'sales', 'warehouse'], defaultRole: 'sales' } })
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## auth.organizations
|
|
53
|
+
|
|
54
|
+
- **Type:** `true | { create?: 'admins' | 'everyone'; creatorAppRoles?: 'all' | string[]; invitationDays?: number; membershipLimit?: number; deleteRecords?: 'refuse' | 'cascade'; invitationUrl?: string }`
|
|
55
|
+
- **Default:** off: the app works as one organization
|
|
56
|
+
|
|
57
|
+
Turns on organizations: people work in one at a time, records of `.tenant` resources are scoped to it, and roles are held globally or per membership. `create` is who may create one (default `admins`), `creatorAppRoles` the roles its creator holds there (default `all`), `invitationDays` how long an invitation works (default 7), `membershipLimit` the most members (default 1000), `deleteRecords` whether deleting one is refused while it has records (`refuse`, the default) or left to the foreign keys (`cascade`), and `invitationUrl` the page an invitation opens (default `<url>/-/invitation`). Its hooks are in `auth/hooks.ts`. See [Organizations](../auth.md#organizations).
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
export default defineConfig({ auth: { organizations: { create: 'everyone', invitationDays: 14 } } })
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## auth.signUp
|
|
64
|
+
|
|
65
|
+
- **Type:** `{ role: string }`
|
|
66
|
+
- **Default:** off
|
|
67
|
+
|
|
68
|
+
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`. Not with organizations. See [Open sign-up](../auth.md#open-sign-up).
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
export default defineConfig({ auth: { roles: ['admin', 'customer'], signUp: { role: 'customer' } } })
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## auth.signInPolicy
|
|
75
|
+
|
|
76
|
+
- **Type:** `Partial<{ password: 'allowed' | 'forbidden'; emailCode: 'allowed' | 'forbidden'; passkey: 'allowed' | 'required' | 'forbidden'; twoFactor: 'allowed' | 'required' | 'forbidden'; staffAccess: 'allowed' | 'notify' | 'forbidden'; platformSignIn: 'allowed' | 'forbidden' }>`
|
|
77
|
+
- **Default:** everything allowed
|
|
78
|
+
|
|
79
|
+
The sign-in policy that applies until an admin saves one on the Sign-in policy page, and when the saved one no longer reads. Checked at startup as an admin's save is. See [Sign-in policy](../auth.md#sign-in-policy).
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
export default defineConfig({ auth: { signInPolicy: { password: 'forbidden', twoFactor: 'required' } } })
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## auth.signInFirst
|
|
86
|
+
|
|
87
|
+
- **Type:** `'password' | 'emailCode'`
|
|
88
|
+
- **Default:** `password`
|
|
89
|
+
|
|
90
|
+
What the sign-in page leads with: the address and a password, with emailing a code below it; or the address and "Email me a sign-in code", with the password behind "Use a password". Only while the policy leaves both on. See [Emailed sign-in codes](../auth.md#emailed-sign-in-codes).
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
export default defineConfig({ auth: { signInFirst: 'emailCode' } })
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## auth.signInPerMinute
|
|
97
|
+
|
|
98
|
+
- **Type:** `number`
|
|
99
|
+
- **Default:** `5`
|
|
100
|
+
|
|
101
|
+
Sign-in attempts allowed per minute and client, and the sign-up requests allowed. See [Client addresses](../auth.md#client-addresses) for how a client is known.
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
export default defineConfig({ auth: { signInPerMinute: 10 } })
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## auth.mailer
|
|
108
|
+
|
|
109
|
+
- **Type:** `false`
|
|
110
|
+
- **Default:** SMTP with `PROTOBASE_SMTP_URL` and `PROTOBASE_MAIL_FROM`, when set
|
|
111
|
+
- **Environment variables:** `PROTOBASE_SMTP_URL`, `PROTOBASE_MAIL_FROM`
|
|
112
|
+
|
|
113
|
+
`false` turns sign-in's mail off whatever the environment says: password reset, emailed codes, sign-up, staff sign-in and invitations are then not offered. A mailer of the project's own is `auth/mailer.ts`. See [Email](../email.md#configuration).
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
export default defineConfig({ auth: { mailer: false } })
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## auth.socialProviders
|
|
120
|
+
|
|
121
|
+
- **Type:** Better Auth's `socialProviders`
|
|
122
|
+
- **Default:** none
|
|
123
|
+
|
|
124
|
+
Sign-in providers, such as `{ github: { clientId, clientSecret } }`; the callback is `<url>/api/auth/callback/<provider>`. A provider also signs up people without an account, with the default role. See [Sign-in with GitHub](../auth.md#sign-in-with-github).
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
export default defineConfig(({ env }) => ({
|
|
128
|
+
auth: { socialProviders: { github: { clientId: env.GITHUB_CLIENT_ID!, clientSecret: env.GITHUB_CLIENT_SECRET! } } },
|
|
129
|
+
}))
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## auth.encryptOAuthTokens
|
|
133
|
+
|
|
134
|
+
- **Type:** `boolean`
|
|
135
|
+
- **Default:** `false`
|
|
136
|
+
|
|
137
|
+
Encrypts the OAuth access, refresh and ID tokens kept for social sign-ins, with the app's secret.
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
export default defineConfig({ auth: { encryptOAuthTokens: true } })
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## auth.sso
|
|
144
|
+
|
|
145
|
+
- **Type:** `{ saml: { id: string; name?: string; domains: string[]; idp: { metadata: string } | { entityId: string; ssoUrl: string; certificate: string | string[] }; attributes?: { email?: string; name?: string; firstName?: string; lastName?: string } }[] }`
|
|
146
|
+
- **Default:** none
|
|
147
|
+
|
|
148
|
+
Single sign-on with SAML 2.0 identity providers. A provider signs up people without an account, with the default role, but only at its `domains`, where it also links to the account with the same address. `name` defaults to `SSO`. See [Sign-in with SAML](../auth.md#sign-in-with-saml).
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
export default defineConfig(({ env }) => ({
|
|
152
|
+
auth: { sso: { saml: [{ id: 'okta', name: 'Okta', domains: ['example.com'], idp: { metadata: env.OKTA_METADATA! } }] } },
|
|
153
|
+
}))
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## auth.signInProvider
|
|
157
|
+
|
|
158
|
+
- **Type:** `{ issuer: string; clientId: string; clientSecret: string; provider?: string; name?: string; scopes?: string[] } | false`
|
|
159
|
+
- **Default:** the provider of the environment variables below, when set
|
|
160
|
+
- **Environment variables:** `PROTOBASE_SIGN_IN_ISSUER`, `PROTOBASE_SIGN_IN_CLIENT_ID`, `PROTOBASE_SIGN_IN_CLIENT_SECRET`, and optionally `PROTOBASE_SIGN_IN_PROVIDER` and `PROTOBASE_SIGN_IN_NAME`
|
|
161
|
+
|
|
162
|
+
An OpenID Connect provider the platform adds for people who already have an account; it never signs anyone up. `provider` is its id (default `oidc`), `name` its button's name. `false` turns it off whatever the environment says. Left out when `socialProviders` has a provider with the same id. See [Platform sign-in provider](../auth.md#platform-sign-in-provider).
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
export default defineConfig({ auth: { signInProvider: false } })
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## auth.operator
|
|
169
|
+
|
|
170
|
+
- **Type:** `{ issuer: string; clientId: string; clientSecret: string; name?: string; group?: string; scopes?: string[]; acrValues?: string[]; sessionMinutes?: number } | false`
|
|
171
|
+
- **Default:** the provider of the environment variables below, when set
|
|
172
|
+
- **Environment variables:** `PROTOBASE_OPERATOR_ISSUER`, `PROTOBASE_OPERATOR_CLIENT_ID`, `PROTOBASE_OPERATOR_CLIENT_SECRET`, and optionally `PROTOBASE_OPERATOR_NAME` and `PROTOBASE_OPERATOR_GROUP`
|
|
173
|
+
|
|
174
|
+
The identity provider the operator's staff sign in with to sign in as people of this app, for support. `group` is the ID token's group that allows it (default `protobase-staff-access`), and `sessionMinutes` how long a staff session lasts (default 30, at most 240). `false` turns staff sign-in off whatever the environment says. See [Staff sign-in](../auth.md#staff-sign-in).
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
export default defineConfig({ auth: { operator: false } })
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## auth.passwordHashes
|
|
181
|
+
|
|
182
|
+
- **Type:** `'bcrypt'[]`
|
|
183
|
+
- **Default:** none
|
|
184
|
+
|
|
185
|
+
Password hashes another system wrote that sign-in accepts besides Better Auth's own, such as Supabase Auth's bcrypt. The first sign-in with one stores the password again as Better Auth hashes it. See [An existing users table](../auth.md#an-existing-users-table).
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
export default defineConfig({ auth: { passwordHashes: ['bcrypt'] } })
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## auth.leakedPasswords
|
|
192
|
+
|
|
193
|
+
- **Type:** `boolean`
|
|
194
|
+
- **Default:** `false`
|
|
195
|
+
|
|
196
|
+
Refuses a new password that appears in a known data breach, by Have I Been Pwned's list. Only the first five characters of the password's SHA-1 hash leave the server. See [Leaked passwords](../auth.md#leaked-passwords).
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
export default defineConfig({ auth: { leakedPasswords: true } })
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## auth.users
|
|
203
|
+
|
|
204
|
+
- **Type:** `{ table?: string; columns?: Record<string, string>; metadata?: string }`
|
|
205
|
+
- **Default:** the table `protobase auth migration` makes
|
|
206
|
+
|
|
207
|
+
The user table, when another system made it, such as Supabase's `auth.users`: its name, the columns named otherwise than Protobase names them, and a JSON column for each user's metadata. See [An existing users table](../auth.md#an-existing-users-table).
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
export default defineConfig({
|
|
211
|
+
auth: { schema: 'auth', users: { table: 'users', columns: { role: 'app_role' }, metadata: 'raw_user_meta_data' } },
|
|
212
|
+
})
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## auth.schema
|
|
216
|
+
|
|
217
|
+
- **Type:** `string`
|
|
218
|
+
- **Default:** `auth`
|
|
219
|
+
|
|
220
|
+
The schema of the auth store in the app's database. See [Admin store](../auth.md#admin-store).
|
|
221
|
+
|
|
222
|
+
```ts
|
|
223
|
+
export default defineConfig({ auth: { schema: 'accounts' } })
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## auth.generateUserId
|
|
227
|
+
|
|
228
|
+
- **Type:** `'uuid'`
|
|
229
|
+
- **Default:** Better Auth's random 32-character text
|
|
230
|
+
|
|
231
|
+
`'uuid'` gives new users a random UUID, and makes every id column of the store a `uuid`. To take ids from the app instead, such as its own users sequence, export `generateUserId` from `auth/hooks.ts`.
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
export default defineConfig({ auth: { generateUserId: 'uuid' } })
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## auth.origins
|
|
238
|
+
|
|
239
|
+
- **Type:** `string[]`
|
|
240
|
+
- **Default:** `PROTOBASE_ORIGINS`, comma separated; none otherwise
|
|
241
|
+
- **Environment variable:** `PROTOBASE_ORIGINS`
|
|
242
|
+
|
|
243
|
+
The other origins the app is served on, besides `url`. A request to one is answered for that host: its sign-in callbacks and the links it mails stay there, and passkeys work on every origin. Tokens keep `url` as issuer. See [Several origins](../auth.md#several-origins).
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
export default defineConfig({ auth: { origins: ['https://admin.shop.com'] } })
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## auth.passkeyDomain
|
|
250
|
+
|
|
251
|
+
- **Type:** `string`
|
|
252
|
+
- **Default:** `PROTOBASE_PASSKEY_DOMAIN`, else the host of `url`
|
|
253
|
+
- **Environment variable:** `PROTOBASE_PASSKEY_DOMAIN`
|
|
254
|
+
|
|
255
|
+
The host new passkeys are made for: the host of `url` or of one of `origins`. Each passkey keeps the one it was made for, so changing it breaks none. See [Passkeys](../auth.md#passkeys).
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
export default defineConfig({ auth: { origins: ['https://admin.shop.com'], passkeyDomain: 'admin.shop.com' } })
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## auth.trustedOrigins
|
|
262
|
+
|
|
263
|
+
- **Type:** `string[]`
|
|
264
|
+
- **Default:** `PROTOBASE_TRUSTED_ORIGINS`, comma separated
|
|
265
|
+
- **Environment variable:** `PROTOBASE_TRUSTED_ORIGINS`
|
|
266
|
+
|
|
267
|
+
Extra origins that may call the auth endpoints, such as the exact host of a dev tunnel; no wildcard is trusted. `url` and `origins` always are. Set in the config, it replaces the variable's list.
|
|
268
|
+
|
|
269
|
+
```ts
|
|
270
|
+
export default defineConfig(({ env }) => ({
|
|
271
|
+
auth: { trustedOrigins: env.TUNNEL_URL ? [env.TUNNEL_URL] : undefined },
|
|
272
|
+
}))
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## auth.mcp
|
|
276
|
+
|
|
277
|
+
- **Type:** `true | { path?: string; connectPage?: string }`
|
|
278
|
+
- **Default:** off
|
|
279
|
+
|
|
280
|
+
Turns on the OAuth provider for MCP clients, and with it the MCP endpoint: a client registers itself, the person signs in and allows it on the connect page, and the client gets tokens for the MCP endpoint only. `path` is the endpoint's (default `/api/mcp`), `connectPage` the page's (default `/-/connect`). Needs an https `url`, or localhost, and the OAuth tables from `protobase auth migration`. The endpoint's tools are [`mcpEndpoint`](api.md#mcpendpoint). See [MCP](../mcp.md#turning-it-on).
|
|
281
|
+
|
|
282
|
+
```ts
|
|
283
|
+
export default defineConfig({ auth: { mcp: true } })
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## authenticate
|
|
287
|
+
|
|
288
|
+
- **Type:** `AuthenticateSettings`
|
|
289
|
+
- **Default:** the tokens of `auth`
|
|
290
|
+
|
|
291
|
+
How the API verifies tokens: the app's own, those of an auth server elsewhere, and those of other Protobase apps it admits. An authenticator of the project's own, such as `jwtAuthenticator(...)` for tokens of another system, is the default export of `auth/authenticate.ts`, which replaces this key. See [Tokens and roles](../auth.md#tokens-and-roles).
|
|
292
|
+
|
|
293
|
+
```ts
|
|
294
|
+
export default defineConfig({ authenticate: { tenant: 'acme' } })
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## authenticate.tenant
|
|
298
|
+
|
|
299
|
+
- **Type:** `string | number`
|
|
300
|
+
|
|
301
|
+
The one tenant everyone works in, for an app without organizations; never read from the token.
|
|
302
|
+
|
|
303
|
+
```ts
|
|
304
|
+
export default defineConfig({ authenticate: { tenant: 1 } })
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## authenticate.jwksUrl
|
|
308
|
+
|
|
309
|
+
- **Type:** `string`
|
|
310
|
+
|
|
311
|
+
The key set of an auth server elsewhere, for an API that runs apart from it. Needs `issuer`. Set without `auth`, it turns the app's own sign-in off.
|
|
312
|
+
|
|
313
|
+
```ts
|
|
314
|
+
export default defineConfig({
|
|
315
|
+
authenticate: { jwksUrl: 'https://auth.example.com/api/auth/jwks', issuer: 'https://auth.example.com' },
|
|
316
|
+
})
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## authenticate.issuer
|
|
320
|
+
|
|
321
|
+
- **Type:** `string`
|
|
322
|
+
- **Default:** the app's `url`
|
|
323
|
+
|
|
324
|
+
The issuer the tokens must name; it is also their audience unless `audience` names another.
|
|
325
|
+
|
|
326
|
+
```ts
|
|
327
|
+
export default defineConfig({ authenticate: { jwksUrl: 'https://auth.example.com/api/auth/jwks', issuer: 'https://auth.example.com' } })
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## authenticate.audience
|
|
331
|
+
|
|
332
|
+
- **Type:** `string`
|
|
333
|
+
- **Default:** `issuer`
|
|
334
|
+
|
|
335
|
+
The audience the tokens must name.
|
|
336
|
+
|
|
337
|
+
```ts
|
|
338
|
+
export default defineConfig({ authenticate: { jwksUrl: 'https://auth.example.com/api/auth/jwks', issuer: 'https://auth.example.com', audience: 'https://api.example.com' } })
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## authenticate.organizations
|
|
342
|
+
|
|
343
|
+
- **Type:** `boolean`
|
|
344
|
+
- **Default:** read from `auth`
|
|
345
|
+
|
|
346
|
+
Whether the tokens carry organizations. Needed with `jwksUrl` only.
|
|
347
|
+
|
|
348
|
+
```ts
|
|
349
|
+
export default defineConfig({ authenticate: { jwksUrl: 'https://auth.example.com/api/auth/jwks', issuer: 'https://auth.example.com', organizations: true } })
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
## authenticate.cache
|
|
353
|
+
|
|
354
|
+
- **Type:** `{ refreshMs?: number; minReloadMs?: number }`
|
|
355
|
+
- **Default:** `{ refreshMs: 600000, minReloadMs: 30000 }`
|
|
356
|
+
|
|
357
|
+
How long the key set is kept: reloaded whole every `refreshMs`, so removed keys stop working, and when a token names an unknown key, at most every `minReloadMs`.
|
|
358
|
+
|
|
359
|
+
```ts
|
|
360
|
+
export default defineConfig({ authenticate: { cache: { refreshMs: 60_000 } } })
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
## authenticate.apps
|
|
364
|
+
|
|
365
|
+
- **Type:** `{ issuer: string; roles: Record<string, string | string[]>; tenant?: string | number }[]`
|
|
366
|
+
- **Default:** none
|
|
367
|
+
|
|
368
|
+
Other Protobase apps whose signed-in users this API admits with their own tokens, so their admin apps can draw its resources. `issuer` is that app's `url`, `roles` maps its global roles to this app's (a role it does not list is dropped, and a user left with none is refused), and `tenant` is where its users work. See [Users of another app](../auth.md#users-of-another-app).
|
|
369
|
+
|
|
370
|
+
```ts
|
|
371
|
+
export default defineConfig({
|
|
372
|
+
authenticate: { apps: [{ issuer: 'https://admin.shop.com', roles: { admin: 'shop' } }] },
|
|
373
|
+
})
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## signingKeyDays
|
|
377
|
+
|
|
378
|
+
- **Type:** `number`
|
|
379
|
+
- **Default:** `30`
|
|
380
|
+
|
|
381
|
+
Days a token signing key signs; the first token after that makes a new key. A month bounds how long a leaked key could sign, and keeps the key set to a few keys. A top-level key, beside `auth`. See [Signing keys](../auth.md#signing-keys).
|
|
382
|
+
|
|
383
|
+
```ts
|
|
384
|
+
export default defineConfig({ signingKeyDays: 90 })
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
## signingKeyGraceDays
|
|
388
|
+
|
|
389
|
+
- **Type:** `number`, at least `1`
|
|
390
|
+
- **Default:** `7`
|
|
391
|
+
|
|
392
|
+
Days a replaced signing key stays in the key set, so the tokens it signed keep verifying until they expire; it is deleted after that. A week is far longer than any token lasts, a day at most, so an API that caches the key set never refuses a token signed just before a rotation. A top-level key, beside `auth`.
|
|
393
|
+
|
|
394
|
+
```ts
|
|
395
|
+
export default defineConfig({ signingKeyGraceDays: 14 })
|
|
396
|
+
```
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
<!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/reference/config.md: run `bun run docs:skill`, do not edit. -->
|
|
2
|
+
|
|
3
|
+
# Configuring Protobase
|
|
4
|
+
|
|
5
|
+
The project's config file, protobase.config.ts or protobase.config.json, as one object of data; defineConfig and its function form, $env values, where the project's code is found and how extensions merge.
|
|
6
|
+
|
|
7
|
+
Protobase reads its config from one file in the project's root: `protobase.config.ts`, or `protobase.config.json` for the same object as JSON. The file describes the whole app as one flat object of data: its address and secret, sign-in, the jobs, the file providers and the API's settings. Every key is optional; Protobase has a default for each, and a project without a config file is a config of defaults.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
// protobase.config.ts
|
|
11
|
+
import { defineConfig } from '@protobase/config'
|
|
12
|
+
|
|
13
|
+
export default defineConfig({
|
|
14
|
+
timezone: 'Europe/Amsterdam',
|
|
15
|
+
auth: { roles: ['admin', 'sales'], organizations: true },
|
|
16
|
+
jobs: {
|
|
17
|
+
'send-invoice': { description: 'Mails an invoice to its customer.', arguments: { invoiceId: 'bigint' }, maxAttempts: 5 },
|
|
18
|
+
},
|
|
19
|
+
writeHooks: ['queue-sent-invoice'],
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The config names things; it never holds or imports their code. Protobase finds the code by its path, so the job above runs `jobs/send-invoice.ts` and the write hook is `hooks/queue-sent-invoice.ts`.
|
|
24
|
+
|
|
25
|
+
Each key is described with its type and default in the option pages:
|
|
26
|
+
|
|
27
|
+
| Page | Keys |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| [App options](config/app.md) | `name`, `url`, `secret`, `previousSecrets`, `locale`, `timezone`, `themeColor`, `backgroundColor`, `mobile` |
|
|
30
|
+
| [Sign-in options](config/sign-in.md) | `auth`, `authenticate`, `signingKeyDays`, `signingKeyGraceDays` |
|
|
31
|
+
| [API options](config/api.md) | `apiPath`, `apiKeys`, `cors`, `defaultAccess`, `rowPermissions`, `statementTimeoutMs`, `scanGuard`, `errorReporting`, `writeHooks`, `mcpEndpoint`, `remoteResources`, `runtimeUpdates` |
|
|
32
|
+
| [Admin app options](config/admin-app.md) | `assistant`, `maps`, `plugins` |
|
|
33
|
+
| [Jobs and events options](config/jobs-and-events.md) | `jobs`, `events`, `history`, `webhooks`, `notifications` |
|
|
34
|
+
| [Files options](config/files.md) | `files` |
|
|
35
|
+
|
|
36
|
+
## Config types
|
|
37
|
+
|
|
38
|
+
`defineConfig` from `@protobase/config` types every key and returns its argument as it is, so the editor completes and checks the config without anything running. The package exports the types too: `ProtobaseConfig` is the object, and `AuthConfig` and `FilesConfig` are its `auth` and `files`.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import type { ProtobaseConfig } from '@protobase/config'
|
|
42
|
+
|
|
43
|
+
const config: ProtobaseConfig = { timezone: 'Europe/Amsterdam' }
|
|
44
|
+
export default config
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Conditional config
|
|
48
|
+
|
|
49
|
+
`defineConfig` also takes a function, which gets the command that reads the config, the environment and the project's folder, and returns a config:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
export default defineConfig(({ command, env }) => ({
|
|
53
|
+
auth: { trustedOrigins: env.TUNNEL_URL ? [env.TUNNEL_URL] : undefined },
|
|
54
|
+
errorReporting: command === 'dev' ? false : undefined,
|
|
55
|
+
}))
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
| | |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| `command` | `dev`, `build`, `serve` (also `protobase worker` and the serve runtime's `migrate` and `create-admin`), or `tool`, any other command over the project, such as `migration`, `users` or `doctor` |
|
|
61
|
+
| `env` | `process.env`, with the project's `.env` loaded |
|
|
62
|
+
| `root` | the project's folder |
|
|
63
|
+
|
|
64
|
+
`protobase serve` reads a bundle's config again where it runs, with that environment, so a bundle built once serves with each host's own variables. The types are `ConfigEnv`, `ConfigCommand` and `ConfigFunction`.
|
|
65
|
+
|
|
66
|
+
## Async config
|
|
67
|
+
|
|
68
|
+
The function may be async, and return its config as a promise:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { readFile } from 'node:fs/promises'
|
|
72
|
+
|
|
73
|
+
export default defineConfig(async ({ root }) => ({
|
|
74
|
+
maps: JSON.parse(await readFile(`${root}/maps.json`, 'utf8')),
|
|
75
|
+
}))
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
A config may read files of its own with Node's `fs`, and import values from other files, such as a list of map layers, as any module can.
|
|
79
|
+
|
|
80
|
+
## Environment variables
|
|
81
|
+
|
|
82
|
+
Secrets are values like any other, read from the environment. Several keys fall back to a variable of their own when the config leaves them out, such as `url` to `PROTOBASE_URL`; each option names its variable. A TypeScript config reads any other variable from `env` (or `process.env`, which holds the same):
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
export default defineConfig(({ env }) => ({
|
|
86
|
+
auth: { trustedOrigins: env.TUNNEL_URLS?.split(',') },
|
|
87
|
+
}))
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
A JSON config reads one with an `$env` value: `{ "$env": "NAME" }`, with `"default"` for when the variable is unset or empty, and `"split": ","` for a list of its non-empty parts, each trimmed. A value whose variable is unset and has no default is left out, as if the key were not written. A TypeScript config may write `$env` values too, but its types do not know them; `env` is the typed way.
|
|
91
|
+
|
|
92
|
+
The app's database is `DATABASE_URL`'s, with the pool size of `PROTOBASE_DB_CONNECTIONS`; neither is a key of the config.
|
|
93
|
+
|
|
94
|
+
## The same config as JSON
|
|
95
|
+
|
|
96
|
+
`protobase.config.json` holds the same object as JSON, with [`$env` values](#environment-variables) for what the environment gives:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"url": { "$env": "PROTOBASE_URL", "default": "http://localhost:5173" },
|
|
101
|
+
"timezone": "Europe/Amsterdam",
|
|
102
|
+
"auth": { "roles": ["admin", "sales"], "trustedOrigins": { "$env": "TUNNEL_URLS", "split": "," } },
|
|
103
|
+
"jobs": { "send-invoice": { "arguments": { "invoiceId": "bigint" }, "maxAttempts": 5 } },
|
|
104
|
+
"writeHooks": ["queue-sent-invoice"]
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
JSON cannot branch on the command or compute a value; a config that needs to is written in TypeScript. There is no JSON Schema for the file yet, so a JSON config is checked when the app starts rather than in the editor.
|
|
109
|
+
|
|
110
|
+
## One config per project
|
|
111
|
+
|
|
112
|
+
A project has one config file: one with both `protobase.config.ts` and `protobase.config.json` stops every command with an error that names both. A config cannot extend another itself; [extensions](#extensions) merge folders instead.
|
|
113
|
+
|
|
114
|
+
## Reading it
|
|
115
|
+
|
|
116
|
+
Every command reads the config, in a few milliseconds: reading it runs the config's file and what that file imports, and none of the project's code. A config may not load part of itself later: an `import()` in `protobase.config.ts` stops every command with an error that names it. Code belongs in the files below.
|
|
117
|
+
|
|
118
|
+
## Where the code is
|
|
119
|
+
|
|
120
|
+
Protobase loads each file below only when the app needs it, never while the config is read. Hooks of the project's own get the app's database, `{ db }` (Kysely, as jobs get it), as their last argument. A job named in the config without its `jobs/<name>.ts`, or a write hook without its `hooks/<name>.ts`, stops the app at start with an error that names the file.
|
|
121
|
+
|
|
122
|
+
The resources and roles have no key of their own:
|
|
123
|
+
|
|
124
|
+
| File | What it holds | See |
|
|
125
|
+
| --- | --- | --- |
|
|
126
|
+
| `config/index.ts`, `config/<dir>/ui.ts` | the resources, views and pages, as exports | [Data config](data-config.md) |
|
|
127
|
+
| `config/roles.ts` | the `roles` export, made with `defineRoles` | [Access](access.md) |
|
|
128
|
+
| `functions/<name>.ts` | an API function, as its default export | [API functions](../guides/api-functions.md) |
|
|
129
|
+
|
|
130
|
+
The other files belong to an option, and are described with it:
|
|
131
|
+
|
|
132
|
+
| File | Option |
|
|
133
|
+
| --- | --- |
|
|
134
|
+
| `auth/hooks.ts`, `auth/mailer.ts`, `emails/` | [`auth`](config/sign-in.md#auth) |
|
|
135
|
+
| `auth/authenticate.ts` | [`authenticate`](config/sign-in.md#authenticate) |
|
|
136
|
+
| `hooks/<name>.ts` | [`writeHooks`](config/api.md#writehooks) |
|
|
137
|
+
| `hooks/error.ts`, `audit/queue.ts` | [Code of the API](config/api.md#code-of-the-api) |
|
|
138
|
+
| `assistant/tools.ts` | [`assistant`](config/admin-app.md#assistant) |
|
|
139
|
+
| `jobs/<name>.ts` | [`jobs`](config/jobs-and-events.md#jobs) |
|
|
140
|
+
| `webhooks/owner-roles.ts` | [`webhooks`](config/jobs-and-events.md#webhooks) |
|
|
141
|
+
| `notifications/store.ts`, `notifications/history-store.ts`, `notifications/senders.ts` | [`notifications`](config/jobs-and-events.md#notifications) |
|
|
142
|
+
| `files/<name>.ts` | [`files.providers`](config/files.md#filesproviders) |
|
|
143
|
+
|
|
144
|
+
## Extensions
|
|
145
|
+
|
|
146
|
+
`protobase dev --extend <dir>` and `protobase build --extend <dir>` merge an extension's folder into the app, before the project. The extension's folder has a config and code of its own, found by the same paths in that folder.
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
// protobase.ui.tsx
|
|
150
|
+
import { defineUi } from '@protobase/ui'
|
|
151
|
+
import * as tasksUi from 'some-extension/protobase.ui'
|
|
152
|
+
|
|
153
|
+
export default defineUi({ extends: [tasksUi] })
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
| What | How it merges | The same name twice |
|
|
157
|
+
| --- | --- | --- |
|
|
158
|
+
| resources, views and pages of `config/` | all kept | an error naming both folders |
|
|
159
|
+
| user menu | at most one among all folders | an error |
|
|
160
|
+
| assistant tools of `assistant/tools.ts` | the extensions' first, in order, then the app's | an error naming the tool and both folders |
|
|
161
|
+
| `jobs`, functions, file providers | all kept, by name | an error naming the name and both folders |
|
|
162
|
+
| `writeHooks` | all run, in the same order | |
|
|
163
|
+
| `config/roles.ts`, `auth/authenticate.ts`, `audit/queue.ts`, `hooks/error.ts`, `webhooks/owner-roles.ts`, `notifications/*.ts` | the app's own; otherwise the last extension's | |
|
|
164
|
+
| `auth/hooks.ts`, `auth/mailer.ts` | those of the last folder whose config sets `auth`; otherwise the app's | |
|
|
165
|
+
| every other key (`auth`, `authenticate`, `assistant`, ...) | the app's own; otherwise the last config that sets it | |
|
|
166
|
+
| UI components (exported by name or in `components`), `actions` | all kept | an error naming the name and both configs |
|
|
167
|
+
| UI `shell.actions`, `shell.rightPanel` | all drawn, the extended configs' first | |
|
|
168
|
+
| UI `shell.logo` | the app's own; otherwise the last config that sets it | |
|
|
169
|
+
|
|
170
|
+
Errors name an extension by its folder. Nothing is namespaced, so a collision is always an error, never a silent override. Names starting with `Protobase` (components) and `protobase_` (tools) belong to Protobase's own extensions, such as `ProtobaseCloudTask` and `protobase_cloud_create_proposal`; give yours other names.
|
|
@@ -6,7 +6,7 @@ React components and action handlers of your own in protobase.ui.tsx, used by na
|
|
|
6
6
|
|
|
7
7
|
Layouts are data; a project's React code lives in one module: `protobase.ui.tsx` at the project root, beside `protobase.config.ts`. It exports each custom component under the name its layouts declare, each from a file of its own, and default-exports `defineUi({ actions })` from `@protobase/ui` for the rest, so the project depends on `@protobase/ui`, and on `react` for its JSX. This is the ERP example's:
|
|
8
8
|
|
|
9
|
-
```tsx title="
|
|
9
|
+
```tsx title="tests/apps/erp/protobase.ui.tsx"
|
|
10
10
|
import { defineUi, type ActionContext } from '@protobase/ui'
|
|
11
11
|
|
|
12
12
|
// The custom components, each in a file of its own, exported by the name their layouts declare.
|
|
@@ -23,7 +23,7 @@ const send = async ({ record, recordKey, etag, client }: ActionContext) => {
|
|
|
23
23
|
export default defineUi({ actions: { send } })
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
```tsx title="
|
|
26
|
+
```tsx title="tests/apps/erp/components/orders-per-day.tsx"
|
|
27
27
|
import { useSeries } from '@protobase/ui'
|
|
28
28
|
|
|
29
29
|
/** Bars for orders per day; the custom component behind `<OrdersPerDay>` in config/overview/page.tsx. */
|
|
@@ -117,7 +117,7 @@ Every option returns a new [field](https://docs.protobase.net/api/schema/interfa
|
|
|
117
117
|
|
|
118
118
|
The ERP's products show most of them, together with soft delete and a tenant:
|
|
119
119
|
|
|
120
|
-
```ts title="
|
|
120
|
+
```ts title="tests/apps/erp/config/products/data.ts"
|
|
121
121
|
import { f, resource } from '@protobase/schema'
|
|
122
122
|
import { erpAccess } from '../roles'
|
|
123
123
|
|
|
@@ -275,7 +275,7 @@ No other field of the resource may be over the column, as its own or as a relati
|
|
|
275
275
|
|
|
276
276
|
### The key
|
|
277
277
|
|
|
278
|
-
The app's key is `PROTOBASE_ENCRYPTION_KEY`: 32 random bytes in base64, such as the output of `openssl rand -base64 32`. It is its own: never `
|
|
278
|
+
The app's key is `PROTOBASE_ENCRYPTION_KEY`: 32 random bytes in base64, such as the output of `openssl rand -base64 32`. It is its own: never the app's `secret` (`PROTOBASE_SECRET`) or an API key, nor derived from one, so rotating those loses nothing. Keep it apart from the database's backups, since whoever holds both reads every value. The server does not start with an encrypted field and no key, or a key that is not 32 bytes in base64.
|
|
279
279
|
|
|
280
280
|
To rotate it on several instances:
|
|
281
281
|
|
|
@@ -396,9 +396,9 @@ export const workOrders = resource('work_orders')
|
|
|
396
396
|
})
|
|
397
397
|
```
|
|
398
398
|
|
|
399
|
-
|
|
399
|
+
Export the roles as `roles` from `config/roles.ts`, where the server finds them, and every operation without a rule needs its capability (`<resource>.<action>`). The ERP's orders use `.owner` and `.search` with the ERP's roles:
|
|
400
400
|
|
|
401
|
-
```ts title="
|
|
401
|
+
```ts title="tests/apps/erp/config/orders/data.ts"
|
|
402
402
|
import { f, resource } from '@protobase/schema'
|
|
403
403
|
import { erpAccess } from '../roles'
|
|
404
404
|
|