mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2026-07-22 07:48:27 +00:00
verify event should catch exceptions from basic validation.
This commit is contained in:
2
jsr.json
2
jsr.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nostr/tools",
|
||||
"version": "2.23.1",
|
||||
"version": "2.23.2",
|
||||
"exports": {
|
||||
".": "./index.ts",
|
||||
"./core": "./core.ts",
|
||||
|
||||
@@ -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
12
pure.ts
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user