@protobase/cli 0.79.4 → 0.79.5

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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.79.4";
2
+ var version = "0.79.5";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.79.4",
3
+ "version": "0.79.5",
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.79.4",
47
- "@protobase/layout": "0.79.4",
48
- "@protobase/query": "0.79.4",
49
- "@protobase/schema": "0.79.4",
50
- "@protobase/server": "0.79.4",
51
- "@protobase/ui": "0.79.4",
52
- "@protobase/workflows": "0.79.4",
46
+ "@protobase/config": "0.79.5",
47
+ "@protobase/layout": "0.79.5",
48
+ "@protobase/query": "0.79.5",
49
+ "@protobase/schema": "0.79.5",
50
+ "@protobase/server": "0.79.5",
51
+ "@protobase/ui": "0.79.5",
52
+ "@protobase/workflows": "0.79.5",
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",
@@ -13,5 +13,6 @@ A bell in the top bar and push to browsers and phones, for what your app tells i
13
13
  - [Web Push](../reference/notifications.md#web-push) (beta): Notifications reach desktop and Android browsers and home-screen web apps on iPhone through Web Push, with keys you generate.
14
14
  - [Push on Android](../reference/notifications.md#android) (beta): The server sends notifications to Android devices through Firebase Cloud Messaging with the service account key in `PROTOBASE_FCM_SERVICE_ACCOUNT`, and the mobile app receives them, set up by `protobase mobile` from a `google-services.json` in the project.
15
15
  - [Push on iOS](../reference/notifications.md#ios) (in development): The server sends notifications to iPhone and iPad through the Apple Push Notification service with the APNs key in `PROTOBASE_APNS_KEY`, `PROTOBASE_APNS_KEY_ID` and `PROTOBASE_APNS_TEAM_ID`; the mobile app registering for them and receiving them on iOS is coming soon.
16
+ - [Push relay](../reference/notifications.md#push-relay) (beta): Send push notifications through a relay that holds the mobile app's push keys, so your app needs only its own relay credential.
16
17
  - [Do not disturb](../reference/status.md#do-not-disturb) (beta): While someone is on do not disturb, sends push nothing to their devices and keep inbox notifications in the bell for later.
17
18
  - [Notification bell](../reference/notifications.md#the-bell) (beta): The top bar shows how many inbox notifications are unread; its panel opens each one, marks them read and turns push on or off for this device.
@@ -37,7 +37,7 @@ A device is where a user receives push: a browser's push subscription, or an And
37
37
  | `POST /api/notifications/devices` | registers the device the request comes from, or refreshes it; answers `{ id, kind, createdAt, lastSeenAt }` |
38
38
  | `DELETE /api/notifications/devices/<id>` | removes the caller's device with that id; answers `204` whether or not the caller had it |
39
39
 
40
- The body of a register is JSON (`Content-Type: application/json`, at most 8 KB), in one of three shapes:
40
+ The body of a register is JSON (`Content-Type: application/json`, at most 8 KB), in one of four shapes:
41
41
 
42
42
  ```jsonc
43
43
  // A browser: its PushSubscription as JSON
@@ -46,6 +46,8 @@ The body of a register is JSON (`Content-Type: application/json`, at most 8 KB),
46
46
  { "kind": "apns", "token": "…", "environment": "production", "appId": "net.example.app" }
47
47
  // An Android app: its token, and optionally its package name
48
48
  { "kind": "fcm", "token": "…", "appId": "net.example.app" }
49
+ // A mobile app's handle from a push relay
50
+ { "kind": "relay", "handle": "…" }
49
51
  ```
50
52
 
51
53
  A field that does not belong to the kind, a missing one, an unknown one such as an owner, or a value out of its format is a `400` that names the field and stores nothing. A browser's `endpoint` must be an https URL on one of the browsers' push services. `environment` is `sandbox` or `production`, and `userAgent`, optional for every kind, is at most 512 characters. The stored device keeps `null` in the fields its kind does not have.
@@ -58,7 +60,7 @@ Who may call them:
58
60
  - An app with its own authenticator ([`auth/authenticate.ts`](config/sign-in.md#authenticate)) marks a user's own sign-in on the session it returns, `signIn: { staff: false }`; without that mark, its sessions are refused.
59
61
  - With Protobase's auth, every token the endpoints take names its sign-in session; one that names none is refused with a `403`.
60
62
 
61
- A device is one token, or one endpoint for a browser. An Android or iOS token someone else had moves to the caller, as a new device with a new id that keeps nothing of the previous user's, so a shared phone notifies whoever signed in on it last. A browser's endpoint never moves: registering one another user holds is a `409` of type `device-held` that stores nothing, and the browser subscribes again for a new endpoint, as [the browser helper](#in-the-browser) does. A user keeps up to 20 devices: registering one more removes their least recently seen. Deleting a user removes their devices.
63
+ A device is one token, or one endpoint for a browser. An Android or iOS token, or a relay handle, someone else had moves to the caller, as a new device with a new id that keeps nothing of the previous user's, so a shared phone notifies whoever signed in on it last. A browser's endpoint never moves: registering one another user holds is a `409` of type `device-held` that stores nothing, and the browser subscribes again for a new endpoint, as [the browser helper](#in-the-browser) does. A user keeps up to 20 devices: registering one more removes their least recently seen. Deleting a user removes their devices.
62
64
 
63
65
  With Protobase's auth, a device belongs to the sign-in session it was registered in. Once that session ends, the device gets no more push and is removed at the next send: when the user signs out, someone signs in on the same browser, the user signs out everywhere, a password change signs out their other devices, an admin ends their sessions or bans them, or the session expires. Registering the device again ties it to the session of that request, which the browser helper does on its own for the same user. With an app's own authenticator, a device stays its user's until it is removed with `DELETE`.
64
66
 
@@ -256,6 +258,33 @@ Any other field is refused, such as `token`, `topic`, `webpush` or `click_action
256
258
 
257
259
  `fcmSender(readFcmSettings(process.env)!)` from `@protobase/server` is the built-in sender, to list beside [your own senders](#senders).
258
260
 
261
+ ## Push relay
262
+
263
+ :::caution[Beta]
264
+ The relay service, and the mobile app that registers relay handles, are coming soon.
265
+ :::
266
+
267
+ An app can deliver mobile push through a relay instead of holding APNs or FCM keys itself. The relay holds the mobile app's push keys, and your app sends to it with a relay credential of its own. You set the relay's URL and your app's credential in two environment variables:
268
+
269
+ ```sh
270
+ PROTOBASE_PUSH_RELAY_URL=https://relay.example.com
271
+ PROTOBASE_PUSH_RELAY_CREDENTIAL=...
272
+ ```
273
+
274
+ Without them the relay is off and relay devices are skipped. Only one of them set, a URL that is not `https` or that has a user, query or fragment, or a credential that is not 16 to 1024 letters, digits and `-._~+/` stops startup, naming the variable without its value. The credential is a secret: keep it out of client code, `VITE_` variables and the repository.
275
+
276
+ A device registered with a relay handle, `{ "kind": "relay", "handle": "…" }` (see [Devices](#devices)), receives your app's notifications with the usual [inbox](#history), [do not disturb](status.md#do-not-disturb) and sign-in session rules. The handle is what the relay gave the device for your app, never its own push token: 16 to 512 letters, digits, `-` and `_`.
277
+
278
+ Each send is `POST <url>/send`, with the credential as a bearer token, never through a redirect, and JSON with the [message](#senders) as senders get it and up to 100 devices, each with its handle and `user`, the id of the user it is registered for:
279
+
280
+ ```json
281
+ { "message": { "title": "Task assigned", "url": "https://app.example.com/tasks/42" }, "devices": [{ "handle": "…", "user": "user-1" }] }
282
+ ```
283
+
284
+ The relay answers a `2xx` with a result for each handle, `ok`, `gone`, `retry` or `refused`, as [senders](#senders) answer: `{ "results": [{ "handle": "…", "result": "ok" }] }`. A handle the relay answers `gone` removes its device. A handle it does not answer, and every handle of any other answer, such as a wrong credential, a `429` or `5xx` (after its `Retry-After`) or no answer within ten seconds, is retried, so a mistake in the configuration removes no device. A device stored with a token that is not a relay handle is `refused`. <gap>A send cannot keep the notification's text from the relay because content-free or encrypted relay payloads are not implemented.</gap>
285
+
286
+ `relaySender(readRelaySettings(process.env)!)` from `@protobase/server` is the built-in sender, to list beside [your own senders](#senders). `relaySendRequest` and `relaySendAnswer` check the request and answer shapes.
287
+
259
288
  ## Your own parts
260
289
 
261
290
  :::caution[Beta]
@@ -308,7 +337,7 @@ A notification is `{ id, userId, title, body, url, data, createdAt, readAt }`, a
308
337
 
309
338
  ### Senders
310
339
 
311
- A sender delivers notifications to the devices of the kinds it names, through their push service. Web Push, APNs and FCM are built in; your own senders, such as from a package, are the default export of `notifications/senders.ts`, an array, and they replace the built-in ones, at most one for each kind. To keep a built-in one beside them, list it too: `webPushSender(readVapidSettings(process.env)!)` from `@protobase/server` is the built-in Web Push sender, and `readVapidSettings` reads the [VAPID variables](#web-push), `undefined` when none is set; `apnsSender(readApnsSettings(process.env)!, { appId })` is the built-in APNs sender, with the mobile app's `appId`, and `readApnsSettings` reads the [APNs variables](#ios) the same way:
340
+ A sender delivers notifications to the devices of the kinds it names, through their push service. Web Push, APNs, FCM and the [push relay](#push-relay) are built in; your own senders, such as from a package, are the default export of `notifications/senders.ts`, an array, and they replace the built-in ones, at most one for each kind. To keep a built-in one beside them, list it too: `webPushSender(readVapidSettings(process.env)!)` from `@protobase/server` is the built-in Web Push sender, and `readVapidSettings` reads the [VAPID variables](#web-push), `undefined` when none is set; `apnsSender(readApnsSettings(process.env)!, { appId })` is the built-in APNs sender, with the mobile app's `appId`, and `readApnsSettings` reads the [APNs variables](#ios) the same way:
312
341
 
313
342
  ```ts
314
343
  // notifications/senders.ts