Closed gzuuus closed 5 months ago
@gzuuus You can use the method .rawEvent()
on a NDKEvent. The NDKUserProfile is being generated from a NDKEvent afaik. I don't know if this method also works on a NDKUserProfile object..
No, I was trying it already 👍
An alternative way would be fetching the event directly.
const filter = {
kinds: [0],
authors: [user.pubkey]
}
const p = await ndk.fetchEvent(filter)
p.rawEvent()
Yes of course, the problem with this approach is that it feels a bit convoluted to fetch the event like that and then set NDKUserProfile
based on it. It would be so convenient to have it already when you call fetchUserProfile()
@gzuuus sorry it's taken a while.
When NDK fetches events it's validating them (verifying signatures) on the way in the door. Is there some other type of verification that you need to do? The way that NDKUserProfile works, it's already storing all the fields it finds in the event content JSON blob, even if they aren't known fields. So I'm not sure if this would actually be beneficial or just mean that we're storing the same data twice.
Yes, that's great. In my specific use case, I need the complete Kind0 event to store it in my database. Since the event itself is a signed document by the author, it wouldn't require any extra authentication to be added. What I'm missing is having access to this complete signed event. Ideally, all I would need is the event ID and signature to reconstruct it, but there are several factors that make this approach unreliable in NDK. For instance, fetchUserProfile() maps the profile data into a more standardized structure (which is great and very convenient), but this makes it difficult to reliably reconstruct the event from the available information (using the ID and signature). Ultimately, the benefit is that NDK can be better integrated into more custom solutions that go beyond simply displaying data on the client-side.
What do you think? Can you think of another solution for this, maybe it could be something optional like a prop for fetUserProfile, for example storeEvent: bolean
. Let me know what you think, happy to code it.
Just updated the pr to make store profile event opt-in
I was wondering if it would be possible to get the raw event from the user metadata (kind:0). It would be interesting if
fetchUserProfile()
orNDKUser
had a method that would allow you to access the kind:0, so you could validate the event.