From 2d7e013b47051bff8f2f260fc34f58c1178ced4b Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Fri, 22 Nov 2024 13:44:50 -0600 Subject: [PATCH 01/38] BUD-02 require the file extension in the url field --- buds/02.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/buds/02.md b/buds/02.md index 230ecad..6d8519c 100644 --- a/buds/02.md +++ b/buds/02.md @@ -12,12 +12,14 @@ Defines the `/upload`, `/list` and `DELETE /` endpoints A blob descriptor is a JSON object containing `url`, `sha256`, `size`, `type`, and `uploaded` fields -- `url` A publicly accessible URL to the [BUD-01](./01.md#get-sha256---get-blob) `GET /` endpoint (optionally with a file extension) +- `url` A publicly accessible URL to the [BUD-01](./01.md#get-sha256---get-blob) `GET /` endpoint with a file extension - `sha256` The sha256 hash of the blob - `size` The size of the blob in bytes - `type` (optional) The MIME type of the blob - `uploaded` The unix timestamp of when the blob was uploaded to the server +Servers MUST include a file extension in the URL in the `url` field to allow clients to easily embed the URL in social posts or other content + Servers MAY include additional fields in the descriptor like `magnet`, `infohash`, or `ipfs` depending on other protocols they support Example: From 34a50d09f5b1ef095eeb0824bc6fe538448e6639 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Tue, 26 Nov 2024 09:15:39 -0600 Subject: [PATCH 02/38] require NIP-94 values to be strings --- buds/08.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buds/08.md b/buds/08.md index b5e2ec0..8964cc7 100644 --- a/buds/08.md +++ b/buds/08.md @@ -12,7 +12,7 @@ As described in [BUD-02](./02.md#blob-descriptor) servers MAY add any additional Servers MAY return an additional `nip94` field in the [blob descriptor](./02.md#blob-descriptor) from the `/upload` or `/mirror` endpoints -The `nip94` field should contain a JSON object with the keys being the tag names defined in [NIP-94](https://github.com/nostr-protocol/nips/blob/master/94.md) +The `nip94` field should contain a JSON object with the keys being the tag names defined in [NIP-94](https://github.com/nostr-protocol/nips/blob/master/94.md) and the values being strings An example response would look like: @@ -27,7 +27,7 @@ An example response would look like: "url": "https://cdn.example.com/b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553.pdf", "m": "application/pdf", "x": "b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553", - "size": 184292, + "size": "184292", "magnet": "magnet:?xt=urn:btih:9804c5286a3fb07b2244c968b39bc3cc814313bc&dn=bitcoin.pdf", "i": "9804c5286a3fb07b2244c968b39bc3cc814313bc" } From ec40af6b95bf6fae3659dc80cac526ea30bbccec Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Mon, 2 Dec 2024 10:50:46 -0600 Subject: [PATCH 03/38] clarify root paths --- buds/01.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/01.md b/buds/01.md index e94b8d4..1c8ea6f 100644 --- a/buds/01.md +++ b/buds/01.md @@ -71,7 +71,7 @@ Authorization: Nostr eyJpZCI6IjhlY2JkY2RkNTMyOTIwMDEwNTUyNGExNDI4NzkxMzg4MWIzOWQ ## Endpoints -All endpoints MUST be served from the root path (eg. `https://cdn.example.com/upload`, etc). This allows clients to talk to servers interchangeably when uploading or retrieving blobs +All endpoints MUST be served from the root of the domain (eg. the `/upload` endpoint MUST accessable from `https://cdn.example.com/upload`, etc). This allows clients to talk to servers interchangeably when uploading or retrieving blobs ## GET /sha256 - Get Blob From 1a44035b7da0e6e03f4a35e69ce89254ef91858a Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Mon, 2 Dec 2024 10:52:00 -0600 Subject: [PATCH 04/38] spelling --- buds/01.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/01.md b/buds/01.md index 1c8ea6f..2e23470 100644 --- a/buds/01.md +++ b/buds/01.md @@ -71,7 +71,7 @@ Authorization: Nostr eyJpZCI6IjhlY2JkY2RkNTMyOTIwMDEwNTUyNGExNDI4NzkxMzg4MWIzOWQ ## Endpoints -All endpoints MUST be served from the root of the domain (eg. the `/upload` endpoint MUST accessable from `https://cdn.example.com/upload`, etc). This allows clients to talk to servers interchangeably when uploading or retrieving blobs +All endpoints MUST be served from the root of the domain (eg. the `/upload` endpoint MUST accessible from `https://cdn.example.com/upload`, etc). This allows clients to talk to servers interchangeably when uploading or retrieving blobs ## GET /sha256 - Get Blob From c195efdf3065597ad2eecc53bf241538c91c5317 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Thu, 26 Dec 2024 09:44:15 -0600 Subject: [PATCH 05/38] Change /media endpoint to require "media" auth --- buds/05.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/buds/05.md b/buds/05.md index 2ad9851..97d9ff9 100644 --- a/buds/05.md +++ b/buds/05.md @@ -18,9 +18,12 @@ Servers MAY reject media uploads for any reason and should respond with the appr ### Upload Authorization -Servers MAY require an `upload` [authorization event](./02.md#upload-authorization-required) to identify the uploader +Servers MAY require a `media` [authorization event](./02.md#upload-authorization-required) to identify the uploader -If a server requires an `upload` authorization event it MUST preform all the checks outlined in the [`/upload`](./02.md#upload-authorization-required) endpoint +If a server requires a `media` authorization event it MUST preform the following checks + +1. The `t` tag MUST be set to `media` +2. MUST contain at least one `x` tag matching the sha256 hash of the body of the request ## HEAD /media @@ -40,6 +43,6 @@ If a longer optimization or transformation process is needed, or if the client n Clients MAY let a user selected a "trusted processing" server for uploading images or short videos -Once a server has been selected, the client can upload the original media to the `/media` endpoint of the trusted server and get the optimized blob back +Once a server has been selected, the client uploads the original media to the `/media` endpoint of the trusted server and get the optimized blob back -Then optionally the client can ask the user to sign another `upload` authorization event for the new optimized blob and call the `/mirror` endpoint on other servers to distribute the blob +Then the client can ask the user to sign another `upload` authorization event for the new optimized blob and call the `/mirror` endpoint on other servers to distribute the blob From b50a5374b31a93213db0497567a66a767cd4fe02 Mon Sep 17 00:00:00 2001 From: "k." Date: Wed, 1 Jan 2025 19:38:07 +0000 Subject: [PATCH 06/38] Update 01.md --- buds/01.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/buds/01.md b/buds/01.md index 5d5434f..41466bb 100644 --- a/buds/01.md +++ b/buds/01.md @@ -36,7 +36,7 @@ Authorization events MAY have multiple `x` tags for endpoints that require a sha Example event: -```json +```jsonc { "id": "bb653c815da18c089f3124b41c4b5ec072a40b87ca0f50bbbc6ecde9aca442eb", "pubkey": "b53185b9f27962ebdf76b8a9b0a84cd8b27f9f3d4abd59f715788a3bf9e7f75e", @@ -45,7 +45,7 @@ Example event: "created_at": 1708773959, "tags": [ ["t", "upload"], - // Authorization events MAY have multiple "x" tags + // Authorization events MAY have multiple "x" tags. ["x", "b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553"], ["expiration", "1708858680"] ], @@ -71,22 +71,22 @@ Authorization: Nostr eyJpZCI6IjhlY2JkY2RkNTMyOTIwMDEwNTUyNGExNDI4NzkxMzg4MWIzOWQ ## Endpoints -All endpoints MUST be served from the root of the domain (eg. the `/upload` endpoint MUST accessible from `https://cdn.example.com/upload`, etc). This allows clients to talk to servers interchangeably when uploading or retrieving blobs +All endpoints MUST be served from the root of the domain (eg. the `/upload` endpoint MUST be accessible from `https://cdn.example.com/upload`, etc). This allows clients to talk to servers interchangeably when uploading or retrieving blobs ## GET /sha256 - Get Blob -The `GET /` endpoint MUST return the contents of the blob with the `Content-Type` header set to the appropriate MIME type +The `GET /` endpoint MUST return the contents of the blob with the `Content-Type` header set to the appropriate MIME-type The endpoint MUST accept an optional file extension in the URL. ie. `.pdf`, `.png`, etc -If the endpoints returns a 301 or 302 redirect it MUST redirect to a URL containing the same sha256 hash as requested blob. +If the endpoints returns a 301 or 302 redirect it MUST redirect to a URL containing the same sha256 hash as the requested blob. This ensures that if a user was to copy or reuse the redirect URL it would still contain the original sha256 hash ### Get Authorization (optional) The server may optionally require authorization when retrieving blobs from the `GET /` endpoint -In this case the server MUST perform additional checks on the authorization event +In this case, the server MUST perform additional checks on the authorization event 1. A `t` tag MUST be present and set to `get` 2. The event MUST contain either a `server` tag containing the full URL to the server or MUST contain at least one `x` tag matching the sha256 hash of the blob being retrieved From 550d8693e02dc92b1e1af7124b26431c3ef4f36e Mon Sep 17 00:00:00 2001 From: "k." Date: Wed, 1 Jan 2025 19:38:47 +0000 Subject: [PATCH 07/38] Update 04.md --- buds/04.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buds/04.md b/buds/04.md index 92559c0..eb1d19f 100644 --- a/buds/04.md +++ b/buds/04.md @@ -12,8 +12,8 @@ A server may expose a `PUT /mirror` endpoint to allow users to copy a blob from Clients MUST pass the URL of the remote blob as a stringified JSON object in the request body -```json -// request body +```jsonc +// request body... { "url": "https://cdn.satellite.earth/b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553.pdf" } From 29cbfbf504041b2a3ff553a024a390510535b8dc Mon Sep 17 00:00:00 2001 From: Kay Date: Thu, 2 Jan 2025 11:13:28 +0000 Subject: [PATCH 08/38] bud-07: media report. --- buds/01.md | 2 +- buds/07.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 buds/07.md diff --git a/buds/01.md b/buds/01.md index 41466bb..13b2bd3 100644 --- a/buds/01.md +++ b/buds/01.md @@ -26,7 +26,7 @@ Authorization events are used to identify the users to the server Authorization events must be generic and must NOT be scoped to specific servers. This allows pubkeys to sign a single event and interact the same way with multiple servers. -Events MUST be kind `24242` and have a `t` tag with a verb of `get`, `upload`, `list`, or `delete` +Events MUST be kind `24242` and have a `t` tag with a verb of `get`, `upload`, `list`, `report`, or `delete` Events MUST have the `content` set to a human readable string explaining to the user what the events inteded use is. For example `Upload Blob`, `Delete dog-picture.png`, `List Images`, etc diff --git a/buds/07.md b/buds/07.md new file mode 100644 index 0000000..8c2098b --- /dev/null +++ b/buds/07.md @@ -0,0 +1,43 @@ +# BUD-07 + +## Media Report + +`draft` `optional` + +This bud defines a new endpoint for clients and users to report medias to servers. + + +### PUT /report/ - reporting a media + +Client MUST provide a report json according to the [NIP-56](https://github.com/nostr-protocol/nips/blob/master/56.md) in the request body. + +Example: + +```json +{ + "kind": 1984, + "tags": [ + ["x", "", ""], + ], + "content": "", + // other fields... +} +``` + +A report request may contain multiple `x` tags or contain some `p` or `e` tags which is not related to blossom server but is SHOULD be considered as a valid request. + +Server MUST response to report request with a successful code or a code in 4xx/5xx range if there was any error. + + +> Note: servers may requests for authorization with `t` tag of `report` as per [BUD-01](./01.md). + +### Client behavior + +The clients can show a media report button on posts or in media details. Or they merge this with normal nostr report and send it to both relays and blossom server. other clients can receive it from relays and hide or blur reported medias from trusted friends. + +### Server behavior + +The servers MAY keep the reports somewhere for operators to check and take action on them. they MAY use a list of trusted people or moderators to directly take action on media without operator request. + +Servers MAY consider removed medias sha256 as blocked in order to prevent rewrite. +Servers MAY advertise a route or landing page to provide their rules and term of service which affects the report process. From 7a9111f54d6bda0c0bb451ccbafa3ebd90077603 Mon Sep 17 00:00:00 2001 From: Kay Date: Thu, 2 Jan 2025 11:17:48 +0000 Subject: [PATCH 09/38] small fixes. --- README.md | 11 +++++++++++ buds/07.md | 12 ++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f55862e..0d60b61 100644 --- a/README.md +++ b/README.md @@ -15,22 +15,32 @@ Blobs are packs of binary data addressed by their sha256 hash Blossom Servers expose a few endpoints for managing blobs - `GET /` (optional file `.ext`) [BUD-01](./buds/01.md#get-sha256---get-blob) + - `HEAD /` (optional file `.ext`) [BUD-01](./buds/01.md#head-sha256---has-blob) + - `PUT /upload` [BUD-02](./buds/02.md#put-upload---upload-blob) - `Authentication`: Signed [nostr event](./buds/02.md#upload-authorization-required) - Return a blob descriptor + - `HEAD /upload` [BUD-06](./buds/06.md#head-upload---upload-requirements) + - `GET /list/` [BUD-02](./buds/02.md#get-listpubkey---list-blobs) - Returns an array of blob descriptors - `Authentication` _(optional)_: Signed [nostr event](./buds/02.md#list-authorization-optional) + - `DELETE /` [BUD-02](./buds/02.md#delete-sha256---delete-blob) - `Authentication`: Signed [nostr event](./buds/02.md#delete-authorization-required) + - `PUT /mirror` [BUD-04](./buds/04.md#put-mirror---mirror-blob) - `Authentication`: Signed [nostr event](./buds/02.md#upload-authorization-required) + - `HEAD /media` [BUD-05](./buds/05.md#head-media) + - `PUT /media` [BUD-05](./buds/05.md#put-media) - `Authentication`: Signed [nostr event](./buds/05.md#upload-authorization) +- `PUT /report/` [BUD-07](./buds/07.md) + ## Protocol specification (BUDs) BUDs stand for **Blossom Upgrade Documents**. @@ -45,6 +55,7 @@ See the [BUDs](./buds) folder and specifically [BUD-01](./buds/01.md) and [BUD-0 - [BUD-04: Mirroring blobs](./buds/04.md) - [BUD-05: Media optimization](./buds/05.md) - [BUD-06: Upload requirements](./buds/06.md) +- [BUD-07: Blob Report](./buds/07.md) - [BUD-08: Nostr File Metadata Tags](./buds/08.md) ## Event kinds diff --git a/buds/07.md b/buds/07.md index 8c2098b..29fb2d7 100644 --- a/buds/07.md +++ b/buds/07.md @@ -1,10 +1,10 @@ # BUD-07 -## Media Report +## Blob Report `draft` `optional` -This bud defines a new endpoint for clients and users to report medias to servers. +This bud defines a new endpoint for clients and users to report blobs to servers. ### PUT /report/ - reporting a media @@ -17,7 +17,7 @@ Example: { "kind": 1984, "tags": [ - ["x", "", ""], + ["x", "", ""], ], "content": "", // other fields... @@ -33,11 +33,11 @@ Server MUST response to report request with a successful code or a code in 4xx/5 ### Client behavior -The clients can show a media report button on posts or in media details. Or they merge this with normal nostr report and send it to both relays and blossom server. other clients can receive it from relays and hide or blur reported medias from trusted friends. +The clients can show a blob report button on posts or in blob details. Or its RECOMMENDED to merge this with normal nostr report and send it to both relays and blossom server. other clients can receive it from relays and hide or blur reported blob from trusted friends. ### Server behavior -The servers MAY keep the reports somewhere for operators to check and take action on them. they MAY use a list of trusted people or moderators to directly take action on media without operator request. +The servers MAY keep the reports somewhere for operators to check and take action on them. they MAY use a list of trusted people or moderators to directly take action on blob without operator request. -Servers MAY consider removed medias sha256 as blocked in order to prevent rewrite. +Servers MAY consider removed blobs sha256 as blocked in order to prevent rewrite. Servers MAY advertise a route or landing page to provide their rules and term of service which affects the report process. From e5462c3e1a6ffc9a55ac1b995e0d73c5111b0079 Mon Sep 17 00:00:00 2001 From: Kay Date: Thu, 2 Jan 2025 11:18:02 +0000 Subject: [PATCH 10/38] small fixes. --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index 29fb2d7..9b0a332 100644 --- a/buds/07.md +++ b/buds/07.md @@ -13,7 +13,7 @@ Client MUST provide a report json according to the [NIP-56](https://github.com/n Example: -```json +```jsonc { "kind": 1984, "tags": [ From fa676debf3ca48c41cdfdb85675344abc3d65a76 Mon Sep 17 00:00:00 2001 From: Kay Date: Fri, 3 Jan 2025 12:51:09 +0000 Subject: [PATCH 11/38] fix requests. --- README.md | 2 +- buds/{07.md => 09.md} | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) rename buds/{07.md => 09.md} (71%) diff --git a/README.md b/README.md index 0d60b61..6ec425b 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Blossom Servers expose a few endpoints for managing blobs - `PUT /media` [BUD-05](./buds/05.md#put-media) - `Authentication`: Signed [nostr event](./buds/05.md#upload-authorization) -- `PUT /report/` [BUD-07](./buds/07.md) +- `PUT /report` [BUD-09](./buds/09.md) ## Protocol specification (BUDs) diff --git a/buds/07.md b/buds/09.md similarity index 71% rename from buds/07.md rename to buds/09.md index 9b0a332..a86bb5e 100644 --- a/buds/07.md +++ b/buds/09.md @@ -1,4 +1,4 @@ -# BUD-07 +# BUD-09 ## Blob Report @@ -7,9 +7,9 @@ This bud defines a new endpoint for clients and users to report blobs to servers. -### PUT /report/ - reporting a media +### PUT /report - reporting a media -Client MUST provide a report json according to the [NIP-56](https://github.com/nostr-protocol/nips/blob/master/56.md) in the request body. +The requests body MUST be a signed [NIP-56](https://github.com/nostr-protocol/nips/blob/master/56.md) report event with `x` tags containing that hashes of the blobs being reported. Example: @@ -19,7 +19,7 @@ Example: "tags": [ ["x", "", ""], ], - "content": "", + "content": "", // other fields... } ``` @@ -28,9 +28,6 @@ A report request may contain multiple `x` tags or contain some `p` or `e` tags w Server MUST response to report request with a successful code or a code in 4xx/5xx range if there was any error. - -> Note: servers may requests for authorization with `t` tag of `report` as per [BUD-01](./01.md). - ### Client behavior The clients can show a blob report button on posts or in blob details. Or its RECOMMENDED to merge this with normal nostr report and send it to both relays and blossom server. other clients can receive it from relays and hide or blur reported blob from trusted friends. @@ -40,4 +37,4 @@ The clients can show a blob report button on posts or in blob details. Or its RE The servers MAY keep the reports somewhere for operators to check and take action on them. they MAY use a list of trusted people or moderators to directly take action on blob without operator request. Servers MAY consider removed blobs sha256 as blocked in order to prevent rewrite. -Servers MAY advertise a route or landing page to provide their rules and term of service which affects the report process. +Servers SHOULD advertise a route or landing page to provide their rules and term of service which affects the report process. From 4e6e322aa371243ae6e7379eb7dcc3e3bc865792 Mon Sep 17 00:00:00 2001 From: Kay Date: Fri, 3 Jan 2025 12:55:43 +0000 Subject: [PATCH 12/38] fix requests. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ec425b..89544ad 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,8 @@ See the [BUDs](./buds) folder and specifically [BUD-01](./buds/01.md) and [BUD-0 - [BUD-04: Mirroring blobs](./buds/04.md) - [BUD-05: Media optimization](./buds/05.md) - [BUD-06: Upload requirements](./buds/06.md) -- [BUD-07: Blob Report](./buds/07.md) - [BUD-08: Nostr File Metadata Tags](./buds/08.md) +- [BUD-08: Blob Report](./buds/08.md) ## Event kinds From 287b32b531ebc43c853cfd8ed813b6eaf357624b Mon Sep 17 00:00:00 2001 From: "k." Date: Fri, 3 Jan 2025 14:59:39 +0000 Subject: [PATCH 13/38] Update buds/01.md Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com> --- buds/01.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/01.md b/buds/01.md index 13b2bd3..41466bb 100644 --- a/buds/01.md +++ b/buds/01.md @@ -26,7 +26,7 @@ Authorization events are used to identify the users to the server Authorization events must be generic and must NOT be scoped to specific servers. This allows pubkeys to sign a single event and interact the same way with multiple servers. -Events MUST be kind `24242` and have a `t` tag with a verb of `get`, `upload`, `list`, `report`, or `delete` +Events MUST be kind `24242` and have a `t` tag with a verb of `get`, `upload`, `list`, or `delete` Events MUST have the `content` set to a human readable string explaining to the user what the events inteded use is. For example `Upload Blob`, `Delete dog-picture.png`, `List Images`, etc From 72d5c1690a19042fbf2d458bdc84a23f1dfb933f Mon Sep 17 00:00:00 2001 From: "k." Date: Fri, 3 Jan 2025 14:59:53 +0000 Subject: [PATCH 14/38] Update README.md Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 89544ad..ae01168 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ See the [BUDs](./buds) folder and specifically [BUD-01](./buds/01.md) and [BUD-0 - [BUD-05: Media optimization](./buds/05.md) - [BUD-06: Upload requirements](./buds/06.md) - [BUD-08: Nostr File Metadata Tags](./buds/08.md) -- [BUD-08: Blob Report](./buds/08.md) +- [BUD-09: Blob Report](./buds/09.md) ## Event kinds From 9e468f874947f240c583b588eeab4077cc3e888b Mon Sep 17 00:00:00 2001 From: "k." Date: Sat, 4 Jan 2025 17:37:58 +0000 Subject: [PATCH 15/38] Update buds/09.md Co-authored-by: Kieran --- buds/09.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/09.md b/buds/09.md index a86bb5e..425761e 100644 --- a/buds/09.md +++ b/buds/09.md @@ -9,7 +9,7 @@ This bud defines a new endpoint for clients and users to report blobs to servers ### PUT /report - reporting a media -The requests body MUST be a signed [NIP-56](https://github.com/nostr-protocol/nips/blob/master/56.md) report event with `x` tags containing that hashes of the blobs being reported. +The request body MUST be a signed [NIP-56](https://github.com/nostr-protocol/nips/blob/master/56.md) report event with one or more `x` tags containing the hashes of the blobs being reported. Example: From 8487a70a2271aa37dee549999167704ea14bce37 Mon Sep 17 00:00:00 2001 From: "k." Date: Sat, 4 Jan 2025 17:38:54 +0000 Subject: [PATCH 16/38] Update buds/09.md Co-authored-by: Kieran --- buds/09.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/09.md b/buds/09.md index 425761e..c9e6a05 100644 --- a/buds/09.md +++ b/buds/09.md @@ -26,7 +26,7 @@ Example: A report request may contain multiple `x` tags or contain some `p` or `e` tags which is not related to blossom server but is SHOULD be considered as a valid request. -Server MUST response to report request with a successful code or a code in 4xx/5xx range if there was any error. +Server MUST respond to a report request with a success code or a code in 4xx/5xx range if there was any error. ### Client behavior From 52abe4467a80087da02d05ac677496fcbef51683 Mon Sep 17 00:00:00 2001 From: "k." Date: Sat, 4 Jan 2025 19:01:39 +0000 Subject: [PATCH 17/38] Update 09.md --- buds/09.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/buds/09.md b/buds/09.md index c9e6a05..875067c 100644 --- a/buds/09.md +++ b/buds/09.md @@ -18,15 +18,16 @@ Example: "kind": 1984, "tags": [ ["x", "", ""], + ["x", "", ""] ], "content": "", // other fields... } ``` -A report request may contain multiple `x` tags or contain some `p` or `e` tags which is not related to blossom server but is SHOULD be considered as a valid request. +The clients can include `e` or `p` tags to point to the event or the profile that contains this media if they want to make this report event useful for relays as well. -Server MUST respond to a report request with a success code or a code in 4xx/5xx range if there was any error. +Server MUST respond to a report request with a success code or a code in the 4xx/5xx range if there was any error. ### Client behavior @@ -36,5 +37,5 @@ The clients can show a blob report button on posts or in blob details. Or its RE The servers MAY keep the reports somewhere for operators to check and take action on them. they MAY use a list of trusted people or moderators to directly take action on blob without operator request. -Servers MAY consider removed blobs sha256 as blocked in order to prevent rewrite. +Servers MAY consider removed blobs sha256 as blocked to prevent rewrite. Servers SHOULD advertise a route or landing page to provide their rules and term of service which affects the report process. From eaa37c348dd1f27dc39967e6da0459c32f584f38 Mon Sep 17 00:00:00 2001 From: "k." Date: Tue, 7 Jan 2025 17:37:14 +0000 Subject: [PATCH 18/38] Update 09.md --- buds/09.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/09.md b/buds/09.md index 875067c..0c2f808 100644 --- a/buds/09.md +++ b/buds/09.md @@ -7,7 +7,7 @@ This bud defines a new endpoint for clients and users to report blobs to servers. -### PUT /report - reporting a media +### PUT /report - reporting a blob The request body MUST be a signed [NIP-56](https://github.com/nostr-protocol/nips/blob/master/56.md) report event with one or more `x` tags containing the hashes of the blobs being reported. From b29ada0e112d5a656d034b72f97ff90b0daa8212 Mon Sep 17 00:00:00 2001 From: hzrd149 <8001706+hzrd149@users.noreply.github.com> Date: Tue, 11 Feb 2025 08:59:38 -0600 Subject: [PATCH 19/38] Update README.md --- README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.md b/README.md index ae01168..628b37a 100644 --- a/README.md +++ b/README.md @@ -15,30 +15,21 @@ Blobs are packs of binary data addressed by their sha256 hash Blossom Servers expose a few endpoints for managing blobs - `GET /` (optional file `.ext`) [BUD-01](./buds/01.md#get-sha256---get-blob) - - `HEAD /` (optional file `.ext`) [BUD-01](./buds/01.md#head-sha256---has-blob) - - `PUT /upload` [BUD-02](./buds/02.md#put-upload---upload-blob) - `Authentication`: Signed [nostr event](./buds/02.md#upload-authorization-required) - Return a blob descriptor - - `HEAD /upload` [BUD-06](./buds/06.md#head-upload---upload-requirements) - - `GET /list/` [BUD-02](./buds/02.md#get-listpubkey---list-blobs) - Returns an array of blob descriptors - `Authentication` _(optional)_: Signed [nostr event](./buds/02.md#list-authorization-optional) - - `DELETE /` [BUD-02](./buds/02.md#delete-sha256---delete-blob) - `Authentication`: Signed [nostr event](./buds/02.md#delete-authorization-required) - - `PUT /mirror` [BUD-04](./buds/04.md#put-mirror---mirror-blob) - `Authentication`: Signed [nostr event](./buds/02.md#upload-authorization-required) - - `HEAD /media` [BUD-05](./buds/05.md#head-media) - - `PUT /media` [BUD-05](./buds/05.md#put-media) - `Authentication`: Signed [nostr event](./buds/05.md#upload-authorization) - - `PUT /report` [BUD-09](./buds/09.md) ## Protocol specification (BUDs) From 9d8b3cb677953830f589eb6f7b39d5e9b72151f4 Mon Sep 17 00:00:00 2001 From: Kieran Date: Wed, 26 Feb 2025 21:16:03 +0000 Subject: [PATCH 20/38] Update 08.md --- buds/08.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/buds/08.md b/buds/08.md index 8964cc7..c4a0e0a 100644 --- a/buds/08.md +++ b/buds/08.md @@ -23,13 +23,13 @@ An example response would look like: "size": 184292, "type": "application/pdf", "uploaded": 1725909682, - "nip94": { - "url": "https://cdn.example.com/b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553.pdf", - "m": "application/pdf", - "x": "b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553", - "size": "184292", - "magnet": "magnet:?xt=urn:btih:9804c5286a3fb07b2244c968b39bc3cc814313bc&dn=bitcoin.pdf", - "i": "9804c5286a3fb07b2244c968b39bc3cc814313bc" - } + "nip94": [ + "url https://cdn.example.com/b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553.pdf", + "m application/pdf", + "x b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553", + "size 184292", + "magnet magnet:?xt=urn:btih:9804c5286a3fb07b2244c968b39bc3cc814313bc&dn=bitcoin.pdf", + "i 9804c5286a3fb07b2244c968b39bc3cc814313bc" + ] } ``` From a3546a5bc3c9d009e39cb9905f6133a7faff6843 Mon Sep 17 00:00:00 2001 From: Kieran Date: Wed, 26 Feb 2025 21:20:25 +0000 Subject: [PATCH 21/38] Update 08.md --- buds/08.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/buds/08.md b/buds/08.md index c4a0e0a..89c1668 100644 --- a/buds/08.md +++ b/buds/08.md @@ -12,7 +12,7 @@ As described in [BUD-02](./02.md#blob-descriptor) servers MAY add any additional Servers MAY return an additional `nip94` field in the [blob descriptor](./02.md#blob-descriptor) from the `/upload` or `/mirror` endpoints -The `nip94` field should contain a JSON object with the keys being the tag names defined in [NIP-94](https://github.com/nostr-protocol/nips/blob/master/94.md) and the values being strings +The `nip94` field should contain a JSON array with KV pairs as defined in [NIP-94](https://github.com/nostr-protocol/nips/blob/master/94.md) An example response would look like: @@ -24,12 +24,12 @@ An example response would look like: "type": "application/pdf", "uploaded": 1725909682, "nip94": [ - "url https://cdn.example.com/b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553.pdf", - "m application/pdf", - "x b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553", - "size 184292", - "magnet magnet:?xt=urn:btih:9804c5286a3fb07b2244c968b39bc3cc814313bc&dn=bitcoin.pdf", - "i 9804c5286a3fb07b2244c968b39bc3cc814313bc" + ["url", "https://cdn.example.com/b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553.pdf"], + ["m", "application/pdf"], + ["x", "b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553"], + ["size", "184292"], + ["magnet", "magnet:?xt=urn:btih:9804c5286a3fb07b2244c968b39bc3cc814313bc&dn=bitcoin.pdf"], + ["i", "9804c5286a3fb07b2244c968b39bc3cc814313bc"] ] } ``` From 782d382ca7ba228d97bc5d9486bdd598ef5319b6 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Mon, 17 Mar 2025 21:41:34 +0000 Subject: [PATCH 22/38] Clarify authorization requirements in BUD-04: change `MUST` to `MAY` for the `Authorization` header and specify auth type --- buds/04.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buds/04.md b/buds/04.md index eb1d19f..474fce8 100644 --- a/buds/04.md +++ b/buds/04.md @@ -19,11 +19,11 @@ Clients MUST pass the URL of the remote blob as a stringified JSON object in the } ``` -Clients MUST set the `Authorization` header to an upload authorization event defined in [BUD-02](./02.md#upload-authorization-required) +Clients MAY set the `Authorization` header to an upload authorization event defined in [BUD-02](./02.md#upload-authorization-required). When using authorization, the event MUST be of type "upload". The `/mirror` endpoint MUST download the blob from the specified URL and verify that there is at least one `x` tag in the authorization event matching the sha256 hash of the download blob -**Multiple `x` tags MUST NOT be interpreted as the user requesting a bulk mirror.** +**Multiple `x` tags in the authorization event MUST NOT be interpreted as the user requesting a bulk mirror.** The endpoint MUST return a [Blob Descriptor](#blob-descriptor) if the mirroring was successful or an error object if it was not From 2aa65cc373a0dbe179e2b63cf12493c3b14abdbc Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Fri, 25 Apr 2025 08:00:17 -0500 Subject: [PATCH 23/38] Fix spelling mistakes --- buds/01.md | 2 +- buds/03.md | 2 +- buds/05.md | 4 ++-- buds/06.md | 4 ++-- buds/09.md | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/buds/01.md b/buds/01.md index 41466bb..4c42e94 100644 --- a/buds/01.md +++ b/buds/01.md @@ -28,7 +28,7 @@ Authorization events must be generic and must NOT be scoped to specific servers. Events MUST be kind `24242` and have a `t` tag with a verb of `get`, `upload`, `list`, or `delete` -Events MUST have the `content` set to a human readable string explaining to the user what the events inteded use is. For example `Upload Blob`, `Delete dog-picture.png`, `List Images`, etc +Events MUST have the `content` set to a human readable string explaining to the user what the events intended use is. For example `Upload Blob`, `Delete dog-picture.png`, `List Images`, etc All events MUST have a [NIP-40](https://github.com/nostr-protocol/nips/blob/master/40.md) `expiration` tag set to a unix timestamp at which the event should be considered expired. diff --git a/buds/03.md b/buds/03.md index c6a1730..cebc0fb 100644 --- a/buds/03.md +++ b/buds/03.md @@ -68,7 +68,7 @@ Take the following event as an example Once the client discovers that the URL `https://cdn.broken-domain.com/b1674191a88ec5cdd733e4240a81803105dc412d6c6708d53ab94fc248f4f553.pdf` is no longer available. It can perform the following steps to find the blob: -1. Get the SHA256 has from the URL +1. Get the SHA256 hash from the URL 2. Look for the authors server list `kind:10063` 3. If found, Attempt to retrieve the blob from each `server` listed started with the first 4. If not found, the client MAY fallback to using a well-known popular blossom server to retrieve the blob diff --git a/buds/05.md b/buds/05.md index 97d9ff9..a7165eb 100644 --- a/buds/05.md +++ b/buds/05.md @@ -20,7 +20,7 @@ Servers MAY reject media uploads for any reason and should respond with the appr Servers MAY require a `media` [authorization event](./02.md#upload-authorization-required) to identify the uploader -If a server requires a `media` authorization event it MUST preform the following checks +If a server requires a `media` authorization event it MUST perform the following checks 1. The `t` tag MUST be set to `media` 2. MUST contain at least one `x` tag matching the sha256 hash of the body of the request @@ -33,7 +33,7 @@ Servers MUST respond to `HEAD` requests on the `/media` endpoint in a similar wa This endpoint is intentionally limited to optimizing a single blob with the goal of making it easier to distribute -How the blob is optimized is the sole respirability of the server and the client should have no say in what optimization process is used +How the blob is optimized is the sole responsibility of the server and the client should have no say in what optimization process is used The goal of this endpoint is to provide a simple "trusted" optimization endpoint clients can use to optimize media for distribution diff --git a/buds/06.md b/buds/06.md index 739404b..f3b9cbe 100644 --- a/buds/06.md +++ b/buds/06.md @@ -8,7 +8,7 @@ Defines how clients can verify if the upload can be completed before sending the ## HEAD /upload - Upload requirements -The `HEAD /upload` endpoint `MUST` use the `X-SHA-256`, `X-Content-Type` and `X-Content-Length` headers sent by client to get the SHA-256 hash, MIME type and size of the blob that will be uploaded, returning a HTTP status code and a custom header `X-Reason` to indicate some human readable message about the upload requirements. +The `HEAD /upload` endpoint MUST use the `X-SHA-256`, `X-Content-Type` and `X-Content-Length` headers sent by client to get the SHA-256 hash, MIME type and size of the blob that will be uploaded, returning a HTTP status code and a custom header `X-Reason` to indicate some human readable message about the upload requirements. ### Headers @@ -38,7 +38,7 @@ Example response from the server if the upload can be done: HTTP/1.1 200 OK ``` -If the upload cannot proceed, the server `MUST` return an appropriate `4xx` HTTP status code and a custom header `X-Reason` with a human readable error message. +If the upload cannot proceed, the server MUST return an appropriate `4xx` HTTP status code and a custom header `X-Reason` with a human readable error message. Some examples of error messages: diff --git a/buds/09.md b/buds/09.md index 0c2f808..bf3a961 100644 --- a/buds/09.md +++ b/buds/09.md @@ -35,7 +35,7 @@ The clients can show a blob report button on posts or in blob details. Or its RE ### Server behavior -The servers MAY keep the reports somewhere for operators to check and take action on them. they MAY use a list of trusted people or moderators to directly take action on blob without operator request. +The servers MAY keep the reports somewhere for operators to check and take action on them. they MAY use a list of trusted people or moderators to directly take action on blob without operator request. Servers MAY consider removed blobs sha256 as blocked to prevent rewrite. -Servers SHOULD advertise a route or landing page to provide their rules and term of service which affects the report process. +Servers SHOULD advertise a route or landing page to provide their rules and terms of service which affects the report process. From 66e6dcec747c98561be4a677e84415a42dc27d87 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Tue, 13 May 2025 09:31:19 -0500 Subject: [PATCH 24/38] Add BUD-00 to define BUDs and common language --- README.md | 37 ++++++++++++++++++------------------- buds/00.md | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+), 19 deletions(-) create mode 100644 buds/00.md diff --git a/README.md b/README.md index 628b37a..0fc2093 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,29 @@ Blossom uses [nostr](https://github.com/nostr-protocol/nostr) public / private k ## What is it? -Blossom is a spec for a set of HTTP endpoints that allow users to store blobs of data on publicly accessible servers +Blossom is a specification for a set of HTTP endpoints that allow users to store blobs of data on publicly accessible servers ## What are blobs Blobs are packs of binary data addressed by their sha256 hash -## How does it work? +## Protocol specification (BUDs) + +BUDs or **Blossom Upgrade Documents** are short documents that outline an additional feature that a blossom server may implement. + +## BUDs + +- [BUD-00: Blossom Upgrade Documents](./buds/00.md) +- [BUD-01: Server requirements and blob retrieval](./buds/01.md) +- [BUD-02: Blob upload and management](./buds/02.md) +- [BUD-03: User Server List](./buds/03.md) +- [BUD-04: Mirroring blobs](./buds/04.md) +- [BUD-05: Media optimization](./buds/05.md) +- [BUD-06: Upload requirements](./buds/06.md) +- [BUD-08: Nostr File Metadata Tags](./buds/08.md) +- [BUD-09: Blob Report](./buds/09.md) + +## Endpoints Blossom Servers expose a few endpoints for managing blobs @@ -32,23 +48,6 @@ Blossom Servers expose a few endpoints for managing blobs - `Authentication`: Signed [nostr event](./buds/05.md#upload-authorization) - `PUT /report` [BUD-09](./buds/09.md) -## Protocol specification (BUDs) - -BUDs stand for **Blossom Upgrade Documents**. - -See the [BUDs](./buds) folder and specifically [BUD-01](./buds/01.md) and [BUD-02](./buds/02.md) for a detailed explanation of the endpoints - -## BUDs - -- [BUD-01: Server requirements and blob retrieval](./buds/01.md) -- [BUD-02: Blob upload and management](./buds/02.md) -- [BUD-03: User Server List](./buds/03.md) -- [BUD-04: Mirroring blobs](./buds/04.md) -- [BUD-05: Media optimization](./buds/05.md) -- [BUD-06: Upload requirements](./buds/06.md) -- [BUD-08: Nostr File Metadata Tags](./buds/08.md) -- [BUD-09: Blob Report](./buds/09.md) - ## Event kinds | kind | description | BUD | diff --git a/buds/00.md b/buds/00.md new file mode 100644 index 0000000..fc50c19 --- /dev/null +++ b/buds/00.md @@ -0,0 +1,19 @@ +# BUD-00 + +## Blossom Upgrade Documents + +`draft` `mandatory` + +This document details the common language for all following BUDs + +## Language + +All occurences of "MUST", "MUST NOT", "SHOULD", "SHOULD NOT" MUST be interpreted as per [RFC 2119](https://www.rfc-editor.org/rfc/rfc2119) + +## BUDs + +BUDs or "Blossom Upgrade Documents" are short documents that outline an additional requirement or feature that a blossom server MUST or MAY implement. + +## Blobs + +Blobs are raw binary data addressed by the sha256 hash of the data. From fca1c42406b2e98dcf3e839ed21056f99e85133f Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Tue, 13 May 2025 09:31:54 -0500 Subject: [PATCH 25/38] Add missing HEAD for CORS headers --- buds/01.md | 2 +- buds/09.md | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/buds/01.md b/buds/01.md index 4c42e94..894778b 100644 --- a/buds/01.md +++ b/buds/01.md @@ -11,7 +11,7 @@ _All pubkeys MUST be in hex format_ Servers MUST set the `Access-Control-Allow-Origin: *` header on all responses to ensure compatibility with applications hosted on other domains. For [preflight](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#preflighted_requests) (`OPTIONS`) requests, -servers MUST also set, at minimum, the `Access-Control-Allow-Headers: Authorization, *` and `Access-Control-Allow-Methods: GET, PUT, +servers MUST also set, at minimum, the `Access-Control-Allow-Headers: Authorization, *` and `Access-Control-Allow-Methods: GET, HEAD, PUT, DELETE` headers. The header `Access-Control-Max-Age: 86400` MAY be set to cache the results of a preflight request for 24 hours. diff --git a/buds/09.md b/buds/09.md index bf3a961..94c9478 100644 --- a/buds/09.md +++ b/buds/09.md @@ -6,7 +6,6 @@ This bud defines a new endpoint for clients and users to report blobs to servers. - ### PUT /report - reporting a blob The request body MUST be a signed [NIP-56](https://github.com/nostr-protocol/nips/blob/master/56.md) report event with one or more `x` tags containing the hashes of the blobs being reported. From 2d1593d634d23ea60d3d3b42242898642e4d1152 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Tue, 13 May 2025 10:32:09 -0500 Subject: [PATCH 26/38] Clarify wording on BUD-04 --- buds/04.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/buds/04.md b/buds/04.md index 474fce8..dd041d9 100644 --- a/buds/04.md +++ b/buds/04.md @@ -8,7 +8,7 @@ Defines the `/mirror` endpoint ## PUT /mirror - Mirror Blob -A server may expose a `PUT /mirror` endpoint to allow users to copy a blob from a URL instead of uploading it +A server MAY expose a `PUT /mirror` endpoint to allow users to copy a blob from a URL instead of uploading it Clients MUST pass the URL of the remote blob as a stringified JSON object in the request body @@ -23,19 +23,19 @@ Clients MAY set the `Authorization` header to an upload authorization event defi The `/mirror` endpoint MUST download the blob from the specified URL and verify that there is at least one `x` tag in the authorization event matching the sha256 hash of the download blob -**Multiple `x` tags in the authorization event MUST NOT be interpreted as the user requesting a bulk mirror.** +**Multiple `x` tags in the authorization event MUST NOT be interpreted as the user requesting to mirror multiple blobs.** -The endpoint MUST return a [Blob Descriptor](#blob-descriptor) if the mirroring was successful or an error object if it was not +The endpoint MUST return a [Blob Descriptor](#blob-descriptor) and a `2xx` status code if the mirroring was successful or a `4xx` status code and error messageif it was not -Servers should re-use the `Content-Type` header returned from the URL to discover the mime type of the blob. if none is returned it may use the file extension in the URL +Servers SHOULD re-use the `Content-Type` header returned from the request to the URL to discover the mime type of the blob. If the `Content-Type` header is not returned they SHOULD attempt to use the file extension in the URL to guess the mime type. -Servers MAY reject a mirror request for any reason and should respond with the appropriate HTTP `4xx` status code and an error message explaining the reason for the rejection +Servers MAY reject a mirror request for any reason and MUST respond with the appropriate HTTP `4xx` status code and an error message explaining the reason for the rejection. ## Example Flow -1. Client signs authorization event and uploads blob to Server A -1. Server A returns blob descriptor with `url` -1. Client sends the `url` to Server B `/mirror` using the original authorization event -1. Server B downloads blob from Server A using the url -1. Server B verifies downloaded blob hash matches `x` tag in authorization event -1. Server B returns [Blob Descriptor](./02.md#blob-descriptor) +1. Client signs an `upload` authorization event and uploads blob to Server A +1. Server A returns a [Blob Descriptor](./02.md#blob-descriptor) with the `url` +1. Client sends the `url` to Server B `/mirror` using the original `upload` authorization event +1. Server B downloads the blob from Server A using the `url` +1. Server B verifies the downloaded blob hash matches the `x` tag in the authorization event +1. Server B returns a [Blob Descriptor](./02.md#blob-descriptor) From 620d74c2a289798ba660e087aa57d2903b7c376d Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Tue, 13 May 2025 10:50:44 -0500 Subject: [PATCH 27/38] Clarify has blob endpoint in BUD-01 Require headers to be identical to get endpoint --- buds/01.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/buds/01.md b/buds/01.md index 4c42e94..09c872b 100644 --- a/buds/01.md +++ b/buds/01.md @@ -75,11 +75,11 @@ All endpoints MUST be served from the root of the domain (eg. the `/upload` endp ## GET /sha256 - Get Blob -The `GET /` endpoint MUST return the contents of the blob with the `Content-Type` header set to the appropriate MIME-type +The `GET /` endpoint MUST return the contents of the blob in the response body. the `Content-Type` header SHOULD beset to the appropriate MIME-type The endpoint MUST accept an optional file extension in the URL. ie. `.pdf`, `.png`, etc -If the endpoints returns a 301 or 302 redirect it MUST redirect to a URL containing the same sha256 hash as the requested blob. +If the endpoint returns a `301` or `302` redirect it MUST redirect to a URL containing the same sha256 hash as the requested blob. This ensures that if a user was to copy or reuse the redirect URL it would still contain the original sha256 hash ### Get Authorization (optional) @@ -131,7 +131,9 @@ Example event for retrieving multiple blobs from single server: ## HEAD /sha256 - Has Blob -The `HEAD /` endpoint MUST respond with either a `200` or `404` status code +The `HEAD /` endpoint MUST be identical to the `GET /` endpoint except that it MUST NOT return the blob in the reponse body per [RFC 7231](https://www.rfc-editor.org/rfc/rfc7231#section-4.3.2) + +The endpoint MUST respond with the same headers that the `GET /` endpoint would respond with including the `Content-Type` header and other content headers. The endpoint MUST accept an optional file extension in the URL similar to the `GET /` endpoint. ie. `.pdf`, `.png`, etc From 0baee02851f4a3de6cd1a0ca83427aaa51233c64 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Sat, 24 May 2025 12:08:00 -0500 Subject: [PATCH 28/38] add fallback to application/octet-stream --- buds/04.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/04.md b/buds/04.md index dd041d9..dde6fc4 100644 --- a/buds/04.md +++ b/buds/04.md @@ -27,7 +27,7 @@ The `/mirror` endpoint MUST download the blob from the specified URL and verify The endpoint MUST return a [Blob Descriptor](#blob-descriptor) and a `2xx` status code if the mirroring was successful or a `4xx` status code and error messageif it was not -Servers SHOULD re-use the `Content-Type` header returned from the request to the URL to discover the mime type of the blob. If the `Content-Type` header is not returned they SHOULD attempt to use the file extension in the URL to guess the mime type. +Servers SHOULD use the `Content-Type` header returned from the requested URL to infer the mime type of the blob. If the `Content-Type` header is not returned they SHOULD attempt to use the file extension in the URL or fallback to `application/octet-stream`. Servers MAY reject a mirror request for any reason and MUST respond with the appropriate HTTP `4xx` status code and an error message explaining the reason for the rejection. From d6c2f9721fe7e9004ce55397d3899ae96bd0e6e1 Mon Sep 17 00:00:00 2001 From: Sadeq <141845753+SwimmingRieux@users.noreply.github.com> Date: Fri, 6 Jun 2025 18:56:56 +0330 Subject: [PATCH 29/38] Fix typo: Change 'where' to 'were' in Blob upload and management (BUD-02) --- buds/02.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/02.md b/buds/02.md index 6d8519c..7264be9 100644 --- a/buds/02.md +++ b/buds/02.md @@ -71,7 +71,7 @@ Example Authorization event: ## GET /list/pubkey - List Blobs (Optional) -The `/list/` endpoint MUST return a JSON array of [Blob Descriptor](#blob-descriptor) that where uploaded by the specified pubkey +The `/list/` endpoint MUST return a JSON array of [Blob Descriptor](#blob-descriptor) that were uploaded by the specified pubkey The endpoint MUST support a `since` and `until` query parameter to limit the returned blobs by their `uploaded` date From 977d0be083d91d7457000a8e8f74d32925171609 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Tue, 17 Jun 2025 15:00:33 -0500 Subject: [PATCH 30/38] explicitly require content-type and content-length --- buds/01.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buds/01.md b/buds/01.md index 09c872b..92e8121 100644 --- a/buds/01.md +++ b/buds/01.md @@ -131,9 +131,9 @@ Example event for retrieving multiple blobs from single server: ## HEAD /sha256 - Has Blob -The `HEAD /` endpoint MUST be identical to the `GET /` endpoint except that it MUST NOT return the blob in the reponse body per [RFC 7231](https://www.rfc-editor.org/rfc/rfc7231#section-4.3.2) +The `HEAD /` endpoint SHOULD be identical to the `GET /` endpoint except that it MUST NOT return the blob in the reponse body per [RFC 7231](https://www.rfc-editor.org/rfc/rfc7231#section-4.3.2) -The endpoint MUST respond with the same headers that the `GET /` endpoint would respond with including the `Content-Type` header and other content headers. +The endpoint MUST respond with the same `Content-Type` and `Content-Length` headers as the `GET /` endpoint. The endpoint MUST accept an optional file extension in the URL similar to the `GET /` endpoint. ie. `.pdf`, `.png`, etc From 5ef2889547dec88427bf17a3cf7869768b876b75 Mon Sep 17 00:00:00 2001 From: Anthony Accioly <1591739+aaccioly@users.noreply.github.com> Date: Wed, 4 Jun 2025 19:13:37 +0100 Subject: [PATCH 31/38] Make type mandatory in the blob descriptor --- buds/02.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/02.md b/buds/02.md index 7264be9..e491892 100644 --- a/buds/02.md +++ b/buds/02.md @@ -15,7 +15,7 @@ A blob descriptor is a JSON object containing `url`, `sha256`, `size`, `type`, a - `url` A publicly accessible URL to the [BUD-01](./01.md#get-sha256---get-blob) `GET /` endpoint with a file extension - `sha256` The sha256 hash of the blob - `size` The size of the blob in bytes -- `type` (optional) The MIME type of the blob +- `type` The MIME type of the blob (falling back to `application/octet-stream` if unknown) - `uploaded` The unix timestamp of when the blob was uploaded to the server Servers MUST include a file extension in the URL in the `url` field to allow clients to easily embed the URL in social posts or other content From cacfa520dd9b26f3f7220625d00798da5062422e Mon Sep 17 00:00:00 2001 From: Anthony Accioly <1591739+aaccioly@users.noreply.github.com> Date: Wed, 4 Jun 2025 19:58:02 +0100 Subject: [PATCH 32/38] Clarify requirements around Content-Type and Content-Length - Specify that the server must return the MIME type in the Content-Type header for blob retrieval. - Clarify fallback behaviour for unknown MIME types to application/octet-stream. - Improve the description of how servers should infer MIME types and handle Content-Length for mirror requests. --- buds/01.md | 3 +++ buds/04.md | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/buds/01.md b/buds/01.md index c10a883..1b17cc5 100644 --- a/buds/01.md +++ b/buds/01.md @@ -79,6 +79,9 @@ The `GET /` endpoint MUST return the contents of the blob in the respons The endpoint MUST accept an optional file extension in the URL. ie. `.pdf`, `.png`, etc +Regardless of the file extension, the server MUST return the MIME type of the blob in the `Content-Type` +header. If the server does not know the MIME type of the blob, it MUST default to `application/octet-stream` + If the endpoint returns a `301` or `302` redirect it MUST redirect to a URL containing the same sha256 hash as the requested blob. This ensures that if a user was to copy or reuse the redirect URL it would still contain the original sha256 hash diff --git a/buds/04.md b/buds/04.md index dde6fc4..4f323c9 100644 --- a/buds/04.md +++ b/buds/04.md @@ -25,9 +25,14 @@ The `/mirror` endpoint MUST download the blob from the specified URL and verify **Multiple `x` tags in the authorization event MUST NOT be interpreted as the user requesting to mirror multiple blobs.** -The endpoint MUST return a [Blob Descriptor](#blob-descriptor) and a `2xx` status code if the mirroring was successful or a `4xx` status code and error messageif it was not +The endpoint MUST return a [Blob Descriptor](#blob-descriptor) and a `2xx` status code if the mirroring was successful +or a `4xx` status code and error message if it was not. -Servers SHOULD use the `Content-Type` header returned from the requested URL to infer the mime type of the blob. If the `Content-Type` header is not returned they SHOULD attempt to use the file extension in the URL or fallback to `application/octet-stream`. +Servers SHOULD use the `Content-Type` header returned from the requested URL to infer the mime type of the blob. If the +`Content-Type` header is not present they SHOULD attempt to detect the `Content-Type` from the blob contents and file +extension, falling back to `application/octet-stream` if they cannot determine the type. + +Servers MAY use the `Content-Length` header to determine the size of the blob. Servers MAY reject a mirror request for any reason and MUST respond with the appropriate HTTP `4xx` status code and an error message explaining the reason for the rejection. From 1a085ed7bf8d4ae86abc17cb9c737df6ff7c6f05 Mon Sep 17 00:00:00 2001 From: Anthony Accioly <1591739+aaccioly@users.noreply.github.com> Date: Wed, 4 Jun 2025 20:15:03 +0100 Subject: [PATCH 33/38] fix: clarify Content-Type handling for blob retrieval and mirroring --- buds/01.md | 9 +++++---- buds/04.md | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/buds/01.md b/buds/01.md index 1b17cc5..f45d497 100644 --- a/buds/01.md +++ b/buds/01.md @@ -79,8 +79,8 @@ The `GET /` endpoint MUST return the contents of the blob in the respons The endpoint MUST accept an optional file extension in the URL. ie. `.pdf`, `.png`, etc -Regardless of the file extension, the server MUST return the MIME type of the blob in the `Content-Type` -header. If the server does not know the MIME type of the blob, it MUST default to `application/octet-stream` +Regardless of the file extension, the server MUST return the MIME type of the blob in the `Content-Type` header. If the +server does not know the MIME type of the blob, it MUST default to `application/octet-stream` If the endpoint returns a `301` or `302` redirect it MUST redirect to a URL containing the same sha256 hash as the requested blob. This ensures that if a user was to copy or reuse the redirect URL it would still contain the original sha256 hash @@ -134,9 +134,10 @@ Example event for retrieving multiple blobs from single server: ## HEAD /sha256 - Has Blob -The `HEAD /` endpoint SHOULD be identical to the `GET /` endpoint except that it MUST NOT return the blob in the reponse body per [RFC 7231](https://www.rfc-editor.org/rfc/rfc7231#section-4.3.2) +The `HEAD /` endpoint SHOULD be identical to the `GET /` endpoint except that it MUST NOT return the +blob in the reponse body per [RFC 7231](https://www.rfc-editor.org/rfc/rfc7231#section-4.3.2) -The endpoint MUST respond with the same `Content-Type` and `Content-Length` headers as the `GET /` endpoint. +The endpoint MUST respond with the same `Content-Type` and `Content-Length` headerers as the `GET /` endpoint The endpoint MUST accept an optional file extension in the URL similar to the `GET /` endpoint. ie. `.pdf`, `.png`, etc diff --git a/buds/04.md b/buds/04.md index 4f323c9..6165ed4 100644 --- a/buds/04.md +++ b/buds/04.md @@ -28,9 +28,9 @@ The `/mirror` endpoint MUST download the blob from the specified URL and verify The endpoint MUST return a [Blob Descriptor](#blob-descriptor) and a `2xx` status code if the mirroring was successful or a `4xx` status code and error message if it was not. -Servers SHOULD use the `Content-Type` header returned from the requested URL to infer the mime type of the blob. If the -`Content-Type` header is not present they SHOULD attempt to detect the `Content-Type` from the blob contents and file -extension, falling back to `application/octet-stream` if they cannot determine the type. +The destination server SHOULD use the `Content-Type` header returned from the origin server to infer the mime type of +the blob. If the `Content-Type` header is not present the destination server SHOULD attempt to detect the `Content-Type` +from the blob contents and file extension, falling back to `application/octet-stream` if it cannot determine the type. Servers MAY use the `Content-Length` header to determine the size of the blob. From 611272e251cc25c408f79a2cb33e4425aba309bf Mon Sep 17 00:00:00 2001 From: Anthony Accioly <1591739+aaccioly@users.noreply.github.com> Date: Wed, 4 Jun 2025 21:37:13 +0100 Subject: [PATCH 34/38] Enhance proxying and redirection specification for blob retrieval --- buds/01.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/buds/01.md b/buds/01.md index f45d497..657b6ba 100644 --- a/buds/01.md +++ b/buds/01.md @@ -82,8 +82,22 @@ The endpoint MUST accept an optional file extension in the URL. ie. `.pdf`, `.pn Regardless of the file extension, the server MUST return the MIME type of the blob in the `Content-Type` header. If the server does not know the MIME type of the blob, it MUST default to `application/octet-stream` -If the endpoint returns a `301` or `302` redirect it MUST redirect to a URL containing the same sha256 hash as the requested blob. -This ensures that if a user was to copy or reuse the redirect URL it would still contain the original sha256 hash +### Proxying and Redirection (Optional) + +If the endpoint returns a redirection 3xx status code such as 307 or 308 ([RFC 9110 section +15.4](https://datatracker.ietf.org/doc/html/rfc9110#name-redirection-3xx)), it MUST redirect to a URL containing the +same sha256 hash as the requested blob. This ensures that if a user copies or reuses the redirect URL, it will still +contain the original sha56 hash. + +While the final blob may not be served from a Blossom server (e.g. CDN, IPFS, object storage, etc.), the destination +server MUST set the `Access-Control-Allow-Origin: *` header on the response to allow cross-origin requests, as well as +the `Content-Type` and `Content-Length` headers to ensure the blob can be correctly displayed by clients. Two ways to +guarantee this are: + +1. Proxying the blob through the Blossom server, allowing it to override headers such as `Content-Type`. +2. Manipulating the redirect URL to include a file extension that matches the blob type, such as `.pdf`, `.png`, etc. If +the server is unable to determine the MIME type of the blob, it MUST default to `application/octet-stream` and MAY +include a file extension in the URL that reflects the blob type (e.g. `.bin`, `.dat`, etc.). ### Get Authorization (optional) From b1a336fe750bb740552bc3d1cc7ce771e5849d41 Mon Sep 17 00:00:00 2001 From: Anthony Accioly <1591739+aaccioly@users.noreply.github.com> Date: Wed, 4 Jun 2025 21:38:51 +0100 Subject: [PATCH 35/38] Add optional file extension normalization during upload --- buds/02.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/buds/02.md b/buds/02.md index e491892..fa073b0 100644 --- a/buds/02.md +++ b/buds/02.md @@ -42,7 +42,15 @@ The endpoint MUST NOT modify the blob in any way and should return the exact sam The endpoint MUST return a [Blob Descriptor](#blob-descriptor) if the upload was successful or an error object if it was not -Servers MAY reject an upload for any reason and should respond with the appropriate HTTP `4xx` status code and an error message explaining the reason for the rejection +Servers MAY reject an upload for any reason and should respond with the appropriate HTTP `4xx` status code and an error +message explaining the reason for the rejection + +### File extension normalization (Optional) + +When storing blobs, servers MAY normalise the file extension to a standard format (e.g. `.pdf`, `.png`, etc.) based on +the MIME type of the blob. This can be especially useful when the `GET /` endpoint is redirected to an external +URL (see the [proxying and redirection section from BUD-01](./01.md#proxying-and-redirection-optional)), as external +servers may rely on the file extension to serve the blob correctly. ### Upload Authorization (Optional) From 658c608b119e11702127322531382fabd7959be3 Mon Sep 17 00:00:00 2001 From: Anthony Accioly <1591739+aaccioly@users.noreply.github.com> Date: Wed, 4 Jun 2025 21:46:07 +0100 Subject: [PATCH 36/38] fix: update authorization event reference link in mirroring documentation --- buds/04.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/04.md b/buds/04.md index 6165ed4..67b013b 100644 --- a/buds/04.md +++ b/buds/04.md @@ -19,7 +19,7 @@ Clients MUST pass the URL of the remote blob as a stringified JSON object in the } ``` -Clients MAY set the `Authorization` header to an upload authorization event defined in [BUD-02](./02.md#upload-authorization-required). When using authorization, the event MUST be of type "upload". +Clients MAY set the `Authorization` header to an upload authorization event defined in [BUD-02](./02.md#upload-authorization-optional). When using authorization, the event MUST be of type "upload". The `/mirror` endpoint MUST download the blob from the specified URL and verify that there is at least one `x` tag in the authorization event matching the sha256 hash of the download blob From 85de0197f0e14c11fbe19958d7fbd4e7f8f10e26 Mon Sep 17 00:00:00 2001 From: Anthony Accioly <1591739+aaccioly@users.noreply.github.com> Date: Tue, 17 Jun 2025 23:18:13 +0100 Subject: [PATCH 37/38] fix: correct typo in Content-Length headers description in blob retrieval documentation --- buds/01.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/01.md b/buds/01.md index 657b6ba..4808b81 100644 --- a/buds/01.md +++ b/buds/01.md @@ -151,7 +151,7 @@ Example event for retrieving multiple blobs from single server: The `HEAD /` endpoint SHOULD be identical to the `GET /` endpoint except that it MUST NOT return the blob in the reponse body per [RFC 7231](https://www.rfc-editor.org/rfc/rfc7231#section-4.3.2) -The endpoint MUST respond with the same `Content-Type` and `Content-Length` headerers as the `GET /` endpoint +The endpoint MUST respond with the same `Content-Type` and `Content-Length` headers as the `GET /` endpoint. The endpoint MUST accept an optional file extension in the URL similar to the `GET /` endpoint. ie. `.pdf`, `.png`, etc From 39ce39aa4d5b02e2b57b745e19debfc412b1f154 Mon Sep 17 00:00:00 2001 From: Anthony Accioly <1591739+aaccioly@users.noreply.github.com> Date: Mon, 23 Jun 2025 14:21:32 +0100 Subject: [PATCH 38/38] fix: correct grammar in bud/01 redirect requirements Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com> --- buds/01.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buds/01.md b/buds/01.md index 4808b81..94243bf 100644 --- a/buds/01.md +++ b/buds/01.md @@ -86,8 +86,8 @@ server does not know the MIME type of the blob, it MUST default to `application/ If the endpoint returns a redirection 3xx status code such as 307 or 308 ([RFC 9110 section 15.4](https://datatracker.ietf.org/doc/html/rfc9110#name-redirection-3xx)), it MUST redirect to a URL containing the -same sha256 hash as the requested blob. This ensures that if a user copies or reuses the redirect URL, it will still -contain the original sha56 hash. +same sha256 hash as the requested blob. This ensures that if a user copies or reuses the redirect URL, it will +contain the original sha256 hash. While the final blob may not be served from a Blossom server (e.g. CDN, IPFS, object storage, etc.), the destination server MUST set the `Access-Control-Allow-Origin: *` header on the response to allow cross-origin requests, as well as