divine-name-sync is a Fastly Compute service that receives signed webhooks from divine-name-server and keeps a Fastly KV store of usernames in sync. That KV store is read by the edge for fast NIP-05 identity lookups, so a name change made in the name server shows up at the edge without a database round trip on every request.
- Single webhook endpoint (
POST /sync) that appliesupsertanddeletechanges to the KV store. - HMAC-SHA256 request authentication with a timing-safe signature comparison.
- Replay protection: requests whose timestamp is more than five minutes off are rejected.
- Failed syncs are logged to a separate KV store for later debugging instead of being silently dropped.
- Health and service-info endpoints for monitoring.
divine-name-server (CF Worker)
│
│ POST /sync (HMAC-signed)
▼
divine-name-sync (Fastly Compute) ← this service
│
│ verify signature, then upsert/delete
▼
divine-names KV store
│
│ read at the edge
▼
divine-web (Fastly Compute)
│
▼
/.well-known/nostr.json (NIP-05)
The name server is the source of truth; this service is a thin, stateless receiver. Running it on Fastly Compute puts the write next to the same divine-names KV store that divine-web reads from, so both sides of the sync live on one platform.
| Method | Path | Description |
|---|---|---|
POST |
/sync |
Receive a webhook from the name server |
GET |
/health |
Health check (returns OK) |
GET |
/ |
Service info as JSON |
Requests to /sync must include both headers:
X-Webhook-Signature— HMAC-SHA256 of the raw request body concatenated with the timestamp, base64-encoded.X-Webhook-Timestamp— Unix time in seconds.
Body:
{
"name": "alice",
"action": "upsert",
"pubkey": "abc123...",
"relays": ["wss://relay.example.com"],
"status": "active"
}actionisupsert(create or update) ordelete.pubkeyis required forupsert.nameis lowercased and trimmed before use; entries are stored under the keyuser:<name>.relaysdefaults to[]andstatusdefaults toactive.
- The name server signs
body + timestampwith the shared secret. - This service recomputes the HMAC and compares it with a timing-safe check.
- Timestamps outside a five-minute window (in either direction) are rejected before the signature is checked.
Missing headers, stale timestamps, and bad signatures all return 401; malformed payloads return 400.
Requires the Fastly CLI and Node.js 22.20+ (22.x), 24.12+ (24.x) or 25+. On older Node versions the install only prints a warning, but every build then fails with Cannot find native binding: a compression library used by the build ships native code only for those versions.
Clone into a path with no spaces. As of @fastly/js-compute 4.4.0, the ahead-of-time build passes its cache path to a shell unquoted, so a space anywhere in the checkout path makes npm run build, npm run dev and npm run deploy fail with Weval initialization failure.
# Install dependencies. --ignore-scripts skips a wasmtime download that
# the default (ahead-of-time) build never uses.
npm install --ignore-scripts
# Serve locally through Fastly Compute
npm run dev
# Build the Wasm package
npm run build
# Publish to Fastly
npm run deployWith the local server running, check the endpoints:
# Health check
curl http://localhost:7676/health
# Sync request (signature check will fail without a matching local secret)
curl -X POST http://localhost:7676/sync \
-H "Content-Type: application/json" \
-H "X-Webhook-Signature: test" \
-H "X-Webhook-Timestamp: $(date +%s)" \
-d '{"name":"test","action":"upsert","pubkey":"abc123"}'The local server reads sample KV and secret data from the paths configured in fastly.toml (test-data/names.json, test-data/failures.json, and secrets.local.json). secrets.local.json holds the local webhook_secret and is gitignored — create it yourself to exercise a passing signature check.
To check the built package end to end, as CI does after each build, run node --test test/compute.smoke.mjs after npm run build. It needs Viceroy on your PATH, or its path in a VICEROY environment variable. It serves bin/main.wasm from a temporary copy of the local stores with a throwaway secret, so it never touches your secrets.local.json.
The service is configured through Fastly resources rather than environment variables. Names are defined in src/index.js and provisioned via the [setup] block in fastly.toml:
| Resource | Name | Purpose |
|---|---|---|
| Secret store | divine-name-sync-secrets |
Holds webhook_secret, the shared HMAC key |
| KV store | divine-names |
Username-to-pubkey mappings, shared with divine-web |
| KV store | sync-failures |
Log of failed sync attempts for debugging |
For checked main-branch deployment, prerequisites, release evidence and rollback, see the deployment guide. Automation stays disabled until a maintainer verifies the existing production resources and protections.
The following is the original manual provisioning flow, not a CD setup step:
- Create the Fastly Compute service.
- Create the
divine-name-sync-secretssecret store and addwebhook_secret(must match the name server's shared secret). - Link the existing
divine-namesKV store. - Create the
sync-failuresKV store. - Publish with
npm run deploy. - Point the service's hostname at the URL the name server sends webhooks to.
MIT
Part of Divine — your playground for human creativity · Brand guidelines