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
+7 -1
View File
@@ -75,7 +75,13 @@ export const createEvent = (kind: number, {content = "", tags = [], created_at =
export const hasValidSignature = cached<string, boolean, [Event]>({
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),
})