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", "name": "nsecbunkerd",
"version": "0.10.1", "version": "0.10.2",
"description": "nsecbunker daemon", "description": "nsecbunker daemon",
"main": "dist/index.js", "main": "dist/index.js",
"bin": { "bin": {

View File

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

View File

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