From cc343b96bedbd4686fe5eb6733b7fa78116a7604 Mon Sep 17 00:00:00 2001 From: arthurfranca Date: Fri, 12 May 2023 15:18:42 -0300 Subject: [PATCH] Add NIP-54 --- 54.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 94.md | 2 ++ README.md | 1 + 3 files changed, 45 insertions(+) create mode 100644 54.md diff --git a/54.md b/54.md new file mode 100644 index 00000000..f04eac87 --- /dev/null +++ b/54.md @@ -0,0 +1,42 @@ +NIP-54 +====== + +Inline Resource Metadata +------------------------ + +`draft` `optional` `author:arthurfranca` `author:Giszmo` `author:jb55` + +Inline resource metadata is additional information associated with urls in notes that clients can optionally use to enhance resource loading. + +It uses [URI Fragment](https://en.wikipedia.org/wiki/URI_fragment) that agents (such as web browsers) never send to the server. + +The URI fragment follows [media fragments structure](https://www.w3.org/TR/media-frags/#general-structure). For example, one could use `t=number_of_seconds` to start playing a video at the specified position along with an extra [percent-encoded](https://www.ietf.org/rfc/rfc3986.txt) name-value pair separated by `&` char like `https://xyz.com/a-video.mp4#t=24&a%20name=a%20value`. + +The metadata can be appended to any url, like this [NIP-21](21.md) one: `nostr:nevent1qq...pm#a-metadata-name=a-metadata-value` + +## NIP-94 File Fragments + +Besides available w3c and proprietary URI fragment usage, nostr uses existing [NIP-94](94.md) tags as file fragment name-value pairs. For example, one could join the following strings to form an image url with inline metadata: + +- `https://nostr.build/i/863321bb1ae68830ebcf9a343ca0a5e0ce2323d0a55b7fbe86f7a886cf61db8d.jpg` +- `#` +- `dim=3024x4032` +- `&` +- `blurhash=eVF%24%5EOI%3A%24%7BM%7Bo%23*0-nNFxakD-%3FxVM%7DWEWB%25iNKxvR-oetmo%23R-aen%24` +- `&` +- `alt=Picture%20of%20a%20scenic%20view%20overlooking%20the%20coast%20near%20Uvita%2C%20with%20a%20person%20holding%20a%20coffee%20cup` + +Multiple array values use repeated names and are positioned in the same order of ocurrence in the tag array. For instance, `["aes-256-gcm", 'i-am-a-key', 'i-am-an-iv']` becomes `aes-256-gcm=i-am-a-key&aes-256-gcm=i-am-an-iv` + +NIP-94 event content may be used as `content` fragment field or alternatively as `alt` if corresponding tag is absent. + +## Recommended client behavior + +When uploading images during a new post, clients can collect metadata +after the image is uploaded and then include the url with inline metadata in the post. + +When pasting urls during post composition, the client could download the image +and add some metadata before the post is sent. + +Clients can use `alt` fragment to add accessible text for people who prefer not to +load images, visibility-impaired users, or text clients. diff --git a/94.md b/94.md index c5e0f182..be7f7066 100644 --- a/94.md +++ b/94.md @@ -18,6 +18,7 @@ This NIP specifies the use of the `1063` event type, having in `content` a descr * `x` containing the SHA-256 hexencoded string of the file. * `size` (optional) size of file in bytes * `dim` (optional) size of file in pixels in the form `x` +* `alt` (optional) accessible text label that describes the image or video * `magnet` (optional) URI to magnet file * `i` (optional) torrent infohash * `blurhash`(optional) the [blurhash](https://github.com/woltapp/blurhash) to show while the file is being loaded by the client @@ -39,6 +40,7 @@ This NIP specifies the use of the `1063` event type, having in `content` a descr ["x",], ["size", ], ["dim", ], + ["alt", ], ["magnet", ], ["i",], ["blurhash", ], diff --git a/README.md b/README.md index 8be05951..d5677a08 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos - [NIP-51: Lists](51.md) - [NIP-52: Calendar Events](52.md) - [NIP-53: Live Activities](53.md) +- [NIP-54: Inline Resource Metadata](54.md) - [NIP-56: Reporting](56.md) - [NIP-57: Lightning Zaps](57.md) - [NIP-58: Badges](58.md)