Nostr onboarding: publish profile, relay list and media server list #269

Merged
raucao merged 13 commits from feature/nostr-onboarding-ruby into master 2026-11-19 07:15:09 +00:00
Owner

Implements #248. The account settings page now lets users publish their own Nostr data with their own key: their profile (kind 0, including NIP-05 and Lightning addresses), their relay list (NIP-65, kind 10002) and their media server list (Blossom, kind 10063). Edited profile fields are merged into the existing profile JSON so unknown keys survive; the configured site relay and Blossom server are pre-included in the respective lists.

Events are signed in the browser with a NIP-07 extension and published by the server. The publish endpoint verifies the event (recomputing the event id before checking the signature, since the nostr gem's verify_signature alone does not bind the signature to the body), enforces a kind allow-list plus freshness and size limits, rate-limits per user, and blocks SSRF through user-supplied relay URLs. Reads — discovering an existing profile, relay list or media server list — happen server-side, with a progressive relays → profile → blossom → render fetch chain.

The branch also includes the id-recompute verification fix, which shipped separately to master via #268, and a merge of master (0.13.0).

Known limitations are documented in docs/dev/nostr.md: relays requiring NIP-42 auth are unsupported, a new relay list is not propagated to relays removed from it, the relay URL guard has a DNS-rebinding TOCTOU gap, non-ws/wss relay URLs are rejected, and metadata discovery is sequential. The adjacent remove_nostr_pubkey TODO (deleting a pubkey without re-authentication) is left out of scope here.

Implements #248. The account settings page now lets users publish their own Nostr data with their own key: their profile (kind 0, including NIP-05 and Lightning addresses), their relay list (NIP-65, kind 10002) and their media server list (Blossom, kind 10063). Edited profile fields are merged into the existing profile JSON so unknown keys survive; the configured site relay and Blossom server are pre-included in the respective lists. Events are signed in the browser with a NIP-07 extension and published by the server. The publish endpoint verifies the event (recomputing the event id before checking the signature, since the `nostr` gem's `verify_signature` alone does not bind the signature to the body), enforces a kind allow-list plus freshness and size limits, rate-limits per user, and blocks SSRF through user-supplied relay URLs. Reads — discovering an existing profile, relay list or media server list — happen server-side, with a progressive `relays → profile → blossom → render` fetch chain. The branch also includes the id-recompute verification fix, which shipped separately to master via #268, and a merge of master (0.13.0). Known limitations are documented in `docs/dev/nostr.md`: relays requiring NIP-42 auth are unsupported, a new relay list is not propagated to relays removed from it, the relay URL guard has a DNS-rebinding TOCTOU gap, non-`ws`/`wss` relay URLs are rejected, and metadata discovery is sequential. The adjacent `remove_nostr_pubkey` TODO (deleting a pubkey without re-authentication) is left out of scope here.
raucao added the
integration
nostr
label 2026-11-18 17:54:14 +00:00
raucao marked the pull request as work in progress 2026-11-18 18:17:52 +00:00
raucao added the feature label 2026-11-18 18:17:58 +00:00
raucao added 8 commits 2026-11-18 18:20:15 +00:00
raucao force-pushed feature/nostr-onboarding-ruby from 1b4bca3078 to 0dda543b03 2026-11-18 18:20:15 +00:00 Compare
raucao added 2 commits 2026-11-18 19:42:14 +00:00
FetchEvent wrapped its wait in Timeout.timeout and FetchLatestEvent
wrapped the relay loop in another one. The nesting leaked
Timeout::ExitException, which is neither a Timeout::Error nor a
StandardError, so it escaped the rescue and surfaced as a 500 on the
metadata endpoint.

- FetchEvent waits on the condition variable with a 5s timeout instead
  of Timeout.timeout, and wakes immediately when the relay errors
- FetchLatestEvent uses a monotonic deadline instead of Timeout.timeout,
  and skips a relay that raises, so one bad relay cannot abort discovery
- PublishEvent uses thread.join(TIMEOUT) instead of Timeout.timeout
Address review nits on the discovery timeout fix
CI / Test (pull_request) Successful in 45s
cd325f39ea
- Track EOSE with a done flag so a healthy relay with no matching
  events returns immediately instead of waiting out the timeout
- Restore the ensure around the client thread cleanup
- Raise the metadata fetch client timeout to 60s to cover the
  worst-case sequential discovery on the server
raucao added 1 commit 2026-11-18 19:51:52 +00:00
Drop the bottom margin on the Relays section so the gap before Media
servers matches the gap before Relays.
raucao added 1 commit 2026-11-19 06:39:59 +00:00
The profile and the media server list are published to the user's write
relays, so they should be set up after the relay list. This also makes
the page order match the discovery order (relays -> profile -> media
servers) shown while loading.
raucao added 1 commit 2026-11-19 06:58:38 +00:00
Add a "Just a moment..." title to the metadata loading state
CI / Test (pull_request) Successful in 47s
Release Drafter / Update release notes draft (pull_request) Successful in 3s
355d0a2fb0
The title sits above the rotating status messages and disappears with
the loading state; the status messages no longer carry their own
ellipses.
raucao marked the pull request as ready for review 2026-11-19 07:14:58 +00:00
raucao merged commit b35aa3050f into master 2026-11-19 07:15:09 +00:00
raucao deleted branch feature/nostr-onboarding-ruby 2026-11-19 07:15:10 +00:00
Sign in to join this conversation.