Skip to content

Commit e44a5f5

Browse files
committed
replace risky khatru.GetConnection().AuthedPubKeys with safe helper.
1 parent 249a49d commit e44a5f5

8 files changed

Lines changed: 9 additions & 11 deletions

File tree

core.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func queryMain(ctx context.Context, filter nostr.Filter) iter.Seq[nostr.Event] {
258258
// normal query
259259
if global.Settings.Paywall.AmountSats > 0 && global.Settings.Paywall.PeriodDays > 0 {
260260
// use this special query that filters content for paying visitors
261-
authed := khatru.GetConnection(ctx).AuthedPublicKeys
261+
authed := khatru.GetAllAuthed(ctx)
262262

263263
for evt := range global.IL.Main.QueryEvents(filter, 500) {
264264
if nip70.IsProtected(evt) && (global.Settings.Paywall.Tag == "" || evt.Tags.FindWithValue("t", global.Settings.Paywall.Tag) != nil) {

favorites/relay.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func setupEnabled() {
7878
policies.PreventTooManyIndexableTags(1200, nil, []nostr.Kind{3}),
7979
policies.RestrictToSpecifiedKinds(true, 1, 11, 1111, 1222, 1244, 30023, 30818, 9802, 20, 21, 22),
8080
func(ctx context.Context, evt nostr.Event) (bool, string) {
81-
authedPublicKeys := khatru.GetConnection(ctx).AuthedPublicKeys
81+
authedPublicKeys := khatru.GetAllAuthed(ctx)
8282
if len(authedPublicKeys) == 0 {
8383
return true, "auth-required: must be a relay member"
8484
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/fiatjaf/pyramid
33
go 1.25
44

55
require (
6-
fiatjaf.com/nostr v0.0.0-20251201193824-15dc5b11aa09
6+
fiatjaf.com/nostr v0.0.0-20251203223123-b323ca1b7327
77
github.com/FastFilter/xorfilter v0.2.1
88
github.com/a-h/templ v0.3.960
99
github.com/kelseyhightower/envconfig v1.4.0

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
fiatjaf.com/nostr v0.0.0-20251126120447-7261a4b515ed h1:dip4Bxlfj4/N2oIIGCZpcYRrvfMObcXRcyBM5uYswnM=
2-
fiatjaf.com/nostr v0.0.0-20251126120447-7261a4b515ed/go.mod h1:ue7yw0zHfZj23Ml2kVSdBx0ENEaZiuvGxs/8VEN93FU=
3-
fiatjaf.com/nostr v0.0.0-20251201193824-15dc5b11aa09 h1:oU/3PgIfxaGdMoaCIl88JRNFcoMdagD3aYNM2a6NGoQ=
4-
fiatjaf.com/nostr v0.0.0-20251201193824-15dc5b11aa09/go.mod h1:ue7yw0zHfZj23Ml2kVSdBx0ENEaZiuvGxs/8VEN93FU=
1+
fiatjaf.com/nostr v0.0.0-20251203223123-b323ca1b7327 h1:Cv7SQkTdSx3b2RxAfjbNiO7oHKzB4Bumny0DWD1AUXk=
2+
fiatjaf.com/nostr v0.0.0-20251203223123-b323ca1b7327/go.mod h1:ue7yw0zHfZj23Ml2kVSdBx0ENEaZiuvGxs/8VEN93FU=
53
github.com/FastFilter/xorfilter v0.2.1 h1:lbdeLG9BdpquK64ZsleBS8B4xO/QW1IM0gMzF7KaBKc=
64
github.com/FastFilter/xorfilter v0.2.1/go.mod h1:aumvdkhscz6YBZF9ZA/6O4fIoNod4YR50kIVGGZ7l9I=
75
github.com/ImVexed/fasturl v0.0.0-20230304231329-4e41488060f3 h1:ClzzXMDDuUbWfNNZqGeYq4PnYOlwlOVIvSyNaIy0ykg=

groups/filter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func (s *GroupsState) RequestAuthWhenNecessary(
1111
ctx context.Context,
1212
filter nostr.Filter,
1313
) (reject bool, msg string) {
14-
authed := khatru.GetConnection(ctx).AuthedPublicKeys
14+
authed := khatru.GetAllAuthed(ctx)
1515
groupIds, _ := filter.Tags["h"]
1616

1717
for _, groupId := range groupIds {

groups/queries.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
func (s *GroupsState) Query(ctx context.Context, filter nostr.Filter) iter.Seq[nostr.Event] {
1313
return func(yield func(nostr.Event) bool) {
14-
authed := khatru.GetConnection(ctx).AuthedPublicKeys
14+
authed := khatru.GetAllAuthed(ctx)
1515
groupIds, hasGroupIds := filter.Tags["d"]
1616

1717
switch hasGroupIds {

inbox/core.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func rejectFilter(ctx context.Context, filter nostr.Filter) (bool, string) {
3737

3838
// from now on we know it's a secret kind query
3939
// secret kinds require authentication
40-
authedPublicKeys := khatru.GetConnection(ctx).AuthedPublicKeys
40+
authedPublicKeys := khatru.GetAllAuthed(ctx)
4141
if len(authedPublicKeys) == 0 {
4242
return true, "auth-required: must authenticate to see private events"
4343
}

internal/relay.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func setupEnabled() {
7070
policies.NoSearchQueries,
7171
policies.MustAuth,
7272
func(ctx context.Context, _ nostr.Filter) (bool, string) {
73-
authedPublicKeys := khatru.GetConnection(ctx).AuthedPublicKeys
73+
authedPublicKeys := khatru.GetAllAuthed(ctx)
7474
if len(authedPublicKeys) == 0 {
7575
return true, "auth-required: this is only viewable by relay members"
7676
}

0 commit comments

Comments
 (0)