UNPKG

node-red-contrib-nostr

Version:

Node-RED nodes for seamless Nostr protocol integration. Features robust WebSocket handling, event filtering, and NPUB-based routing. Built with TypeScript for type safety and extensive testing. Perfect for Nostr automation flows.

36 lines (35 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ContactList = void 0; const event_1 = require("../core/event"); class ContactList { static parseContactList(event) { if (event.kind !== 3) throw new Error('Not a contact list event'); return event.tags .filter(tag => tag[0] === 'p') .map(tag => ({ pubkey: tag[1], relayUrl: tag[2] || '', petname: tag[3] })); } static async createContactListEvent(contacts, privateKey) { const tags = contacts.map(contact => [ 'p', contact.pubkey, contact.relayUrl, contact.petname || '' ]); return await event_1.EventBuilder.createEvent(3, '', // Content can be empty or contain additional metadata privateKey, tags); } static getContactListFilter(pubkey) { return { kinds: [3], authors: [pubkey], limit: 1 }; } } exports.ContactList = ContactList;