feat(pairing): auto-detect NIP-43 relay and route target to /pair sidecar - #470
Merged
Conversation
When the relay requires NIP-42 authentication (indicating NIP-43 access control), the QR code URL is automatically suffixed with /pair so the target device connects to the ephemeral pairing sidecar instead of the auth-locked main relay. Non-NIP-43 relays continue to work unchanged — the target connects directly to the relay URL without the /pair suffix. Detection: a throwaway WebSocket connection probes for an AUTH challenge within 3 seconds. If received → NIP-43 locked → append /pair. Follows up on #467 (sprout-pair-relay sidecar).
Codex review (5/10) identified two issues: 1. AUTH challenge detection is too broad — Sprout sends AUTH on all connections regardless of NIP-43 enforcement. Switched to fetching the NIP-11 relay info document and checking limitation.auth_required. 2. String-based URL construction breaks URLs with query strings. Switched to url::Url for proper path segment appending.
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.
What
When the desktop app starts a NIP-AB pairing session, it now checks the relay's NIP-11 information document for
limitation.auth_required: true. If the relay requires auth (NIP-43 access control), the QR code URL is automatically suffixed with/pairso the target device connects to the ephemeral pairing sidecar instead of the auth-locked main relay.Non-NIP-43 relays continue to work unchanged — the target connects directly to the relay URL without the
/pairsuffix.Why
Follows up on #467 (sprout-pair-relay sidecar). The sidecar handles unauthenticated pairing traffic on NIP-43 locked relays, but the desktop client needs to know when to route the target device there.
How
GET /withAccept: application/nostr+json)limitation.auth_required— iftrue, the relay is NIP-43 locked/pairto the relay URL usingurl::Urlfor proper path handlingChange
desktop/src-tauri/src/commands/pairing.rs(+55 lines)desktop/scripts/check-file-sizes.mjs(bump limit 550→600)Quality
unwrap_or_default()on reqwest client builder (infallible in practice)