kind-0 / nsecbunkerd

nsecbunker daemon
https://nsecbunker.com
MIT License
126 stars 36 forks source link

Run time error when admin.npubs is not empty #34

Open seanmurphy1661 opened 7 months ago

seanmurphy1661 commented 7 months ago

I've stood up nsecbunkerd the hard way. And I'm encountering:

/home/ubuntu/code/nsecbunkerd/node_modules/nostr-tools/lib/cjs/index.js:1243
  let cryptoKey = await crypto.subtle.importKey("raw", normalizedKey, { name: "AES-CBC" }, false, ["encrypt"]);
                  ^

ReferenceError: crypto is not defined
    at Object.encrypt (/home/ubuntu/code/nsecbunkerd/node_modules/nostr-tools/lib/cjs/index.js:1243:19)
    at _NDKPrivateKeySigner.encrypt (/home/ubuntu/code/nsecbunkerd/node_modules/@nostr-dev-kit/ndk/dist/index.js:4138:45)
    at _NDKEvent.encrypt (/home/ubuntu/code/nsecbunkerd/node_modules/@nostr-dev-kit/ndk/dist/index.js:1485:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async dmUser (/home/ubuntu/code/nsecbunkerd/dist/daemon/index.js:845:3)

Node.js v18.19.1

My /config/nsecbunkger.json:

{
  "nostr": {
    "relays": [
      "wss://nostr.1661.io",
      "wss://relay.nsecbunker.com"
    ]
  },
  "admin": {
    "npubs": [
      "npub158r9ez32tfyxg9nyjwj3c8rdt9f4ndsv0jszdy2kllaq5fz53n9sqaetzr"
    ],
    "adminRelays": [
      "wss://relay.nsecbunker.com"
    ],
    "key": "****",
    "notifyAdminsOnBoot": true
  },
  "database": "sqlite://nsecbunker.db",
  "logs": "./nsecbunker.log",
  "keys": {
    "nostr1661": {
      "iv": "****",
      "data": "****"
    }
  },
  "verbose": true,
  "version": "0.10.3"
}

Running on a plain vanilla ubuntu 22.04 LTS, Node v18.19.1

The setting admin.npubs seems to be the main issue. When I set it to [], nsecbunkerd starts up and seems to be working. However, no admin.npubs, no admin. The admin ui at apps.nsecbunkerd.com rightfully won't connect.

seanmurphy1661 commented 7 months ago

Follow up on this ticket. The call to dmUser is only triggered on startup when "notifyAdminsOnBoot": true, so setting it to false is a work around for now.