fix auth.js didn't work with noscraper

Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
Yonle 2024-05-10 17:23:23 +07:00
parent e1fbfbf06d
commit 60c1674fd6

View File

@ -1,9 +1,9 @@
"use strict";
const { validateEvent, verifyEvent } = require("nostr-tools");
const { authorized_keys, private_keys } = require(process.env.BOSTR_CONFIG_PATH || "./config");
const { authorized_keys, private_keys, noscraper } = require(process.env.BOSTR_CONFIG_PATH || "./config");
module.exports = (authKey, data, ws, req) => {
if (!(authorized_keys?.length || Object.keys(private_keys).length)) return; // do nothing
if (!authorized_keys?.length && !Object.keys(private_keys).length && !noscraper) return; // do nothing
if (!validateEvent(data) || !verifyEvent(data)) {
ws.send(JSON.stringify(["NOTICE", "error: invalid challenge response."]));
return false;