verify event should catch exceptions from basic validation.

This commit is contained in:
fiatjaf
2026-02-26 18:10:17 -03:00
parent 54199504a7
commit 1c1e2cc51a
3 changed files with 8 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@nostr/tools",
"version": "2.23.1",
"version": "2.23.2",
"exports": {
".": "./index.ts",
"./core": "./core.ts",

View File

@@ -1,7 +1,7 @@
{
"type": "module",
"name": "nostr-tools",
"version": "2.23.1",
"version": "2.23.2",
"description": "Tools for making a Nostr client.",
"repository": {
"type": "git",

12
pure.ts
View File

@@ -23,13 +23,13 @@ class JS implements Nostr {
verifyEvent(event: Event): event is VerifiedEvent {
if (typeof event[verifiedSymbol] === 'boolean') return event[verifiedSymbol]
const hash = getEventHash(event)
if (hash !== event.id) {
event[verifiedSymbol] = false
return false
}
try {
const hash = getEventHash(event)
if (hash !== event.id) {
event[verifiedSymbol] = false
return false
}
const valid = schnorr.verify(hexToBytes(event.sig), hexToBytes(hash), hexToBytes(event.pubkey))
event[verifiedSymbol] = valid
return valid