Fix NIP-42 AUTH compliance: always respond with OK message
Some checks failed
Go / build-and-release (push) Has been cancelled
Some checks failed
Go / build-and-release (push) Has been cancelled
- Ensure AUTH handler always sends OK response per NIP-42 specification, including for parse failures (uses zero event ID with error reason) - Add zeroEventID constant for OK responses when event ID cannot be parsed - Document critical client guidance: clients MUST wait for OK response after AUTH before publishing events requiring authentication - Update nostr skill and CLAUDE.md with NIP-42 AUTH protocol requirements for client developers, emphasizing OK response handling - Add MAX_THINKING_TOKENS setting to Claude configuration Files modified: - app/handle-auth.go: Add OK response for AUTH parse failures - .claude/skills/nostr/SKILL.md: Document AUTH OK response requirements - CLAUDE.md: Add NIP-42 AUTH Protocol section for client developers - .claude/settings.local.json: Add MAX_THINKING_TOKENS setting - pkg/version/version: Bump to v0.34.7 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,13 +5,25 @@ import (
|
||||
"lol.mleku.dev/log"
|
||||
"git.mleku.dev/mleku/nostr/encoders/envelopes/authenvelope"
|
||||
"git.mleku.dev/mleku/nostr/encoders/envelopes/okenvelope"
|
||||
"git.mleku.dev/mleku/nostr/encoders/reason"
|
||||
"git.mleku.dev/mleku/nostr/protocol/auth"
|
||||
)
|
||||
|
||||
// zeroEventID is used for OK responses when we cannot parse the event ID
|
||||
var zeroEventID = make([]byte, 32)
|
||||
|
||||
func (l *Listener) HandleAuth(b []byte) (err error) {
|
||||
var rem []byte
|
||||
env := authenvelope.NewResponse()
|
||||
if rem, err = env.Unmarshal(b); chk.E(err) {
|
||||
// NIP-42: AUTH messages MUST be answered with an OK message
|
||||
// For parse failures, use zero event ID
|
||||
log.E.F("%s AUTH unmarshal failed: %v", l.remote, err)
|
||||
if writeErr := okenvelope.NewFrom(
|
||||
zeroEventID, false, reason.Error.F("failed to parse auth event: %s", err),
|
||||
).Write(l); chk.E(writeErr) {
|
||||
return writeErr
|
||||
}
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
|
||||
Reference in New Issue
Block a user