Skip to content

Commit

Permalink
feat: Add authed pubkey to ReqAccepter
Browse files Browse the repository at this point in the history
Pass the nip-42 pubkey to the ReqAccepter. This allows a relay to
authenticate REQs.
  • Loading branch information
bndw committed Nov 22, 2023
1 parent f5a2ca4 commit bf5df12
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (s *Server) doReq(ctx context.Context, ws *WebSocket, request []json.RawMes
}

if accepter, ok := s.relay.(ReqAccepter); ok {
if !accepter.AcceptReq(ctx, id, filters) {
if !accepter.AcceptReq(ctx, id, filters, ws.authed) {
return "REQ filters are not accepted"
}
}
Expand Down
2 changes: 1 addition & 1 deletion interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type ReqAccepter interface {
// AcceptReq is called for every nostr request filters received by the
// server. If the returned value is true, the filtres is passed on to
// [Storage.QueryEvent].
AcceptReq(context.Context, string, nostr.Filters) bool
AcceptReq(ctx context.Context, id string, filters nostr.Filters, authedPubkey string) bool
}

// Auther is the interface for implementing NIP-42.
Expand Down

0 comments on commit bf5df12

Please sign in to comment.