@vllnt/convex-push 0.0.0-stage → 0.1.0-canary.4a1ca91

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 (152) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE +21 -0
  3. package/README.md +415 -2
  4. package/dist/client/index.d.ts +180 -0
  5. package/dist/client/index.d.ts.map +1 -0
  6. package/dist/client/index.js +152 -0
  7. package/dist/client/index.js.map +1 -0
  8. package/dist/component/_generated/api.d.ts +80 -0
  9. package/dist/component/_generated/api.d.ts.map +1 -0
  10. package/dist/component/_generated/api.js +31 -0
  11. package/dist/component/_generated/api.js.map +1 -0
  12. package/dist/component/_generated/component.d.ts +274 -0
  13. package/dist/component/_generated/component.d.ts.map +1 -0
  14. package/dist/component/_generated/component.js +11 -0
  15. package/dist/component/_generated/component.js.map +1 -0
  16. package/dist/component/_generated/dataModel.d.ts +46 -0
  17. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  18. package/dist/component/_generated/dataModel.js +11 -0
  19. package/dist/component/_generated/dataModel.js.map +1 -0
  20. package/dist/component/_generated/server.d.ts +142 -0
  21. package/dist/component/_generated/server.d.ts.map +1 -0
  22. package/dist/component/_generated/server.js +80 -0
  23. package/dist/component/_generated/server.js.map +1 -0
  24. package/dist/component/actions.d.ts +29 -0
  25. package/dist/component/actions.d.ts.map +1 -0
  26. package/dist/component/actions.js +29 -0
  27. package/dist/component/actions.js.map +1 -0
  28. package/dist/component/checks.d.ts +27 -0
  29. package/dist/component/checks.d.ts.map +1 -0
  30. package/dist/component/checks.js +107 -0
  31. package/dist/component/checks.js.map +1 -0
  32. package/dist/component/convex.config.d.ts +18 -0
  33. package/dist/component/convex.config.d.ts.map +1 -0
  34. package/dist/component/convex.config.js +30 -0
  35. package/dist/component/convex.config.js.map +1 -0
  36. package/dist/component/crons.d.ts +8 -0
  37. package/dist/component/crons.d.ts.map +1 -0
  38. package/dist/component/crons.js +15 -0
  39. package/dist/component/crons.js.map +1 -0
  40. package/dist/component/crypto/codec.d.ts +64 -0
  41. package/dist/component/crypto/codec.d.ts.map +1 -0
  42. package/dist/component/crypto/codec.js +102 -0
  43. package/dist/component/crypto/codec.js.map +1 -0
  44. package/dist/component/crypto/jwt.d.ts +46 -0
  45. package/dist/component/crypto/jwt.d.ts.map +1 -0
  46. package/dist/component/crypto/jwt.js +82 -0
  47. package/dist/component/crypto/jwt.js.map +1 -0
  48. package/dist/component/crypto/token_seal.d.ts +31 -0
  49. package/dist/component/crypto/token_seal.d.ts.map +1 -0
  50. package/dist/component/crypto/token_seal.js +44 -0
  51. package/dist/component/crypto/token_seal.js.map +1 -0
  52. package/dist/component/crypto/web_push_crypto.d.ts +42 -0
  53. package/dist/component/crypto/web_push_crypto.d.ts.map +1 -0
  54. package/dist/component/crypto/web_push_crypto.js +49 -0
  55. package/dist/component/crypto/web_push_crypto.js.map +1 -0
  56. package/dist/component/internal_mutations.d.ts +48 -0
  57. package/dist/component/internal_mutations.d.ts.map +1 -0
  58. package/dist/component/internal_mutations.js +82 -0
  59. package/dist/component/internal_mutations.js.map +1 -0
  60. package/dist/component/mutations.d.ts +223 -0
  61. package/dist/component/mutations.d.ts.map +1 -0
  62. package/dist/component/mutations.js +244 -0
  63. package/dist/component/mutations.js.map +1 -0
  64. package/dist/component/providers/apns.d.ts +46 -0
  65. package/dist/component/providers/apns.d.ts.map +1 -0
  66. package/dist/component/providers/apns.js +105 -0
  67. package/dist/component/providers/apns.js.map +1 -0
  68. package/dist/component/providers/fcm.d.ts +36 -0
  69. package/dist/component/providers/fcm.d.ts.map +1 -0
  70. package/dist/component/providers/fcm.js +116 -0
  71. package/dist/component/providers/fcm.js.map +1 -0
  72. package/dist/component/providers/http.d.ts +45 -0
  73. package/dist/component/providers/http.d.ts.map +1 -0
  74. package/dist/component/providers/http.js +74 -0
  75. package/dist/component/providers/http.js.map +1 -0
  76. package/dist/component/providers/keys.d.ts +70 -0
  77. package/dist/component/providers/keys.d.ts.map +1 -0
  78. package/dist/component/providers/keys.js +89 -0
  79. package/dist/component/providers/keys.js.map +1 -0
  80. package/dist/component/providers/payload.d.ts +83 -0
  81. package/dist/component/providers/payload.d.ts.map +1 -0
  82. package/dist/component/providers/payload.js +162 -0
  83. package/dist/component/providers/payload.js.map +1 -0
  84. package/dist/component/providers/token_cache.d.ts +56 -0
  85. package/dist/component/providers/token_cache.d.ts.map +1 -0
  86. package/dist/component/providers/token_cache.js +42 -0
  87. package/dist/component/providers/token_cache.js.map +1 -0
  88. package/dist/component/providers/web_push.d.ts +40 -0
  89. package/dist/component/providers/web_push.d.ts.map +1 -0
  90. package/dist/component/providers/web_push.js +94 -0
  91. package/dist/component/providers/web_push.js.map +1 -0
  92. package/dist/component/queries.d.ts +132 -0
  93. package/dist/component/queries.d.ts.map +1 -0
  94. package/dist/component/queries.js +156 -0
  95. package/dist/component/queries.js.map +1 -0
  96. package/dist/component/queue.d.ts +66 -0
  97. package/dist/component/queue.d.ts.map +1 -0
  98. package/dist/component/queue.js +356 -0
  99. package/dist/component/queue.js.map +1 -0
  100. package/dist/component/registry.d.ts +46 -0
  101. package/dist/component/registry.d.ts.map +1 -0
  102. package/dist/component/registry.js +128 -0
  103. package/dist/component/registry.js.map +1 -0
  104. package/dist/component/schema.d.ts +286 -0
  105. package/dist/component/schema.d.ts.map +1 -0
  106. package/dist/component/schema.js +70 -0
  107. package/dist/component/schema.js.map +1 -0
  108. package/dist/component/senders.d.ts +67 -0
  109. package/dist/component/senders.d.ts.map +1 -0
  110. package/dist/component/senders.js +123 -0
  111. package/dist/component/senders.js.map +1 -0
  112. package/dist/component/validators.d.ts +784 -0
  113. package/dist/component/validators.d.ts.map +1 -0
  114. package/dist/component/validators.js +193 -0
  115. package/dist/component/validators.js.map +1 -0
  116. package/dist/shared.d.ts +109 -0
  117. package/dist/shared.d.ts.map +1 -0
  118. package/dist/shared.js +131 -0
  119. package/dist/shared.js.map +1 -0
  120. package/docs/API.md +258 -0
  121. package/llms.txt +33 -0
  122. package/package.json +125 -4
  123. package/src/client/index.ts +276 -0
  124. package/src/component/_generated/api.ts +96 -0
  125. package/src/component/_generated/component.ts +263 -0
  126. package/src/component/_generated/dataModel.ts +60 -0
  127. package/src/component/_generated/server.ts +178 -0
  128. package/src/component/actions.ts +31 -0
  129. package/src/component/checks.ts +117 -0
  130. package/src/component/convex.config.ts +32 -0
  131. package/src/component/crons.ts +17 -0
  132. package/src/component/crypto/codec.ts +113 -0
  133. package/src/component/crypto/jwt.ts +109 -0
  134. package/src/component/crypto/token_seal.ts +56 -0
  135. package/src/component/crypto/web_push_crypto.ts +75 -0
  136. package/src/component/internal_mutations.ts +88 -0
  137. package/src/component/mutations.ts +257 -0
  138. package/src/component/providers/apns.ts +116 -0
  139. package/src/component/providers/fcm.ts +132 -0
  140. package/src/component/providers/http.ts +78 -0
  141. package/src/component/providers/keys.ts +133 -0
  142. package/src/component/providers/payload.ts +200 -0
  143. package/src/component/providers/token_cache.ts +75 -0
  144. package/src/component/providers/web_push.ts +101 -0
  145. package/src/component/queries.ts +182 -0
  146. package/src/component/queue.ts +425 -0
  147. package/src/component/registry.ts +144 -0
  148. package/src/component/schema.ts +82 -0
  149. package/src/component/senders.ts +152 -0
  150. package/src/component/validators.ts +285 -0
  151. package/src/shared.ts +155 -0
  152. package/src/test.ts +25 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,41 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ## [0.1.0] - 2026-11-27
