Skip to content
evboguePublic

About

A personal data server for ANProto

Resources

Stars

5 stars

Watchers

2 watching

Forks

Repository files navigation

APDS

A personal data server (pds) for ANProto https://anproto.com/

Try it at https://apds.anproto.com/


MIT

Blob retrieval over HTTP (blobs.js)

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. HEAD and OPTIONS are supported.
  • The handler returns null for 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; basePath defaults to /blobs and is configurable.

Web Push (server)

This server exposes minimal Web Push subscription + notification plumbing:

  • GET /push/vapidPublicKey returns { publicKey } (base64url) for pushManager.subscribe({ applicationServerKey }).
  • POST /push/subscribe stores a browser PushSubscription (JSON body).
  • POST /push/test triggers 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.json and vapid.json locally.
  • Set VAPID_SUBJECT (e.g. mailto:you@example.com or https://your.site) if you don’t want the default.

About

A personal data server for ANProto

Resources

Stars

5 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages