nip46: fixes from nak bunker tests.

This commit is contained in:
fiatjaf
2025-04-22 08:37:34 -03:00
parent b92e70270d
commit 631ff67d52
2 changed files with 8 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ func NewDynamicSigner(
onEventSigned func(event nostr.Event),
) DynamicSigner {
return DynamicSigner{
sessions: make(map[nostr.PubKey]Session),
getHandlerSecretKey: getHandlerSecretKey,
getUserKeyer: getUserKeyer,
authorizeSigning: authorizeSigning,
@@ -51,6 +52,9 @@ func NewDynamicSigner(
}
func (p *DynamicSigner) GetSession(clientPubkey nostr.PubKey) (Session, bool) {
p.Lock()
defer p.Unlock()
session, exists := p.sessions[clientPubkey]
if exists {
return session, true

View File

@@ -26,10 +26,14 @@ type StaticKeySigner struct {
func NewStaticKeySigner(secretKey [32]byte) StaticKeySigner {
return StaticKeySigner{
secretKey: secretKey,
sessions: make(map[nostr.PubKey]Session),
}
}
func (p *StaticKeySigner) GetSession(clientPubkey nostr.PubKey) (Session, bool) {
p.Lock()
defer p.Unlock()
session, ok := p.sessions[clientPubkey]
return session, ok
}