Cloudflare Worker for pgp.kareem.one that serves the public key material and WKD endpoints from a durable KV cache with an automatic GitHub fallback.
- Serves static PGP assets (e.g.
/shaquille.asc,/.well-known/openpgpkey/...) with CORS and WKD-friendly headers. - Reads from the
PGP_ASSETSKV namespace first; on a miss it fetches from the public GitHub mirror and writes the response back to KV. - Stores KV payloads as base64-encoded bytes in bulk manifests to preserve binary WKD packets.
- Keeps assets in KV for 30 days by default — rotation workflows refresh the content ahead of key changes.
- Requests to
/are rewritten to the asset defined byROOT_OBJECT(defaults to/public-masterkey.asc) and returned withtext/plainso the root URL streams the ASCII-armored key directly. - WKD
hu/<hash>aliases are generated automatically fromhu/<hash>/<email>.pubfiles, and sharedhost/policyfiles are aliased into the advanced/<domain>/...paths, so standard WKD lookup URLs resolve without web-server rewrites.
-
Install dependencies:
cd worker npm install -
Create the KV namespaces (production + preview):
wrangler kv namespace create pgp-assets wrangler kv namespace create pgp-assets-preview --preview
Copy the resulting IDs into
wrangler.toml(idfor production,preview_idfor preview). -
(Optional but recommended) Restrict traffic to the intended hostnames by editing
ALLOWED_HOSTSinwrangler.toml. -
Point DNS (
pgp CNAME pgp-worker.<account>.workers.dev) and ensure routes inwrangler.tomlcover:pgp.kareem.one/*kareem.one/.well-known/openpgpkey/*openpgpkey.kareem.one/.well-known/openpgpkey/*
Generate a KV bulk upload manifest from the repository contents:
cd worker
npm run kv:sync -- --out dist/kv-assets.json
npm run kv:validate -- --manifest dist/kv-assets.jsonThen push to KV (remote namespaces):
wrangler kv bulk put dist/kv-assets.json --binding=PGP_ASSETS --remote --preview=false
wrangler kv bulk put dist/kv-assets.json --binding=PGP_ASSETS --remote --previewThe worker will now serve content directly from KV. When new keys or WKD files land in the repo, re-run the sync workflow so updates are available instantly without waiting on the GitHub fallback.
The sync script skips files that are absent (e.g.
shaquille.asc), so it is safe to run before every rotation.
Pushes to main that touch key material, WKD files, or worker code also trigger ../.github/workflows/refresh-cache.yml, which regenerates the manifest and bulk-uploads the production KV cache automatically.
npm run dev– local development (requireswranglerauthentication).npm run deploy– publish the worker once all bindings are configured.
The worker mirrors from https://raw.githubusercontent.com/kareemlukitomo/pgp/main by default. Override GITHUB_MIRROR_BASE in wrangler.toml if you prefer another mirror (e.g. a Forgejo origin).