From 61586d5d1b31a6f9cd37ee8bc8042e3661b0d23b Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Mon, 4 May 2026 10:17:06 -0300 Subject: [PATCH] khatru: ForceSetAuthed() --- khatru/utils.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/khatru/utils.go b/khatru/utils.go index b11f138..10b982d 100644 --- a/khatru/utils.go +++ b/khatru/utils.go @@ -74,6 +74,13 @@ func IsAuthed(ctx context.Context, pubkey nostr.PubKey) bool { return false } +// ForceSetAuthed modifies the context to insert a custom authed public key. +// It can be used in testing or other rare scenarios for making requests as if a given public key +// was authenticated when in fact it didn't perform any of the authentication rituals. +func ForceSetAuthed(ctx context.Context, pubkey nostr.PubKey) context.Context { + return context.WithValue(ctx, nip86HeaderAuthKey, pubkey) +} + // IsInternalCall returns true when a call to QueryEvents, for example, is being made because of a deletion // or expiration request. func IsInternalCall(ctx context.Context) bool {