@protobase/cli 0.124.1 → 0.125.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.
- package/dist/cli/package.js +1 -1
- package/dist/dev/dev-relay.js +3 -6
- package/dist/relay/register.js +3 -3
- package/package.json +8 -8
- package/skills/protobase/references/features/email-and-public-forms.md +1 -1
- package/skills/protobase/references/features/history-comments-and-live-updates.md +1 -1
- package/skills/protobase/references/reference/auth.md +1 -0
- package/skills/protobase/references/reference/cli.md +2 -2
- package/skills/protobase/references/reference/email.md +49 -12
- package/skills/protobase/references/reference/realtime-relay.md +21 -2
package/dist/cli/package.js
CHANGED
package/dist/dev/dev-relay.js
CHANGED
|
@@ -31,11 +31,12 @@ const withDevRelay = async (config, projectDir, devUrl, views) => {
|
|
|
31
31
|
return config;
|
|
32
32
|
}
|
|
33
33
|
const keys = devKeys();
|
|
34
|
-
const options = {
|
|
34
|
+
const options = checkRelayOptions({
|
|
35
35
|
...relay,
|
|
36
|
+
url: devUrl,
|
|
36
37
|
apiKey: relay.apiKey || keys.apiKey,
|
|
37
38
|
ticketKey: relay.ticketKey || keys.ticketKey
|
|
38
|
-
};
|
|
39
|
+
});
|
|
39
40
|
const entry = JSON.stringify({
|
|
40
41
|
...relayAppEntry(options, {
|
|
41
42
|
url: devUrl,
|
|
@@ -46,10 +47,6 @@ const withDevRelay = async (config, projectDir, devUrl, views) => {
|
|
|
46
47
|
if (store.__protobaseDevRelay?.entry !== entry) {
|
|
47
48
|
await stopDevRelay();
|
|
48
49
|
const port = await freePort();
|
|
49
|
-
checkRelayOptions({
|
|
50
|
-
...options,
|
|
51
|
-
url: relayUrl(port)
|
|
52
|
-
});
|
|
53
50
|
store.__protobaseDevRelay = {
|
|
54
51
|
entry,
|
|
55
52
|
url: relayUrl(port),
|
package/dist/relay/register.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/relay/register.ts
|
|
2
2
|
const registerRelay = (program) => {
|
|
3
|
-
program.command("relay").description("The realtime relay the app hands its connections to (realtime.relay)").command("app").description("Print the app's entry for the relay's apps file, from realtime.relay
|
|
4
|
-
const [{
|
|
3
|
+
program.command("relay").description("The realtime relay the app hands its connections to (realtime.relay)").command("app").description("Print the app's entry for the relay's apps file, from realtime.relay or PROTOBASE_RELAY_*, url and the views").action(async () => {
|
|
4
|
+
const [{ configExports, relaySettings }, { loadSourceConfig }, { projectResources }, { loadNearestEnvFile }, { relayAppEntry }] = await Promise.all([
|
|
5
5
|
import("@protobase/server"),
|
|
6
6
|
import("../config/source-config.js"),
|
|
7
7
|
import("../config/project-parts.js"),
|
|
@@ -13,7 +13,7 @@ const registerRelay = (program) => {
|
|
|
13
13
|
if (!config.realtime?.relay) throw new Error("The config has no realtime.relay");
|
|
14
14
|
const url = config.url ?? process.env.PROTOBASE_URL;
|
|
15
15
|
const views = configExports(await projectResources(config)).views.map((view) => view.toModel());
|
|
16
|
-
process.stdout.write(`${JSON.stringify(relayAppEntry(
|
|
16
|
+
process.stdout.write(`${JSON.stringify(relayAppEntry(relaySettings(config.realtime.relay, process.env), {
|
|
17
17
|
url,
|
|
18
18
|
apiPath: config.apiPath,
|
|
19
19
|
views
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.125.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": {
|
|
@@ -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.
|
|
47
|
-
"@protobase/layout": "0.
|
|
48
|
-
"@protobase/query": "0.
|
|
49
|
-
"@protobase/schema": "0.
|
|
50
|
-
"@protobase/server": "0.
|
|
51
|
-
"@protobase/ui": "0.
|
|
52
|
-
"@protobase/workflows": "0.
|
|
46
|
+
"@protobase/config": "0.125.0",
|
|
47
|
+
"@protobase/layout": "0.125.0",
|
|
48
|
+
"@protobase/query": "0.125.0",
|
|
49
|
+
"@protobase/schema": "0.125.0",
|
|
50
|
+
"@protobase/server": "0.125.0",
|
|
51
|
+
"@protobase/ui": "0.125.0",
|
|
52
|
+
"@protobase/workflows": "0.125.0",
|
|
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",
|
|
@@ -16,7 +16,7 @@ Mail the app sends, the PDF documents it makes, and forms for people without an
|
|
|
16
16
|
- [PDF documents](../reference/pdf.md#documents): PDF files such as invoices and quotes are React components with typed data, rendered from jobs, hooks or functions and attached to mail as they are.
|
|
17
17
|
- [Mail from your own mailbox](../reference/email.md#from-someones-own-mailbox) (beta): People link their Gmail on the account page, and the app's functions send mail from it; an action offers to connect the mailbox right there when the link is missing or expired.
|
|
18
18
|
- [From addresses](../reference/email.md#from-addresses): Each send-as address is a record on the person's mailbox, with a display name, a signature of its own and a state. With the optional `gmail.settings.basic` scope, Gmail lists them and says which it really sends from, and the app refuses to send from an address Gmail would replace. The app sends from the record it names, or the person's default.
|
|
19
|
-
- [
|
|
19
|
+
- [Verifying a From address](../reference/email.md#verifying-a-from-address) (beta): The app plugs in its own way to prove a From address its mailbox provider cannot vouch for, such as a hosting platform's test-mail check: a verifier sends one test message through the person's mailbox, and its proof makes the address verified until it runs out. Verifications wait, survive a restart and settle once, by the app's own check each minute or by a report carrying the verification's secret.
|
|
20
20
|
- [A From address on a record](../reference/email.md#a-from-address-on-a-record) (beta): A field such as a client's "Send from" is a dropdown of the person's addresses with their states, and an address a record holds cannot be removed.
|
|
21
21
|
- [Public forms](../reference/forms.md#what-the-visitor-sees): A form at its own address lets people without an account create a record, such as a contact request.
|
|
22
22
|
- [Bot check](../reference/forms.md#bot-check): Each submission passes a check in the browser, without a third-party service or a puzzle.
|
|
@@ -17,7 +17,7 @@ The changes of each record, comments on it, and pages that refresh as records ch
|
|
|
17
17
|
- [Change stream](../reference/live.md#the-stream): Apps follow record changes over a stream that catches up after a reconnect.
|
|
18
18
|
- [Polling, then a socket](../reference/live.md#polling-then-a-socket): Apps and Node scripts poll for changes first and switch to a WebSocket after 30 seconds, or at once, falling back to polling while the socket is down.
|
|
19
19
|
- [Presence](../reference/channels.md#presence) (beta): Apps see who else has a record open and what each of them tracks, such as online or away, for whoever may read the record.
|
|
20
|
-
- [Realtime relay](../reference/realtime-relay.md) (in development): Apps hand their realtime connections to a relay, so they and their database can sleep while people stay connected: the app issues connect tickets for signed-in people and visitors, keeps the relay's channel members in step with its members records, tells each channel's members of every change, and closes a session's sockets when it signs out or expires. `protobase dev` runs a relay for the app by itself.
|
|
20
|
+
- [Realtime relay](../reference/realtime-relay.md) (in development): Apps hand their realtime connections to a relay, so they and their database can sleep while people stay connected: the app issues connect tickets for signed-in people and visitors, keeps the relay's channel members in step with its members records, tells each channel's members of every change, and closes a session's sockets when it signs out or expires. `protobase dev` runs a relay for the app by itself. An app on a platform that runs the relay picks up its address and keys from PROTOBASE_RELAY_URL, PROTOBASE_RELAY_APP, PROTOBASE_RELAY_API_KEY and PROTOBASE_RELAY_TICKET_KEY; a value in the config wins.
|
|
21
21
|
- [Relay presence](../reference/realtime-relay.md#presence) (in development): The relay reports who comes online, goes away and goes offline; the app keeps it in a resource of its own, raises that resource's events, so workflows can act when someone goes offline, and tells the people who share a conversation with them, whose sidebar and members page show them online, away or offline.
|
|
22
22
|
- [Relay in pages](../reference/realtime-relay.md#pages) (in development): Pages follow the relay on one socket: open views stay current from its notices and read again once after a reconnect, conversations show who types, sidebar groups say "typing…" and count unread messages without reading per message, also of a conversation the person was just added to, all by configuration; `client.relay` gives the same from code.
|
|
23
23
|
- [Relay client events](../reference/realtime-relay.md#client-events) (in development): Each channel resource declares in the config the events its clients may send each other, such as typing, with a schema, a size and a rate.
|
|
@@ -157,6 +157,7 @@ export const generateUserId: AuthHooks['generateUserId'] = async ({ db }) => {
|
|
|
157
157
|
| `onOrganizationCreated` | `({ organization, member }, { db })`, after an organization is created, with its owner's membership |
|
|
158
158
|
| `beforeOrganizationDeleted` | `(organization, { db })`, before an organization is deleted; throwing refuses it |
|
|
159
159
|
| `organizationHooks` | Better Auth's organization hooks by name, each with `{ db }` last, run after Protobase's own |
|
|
160
|
+
| `senderVerifiers` | `(add_verifier)`, once as the app starts: adds the app's ways to prove a From address; see [Verifying a From address](email.md#verifying-a-from-address) |
|
|
160
161
|
|
|
161
162
|
A mailer of the project's own, for sign-in's mail, is the default export of `auth/mailer.ts` (see [Password reset](#password-reset)). An authenticator of its own, in place of the one `authenticate` describes, is the default export of `auth/authenticate.ts` (see [Tokens and roles](#tokens-and-roles)).
|
|
162
163
|
|
|
@@ -481,8 +481,8 @@ Serves the API of a bundle from `protobase build` and owns the process around it
|
|
|
481
481
|
| `PROTOBASE_FIRST_ADMIN_URL` | the hosting platform's page where the app's first user is added, such as its console's; while the app has no users, the sign-in page links there in place of the `protobase users create` command ([the first admin](auth.md#first-run)) |
|
|
482
482
|
| `PROTOBASE_RUNS_ON_NOTE` | `true` ends the sign-in page on the [Runs on Protobase note](app-identity.md#runs-on-protobase-note), for a hosting platform; default `false`, and any value but `true` or `false` stops startup |
|
|
483
483
|
| `PROTOBASE_RUNTIME_URL` | the endpoint behind the top bar's [runtime update button](versioning.md#runtime-updates), such as a hosting platform's; without it there is no button |
|
|
484
|
-
| `PROTOBASE_MAIL_CHECK_URL` | the hosting platform's service that [checks a From address](email.md#checking-a-from-address), signed with a key derived from `PROTOBASE_SECRET`; without it the account page says addresses cannot be checked |
|
|
485
484
|
| `PROTOBASE_SENTRY_DSN` | the DSN of a Sentry-compatible error tracker the app's server and admin app send their errors to, after the config's `errorReporting` ([Error reporting](api.md#error-reporting)); without it nothing is sent |
|
|
485
|
+
| `PROTOBASE_RELAY_URL`, `PROTOBASE_RELAY_APP`, `PROTOBASE_RELAY_API_KEY`, `PROTOBASE_RELAY_TICKET_KEY` | the address, the app's id and its API and ticket keys of the [realtime relay](realtime-relay.md#from-the-platform), each where the config's `realtime.relay` leaves it out; without `realtime.relay` the relay stays off |
|
|
486
486
|
| `PROTOBASE_MAP_STYLE_URL` | the URL of the MapLibre style the record page's [maps](ui-config.md#maps) are drawn with, after the config's `maps`; without it there are no maps |
|
|
487
487
|
| `PROTOBASE_SOURCES` | other Protobase APIs whose resources the app draws as its own, a JSON list of `{ "url", "label", "resources", "roles"? }` after the config's `remoteResources` ([Remote resources](remote-resources.md#declaring-a-source)) |
|
|
488
488
|
| `PROTOBASE_FILES_<NAME>`, `PROTOBASE_FILES_RETENTION`, `PROTOBASE_FILES_SECRET` | [file providers](files.md#providers) and their settings, over `files` in the config; a bucket's credentials in `PROTOBASE_FILES_<NAME>_ACCESS_KEY_ID` and `_SECRET_ACCESS_KEY` |
|
|
@@ -678,7 +678,7 @@ Recounts a [time rollup](data-config.md#keeping-it-up-to-date)'s buckets from th
|
|
|
678
678
|
protobase relay app
|
|
679
679
|
```
|
|
680
680
|
|
|
681
|
-
Prints the app's entry for the apps file of the [realtime relay](realtime-relay.md), as JSON: its `id`, `api_keys` and `ticket_keys` from `realtime.relay`, and in `origins` the origin of the app's `url` (or `PROTOBASE_URL`); in `client_events` each channel resource's [client events](realtime-relay.md#client-events), with `typing` on those whose conversation page types; with [presence](realtime-relay.md#presence), `presence` with the app's presence endpoint at that `url`, the presence key and a `grace_seconds` of 30. Add the relay's limits and options to it there. It reads `protobase.config.ts` with `command: 'tool'` and the `.env` nearest the current directory.
|
|
681
|
+
Prints the app's entry for the apps file of the [realtime relay](realtime-relay.md), as JSON: its `id`, `api_keys` and `ticket_keys` from `realtime.relay`, or else `PROTOBASE_RELAY_APP`, `PROTOBASE_RELAY_API_KEY` and `PROTOBASE_RELAY_TICKET_KEY`, and in `origins` the origin of the app's `url` (or `PROTOBASE_URL`); in `client_events` each channel resource's [client events](realtime-relay.md#client-events), with `typing` on those whose conversation page types; with [presence](realtime-relay.md#presence), `presence` with the app's presence endpoint at that `url`, the presence key and a `grace_seconds` of 30. Add the relay's limits and options to it there. It reads `protobase.config.ts` with `command: 'tool'` and the `.env` nearest the current directory.
|
|
682
682
|
|
|
683
683
|
## `auth migration`
|
|
684
684
|
|
|
@@ -414,6 +414,8 @@ A mailbox may send as more than its own address, such as Gmail's send-as address
|
|
|
414
414
|
- `failed`: a complete listing since the address was added did not hold it, so Gmail would send from the account's own address instead.
|
|
415
415
|
- `unverified`: nothing says either way.
|
|
416
416
|
|
|
417
|
+
Where the provider says nothing, a [verifier](#verifying-a-from-address) of the app may prove the address `verified`.
|
|
418
|
+
|
|
417
419
|
The state is worked out each time it is read, from what typed the address and what the provider last listed. An address the listing leaves out keeps its record and its id: only its listed state goes.
|
|
418
420
|
- **Without the scope:** a Gmail link without `gmail.settings.basic` is told which scope it lacks. The account page then offers **Allow address checks**, which connects Gmail again asking for it, and sends the person back to the account page.
|
|
419
421
|
- **Name:** an address may carry a display name, which the From header shows beside it, such as `From: Shop billing <billing@shop.example>`, as mail sent by hand from a send-as address shows the name set up for it; a name that is not ASCII is encoded. Left empty, the header holds the bare address.
|
|
@@ -458,24 +460,59 @@ export default defineFunction(async (request, { personalMail }) => {
|
|
|
458
460
|
|
|
459
461
|
Each acts on the signed-in person's own addresses and connections only: any other id answers `404` before anything is done.
|
|
460
462
|
- **Upgrading:** an address entered before From addresses were records goes on its owner's Gmail connection when they had exactly one. With none or several it shows **No mailbox**, and the person removes it and adds it again.
|
|
461
|
-
- <gap>An address on a mailbox linked without `gmail.settings.basic` cannot be checked before each send because only the account page
|
|
463
|
+
- <gap>An address on a mailbox linked without `gmail.settings.basic` cannot be checked before each send because only a [verification](#verifying-a-from-address) started from the account page is implemented for it.</gap>
|
|
462
464
|
- <gap>An address cannot be shared with others who send mail because proving that the person owns the address is not implemented.</gap>
|
|
463
465
|
|
|
464
|
-
###
|
|
466
|
+
### Verifying a From address
|
|
465
467
|
|
|
466
|
-
:::
|
|
467
|
-
|
|
468
|
+
:::caution[Beta]
|
|
469
|
+
Protobase ships no verifier: an app, or the platform it runs on, plugs in its own.
|
|
468
470
|
:::
|
|
469
471
|
|
|
470
|
-
Gmail sends from the account's own address, without an error, when a From address is not one of its verified send-as addresses
|
|
472
|
+
Gmail sends from the account's own address, without an error, when a From address is not one of its verified send-as addresses, and a mailbox that cannot list its send-as addresses leaves an address `unverified`. A verifier proves such an address another way, such as by sending one test message from it and reading how it arrives. The app's trusted code adds verifiers with `add_verifier`, from the project's `auth/hooks.ts`:
|
|
473
|
+
|
|
474
|
+
```ts
|
|
475
|
+
import type { AuthHooks } from '@protobase/server'
|
|
476
|
+
|
|
477
|
+
export const senderVerifiers: AuthHooks['senderVerifiers'] = (add_verifier) => add_verifier(testMailVerifier)
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
A host's runtime can pass its own in `createAuth`'s `senderVerifiers`. A verifier is a `SenderAddressVerifier`:
|
|
471
481
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
482
|
+
```ts
|
|
483
|
+
const testMailVerifier: SenderAddressVerifier = {
|
|
484
|
+
id: 'test-mail',
|
|
485
|
+
verify: async ({ verification_id, address, secret, locale }, { send }) => {
|
|
486
|
+
const to = await checkService.issue({ verification_id, secret })
|
|
487
|
+
await send({ to, subject: `Test message for ${address}`, text: 'This message checks that your mailbox sends from this address.' })
|
|
488
|
+
return { state: 'pending', expires_at: new Date(Date.now() + 10 * 60_000) }
|
|
489
|
+
},
|
|
490
|
+
check: async ({ verification_id }) => checkService.result(verification_id),
|
|
491
|
+
}
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
- **`id`:** stored on each verification, so it stays the same across releases: lowercase letters, digits, `_`, `.` and `-`, starting with a letter, at most 64 characters. Two verifiers with one id, or a verifier without `auth.personalMail`, stop startup.
|
|
495
|
+
- **`verify(input, tools)`:** starts a verification of `address`. `tools.send({ to, subject, text, html? })` sends one test message through the address's own mailbox, From that address, to one recipient: a From, copies, headers or attachments it is given are left out, and a second send is refused.
|
|
496
|
+
- **`check(input)`:** optional. The app's sweep calls it each minute a pending verification is due, until it settles or expires.
|
|
497
|
+
- **Outcomes:** `verify` and `check` answer one of these.
|
|
498
|
+
- `{ state: 'pending', expires_at, check_after? }`: `verify` must name `expires_at`, which the app caps at 24 hours after the verification started. `check` cannot move it. The next check comes at `check_after`, else a minute on, and never sooner than a minute on.
|
|
499
|
+
- `{ state: 'verified', valid_until }`: `valid_until` is required, lies ahead, and is capped at 28 days.
|
|
500
|
+
- `{ state: 'failed', error_code, error? }`: `error_code` is a lowercase name, such as `from_rewritten`. `error` is plain text of at most 500 characters, with no control characters but line breaks and tabs, shown as text and never as markup.
|
|
501
|
+
|
|
502
|
+
An outcome that breaks these rules, or a `verify` that throws, fails the verification as `verifier_error`. The address's state does not change.
|
|
503
|
+
- **One at a time:** an address has at most one pending verification per verifier. It is stored before `verify` runs, so starting it again sends nothing while it is pending. A verification whose `verify` never returned expires after 5 minutes, and the next start takes its place.
|
|
504
|
+
- **Expiry:** a verification still pending at `expires_at` fails as `verification_expired`, from the sweep, `auth.mail-sender-verifications`, which runs each minute on the app's jobs.
|
|
505
|
+
- **Reports:** an outside service settles a verification with `POST /api/auth/mail-sender-verifications/report`, with this JSON body: `{ verifier, secret, state: 'verified', valid_until }` or `{ verifier, secret, state: 'failed', error_code, error? }`.
|
|
506
|
+
- `secret` is the one `verify` was given: 256 random bits, made for that verification alone. The app keeps only its SHA-256, so it is never handed out again. The verification's id is not a secret.
|
|
507
|
+
- The secret is read from the body only. Keep it out of URLs and logs.
|
|
508
|
+
- A report settles the verification only for the verifier that started it, while it is pending and before it expires, and once only. Whichever comes first wins: the report, the sweep or `verify`'s own outcome.
|
|
509
|
+
- Any report that settles nothing answers the same `403` with `code: "VERIFICATION_REFUSED"`, whatever the reason. A malformed outcome answers `400` before anything is looked up.
|
|
510
|
+
- **The address's state:** a verified verification makes an address the provider says nothing of `verified`, until its `valid_until`. It never outweighs what the provider says, such as a `failed` listing. It counts only while its verifier is registered, and only if it settled after the address was last removed. A failed verification shows on the account page and leaves the state as it was.
|
|
511
|
+
- **The account page:** adding an address verifies it at once. Its dialog, under **Edit**, verifies it again with **Verify address**, and after a result with **Verify again**. While a verification is pending, the dialog reads it again every 3 seconds for up to 2 minutes. Without a verifier, the dialog says the app cannot verify From addresses, and how to check one by hand.
|
|
512
|
+
- **The account page's calls:**
|
|
513
|
+
- `GET /api/auth/account/mail-senders` says `verifiers: true` when the app has any, and gives each address its latest `verifications`, one per verifier: `verifier`, `state`, `expiresAt` while pending, `settledAt`, `validUntil`, `errorCode` and `error`.
|
|
514
|
+
- `POST .../mail-senders/verify { id }` starts each verifier on one of the person's addresses on a connection they can send through, and answers its `verifications`.
|
|
515
|
+
- Staff signed in as the person cannot start one.
|
|
479
516
|
|
|
480
517
|
### A From address on a record
|
|
481
518
|
|
|
@@ -47,7 +47,26 @@ export default defineConfig(({ env }) => ({
|
|
|
47
47
|
|
|
48
48
|
The relay needs the app's own [sign-in](auth.md), whose sessions its tickets name, with its store in the app's own database, as the `auth` config puts it: an auth store in another database is refused. A members resource's changes must be captured, so declare [`.live()`](live.md) on it; the relay hears of the changes of every resource whose changes are captured, such as a live one, that is a channel resource or has a relation field to one. [`protobase migration`](cli.md#migration) writes the trigger that ends a deleted session's sockets, in the `relay` schema, after the auth store's steps when the same file writes them, so a new app's first migration sets up both; the server checks it at start.
|
|
49
49
|
|
|
50
|
-
[`protobase relay app`](cli.md#relay-app) prints the app's entry for the relay's apps file, from this config and the app's `url`.
|
|
50
|
+
[`protobase relay app`](cli.md#relay-app) prints the app's entry for the relay's apps file, from this config, these variables and the app's `url`.
|
|
51
|
+
|
|
52
|
+
### From the platform
|
|
53
|
+
|
|
54
|
+
An app on a platform that runs the relay picks up its address and keys from the environment, so its config names only its channels:
|
|
55
|
+
|
|
56
|
+
| Variable | Default of |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `PROTOBASE_RELAY_URL` | `url` |
|
|
59
|
+
| `PROTOBASE_RELAY_APP` | `app` |
|
|
60
|
+
| `PROTOBASE_RELAY_API_KEY` | `apiKey` |
|
|
61
|
+
| `PROTOBASE_RELAY_TICKET_KEY` | `ticketKey` |
|
|
62
|
+
|
|
63
|
+
Each is a default on its own: a value in the config wins, and a key that neither sets stops the server at start, naming the key and its variable. The relay stays off without `realtime.relay` in the config, however many of these are set: the app turns it on by declaring its channels.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
export default defineConfig({
|
|
67
|
+
realtime: { relay: { channels: { conversations: { members: { resource: 'conversation_members', channel: 'conversation_id', user: 'user_id' } } } } },
|
|
68
|
+
})
|
|
69
|
+
```
|
|
51
70
|
|
|
52
71
|
## Local development
|
|
53
72
|
|
|
@@ -59,7 +78,7 @@ npm install --save-dev @protobase/realtime
|
|
|
59
78
|
|
|
60
79
|
<gap>`protobase dev` cannot run the relay without the project installing `@protobase/realtime` because the CLI does not depend on it until the package is published.</gap>
|
|
61
80
|
|
|
62
|
-
It starts the relay on the first load of a config with `realtime.relay`, an edit that adds it included, on a free port of `127.0.0.1`, serving this one app with the dev server's origin, and gives the app its address. The keys are the config's when it sets them, and otherwise made anew for each `protobase dev`. An edit that changes the app's id or keys starts it again, one that removes `realtime.relay` or sets a `url` stops it, and it stops with `dev`. Its own messages, such as an apps file it refuses, show in the terminal. With a `url`, the app uses that relay and `dev` starts none.
|
|
81
|
+
It starts the relay on the first load of a config with `realtime.relay`, an edit that adds it included, on a free port of `127.0.0.1`, serving this one app with the dev server's origin, and gives the app its address. The keys are the config's when it sets them, and otherwise made anew for each `protobase dev`. An edit that changes the app's id or keys starts it again, one that removes `realtime.relay` or sets a `url` stops it, and it stops with `dev`. Its own messages, such as an apps file it refuses, show in the terminal. With a `url`, the app uses that relay and `dev` starts none. `dev` reads [the platform's variables](#from-the-platform) for neither: the app's id comes from the config.
|
|
63
82
|
|
|
64
83
|
## Tickets
|
|
65
84
|
|