From 348830c577f1077e47bfd1bde50b7d1bd87f4bef Mon Sep 17 00:00:00 2001 From: Yonle Date: Sat, 2 Mar 2024 18:07:30 +0700 Subject: [PATCH] bouncer: absurd harmless bug that does not harm anyone but technically annoying As it turns out, private_keys !== {} is not enough. When i do some experiment in Node.js REPL to find out the cause why the heck bouncer.js still sends AUTH to user even with private_keys being empty ({}), This absurd result happens: Welcome to Node.js v20.11.1. Type ".help" for more information. > {} === {} false > {} !== {} true > {} != {} true > {} == {} false What the fuck.. Signed-off-by: Yonle --- bouncer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bouncer.js b/bouncer.js index b2251c6..d19b211 100644 --- a/bouncer.js +++ b/bouncer.js @@ -45,7 +45,7 @@ module.exports = (ws, req, onClose) => { authKey = Date.now() + Math.random().toString(36); authorized = false; ws.send(JSON.stringify(["AUTH", authKey])); - } else if (private_keys !== {}) { + } else if (Object.keys(private_keys).length) { // If there is no whitelist, Then we ask to client what is their public key. // We will enable NIP-42 function for this session if user pubkey was available & valid in .