Document queryable x media hashes in kind 360 NIP
Add top-level x tags carrying the SHA-256 of the primary media and thumbnail, following NIP-68's queryable-hash pattern. The imeta x anchors which hash is primary; parsing, deletion, querying and examples are covered.
This commit is contained in:
1 file changed
+46
-5
@@ -57,7 +57,7 @@ This NIP adds the following requirements: events MUST include at least one high-
|
||||
|
||||
An event MUST contain exactly one `imeta` tag representing a single media item. Field definitions are per [NIP-92](92.md) and [NIP-94](94.md).
|
||||
|
||||
Clients SHOULD include `alt` (accessibility description — also the media's description/caption, see below), `dim` (dimensions), `m` (MIME type, image or video), `thumb` (URL to a smaller thumbnail image), and `blurhash` where possible. Clients MAY also include `fallback` URLs if the media is mirrored.
|
||||
Clients SHOULD include `alt` (accessibility description — also the media's description/caption, see below), `dim` (dimensions), `m` (MIME type, image or video), `x` (SHA-256 of the media, see below), `thumb` (URL to a smaller thumbnail image), and `blurhash` where possible. Clients MAY also include `fallback` URLs if the media is mirrored.
|
||||
|
||||
`alt` serves as the description of the media (not only accessibility text); clients SHOULD prompt authors for it and MAY display it as the media's caption. Since `.content` cannot carry a caption, `alt` is the only description channel for a kind 360 item. A generic or empty `alt` is little better than none.
|
||||
|
||||
@@ -68,6 +68,7 @@ Authors MAY set `.content` to the primary `url` so that clients which do not par
|
||||
"imeta",
|
||||
"url https://blossom.example.com/8e2e28a503fa37482de5b0959ee38b2bb4de4e0a752db24c568981c2ab410260.jpg",
|
||||
"m image/jpeg",
|
||||
"x 8e2e28a503fa37482de5b0959ee38b2bb4de4e0a752db24c568981c2ab410260",
|
||||
"dim 1440x1920",
|
||||
"alt A steaming bowl of ramen on a wooden table at the restaurant.",
|
||||
"fallback https://mirror.example.com/8e2e28a503fa37482de5b0959ee38b2bb4de4e0a752db24c568981c2ab410260.jpg",
|
||||
@@ -84,9 +85,25 @@ Clients MAY additionally include a top-level `["m", "<mime>"]` tag for `#m` filt
|
||||
|
||||
- `t`: Hashtags for categorization (e.g., `["t", "food"]`, `["t", "architecture"]`).
|
||||
- `content-warning`: Optional reason as defined in [NIP-36](36.md); clients MAY hide the media until the user acts. Example: `["content-warning", "nudity"]`.
|
||||
- `x`: Media hashes. See below.
|
||||
|
||||
For kind 360, the warning applies to the media (rendering), not `.content`: clients SHOULD hide or blur the media (e.g., via the `blurhash` placeholder) until the user acts.
|
||||
|
||||
#### `x` — Media Hashes
|
||||
|
||||
Each top-level `x` tag carries the SHA-256 of one distinct file the event references, as 64 lowercase hex characters. There MUST NOT be duplicate `x` values.
|
||||
|
||||
```json
|
||||
[
|
||||
["x", "a9c84e183789a74288b8e05d04cc61230e74f386925a953e6b29f957e8cc3a61"],
|
||||
["x", "c5a528e20235e16cc1c18090b8f04179de76288ea4e410b0fcb8d1487e416a2d"]
|
||||
]
|
||||
```
|
||||
|
||||
The first value above is the primary media's hash; the second is its thumbnail's. The primary's hash SHOULD also appear inside `imeta` (NIP-92) and SHOULD be listed first, but the `imeta` `x` is what identifies the primary — clients MUST NOT infer roles from tag order. If the `imeta` `x` field is present and the event has any top-level `x` tags, one of them MUST equal it. Clients that know a hash (e.g. their own uploads, where the host returns the SHA-256) SHOULD include it; clients that only have a URL and cannot hash the file MAY omit it, and MUST NOT be required to fetch media in order to publish.
|
||||
|
||||
Each hash is of the bytes served at the corresponding URL: the primary at `imeta`'s `url` (or a `fallback` URL), derived images at their `imeta` URLs (`thumb`, and NIP-71 `image` previews). If a host serves a transformed file, the hash is of the bytes it serves; the pre-transformation hash MAY be carried as NIP-94's `ox` inside `imeta` (there is no top-level `ox`). `fallback` URLs serve the same bytes as `url` and get no extra `x`; hashes of files the event does not reference MUST NOT be included. See Querying for `#x` filters; [NIP-94](94.md) defines the tag, while the 64-character lowercase-hex format is this NIP's requirement (relay tag matching is exact-string per [NIP-01](01.md)).
|
||||
|
||||
## Querying
|
||||
|
||||
Single-item tags are filterable per [NIP-01](01.md).
|
||||
@@ -99,6 +116,17 @@ Single-item tags are filterable per [NIP-01](01.md).
|
||||
|
||||
This returns every media item for the place regardless of geohash presence or precision, and does not require geohash tags.
|
||||
|
||||
**Events for a blob.** Filter by kind 360 and `#x` with the media's SHA-256:
|
||||
|
||||
```json
|
||||
{
|
||||
"kinds": [360],
|
||||
"#x": ["a9c84e183789a74288b8e05d04cc61230e74f386925a953e6b29f957e8cc3a61"]
|
||||
}
|
||||
```
|
||||
|
||||
Dropping `kinds` finds the same blob across other event kinds that use `x` (e.g. 20, 1063). A match may indicate the blob is the event's thumbnail or preview rather than its primary media.
|
||||
|
||||
**Spatial discovery.** Filter by kind 360 and `#g`:
|
||||
|
||||
```json
|
||||
@@ -107,15 +135,17 @@ This returns every media item for the place regardless of geohash presence or pr
|
||||
|
||||
Clients SHOULD query a single geohash precision level per request, MAY include multiple geohash values to cover a bounding box, SHOULD limit values per query (e.g., ≤ 30), and MAY reduce precision or split queries when necessary.
|
||||
|
||||
Relays MAY not index arbitrary tags; clients SHOULD NOT assume all relays serve `#i`/`#g` queries for this kind.
|
||||
Relays MAY not index arbitrary tags; clients SHOULD NOT assume all relays serve `#i`/`#g`/`#x` queries for this kind.
|
||||
|
||||
## Client Behavior
|
||||
|
||||
**Publishing.** Clients MUST NOT publish events that violate the required tags or the content rule above.
|
||||
**Publishing.** Clients MUST NOT publish events that violate the required tags, the `x`/`m` tag invariants, or the content rule above.
|
||||
|
||||
**Parsing.** Clients SHOULD tolerate missing optional fields and unknown tags, and MAY use the first `imeta` if multiple are present. An event whose `imeta` lacks a `url` has no renderable media. If the `i` element cannot be resolved (e.g., a deleted OSM element), clients MAY fall back to the `g` geohash for placement, or skip the event.
|
||||
**Parsing.** Clients SHOULD tolerate missing optional fields and unknown tags, and MAY use the first `imeta` if multiple are present. An event whose `imeta` lacks a `url` has no renderable media. `x` tags are optional; clients MUST NOT require them. The `imeta` `x` value, when present, identifies the primary media's hash. If the `imeta` `x` is present and top-level `x` tags exist but none equals it, clients SHOULD treat the event's hashes as untrusted for verification. With more than one top-level `x`, clients MUST NOT assume which value belongs to the primary media; a fetched file (media, thumbnail, preview) MAY instead be verified by hashing its bytes and testing membership in the `x` values. Clients MAY associate every top-level `x` with the event for blob indexing and lifecycle (e.g. Blossom garbage collection). If the `i` element cannot be resolved (e.g., a deleted OSM element), clients MAY fall back to the `g` geohash for placement, or skip the event.
|
||||
|
||||
**Rendering.** Clients MAY skip media they cannot render, SHOULD honor `content-warning` (media, not `.content` — see above), and SHOULD use `thumb`/`blurhash` placeholders while loading. Relays: see Querying for the `#i`/`#g` indexing caveat.
|
||||
**Deletion.** When deleting a kind 360 event, clients MAY delete the blobs it references — every top-level `x` hash (for legacy events without `x`, hashes extracted from URLs) — from the author's blob servers ([NIP-B7](B7.md)). Blobs are content-addressed and may be referenced by other events; clients SHOULD first check that a hash is no longer referenced (e.g. an `#x` query) before deleting it.
|
||||
|
||||
**Rendering.** Clients MAY skip media they cannot render, SHOULD honor `content-warning` (media, not `.content` — see above), and SHOULD use `thumb`/`blurhash` placeholders while loading. Relays: see Querying for the `#i`/`#g`/`#x` indexing caveat.
|
||||
|
||||
## Example Event
|
||||
|
||||
@@ -136,12 +166,15 @@ Relays MAY not index arbitrary tags; clients SHOULD NOT assume all relays serve
|
||||
"imeta",
|
||||
"url https://blossom.example.com/a9c84e183789a74288b8e05d04cc61230e74f386925a953e6b29f957e8cc3a61.jpg",
|
||||
"m image/jpeg",
|
||||
"x a9c84e183789a74288b8e05d04cc61230e74f386925a953e6b29f957e8cc3a61",
|
||||
"dim 1920x1920",
|
||||
"alt A close-up of spicy miso ramen with chashu pork, soft boiled egg, and scallions.",
|
||||
"fallback https://mirror.example.com/a9c84e183789a74288b8e05d04cc61230e74f386925a953e6b29f957e8cc3a61.jpg",
|
||||
"thumb https://example.com/c5a528e20235e16cc1c18090b8f04179de76288ea4e410b0fcb8d1487e416a2d.jpg",
|
||||
"blurhash UHI=0o~q4T-o~q%MozM{x]t7RjRPt7oKkCWB"
|
||||
],
|
||||
["x", "a9c84e183789a74288b8e05d04cc61230e74f386925a953e6b29f957e8cc3a61"],
|
||||
["x", "c5a528e20235e16cc1c18090b8f04179de76288ea4e410b0fcb8d1487e416a2d"],
|
||||
["t", "ramen"],
|
||||
["t", "food"]
|
||||
]
|
||||
@@ -170,6 +203,12 @@ The `osm:<type>:<id>` scheme is defined by [NIP-73](73.md) (External Content IDs
|
||||
|
||||
Place Reviews (kind 30360) is a work-in-progress companion NIP, not yet published; when it is, reviews and media will interoperate as follows. Reviews and media have different lifecycles and data models. A user might upload 10 photos of a park without writing a review, or write a detailed review without attaching photos. Keeping them as separate events allows clients to query `imeta` attachments for a specific `i` tag to quickly build a media gallery for a place, regardless of whether a review was attached.
|
||||
|
||||
### Queryable Media Hashes (`x`)
|
||||
|
||||
Blob stores address files by SHA-256, and relays index single-letter tags, but a hash nested only inside `imeta` cannot be filtered on. [NIP-71](71.md) puts the hash in `imeta` alone, which voids queryability of the file; [NIP-68](68.md) puts it at the top level for exactly this reason, and this NIP follows that pattern. Kind 360 carries exactly one media item, so the `imeta` `x` — never tag order — identifies the primary hash among the event's `x` values; the rest are derived images. Including them means `#x` lookups and deletion flows see every blob the event references, not just the primary — NIP-68 lists one top-level `x` per displayed image for the same reason.
|
||||
|
||||
The payoff is cross-kind and cross-client: `{"#x": ["<hash>"]}` answers "which events reference this blob?" for clients, media-management UIs (e.g. Blossom blob browsers) and indexers/crawlers, and lets downloaders find mirrors and verify bytes without parsing the URL. Keeping `x` also inside `imeta` serves NIP-92-only readers, which never see top-level tags.
|
||||
|
||||
### Single Media Item per Event
|
||||
|
||||
Restricting events to a single `imeta` attachment (one media item per event) is an intentional design choice. Batching media into a single event forces all engagement (likes, zaps) to apply to the entire batch, rendering granular tagging and sorting impossible. Single-item events enable per-item engagement, fine-grained categorization (e.g., tagging one photo as "food" and another as "menu"), and richer sorting algorithms based on individual item popularity.
|
||||
@@ -180,6 +219,8 @@ Restricting events to a single `imeta` attachment (one media item per event) is
|
||||
- **Spam.** Clients SHOULD NOT assume all events are legitimate and SHOULD apply their own moderation/trust mechanisms.
|
||||
- **Untrusted media.** `url`, `thumb`, and `fallback` point to arbitrary servers; clients SHOULD treat fetched media as untrusted content. Fetching media reveals the viewer's interest in a place to the hosting server.
|
||||
- **Identifier decay.** Referenced OSM elements may be deleted or retyped; see Client Behavior for parsing fallbacks.
|
||||
- **Author-asserted hash.** `x` is signed but is not proof of content. Clients SHOULD verify downloaded bytes against it before trusting, re-hosting or treating the media as verified; for large media, verification MAY be lazy/streamed. On mismatch, clients MUST NOT silently substitute other media or drop the event, and SHOULD surface the mismatch to the user.
|
||||
- **Content fingerprinting.** For files whose URL already embeds the SHA-256 (e.g. Blossom media and thumbnails), `x` discloses nothing new. For other URLs it publishes a content fingerprint that lets relay watchers correlate events referencing identical bytes across hosts or places without fetching the media. This is a verification/convenience trade-off, not a reason to omit `x`.
|
||||
|
||||
## Future Work
|
||||
|
||||
|
||||
Reference in new issue
Block a user