diff options
Diffstat (limited to 'shim')
-rw-r--r-- | shim/ws-shim/src/nostr.ts | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/shim/ws-shim/src/nostr.ts b/shim/ws-shim/src/nostr.ts index b123bc8..f3e5a47 100644 --- a/shim/ws-shim/src/nostr.ts +++ b/shim/ws-shim/src/nostr.ts @@ -1,11 +1,32 @@ -import { finalizeEvent, nip19, validateEvent, verifyEvent } from "nostr-tools"; +import { + finalizeEvent, + getPublicKey, + nip19, + validateEvent, + verifyEvent, +} from "nostr-tools"; import type { NostrEvent } from "./types"; import { hexToBytes } from "nostr-tools/utils"; export function validate(event: NostrEvent) { + const ok = validateEvent(event); + const ok2 = verifyEvent(event); + return ok && ok2; +} + +export function checkPubkey(pubkey: string): boolean { + const npub = nip19.npubEncode(pubkey); + console.log({ npub, hex: pubkey }); + return false; +} + +function testKeys(event: NostrEvent) { console.log("constructing event in js"); + // pub="3f4dd2220bdeeb153eea8908932d83756a488ee77dbd38cec4fd4bbe03997f333" + // priv="8224d719fb5a115272f1e63d4c6b65311a3e6bce323189c3094e891369cef715" const priv = - "d862c25aacfae2f66380448eafdeefeccb970a382f2ff185f3e0c5a538d60e35"; + "8224d719fb5a115272f1e63d4c6b65311a3e6bce323189c3094e891369cef715"; + // "d862c25aacfae2f66380448eafdeefeccb970a382f2ff185f3e0c5a538d60e35"; const sk = hexToBytes(priv); const raw = { kind: event.kind, @@ -13,18 +34,7 @@ export function validate(event: NostrEvent) { tags: event.tags, content: event.content, }; - const ev = finalizeEvent(raw, sk); - console.log("js event", ev); + const jsev = finalizeEvent(raw, sk); + console.log("js event", jsev); 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; -} - -export function checkPubkey(pubkey: string): boolean { - const npub = nip19.npubEncode(pubkey); - console.log({ npub, hex: pubkey }); - return false; } |