Skip to content

Commit

Permalink
ws: use new nip42 api (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-dionysos authored Dec 20, 2024
1 parent 3fe6867 commit 64e0cc2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.23.4

replace (
filippo.io/mkcert => github.com/kixelated/mkcert v1.4.4-days
github.com/nbd-wtf/go-nostr => github.com/ice-blockchain/go-nostr v0.42.3-ion.0.20241216090049-0a53b52ee105
github.com/nbd-wtf/go-nostr => github.com/ice-blockchain/go-nostr v0.42.3-ion.0.20241220135714-1279f2e44ffd
github.com/xssnick/tonutils-storage => github.com/ice-blockchain/tonutils-storage v0.0.0-20241021135840-ef55d22c523b
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ice-blockchain/go-nostr v0.42.3-ion.0.20241216090049-0a53b52ee105 h1:Wg5KeVb1yxGxVCxWQCSTGE/tadQWJeOHRs9NauSLtio=
github.com/ice-blockchain/go-nostr v0.42.3-ion.0.20241216090049-0a53b52ee105/go.mod h1:EDZl0i7UAQDqKdlY1nCPL0wOo6CcW0QnCL5Zb+WGJN0=
github.com/ice-blockchain/go-nostr v0.42.3-ion.0.20241220135714-1279f2e44ffd h1:lLEdAgC5vlAAUhifViPKPvVr9RRgfVOVB/51DIOYe0Y=
github.com/ice-blockchain/go-nostr v0.42.3-ion.0.20241220135714-1279f2e44ffd/go.mod h1:a3+uZ3tE8dXZYbBzl+UaGJ+VPTpDlDuws6azKs7tn5c=
github.com/ice-blockchain/go/src v0.0.0-20240529122316-8d9458949bdd h1:SY8V7ujSDgEYEdtMk26DEaiq8qvCTEZ7XlojacrWZj4=
github.com/ice-blockchain/go/src v0.0.0-20240529122316-8d9458949bdd/go.mod h1:pVzkmaIwkLaJ5cKPHPtuKyxaXiTsa/V7kbbgLmsr4Hw=
github.com/ice-blockchain/tonutils-storage v0.0.0-20241021135840-ef55d22c523b h1:Ns/j/FMyMIr0PaZhhJSEDkUt2BVHI30Ofu6NBDGAS8k=
Expand Down
13 changes: 9 additions & 4 deletions server/ws/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,15 @@ func (h *handler) handleAuth(_ context.Context, respWriter Writer, e *model.Even
return &resp
}

if _, ok = nip42.ValidateAuthEvent(&e.Event, state.Challenge, h.relayURL, func(nostrEvent *nostr.Event) (bool, error) {
return (&model.Event{Event: *nostrEvent}).CheckSignature()
}); !ok {
resp.Reason = "failed to validate auth event"
_, err := nip42.ValidateAuthEvent(
&e.Event,
state.Challenge,
h.relayURL,
nip42.WithCustomVerificator(func(nostrEvent *nostr.Event) (bool, error) {
return (&model.Event{Event: *nostrEvent}).CheckSignature()
}))
if err != nil {
resp.Reason = "failed to validate auth event: " + err.Error()

return &resp
}
Expand Down

0 comments on commit 64e0cc2

Please sign in to comment.