some helper.

Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
Yonle 2023-11-16 22:07:07 +07:00
parent 74c2e4c21f
commit 3be8e325e1
3 changed files with 17 additions and 2 deletions

View File

@ -39,8 +39,13 @@ module.exports = {
// Warning: Ensure that <authorized_keys> is NOT empty so only <authorized_keys> 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.

8
hexconverter.js Normal file
View File

@ -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 <npub....|nsec....> ....");
for (i of argv) {
console.log(nip19.decode(i).data);
}

View File

@ -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),