Skip to content

Add imeta tag#904

Merged
staab merged 1 commit into
nostr-protocol:masterfrom
coracle-social:imeta
Feb 1, 2024
Merged

Add imeta tag#904
staab merged 1 commit into
nostr-protocol:masterfrom
coracle-social:imeta

Conversation

@staab
Copy link
Copy Markdown
Member

@staab staab commented Nov 27, 2023

This is adapted from Damus' DIPS repo: https://github.com/damus-io/dips/blob/master/01.md. I don't love the format, but I think there are probably a good number of events in the wild already using it. This PR is backwards-compatible except for renaming sha256 to x following NIP 94.

@jb55 correct me if I'm wrong and there is an opportunity to revisit the format. My preference would be to make the url the first argument of the tag rather than the value of the url key to make it more conventional. It would also be nice to use a query string or json or something instead of space delimited data.

@staab staab requested a review from jb55 November 27, 2023 22:50
@staab staab mentioned this pull request Nov 27, 2023
@v0l
Copy link
Copy Markdown
Member

v0l commented Nov 28, 2023

snort is pushing some imeta tags when using nostr.build, happy to see this added to nips:
https://git.v0l.io/Kieran/snort/src/commit/509228d53287b62cc79c9f4d28fdfe1ac63dd029/packages/app/src/Element/Event/Create/NoteCreator.tsx#L198-L205

@fabianfabian
Copy link
Copy Markdown
Contributor

Nostur is already reading imeta tags, and I am now in the process of adding them to new posts. I don't have strong opinion against changing the spec but changing it now would mean I would have to support 2 versions because there are already many imeta posts out there.

@fiatjaf
Copy link
Copy Markdown
Member

fiatjaf commented Nov 28, 2023

I think there is no way to change this. Let's merge it.

@vitorpamplona
Copy link
Copy Markdown
Collaborator

vitorpamplona commented Nov 28, 2023

I continue my position that static content should never be referenced with URLs inside Nostr due to:

  1. the centralizing nature of domain name registrars,
  2. the full state control of the DNS resolution stack,
  3. the centralizing nature of the domain name resolution to a single provider
  4. the immutability break of today's extremely frequent editing of such images by the image host without the author's approval or review
  5. the potential for rug-pulling a massive amount of users at once by a hostile takeover of an image host provider to replace image and video files of popular Nostr contents for profit (ads, porn, SEO-hacking, etc) or criminal activities (scams, impersonation, etc).

The dynamic nature of the content resolution makes it impossible for a Nostr or Web crawler to correctly weigh the content of such URLs since the crawler cannot verify if the image host has changed the contents without the author's consent or not, making Nostr search way more difficult to correctly index.

But I won't block adding this to the repo if people are using it. 2+ clients rule always win.

I just think it is a huge mistake to keep building on top of a structure that doesn't align with Nostr's goals.

@arthurfranca
Copy link
Copy Markdown
Contributor

arthurfranca commented Nov 28, 2023

I don't get why not use NIP-54.
NIP-54 reuses and supports all NIP-94 tag names and works both inline (in .content) or inside a tag.

For fallback urls it would be like this:
https://abc.com/img.jpg#url=<fallback-url-1>&url=<fallback-url-2> and it would work inside .content for both kind:1 and kind:30023 markdown.

It is like query params but using # instead of ? so that the params don't get sent to the server (in the example an <a> <img> html tag with the src as https://abc.com/img.jpg#url=<fallback-url-1>&url=<fallback-url-2> would request just https://abc.com/img.jpg and could use onerror handler to swap src to the fallback url)

@jb55
Copy link
Copy Markdown
Contributor

jb55 commented Nov 28, 2023 via email

@jb55
Copy link
Copy Markdown
Contributor

jb55 commented Nov 28, 2023 via email

@jb55
Copy link
Copy Markdown
Contributor

jb55 commented Nov 28, 2023 via email

@mattn
Copy link
Copy Markdown
Member

mattn commented Nov 28, 2023

I don't strong opinion, but is better to be two elements tags? since this can pass empty value like ["alt": ""]

{
  "content": "More image metadata tests don’t mind me https://nostr.build/i/my-image.jpg",
  "kind": 1,
  "tags": [
    ["imeta"]
    ["url", "https://nostr.build/i/my-image.jpg"],
    ["blurhash", "eVF$^OI:${M{o#*0-nNFxakD-?xVM}WEWB%iNKxvR-oetmo#R-aen$"],
    ["dim", "3024x4032"],
    ["alt", "A scenic photo overlooking the coast of Costa Rica"],
    ["x", "<sha256 hash as specified in NIP 94>"],
    ["fallback", "https://nostrcheck.me/alt1.jpg"],
    ["fallback", "https://void.cat/alt1.jpg"]
  ]
}

@mattn
Copy link
Copy Markdown
Member

mattn commented Nov 28, 2023

Well, Sorry. I can't explain it well immediately, I mean it should be a nested structure.

@alexgleason
Copy link
Copy Markdown
Member

There really needs to be a way to represent media attachments that are not part of the text content. This is very common on platforms such as Twitter, Facebook, Instagram, email, Mastodon, and practically every other social platform users are accustomed to that isn't Medium, and it fills me with existential dread that we cannot do it on Nostr.

#751

@jb55
Copy link
Copy Markdown
Contributor

jb55 commented Nov 28, 2023 via email

@AsaiToshiya
Copy link
Copy Markdown
Collaborator

#751

I really like this idea.

@jb55
Copy link
Copy Markdown
Contributor

jb55 commented Nov 28, 2023 via email

@vitorpamplona
Copy link
Copy Markdown
Collaborator

Your tirade against URLs is bizarre. URLs are here to stay unless there are some fundamental changes to the internet itself. nostr is an internet protocol, it will naturally interact with other aspects of the internet and the web.

They can stay. I just find it dumb to have a decentralized protocol based on a centralized and even state-controlled infrastructure.

But people never pay attention to these things until they get rug pulled. I was rug-pulled once over DNS when doing signed payloads between two countries at war with one another. I learned my lesson.

@jb55
Copy link
Copy Markdown
Contributor

jb55 commented Nov 28, 2023

I think there are room for both approaches but not everyone is going to have the same threat model.

@vitorpamplona
Copy link
Copy Markdown
Collaborator

I think there are room for both approaches but not everyone is going to have the same threat model.

People always say that until somebody buys nostr.build out and start advertising fake Damus coins in the images of your own signed posts for everyone but your own location. People will be scammed by your own posts and you won't even see until it's too late.

That's the threat we should fix as soon as possible.

@alexgleason
Copy link
Copy Markdown
Member

What does this gain you over urls and metadata?

By replacing URLs with inline attachments in posts (which most clients do), we have inadvertently created an undocumented custom data format for Nostr similar to Markdown or HTML.

I just want to add imeta tags to my events, and clients will display them as attachments even if they don't match any URL in the post content.

@jb55
Copy link
Copy Markdown
Contributor

jb55 commented Nov 28, 2023 via email

@vitorpamplona
Copy link
Copy Markdown
Collaborator

vitorpamplona commented Nov 28, 2023

Then I would just add sha256 to imeta? I would download the image after upload and then hash it before posting.

Not just add but verify as well. Then that does solve one of the issues there.

Then you have the rest:

  • User tracking by the image host.
  • Posts might be broken when such a host disappears.
  • Image hosts might fully censor your past or just decrease the bandwidth/increase the latency for disliked persons.
  • Image hosts might request payment from downloaders before sending the image/video.

So many things can happen after the post is signed... all because people insist on specifying a host at the signing time.

@fabianfabian
Copy link
Copy Markdown
Contributor

For me the image dimensions and hash are the most important, this solves jumpy image loading and content rug replacement. Where this info is seems less relevant as long as its somewhere in the event, NIP-54 and imeta seems to solve it good enough, not sure why one would be better than the other, but imeta is already in use.

I don't think DMs is a good enough reason to use NIP-54, because DMs shouldn't leak any tags at all, this needs to be fixed on the DM level so you can add any tag probably in a way similar to NIP-51 lists. Otherwise for every spec that requires tags you need to find a special way to use it in DMs also.

@jb55
Copy link
Copy Markdown
Contributor

jb55 commented Nov 28, 2023 via email

@vitorpamplona
Copy link
Copy Markdown
Collaborator

vitorpamplona commented Nov 28, 2023

I don't think DMs is a good enough reason to use NIP-54, because DMs shouldn't leak any tags at all

Agree, DMs should never, ever have any public tag but the receiver's pubkey.

And static content (pictures, videos, pdfs, etc) transferred through DMs must always be encrypted to the receiver in the same way the content of the event is. We tested that expectation a few months back with our users. Neither a hidden but public link nor an image encrypted with a shareable secret is enough. People expect significant privacy on DM attachments.

@jb55
Copy link
Copy Markdown
Contributor

jb55 commented Nov 28, 2023 via email

@jb55
Copy link
Copy Markdown
Contributor

jb55 commented Nov 28, 2023 via email

@staab
Copy link
Copy Markdown
Member Author

staab commented Dec 1, 2023

Ok, I can't think of any real problems with that.

@cxplay
Copy link
Copy Markdown

cxplay commented Dec 4, 2023

The idea of rendering previews for URLs without some kind of metadata like imeta is fundamentally flawed. How do you render a preview for this URL? https://media.gleasonator.dev/ipfs/QmVLHE4WC6fbArqm2ndqqYcEsdPmZEHz3jTJGtup4QV5gB

Relying on the file extension is flawed. Some URLs (like above) do not have a file extension. Some file extensions are ambiguous, like .ts, which is both a TypeScript file and a video format. We need an explicit media type at the very least. Just because people are doing it currently doesn't mean it's good.

I have exactly the same problem. Not only images, but I can't control how other media in my note is displayed, or even how all nostr:xxx is rendered. Now I have to use NIP-23 to publish content in order to be able to control how these things are rendered the way I want them to be.
If I want to declare a URL as an image, then:
![alt](https://media.gleasonator.dev/ipfs/QmVLHE4WC6fbArqm2ndqqYcEsdPmZEHz3jTJGtup4QV5gB)
If I want to declare that the URL is just a URL and I don't want it to be previewed, then:
<https://gleasonator.com/pikachu.png>
If you want the URL to be previewed then:
[preview me](https://github.com/nostr-protocol/nips/pull/904)
But Markdown itself is an overly flexible and lagging markup language. The final question becomes "How can a user declare in plain text content that a section here is not plain text?" . How do I declare that the client should not display the preview the nostr:naddrxxx link?

@fiatjaf
Copy link
Copy Markdown
Member

fiatjaf commented Feb 1, 2024

Can you please decide on this versus the inline metadata? Otherwise we will end up everybody having to implement both in the long run.

@staab
Copy link
Copy Markdown
Member Author

staab commented Feb 1, 2024

Can you please decide on this versus the inline metadata? Otherwise we will end up everybody having to implement both in the long run.

Probably too late for that, but Coracle reads both and only publishes imeta.

@alexgleason
Copy link
Copy Markdown
Member

As a "requested-changes" person on this MR, I've conceded the point about not having URLs in the text. It's work-around-able.

We do need some kind of media tag, though. I wish it were just called media instead of imeta.

It would support images, videos, and any other type of file. The mime would be required, and it would determine which other fields matter and how they're used.

We get the feeling that things are set in stone and we can't change them. But Nostr is really still in its early stages. We absolutely can afford to change, and we'll be glad we did 5 years from now. So I would strongly suggest naming the tag media instead of imeta, and keeping everything else the same. But if we don't do that, I won't die. Either way, using a tag is 1000% better than inline URL fragments.

@fabianfabian
Copy link
Copy Markdown
Contributor

Nostur also reads both but only publishes imeta.

@jb55
Copy link
Copy Markdown
Contributor

jb55 commented Feb 1, 2024 via email

@fiatjaf
Copy link
Copy Markdown
Member

fiatjaf commented Feb 1, 2024

Snort also apparently reads and publishes imeta.

Looks like should merge this.

I think we should merge @alexgleason's code suggestions before.

@staab
Copy link
Copy Markdown
Member Author

staab commented Feb 1, 2024

@fiatjaf I thought the consensus was that appending urls to the end of text notes was the best way to handle this to avoid weird UI problems in clients that don't support attachments.

@alexgleason
Copy link
Copy Markdown
Member

When there is an imeta tag that doesn't match any URL in the content, do clients display the media or ignore the tag?

@jb55
Copy link
Copy Markdown
Contributor

jb55 commented Feb 1, 2024

ignore the tag

@staab staab force-pushed the imeta branch 2 times, most recently from ae3a0ba to 3cfc981 Compare February 1, 2024 21:06
@fiatjaf
Copy link
Copy Markdown
Member

fiatjaf commented Feb 1, 2024

@fiatjaf I thought the consensus was that appending urls to the end of text notes was the best way to handle this to avoid weird UI problems in clients that don't support attachments.

Yes, I definitely think that should be how it works. Isn't that what this NIP describes?

@staab staab force-pushed the imeta branch 2 times, most recently from 7c1aaed to fc26ed4 Compare February 1, 2024 21:08
@staab
Copy link
Copy Markdown
Member Author

staab commented Feb 1, 2024

Yes, I definitely think that should be how it works. Isn't that what this NIP describes?

Yes, Alex just had an outstanding suggestion that changed that. Resolved now. I've rebased and fixed a couple formatting things, merging now.

@staab staab merged commit 1ac2811 into nostr-protocol:master Feb 1, 2024
@staab staab deleted the imeta branch February 1, 2024 21:10
@fiatjaf
Copy link
Copy Markdown
Member

fiatjaf commented Feb 1, 2024

You have merged your own PR!

@staab
Copy link
Copy Markdown
Member Author

staab commented Feb 1, 2024

I kept waiting for you to do it and you kept telling some indeterminate person to do it

@fiatjaf
Copy link
Copy Markdown
Member

fiatjaf commented Feb 1, 2024

Outrageous!

(I'm kidding)

pats2sats pushed a commit to sudonym-btc/accommodation-nip that referenced this pull request May 20, 2026
francismars pushed a commit to francismars/nips that referenced this pull request May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.