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 <yonle@lecturify.net>
This commit is contained in:
Yonle 2024-03-02 18:07:30 +07:00
parent f148914ed8
commit 348830c577

View File

@ -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 <private_keys>.