Handle failure to derive event hash

This commit is contained in:
Jon Staab
2024-01-01 09:19:17 -08:00
parent 2a402f1190
commit 0af0375f62
2 changed files with 9 additions and 3 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "paravel", "name": "paravel",
"version": "0.4.16", "version": "0.4.17",
"description": "Yet another toolkit for nostr", "description": "Yet another toolkit for nostr",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
@@ -24,7 +24,7 @@
"build" "build"
], ],
"scripts": { "scripts": {
"pub": "pnpm install && npm run lint && tsc-multi && pnpm publish", "pub": "pnpm install && pnpm run lint && tsc-multi && pnpm publish",
"build": "tsc-multi", "build": "tsc-multi",
"clean": "gts clean", "clean": "gts clean",
"lint": "gts lint", "lint": "gts lint",
+7 -1
View File
@@ -75,7 +75,13 @@ export const createEvent = (kind: number, {content = "", tags = [], created_at =
export const hasValidSignature = cached<string, boolean, [Event]>({ export const hasValidSignature = cached<string, boolean, [Event]>({
maxSize: 10000, maxSize: 10000,
getKey: ([e]: [Event]) => [getEventHash(e), e.sig].join(":"), getKey: ([e]: [Event]) => {
try {
return [getEventHash(e), e.sig].join(":")
} catch (err) {
return 'invalid'
}
},
getValue: ([e]: [Event]) => verifySignature(e), getValue: ([e]: [Event]) => verifySignature(e),
}) })