From cce7cd00f9a6cc78855e5262adce70198e5027f4 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Wed, 16 Feb 2022 06:41:20 -0300 Subject: [PATCH] change interface so `signEvent()` returns the full event with pubkey, sig and id. --- README.md | 4 ++-- extension/background.js | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5d41098..fd5f15e 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ It provides a `window.nostr` object which has the following methods: ``` async window.nostr.getPublicKey(): string // returns your public key as hex -async window.nostr.signEvent(event): string // returns the signature as hex -async window.nostr.getRelays(): {} // returns a list of relays +async window.nostr.signEvent(event): Event // returns the full event object signed +async window.nostr.getRelays(): { [url: string]: RelayPolicy } // returns a map of relays async window.nostr.nip04.encrypt(pubkey, plaintext): string // returns ciphertext+iv as specified in nip04 async window.nostr.nip04.decrypt(pubkey, ciphertext): string // takes ciphertext+iv as specified in nip04 ``` diff --git a/extension/background.js b/extension/background.js index f789dea..45e9099 100644 --- a/extension/background.js +++ b/extension/background.js @@ -66,11 +66,10 @@ async function handleContentScriptMessage({type, params, host}) { if (!event.pubkey) event.pubkey = getPublicKey(sk) if (!event.id) event.id = getEventHash(event) - if (!validateEvent(event)) return {error: 'invalid event'} - let signature = await signEvent(event, sk) - return signature + event.sig = await signEvent(event, sk) + return event } case 'nip04.encrypt': { let {peer, plaintext} = params