Skip to content

feat(bunker): Support direct connection initiated by the client (nostrconnect tokens)#73

Open
aaccioly wants to merge 1 commit intofiatjaf:masterfrom
aaccioly-open-source:feat/bunker-nip46-nostrconnect-direct-connection
Open

feat(bunker): Support direct connection initiated by the client (nostrconnect tokens)#73
aaccioly wants to merge 1 commit intofiatjaf:masterfrom
aaccioly-open-source:feat/bunker-nip46-nostrconnect-direct-connection

Conversation

@aaccioly
Copy link
Contributor

@aaccioly aaccioly commented Jul 4, 2025

Also adds subcommands to nak bunker so that the user can display info, qr code, connect, quit, etc.

Copilot AI review requested due to automatic review settings July 4, 2025 18:09
@aaccioly aaccioly force-pushed the feat/bunker-nip46-nostrconnect-direct-connection branch from b54297f to 62dc143 Compare July 4, 2025 18:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds client-initiated connection support via nostrconnect URIs and interactive subcommands for the nak bunker command.

  • Introduces qrterminal for QR code generation and a --qrcode flag.
  • Implements a REPL-like interface with help, info, qr, connect, and exit commands.
  • Handles parsing, authorizing, and responding to NostrConnect events with encrypted payloads.

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
go.mod Bumps x/term, go-colorable; adds qrterminal/v3 and rsc.io/qr.
bunker.go Adds subcommand loop, QR printing, handleConnect flow, and dynamic subscriptions.
README.md Documents new bunker subcommands and --qrcode flag with examples.
Comments suppressed due to low confidence (2)

bunker.go:477

  • The code calls json.MarshalIndent but there is no import "encoding/json" in the import block, resulting in a compile error. Please add the missing import.
			responseJSON, err := json.MarshalIndent(responsePayload, "", "  ")

bunker.go:636

  • cancelPreviousBunkerInfoPrint may be nil on first invocation, causing a panic. Consider checking if it's non-nil before calling or initialize it with a no-op function.
				cancelPreviousBunkerInfoPrint() // this prevents us from printing a million bunker info blocks

@fiatjaf
Copy link
Owner

fiatjaf commented Jul 4, 2025

Sorry, but this isn't in accordance with the way nak works. Just reading commands from stdin while the daemon is running feels very sloppy, it's something I've done in the past but I can't do it now again in good conscience.

I'll think of another way to implement nostrconnect:// support.

@aaccioly
Copy link
Contributor Author

aaccioly commented Jul 4, 2025

No problem at all fiatjaf. Understood. I've started with your top level TODO nostr connect command, but then I realised that some clients only support nostrconnect tokens and I wanted all clients authenticating with bunker:// and nostrconnect:// alike in the same bunker profile.

The only alternatives that I could think of to reading input from stdin are:

  1. Restart the bunker every time I needed to work with new nostrconnect tokens (i.e, shutdown and nak bunker --persist connect nostrconnect://xxxx to add the new authorisation), or
  2. Expose an RCP like interface and have other top level commands modify a running bunker, e.g., nostr bunker --profile anthony ---rpc connect nostrconnect://xxx would interact with a running nak bunker daemon and trigger the connect flow.

But both options felt... well... not that great from an UX perspective either. I'm sure that you can think of something better though.

One way or another, the code is here. Feel free to reuse and adapt it in any way that you see fit.

@aaccioly aaccioly force-pushed the feat/bunker-nip46-nostrconnect-direct-connection branch from 62dc143 to 8e1d7fb Compare July 7, 2025 11:25
@aaccioly aaccioly force-pushed the feat/bunker-nip46-nostrconnect-direct-connection branch from 8e1d7fb to b646b39 Compare July 20, 2025 19:01
@aaccioly aaccioly force-pushed the feat/bunker-nip46-nostrconnect-direct-connection branch from b646b39 to c71f795 Compare July 29, 2025 15:14
@aaccioly aaccioly force-pushed the feat/bunker-nip46-nostrconnect-direct-connection branch from c71f795 to f8cd233 Compare August 8, 2025 20:39
@aaccioly aaccioly force-pushed the feat/bunker-nip46-nostrconnect-direct-connection branch from f8cd233 to dc8e3d1 Compare August 21, 2025 23:51
@aaccioly aaccioly force-pushed the feat/bunker-nip46-nostrconnect-direct-connection branch from dc8e3d1 to f786639 Compare September 8, 2025 19:30
@aaccioly aaccioly force-pushed the feat/bunker-nip46-nostrconnect-direct-connection branch from f786639 to a426225 Compare November 10, 2025 18:22
@aaccioly aaccioly force-pushed the feat/bunker-nip46-nostrconnect-direct-connection branch from a426225 to 4be4abb Compare November 24, 2025 14:18
@fiatjaf fiatjaf force-pushed the master branch 6 times, most recently from 82418f6 to a288cc4 Compare December 6, 2025 01:09
@aaccioly aaccioly force-pushed the feat/bunker-nip46-nostrconnect-direct-connection branch from 4be4abb to 911e3c9 Compare December 15, 2025 17:59
@fiatjaf fiatjaf force-pushed the master branch 4 times, most recently from b2c3896 to 3299991 Compare December 27, 2025 17:52
@aaccioly aaccioly force-pushed the feat/bunker-nip46-nostrconnect-direct-connection branch from 911e3c9 to 7c5430f Compare January 8, 2026 18:55
@aaccioly aaccioly force-pushed the feat/bunker-nip46-nostrconnect-direct-connection branch 4 times, most recently from f611fbb to 9bc5096 Compare January 22, 2026 13:51
@aaccioly aaccioly force-pushed the feat/bunker-nip46-nostrconnect-direct-connection branch 2 times, most recently from 3ab1d98 to 0c8735c Compare January 29, 2026 00:08
@aaccioly aaccioly force-pushed the feat/bunker-nip46-nostrconnect-direct-connection branch 3 times, most recently from e76586c to e52fba8 Compare February 16, 2026 09:51
@aaccioly aaccioly force-pushed the feat/bunker-nip46-nostrconnect-direct-connection branch from e52fba8 to b269ff9 Compare February 18, 2026 17:08
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.

2 participants

Comments