feat(bunker): Support direct connection initiated by the client (nostrconnect tokens)#73
Conversation
b54297f to
62dc143
Compare
There was a problem hiding this comment.
Pull Request Overview
Adds client-initiated connection support via nostrconnect URIs and interactive subcommands for the nak bunker command.
- Introduces
qrterminalfor QR code generation and a--qrcodeflag. - Implements a REPL-like interface with
help,info,qr,connect, andexitcommands. - 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.MarshalIndentbut there is noimport "encoding/json"in the import block, resulting in a compile error. Please add the missing import.
responseJSON, err := json.MarshalIndent(responsePayload, "", " ")
bunker.go:636
cancelPreviousBunkerInfoPrintmay 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
|
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. |
|
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 The only alternatives that I could think of to reading input from stdin are:
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. |
62dc143 to
8e1d7fb
Compare
8e1d7fb to
b646b39
Compare
b646b39 to
c71f795
Compare
c71f795 to
f8cd233
Compare
f8cd233 to
dc8e3d1
Compare
dc8e3d1 to
f786639
Compare
f786639 to
a426225
Compare
a426225 to
4be4abb
Compare
82418f6 to
a288cc4
Compare
4be4abb to
911e3c9
Compare
b2c3896 to
3299991
Compare
911e3c9 to
7c5430f
Compare
f611fbb to
9bc5096
Compare
3ab1d98 to
0c8735c
Compare
e76586c to
e52fba8
Compare
e52fba8 to
b269ff9
Compare
Also adds subcommands to nak bunker so that the user can display info, qr code, connect, quit, etc.