Skip to content

fix(pairing): CLI payload format mismatch + mobile ws:// scheme rejection - #4757

Open
tak-uukti wants to merge 1 commit into
block:mainfrom
tak-uukti:fix/pairing-payload-format
Open

tak-uukti wants to merge 1 commit into
block:mainfrom
tak-uukti:fix/pairing-payload-format

Conversation

@tak-uukti

Copy link
Copy Markdown

Problem

Running buzz-pair source --relay ws://<relay>:3000 and scanning the QR code with the Buzz mobile app resulted in:

Failed to import credentials: FormatException: Unexpected character (at character 1)

Root Cause (two bugs)

Bug 1: CLI sends raw nsec, mobile expects JSON object

buzz-pairing-cli::resolve_payload() was sending the nsec as a raw bech32 string:

{"type":"payload","payload_type":"nsec","payload":"nsec1abc..."}

But _processPayload() in the mobile app calls jsonDecode(payload) expecting:

{"relayUrl":"ws://...","pubkey":"...","nsec":"nsec1..."}

jsonDecode("nsec1abc...") throws FormatException because n is not valid JSON.

Fix: resolve_payload() now constructs a JSON object with relayUrl, pubkey, and nsec fields.

Bug 2: Mobile app rejects ws:// relay URLs

_validateRelayUrl() only accepted http/https, rejecting ws:///wss://.

Fix: Added ws and wss to allowed URL schemes.

Files Changed

  • crates/buzz-pairing-cli/src/main.rs — resolve_payload constructs JSON payload
  • mobile/lib/features/pairing/pairing_provider.dart — accept ws/wss URL schemes

Testing

End-to-end on Android with Tailscale relay — pairing completes successfully.

Fixes #4744

…tion

Two fixes for buzz-pair source → mobile app credential import:

1. CLI (buzz-pairing-cli): resolve_payload() was sending a raw nsec string
   as the payload, but the mobile app's _processPayload() expects a JSON
   object with relayUrl, pubkey, and nsec fields. Changed to construct
   the proper JSON payload matching the mobile app's expected format.

2. Mobile (pairing_provider.dart): _validateRelayUrl() rejected ws:// and
   wss:// URL schemes, only accepting http/https. Added ws/wss to allowed
   schemes since the CLI sends the relay URL with its native ws:// prefix.

Fixes block#4744

Signed-off-by: yash101017 <yashpatel0017@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

buzz-pair source: payload format mismatch breaks mobile credential import (raw nsec sent instead of JSON object)

2 participants