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",
|
"name": "@nostr/tools",
|
||||||
"version": "2.23.1",
|
"version": "2.23.2",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./index.ts",
|
".": "./index.ts",
|
||||||
"./core": "./core.ts",
|
"./core": "./core.ts",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"name": "nostr-tools",
|
"name": "nostr-tools",
|
||||||
"version": "2.23.1",
|
"version": "2.23.2",
|
||||||
"description": "Tools for making a Nostr client.",
|
"description": "Tools for making a Nostr client.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
12
pure.ts
12
pure.ts
@@ -23,13 +23,13 @@ class JS implements Nostr {
|
|||||||
verifyEvent(event: Event): event is VerifiedEvent {
|
verifyEvent(event: Event): event is VerifiedEvent {
|
||||||
if (typeof event[verifiedSymbol] === 'boolean') return event[verifiedSymbol]
|
if (typeof event[verifiedSymbol] === 'boolean') return event[verifiedSymbol]
|
||||||
|
|
||||||
const hash = getEventHash(event)
|
|
||||||
if (hash !== event.id) {
|
|
||||||
event[verifiedSymbol] = false
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
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))
|
const valid = schnorr.verify(hexToBytes(event.sig), hexToBytes(hash), hexToBytes(event.pubkey))
|
||||||
event[verifiedSymbol] = valid
|
event[verifiedSymbol] = valid
|
||||||
return valid
|
return valid
|
||||||
|
|||||||
Reference in New Issue
Block a user