22 lines
550 B
JavaScript
22 lines
550 B
JavaScript
|
|
const { generatePrivateKey, getPublicKey, finalizeEvent } = require('nostr-tools');
|
|
|
|
const privateKey = generatePrivateKey();
|
|
const publicKey = getPublicKey(privateKey);
|
|
|
|
const nonce = process.argv[2]; // Nonce from challenge endpoint
|
|
|
|
if (!nonce) {
|
|
console.error("Usage: node gen_nostr_event.js <nonce>");
|
|
process.exit(1);
|
|
}
|
|
|
|
const event = finalizeEvent({
|
|
kind: 27235,
|
|
created_at: Math.floor(Date.now() / 1000),
|
|
tags: [['challenge', nonce]],
|
|
content: "NIP-27235 challenge response",
|
|
}, privateKey);
|
|
|
|
console.log(JSON.stringify(event));
|