A personal data server (pds) for ANProto https://anproto.com/
Try it at https://apds.anproto.com/
MIT
createBlobHandler exposes the local blob store over HTTP so any host
(a relay, a personal server, an agent) can serve blobs by their 44-character
ANProto hash without reimplementing routing, validation, or headers.
Runtime-agnostic (Deno, Node 18+, browsers, edge workers), no dependencies:
import { createBlobHandler } from './blobs.js'
import { apds } from './apds.js'
const serveBlob = createBlobHandler({ get: (hash) => apds.get(hash) })
// Deno:
Deno.serve(async (req) => (await serveBlob(req)) ?? new Response('not found', { status: 404 }))GET /blobs/<hash>→ 200 with the blob bytes, or 404 when unknown. Malformed hashes get 400.HEADandOPTIONSare supported.- The handler returns
nullfor non-blob paths so hosts can chain it with their other routes. - Responses carry
Access-Control-Allow-Origin: *and immutable cache headers (blobs are content-addressed). - Content type is sniffed from magic bytes (png/jpeg/gif/webp, else text/plain for printable data, else application/octet-stream).
handleBlobRequest(urlString, { get, basePath })offers the same logic for hosts not using Fetch API Request/Response objects;basePathdefaults to/blobsand is configurable.
This server exposes minimal Web Push subscription + notification plumbing:
GET /push/vapidPublicKeyreturns{ publicKey }(base64url) forpushManager.subscribe({ applicationServerKey }).POST /push/subscribestores a browser PushSubscription (JSON body).POST /push/testtriggers a test push to all stored subscriptions.
When a new ANProto message is added via WebSocket, the server sends a push with payload { type: "latest" } so the service worker can wake up and fetch /latest.
By default it sends { type: "anproto", sigs: ["...==", ...] } (batched + throttled), so the service worker can process specific messages and/or still fetch /latest as a fallback.
Notes:
- The server writes
subscriptions.jsonandvapid.jsonlocally. - Set
VAPID_SUBJECT(e.g.mailto:you@example.comorhttps://your.site) if you don’t want the default.