From 3a57aea96e8bb6ba7d6c16a9d218cd80d0700134 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sat, 25 Feb 2023 13:47:09 -0300 Subject: [PATCH] use full event when signing with the extension. because if the client is building the event with the pubkey A, but the actual key used by the extension is B, using just the `.sig` property of the value returned by `window.nostr.signEvent()` will cause the event to be invalid. --- src/agent/keys.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/agent/keys.ts b/src/agent/keys.ts index b88ca137..66a000f9 100644 --- a/src/agent/keys.ts +++ b/src/agent/keys.ts @@ -28,11 +28,13 @@ const sign = async event => { event.pubkey = get(pubkey) event.id = getEventHash(event) - event.sig = ext - ? prop('sig', await ext.signEvent(event)) - : signEvent(event, get(privkey)) - return event + if (ext) { + return await ext.signEvent(event) + } else { + event.sign = signEvent(event, get(privkey)) + return event + } } const getCrypt = () => {