- drop the sm-user-plugin replace line; require sm-user-plugin v0.1.13 and summercms v0.6.0 - README Dependencies lists the required versions
Herald
A compiled Web Push plugin for SummerCMS: store subscriptions, send through fetchguard PublicOnly, prune gone endpoints.
import _ "git.golem15.com/golem15/sm-herald-plugin"
Name: Herald on the shore; the bell carries after the tide.
Module git.golem15.com/golem15/sm-herald-plugin, package herald, plugin ID golem15.herald, requires nothing. Display name Herald / Herald.
Overview
The plugin ports the WinterCMS Golem15.Herald plugin. classes.SubscriptionService upserts browser Push subscriptions on (user_id, endpoint). classes.Sender.SendEvent and classes.Sender.SendUnconditional enqueue jobs.SendArgs on the caller transaction so a rolled-back write pushes nothing. The worker sends with github.com/SherClockHolmes/webpush-go through a fetchguard.Client in PublicOnlyMode and prunes HTTP 404 and 410. SendEvent consults contracts.PresenceGate; SendUnconditional does not.
Table (PHP names, one idempotent baseline migration 202610180001_create_golem15_herald_baseline, every statement IF NOT EXISTS):
golem15_herald_push_subscriptions: per-user endpoint and JSON keys{p256dh, auth}(models.Subscription), unique(user_id, endpoint)(herald_push_user_endpoint_unique),user_idFK cascade.
Unlike the PHP plugin, this port ships a generic JSON API (herald.APIPrefix /_herald/api/v1). Hosts consume those routes instead of writing their own controllers (D-06). Routes sit behind jwt.auth and the named bucket herald-api (120/min). The actor id always comes from the token, never from the request body. A blog or acme host enables push by mounting the plugin, setting VAPID keys, and installing a PresenceGate.
Requires() is empty. Herald stores user ids only and does not import user models.
Features
- Subscribe / patch / unsubscribe.
POST/PATCH/DELETE /push/subscriptionfor the JWT actor. Non-HTTPS and non-public hosts are rejected (D-10). There is no EndpointGuard type. - SendEvent. Enqueues
golem15.herald.sendon the caller tx (D-11). The worker consultsPresenceGate.ShouldSendand skips when false. - SendUnconditional. Same enqueue; the worker does not consult PresenceGate.
- 410/404 prune. A gone push-service response deletes the row.
- PresenceGate. Default
classes.DenyAll(ShouldSendalways false).Plugin.SetPresenceGate(nil)becomes DenyAll. Boot Warns while DenyAll remains. - HeraldProfile. Default
classes.NeutralHeraldProfile(app name only). No Warn for the profile. - VAPID config. Keys
golem15.herald.vapid.{subject,public_key,private_key}with default subjectmailto:admin@example.com. PHP env namesVAPID_SUBJECT/VAPID_PUBLIC_KEY/VAPID_PRIVATE_KEYoverlay empty values at Boot. Boot Warns when keys are missing; never auto-generates.summer herald:vapid-generateprints env lines.GET /push/vapid-public-keyreturns the public key only.
Usage
Look the sender up after Boot:
send, _ := app.Lookup[*classes.Sender]()
err := send.SendUnconditional(ctx, tx, userID, payload, classes.SendOptions{})
err = send.SendEvent(ctx, tx, userID, "message", map[string]any{}, classes.EventOptions{EventID: "evt-1"})
Install a PresenceGate from an application plugin after looking the plugin up (Herald publishes it at Boot):
func (p *Plugin) Boot(app *backpack.App) error {
h, _ := app.Lookup[*herald.Plugin]()
h.SetPresenceGate(p.gate) // contracts.PresenceGate
return nil
}
Subscribe through the generic API as the JWT actor:
POST /_herald/api/v1/push/subscription
{"subscription":{"endpoint":"https://push.example.com/…","keys":{"p256dh":"…","auth":"…"}}}
A blog or acme host that only stores subscriptions still uses SendUnconditional for deliveries that must always go out. Gated sends stay silent until the host installs a PresenceGate.
The generic JSON API is herald.APIPrefix (/_herald/api/v1). Published paths:
POST /push/subscriptionPATCH /push/subscription({oldEndpoint, subscription})DELETE /push/subscription({endpoint})GET /push/vapid-public-key({"publicKey"})
API reference
| Identifier | Description |
|---|---|
herald.PluginID |
golem15.herald |
herald.APIPrefix |
/_herald/api/v1 |
herald.APIBucket |
Throttle bucket herald-api (120/min) |
herald.ConfigVAPIDSubject |
golem15.herald.vapid.subject |
herald.ConfigVAPIDPublicKey |
golem15.herald.vapid.public_key |
herald.ConfigVAPIDPrivateKey |
golem15.herald.vapid.private_key |
models.Subscription |
Row of golem15_herald_push_subscriptions |
models.Keys |
JSON {p256dh, auth} |
classes.SubscriptionService |
Actor-scoped subscribe / patch / unsubscribe / prune |
classes.NewSubscriptionService |
Store over a *gorm.DB |
classes.ValidateEndpoint |
HTTPS + public-host check (D-10) |
classes.ErrUnsafeEndpoint |
Subscribe rejected a non-public URL |
classes.Sender |
Enqueue and deliver |
classes.NewSender |
Builds a sender over fetchguard PublicOnly |
classes.Sender.SendEvent |
Enqueue on caller tx; worker consults PresenceGate |
classes.Sender.SendUnconditional |
Enqueue on caller tx; worker skips PresenceGate |
classes.Sender.Deliver |
Worker: gated skip, send every row, prune 404/410 |
classes.SendOptions |
Optional TTL and urgency |
classes.EventOptions |
SendEvent build options; EventID required |
classes.DenyAll |
Default PresenceGate; ShouldSend always false |
classes.NeutralHeraldProfile |
Default HeraldProfile; app name only |
contracts.PresenceGate |
Host per-send seam |
contracts.HeraldProfile |
Host notification vocabulary |
herald.Plugin.SetPresenceGate |
Host setter; nil becomes DenyAll |
herald.Plugin.SetHeraldProfile |
Host setter; nil becomes Neutral |
console.VAPIDGenerateName |
herald:vapid-generate |
console.VAPIDGenerate |
Prints VAPID_PUBLIC_KEY= / VAPID_PRIVATE_KEY= |
jobs.SendArgs |
River args for golem15.herald.send |
jobs.Kind |
golem15.herald.send |
jobs.Queue |
push |
Configuration
| Key | Default | Notes |
|---|---|---|
golem15.herald.vapid.subject |
mailto:admin@example.com |
VAPID JWT sub; env VAPID_SUBJECT |
golem15.herald.vapid.public_key |
empty | env VAPID_PUBLIC_KEY |
golem15.herald.vapid.private_key |
empty | env VAPID_PRIVATE_KEY; never logged |
CLI commands
| Command | Meaning | Example |
|---|---|---|
herald:vapid-generate |
Print a fresh VAPID keypair as VAPID_PUBLIC_KEY= and VAPID_PRIVATE_KEY= lines. The private key is never logged. Never auto-generates keys at Boot. --json prints {"public_key": …, "private_key": …} instead; the keys print under -q too. |
bin/<app> herald:vapid-generate -q >> .env |
bin/<app> help herald:vapid-generate shows the long help and examples. The plugin logs through the component herald (log.components.herald in config/log.yaml).
Dependencies
github.com/SherClockHolmes/webpush-gov1.4.0 (VAPID + aes128gcm)- SummerCMS v0.6.0 or later (
git.golem15.com/golem15/summercms) modules: backpack, party, pact, lagoon, surf, bouncer, wire, conga, fetchguard, bonfire, diary git.golem15.com/golem15/sm-user-pluginv0.1.13 or later
go.mod requires tagged versions only; the one replace points the framework at a local checkout for development, and module consumers ignore it. The tracked go.work resolves sibling checkouts during development.
Testing
go vet ./...
go test -short ./...
go test -run '^(TestHTTPTracer|TestSendEventRollback)$' -v .
TestCommandsDocumented (in -short) logs, without failing, each command whose help lacks a description, long help, examples or an option description (bonfire.CheckDocs).
The proof host is golem15.user + golem15.herald + a test-only acme fixture. TestFixtureAbsentFromProduction keeps the fixture id and retired tokens out of production sources. TestSubscribeEndpoint runs under -short. TestHTTPTracer and TestSendEventRollback need Docker. Tests inject fetchguard.WithTransport.