Importing a Nostr profile pointer without mistaking a relay hint for identity
A contact shares an nprofile with two relay URLs. The receiver needs one author key for its subscription and may use the URLs to locate events. Passing the entire share string as an author filter can yield an empty feed.
Extract the typed field after Bech32 decoding
Use a NIP-19 decoder to validate the checksum and extract the binary payload. For nprofile, type zero holds the 32-byte public key and type one holds a relay hint. The Node.js fixture shows just one binary type-length-value record after decoding. It prints type zero, length 32 and the key in hexadecimal.
const key = Buffer.alloc(32, 0xab);
const value = Buffer.concat([Buffer.from([0,32]), key]);
console.log(value[0], value[1], value.subarray(2).toString("hex"));
Build a filter that survives a relay change
Use the extracted hex key in authors. Store relay hints separately so a second share of the same profile adds a location without creating a second identity. Check field lengths before slicing untrusted input. If a hinted relay later becomes unavailable, another relay can still serve events signed by the same key.