From a9188ae1607d8cd2fae347340984e243fe3d39d8 Mon Sep 17 00:00:00 2001 From: Yonle Date: Sun, 18 Feb 2024 12:56:00 +0700 Subject: [PATCH] auth: fix bug on using event validation Signed-off-by: Yonle --- auth.js | 4 ++-- bouncer.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/auth.js b/auth.js index f17cdba..4325113 100644 --- a/auth.js +++ b/auth.js @@ -1,8 +1,8 @@ -const { verifyEvent } = require("nostr-tools"); +const { validateEvent, verifyEvent } = require("nostr-tools"); const { authorized_keys, private_keys } = require("./config"); module.exports = (authKey, data, ws, req) => { - if (!verifyEvent(data)) { + if (!validateEvent(data) || !verifyEvent(data)) { ws.send(JSON.stringify(["NOTICE", "error: invalid challenge response."])); return false; } diff --git a/bouncer.js b/bouncer.js index 396353d..8c49612 100644 --- a/bouncer.js +++ b/bouncer.js @@ -2,7 +2,7 @@ const { version } = require("./package.json"); const WebSocket = require("ws"); const querystring = require("querystring"); -const { verifyEvent, nip19, matchFilters, mergeFilters, getFilterLimit } = require("nostr-tools"); +const { validateEvent, nip19, matchFilters, mergeFilters, getFilterLimit } = require("nostr-tools"); const auth = require("./auth.js"); const nip42 = require("./nip42.js"); @@ -64,7 +64,7 @@ module.exports = (ws, req, onClose) => { switch (data[0]) { case "EVENT": if (!authorized) return; - if (!verifyEvent(data[1])) return ws.send(JSON.stringify(["NOTICE", "error: invalid event"])); + if (!validateEvent(data[1])) return ws.send(JSON.stringify(["NOTICE", "error: invalid event"])); if (data[1].kind == 22242) return ws.send(JSON.stringify(["OK", data[1]?.id, false, "rejected: kind 22242"])); if (