@protobase/cli 0.34.2 → 0.35.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/build/npm-ws.js +15 -0
- package/dist/build/serve-runtime.js +2 -1
- package/dist/cli/package.js +1 -1
- package/dist/dev/api-websockets.js +2 -2
- package/dist/project/api-websocket-server.js +40 -0
- package/dist/serve/lifecycle.js +2 -2
- package/dist/users/register.js +4 -3
- package/dist/users/set-disabled.js +10 -0
- package/package.json +6 -6
- package/skills/protobase/references/reference/auth.md +2 -2
- package/skills/protobase/references/reference/cli.md +2 -2
- package/skills/protobase/references/reference/custom-components.md +2 -0
- package/skills/protobase/references/reference/supabase-realtime.md +2 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
//#region src/build/npm-ws.ts
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
/**
|
|
6
|
+
* Bundles npm `ws` for a bare `ws` import. Built on Bun, Vite takes `ws` for a builtin and leaves it out, and the runtime
|
|
7
|
+
* then gets Bun's own shim, which realtime refuses (`apiWebSocketServer`).
|
|
8
|
+
*/
|
|
9
|
+
const npmWs = () => ({
|
|
10
|
+
name: "protobase-npm-ws",
|
|
11
|
+
enforce: "pre",
|
|
12
|
+
resolveId: (id) => id === "ws" ? path.join(path.dirname(require.resolve("ws/package.json")), "wrapper.mjs") : void 0
|
|
13
|
+
});
|
|
14
|
+
//#endregion
|
|
15
|
+
export { npmWs };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { viteBundle } from "./vite-bundle.js";
|
|
2
2
|
import { moduleFile } from "../module-file.js";
|
|
3
|
+
import { npmWs } from "./npm-ws.js";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
//#region src/build/serve-runtime.ts
|
|
5
6
|
const cliRoot = fileURLToPath(new URL("../..", import.meta.url));
|
|
@@ -10,7 +11,7 @@ const buildServeRuntime = async ({ outFile, bun }) => {
|
|
|
10
11
|
entry: serveMain,
|
|
11
12
|
outFile,
|
|
12
13
|
bun,
|
|
13
|
-
plugins: []
|
|
14
|
+
plugins: [npmWs()]
|
|
14
15
|
});
|
|
15
16
|
};
|
|
16
17
|
//#endregion
|
package/dist/cli/package.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { apiWebSocketServer } from "../project/api-websocket-server.js";
|
|
1
2
|
import { isAllowedHost } from "./allowed-host.js";
|
|
2
3
|
import { isProjectFile } from "./project-files.js";
|
|
3
4
|
import { createAdaptorServer } from "@hono/node-server";
|
|
4
|
-
import { WebSocketServer } from "ws";
|
|
5
5
|
//#region src/dev/api-websockets.ts
|
|
6
6
|
const isApiWebSocket = (url) => /^\/api\/sb\/realtime\/v1\/websocket(\?|$)/.test(url) || /^\/api\/functions\/[^/?#]+(\/|\?|$)/.test(url);
|
|
7
7
|
const restartCode = 1012;
|
|
@@ -15,7 +15,7 @@ const apiUpgrades = (allowedHosts, forward) => (request, socket, head) => {
|
|
|
15
15
|
socket.end("HTTP/1.1 403 Forbidden\r\nConnection: close\r\nContent-Length: 0\r\n\r\n");
|
|
16
16
|
};
|
|
17
17
|
const apiWebSockets = (entry, dirs) => {
|
|
18
|
-
const wss =
|
|
18
|
+
const wss = apiWebSocketServer();
|
|
19
19
|
return {
|
|
20
20
|
name: "protobase-api-websockets",
|
|
21
21
|
configureServer: (server) => {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { realtimeLimits } from "@protobase/server";
|
|
4
|
+
import { WebSocketServer } from "ws";
|
|
5
|
+
//#region src/project/api-websocket-server.ts
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
const npmWebSocketServer = () => {
|
|
8
|
+
if (process.versions.bun === void 0 || WebSocketServer !== require("ws").WebSocketServer) return WebSocketServer;
|
|
9
|
+
return require(path.join(path.dirname(require.resolve("ws/package.json")), "index.js")).WebSocketServer;
|
|
10
|
+
};
|
|
11
|
+
const functionsPrefix = "/api/functions/";
|
|
12
|
+
const functionMaxPayload = 104857600;
|
|
13
|
+
/**
|
|
14
|
+
* The frame cap of a socket upgraded at `url`: ws's default for an api function's socket, and realtime's
|
|
15
|
+
* `maxFrameBytes` for any other, so a path this does not recognise as a function's, such as an encoded one, gets the
|
|
16
|
+
* smaller cap.
|
|
17
|
+
*/
|
|
18
|
+
const maxPayloadOf = (url) => {
|
|
19
|
+
if (!URL.canParse(url, "http://localhost")) return realtimeLimits.maxFrameBytes;
|
|
20
|
+
return new URL(url, "http://localhost").pathname.startsWith(functionsPrefix) ? functionMaxPayload : realtimeLimits.maxFrameBytes;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The server of npm `ws` that upgrades the API's sockets, realtime's and the app's functions', on Node and Bun: a frame
|
|
24
|
+
* over its socket's cap (`maxPayloadOf`) closes the socket with 1009 before it is read.
|
|
25
|
+
*/
|
|
26
|
+
const apiWebSocketServer = () => {
|
|
27
|
+
const Base = npmWebSocketServer();
|
|
28
|
+
class ApiWebSocketServer extends Base {
|
|
29
|
+
handleUpgrade(...[request, ...rest]) {
|
|
30
|
+
this.options.maxPayload = maxPayloadOf(request.url ?? "");
|
|
31
|
+
super.handleUpgrade(request, ...rest);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return new ApiWebSocketServer({
|
|
35
|
+
noServer: true,
|
|
36
|
+
maxPayload: realtimeLimits.maxFrameBytes
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { apiWebSocketServer, maxPayloadOf };
|
package/dist/serve/lifecycle.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { apiWebSocketServer } from "../project/api-websocket-server.js";
|
|
1
2
|
import { withClientAddress } from "./client-address.js";
|
|
2
3
|
import { projectAdmin } from "../project/project-admin.js";
|
|
3
4
|
import { createPgDb } from "../project/pg-db.js";
|
|
@@ -6,7 +7,6 @@ import { startCleanupTimer } from "./cleanup-timer.js";
|
|
|
6
7
|
import { closeSockets } from "./close-sockets.js";
|
|
7
8
|
import { backgroundSettled, checkAi, checkAuthSchema, checkChanges, checkComments, checkComputed, checkJobsSchema, checkWebhooksSchema, configExports, createFileCleanup, startJobs } from "@protobase/server";
|
|
8
9
|
import { createAdaptorServer, upgradeWebSocket } from "@hono/node-server";
|
|
9
|
-
import { WebSocketServer } from "ws";
|
|
10
10
|
import pg from "pg";
|
|
11
11
|
//#region src/serve/lifecycle.ts
|
|
12
12
|
const listen = (server, port) => new Promise((resolve, reject) => {
|
|
@@ -49,7 +49,7 @@ const startServe = async ({ project, env, createDb = (url) => createPgDb(pg, url
|
|
|
49
49
|
...jobs && { jobs },
|
|
50
50
|
...env.drainToken && { drainToken: env.drainToken }
|
|
51
51
|
});
|
|
52
|
-
const sockets =
|
|
52
|
+
const sockets = apiWebSocketServer();
|
|
53
53
|
const server = createAdaptorServer({
|
|
54
54
|
fetch: withClientAddress(app.fetch, env.trustedProxies),
|
|
55
55
|
overrideGlobalObjects: false,
|
package/dist/users/register.js
CHANGED
|
@@ -3,9 +3,10 @@ import { addMemberCommand } from "../organizations/commands.js";
|
|
|
3
3
|
import { organizationsApi } from "../organizations/register.js";
|
|
4
4
|
import { readHidden, rejectPasswordArgument } from "./password.js";
|
|
5
5
|
import { createUserCommand, listRolesCommand, listUsersCommand } from "./commands.js";
|
|
6
|
-
import { deleteUserCommand,
|
|
7
|
-
import { parseTtl } from "./ttl.js";
|
|
6
|
+
import { deleteUserCommand, setRoleCommand } from "./manage.js";
|
|
8
7
|
import { usersApi } from "./users-api.js";
|
|
8
|
+
import { setDisabledInProject } from "./set-disabled.js";
|
|
9
|
+
import { parseTtl } from "./ttl.js";
|
|
9
10
|
import { Option } from "commander";
|
|
10
11
|
import { issueToken } from "@protobase/server";
|
|
11
12
|
import { createInterface } from "node:readline/promises";
|
|
@@ -63,7 +64,7 @@ const registerUsers = (program) => {
|
|
|
63
64
|
finish(0);
|
|
64
65
|
});
|
|
65
66
|
for (const disabled of [true, false]) users.command(disabled ? "disable" : "enable").description(disabled ? "Ban a user and revoke their sessions" : "Lift a ban").argument("<email>").action(async (email) => {
|
|
66
|
-
await
|
|
67
|
+
await setDisabledInProject(await loadProjectAuth(process.cwd()), {
|
|
67
68
|
email,
|
|
68
69
|
disabled
|
|
69
70
|
}, out);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { setDisabledCommand } from "./manage.js";
|
|
2
|
+
import { usersApi } from "./users-api.js";
|
|
3
|
+
import { checkAuthSchema } from "@protobase/server";
|
|
4
|
+
//#region src/users/set-disabled.ts
|
|
5
|
+
const setDisabledInProject = async (auth, options, out) => {
|
|
6
|
+
await checkAuthSchema(auth);
|
|
7
|
+
await setDisabledCommand(usersApi(auth), options, out);
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { setDisabledInProject };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.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": {
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"@better-auth/core": "^1.7.12",
|
|
37
37
|
"@hono/node-server": "^2.1.3",
|
|
38
38
|
"@hono/vite-dev-server": "^0.26.1",
|
|
39
|
-
"@protobase/layout": "0.
|
|
40
|
-
"@protobase/query": "0.
|
|
41
|
-
"@protobase/schema": "0.
|
|
42
|
-
"@protobase/server": "0.
|
|
43
|
-
"@protobase/ui": "0.
|
|
39
|
+
"@protobase/layout": "0.35.0",
|
|
40
|
+
"@protobase/query": "0.35.0",
|
|
41
|
+
"@protobase/schema": "0.35.0",
|
|
42
|
+
"@protobase/server": "0.35.0",
|
|
43
|
+
"@protobase/ui": "0.35.0",
|
|
44
44
|
"@react-email/render": "^2.1.0",
|
|
45
45
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
46
46
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -35,7 +35,7 @@ bun run protobase auth migration # compares it with what Better Auth needs; w
|
|
|
35
35
|
bun run db:migrate # applies it
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
The file only adds tables, columns and indexes, never drops one, and is plain SQL to review, edit or leave out where the project handles the auth schema itself. `--dir` and `--name` choose the folder and the name after the number. [`protobase migration`](cli.md#migration)) writes the same file, along with what the config's other features need, such as [jobs](jobs.md)).
|
|
38
|
+
The file only adds tables, columns and indexes, never drops one except the OAuth tables of [MCP](#oauth-for-mcp-clients) once `mcp` is off, and is plain SQL to review, edit or leave out where the project handles the auth schema itself. `--dir` and `--name` choose the folder and the name after the number. [`protobase migration`](cli.md#migration)) writes the same file, along with what the config's other features need, such as [jobs](jobs.md)).
|
|
39
39
|
|
|
40
40
|
The store's tables and columns are snake_case, like the app's (`sign_in_policy.platform_sign_in`, `session.user_id`); the code and the API keep Better Auth's camelCase names. A store set up by Protobase 0.6 has Better Auth's camelCase names instead (`"signInPolicy"."platformSignIn"`): for it, `protobase auth migration` writes the migration that renames its tables, columns, indexes and constraints in place, keeping every row. The examples carry it as `db/migrations/*_auth_snake_case.sql`; on a store with the snake_case names it does nothing.
|
|
41
41
|
|
|
@@ -517,7 +517,7 @@ createAuth({ ..., mcp: { path: '/api/mcp', connectPage: '/-/connect' } })
|
|
|
517
517
|
```
|
|
518
518
|
|
|
519
519
|
- `path` is the MCP endpoint's path on the origin of `baseURL`, its OAuth resource (default `/api/mcp`); `connectPage` is the connect page's path (default `/-/connect`, for a UI at the root); `fetchClientMetadata` replaces how a client's metadata document is fetched (default a transport that refuses private and reserved addresses). `auth.mcp` is `{ resource, path, scope }`, for the endpoint.
|
|
520
|
-
- It needs an https `baseURL`, or localhost, and the OAuth tables: run `protobase auth migration` after turning it on (see [migrations](#migrations)). Clients connect through `baseURL`'s origin only, whatever [other origins](#several-origins) the app has. Changing `path` makes every client connect again.
|
|
520
|
+
- It needs an https `baseURL`, or localhost, and the OAuth tables: run `protobase auth migration` after turning it on (see [migrations](#migrations)). Turning it off is a migration too: `protobase auth migration` writes the drop of the OAuth tables, and the app does not start until it is applied. That disconnects every client and forgets every grant, so turning MCP on again starts from nothing and each client has to be allowed again. With `PROTOBASE_STARTUP_CHECKS=false` the tables and their grants stay until the migration is applied. Clients connect through `baseURL`'s origin only, whatever [other origins](#several-origins) the app has. Changing `path` makes every client connect again.
|
|
521
521
|
- Clients find the provider at `/.well-known/oauth-protected-resource` and `/.well-known/oauth-authorization-server`, register at `/api/auth/oauth2/register` (dynamic registration) or are known by an https client id that names their metadata document (CIMD), and are asked for nothing per client. Back-channel logout, a key set URL at registration (`jwks_uri`) and the client credentials grant are refused, though a client with a metadata document may publish its keys on its own origin, and the provider's client management, userinfo, logout and consent endpoints are closed.
|
|
522
522
|
- The scopes are `mcp` and `offline_access`, which is added when a client leaves it out. Access tokens last 15 minutes, carry the MCP resource as their audience and `typ: at+jwt`, and work for MCP only: the app's API refuses them, and the MCP endpoint refuses the app's own tokens. Refresh tokens roll for 30 days. `betterAuthAuthenticator(...).forAudience(auth.mcp.resource)` verifies them; a client that binds its tokens to a key (DPoP) sends a proof with each, checked against the resource's URL.
|
|
523
523
|
- A grant keeps the role and organization the person worked in when they allowed the client. A refresh is refused once they no longer hold that role or may no longer enter that organization, once the [sign-in policy](#sign-in-policy) requires something they have not set up, and while they are banned; access tokens already issued last out their 15 minutes. A grant made without a role is refused.
|
|
@@ -400,7 +400,7 @@ Better Auth and other settings are the project's own variables (`BETTER_AUTH_SEC
|
|
|
400
400
|
- **Routes:** `createAdmin` (`/api/v1`, `/api/meta`, `/api/functions/*`, `/api/auth/*`, ...) and `GET /health`, which answers `{"status":"ok"}` without a token and without touching the database. The runtime never serves the UI; `protobase serve <bundle>` serves `public/` for every path outside the manifest's `api` and `/.well-known/webauthn`, after `/health`, with `X-Frame-Options: DENY` and `Content-Security-Policy: frame-ancestors 'none'`, so no other site frames its pages.
|
|
401
401
|
- **Plugins:** the runtime reads the manifest's `plugins`: `/api/meta` names them, and a view that shows a field with one of their [field types](plugins.md#field-types)) that does not show the field's storage type stops startup, naming the view, the field and what the field type shows.
|
|
402
402
|
- **Version:** before loading the config module, the runtime reads `protobase.bundle.json` beside it and refuses a bundle built by a Protobase version it does not serve, or one without a version, with an error naming both versions (see [Versioning](versioning.md#bundles-and-runtimes))). A config module needs its manifest beside it.
|
|
403
|
-
- **Startup:** a bundle without a default export, `config` or `authenticate`, or with an `options.basePath` other than `/api/v1`, stops startup with a one-line error and exit code 1, as does a missing `DATABASE_URL`, an auth schema that lacks a table or column (see [`auth migration`](#auth-migration)), a resource whose [events](events.md)) or [history](history.md)) lack their triggers or have out-of-date ones, or a missing history or [comments](comments.md#the-table)) table, a [rollup or formula field](data-config.md#rollups-and-formulas)) whose column or trigger is missing or out of date, a jobs schema that is missing or behind for a config with [jobs](jobs.md#the-jobs-schema)) (see [`migration`](#migration)), an [AI field or action](ai.md#the-model)) without a model key, [encrypted fields](data-config.md#encrypted-fields)) without a key, or another resource over their column, or a taken port; `PROTOBASE_STARTUP_CHECKS=false` skips the checks of those schemas and the key. `protobase serve listening on port <port>` means it is ready.
|
|
403
|
+
- **Startup:** a bundle without a default export, `config` or `authenticate`, or with an `options.basePath` other than `/api/v1`, stops startup with a one-line error and exit code 1, as does a missing `DATABASE_URL`, an auth schema that lacks a table or column, or still has the OAuth tables of [MCP](auth.md#oauth-for-mcp-clients)) with `mcp` off (see [`auth migration`](#auth-migration)), a resource whose [events](events.md)) or [history](history.md)) lack their triggers or have out-of-date ones, or a missing history or [comments](comments.md#the-table)) table, a [rollup or formula field](data-config.md#rollups-and-formulas)) whose column or trigger is missing or out of date, a jobs schema that is missing or behind for a config with [jobs](jobs.md#the-jobs-schema)) (see [`migration`](#migration)), an [AI field or action](ai.md#the-model)) without a model key, [encrypted fields](data-config.md#encrypted-fields)) without a key, or another resource over their column, or a taken port; `PROTOBASE_STARTUP_CHECKS=false` skips the checks of those schemas and the key. `protobase serve listening on port <port>` means it is ready.
|
|
404
404
|
- **Jobs:** with [jobs](jobs.md)) in the config it runs them beside the API, unless `PROTOBASE_JOBS=false`, and with `PROTOBASE_JOBS_DRAIN_TOKEN` it answers `POST /api/jobs/drain` for the operator.
|
|
405
405
|
- **Shutdown:** the first SIGTERM or SIGINT stops accepting connections, closes open WebSockets with 1001 (dropping any still open after 5 seconds), waits for open requests, gives running jobs 30 seconds to finish, drains the pool `serve` created (a `db` the config exports is the project's to close) and exits with 0.
|
|
406
406
|
- **Host modules:** under Bun, the runtime registers [the modules it supplies](#the-config-module) as virtual modules, so the bundle needs no `node_modules` for them. `protobase serve`, on Node or Bun, resolves them from the `node_modules` next to the bundle, so keep the bundle inside the project. Native packages load from the bundle's own `node_modules/` under both.
|
|
@@ -499,7 +499,7 @@ bun run db:migrate # applies them
|
|
|
499
499
|
protobase auth migration [--dir db/migrations] [--name auth]
|
|
500
500
|
```
|
|
501
501
|
|
|
502
|
-
Run inside a project whose `protobase.config.ts` exports `auth`, against its database with the project's migrations applied. It compares the database with the tables, columns and indexes Better Auth needs (with Protobase's plugins and the project's own) and writes what is missing as the next migration in `--dir`: `009_auth.sql` after `008_...`. Nothing is written when the schema is current. The file only adds, never drops; apply it with the project's other migrations. For a store with the camelCase names of Protobase 0.6 it writes their rename to snake_case instead, and the startup check asks for that. See [migrations](auth.md#migrations)).
|
|
502
|
+
Run inside a project whose `protobase.config.ts` exports `auth`, against its database with the project's migrations applied. It compares the database with the tables, columns and indexes Better Auth needs (with Protobase's plugins and the project's own) and writes what is missing as the next migration in `--dir`: `009_auth.sql` after `008_...`. Nothing is written when the schema is current. The file only adds, never drops, except the OAuth tables of MCP once `mcp` is off; apply it with the project's other migrations. For a store with the camelCase names of Protobase 0.6 it writes their rename to snake_case instead, and the startup check asks for that. See [migrations](auth.md#migrations)).
|
|
503
503
|
|
|
504
504
|
## `import supabase`
|
|
505
505
|
|
|
@@ -71,6 +71,8 @@ The element stays data, `{ type: 'OrdersPerDay', props: { days: 30 }, children:
|
|
|
71
71
|
|
|
72
72
|
A component that asks for a one-time code uses `OtpInput` from `@protobase/ui`, the field of the app's own code pages: a box per digit drawn over one real input, so pasting a whole code into any box, the system's code autofill from a mail or a text message, and the phone's digit keyboard all work. It takes `value` and `onChange`, `length` (6 by default), `invalid` and `disabled`, and `onComplete` gets the code once its last digit is in, to check it at once. Ask for a code on a step of its own, before anything else.
|
|
73
73
|
|
|
74
|
+
A component that shows markdown, such as a chat message, uses `Markdown` from `@protobase/ui`, which markdown fields draw with: `source` is the markdown, in GitHub's flavour with line breaks kept, shown in the theme's styles. Raw HTML in it shows as text, links open in a new tab, and only links and images to web, mail and phone addresses or relative ones stay. `className` adds classes to its outer element, and `inLink` draws it as running text inside a link, such as a card, with its links and images as their text.
|
|
75
|
+
|
|
74
76
|
`protobase build` fails when the config declares a component that `protobase.ui.tsx` does not export, naming it; while you work, `protobase dev` draws a warning in its place. A component a plugin provides is declared with the plugin's name, `component('DraftOrders', { plugin: 'sales-tools' })`, and the build does not look for it in `protobase.ui.tsx`. A component that throws while drawing shows a warning in its own place, not a blank app. The object form, `defineUi({ components: { OrdersPerDay } })`, still works, and a name given both ways must be the same component.
|
|
75
77
|
|
|
76
78
|
### Fields and resources in props
|
|
@@ -44,6 +44,8 @@ room
|
|
|
44
44
|
|
|
45
45
|
A broadcast reaches the topic's other channels, and the sender's own with `self`; with `ack`, `send` resolves once the server has it. Binary payloads go to clients on the default serializer (`vsn` 2.0.0) only. Presence follows Phoenix Presence: a channel tracks one presence under its `presence.key` (a random one when it names none), tracking again replaces it, and channels with presence enabled get the state when they join and each join and leave after, their own included. A channel that leaves, closes or whose token expires leaves the presence it tracked.
|
|
46
46
|
|
|
47
|
+
Limits, near Supabase's Free plan, apply per socket and per topic. A socket sends at most 100 broadcast and presence messages a second, joins at most 100 times a second and holds at most 100 channels; on each channel it sends at most 5 presence updates in 30 seconds, also counted across a rejoin. A topic takes 100 broadcasts a second, whoever sends them, so one busy sender can use up a topic's budget. A topic is at most 255 bytes, and a tracked presence at most 10 000 bytes of JSON. A message over a limit gets an error reply and goes to no one, where Supabase would close the channel. A frame over 256 KiB closes the socket with 1009. It closes with 1008 when the client leaves more than 4 MiB unread, or sends more than 300 messages or 4 MiB while earlier ones wait, such as behind a token check.
|
|
48
|
+
|
|
47
49
|
Broadcasts and presence go between the channels of one serving process, which is how a cloud app runs; several processes behind one address do not reach each other's channels. Sending without a joined channel, which supabase-js does over `POST /api/sb/realtime/v1/api/broadcast`, is not supported.
|
|
48
50
|
|
|
49
51
|
## What a subscriber receives
|