Phase 0 of #326 (decision: full DB-backed identity). Non-breaking refactor, no behaviour change — and the prerequisite for every later phase.
Problem
SITE_URL / FEDI_HANDLE / FEDI_DOMAIN are read directly, in ~63 places, and several are evaluated at import time:
// src/lib/federation.ts:7
const siteUrl = siteConfig.url; // captured once, at module load
|
Count |
siteConfig.url |
32 across 18 files |
direct process.env.SITE_URL / FEDI_DOMAIN / FEDI_HANDLE |
31 |
siteConfig.fediAddress |
10 |
A runtime (DB-backed) value simply cannot be seen by a module-level constant, so no overlay is possible until these funnel through one accessor.
Scope
Add src/lib/identity.ts exposing the identity triple (+ derived fediAddress, actor id, etc.), still env-backed, and route every call site through it. No DB, no UI, no semantic change — siteConfig keeps working for everything else.
Call sites span the federation-critical path and must each be checked, not sed'd blindly:
.well-known/webfinger, .well-known/oauth-authorization-server
ap/inbox, ap/outbox, ap/followers, ap/following, lib/federation.ts, lib/http-signatures.ts
api/micropub, api/compose, api/media, api/oauth/token, api/setup, xmlrpc, rsd.xml
lib/crosspost.ts, lib/publish-post.ts, lib/auth.ts, the audio feed
Why it needs care
A wrong value here fails silently: the actor id, WebFinger response and HTTP-signature keyId must agree, or remote servers stop verifying posts with nothing in the logs to say why. Related: #310.
Done when
- No
process.env.SITE_URL / FEDI_DOMAIN / FEDI_HANDLE outside identity.ts (and site.config.ts).
- No module-level captures of identity values.
- Actor id / WebFinger /
keyId agreement covered by a test.
- Full gate suite green; a federated smoke on the demo (a post still verifies remotely, WebFinger resolves).
Phase 0 of #326 (decision: full DB-backed identity). Non-breaking refactor, no behaviour change — and the prerequisite for every later phase.
Problem
SITE_URL/FEDI_HANDLE/FEDI_DOMAINare read directly, in ~63 places, and several are evaluated at import time:siteConfig.urlprocess.env.SITE_URL/FEDI_DOMAIN/FEDI_HANDLEsiteConfig.fediAddressA runtime (DB-backed) value simply cannot be seen by a module-level constant, so no overlay is possible until these funnel through one accessor.
Scope
Add
src/lib/identity.tsexposing the identity triple (+ derivedfediAddress, actor id, etc.), still env-backed, and route every call site through it. No DB, no UI, no semantic change —siteConfigkeeps working for everything else.Call sites span the federation-critical path and must each be checked, not sed'd blindly:
.well-known/webfinger,.well-known/oauth-authorization-serverap/inbox,ap/outbox,ap/followers,ap/following,lib/federation.ts,lib/http-signatures.tsapi/micropub,api/compose,api/media,api/oauth/token,api/setup,xmlrpc,rsd.xmllib/crosspost.ts,lib/publish-post.ts,lib/auth.ts, the audio feedWhy it needs care
A wrong value here fails silently: the actor id, WebFinger response and HTTP-signature
keyIdmust agree, or remote servers stop verifying posts with nothing in the logs to say why. Related: #310.Done when
process.env.SITE_URL/FEDI_DOMAIN/FEDI_HANDLEoutsideidentity.ts(andsite.config.ts).keyIdagreement covered by a test.