Add NIP-5A nsite discovery, installation, and serving#171
Merged
Conversation
Extend the Web Clients settings section with nsites — static websites published on Nostr per NIP-5A. Users can browse nsites discovered by querying relays globally for manifest events (kinds 15128/35128), install one (download its blobs from Blossom servers, verify each against its path sha256, and store under filesDir/nsites), and serve it through the existing localhost web-client mechanism. A daily update check (gated on the existing service timer, mirroring the weekly auto-backup) compares each installed manifest's aggregate hash and either auto-applies the update (per-nsite toggle) or posts a notification letting the user choose to update. - Settings: NsiteInfo model, nsites list, lastNsiteCheck + JSON helpers - LocalPreferences: persist nsites and last-check timestamp - NsiteManager: discovery, blob download/verify, install, update check - CustomWebSocketServer: File-based serveFromDir + nsite server start/stop - WebSocketServerService: daily check + update notification - ClipboardReceiver: notification action to apply an update - UI: BrowseNsitesScreen, NsiteRow, Web Clients section + nav wiring Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NgPUkQoCoYH2Fz9bPxK1j7
The browser list showed the author's kind-0 profile name. NIP-5A manifests carry an optional `title` tag (the site's own name); prefer it as the primary label, falling back to the d tag, author name, then short pubkey. The author name is now shown as the secondary line. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NgPUkQoCoYH2Fz9bPxK1j7
Add Coil 3 to load each nsite's icon. NIP-5A has no icon tag, so the icon is one of the manifest's path-mapped blobs (favicon.png, etc.); the browse list loads it from a Blossom URL and the installed list loads it from the already-downloaded file on disk. Coil's network fetcher is wired to the app's OkHttp client so icon requests honor the Tor/proxy fail-closed policy. Undecodable/missing icons fall back to a globe placeholder. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NgPUkQoCoYH2Fz9bPxK1j7
Order discovered nsites by their manifest's most recent update (newest first) instead of alphabetically, and add a search field that filters the list by name, author, or address. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NgPUkQoCoYH2Fz9bPxK1j7
Thread a progress callback through NsiteManager.install/downloadAndStore reporting downloaded/total blobs. While installing, the browse row shows a determinate spinner in place of the icon and a "Installing… x/y files" subtitle, and other rows are disabled until it finishes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NgPUkQoCoYH2Fz9bPxK1j7
Add a configurable nsite relay list (Settings.nsiteRelays, persisted) that NsiteManager.discoveryRelays() uses when non-empty, falling back to the aggregator relays otherwise. New NsiteRelaysSettingsScreen (reusing the relay-list editor components) is reachable from the Web Clients nsites section, with add/delete and a reset-to-default action. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NgPUkQoCoYH2Fz9bPxK1j7
nsite discovery now uses only the nsite relay set (defaulting to DEFAULT_NSITE_RELAYS) and no longer falls back to the relay aggregator relays. nsiteRelays defaults to the built-in set on fresh installs and on reset. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NgPUkQoCoYH2Fz9bPxK1j7
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NgPUkQoCoYH2Fz9bPxK1j7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements full support for discovering, installing, and serving nsites (NIP-5A static websites) on the relay. Users can browse available nsites from Nostr relays, install them locally, and access them via the relay's web server. Auto-update checks run daily and can be toggled per-site.
Key Changes
NsiteManager (
service/NsiteManager.kt) — New singleton managing the complete nsite lifecycle:filesDir/nsites/<folderName>with path-traversal guardspathtags, prioritizing common raster formatsWeb server integration (
server/CustomWebSocketServer.kt):serveFromDir()to serve files from plainFiletrees (vs. SAF DocumentFile)startNsiteServer()/stopNsiteServer()to hot-add/remove nsite servers without relay restart/<folderName>.localhost:<port>alongside existing web clientsSettings & persistence (
server/Settings.kt,service/LocalPreferences.kt):nsites: MutableList<NsiteInfo>to store installed siteslastNsiteCheck: Longto gate daily update checksUI screens:
BrowseNsitesScreen— Discover and install nsites with search, progress tracking, and error handlingNsiteRow— Display installed nsites with auto-update toggle, update button, and delete actionNsiteIcon— Coil-based icon loader with globe placeholder fallbackWebClientsSettingsScreento show installed nsites alongside web clientsService integration (
service/WebSocketServerService.kt):lastNsiteCheck)autoUpdate=true; posts notification otherwiseDependencies:
Implementation Details
path(file mappings),server(Blossom hints),x(aggregate hash for change detection),title, and icon filenames from event tags../../../etc/passwd)index.htmlfor extension-less routes; serves404.htmlwith 404 status per NIP-5Ansite<16-hex-chars>slug from sha256(address) for hostname safetyhttps://claude.ai/code/session_01NgPUkQoCoYH2Fz9bPxK1j7