6
+
7
+ First canary. Delivery to real devices is not verified yet.
8
+
9
+ ### Added
10
+
11
+ - Sandboxed component `push` with `devices`, `messages`, `deliveries` and
12
+ `providerTokens` tables.
13
+ - Keys bound at mount through component environment variables (`APNS_*`,
14
+ `FCM_SERVICE_ACCOUNT_JSON`, `VAPID_*`). A provider without keys is off.
15
+ - Device registry: `register` (dedupe by address hash, reassignment, token
16
+ rotation by `installRef` within one app, restore of invalid devices; a
17
+ device that moves to another subject is not sent that subject's queued
18
+ messages), `unregister`,
19
+ `setDeviceStatus`, `listDevices`.
20
+ - Send queue: `send` and `sendBatch` (fan-out to up to 100 devices, up to
21
+ 100 deliveries per batch, idempotency key, TTL, payload size check after
22
+ `rawJson`), `status`, `listBySubject`, `cancel`, `prune` (row-budgeted, keeps
23
+ a message until a day after it expires) and a daily prune cron.
24
+ - Senders for APNs (ES256 provider token, HTTP/2), FCM HTTP v1 (RS256 assertion,
25
+ OAuth token exchange) and Web Push (RFC 8291 aes128gcm, RFC 8292 VAPID), all
26
+ on Web Crypto in the default runtime.
27
+ - One `@convex-dev/workpool` per provider; retries with `Retry-After` and
28
+ exponential backoff, stopped at the attempt limit or the message's expiry.
29
+ - Dead-device handling with Apple's 410 timestamp guard, and a per-app
30
+ `BadDeviceToken`/`DeviceTokenNotForTopic` burst breaker plus a per-device
31
+ rate fuse (`@convex-dev/rate-limiter`).
32
+ - Outbound safety: provider requests never follow redirects; Web Push
33
+ endpoints must be https to a public host name; the Google token exchange
34
+ always goes to `oauth2.googleapis.com` (a key file's `token_uri` is ignored).
35
+ - Encrypted provider-token cache (AES-256-GCM, HKDF key from the private key),
36
+ shared by concurrent senders.
37
+ - Extension points: custom providers (`customSendArgs` → `sendResult`), the
38
+ `onDelivery` hook (`deliveryEvent`) and `rawJson` overrides.
39
+ - Content scrubbed from messages once every delivery has finished (on by
40
+ default).
41
+ - `@vllnt/convex-push/test` `register()` helper for `convex-test`.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 bntvllnt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,416 @@
1
- # Temporary Holding Version
1
+ <!-- Badges -->
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![Convex Component](https://img.shields.io/badge/convex-component-EE342F.svg)](https://www.convex.dev/components)
4
+ [![npm version](https://img.shields.io/npm/v/@vllnt/convex-push.svg)](https://www.npmjs.com/package/@vllnt/convex-push)
5
+ [![CI](https://github.com/vllnt/convex-push/actions/workflows/ci.yml/badge.svg)](https://github.com/vllnt/convex-push/actions/workflows/ci.yml)
6
+ [![License](https://img.shields.io/npm/l/@vllnt/convex-push.svg)](./LICENSE)
7
+
8
+ # @vllnt/convex-push
9
+
10
+ Push notifications sent straight from a Convex backend to Apple (APNs), Google
11
+ (FCM HTTP v1) and browser push services (Web Push), as a
12
+ [Convex component](https://docs.convex.dev/components). No relay company sits in
13
+ the path: the component signs and sends each request itself.
14
+
15
+ ```ts
16
+ const push = new Push(components.push, {
17
+ apps: { ios: { platform: "apns", topic: "com.example.app", environment: "production" }, android: { platform: "fcm" } },
18
+ });
19
+
20
+ await push.register(ctx, { subjectRef: userId, appRef: "ios", address: { platform: "apns", token } });
21
+ const { messageId } = await push.send(ctx, {
22
+ to: { subjectRef: userId },
23
+ title: "Support replied",
24
+ data: { ticketRef: "42" },
25
+ idempotencyKey: `reply:${replyId}`,
26
+ });
27
+ const status = await push.status(ctx, messageId);
28
+ ```
29
+
30
+ > **Status: 0.1.0 canary.** Every sender is tested against recorded provider
31
+ > responses and published crypto test vectors, and the crypto also passes in a
32
+ > real Convex runtime. **Delivery to real devices has not been verified yet**
33
+ > (no Apple or Google credentials were used). Treat the first real send on each
34
+ > platform as a smoke test.
35
+
36
+ ## Features
37
+
38
+ - **Direct to the provider.** APNs over HTTP/2, FCM HTTP v1 and Web Push
39
+ (RFC 8030/8291/8292) from a default-runtime action. UnifiedPush endpoints
40
+ speak Web Push.
41
+ - **Device registry.** One row per device address, deduplicated by a hash of
42
+ the address. A rotated token with the same `installRef` (same app) replaces
43
+ its row. A device moves to a new subject when another user registers it, and
44
+ messages queued for the old subject are not sent to it.
45
+ - **Durable queue.** One delivery per device. One [workpool](https://www.convex.dev/components/workpool)
46
+ per built-in provider, so a slow provider cannot starve the others (custom
47
+ providers share one pool).
48
+ - **Retries that follow the provider.** Exponential backoff from one minute,
49
+ `Retry-After` honoured, stop at the attempt limit or at the message's expiry.
50
+ - **Dead-device cleanup.** Provider "gone" answers mark the device `invalid`;
51
+ the next registration restores it. A burst of APNs `BadDeviceToken` or
52
+ `DeviceTokenNotForTopic` for one app pauses that app instead of killing every
53
+ device (wrong environment or topic).
54
+ - **Cached provider tokens.** APNs and VAPID JWTs and the Google access token
55
+ are reused, stored encrypted (AES-256-GCM, key derived from your private key,
56
+ never stored).
57
+ - **Extensible without a fork.** A custom provider (one host action), a
58
+ delivery hook (one host mutation) and `rawJson` for payload fields that have
59
+ no typed option yet.
60
+ - **Content scrubbed at rest.** Title, body and data are erased once every
61
+ delivery has finished (on by default).
62
+
63
+ ## Installation
64
+
65
+ Requires `convex@^1.47.0` (component environment variables).
66
+
67
+ ```bash
68
+ npm install convex @vllnt/convex-push
69
+ ```
70
+
71
+ Prereleases are published under the `canary` dist-tag
72
+ (`npm install @vllnt/convex-push@canary`); pin the resolved version for
73
+ reproducible installs.
74
+
75
+ Bind your keys at mount in `convex/convex.config.ts`. Every variable is
76
+ optional: a provider without keys is switched off and its deliveries fail with
77
+ `PROVIDER_NOT_CONFIGURED`.
78
+
79
+ ```ts
80
+ import { defineApp } from "convex/server";
81
+ import { v } from "convex/values";
82
+ import push from "@vllnt/convex-push/convex.config";
83
+
84
+ const app = defineApp({
85
+ env: {
86
+ APNS_KEY_P8: v.optional(v.string()), // contents of the .p8 file
87
+ APNS_KEY_ID: v.optional(v.string()),
88
+ APNS_TEAM_ID: v.optional(v.string()),
89
+ FCM_SERVICE_ACCOUNT_JSON: v.optional(v.string()),
90
+ VAPID_PUBLIC_KEY: v.optional(v.string()),
91
+ VAPID_PRIVATE_KEY: v.optional(v.string()),
92
+ VAPID_SUBJECT: v.optional(v.string()), // mailto: or https: contact
93
+ },
94
+ });
95
+
96
+ app.use(push, {
97
+ env: {
98
+ APNS_KEY_P8: app.env.APNS_KEY_P8,
99
+ APNS_KEY_ID: app.env.APNS_KEY_ID,
100
+ APNS_TEAM_ID: app.env.APNS_TEAM_ID,
101
+ FCM_SERVICE_ACCOUNT_JSON: app.env.FCM_SERVICE_ACCOUNT_JSON,
102
+ VAPID_PUBLIC_KEY: app.env.VAPID_PUBLIC_KEY,
103
+ VAPID_PRIVATE_KEY: app.env.VAPID_PRIVATE_KEY,
104
+ VAPID_SUBJECT: app.env.VAPID_SUBJECT,
105
+ },
106
+ });
107
+
108
+ export default app;
109
+ ```
110
+
111
+ Then set the values with `npx convex env set APNS_KEY_P8 "$(cat AuthKey_ABC123.p8)"`
112
+ and so on. Two more optional variables, `APNS_SANDBOX_KEY_P8` and
113
+ `APNS_SANDBOX_KEY_ID`, cover an Apple key limited to the sandbox environment.
114
+ A second Apple team or Firebase project is a second mount:
115
+ `app.use(push, { name: "pushPartner", env: { … } })`.
116
+
117
+ ## For coding agents
118
+
119
+ The npm package bundles its docs at `node_modules/@vllnt/convex-push/`:
120
+ `docs/API.md`, `CHANGELOG.md`, `llms.txt` and the TypeScript source in `src/`.
121
+ They match the installed version. Read them before writing code against this
122
+ package.
123
+
124
+ ## Usage
125
+
126
+ ### Name your apps
127
+
128
+ The non-secret part of each app is plain config on the client class. An
129
+ `appRef` is your name for one app on one platform.
130
+
131
+ ```ts
132
+ import { Push } from "@vllnt/convex-push";
133
+ import { components, internal } from "./_generated/api";
134
+
135
+ export const push = new Push(components.push, {
136
+ apps: {
137
+ ios: { platform: "apns", topic: "com.example.app", environment: "production" },
138
+ "ios-dev": { platform: "apns", topic: "com.example.app", environment: "sandbox" },
139
+ android: { platform: "fcm" },
140
+ web: { platform: "webpush" },
141
+ },
142
+ });
143
+ ```
144
+
145
+ ### Register devices
146
+
147
+ Your app owns auth. Resolve the user in your own function and pass an opaque
148
+ `subjectRef`.
149
+
150
+ ```ts
151
+ import { deviceAddress } from "@vllnt/convex-push";
152
+
153
+ export const registerDevice = mutation({
154
+ args: { appRef: v.string(), address: deviceAddress, installRef: v.optional(v.string()), locale: v.optional(v.string()) },
155
+ returns: v.object({ deviceId: v.string(), created: v.boolean() }),
156
+ handler: async (ctx, args) => push.register(ctx, { subjectRef: await requireUserId(ctx), ...args }),
157
+ });
158
+ ```
159
+
160
+ Addresses by platform:
161
+
162
+ | Platform | Address | Where it comes from |
163
+ |---|---|---|
164
+ | `apns` | `{ platform: "apns", token }` | `registerForRemoteNotifications()`, or `getDevicePushTokenAsync()` in Expo (`type: "ios"`) |
165
+ | `fcm` | `{ platform: "fcm", token }` | `FirebaseMessaging.getToken()`, or `getDevicePushTokenAsync()` in Expo (`type: "android"`) |
166
+ | `webpush` | `{ platform: "webpush", endpoint, p256dh, auth }` | `registration.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey })` |
167
+ | `custom` | `{ platform: "custom", provider, address }` | Your own provider, see below |
168
+
169
+ Register on every app launch. Call `unregister` on logout and
170
+ `setDeviceStatus` to pause one device.
171
+
172
+ ### Send
173
+
174
+ ```ts
175
+ export const notifyReply = internalMutation({
176
+ args: { customerRef: v.string(), ticketRef: v.string(), replyRef: v.string(), preview: v.string() },
177
+ returns: v.object({ messageId: v.string(), deliveries: v.number(), deduplicated: v.boolean() }),
178
+ handler: async (ctx, a) =>
179
+ push.send(ctx, {
180
+ to: { subjectRef: a.customerRef },
181
+ title: "Support replied",
182
+ body: a.preview,
183
+ data: { kind: "ticket.reply", ticketRef: a.ticketRef },
184
+ collapseKey: `ticket:${a.ticketRef}`,
185
+ ttlSeconds: 3600,
186
+ idempotencyKey: `reply:${a.replyRef}`,
187
+ overrides: { apns: { threadId: a.ticketRef }, fcm: { channelId: "support" } },
188
+ }),
189
+ });
190
+ ```
191
+
192
+ `send` runs in your mutation's transaction: if the mutation fails, nothing is
193
+ queued. `to` is either `{ subjectRef }` (every active device of that subject) or
194
+ `{ deviceIds }`. A message without title and body is silent: a background push
195
+ on APNs and a data-only message on FCM. Web Push has no silent push, so those
196
+ deliveries fail with `SILENT_NOT_SUPPORTED`. `sendBatch` queues up to 100
197
+ messages and 100 deliveries in one call.
198
+
199
+ ### Watch delivery
200
+
201
+ ```ts
202
+ import { messageStatus } from "@vllnt/convex-push";
203
+
204
+ export const pushStatus = query({
205
+ args: { messageId: v.string() },
206
+ returns: v.union(messageStatus, v.null()),
207
+ handler: async (ctx, { messageId }) => {
208
+ await requireAgent(ctx);
209
+ return push.status(ctx, messageId);
210
+ },
211
+ });
212
+ ```
213
+
214
+ Each delivery ends `sent`, `failed` or `invalid`, with the provider's message id
215
+ or an error code. `listBySubject` lists a subject's recent messages with counts.
216
+ `cancel` stops the deliveries still queued. Queries never return a device
217
+ address, a token or message content.
218
+
219
+ ## Extending it
220
+
221
+ | You want to | Use |
222
+ |---|---|
223
+ | Change TTL, attempt limit, sends in parallel, retention | `defaultTtlSeconds`, `maxAttempts`, `maxParallelism`, `retentionMs` on the client |
224
+ | Keep content after delivery | `scrubContent: false` |
225
+ | Use a payload field with no typed option | `rawJson` in that provider's `overrides` slot |
226
+ | Add a provider this package does not ship | A custom provider: one action in your app |
227
+ | Act when a delivery ends | The `onDelivery` hook: one mutation in your app |
228
+ | Consent, quiet hours, who may send | Your own function around `push.send` |
229
+
230
+ ### A custom provider
231
+
232
+ A custom provider is one action in your app that sends one notification to one
233
+ address. The component keeps the device row, the queue, retries, expiry and
234
+ dead-address cleanup.
235
+
236
+ ```ts
237
+ import { customSendArgs, sendResult, type SendResult } from "@vllnt/convex-push";
238
+
239
+ const push = new Push(components.push, {
240
+ apps: { desktop: { platform: "custom", provider: "webhook" } },
241
+ providers: { webhook: { send: internal.pushSenders.webhook } },
242
+ });
243
+
244
+ export const webhook = internalAction({
245
+ args: customSendArgs,
246
+ returns: sendResult,
247
+ handler: async (_ctx, a): Promise<SendResult> => {
248
+ const res = await fetch(a.address, {
249
+ method: "POST",
250
+ headers: { "content-type": "application/json", "idempotency-key": a.deliveryId },
251
+ body: JSON.stringify({ title: a.title, body: a.body, data: a.data }),
252
+ });
253
+ if (res.ok) return { status: "sent", providerMessageId: res.headers.get("x-message-id") ?? undefined };
254
+ if (res.status === 404 || res.status === 410) return { status: "invalid", code: "GONE" };
255
+ if (res.status === 429 || res.status >= 500) return { status: "retry", code: String(res.status) };
256
+ return { status: "failed", code: String(res.status) };
257
+ },
258
+ });
259
+ ```
260
+
261
+ | The sender returns | The component then |
262
+ |---|---|
263
+ | `sent` (optional `providerMessageId`) | Marks the delivery sent |
264
+ | `retry` (optional `delayMs`, bounded to 1 s..1 day) | Queues it again, until the attempt limit or the message's expiry |
265
+ | `invalid` | Marks the delivery and the device invalid; the next registration restores the device |
266
+ | `failed` | Marks the delivery failed, no retry |
267
+ | Throws or times out | Counts as `retry` with code `SENDER_ERROR` |
268
+ | Anything else | Fails the delivery with `SENDER_BAD_RESULT` |
269
+
270
+ The sender may live in a `"use node"` file and read its own environment
271
+ variables. Delivery is at least once: use `deliveryId` as an idempotency key
272
+ where your provider supports one.
273
+
274
+ ### The delivery hook
275
+
276
+ ```ts
277
+ import { deliveryEvent } from "@vllnt/convex-push";
278
+
279
+ export const onDelivery = internalMutation({
280
+ args: deliveryEvent,
281
+ returns: v.null(),
282
+ handler: async (ctx, e) => {
283
+ await ctx.db.insert("pushEvents", e);
284
+ return null;
285
+ },
286
+ });
287
+ ```
288
+
289
+ Pass it as `onDelivery: internal.push.onDelivery`. It runs once per delivery,
290
+ when it reaches `sent`, `failed` or `invalid`, never on a retry. The event holds
291
+ ids, platform, status and error code, never title, body or data. The component
292
+ schedules the hook instead of calling it inline, so a hook that throws cannot
293
+ undo the delivery record.
294
+
295
+ ### Raw payload fields
296
+
297
+ ```ts
298
+ overrides: { apns: { rawJson: JSON.stringify({ aps: { "relevance-score": 0.8 } }) } }
299
+ ```
300
+
301
+ `rawJson` must parse to a JSON object. It is merged into the built payload last
302
+ and the size limit (4096 bytes for APNs and FCM, 3993 bytes of plaintext for
303
+ Web Push) is checked after the merge. Bad JSON or an oversized result is refused
304
+ when the message is queued. It reaches payload fields only, not headers.
305
+
306
+ ## Composition at the host
307
+
308
+ Components never call each other. Your app wires them. The ticket reply flow
309
+ from sibling packages: inbox first, a push if the customer has not read it after
310
+ two minutes, email if there is no device.
311
+
312
+ ```ts
313
+ export const nudge = internalMutation({
314
+ args: nudgeArgs,
315
+ returns: v.null(),
316
+ handler: async (ctx, a) => {
317
+ const item = await inbox.get(ctx, a.notificationId, { subjectRef: a.customerRef });
318
+ if (!item || item.readAt) return null;
319
+ const { deliveries } = await push.send(ctx, {
320
+ to: { subjectRef: a.customerRef },
321
+ title: "Support replied",
322
+ data: { ticketRef: a.ticketRef },
323
+ idempotencyKey: `reply:${a.notificationId}`,
324
+ });
325
+ if (deliveries === 0) await email.enqueue(ctx, a.notificationId, a.customerEmail, "support@example.com", "smtp");
326
+ return null;
327
+ },
328
+ });
329
+ ```
330
+
331
+ `inbox` is `@vllnt/convex-notifications` and `email` is `@vllnt/convex-email`.
332
+
333
+ ## Security
334
+
335
+ - **Keys stay in environment variables.** They are bound at mount, read inside
336
+ the send action, and never written to a table, returned or logged.
337
+ - **Cached tokens are encrypted.** AES-256-GCM, with a key derived by HKDF from
338
+ your private key inside the action. A database export holds no usable
339
+ credential.
340
+ - **No content or address in queries or logs.** Queries return ids, statuses and
341
+ codes. Logs carry ids, platforms and codes.
342
+ - **Content-free pushes are the private option.** Apple and Google read what you
343
+ send them. Send a neutral title plus an id, and let the app fetch the text from
344
+ Convex after it wakes. Web Push payloads are encrypted end to end.
345
+ - **Device tokens are stored in the clear,** because sending needs them. A token
346
+ is useless without the provider key, except a Web Push endpoint without VAPID.
347
+ - **Requests go only where they should.** Provider requests never follow
348
+ redirects. Web Push endpoints must be https to a public host name (no IP
349
+ literals, trailing dots, `localhost` or private suffixes); DNS answers are not checked. A
350
+ custom sender fetches whatever address you store, so validate it there.
351
+ - **Your app owns auth.** The optional `subjectRef` on `unregister` and
352
+ `setDeviceStatus` guards against cross-user bugs in an honest host, not a
353
+ hostile one.
354
+
355
+ ## Limits
356
+
357
+ | Limit | Value |
358
+ |---|---|
359
+ | Devices per message | 100 (a subject's first 100 active devices) |
360
+ | Messages per `sendBatch` | 100, and 100 deliveries in total |
361
+ | Payload | 4096 bytes (APNs, FCM), 3993 bytes plaintext (Web Push) |
362
+ | `rawJson` | 4096 characters |
363
+ | `ttlSeconds` | 0 to 2,419,200 (28 days), default 86,400 |
364
+ | Attempts per delivery | default 5, at most 20 |
365
+ | Sends to one device | 60 per minute, then delayed |
366
+ | Retention | 30 days by the daily prune; `prune()` uses the client's `retentionMs`. A message is kept until a day after it expires |
367
+
368
+ ## Testing your app
369
+
370
+ `@vllnt/convex-push/test` exports `register(t, name = "push")`. It mounts the
371
+ component and its child components (four workpools and a rate limiter) in a
372
+ `convex-test` instance. It needs `convex-test` and `vitest` (with Vite's
373
+ `import.meta.glob`).
374
+
375
+ ```ts
376
+ /// <reference types="vite/client" />
377
+ import { convexTest } from "convex-test";
378
+ import { register } from "@vllnt/convex-push/test";
379
+ import schema from "./schema";
380
+
381
+ const t = convexTest(schema, import.meta.glob("./**/*.ts"));
382
+ register(t, "push");
383
+ ```
384
+
385
+ Stub `fetch` with `vi.stubGlobal` to script provider answers, and set keys with
386
+ `vi.stubEnv`. See [`example/convex/example.test.ts`](https://github.com/vllnt/convex-push/blob/main/example/convex/example.test.ts).
387
+
388
+ ## Related packages
389
+
390
+ - [`@convex-dev/expo-push-notifications`](https://www.npmjs.com/package/@convex-dev/expo-push-notifications)
391
+ — sends through Expo's push service. Use it if you want Expo to hold your
392
+ Apple and Google credentials; use this package to send direct.
393
+ - `@vllnt/convex-notifications` — the in-app inbox with read state. A push can
394
+ be lost; the inbox cannot. Use both.
395
+ - `@vllnt/convex-email` — the email channel, with its own queue.
396
+
397
+ ## Contributing
398
+
399
+ See
400
+ [CONTRIBUTING.md](https://github.com/vllnt/convex-push/blob/main/CONTRIBUTING.md)
401
+ for development setup, testing, and PR guidelines.
402
+
403
+ ## Author
404
+
405
+ Built by [bntvllnt](https://github.com/bntvllnt) ·
406
+ [bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
407
+
408
+ If this is useful, [sponsor the work](https://github.com/sponsors/bntvllnt).
409
+
410
+ ## License
411
+
412
+ MIT — see [LICENSE](LICENSE).
413
+
414
+ ---
415
+
416
+ Part of vllnt oss: https://oss.vllnt.com
@@ -0,0 +1,180 @@
1
+ import { type FunctionReference, type FunctionVisibility, type GenericActionCtx, type GenericDataModel, type GenericMutationCtx, type GenericQueryCtx } from "convex/server";
2
+ import { type DeviceStatus } from "../shared.js";
3
+ import type { ComponentApi } from "../component/_generated/component.js";
4
+ import type { AppConfig, CustomSendArgs, DeliveryEvent, DeviceAddress, DeviceView, MessageStatus, MessageSummary, SendInput } from "../component/validators.js";
5
+ export { appConfig, customSendArgs, data, deliveryEvent, deliveryView, deviceAddress, deviceView, messageStatus, messageSummary, overrides, sendResult, } from "../component/validators.js";
6
+ export type { AppConfig, CustomSendArgs, DeliveryEvent, DeliveryView, DeviceAddress, DeviceView, MessageStatus, MessageSummary, Overrides, PushData, SendInput, SendResult, } from "../component/validators.js";
7
+ export * from "../shared.js";
8
+ /** A context that can run component mutations. */
9
+ export type RunMutationCtx = Pick<GenericMutationCtx<GenericDataModel>, "runMutation">;
10
+ /** A context that can run component queries. */
11
+ export type RunQueryCtx = Pick<GenericQueryCtx<GenericDataModel>, "runQuery">;
12
+ /** Any context that can run component queries (query, mutation or action). */
13
+ export type AnyQueryCtx = RunQueryCtx | Pick<GenericActionCtx<GenericDataModel>, "runQuery">;
14
+ /** A host action that sends one notification for a custom provider. */
15
+ export type CustomSender = FunctionReference<"action", FunctionVisibility, CustomSendArgs>;
16
+ /** A host mutation told once per finished delivery. */
17
+ export type DeliveryHook = FunctionReference<"mutation", FunctionVisibility, DeliveryEvent>;
18
+ /** Settings of one mount. Only `apps` is required. */
19
+ export interface PushOptions {
20
+ /** What each `appRef` means: platform, and for APNs the bundle id and Apple host. */
21
+ apps: Readonly<Record<string, AppConfig>>;
22
+ /** Custom providers by name, each with the host action that sends. */
23
+ providers?: Readonly<Record<string, {
24
+ send: CustomSender;
25
+ }>>;
26
+ /** Host mutation run once per delivery when it reaches sent, failed or invalid. */
27
+ onDelivery?: DeliveryHook;
28
+ /** Time to live when a send gives none. Default one day. */
29
+ defaultTtlSeconds?: number;
30
+ /** Attempts per delivery. Default 5. */
31
+ maxAttempts?: number;
32
+ /** Sends in flight per provider queue. Default 10. */
33
+ maxParallelism?: number;
34
+ /** Erase title, body and data once every delivery has finished. Default true. */
35
+ scrubContent?: boolean;
36
+ /** Retention used by {@link Push.prune}. Default 30 days. */
37
+ retentionMs?: number;
38
+ }
39
+ /** One message to send. */
40
+ export type SendMessage = SendInput;
41
+ /** Arguments of {@link Push.register}. */
42
+ export interface RegisterArgs {
43
+ subjectRef: string;
44
+ appRef: string;
45
+ address: DeviceAddress;
46
+ installRef?: string;
47
+ locale?: string;
48
+ }
49
+ /**
50
+ * Typed entry point to a mounted push component.
51
+ *
52
+ * @example
53
+ * const push = new Push(components.push, {
54
+ * apps: { ios: { platform: "apns", topic: "com.example.app", environment: "production" } },
55
+ * });
56
+ * await push.send(ctx, { to: { subjectRef: userId }, title: "Support replied", body: preview });
57
+ */
58
+ export declare class Push {
59
+ readonly component: ComponentApi;
60
+ private readonly options;
61
+ /**
62
+ * @param component - `components.push` from the host's `_generated/api`.
63
+ * @param options - Apps, providers, hook and defaults.
64
+ */
65
+ constructor(component: ComponentApi, options: PushOptions);
66
+ private config;
67
+ private withDefaults;
68
+ /**
69
+ * Register or refresh a device. The host resolves `subjectRef` from its own auth.
70
+ * @param ctx - A mutation context.
71
+ * @param args - Owner, app, address and optional install id and locale.
72
+ * @returns The device id and whether a new row was created.
73
+ * @throws `UNKNOWN_APP` when `appRef` is not in `apps`; `PLATFORM_MISMATCH` when the address does not fit the app.
74
+ */
75
+ register(ctx: RunMutationCtx, args: RegisterArgs): Promise<{
76
+ deviceId: string;
77
+ created: boolean;
78
+ }>;
79
+ /**
80
+ * Remove a device, for example on logout.
81
+ * @param ctx - A mutation context.
82
+ * @param args - `deviceId` or `address`, and optionally the owner to check.
83
+ * @returns Whether a device was removed.
84
+ */
85
+ unregister(ctx: RunMutationCtx, args: {
86
+ deviceId: string;
87
+ subjectRef?: string;
88
+ } | {
89
+ address: DeviceAddress;
90
+ subjectRef?: string;
91
+ }): Promise<{
92
+ removed: boolean;
93
+ }>;
94
+ /**
95
+ * Pause or resume one device.
96
+ * @param ctx - A mutation context.
97
+ * @param args - Device, new status, and optionally the owner to check.
98
+ * @returns Whether the device was updated.
99
+ */
100
+ setDeviceStatus(ctx: RunMutationCtx, args: {
101
+ deviceId: string;
102
+ status: Exclude<DeviceStatus, "invalid">;
103
+ subjectRef?: string;
104
+ }): Promise<{
105
+ updated: boolean;
106
+ }>;
107
+ /**
108
+ * List a subject's devices. Addresses are never returned.
109
+ * @param ctx - Any context that can run queries.
110
+ * @param args - Owner, optional status filter and limit (default 20, max 100).
111
+ * @returns Device views.
112
+ */
113
+ listDevices(ctx: AnyQueryCtx, args: {
114
+ subjectRef: string;
115
+ status?: DeviceStatus;
116
+ limit?: number;
117
+ }): Promise<DeviceView[]>;
118
+ /**
119
+ * Enqueue one message. Call it from a mutation: if the mutation fails, nothing is queued.
120
+ * @param ctx - A mutation context.
121
+ * @param message - Recipient, content, options, overrides and idempotency key.
122
+ * @returns The message id, how many deliveries were created, and whether the idempotency key matched an earlier send.
123
+ */
124
+ send(ctx: RunMutationCtx, message: SendMessage): Promise<{
125
+ messageId: string;
126
+ deliveries: number;
127
+ deduplicated: boolean;
128
+ }>;
129
+ /**
130
+ * Enqueue up to 100 messages and 100 deliveries in one transaction. Over
131
+ * that it throws `INVALID_ARGUMENT` and queues nothing.
132
+ * @param ctx - A mutation context.
133
+ * @param messages - The messages.
134
+ * @returns One result per message, in order.
135
+ */
136
+ sendBatch(ctx: RunMutationCtx, messages: SendMessage[]): Promise<{
137
+ messageId: string;
138
+ deliveries: number;
139
+ deduplicated: boolean;
140
+ }[]>;
141
+ /**
142
+ * A message's delivery state. Reactive in a query. Never returns content.
143
+ * @param ctx - Any context that can run queries.
144
+ * @param messageId - The id `send` returned.
145
+ * @returns The status, or `null` for an unknown id.
146
+ */
147
+ status(ctx: AnyQueryCtx, messageId: string): Promise<MessageStatus | null>;
148
+ /**
149
+ * A subject's recent messages, newest first, with delivery counts.
150
+ * @param ctx - Any context that can run queries.
151
+ * @param args - Subject and optional limit (default 20, max 100).
152
+ * @returns Message summaries.
153
+ */
154
+ listBySubject(ctx: AnyQueryCtx, args: {
155
+ subjectRef: string;
156
+ limit?: number;
157
+ }): Promise<MessageSummary[]>;
158
+ /**
159
+ * Cancel a message's queued deliveries.
160
+ * @param ctx - A mutation context.
161
+ * @param messageId - The message.
162
+ * @returns How many deliveries were cancelled.
163
+ */
164
+ cancel(ctx: RunMutationCtx, messageId: string): Promise<{
165
+ cancelled: number;
166
+ }>;
167
+ /**
168
+ * Delete data older than the retention window. The component also runs this daily with the default window.
169
+ * @param ctx - A mutation context.
170
+ * @param args - Optional batch size.
171
+ * @returns Rows deleted, and whether another pass was scheduled.
172
+ */
173
+ prune(ctx: RunMutationCtx, args?: {
174
+ batch?: number;
175
+ }): Promise<{
176
+ deleted: number;
177
+ more: boolean;
178
+ }>;
179
+ }
180
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,aAAa,EACb,aAAa,EACb,UAAU,EACV,aAAa,EACb,cAAc,EAEd,SAAS,EACV,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,SAAS,EACT,cAAc,EACd,IAAI,EACJ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,aAAa,EACb,cAAc,EACd,SAAS,EACT,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,SAAS,EACT,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,aAAa,EACb,cAAc,EACd,SAAS,EACT,QAAQ,EACR,SAAS,EACT,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,cAAc,cAAc,CAAC;AAE7B,kDAAkD;AAClD,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,aAAa,CAAC,CAAC;AACvF,gDAAgD;AAChD,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,CAAC;AAC9E,8EAA8E;AAC9E,MAAM,MAAM,WAAW,GA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