Handle failure to derive event hash
This commit is contained in:
+2
-2
@@ -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
@@ -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),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user