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.

43 lines (42 loc) 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InternetIdentifier = void 0; class InternetIdentifier { static async verify(identifier, pubkey) { try { const [name, domain] = identifier.split('@'); if (!name || !domain) return false; const url = `https://${domain}/.well-known/nostr.json?name=${name}`; const response = await fetch(url); const data = await response.json(); return data.names[name] === pubkey; } catch { return false; } } static parseIdentifier(identifier) { const [name, domain] = identifier.split('@'); if (!name || !domain) { throw new Error('Invalid NIP-05 identifier format'); } return { name, domain }; } static async getRelays(identifier, pubkey) { const { name, domain } = this.parseIdentifier(identifier); const url = `https://${domain}/.well-known/nostr.json?name=${name}`; try { const response = await fetch(url); const data = await response.json(); if (data.relays && data.relays[pubkey]) { return data.relays[pubkey]; } return []; } catch { return []; } } } exports.InternetIdentifier = InternetIdentifier;