From 91b15ad49092c314dd6d3483aec47f0be7a37506 Mon Sep 17 00:00:00 2001 From: polwex Date: Thu, 11 Sep 2025 01:50:29 +0700 Subject: ihategit --- shim/ws-shim/src/nostr.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 shim/ws-shim/src/nostr.ts (limited to 'shim/ws-shim/src/nostr.ts') diff --git a/shim/ws-shim/src/nostr.ts b/shim/ws-shim/src/nostr.ts new file mode 100644 index 0000000..0b084b6 --- /dev/null +++ b/shim/ws-shim/src/nostr.ts @@ -0,0 +1,24 @@ +import { finalizeEvent, validateEvent, verifyEvent } from "nostr-tools"; +import type { NostrEvent } from "./types"; +import { hexToBytes } from "nostr-tools/utils"; + +export function validate(event: NostrEvent) { + console.log("constructing event in js"); + const priv = + "d862c25aacfae2f66380448eafdeefeccb970a382f2ff185f3e0c5a538d60e35"; + const sk = hexToBytes(priv); + const raw = { + kind: event.kind, + created_at: event.created_at, + tags: event.tags, + content: event.content, + }; + const ev = finalizeEvent(raw, sk); + console.log("js event", ev); + console.log("validating my event", event); + const ok = validateEvent(event); + console.log("is valid?", ok); + const ok2 = verifyEvent(event); + console.log("is verified?", ok2); + return ok && ok2; +} -- cgit v1.2.3