diff --git a/config.js.example b/config.js.example index 834b1d0..cb9239c 100644 --- a/config.js.example +++ b/config.js.example @@ -39,8 +39,13 @@ module.exports = { // Warning: Ensure that is NOT empty so only could access this bostr bouncer private_keys: { - // "pubkey-in-hex": "privatekey" + // "pubkey-in-hex": "privatekey", + // "pubkey-in-hex": "nsec ...." } + // Tip: If you want to convert your pubkey/privatekey to hex, + // You could run the following command: + // $ node hexconverter.js npub.... + // $ node hexconverter.js nsec.... // Server information. // Only for when nostr client requesting server information. diff --git a/hexconverter.js b/hexconverter.js new file mode 100644 index 0000000..c174847 --- /dev/null +++ b/hexconverter.js @@ -0,0 +1,8 @@ +const { nip19 } = require("nostr-tools"); +const argv = process.argv.slice(2); + +if (!argv.length) return console.log("Usage: node hexconverter.js ...."); + +for (i of argv) { + console.log(nip19.decode(i).data); +} diff --git a/nip42.js b/nip42.js index 6c0aa59..608246f 100644 --- a/nip42.js +++ b/nip42.js @@ -1,7 +1,9 @@ -const { getEventHash, getSignature } = require("nostr-tools"); +const { getEventHash, getSignature, nip19 } = require("nostr-tools"); module.exports = (relay, pubkey, privkey, challenge) => { if (!privkey) return; + if (privkey.startsWith("nsec")) privkey = nip19.decode(privkey).data; + let signed_challenge = { pubkey, created_at: Math.floor(Date.now() / 1000),