From b323ca1b7327a634998b55c83dea8c35f00981fe Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Wed, 3 Dec 2025 19:31:23 -0300 Subject: [PATCH] khatru: expose GetAllAuthed() safe helper. --- khatru/utils.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/khatru/utils.go b/khatru/utils.go index 578c47d..800d0c0 100644 --- a/khatru/utils.go +++ b/khatru/utils.go @@ -43,6 +43,19 @@ func GetAuthed(ctx context.Context) (nostr.PubKey, bool) { return nostr.ZeroPK, false } +// GetAllAuthed returns all authenticated public keys. +// +// In a NIP-86 context it returns the single pubkey that authenticated for that method call. +func GetAllAuthed(ctx context.Context) []nostr.PubKey { + if conn := GetConnection(ctx); conn != nil { + return conn.AuthedPublicKeys + } + if nip86Auth := ctx.Value(nip86HeaderAuthKey); nip86Auth != nil { + return []nostr.PubKey{nip86Auth.(nostr.PubKey)} + } + return []nostr.PubKey{} +} + // IsAuthed checks if the given public key is among the multiple that may have potentially authenticated. func IsAuthed(ctx context.Context, pubkey nostr.PubKey) bool { if conn := GetConnection(ctx); conn != nil {