validate that the root nip05 of the desired domain points to the nsecbunker's key

This commit is contained in:
Pablo Fernandez
2024-01-02 12:44:54 +00:00
parent 77d8848a01
commit fddc592f50
2 changed files with 20 additions and 2 deletions

View File

@@ -150,7 +150,7 @@ With this configuration users will be able to:
* get an lnbits-based LN wallet * get an lnbits-based LN wallet
* get zapping capabilitiyes through nostdress * get zapping capabilitiyes through nostdress
For this to work you'll need to run, in addition to `nsecbunkerd`, an lnbits instance and a [nostdress](https://github.com/believethehype/nostdress) instance. For this to work you'll need to run, in addition to `nsecbunkerd`, an lnbits instance and a [nostdress](https://github.com/believethehype/nostdress) instance. Your LNBits **needs to have the user manager extension enabled**.
- [ ] TODO: Add NWC support - [ ] TODO: Add NWC support

View File

@@ -19,8 +19,25 @@ async function nip89announcement(configData: IConfig) {
const hasNip89 = !!config.nip89; const hasNip89 = !!config.nip89;
if (!hasNip89) continue; if (!hasNip89) continue;
const signer = new NDKPrivateKeySigner(configData.admin.key);
const signerUser = await signer.user();
const profile = config.nip89!.profile; const profile = config.nip89!.profile;
const relays = config.nip89!.relays; const relays = config.nip89!.relays;
const nip05 = `_@${domain}`;
// make sure the nip05 correctly points to this pubkey
const uservianip05 = await NDKUser.fromNip05(nip05);
if (!uservianip05 || uservianip05.pubkey !== signerUser.pubkey) {
console.log(`${nip05} does not point to this nsecbunker's key`);
if (uservianip05) {
console.log(`${nip05} points to ${uservianip05.pubkey} instead of ${signerUser.pubkey}`)
} else {
console.log(`${nip05} needs to point to ${signerUser.pubkey}`)
}
continue
}
if (!profile) { if (!profile) {
console.log(`❌ No NIP-89 profile in configuration of ${domain}!`); console.log(`❌ No NIP-89 profile in configuration of ${domain}!`);
@@ -36,7 +53,7 @@ async function nip89announcement(configData: IConfig) {
const hasNostrdress = !!config.wallet?.lnbits?.nostdressUrl; const hasNostrdress = !!config.wallet?.lnbits?.nostdressUrl;
const ndk = new NDK({explicitRelayUrls: relays}); const ndk = new NDK({explicitRelayUrls: relays});
ndk.signer = new NDKPrivateKeySigner(configData.admin.key); ndk.signer = signer;
ndk.connect(5000).then(async () => { ndk.connect(5000).then(async () => {
const event = new NDKAppHandlerEvent(ndk, { const event = new NDKAppHandlerEvent(ndk, {
tags: [ tags: [
@@ -70,6 +87,7 @@ async function nip89announcement(configData: IConfig) {
event.tags.push(["d", NDKKind.NostrConnect.toString()]); event.tags.push(["d", NDKKind.NostrConnect.toString()]);
} }
profile.nip05 = nip05;
event.content = JSON.stringify(profile); event.content = JSON.stringify(profile);
event.tags.push(["k", NDKKind.NostrConnect.toString()]) event.tags.push(["k", NDKKind.NostrConnect.toString()])
if (hasWallet && hasNostrdress) { if (hasWallet && hasNostrdress) {