@protobase/server 0.45.18 → 0.45.20

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.
Files changed (43) hide show
  1. package/dist/better-auth/create-auth.d.ts +9 -20
  2. package/dist/better-auth/create-auth.js +9 -1
  3. package/dist/better-auth/end-replaced-session.d.ts +17 -0
  4. package/dist/better-auth/end-replaced-session.js +15 -0
  5. package/dist/better-auth/live-sessions.js +24 -0
  6. package/dist/create-admin.js +6 -3
  7. package/dist/index.d.ts +6 -4
  8. package/dist/index.js +3 -1
  9. package/dist/jobs/current.d.ts +2 -0
  10. package/dist/jobs/job-progress.js +30 -0
  11. package/dist/jobs/job-types.d.ts +5 -0
  12. package/dist/jobs/run-job.d.ts +1 -0
  13. package/dist/jobs/run-job.js +5 -3
  14. package/dist/jobs/runtime.js +7 -1
  15. package/dist/notifications/caller.js +15 -1
  16. package/dist/notifications/deliver.js +133 -0
  17. package/dist/notifications/device-input.js +17 -6
  18. package/dist/notifications/device-store.d.ts +5 -3
  19. package/dist/notifications/device.d.ts +3 -1
  20. package/dist/notifications/guarded-sender.js +13 -4
  21. package/dist/notifications/history.js +2 -1
  22. package/dist/notifications/options.d.ts +1 -1
  23. package/dist/notifications/options.js +1 -0
  24. package/dist/notifications/paths.d.ts +3 -5
  25. package/dist/notifications/paths.js +1 -4
  26. package/dist/notifications/postgres-store.js +4 -0
  27. package/dist/notifications/push-job-name.js +5 -0
  28. package/dist/notifications/push-job.js +52 -0
  29. package/dist/notifications/push-payload.js +60 -0
  30. package/dist/notifications/routes.js +22 -10
  31. package/dist/notifications/schema-sql.js +7 -1
  32. package/dist/notifications/schema.d.ts +2 -1
  33. package/dist/notifications/schema.js +19 -9
  34. package/dist/notifications/send-input.d.ts +28 -0
  35. package/dist/notifications/send-input.js +80 -0
  36. package/dist/notifications/send-notification.d.ts +11 -0
  37. package/dist/notifications/send-notification.js +19 -0
  38. package/dist/notifications/sender.d.ts +4 -3
  39. package/dist/notifications/store-call.js +32 -0
  40. package/dist/notifications/web-push/web-push-sender.d.ts +1 -1
  41. package/dist/notifications/web-push/web-push-sender.js +9 -5
  42. package/dist/package.js +1 -1
  43. package/package.json +4 -4
@@ -9,7 +9,7 @@ export type WebPushOptions = PostOptions & {
9
9
  * The built-in Web Push sender (RFC 8030, 8291, 8292): delivers to `web` devices, signed with the VAPID pair and
10
10
  * encrypted for each device's keys. It checks the message as `pushMessage` does and throws before any request when it
11
11
  * is not one. A device whose endpoint is not on a browser's push service, or whose keys are not a subscription's, is
12
- * answered `gone` with no request. It logs nothing, and its errors and answers carry no endpoint, key or token.
12
+ * answered `refused` with no request. Each device's JSON carries its user's id as `user`. It logs nothing, and its errors and answers carry no endpoint, key or token.
13
13
  */
14
14
  export declare const webPushSender: (settings: VapidSettings, options?: WebPushOptions) => PushSender;
15
15
  //#endregion
@@ -33,7 +33,7 @@ const headersOf = (message) => {
33
33
  * The built-in Web Push sender (RFC 8030, 8291, 8292): delivers to `web` devices, signed with the VAPID pair and
34
34
  * encrypted for each device's keys. It checks the message as `pushMessage` does and throws before any request when it
35
35
  * is not one. A device whose endpoint is not on a browser's push service, or whose keys are not a subscription's, is
36
- * answered `gone` with no request. It logs nothing, and its errors and answers carry no endpoint, key or token.
36
+ * answered `refused` with no request. Each device's JSON carries its user's id as `user`. It logs nothing, and its errors and answers carry no endpoint, key or token.
37
37
  */
38
38
  const webPushSender = (settings, options = {}) => {
39
39
  const authorization = vapidAuthorizer(settings, options.now);
@@ -42,7 +42,7 @@ const webPushSender = (settings, options = {}) => {
42
42
  const keys = keysOf(device);
43
43
  if (!url || !keys) return {
44
44
  id: device.id,
45
- result: "gone"
45
+ result: "refused"
46
46
  };
47
47
  const body = encryptPayload(plaintext, keys);
48
48
  const answer = await postPush(url, {
@@ -58,10 +58,14 @@ const webPushSender = (settings, options = {}) => {
58
58
  const message = pushMessage(given);
59
59
  if (devices.some((device) => device.kind !== "web")) throw new Error("The Web Push sender was given a device that is not a web device");
60
60
  const headers = headersOf(message);
61
- const plaintext = Buffer.from(JSON.stringify(webPushPayload(message)));
62
- if (plaintext.length > 3993) throw new PushMessageError(`message: its Web Push payload is over ${maxPlaintextBytes} bytes`);
61
+ const payload = webPushPayload(message);
62
+ const plaintexts = new Map(devices.map((device) => [device.id, Buffer.from(JSON.stringify({
63
+ ...payload,
64
+ user: device.userId
65
+ }))]));
66
+ if ([...plaintexts.values()].some((plaintext) => plaintext.length > 3993)) throw new PushMessageError(`message: its Web Push payload is over ${maxPlaintextBytes} bytes`);
63
67
  const answers = [];
64
- for (let start = 0; start < devices.length; start += concurrency) answers.push(...await Promise.all(devices.slice(start, start + concurrency).map((device) => sendOne(device, headers, plaintext))));
68
+ for (let start = 0; start < devices.length; start += concurrency) answers.push(...await Promise.all(devices.slice(start, start + concurrency).map((device) => sendOne(device, headers, plaintexts.get(device.id)))));
65
69
  return answers;
66
70
  };
67
71
  return {
package/dist/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.45.18";
2
+ var version = "0.45.20";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/server",
3
- "version": "0.45.18",
3
+ "version": "0.45.20",
4
4
  "description": "The Protobase REST API as a Hono app, with Better Auth sign-in.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -36,9 +36,9 @@
36
36
  "@better-auth/passkey": "^1.7.12",
37
37
  "@better-auth/sso": "^1.7.12",
38
38
  "@modelcontextprotocol/server": "^2.3.1",
39
- "@protobase/layout": "0.45.18",
40
- "@protobase/query": "0.45.18",
41
- "@protobase/schema": "0.45.18",
39
+ "@protobase/layout": "0.45.20",
40
+ "@protobase/query": "0.45.20",
41
+ "@protobase/schema": "0.45.20",
42
42
  "@react-email/render": "^2.1.0",
43
43
  "@scalar/hono-api-reference": "^0.12.10",
44
44
  "@sentry/core": "^11.7.0",