aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/nip07.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/nip07.ts')
-rw-r--r--src/lib/nip07.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/nip07.ts b/src/lib/nip07.ts
new file mode 100644
index 00000000..b93779dc
--- /dev/null
+++ b/src/lib/nip07.ts
@@ -0,0 +1,11 @@
+import { finalizeEvent } from 'nostr-tools/pure';
+import { getPrivateKey } from '$lib/nostr';
+
+export const signEvent = async (event: object, user: object): object => {
+ if (await window.nostr.getPublicKey() === user.pubkey) {
+ return window.nostr.signEvent(event);
+ } else {
+ const sk = await getPrivateKey();
+ return finalizeEvent(event, sk);
+ }
+}