@lunora/notify 1.0.0-alpha.2 → 1.0.0-alpha.21

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/README.md CHANGED
@@ -98,6 +98,35 @@ for (const message of batch.messages) await runPushBroadcastJob(ctx.push, messag
98
98
 
99
99
  `SubscriptionStore` implementations: `memorySubscriptionStore()` (non-durable default, tests/dev) and `d1SubscriptionStore(db)` (durable, edge-safe, lazy table creation). Lifecycle: register (upsert), list/filter (by kind or user), status marking, and automatic prune of gone subscriptions on send/broadcast.
100
100
 
101
+ ## Security
102
+
103
+ `ctx.push.register(...)` and the browser `subscribeToPush` helper both accept
104
+ client-supplied data, so the facade enforces two boundaries:
105
+
106
+ - **Endpoint validation (anti-SSRF).** Every later `send`/`broadcast` POSTs to a
107
+ subscription's stored Web Push `endpoint`, so a hostile `endpoint` would turn the
108
+ worker into an SSRF / amplification primitive. `register()` validates the endpoint
109
+ **at storage time** (the durable boundary): it must be an absolute `https:` URL
110
+ with a non-private / non-loopback / non-link-local / non-CGNAT host. To hard-pin
111
+ the boundary to the push services you actually use, set `allowedPushOrigins` on
112
+ `defineNotify` — when present, an endpoint's origin must match one of the listed
113
+ origins **exactly** (no wildcards), which also closes DNS rebinding:
114
+
115
+ ```ts
116
+ export default defineNotify({
117
+ webPush: (env) => webPushFromEnv(env),
118
+ allowedPushOrigins: ["https://fcm.googleapis.com", "https://updates.push.services.mozilla.com"],
119
+ store: (env) => d1SubscriptionStore(env.DB),
120
+ });
121
+ ```
122
+
123
+ - **No secrets on the app facade.** `ctx.push.list()`
124
+ returns the registered devices with the delivery **secrets stripped** — the Web
125
+ Push `keys` (`auth`/`p256dh`) and the FCM `token`, which together with the
126
+ endpoint are enough to deliver arbitrary push to a device. The raw rows are
127
+ reachable only through the internal `SubscriptionStore` (which handlers never
128
+ hold); the broadcast path uses the store directly.
129
+
101
130
  ## Delivery observability
102
131
 
103
132
  Every send is counted onto `ctx.metrics` and failures onto `ctx.log` for you — codegen threads the request's logger/metrics into `ctx.notify` (`createNotify(notifyConfig, env, { log, metrics })`), so there is nothing to wire. Two low-cardinality metric series feed the durable metric history + trend charts:
package/dist/index.d.mts CHANGED
@@ -75,8 +75,58 @@ type RegisterInput = {
75
75
  };
76
76
  /** Filter narrowing which stored subscriptions a `list`/`broadcast` targets. */
77
77
  interface SubscriptionFilter {
78
+ /**
79
+ * Keyset pagination cursor: return only rows with `id` strictly GREATER
80
+ * than this value, ordered ascending by `id`. `id` is a stable,
81
+ * content-derived hash (see `webPushId`/`fcmId`), so ordering by it is
82
+ * immune to concurrent inserts/deletes elsewhere in the table — a page
83
+ * already walked never re-delivers or skips a row when another device
84
+ * registers mid-broadcast (the reviewer-flagged "stable under concurrent
85
+ * registers" property). `broadcastPage`/`broadcast` set this internally to
86
+ * walk pages; a direct `list()` caller may also page through results with
87
+ * it.
88
+ *
89
+ * OPTIONAL for a reason: `SubscriptionStore` is implementable outside this
90
+ * package. An external store that does not support cursoring may ignore
91
+ * `after` entirely and keep returning its (from-the-top) unpaged result —
92
+ * `broadcastPage` defensively re-filters whatever the store returns down
93
+ * to `id > after` itself, so a non-cursoring store can never cause a
94
+ * double-send or an infinite page-walk (each page's result only ever
95
+ * contains ids the previous page didn't already deliver), but it also
96
+ * cannot deliver the FULL matched audience beyond whatever the store's own
97
+ * (unpaged) response window happens to contain — implement `after`
98
+ * (ordered ascending by `id`, exclusive) to get real, complete pagination
99
+ * over a large audience.
100
+ */
101
+ after?: string;
78
102
  /** Restrict to a delivery kind. */
79
103
  kind?: SubscriptionKind;
104
+ /**
105
+ * Cap the number of rows returned (a `LIMIT`). Applied server-side by the
106
+ * store, so a large audience never materializes wholesale in the isolate.
107
+ * A non-positive/absent value means "no cap"; a fractional value is truncated.
108
+ *
109
+ * For `list`/admin reads this bounds the returned page as before. For
110
+ * `broadcast`, this is now an OVERALL cap on the total number of
111
+ * subscriptions reached across every internally-walked page (still
112
+ * deliberately left unset by default — it must reach every matched
113
+ * device); the PER-PAGE batch size is a separate, independent knob (see
114
+ * `CreateNotifyOptions`'s `broadcastPageSize`, default 250) so a caller
115
+ * that sets `limit` to bound the audience doesn't also have to reason
116
+ * about page sizing.
117
+ *
118
+ * The non-positive sentinel means something different at each layer: at
119
+ * the STORE layer (`list`, and the `d1-store`/`memory-store` fetch-size
120
+ * hint) a non-positive `limit` means "no cap" — fetch everything. At the
121
+ * `broadcast`/`broadcastPage` layer, where `limit` is an AUDIENCE cap, a
122
+ * non-positive value instead means "no deliveries" — `broadcast({ limit: 0
123
+ * })` reaches nobody, not everybody. This asymmetry is deliberate: the two
124
+ * layers answer different questions ("how many rows to fetch" vs. "how
125
+ * many recipients to reach"), and unifying them would either break `list`
126
+ * callers relying on "no cap" or reintroduce the over-delivery this
127
+ * distinction fixes (see `broadcastPage`'s doc comment).
128
+ */
129
+ limit?: number;
80
130
  /** Restrict to a single owning user. */
81
131
  userId?: string | null;
82
132
  }
@@ -90,7 +140,13 @@ interface SubscriptionStore {
90
140
  delete: (id: string) => Promise<void>;
91
141
  /** Read a subscription by id, or `undefined`. */
92
142
  get: (id: string) => Promise<StoredSubscription | undefined>;
93
- /** List subscriptions, optionally filtered. */
143
+ /**
144
+ * List subscriptions, optionally filtered. When `filter.after` is set,
145
+ * results are keyset-paginated: only rows with `id` strictly greater than
146
+ * `filter.after` are returned, ordered ascending by `id`. Implementing
147
+ * `after` is OPTIONAL (see {@link SubscriptionFilter.after}) — a store
148
+ * that ignores it may keep returning its unpaged result.
149
+ */
94
150
  list: (filter?: SubscriptionFilter) => Promise<StoredSubscription[]>;
95
151
  /** Record the latest delivery outcome for a subscription (best-effort). */
96
152
  markStatus: (id: string, status: SubscriptionStatus, error?: string) => Promise<void>;
@@ -119,6 +175,18 @@ interface BroadcastResult {
119
175
  /** Total subscriptions attempted. */
120
176
  total: number;
121
177
  }
178
+ /**
179
+ * Result of `broadcastPage` — one bounded page of a fan-out, plus the cursor
180
+ * to fetch the next page. `nextCursor` is `undefined` when this was the last
181
+ * page (or the store doesn't support cursoring — see
182
+ * {@link SubscriptionFilter.after}'s documented unpaged fallback).
183
+ */
184
+ interface BroadcastPageResult {
185
+ /** Cursor for the next page (pass as `filter.after`), or `undefined` when done. */
186
+ nextCursor?: string;
187
+ /** The delivery outcome for just this page. */
188
+ result: BroadcastResult;
189
+ }
122
190
  /**
123
191
  * The compact, stable delivery-status vocabulary emitted on notify observability
124
192
  * signals — the `status` dimension on the `notify.send` metric and the failure
@@ -173,10 +241,36 @@ interface LunoraPush {
173
241
  * Reuses the engine's retry/circuit-breaker middleware; prunes subscriptions
174
242
  * the push service reports as gone (HTTP 404/410, FCM `UNREGISTERED`). The `to`
175
243
  * target is derived from each subscription, so it is omitted from the payload.
244
+ *
245
+ * Internally walks the audience in bounded pages (via {@link LunoraPush.broadcastPage},
246
+ * keyset-paginated on the subscription `id`) so a huge audience is never
247
+ * materialized wholesale in the isolate — see `CreateNotifyOptions`'s
248
+ * `broadcastPageSize`. This call still processes the WHOLE matched
249
+ * audience in one request/queue message; use {@link LunoraPush.broadcastPage}
250
+ * directly (as `runPushBroadcastJob` does) to bound a single queue message
251
+ * to one page.
176
252
  */
177
253
  broadcast: (payload: PushContent, filter?: SubscriptionFilter) => Promise<BroadcastResult>;
178
- /** List stored subscriptions (optionally filtered). */
179
- list: (filter?: SubscriptionFilter) => Promise<StoredSubscription[]>;
254
+ /**
255
+ * Fan-out a push to ONE bounded page of stored subscriptions matching
256
+ * `filter` (page size: `CreateNotifyOptions`'s `broadcastPageSize`, default
257
+ * 250, capped by `filter.limit` when set). Same delivery semantics as
258
+ * {@link LunoraPush.broadcast} (retry/circuit-breaker, gone-pruning) but
259
+ * scoped to a single page; returns the page's own {@link BroadcastResult}
260
+ * plus a `nextCursor` to fetch the next page (`undefined` when done).
261
+ * Backs `runPushBroadcastJob` so one queue message does bounded work
262
+ * regardless of audience size — most app code should call
263
+ * {@link LunoraPush.broadcast} instead.
264
+ */
265
+ broadcastPage: (payload: PushContent, filter?: SubscriptionFilter) => Promise<BroadcastPageResult>;
266
+ /**
267
+ * List stored subscriptions (optionally filtered), with the delivery
268
+ * **secrets** stripped — the Web Push `keys` (RFC 8291 `auth`/`p256dh`) and the
269
+ * FCM `token`. Those, plus the endpoint, are enough to deliver arbitrary push to
270
+ * a device, so they never cross the app-facing facade; the raw rows are
271
+ * reachable only through the internal `SubscriptionStore`.
272
+ */
273
+ list: (filter?: SubscriptionFilter) => Promise<PushSubscriptionDevice[]>;
180
274
  /** Register (upsert) a device subscription and return the stored record. */
181
275
  register: (input: RegisterInput) => Promise<StoredSubscription>;
182
276
  /** Send a push to a single stored subscription (by id or record); `to` is derived from it. */
@@ -213,6 +307,22 @@ type WebPushConfigFactory = (env: NotifyEnv) => WebPushConfig | undefined;
213
307
  type FcmConfigFactory = (env: NotifyEnv) => FcmConfig | undefined;
214
308
  /** Options accepted by `defineNotify`. */
215
309
  interface NotifyConfig {
310
+ /**
311
+ * Exact origins (`https://host[:port]`) a client-supplied Web Push `endpoint`
312
+ * may register from. When set (non-empty), `register()` requires the endpoint's
313
+ * origin to be one of these — the strongest anti-SSRF posture, and the way to
314
+ * close DNS rebinding for a facade that accepts client-controlled endpoints.
315
+ *
316
+ * When unset, the default posture applies: an endpoint must be `https:` with a
317
+ * host a STRING classifier does not flag as private / loopback / link-local.
318
+ * That classifier does NOT resolve DNS, so a public hostname resolving to a
319
+ * private/internal IP (e.g. `https://127.0.0.1.nip.io/…`) is NOT blocked by it
320
+ * — `register()` also emits a one-shot dev warning in this case. Set this to the
321
+ * push services your app actually uses (e.g. `["https://fcm.googleapis.com",
322
+ * "https://updates.push.services.mozilla.com"]` — exact origins only, no
323
+ * wildcards) to hard-pin the boundary and close DNS rebinding.
324
+ */
325
+ allowedPushOrigins?: string[];
216
326
  /**
217
327
  * Optional chat provider factory (Slack/Discord/Teams/Telegram). Wire with a
218
328
  * provider from `@visulima/notification/providers/*`. Edge-safe (fetch-based).
@@ -303,6 +413,16 @@ declare const defineNotify: (config: NotifyConfig) => NotifyDefinition;
303
413
  declare const isNotifyDefinition: (value: unknown) => value is NotifyDefinition;
304
414
  /** Options for {@link createNotify}. */
305
415
  interface CreateNotifyOptions {
416
+ /**
417
+ * Page size for `push.broadcast`'s internal keyset pagination over the
418
+ * subscription store (default {@link DEFAULT_BROADCAST_PAGE_SIZE}, 250).
419
+ * Each page is fetched, delivered, and counted independently before the
420
+ * next page's store round trip, so a huge audience is never materialized
421
+ * wholesale in the isolate. Also the per-message bound `push.broadcastPage`
422
+ * (and so `runPushBroadcastJob`) uses. A test/tuning seam — most apps never
423
+ * need to set this.
424
+ */
425
+ broadcastPageSize?: number;
306
426
  /** Max concurrent sends during a `broadcast` (default 10). */
307
427
  concurrency?: number;
308
428
  /**
@@ -347,6 +467,11 @@ declare const createNotify: (definition: NotifyDefinition, env: NotifyEnv, optio
347
467
  };
348
468
  /** Options for {@link routingPushProvider}. */
349
469
  interface RoutingPushOptions {
470
+ /**
471
+ * The definition's exact-origin allowlist, when configured. Its presence
472
+ * disables the send-time rebinding re-check (see {@link assertPushTargetResolvable}).
473
+ */
474
+ allowedPushOrigins?: string[];
350
475
  fcm?: Provider<unknown, PushPayload>;
351
476
  webPush?: Provider<unknown, PushPayload>;
352
477
  }
@@ -360,6 +485,8 @@ interface RoutingPushOptions {
360
485
  declare const routingPushProvider: (options: RoutingPushOptions) => Provider<unknown, PushPayload>;
361
486
  /** A resolved, ready-to-wire set of channel configs (edge-safe channels only). */
362
487
  interface ResolvedProviders {
488
+ /** The definition's `allowedPushOrigins`, threaded to the push router's send-time SSRF guard. */
489
+ allowedPushOrigins?: string[];
363
490
  chat?: Provider;
364
491
  fcm?: FcmConfig;
365
492
  inApp?: Provider;
@@ -377,23 +504,26 @@ declare const buildEngine: (resolved: ResolvedProviders) => Notification;
377
504
  * A broadcast job body — the JSON-serialisable payload enqueued for off-request
378
505
  * fan-out. Shaped to travel through a `@lunora/queue` producer/consumer without
379
506
  * `@lunora/notify` depending on `@lunora/queue` (the seam stays structural).
507
+ * `filter.after`, when set, resumes a broadcast partway through (see
508
+ * {@link runPushBroadcastJob}'s continuation semantics).
380
509
  */
381
510
  interface PushBroadcastJob {
382
- /** Subscription filter (which devices/users to target). */
511
+ /** Subscription filter (which devices/users to target; `filter.after` resumes a paged broadcast). */
383
512
  filter?: SubscriptionFilter;
384
513
  /** The push payload to deliver (the `to` target is derived per subscription). */
385
514
  payload: PushContent;
386
515
  /** Discriminator so a shared queue can multiplex message kinds. */
387
516
  type: "lunora.push.broadcast";
388
517
  }
389
- /** The structural slice of a `@lunora/queue` producer (`ctx.queues.&lt;name>`) used here. */
518
+ /** The structural slice of a `@lunora/queue` producer (`ctx.queues.<name>`) used here. */
390
519
  interface QueueProducerLike {
391
520
  send: (body: PushBroadcastJob) => Promise<void>;
392
521
  }
393
522
  /**
394
523
  * Enqueue a fan-out broadcast for background delivery through a `@lunora/queue`
395
524
  * queue instead of blocking the request. Pair with {@link runPushBroadcastJob} in
396
- * the queue consumer.
525
+ * the queue consumer — see its doc comment for how a large audience continues
526
+ * across MULTIPLE messages (one bounded page per message), not one.
397
527
  *
398
528
  * ```ts
399
529
  * // in a mutation/action:
@@ -401,17 +531,59 @@ interface QueueProducerLike {
401
531
  *
402
532
  * // in lunora/queues.ts consumer:
403
533
  * export const push = defineQueue({ async handler(batch, ctx) {
404
- * for (const message of batch.messages) await runPushBroadcastJob(ctx.push, message.body);
534
+ * for (const message of batch.messages) {
535
+ * const { nextCursor } = await runPushBroadcastJob(ctx.push, message.body);
536
+ *
537
+ * if (nextCursor !== undefined) {
538
+ * // More pages remain — enqueue the continuation. Each message still
539
+ * // does only ONE bounded page of work.
540
+ * await enqueuePushBroadcast(ctx.queues.push, {
541
+ * payload: message.body.payload,
542
+ * filter: { ...message.body.filter, after: nextCursor },
543
+ * });
544
+ * }
545
+ * }
405
546
  * }});
406
547
  * ```
407
548
  */
408
549
  declare const enqueuePushBroadcast: (queue: QueueProducerLike, job: Omit<PushBroadcastJob, "type">) => Promise<void>;
409
550
  /**
410
- * Run an enqueued broadcast job on the consumer side, delivering through the push
411
- * facade (which reuses the engine's retry + circuit-breaker middleware and prunes
412
- * gone subscriptions).
551
+ * Run ONE bounded page of an enqueued broadcast job on the consumer side,
552
+ * delivering through the push facade's {@link LunoraPush.broadcastPage} (which
553
+ * reuses the engine's retry + circuit-breaker middleware and prunes gone
554
+ * subscriptions).
555
+ *
556
+ * RETRY / CONTINUATION SEMANTICS (rewritten for plan 222 / NOTIFY-01 — a
557
+ * broadcast job used to process the WHOLE audience in one message, which could
558
+ * exceed Worker CPU/wall limits for a large audience and made a retry re-run
559
+ * everything):
560
+ *
561
+ * - A job now processes exactly ONE bounded page (see `CreateNotifyOptions`'s
562
+ * page-size option, default 250, or `job.filter.limit` when smaller),
563
+ * keyset-paginated on the subscription `id` (see `SubscriptionFilter.after`)
564
+ * — so per-message work is bounded regardless of total audience size.
565
+ * - Retry is still gated on `result.failed` — the count of TRANSIENT delivery
566
+ * errors (a provider 5xx / network fault worth another attempt). When at
567
+ * least one recipient in THIS PAGE `failed`, the job is RE-THROWN so the
568
+ * queue does NOT ack it and its normal retry/backoff (and, on exhaustion,
569
+ * dead-letter) applies — to just this page, not the whole broadcast.
570
+ * - A page with zero `failed` resolves and is acked — this includes the
571
+ * all-`pruned` case (every device on the page had unsubscribed:
572
+ * `sent:0`, `failed:0`, `pruned:N`), which is a SUCCESSFUL prune, not a
573
+ * failure, so throwing on it would spuriously retry and pressure the DLQ;
574
+ * and the empty-page case (zero `total`), which has nothing to retry.
575
+ * - The returned `nextCursor` is set when more pages remain. `@lunora/notify`
576
+ * does NOT enqueue the continuation itself — it has no `@lunora/queue`
577
+ * dependency (the seam stays structural) and no reference to the producer
578
+ * that enqueued this message — so the CALLER (the `lunora/queues.ts`
579
+ * consumer) is responsible for re-enqueueing with `filter.after: nextCursor`
580
+ * when present. See the consumer example on {@link enqueuePushBroadcast}.
581
+ * - A retry of a page redelivers only that page's already-delivered recipients
582
+ * on a transient partial failure (a page is not individually idempotent) —
583
+ * the accepted cost of getting the transiently failed ones redelivered, now
584
+ * scoped to one page instead of the whole broadcast.
413
585
  */
414
- declare const runPushBroadcastJob: (push: LunoraPush, job: PushBroadcastJob) => Promise<unknown>;
586
+ declare const runPushBroadcastJob: (push: LunoraPush, job: PushBroadcastJob) => Promise<BroadcastPageResult>;
415
587
  /**
416
588
  * The minimal structural slice of Cloudflare's `D1Database` this store uses. A
417
589
  * structural type (rather than importing `@cloudflare/workers-types`) keeps the
@@ -438,6 +610,15 @@ interface D1StoreOptions {
438
610
  * backing table is created lazily on first use (`CREATE TABLE IF NOT EXISTS`), so
439
611
  * no migration step is required for the subscription table itself.
440
612
  *
613
+ * ID SCHEME / LAZY MIGRATION: `id` (the `PRIMARY KEY`, upserted via `ON
614
+ * CONFLICT(id) DO UPDATE`) is a version-prefixed digest of the endpoint/token —
615
+ * currently `wp2_`/`fcm2_` (64-bit FNV-1a; see `normalize.ts`). No table migration
616
+ * runs when the id scheme is revised: a returning device re-registers under its new
617
+ * id and upserts a fresh row, while its old-prefix row (`wp_`/`fcm_`) ages out via
618
+ * the normal gone-pruning on the next failed send. So a table can transiently hold
619
+ * both an old- and new-prefix row for one device — expected, self-healing, and the
620
+ * reason a prefix must NEVER be reused for a different scheme.
621
+ *
441
622
  * ```ts
442
623
  * export default defineNotify({
443
624
  * webPush: (env) => webPushFromEnv(env),
@@ -453,16 +634,43 @@ declare const d1SubscriptionStore: (database: D1Like, options?: D1StoreOptions)
453
634
  * (or another backing store) for production so subscriptions survive restarts.
454
635
  */
455
636
  declare const memorySubscriptionStore: () => SubscriptionStore;
456
- /** Stable store id for a web-push endpoint. */
637
+ /**
638
+ * Stable store id for a web-push endpoint.
639
+ *
640
+ * The `wp2_` prefix is a version tag (see also {@link fcmId}'s `fcm2_`): it marks
641
+ * the 64-bit-id revision so the pre-existing 32-bit `wp_` rows stay readable and a
642
+ * returning device simply re-registers under the new id, its stale `wp_` row aging
643
+ * out via normal gone-pruning. A future third revision must mint `wp3_` and repeat
644
+ * the lazy migration — NEVER reuse a prefix.
645
+ */
457
646
  declare const webPushId: (endpoint: string) => string;
458
- /** Stable store id for an FCM device token. */
647
+ /** Stable store id for an FCM device token. See {@link webPushId} for the `_2` version-prefix contract. */
459
648
  declare const fcmId: (token: string) => string;
649
+ /** Options threaded into {@link normalizeRegisterInput} from the notify definition. */
650
+ interface NormalizeOptions {
651
+ /**
652
+ * Exact origins (`https://host[:port]`) a web-push endpoint may register from.
653
+ * When set (non-empty), the endpoint's origin must be one of these — the
654
+ * strongest anti-SSRF posture, and the ONLY way to close DNS rebinding for a
655
+ * facade that accepts client-controlled endpoints.
656
+ *
657
+ * When unset, the default posture applies: `https:` scheme + a host the
658
+ * {@link assertPushEndpoint} STRING classifier does not flag as
659
+ * private/loopback, plus a resolved-address re-check at send time. Setting
660
+ * this allowlist replaces both with an exact-origin match — the hard
661
+ * guarantee, and the only one that also covers an internal push service you
662
+ * deliberately want to reach.
663
+ */
664
+ allowedPushOrigins?: string[];
665
+ }
460
666
  /**
461
667
  * Normalise a `register(...)` input into a {@link StoredSubscription}. Validates
462
668
  * the shape (a web-push subscription needs `endpoint` + `keys.{p256dh,auth}`; an
463
- * FCM entry needs a non-empty `token`) and stamps `createdAt`/`lastSeenAt`.
669
+ * FCM entry needs a non-empty `token`), enforces the anti-SSRF endpoint boundary
670
+ * (see {@link assertPushEndpoint}), validates `metadata` (see
671
+ * {@link validateMetadata}), and stamps `createdAt`/`lastSeenAt`.
464
672
  */
465
- declare const normalizeRegisterInput: (input: RegisterInput, now?: number) => StoredSubscription;
673
+ declare const normalizeRegisterInput: (input: RegisterInput, now?: number, options?: NormalizeOptions) => StoredSubscription;
466
674
  /**
467
675
  * The provider `to` target for a stored subscription: the W3C Push subscription
468
676
  * (JSON-stringified) for web-push, or the raw device token for FCM. Matches the
@@ -481,4 +689,80 @@ declare const targetOf: (subscription: StoredSubscription) => string;
481
689
  * (a cert/session expiry) can never permanently drop a valid subscription.
482
690
  */
483
691
  declare const isGoneError: (message: string | undefined) => boolean;
484
- export { type BroadcastOutcome, type BroadcastResult, type CreateNotifyOptions, type D1Like, type D1PreparedLike, type D1StoreOptions, FCM_ENV_KEYS, type FcmConfigFactory, type LunoraNotify, type LunoraPush, type NotifyConfig, type NotifyDefinition, type NotifyDeliveryStatus, type NotifyEnv, type NotifyLogger, type NotifyMetrics, type NotifySkipReason, type PushBroadcastJob, type PushSubscriptionDevice, type PushSubscriptionsResult, type QueueProducerLike, type RegisterInput, type ResolvedProviders, type RoutingPushOptions, type StoredSubscription, type SubscriptionFilter, type SubscriptionKind, type SubscriptionStatus, type SubscriptionStore, WEB_PUSH_ENV_KEYS, type WebPushConfigFactory, buildEngine, createNotify, d1SubscriptionStore, defineNotify, enqueuePushBroadcast, fcmFromEnv, fcmId, isGoneError, isNotifyDefinition, memorySubscriptionStore, normalizeRegisterInput, routingPushProvider, runPushBroadcastJob, targetOf, webPushFromEnv, webPushId };
692
+ export { type BroadcastOutcome, type BroadcastResult, type CreateNotifyOptions, type D1Like, type D1PreparedLike, type D1StoreOptions,
693
+ /**
694
+ * `@lunora/notify`
695
+ *
696
+ * Multi-channel notifications for Lunora, wrapping the `@visulima/notification`
697
+ * engine. `defineNotify` in `lunora/notify.ts` configures the edge-safe channels
698
+ * (Web Push + FCM, plus chat / in-app inbox / webhook); codegen wires `ctx.notify`
699
+ * and its `ctx.push` alias onto every handler ctx from it (mirroring `defineFlags`
700
+ * → `ctx.flags`).
701
+ *
702
+ * Edge-safety: Web Push (VAPID + RFC 8291) and FCM (HTTP v1) run on `fetch` + Web
703
+ * Crypto under workerd. APNs (`node:http2`) and SMS / Node-only queue adapters are
704
+ * deliberately **not** on the edge facade — route heavy fan-out through
705
+ * `@lunora/queue` (`enqueuePushBroadcast` / `runPushBroadcastJob`).
706
+ *
707
+ * - `@lunora/notify` — `defineNotify`, `createNotify`, config resolvers, subscription stores and types.
708
+ * - `@lunora/notify/web` — the browser `subscribeToPush` service-worker helper.
709
+ * @packageDocumentation
710
+ */
711
+ FCM_ENV_KEYS, type FcmConfigFactory, type LunoraNotify, type LunoraPush, type NotifyConfig, type NotifyDefinition, type NotifyDeliveryStatus, type NotifyEnv, type NotifyLogger, type NotifyMetrics, type NotifySkipReason, type PushBroadcastJob, type PushSubscriptionDevice, type PushSubscriptionsResult, type QueueProducerLike, type RegisterInput, type ResolvedProviders, type RoutingPushOptions, type StoredSubscription, type SubscriptionFilter, type SubscriptionKind, type SubscriptionStatus, type SubscriptionStore,
712
+ /**
713
+ * `@lunora/notify`
714
+ *
715
+ * Multi-channel notifications for Lunora, wrapping the `@visulima/notification`
716
+ * engine. `defineNotify` in `lunora/notify.ts` configures the edge-safe channels
717
+ * (Web Push + FCM, plus chat / in-app inbox / webhook); codegen wires `ctx.notify`
718
+ * and its `ctx.push` alias onto every handler ctx from it (mirroring `defineFlags`
719
+ * → `ctx.flags`).
720
+ *
721
+ * Edge-safety: Web Push (VAPID + RFC 8291) and FCM (HTTP v1) run on `fetch` + Web
722
+ * Crypto under workerd. APNs (`node:http2`) and SMS / Node-only queue adapters are
723
+ * deliberately **not** on the edge facade — route heavy fan-out through
724
+ * `@lunora/queue` (`enqueuePushBroadcast` / `runPushBroadcastJob`).
725
+ *
726
+ * - `@lunora/notify` — `defineNotify`, `createNotify`, config resolvers, subscription stores and types.
727
+ * - `@lunora/notify/web` — the browser `subscribeToPush` service-worker helper.
728
+ * @packageDocumentation
729
+ */
730
+ WEB_PUSH_ENV_KEYS, type WebPushConfigFactory, buildEngine, createNotify, d1SubscriptionStore, defineNotify, enqueuePushBroadcast,
731
+ /**
732
+ * `@lunora/notify`
733
+ *
734
+ * Multi-channel notifications for Lunora, wrapping the `@visulima/notification`
735
+ * engine. `defineNotify` in `lunora/notify.ts` configures the edge-safe channels
736
+ * (Web Push + FCM, plus chat / in-app inbox / webhook); codegen wires `ctx.notify`
737
+ * and its `ctx.push` alias onto every handler ctx from it (mirroring `defineFlags`
738
+ * → `ctx.flags`).
739
+ *
740
+ * Edge-safety: Web Push (VAPID + RFC 8291) and FCM (HTTP v1) run on `fetch` + Web
741
+ * Crypto under workerd. APNs (`node:http2`) and SMS / Node-only queue adapters are
742
+ * deliberately **not** on the edge facade — route heavy fan-out through
743
+ * `@lunora/queue` (`enqueuePushBroadcast` / `runPushBroadcastJob`).
744
+ *
745
+ * - `@lunora/notify` — `defineNotify`, `createNotify`, config resolvers, subscription stores and types.
746
+ * - `@lunora/notify/web` — the browser `subscribeToPush` service-worker helper.
747
+ * @packageDocumentation
748
+ */
749
+ fcmFromEnv, fcmId, isGoneError, isNotifyDefinition, memorySubscriptionStore, normalizeRegisterInput, routingPushProvider, runPushBroadcastJob, targetOf,
750
+ /**
751
+ * `@lunora/notify`
752
+ *
753
+ * Multi-channel notifications for Lunora, wrapping the `@visulima/notification`
754
+ * engine. `defineNotify` in `lunora/notify.ts` configures the edge-safe channels
755
+ * (Web Push + FCM, plus chat / in-app inbox / webhook); codegen wires `ctx.notify`
756
+ * and its `ctx.push` alias onto every handler ctx from it (mirroring `defineFlags`
757
+ * → `ctx.flags`).
758
+ *
759
+ * Edge-safety: Web Push (VAPID + RFC 8291) and FCM (HTTP v1) run on `fetch` + Web
760
+ * Crypto under workerd. APNs (`node:http2`) and SMS / Node-only queue adapters are
761
+ * deliberately **not** on the edge facade — route heavy fan-out through
762
+ * `@lunora/queue` (`enqueuePushBroadcast` / `runPushBroadcastJob`).
763
+ *
764
+ * - `@lunora/notify` — `defineNotify`, `createNotify`, config resolvers, subscription stores and types.
765
+ * - `@lunora/notify/web` — the browser `subscribeToPush` service-worker helper.
766
+ * @packageDocumentation
767
+ */
768
+ webPushFromEnv, webPushId };