[Relay] Account Whitelist + Trust-Gated Access #47
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What & Why
Timmy's relay starts with an empty whitelist. Accounts must earn or be granted access. This task builds the account registry, trust-tier promotion logic, and API surface for granting/revoking/querying relay access.
Trust tiers (from existing Nostr identity/trust scoring) map to relay access:
Accounts below
establishedcan be manually whitelisted by the relay admin.Done looks like
relay_accountsDB table:pubkey(FKnostr_identities),access_level(none/read/write),granted_by,granted_at,revoked_at,notesRelayAccountService:getAccess(pubkey),grant(pubkey, level, reason),revoke(pubkey),syncFromTrustTier(pubkey)POST /api/relay/policychecksrelay_accounts; write access →accept; read/none →rejectGET /api/admin/relay/accounts,POST .../grant,POST .../revokeTIMMY_NOSTR_PUBKEYenv var) witheliteaccessTrustService.recordSuccesscallssyncFromTrustTierafter tier promotionOut of scope
Tasks
relay_accountstable with columns above. FK tonostr_identities.pubkey. Rundb:push.syncFromTrustTiermaps tier → access level via configurable env map (established→write, new→read, none→none).TrustService.recordSuccess+ tier promotion, callRelayAccountService.syncFromTrustTier(pubkey).POST /api/relay/policyto queryrelay_accounts. Write →accept; read/missing →reject.GET /api/admin/relay/accounts,POST .../grant,POST .../revoke. Admin auth middleware.TIMMY_NOSTR_PUBKEYset, upsertnostr_identitiesand grant elite relay access.Relevant files
lib/db/src/schema/nostr-identities.tsartifacts/api-server/src/lib/trust.tsartifacts/api-server/src/routes/index.tsAll 6 tasks from this issue are already implemented on
main:relay_accountstable exists inlib/db/src/schema/relay-accounts.tswith all required columns (pubkey FK→nostr_identities, access_level, granted_by, granted_at, revoked_at, notes)artifacts/api-server/src/lib/relay-accounts.tswithgetAccess(),grant(),revoke(),syncFromTrustTier(),seedElite(), andlist()TrustService.recordSuccess()andrecordFailure()callrelayAccountService.syncFromTrustTier(pubkey)after tier updatesPOST /api/relay/policyinartifacts/api-server/src/routes/relay.tschecks relay_accounts; write+elite→accept, write+non-elite→shadowReject (moderation queue), read/none→rejectGET /api/admin/relay/accounts,POST .../grant,POST .../revokeinartifacts/api-server/src/routes/admin-relay.tswithrequireAdminmiddlewareseedElite()called at startup inartifacts/api-server/src/index.tsusingTIMMY_NOSTR_PUBKEYenv var or derived fromTIMMY_NOSTR_NSECNo code changes needed — this was part of the initial codebase. Closing as already-complete.
PR #90 created: http://143.198.27.163:3000/replit/timmy-tower/pulls/90
All 6 tasks from the issue were already implemented on main. This PR adds the missing SQL migration file
0009_relay_access.sqlwith explicit DDL forrelay_accountsandrelay_event_queue, completing the schema tracking for environments using SQL-based migrations.