This commit is contained in:
Pablo Fernandez 2024-01-31 13:58:53 +00:00
parent 64a41e98ab
commit b5d4694e36
3 changed files with 19 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{
"name": "nsecbunkerd",
"version": "0.10.1",
"version": "0.10.2",
"description": "nsecbunker daemon",
"main": "dist/index.js",
"bin": {

View File

@ -2,6 +2,7 @@ import "websocket-polyfill";
import NDK, { NDKUser, NDKEvent, NDKPrivateKeySigner, NDKNip46Signer, NostrEvent } from '@nostr-dev-kit/ndk';
import fs from 'fs';
const args = process.argv;
const command = process.argv[2];
let remotePubkey = process.argv[3];
let content = process.argv[4];
@ -11,6 +12,13 @@ let signer: NDKNip46Signer;
let ndk: NDK;
let remoteUser: NDKUser;
const relaysIndex = args.findIndex(arg => arg === '--relays');
let relays: string[] = [];
if (relaysIndex !== -1 && args[relaysIndex + 1]) {
relays = args[relaysIndex + 1].split(',');
}
if (!command) {
console.log('Usage: node src/client.js <command> <remote-npub> <content> [--dont-publish] [--debug] [--pk <key>]');
console.log('');
@ -19,16 +27,19 @@ if (!command) {
console.log(`\t<content>: sign flow: event JSON to sign (no need for pubkey or id fields) | or kind:1 content string to sign\n`);
console.log(`\t create_account flow: [desired-nip05[,desired-domain,[email]]]`);
console.log('\t--debug: enable debug mode');
console.log('\t--relays: list of relays to publish to (separated by commas)');
process.exit(1);
}
async function createNDK(): Promise<NDK> {
const ndk = new NDK({
explicitRelayUrls: ['wss://relay.nsecbunker.com'],
explicitRelayUrls: [
'wss://relay.nsecbunker.com',
...relays
],
enableOutboxModel: false
});
if (debug) {
ndk.pool.on('relay:connect', () => console.log('✅ connected'));
ndk.pool.on('relay:disconnect', () => console.log('❌ disconnected'));
}
await ndk.connect(5000);
@ -177,9 +188,13 @@ function signFlow() {
console.log(event.sig);
}
if (!dontPublish) {
const relaysPublished = await event.publish();
}
process.exit(0);
} catch(e) {
console.log('sign error', e);
}
}, 2000);
}
}

View File

@ -110,8 +110,6 @@ async function nip89announcement(configData: IConfig) {
export async function start(opts: IOpts) {
const configData = await getCurrentConfig(opts.config);
console.log(opts)
if (opts.adminNpubs && opts.adminNpubs.length > 0) {
configData.admin.npubs = opts.adminNpubs;
console.log(`✅ adminNpubs: ${opts.adminNpubs}`)