From 2bd04954a41489afa66825662dbbe200227b4a9d Mon Sep 17 00:00:00 2001 From: Quentin Date: Tue, 10 Sep 2024 10:41:34 +0200 Subject: [PATCH 01/46] Paid storage --- README.md | 1 + buds/07.md | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 buds/07.md diff --git a/README.md b/README.md index 9c9c85c..7ca334b 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ See the [BUDs](./buds) folder and specifically [BUD-01](./buds/01.md) and [BUD-0 - [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-07: Paid storage](./buds/07.md) ## Event kinds diff --git a/buds/07.md b/buds/07.md new file mode 100644 index 0000000..64a74d5 --- /dev/null +++ b/buds/07.md @@ -0,0 +1,69 @@ +BUD-07 +====== + +Paid storage +--------------- + +`draft` `optional` + +Payment requirements for blob storage. + +## Payment Required + +Some servers **MAY** require payment for file storage. In that case, these endpoints **MUST** return a **402 Payment Required** status code and a `Www-Authenticate` header when the payment is required. + +- [HEAD /upload](./01.md#head-sha256---has-blob) +- [PUT /upload](./02.md#put-upload---upload-blob) +- [HEAT /](./01.md#head-sha256---has-blob) +- [GET /](./01.md#get-sha256---get-blob) + + +## Authenticate header + +The `Www-Authenticate` header is a standard HTTP header field that defines the authentication method that should be used to gain access to a resource. It is used by the server to challenge the client to authenticate itself. Using the [L402 protocol](https://github.com/lightninglabs/L402), the `Www-Authenticate` header can be used to request payment for specific blobs. + +The `Www-Authenticate` header contains the `macaroon` and `invoice` fields for servers and the `macaroon` and `preimage` fields for clients. + +- `macaroon` A base64 encoded string containing the macaroon, see [L402 macaroons](https://github.com/lightninglabs/L402/blob/master/macaroons.md). +- `invoice` A string containing LN the payment request. +- `preimage` A string containing the payment preimage. + +### Server implementation + +Servers **MUST** return a **402 Payment Required** status code along with a `Www-Authenticate` header containing the `macaroon` and `invoice` fields using the [L402 protocol](https://github.com/lightninglabs/L402) for all requests related to the blob: + +Schema: + +```http +HTTP/1.1 402 Payment Required +Www-Authenticate: L402 macaroon="",invoice="" +``` + +Example: + +```http +HTTP/1.1 402 Payment Required +Www-Authenticate: L402 macaroon="eyJJRCI6IjMyMGQyMDAwZjVjODQ0NmQ3OTgyMjBlYTMxOGY5ZDg0MmM5MWZkMjYyMTliODZhYWE2ODEzMDBjYjc4YTI2YWEiLCJ2ZXJzaW9uIjoiMCIsInBheW1lbnRfaGFzaCI6IjQzN2Q2YTg1Y2M2ZDQxMzNiYWIzZTEwNWM0NjViZjMzNTQ4ODNjNmVkNzNkZmFhODA3MDQ1ZmIyMTI4MTRmMjYiLCJ0b2tlbl9pZCI6IjExMzIiLCJsb2NhdGlvbiI6Ii9hcGkvdjIvbWVkaWEvNjZiMGU3NzFlYTM0ZDE0MTBkNTM4Nzk3MjQ0NGRiN2RkNjU3OGE5OTBhZDhmMjRjZjFiZTE1OWUwYmVkODdmYy8wNmQwM2FmYzJjZTJkYzY2ODUxMjFmNTFhZjM5ZDUyNjM2OWY5NjgyZTFhOWNiNGRiZGFlZDhlOWI1ZTJiNDI3Lm1wNCIsImNhdmVhdHMiOlsiIl19",invoice="lnbc30n1pnvscg5pp56rft56xqcdamm59epsvmes06ymctq7gjt3nfnu3mjaw6fmfuhweqhp5w48l28v60yvythn6qvnpq0lez54422a042yaw4kq8arvd68a6n7qcqzzsxqyz5vqsp5a5tz8qqf897a2psdh3gc8m72tkpfwf03p8j95tgvkwm0jx97ypqs9qxpqysgqxuv6h48rzmguqkyxdyegrwf2m9890st2mty7z68acvcp9s8ukpx5daja0tdfq4tn2lmt443kua45zh6dzuy90grz02hcfauqx999g4gpf9lqhw" +``` + +### Client implementation + +Clients `SHOULD` check the `Www-Authenticate` header recieved from the server and display the payment request to the user. If the payment is done, the client `SHOULD` use *the same macaroon* and the payment `preimage`to create a new `Www-Authenticate` header to be used in the next requests. + +Schema: + +```http +Www-Authenticate: L402 macaroon="",preimage="" +``` + +Example: + +```http +Www-Authenticate: L402 macaroon="eyJJRCI6IjMyMGQyMDAwZjVjODQ0NmQ3OTgyMjBlYTMxOGY5ZDg0MmM5MWZkMjYyMTliODZhYWE2ODEzMDBjYjc4YTI2YWEiLCJ2ZXJzaW9uIjoiMCIsInBheW1lbnRfaGFzaCI6IjQzN2Q2YTg1Y2M2ZDQxMzNiYWIzZTEwNWM0NjViZjMzNTQ4ODNjNmVkNzNkZmFhODA3MDQ1ZmIyMTI4MTRmMjYiLCJ0b2tlbl9pZCI6IjExMzIiLCJsb2NhdGlvbiI6Ii9hcGkvdjIvbWVkaWEvNjZiMGU3NzFlYTM0ZDE0MTBkNTM4Nzk3MjQ0NGRiN2RkNjU3OGE5OTBhZDhmMjRjZjFiZTE1OWUwYmVkODdmYy8wNmQwM2FmYzJjZTJkYzY2ODUxMjFmNTFhZjM5ZDUyNjM2OWY5NjgyZTFhOWNiNGRiZGFlZDhlOWI1ZTJiNDI3Lm1wNCIsImNhdmVhdHMiOlsiIl19",preimage="3e590d1336f241e858359c865802b4883ca91d47379c840af66785e2143bad22" +``` + +### Unpaid Uploads + +Some servers `MAY` accept unpaid uploads and require payment after the upload is completed. In this case, the server `MUST` return a **402 Payment Required** status code along with a `Www-Authenticate` header containing the macaroon and payment request fields using the [L402 protocol](https://github.com/lightninglabs/L402) for the endpoints described in [#payment-required](#payment-required). + +For backward compatibility, the server `SHOULD` display a QR code, JSON file, or other useful information instead of the blob in the response body. When the payment is completed, the server `MUST` replace this information with the actual uploaded file. From 17d6814fd0a01b379dbc13be8ad33aa3e3416711 Mon Sep 17 00:00:00 2001 From: Quentin <125748180+quentintaranpino@users.noreply.github.com> Date: Thu, 12 Sep 2024 09:48:05 +0200 Subject: [PATCH 02/46] Update buds/07.md Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com> --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index 64a74d5..c9c9023 100644 --- a/buds/07.md +++ b/buds/07.md @@ -48,7 +48,7 @@ Www-Authenticate: L402 macaroon="eyJJRCI6IjMyMGQyMDAwZjVjODQ0NmQ3OTgyMjBlYTMxOGY ### Client implementation -Clients `SHOULD` check the `Www-Authenticate` header recieved from the server and display the payment request to the user. If the payment is done, the client `SHOULD` use *the same macaroon* and the payment `preimage`to create a new `Www-Authenticate` header to be used in the next requests. +Clients SHOULD check the `Www-Authenticate` header received from the server and display the payment request to the user. When the payment is complete the client should use *the same macaroon* and the payment `preimage` to create a new `Www-Authenticate` header to be used in the next request. Schema: From c3f7a5da0d495cae8bee9aa0c8f3c3f9ae66a552 Mon Sep 17 00:00:00 2001 From: Quentin <125748180+quentintaranpino@users.noreply.github.com> Date: Thu, 12 Sep 2024 09:48:20 +0200 Subject: [PATCH 03/46] Update buds/07.md Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com> --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index c9c9023..9c498b4 100644 --- a/buds/07.md +++ b/buds/07.md @@ -30,7 +30,7 @@ The `Www-Authenticate` header contains the `macaroon` and `invoice` fields for s ### Server implementation -Servers **MUST** return a **402 Payment Required** status code along with a `Www-Authenticate` header containing the `macaroon` and `invoice` fields using the [L402 protocol](https://github.com/lightninglabs/L402) for all requests related to the blob: +Servers MUST return a **402 Payment Required** status code along with a `Www-Authenticate` header containing the `macaroon` and `invoice` fields using the [L402 protocol](https://github.com/lightninglabs/L402) for all requests related to the blob: Schema: From b6bd9b9a943491e93974574f405a4c77c9d48c91 Mon Sep 17 00:00:00 2001 From: Quentin <125748180+quentintaranpino@users.noreply.github.com> Date: Thu, 12 Sep 2024 09:48:26 +0200 Subject: [PATCH 04/46] Update buds/07.md Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com> --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index 9c498b4..e712794 100644 --- a/buds/07.md +++ b/buds/07.md @@ -10,7 +10,7 @@ Payment requirements for blob storage. ## Payment Required -Some servers **MAY** require payment for file storage. In that case, these endpoints **MUST** return a **402 Payment Required** status code and a `Www-Authenticate` header when the payment is required. +Some servers MAY require payment for file storage. In that case, these endpoints MUST return a **402 Payment Required** status code and a `Www-Authenticate` header when the payment is required. - [HEAD /upload](./01.md#head-sha256---has-blob) - [PUT /upload](./02.md#put-upload---upload-blob) From f0ac329e9062c20466dd5123c027b7cc3cf3dd49 Mon Sep 17 00:00:00 2001 From: Quentin <125748180+quentintaranpino@users.noreply.github.com> Date: Thu, 12 Sep 2024 09:48:34 +0200 Subject: [PATCH 05/46] Update buds/07.md Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com> --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index e712794..4d5e02b 100644 --- a/buds/07.md +++ b/buds/07.md @@ -64,6 +64,6 @@ Www-Authenticate: L402 macaroon="eyJJRCI6IjMyMGQyMDAwZjVjODQ0NmQ3OTgyMjBlYTMxOGY ### Unpaid Uploads -Some servers `MAY` accept unpaid uploads and require payment after the upload is completed. In this case, the server `MUST` return a **402 Payment Required** status code along with a `Www-Authenticate` header containing the macaroon and payment request fields using the [L402 protocol](https://github.com/lightninglabs/L402) for the endpoints described in [#payment-required](#payment-required). +Some servers MAY accept unpaid uploads and require payment after the upload is completed. In this case, the server MUST return a **402 Payment Required** status code along with a `Www-Authenticate` header containing the macaroon and payment request fields using the [L402 protocol](https://github.com/lightninglabs/L402) for the endpoints described in [#payment-required](#payment-required). For backward compatibility, the server `SHOULD` display a QR code, JSON file, or other useful information instead of the blob in the response body. When the payment is completed, the server `MUST` replace this information with the actual uploaded file. From 7a57b0c19a8e1e65aecf988b525925664bd729bf Mon Sep 17 00:00:00 2001 From: quentintaranpino Date: Thu, 12 Sep 2024 10:00:58 +0200 Subject: [PATCH 06/46] Backward compatibility proposal --- buds/07.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/buds/07.md b/buds/07.md index 4d5e02b..34feb59 100644 --- a/buds/07.md +++ b/buds/07.md @@ -62,8 +62,6 @@ Example: Www-Authenticate: L402 macaroon="eyJJRCI6IjMyMGQyMDAwZjVjODQ0NmQ3OTgyMjBlYTMxOGY5ZDg0MmM5MWZkMjYyMTliODZhYWE2ODEzMDBjYjc4YTI2YWEiLCJ2ZXJzaW9uIjoiMCIsInBheW1lbnRfaGFzaCI6IjQzN2Q2YTg1Y2M2ZDQxMzNiYWIzZTEwNWM0NjViZjMzNTQ4ODNjNmVkNzNkZmFhODA3MDQ1ZmIyMTI4MTRmMjYiLCJ0b2tlbl9pZCI6IjExMzIiLCJsb2NhdGlvbiI6Ii9hcGkvdjIvbWVkaWEvNjZiMGU3NzFlYTM0ZDE0MTBkNTM4Nzk3MjQ0NGRiN2RkNjU3OGE5OTBhZDhmMjRjZjFiZTE1OWUwYmVkODdmYy8wNmQwM2FmYzJjZTJkYzY2ODUxMjFmNTFhZjM5ZDUyNjM2OWY5NjgyZTFhOWNiNGRiZGFlZDhlOWI1ZTJiNDI3Lm1wNCIsImNhdmVhdHMiOlsiIl19",preimage="3e590d1336f241e858359c865802b4883ca91d47379c840af66785e2143bad22" ``` -### Unpaid Uploads +### Backward compatibility -Some servers MAY accept unpaid uploads and require payment after the upload is completed. In this case, the server MUST return a **402 Payment Required** status code along with a `Www-Authenticate` header containing the macaroon and payment request fields using the [L402 protocol](https://github.com/lightninglabs/L402) for the endpoints described in [#payment-required](#payment-required). - -For backward compatibility, the server `SHOULD` display a QR code, JSON file, or other useful information instead of the blob in the response body. When the payment is completed, the server `MUST` replace this information with the actual uploaded file. +For backward compatibility, when a client requests an unpaid blob, the server `SHOULD` return alternative information, such as a QR code, a JSON file, or other useful data in the response body. This serves as a placeholder, clearly indicating that the actual file is unavailable until payment is made. Once the payment is completed, the server `MUST` replace this placeholder with the actual blob in subsequent requests. This ensures that legacy clients still receive meaningful responses without breaking functionality, while supporting the new payment logic. \ No newline at end of file From 40a7cd943cb42fa43bb833615232a3d54a7f5ee6 Mon Sep 17 00:00:00 2001 From: quentintaranpino Date: Thu, 12 Sep 2024 10:04:30 +0200 Subject: [PATCH 07/46] fix typos --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index 34feb59..a9aa3f2 100644 --- a/buds/07.md +++ b/buds/07.md @@ -64,4 +64,4 @@ Www-Authenticate: L402 macaroon="eyJJRCI6IjMyMGQyMDAwZjVjODQ0NmQ3OTgyMjBlYTMxOGY ### Backward compatibility -For backward compatibility, when a client requests an unpaid blob, the server `SHOULD` return alternative information, such as a QR code, a JSON file, or other useful data in the response body. This serves as a placeholder, clearly indicating that the actual file is unavailable until payment is made. Once the payment is completed, the server `MUST` replace this placeholder with the actual blob in subsequent requests. This ensures that legacy clients still receive meaningful responses without breaking functionality, while supporting the new payment logic. \ No newline at end of file +For backward compatibility, when a client requests an unpaid blob, the server SHOULD return alternative information, such as a QR code, a JSON file, or other useful data in the response body. This serves as a placeholder, clearly indicating that the actual file is unavailable until payment is made. Once the payment is completed, the server MUST replace this placeholder with the actual blob in subsequent requests. This ensures that legacy clients still receive meaningful responses without breaking functionality, while supporting the new payment logic. \ No newline at end of file From cd778dec22d2ef529b7ab46e3bb8531a60a14525 Mon Sep 17 00:00:00 2001 From: quentintaranpino Date: Mon, 16 Sep 2024 09:22:58 +0200 Subject: [PATCH 08/46] change backward compatibility text --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index a9aa3f2..ecc639c 100644 --- a/buds/07.md +++ b/buds/07.md @@ -64,4 +64,4 @@ Www-Authenticate: L402 macaroon="eyJJRCI6IjMyMGQyMDAwZjVjODQ0NmQ3OTgyMjBlYTMxOGY ### Backward compatibility -For backward compatibility, when a client requests an unpaid blob, the server SHOULD return alternative information, such as a QR code, a JSON file, or other useful data in the response body. This serves as a placeholder, clearly indicating that the actual file is unavailable until payment is made. Once the payment is completed, the server MUST replace this placeholder with the actual blob in subsequent requests. This ensures that legacy clients still receive meaningful responses without breaking functionality, while supporting the new payment logic. \ No newline at end of file +For backward compatibility with image and video uploads, the server MAY return an image or video displaying a QR code or other useful information instead of the original blob. When the payment is completed, the server SHOULD replace this information with the original uploaded blob. \ No newline at end of file From 942fb60e976c83eecd938d950cfc69d67a07ff8c Mon Sep 17 00:00:00 2001 From: Quentin Date: Fri, 1 Nov 2024 10:55:49 +0100 Subject: [PATCH 09/46] Update BUD-07 for multiple L2; discard L402 --- buds/07.md | 93 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 30 deletions(-) diff --git a/buds/07.md b/buds/07.md index ecc639c..0ee6ae9 100644 --- a/buds/07.md +++ b/buds/07.md @@ -10,58 +10,91 @@ Payment requirements for blob storage. ## Payment Required -Some servers MAY require payment for file storage. In that case, these endpoints MUST return a **402 Payment Required** status code and a `Www-Authenticate` header when the payment is required. +Some servers MAY require payment for file storage. In that case, these endpoints MUST return a **402 Payment Required** status code and a `X-Payment` header when the payment is required. - [HEAD /upload](./01.md#head-sha256---has-blob) - [PUT /upload](./02.md#put-upload---upload-blob) - [HEAT /](./01.md#head-sha256---has-blob) - [GET /](./01.md#get-sha256---get-blob) +## Server header -## Authenticate header +The `X-Payment` header is used by the server to inform the client that payment is required for the requested operation, MUST contain the following fields: -The `Www-Authenticate` header is a standard HTTP header field that defines the authentication method that should be used to gain access to a resource. It is used by the server to challenge the client to authenticate itself. Using the [L402 protocol](https://github.com/lightninglabs/L402), the `Www-Authenticate` header can be used to request payment for specific blobs. +- blob: The blob to be paid. +- amount: The amount to be paid (*optional*). +- payment_method: The payment system to be used (e.g., cashu, lightning, liquid). +- payment_details: L2 specific payment details. -The `Www-Authenticate` header contains the `macaroon` and `invoice` fields for servers and the `macaroon` and `preimage` fields for clients. +Each payment method has its own requirements and the server SHOULD provide the necessary information for the client to complete the payment. -- `macaroon` A base64 encoded string containing the macaroon, see [L402 macaroons](https://github.com/lightninglabs/L402/blob/master/macaroons.md). -- `invoice` A string containing LN the payment request. -- `preimage` A string containing the payment preimage. +Example for cashu: -### Server implementation +```json +{ + "blob": "481d5f1a374e3750518db22337bc6cb3be5be615d550ba189c9a9a55f6d55644", + "payment_method": "cashu", + "payment_details": { + "amount": "300", + "mints": "https://example.com", + "unit": "sat", + "pubkey": "0a3bce8b6005175d25432244340912dfa431a0d62681d9720cda9196398d7222" + } +} +``` -Servers MUST return a **402 Payment Required** status code along with a `Www-Authenticate` header containing the `macaroon` and `invoice` fields using the [L402 protocol](https://github.com/lightninglabs/L402) for all requests related to the blob: +Example for lightning: + +```json +{ + "blob": "481d5f1a374e3750518db22337bc6cb3be5be615d550ba189c9a9a55f6d55644", + "amount": "300", + "payment_method": "lightning", + "payment_details": { + "payment_request": "lnbc300n1pw4..:", + } +} + +Example for liquid: + +```json +{ + "blob": "481d5f1a374e3750518db22337bc6cb3be5be615d550ba189c9a9a55f6d55644", + "payment_method": "liquid", + "payment_details": { + "payment_request": { + "address": "VJLgF1s3...", + "asset_id": "6f0279e9ed...", + "amount": 0.000300, + "memo": "test" + } + } +} +``` Schema: ```http HTTP/1.1 402 Payment Required -Www-Authenticate: L402 macaroon="",invoice="" -``` - -Example: - -```http -HTTP/1.1 402 Payment Required -Www-Authenticate: L402 macaroon="eyJJRCI6IjMyMGQyMDAwZjVjODQ0NmQ3OTgyMjBlYTMxOGY5ZDg0MmM5MWZkMjYyMTliODZhYWE2ODEzMDBjYjc4YTI2YWEiLCJ2ZXJzaW9uIjoiMCIsInBheW1lbnRfaGFzaCI6IjQzN2Q2YTg1Y2M2ZDQxMzNiYWIzZTEwNWM0NjViZjMzNTQ4ODNjNmVkNzNkZmFhODA3MDQ1ZmIyMTI4MTRmMjYiLCJ0b2tlbl9pZCI6IjExMzIiLCJsb2NhdGlvbiI6Ii9hcGkvdjIvbWVkaWEvNjZiMGU3NzFlYTM0ZDE0MTBkNTM4Nzk3MjQ0NGRiN2RkNjU3OGE5OTBhZDhmMjRjZjFiZTE1OWUwYmVkODdmYy8wNmQwM2FmYzJjZTJkYzY2ODUxMjFmNTFhZjM5ZDUyNjM2OWY5NjgyZTFhOWNiNGRiZGFlZDhlOWI1ZTJiNDI3Lm1wNCIsImNhdmVhdHMiOlsiIl19",invoice="lnbc30n1pnvscg5pp56rft56xqcdamm59epsvmes06ymctq7gjt3nfnu3mjaw6fmfuhweqhp5w48l28v60yvythn6qvnpq0lez54422a042yaw4kq8arvd68a6n7qcqzzsxqyz5vqsp5a5tz8qqf897a2psdh3gc8m72tkpfwf03p8j95tgvkwm0jx97ypqs9qxpqysgqxuv6h48rzmguqkyxdyegrwf2m9890st2mty7z68acvcp9s8ukpx5daja0tdfq4tn2lmt443kua45zh6dzuy90grz02hcfauqx999g4gpf9lqhw" +X-Payment: "" ``` ### Client implementation -Clients SHOULD check the `Www-Authenticate` header received from the server and display the payment request to the user. When the payment is complete the client should use *the same macaroon* and the payment `preimage` to create a new `Www-Authenticate` header to be used in the next request. +Clients MUST check the `X-Payment` header received from the server and display the payment request to the user. When the payment is complete the client MUST use the same header to inform the server that the payment was successful using this structure: + +- blob: The paid blob. +- payment_proof: The payment proof. (e.g., preimage for cashu and lightning, txid for liquid). + +```json +{ + "blob": "481d5f1a374e3750518db22337bc6cb3be5be615d550ba189c9a9a55f6d55644", + "payment_proof": "c3b9e2..." +} +``` Schema: - + ```http -Www-Authenticate: L402 macaroon="",preimage="" +X-Payment: "" ``` - -Example: - -```http -Www-Authenticate: L402 macaroon="eyJJRCI6IjMyMGQyMDAwZjVjODQ0NmQ3OTgyMjBlYTMxOGY5ZDg0MmM5MWZkMjYyMTliODZhYWE2ODEzMDBjYjc4YTI2YWEiLCJ2ZXJzaW9uIjoiMCIsInBheW1lbnRfaGFzaCI6IjQzN2Q2YTg1Y2M2ZDQxMzNiYWIzZTEwNWM0NjViZjMzNTQ4ODNjNmVkNzNkZmFhODA3MDQ1ZmIyMTI4MTRmMjYiLCJ0b2tlbl9pZCI6IjExMzIiLCJsb2NhdGlvbiI6Ii9hcGkvdjIvbWVkaWEvNjZiMGU3NzFlYTM0ZDE0MTBkNTM4Nzk3MjQ0NGRiN2RkNjU3OGE5OTBhZDhmMjRjZjFiZTE1OWUwYmVkODdmYy8wNmQwM2FmYzJjZTJkYzY2ODUxMjFmNTFhZjM5ZDUyNjM2OWY5NjgyZTFhOWNiNGRiZGFlZDhlOWI1ZTJiNDI3Lm1wNCIsImNhdmVhdHMiOlsiIl19",preimage="3e590d1336f241e858359c865802b4883ca91d47379c840af66785e2143bad22" -``` - -### Backward compatibility - -For backward compatibility with image and video uploads, the server MAY return an image or video displaying a QR code or other useful information instead of the original blob. When the payment is completed, the server SHOULD replace this information with the original uploaded blob. \ No newline at end of file From 5c0ecbb4fab8b4017d867b9523e103ee6965ea34 Mon Sep 17 00:00:00 2001 From: Quentin Date: Tue, 12 Nov 2024 10:01:43 +0100 Subject: [PATCH 10/46] fix typo --- buds/07.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buds/07.md b/buds/07.md index 0ee6ae9..c76c389 100644 --- a/buds/07.md +++ b/buds/07.md @@ -55,6 +55,8 @@ Example for lightning: } } +``` + Example for liquid: ```json From bf417ae115dd8e735afd5f559478ea69a55b951b Mon Sep 17 00:00:00 2001 From: Quentin Date: Mon, 18 Nov 2024 12:28:43 +0100 Subject: [PATCH 11/46] using different headers for each payment method --- buds/07.md | 148 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 105 insertions(+), 43 deletions(-) diff --git a/buds/07.md b/buds/07.md index c76c389..880c04a 100644 --- a/buds/07.md +++ b/buds/07.md @@ -10,93 +10,155 @@ Payment requirements for blob storage. ## Payment Required -Some servers MAY require payment for file storage. In that case, these endpoints MUST return a **402 Payment Required** status code and a `X-Payment` header when the payment is required. +Some servers MAY require payment for file storage. In such cases, these endpoints MUST return a **402 Payment Required** status code: -- [HEAD /upload](./01.md#head-sha256---has-blob) +- [HEAD /upload](./01.md#head-sha256---has-blob) (Optional, if [BU-06](./06.md) is implemented) - [PUT /upload](./02.md#put-upload---upload-blob) - [HEAT /](./01.md#head-sha256---has-blob) - [GET /](./01.md#get-sha256---get-blob) -## Server header +When payment is required, the server MUST include one or more `X-{payment_method}` header(s), each corresponding to a supported payment method. -The `X-Payment` header is used by the server to inform the client that payment is required for the requested operation, MUST contain the following fields: +## Server headers -- blob: The blob to be paid. -- amount: The amount to be paid (*optional*). -- payment_method: The payment system to be used (e.g., cashu, lightning, liquid). -- payment_details: L2 specific payment details. +The `X-{payment_method}` header is used by the server to inform the client that payment is required for the requested operation. The server MUST provide specific headers for each supported payment method, using the following conventions: -Each payment method has its own requirements and the server SHOULD provide the necessary information for the client to complete the payment. +- `X-{payment_method}`: Base64 UrlSafe encoded JSON with the payment details. + +Supported payment methods: + +- `X-Cashu`: Payment details for the cashu payment method. +- `X-Lightning`: Payment details for the lightning payment method. + +If a server supports multiple payment methods, it MAY send multiple `X-{payment_method}` headers in the same response. The client MUST choose one of the provided methods and proceed with the payment accordingly. + +### `X-Cashu` Header + +Fields included in the X-Cashu header: + +- identifier: The unique identifier for the payment. +- amount: The amount of ecash being requested +- mints: An array of mints that this server uses +- unit: The cashu `unit` from the `mints` +- pubkey: (optional) a 33 byte pubkey to lock the tokens too. see [NUT-11](https://github.com/cashubtc/nuts/blob/main/11.md) + +The `identifier` field is a unique reference to a specific payment request. It allows the server to distinguish between different payments for the same file or blob. The server MUST ensure that each identifier is unique and link it internally to the relevant file or blob. Example for cashu: ```json { - "blob": "481d5f1a374e3750518db22337bc6cb3be5be615d550ba189c9a9a55f6d55644", - "payment_method": "cashu", - "payment_details": { - "amount": "300", - "mints": "https://example.com", - "unit": "sat", - "pubkey": "0a3bce8b6005175d25432244340912dfa431a0d62681d9720cda9196398d7222" - } + "identifier": "23537", + "amount": "300", + "mints": ["https://example.com", "https://example2.com"], + "unit": "sat", + "pubkey": "0a3bce8b6005175d25432244340912dfa431a0d62681d9720cda9196398d7222" } ``` +```http +HTTP/1.1 402 Payment Required +X-Cashu: ewogICJpZGVudGlmaWVyIjogIjIzNTM3IiwKICAiYW1vdW50IjogIjMwMCIsCiAgIm1pbnRzIjogWyJodHRwczovL2V4YW1wbGUuY29tIiwgImh0dHBzOi8vZXhhbXBsZTIuY29tIl0sCiAgInVuaXQiOiAic2F0IiwKICAicHVia2V5IjogIjBhM2JjZThiNjAwNTE3NWQyNTQzMjI0NDM0MDkxMmRmYTQzMWEwZDYyNjgxZDk3MjBjZGE5MTk2Mzk4ZDcyMjIiCn0 +``` + +### `X-Lightning` Header + +Fields included in the X-Lightning header: + +- identifier: The unique identifier for the payment. +- amount: The amount to be paid. +- payment_request: The lightning payment request. + +The `identifier` field is a unique reference to a specific payment request. It allows the server to distinguish between different payments for the same file or blob. The server MUST ensure that each identifier is unique and link it internally to the relevant file or blob. + Example for lightning: ```json { - "blob": "481d5f1a374e3750518db22337bc6cb3be5be615d550ba189c9a9a55f6d55644", + "identifier": "23537", "amount": "300", - "payment_method": "lightning", - "payment_details": { - "payment_request": "lnbc300n1pw4..:", - } + "payment_request": "lnbc300n1pw4..:", } ``` -Example for liquid: - -```json -{ - "blob": "481d5f1a374e3750518db22337bc6cb3be5be615d550ba189c9a9a55f6d55644", - "payment_method": "liquid", - "payment_details": { - "payment_request": { - "address": "VJLgF1s3...", - "asset_id": "6f0279e9ed...", - "amount": 0.000300, - "memo": "test" - } - } -} +```http +HTTP/1.1 402 Payment Required +X-Lightning: ewogICJpZGVudGlmaWVyIjogIjIzNTM3IiwKICAiYW1vdW50IjogIjMwMCIsCiAgInBheW1lbnRfcmVxdWVzdCI6ICJsbmJjMzAwbjFwdzQuLjoiLAp9 ``` Schema: ```http HTTP/1.1 402 Payment Required -X-Payment: "" +X-Payment-{payment_method}: "" ``` + ### Client implementation -Clients MUST check the `X-Payment` header received from the server and display the payment request to the user. When the payment is complete the client MUST use the same header to inform the server that the payment was successful using this structure: +Clients MUST parse and validate all available `X-{payment_method}` headers received from the server. The client SHOULD provide a way for the user to complete the payment and retry the request using the appropiate `X-Payment-{payment_method}` header. -- blob: The paid blob. -- payment_proof: The payment proof. (e.g., preimage for cashu and lightning, txid for liquid). +- `X-{payment_method}-Payment`: Base64 UrlSafe encoded JSON with the client payment proof. + +- identifier: The unique identifier for the payment. +- payment_proof: The proof of payment, specific to the method: + + - For cashu the payment should be a serialized cashu token according to [NUT-00](https://github.com/cashubtc/nuts/blob/main/00.md#v4-tokens) + - For lightning the payment should be the preimage of the payment request according to [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) + +Example for Cashu: ```json { - "blob": "481d5f1a374e3750518db22337bc6cb3be5be615d550ba189c9a9a55f6d55644", + "identifier": "23537", "payment_proof": "c3b9e2..." } + +```http +X-Cashu-Payment: ewogICJpZGVudGlmaWVyIjogIjIzNTM3IiwKICAicGF5bWVudF9wcm9vZiI6ICJjM2I5ZTIiCn0 +``` + +Example for Lightning: + +```json +{ + "identifier": "23537", + "payment_proof": "lnbc300n1pw4..." +} + +```http +X-Lightning-Payment: ewogICJpZGVudGlmaWVyIjogIjIzNTM3IiwKICAicGF5bWVudF9wcm9vZiI6ICJsbmJjMzAwbjFwdzQuLjoiCn0 ``` Schema: ```http -X-Payment: "" +X-{payment_method}-Payment: "" ``` + +### Error handling + +If the client fails to provide the payment proof (expired invoice, invalid token, etc.) the server MUST respond with **402 Payment Required** status code and include the relevant `X-{payment_method}` header(s) with updated payment details. + + +### Extending with Future Payment Methods + +To support future payment methods (e.g., other Layer 2 solutions), the specification allows the addition of new X-{payment_method} headers. Each new method MUST adhere to the following: + +Header Format: + +New methods MUST use a unique `X-{payment_method}` header containing Base64 UrlSafe encoded JSON. + +Required Fields: + +- identifier: Unique reference for the payment. +- amount: Payment amount in the method’s smallest unit. + +Backward Compatibility: + +Servers and clients MUST ignore unknown X-{payment_method} headers. + +Documentation: + +Any new payment method added in the future MUST follow the same structure as existing methods, ensuring that the `identifier` and `amount` fields are always present and well-defined. This consistency allows seamless integration of new methods without breaking compatibility for existing clients and servers. From 3524b81baca9052a33dcff091ad3ed849afbf427 Mon Sep 17 00:00:00 2001 From: Quentin Date: Mon, 18 Nov 2024 12:37:37 +0100 Subject: [PATCH 12/46] fix typos --- buds/07.md | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/buds/07.md b/buds/07.md index 880c04a..33f13c0 100644 --- a/buds/07.md +++ b/buds/07.md @@ -12,7 +12,7 @@ Payment requirements for blob storage. Some servers MAY require payment for file storage. In such cases, these endpoints MUST return a **402 Payment Required** status code: -- [HEAD /upload](./01.md#head-sha256---has-blob) (Optional, if [BU-06](./06.md) is implemented) +- [HEAD /upload](./01.md#head-sha256---has-blob) (Optional, if [BUD-06](./06.md) is implemented) - [PUT /upload](./02.md#put-upload---upload-blob) - [HEAT /](./01.md#head-sha256---has-blob) - [GET /](./01.md#get-sha256---get-blob) @@ -36,11 +36,11 @@ If a server supports multiple payment methods, it MAY send multiple `X-{payment_ Fields included in the X-Cashu header: -- identifier: The unique identifier for the payment. -- amount: The amount of ecash being requested -- mints: An array of mints that this server uses -- unit: The cashu `unit` from the `mints` -- pubkey: (optional) a 33 byte pubkey to lock the tokens too. see [NUT-11](https://github.com/cashubtc/nuts/blob/main/11.md) +- `identifier`: The unique identifier for the payment. +- `amount`: The amount of ecash being requested +- `mints`: An array of mints that this server uses +- `unit`: The cashu `unit` from the `mints` +- `pubkey`: (optional) a 33 byte pubkey to lock the tokens too. see [NUT-11](https://github.com/cashubtc/nuts/blob/main/11.md) The `identifier` field is a unique reference to a specific payment request. It allows the server to distinguish between different payments for the same file or blob. The server MUST ensure that each identifier is unique and link it internally to the relevant file or blob. @@ -65,9 +65,9 @@ X-Cashu: ewogICJpZGVudGlmaWVyIjogIjIzNTM3IiwKICAiYW1vdW50IjogIjMwMCIsCiAgIm1pbnR Fields included in the X-Lightning header: -- identifier: The unique identifier for the payment. -- amount: The amount to be paid. -- payment_request: The lightning payment request. +- `identifier`: The unique identifier for the payment. +- `amount`: The amount to be paid. +- `payment_request`: The lightning payment request. The `identifier` field is a unique reference to a specific payment request. It allows the server to distinguish between different payments for the same file or blob. The server MUST ensure that each identifier is unique and link it internally to the relevant file or blob. @@ -101,8 +101,8 @@ Clients MUST parse and validate all available `X-{payment_method}` headers recei - `X-{payment_method}-Payment`: Base64 UrlSafe encoded JSON with the client payment proof. -- identifier: The unique identifier for the payment. -- payment_proof: The proof of payment, specific to the method: +- `identifier`: The unique identifier for the payment. +- `payment_proof`: The proof of payment, specific to the method: - For cashu the payment should be a serialized cashu token according to [NUT-00](https://github.com/cashubtc/nuts/blob/main/00.md#v4-tokens) - For lightning the payment should be the preimage of the payment request according to [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) @@ -114,6 +114,7 @@ Example for Cashu: "identifier": "23537", "payment_proof": "c3b9e2..." } +``` ```http X-Cashu-Payment: ewogICJpZGVudGlmaWVyIjogIjIzNTM3IiwKICAicGF5bWVudF9wcm9vZiI6ICJjM2I5ZTIiCn0 @@ -152,8 +153,8 @@ New methods MUST use a unique `X-{payment_method}` header containing Base64 UrlS Required Fields: -- identifier: Unique reference for the payment. -- amount: Payment amount in the method’s smallest unit. +- `identifier`: Unique reference for the payment. +- `amount`: Payment amount in the method’s smallest unit. Backward Compatibility: From b450680b00b79544f648301b33ec13d7ae2aaf73 Mon Sep 17 00:00:00 2001 From: Quentin Date: Mon, 18 Nov 2024 12:39:10 +0100 Subject: [PATCH 13/46] fix typo --- buds/07.md | 1 + 1 file changed, 1 insertion(+) diff --git a/buds/07.md b/buds/07.md index 33f13c0..071f6e9 100644 --- a/buds/07.md +++ b/buds/07.md @@ -127,6 +127,7 @@ Example for Lightning: "identifier": "23537", "payment_proof": "lnbc300n1pw4..." } +``` ```http X-Lightning-Payment: ewogICJpZGVudGlmaWVyIjogIjIzNTM3IiwKICAicGF5bWVudF9wcm9vZiI6ICJsbmJjMzAwbjFwdzQuLjoiCn0 From 8a4728e3e6085157867be9562832561dff1d9372 Mon Sep 17 00:00:00 2001 From: Quentin Date: Mon, 18 Nov 2024 12:41:43 +0100 Subject: [PATCH 14/46] remove some texts --- buds/07.md | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/buds/07.md b/buds/07.md index 071f6e9..37355f9 100644 --- a/buds/07.md +++ b/buds/07.md @@ -148,19 +148,9 @@ If the client fails to provide the payment proof (expired invoice, invalid token To support future payment methods (e.g., other Layer 2 solutions), the specification allows the addition of new X-{payment_method} headers. Each new method MUST adhere to the following: -Header Format: - New methods MUST use a unique `X-{payment_method}` header containing Base64 UrlSafe encoded JSON. -Required Fields: +**Required Fields:** - `identifier`: Unique reference for the payment. -- `amount`: Payment amount in the method’s smallest unit. - -Backward Compatibility: - -Servers and clients MUST ignore unknown X-{payment_method} headers. - -Documentation: - -Any new payment method added in the future MUST follow the same structure as existing methods, ensuring that the `identifier` and `amount` fields are always present and well-defined. This consistency allows seamless integration of new methods without breaking compatibility for existing clients and servers. +- `amount`: Payment amount in the method’s smallest unit. \ No newline at end of file From 970fc2b072818d8b10ec892262ec991412eefed1 Mon Sep 17 00:00:00 2001 From: Quentin Date: Mon, 18 Nov 2024 12:41:51 +0100 Subject: [PATCH 15/46] fix typo --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index 37355f9..3876e9b 100644 --- a/buds/07.md +++ b/buds/07.md @@ -153,4 +153,4 @@ New methods MUST use a unique `X-{payment_method}` header containing Base64 UrlS **Required Fields:** - `identifier`: Unique reference for the payment. -- `amount`: Payment amount in the method’s smallest unit. \ No newline at end of file +- `amount`: Payment amount in the method’s smallest unit. From 0aa5a9dd6f033ce5be4bbc29663ac4e5e255500b Mon Sep 17 00:00:00 2001 From: Quentin Date: Wed, 20 Nov 2024 12:14:00 +0100 Subject: [PATCH 16/46] Refactored to clarify payment header encoding and method-specific requirements --- buds/07.md | 114 +++++++++++++---------------------------------------- 1 file changed, 28 insertions(+), 86 deletions(-) diff --git a/buds/07.md b/buds/07.md index 3876e9b..aad8b53 100644 --- a/buds/07.md +++ b/buds/07.md @@ -17,140 +17,82 @@ Some servers MAY require payment for file storage. In such cases, these endpoint - [HEAT /](./01.md#head-sha256---has-blob) - [GET /](./01.md#get-sha256---get-blob) -When payment is required, the server MUST include one or more `X-{payment_method}` header(s), each corresponding to a supported payment method. +When payment is required, the server MUST include one or more `X-{payment_method}` header(s), each corresponding to a supported payment method. The client MUST choose one of the provided methods and proceed with the payment accordingly. ## Server headers The `X-{payment_method}` header is used by the server to inform the client that payment is required for the requested operation. The server MUST provide specific headers for each supported payment method, using the following conventions: -- `X-{payment_method}`: Base64 UrlSafe encoded JSON with the payment details. - Supported payment methods: -- `X-Cashu`: Payment details for the cashu payment method. -- `X-Lightning`: Payment details for the lightning payment method. +- `X-Cashu`: Payment details for the cashu payment method, adhering to the [NUT-18](https://github.com/cashubtc/nuts/blob/main/18.md) standard. +- `X-Lightning`: Payment details for the lightning payment method, adhering to the [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) standard. If a server supports multiple payment methods, it MAY send multiple `X-{payment_method}` headers in the same response. The client MUST choose one of the provided methods and proceed with the payment accordingly. +Schema: + +```http +HTTP/1.1 402 Payment Required +X-Payment-{payment_method}: "" +``` + ### `X-Cashu` Header -Fields included in the X-Cashu header: - -- `identifier`: The unique identifier for the payment. -- `amount`: The amount of ecash being requested -- `mints`: An array of mints that this server uses -- `unit`: The cashu `unit` from the `mints` -- `pubkey`: (optional) a 33 byte pubkey to lock the tokens too. see [NUT-11](https://github.com/cashubtc/nuts/blob/main/11.md) - -The `identifier` field is a unique reference to a specific payment request. It allows the server to distinguish between different payments for the same file or blob. The server MUST ensure that each identifier is unique and link it internally to the relevant file or blob. +When using the X-Cashu header, the server MUST adhere to the [NUT-18](https://github.com/cashubtc/nuts/blob/main/18.md) standard. Example for cashu: -```json -{ - "identifier": "23537", - "amount": "300", - "mints": ["https://example.com", "https://example2.com"], - "unit": "sat", - "pubkey": "0a3bce8b6005175d25432244340912dfa431a0d62681d9720cda9196398d7222" -} -``` - ```http HTTP/1.1 402 Payment Required -X-Cashu: ewogICJpZGVudGlmaWVyIjogIjIzNTM3IiwKICAiYW1vdW50IjogIjMwMCIsCiAgIm1pbnRzIjogWyJodHRwczovL2V4YW1wbGUuY29tIiwgImh0dHBzOi8vZXhhbXBsZTIuY29tIl0sCiAgInVuaXQiOiAic2F0IiwKICAicHVia2V5IjogIjBhM2JjZThiNjAwNTE3NWQyNTQzMjI0NDM0MDkxMmRmYTQzMWEwZDYyNjgxZDk3MjBjZGE5MTk2Mzk4ZDcyMjIiCn0 +X-Cashu: creqApWF0gaNhdGVub3N0cmFheKlucHJvZmlsZTFxeTI4d3VtbjhnaGo3dW45ZDNzaGp0bnl2OWtoMnVld2Q5aHN6OW1od2RlbjV0ZTB3ZmprY2N0ZTljdXJ4dmVuOWVlaHFjdHJ2NWhzenJ0aHdkZW41dGUwZGVoaHh0bnZkYWtxcWd5ZGFxeTdjdXJrNDM5eWtwdGt5c3Y3dWRoZGh1NjhzdWNtMjk1YWtxZWZkZWhrZjBkNDk1Y3d1bmw1YWeBgmFuYjE3YWloYjdhOTAxNzZhYQphdWNzYXRhbYF4Imh0dHBzOi8vbm9mZWVzLnRlc3RudXQuY2FzaHUuc3BhY2U ``` ### `X-Lightning` Header -Fields included in the X-Lightning header: - -- `identifier`: The unique identifier for the payment. -- `amount`: The amount to be paid. -- `payment_request`: The lightning payment request. - -The `identifier` field is a unique reference to a specific payment request. It allows the server to distinguish between different payments for the same file or blob. The server MUST ensure that each identifier is unique and link it internally to the relevant file or blob. - +When using the X-Lightning header, the server MUST adhere to the [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) standard. Example for lightning: -```json -{ - "identifier": "23537", - "amount": "300", - "payment_request": "lnbc300n1pw4..:", -} - -``` - ```http HTTP/1.1 402 Payment Required -X-Lightning: ewogICJpZGVudGlmaWVyIjogIjIzNTM3IiwKICAiYW1vdW50IjogIjMwMCIsCiAgInBheW1lbnRfcmVxdWVzdCI6ICJsbmJjMzAwbjFwdzQuLjoiLAp9 +X-Lightning: lnbc30n1pnnmw3lpp57727jjq8zxctahfavqacymellq56l70f7lwfkmhxfjva6dgul2zqhp5w48l28v60yvythn6qvnpq0lez54422a042yaw4kq8arvd68a6n7qcqzzsxqyz5vqsp5sqezejdfaxx5hge83tf59a50h6gagwah59fjn9mw2d5mn278jkys9qxpqysgqt2q2lhjl9kgfaqz864mhlsspftzdyr642lf3zdt6ljqj6wmathdhtgcn0e6f4ym34jl0qkt6gwnllygvzkhdlpq64c6yv3rta2hyzlqp8k28pz ``` -Schema: - -```http -HTTP/1.1 402 Payment Required -X-Payment-{payment_method}: "" -``` - - ### Client implementation -Clients MUST parse and validate all available `X-{payment_method}` headers received from the server. The client SHOULD provide a way for the user to complete the payment and retry the request using the appropiate `X-Payment-{payment_method}` header. +Clients MUST parse and validate all available `X-{payment_method}` headers received from the server. The client SHOULD provide a way for the user to complete the payment and retry the request using the same `X-{payment_method}` header. -- `X-{payment_method}-Payment`: Base64 UrlSafe encoded JSON with the client payment proof. +The client MUST provide the payment proof in the request headers using the same `X-{payment_method}` header that was chosen. The payment proof MUST aling with the payment method specification: -- `identifier`: The unique identifier for the payment. -- `payment_proof`: The proof of payment, specific to the method: - - - For cashu the payment should be a serialized cashu token according to [NUT-00](https://github.com/cashubtc/nuts/blob/main/00.md#v4-tokens) - - For lightning the payment should be the preimage of the payment request according to [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) +- For cashu the payment proof should be a serialized cashu token according to [NUT-00](https://github.com/cashubtc/nuts/blob/main/00.md#v4-tokens) +- For lightning the payment proof should be the preimage of the payment request according to [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) + +Schema: + +```http +X-{payment_method}: "" +``` Example for Cashu: -```json -{ - "identifier": "23537", - "payment_proof": "c3b9e2..." -} -``` - ```http -X-Cashu-Payment: ewogICJpZGVudGlmaWVyIjogIjIzNTM3IiwKICAicGF5bWVudF9wcm9vZiI6ICJjM2I5ZTIiCn0 +X-Cashu: cashuBo2F0gqJhaUgA_9SLj17PgGFwgaNhYQFhc3hAYWNjMTI0MzVlN2I4NDg0YzNjZjE4NTAxNDkyMThhZjkwZjcxNmE1MmJmNGE1ZWQzNDdlNDhlY2MxM2Y3NzM4OGFjWCECRFODGd5IXVW ``` Example for Lightning: -```json -{ - "identifier": "23537", - "payment_proof": "lnbc300n1pw4..." -} -``` - ```http -X-Lightning-Payment: ewogICJpZGVudGlmaWVyIjogIjIzNTM3IiwKICAicGF5bWVudF9wcm9vZiI6ICJsbmJjMzAwbjFwdzQuLjoiCn0 -``` - -Schema: - -```http -X-{payment_method}-Payment: "" +X-Lightning: "966fcb8f153339372f9a187f725384ff4ceae0047c25b9ce607488d7c7e93bba" ``` ### Error handling If the client fails to provide the payment proof (expired invoice, invalid token, etc.) the server MUST respond with **402 Payment Required** status code and include the relevant `X-{payment_method}` header(s) with updated payment details. - ### Extending with Future Payment Methods To support future payment methods (e.g., other Layer 2 solutions), the specification allows the addition of new X-{payment_method} headers. Each new method MUST adhere to the following: -New methods MUST use a unique `X-{payment_method}` header containing Base64 UrlSafe encoded JSON. +New methods MUST use a unique `X-{payment_method}` header containing the specific payment details. -**Required Fields:** - -- `identifier`: Unique reference for the payment. -- `amount`: Payment amount in the method’s smallest unit. +New methods MUST adhere their own specification, which MUST be publicly available and linked in the header. From 8600dbecfc44f89b21cd08cfeae9215a67bd6bfa Mon Sep 17 00:00:00 2001 From: Quentin Date: Wed, 20 Nov 2024 12:35:18 +0100 Subject: [PATCH 17/46] Recurring payments. --- buds/07.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/buds/07.md b/buds/07.md index aad8b53..19d6293 100644 --- a/buds/07.md +++ b/buds/07.md @@ -85,6 +85,18 @@ Example for Lightning: X-Lightning: "966fcb8f153339372f9a187f725384ff4ceae0047c25b9ce607488d7c7e93bba" ``` +### Recurring Payments + +Servers MAY accept recurring payments for blob storage using the following Nostr event types: + +- **Cashu**: Using [NIP-61](https://github.com/nostr-protocol/nips/blob/master/61.md) for details. + +- **Lightning**: Using [NIP-57](https://github.com/nostr-protocol/nips/blob/master/57.md) for details. + +The event MUST include a custom `x` tag containing the hash of the blob being paid for. + +- `x`: A string that represents the blob's SHA-256 hash. + ### Error handling If the client fails to provide the payment proof (expired invoice, invalid token, etc.) the server MUST respond with **402 Payment Required** status code and include the relevant `X-{payment_method}` header(s) with updated payment details. @@ -96,3 +108,5 @@ To support future payment methods (e.g., other Layer 2 solutions), the specifica New methods MUST use a unique `X-{payment_method}` header containing the specific payment details. New methods MUST adhere their own specification, which MUST be publicly available and linked in the header. + +New methods MAY have a Nostr event type for recurring payments, which MUST be linked in the Recurring Payments section. From e003b22318a3ff9533944f961baea47c83118002 Mon Sep 17 00:00:00 2001 From: Quentin Date: Wed, 20 Nov 2024 12:40:39 +0100 Subject: [PATCH 18/46] Fix typos. --- buds/07.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/buds/07.md b/buds/07.md index 19d6293..227e4ba 100644 --- a/buds/07.md +++ b/buds/07.md @@ -21,7 +21,7 @@ When payment is required, the server MUST include one or more `X-{payment_method ## Server headers -The `X-{payment_method}` header is used by the server to inform the client that payment is required for the requested operation. The server MUST provide specific headers for each supported payment method, using the following conventions: +The `X-{payment_method}` header is used by the server to inform the client that payment is required for the requested operation. The server MUST provide specific headers for each supported payment method. Supported payment methods: @@ -64,9 +64,9 @@ Clients MUST parse and validate all available `X-{payment_method}` headers recei The client MUST provide the payment proof in the request headers using the same `X-{payment_method}` header that was chosen. The payment proof MUST aling with the payment method specification: -- For cashu the payment proof should be a serialized cashu token according to [NUT-00](https://github.com/cashubtc/nuts/blob/main/00.md#v4-tokens) -- For lightning the payment proof should be the preimage of the payment request according to [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) - +- For cashu the payment proof should be a serialized cashu token according to [NUT-00](https://github.com/cashubtc/nuts/blob/main/00.md#v4-tokens). +- For lightning the payment proof should be the preimage of the payment request according to [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md). + Schema: ```http @@ -89,9 +89,9 @@ X-Lightning: "966fcb8f153339372f9a187f725384ff4ceae0047c25b9ce607488d7c7e93bba" Servers MAY accept recurring payments for blob storage using the following Nostr event types: -- **Cashu**: Using [NIP-61](https://github.com/nostr-protocol/nips/blob/master/61.md) for details. +- **Cashu**: Using [NIP-61](https://github.com/nostr-protocol/nips/blob/master/61.md) standard. -- **Lightning**: Using [NIP-57](https://github.com/nostr-protocol/nips/blob/master/57.md) for details. +- **Lightning**: Using [NIP-57](https://github.com/nostr-protocol/nips/blob/master/57.md) standard. The event MUST include a custom `x` tag containing the hash of the blob being paid for. From cda53cf47afb31d2747fead6fef8a8ab1e6e85a5 Mon Sep 17 00:00:00 2001 From: Quentin <125748180+quentintaranpino@users.noreply.github.com> Date: Wed, 20 Nov 2024 16:25:33 +0100 Subject: [PATCH 19/46] Update buds/07.md Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com> --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index 227e4ba..6e539de 100644 --- a/buds/07.md +++ b/buds/07.md @@ -17,7 +17,7 @@ Some servers MAY require payment for file storage. In such cases, these endpoint - [HEAT /](./01.md#head-sha256---has-blob) - [GET /](./01.md#get-sha256---get-blob) -When payment is required, the server MUST include one or more `X-{payment_method}` header(s), each corresponding to a supported payment method. The client MUST choose one of the provided methods and proceed with the payment accordingly. +When payment is required, the server MUST include one or more `X-{payment_method}` header(s), each corresponding to a supported payment method. ## Server headers From 0d039843a0989af58756d2cb92e5ddeb9994b42f Mon Sep 17 00:00:00 2001 From: Quentin <125748180+quentintaranpino@users.noreply.github.com> Date: Wed, 20 Nov 2024 16:25:58 +0100 Subject: [PATCH 20/46] Update buds/07.md Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com> --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index 6e539de..8c180c5 100644 --- a/buds/07.md +++ b/buds/07.md @@ -21,7 +21,7 @@ When payment is required, the server MUST include one or more `X-{payment_method ## Server headers -The `X-{payment_method}` header is used by the server to inform the client that payment is required for the requested operation. The server MUST provide specific headers for each supported payment method. +The 402 status code and `X-{payment_method}` header is used by the server to inform the client that a payment is required for the requested operation. The server MUST provide specific headers for each supported payment method. Supported payment methods: From ffe55bbffcce6413ab8b95325911cfba9bd31783 Mon Sep 17 00:00:00 2001 From: Quentin <125748180+quentintaranpino@users.noreply.github.com> Date: Wed, 20 Nov 2024 16:26:17 +0100 Subject: [PATCH 21/46] Update buds/07.md Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com> --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index 8c180c5..4a8b7f3 100644 --- a/buds/07.md +++ b/buds/07.md @@ -28,7 +28,7 @@ Supported payment methods: - `X-Cashu`: Payment details for the cashu payment method, adhering to the [NUT-18](https://github.com/cashubtc/nuts/blob/main/18.md) standard. - `X-Lightning`: Payment details for the lightning payment method, adhering to the [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) standard. -If a server supports multiple payment methods, it MAY send multiple `X-{payment_method}` headers in the same response. The client MUST choose one of the provided methods and proceed with the payment accordingly. +If a server supports multiple payment methods, it MAY send multiple `X-{payment_method}` headers in the same response. Schema: From 8f95ad746819281d1d772cc5172a841fcb59b58a Mon Sep 17 00:00:00 2001 From: Quentin <125748180+quentintaranpino@users.noreply.github.com> Date: Wed, 20 Nov 2024 16:27:35 +0100 Subject: [PATCH 22/46] Update buds/07.md Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com> --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index 4a8b7f3..62fb9fe 100644 --- a/buds/07.md +++ b/buds/07.md @@ -1,7 +1,7 @@ BUD-07 ====== -Paid storage +Paid upload and download --------------- `draft` `optional` From 38274c6a5e263f59dd415b8eb49bbf22f69b0a42 Mon Sep 17 00:00:00 2001 From: Quentin <125748180+quentintaranpino@users.noreply.github.com> Date: Wed, 20 Nov 2024 16:28:13 +0100 Subject: [PATCH 23/46] Update buds/07.md Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com> --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index 62fb9fe..c414721 100644 --- a/buds/07.md +++ b/buds/07.md @@ -14,7 +14,7 @@ Some servers MAY require payment for file storage. In such cases, these endpoint - [HEAD /upload](./01.md#head-sha256---has-blob) (Optional, if [BUD-06](./06.md) is implemented) - [PUT /upload](./02.md#put-upload---upload-blob) -- [HEAT /](./01.md#head-sha256---has-blob) +- [HEAD /](./01.md#head-sha256---has-blob) - [GET /](./01.md#get-sha256---get-blob) When payment is required, the server MUST include one or more `X-{payment_method}` header(s), each corresponding to a supported payment method. From f9f44fc592c1407b836ea94ced6a6a829e48a77b Mon Sep 17 00:00:00 2001 From: Quentin <125748180+quentintaranpino@users.noreply.github.com> Date: Wed, 20 Nov 2024 16:32:04 +0100 Subject: [PATCH 24/46] Update buds/07.md Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com> --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index c414721..bb07c09 100644 --- a/buds/07.md +++ b/buds/07.md @@ -62,7 +62,7 @@ X-Lightning: lnbc30n1pnnmw3lpp57727jjq8zxctahfavqacymellq56l70f7lwfkmhxfjva6dgul Clients MUST parse and validate all available `X-{payment_method}` headers received from the server. The client SHOULD provide a way for the user to complete the payment and retry the request using the same `X-{payment_method}` header. -The client MUST provide the payment proof in the request headers using the same `X-{payment_method}` header that was chosen. The payment proof MUST aling with the payment method specification: +The client MUST provide the payment proof when re-trying the request using the same `X-{payment_method}` header that was chosen. The payment proof MUST align with the payment method specification: - For cashu the payment proof should be a serialized cashu token according to [NUT-00](https://github.com/cashubtc/nuts/blob/main/00.md#v4-tokens). - For lightning the payment proof should be the preimage of the payment request according to [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md). From 73fcfbfbd3c399915ece48ca9941a8a64c945d42 Mon Sep 17 00:00:00 2001 From: Quentin Date: Wed, 20 Nov 2024 20:57:46 +0100 Subject: [PATCH 25/46] update BUD-07 --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index bb07c09..516c093 100644 --- a/buds/07.md +++ b/buds/07.md @@ -60,7 +60,7 @@ X-Lightning: lnbc30n1pnnmw3lpp57727jjq8zxctahfavqacymellq56l70f7lwfkmhxfjva6dgul ### Client implementation -Clients MUST parse and validate all available `X-{payment_method}` headers received from the server. The client SHOULD provide a way for the user to complete the payment and retry the request using the same `X-{payment_method}` header. +Clients MUST parse and validate the `X-{payment_method}` header received from the server. The client SHOULD provide a way for the user to complete the payment and retry the request using the same `X-{payment_method}` header. The client MUST provide the payment proof when re-trying the request using the same `X-{payment_method}` header that was chosen. The payment proof MUST align with the payment method specification: From 463f28da7b879be42e4948eb60c7b4e9ee9f131c Mon Sep 17 00:00:00 2001 From: Quentin Date: Wed, 20 Nov 2024 21:22:20 +0100 Subject: [PATCH 26/46] error handling 402->400. Special note for Head requests --- buds/07.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index 516c093..8b5dde3 100644 --- a/buds/07.md +++ b/buds/07.md @@ -85,6 +85,10 @@ Example for Lightning: X-Lightning: "966fcb8f153339372f9a187f725384ff4ceae0047c25b9ce607488d7c7e93bba" ``` +**Special Note on HEAD Requests** + +The HEAD endpoints are only used to retrieve blob or server information. They MUST NOT be retried with payment proof. Instead, clients should complete the payment and proceed with the `PUT` or `GET` request. + ### Recurring Payments Servers MAY accept recurring payments for blob storage using the following Nostr event types: @@ -99,7 +103,7 @@ The event MUST include a custom `x` tag containing the hash of the blob being pa ### Error handling -If the client fails to provide the payment proof (expired invoice, invalid token, etc.) the server MUST respond with **402 Payment Required** status code and include the relevant `X-{payment_method}` header(s) with updated payment details. +If the client fails to provide the payment proof (expired invoice, invalid token, etc.) the server MUST respond with **400 Bad request** status code and include a `X-Reason` header with a human-readable message. The client SHOULD inform the user about the error and provide a way to retry the request. ### Extending with Future Payment Methods From 4d9b22a96c3c8ed76bb6001a7898d4c864fcdb0d Mon Sep 17 00:00:00 2001 From: quentintaranpino Date: Tue, 3 Dec 2024 13:03:23 +0100 Subject: [PATCH 27/46] remove recurring payments --- buds/07.md | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/buds/07.md b/buds/07.md index 8b5dde3..8b4bb3e 100644 --- a/buds/07.md +++ b/buds/07.md @@ -89,18 +89,6 @@ X-Lightning: "966fcb8f153339372f9a187f725384ff4ceae0047c25b9ce607488d7c7e93bba" The HEAD endpoints are only used to retrieve blob or server information. They MUST NOT be retried with payment proof. Instead, clients should complete the payment and proceed with the `PUT` or `GET` request. -### Recurring Payments - -Servers MAY accept recurring payments for blob storage using the following Nostr event types: - -- **Cashu**: Using [NIP-61](https://github.com/nostr-protocol/nips/blob/master/61.md) standard. - -- **Lightning**: Using [NIP-57](https://github.com/nostr-protocol/nips/blob/master/57.md) standard. - -The event MUST include a custom `x` tag containing the hash of the blob being paid for. - -- `x`: A string that represents the blob's SHA-256 hash. - ### Error handling If the client fails to provide the payment proof (expired invoice, invalid token, etc.) the server MUST respond with **400 Bad request** status code and include a `X-Reason` header with a human-readable message. The client SHOULD inform the user about the error and provide a way to retry the request. @@ -111,6 +99,4 @@ To support future payment methods (e.g., other Layer 2 solutions), the specifica New methods MUST use a unique `X-{payment_method}` header containing the specific payment details. -New methods MUST adhere their own specification, which MUST be publicly available and linked in the header. - -New methods MAY have a Nostr event type for recurring payments, which MUST be linked in the Recurring Payments section. +New methods MUST adhere their own specification, which MUST be publicly available and linked in the header. \ No newline at end of file From 8e12280410443029cbae882450d5714fef930414 Mon Sep 17 00:00:00 2001 From: quentintaranpino Date: Tue, 3 Dec 2024 13:06:04 +0100 Subject: [PATCH 28/46] fix typo --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index 8b4bb3e..5c88aab 100644 --- a/buds/07.md +++ b/buds/07.md @@ -34,7 +34,7 @@ Schema: ```http HTTP/1.1 402 Payment Required -X-Payment-{payment_method}: "" +X-{payment_method}: "" ``` ### `X-Cashu` Header From 542c654045f858852dedd39b763d1b9fc40b7e39 Mon Sep 17 00:00:00 2001 From: Quentin <125748180+quentintaranpino@users.noreply.github.com> Date: Sun, 20 Apr 2025 18:37:03 +0200 Subject: [PATCH 29/46] Update buds/07.md Co-authored-by: hzrd149 <8001706+hzrd149@users.noreply.github.com> --- buds/07.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buds/07.md b/buds/07.md index 5c88aab..f996045 100644 --- a/buds/07.md +++ b/buds/07.md @@ -39,7 +39,7 @@ X-{payment_method}: "" ### `X-Cashu` Header -When using the X-Cashu header, the server MUST adhere to the [NUT-18](https://github.com/cashubtc/nuts/blob/main/18.md) standard. +When using the X-Cashu header, the server MUST adhere to the [NUT-23](https://github.com/cashubtc/nuts/pull/239) standard. Example for cashu: From 2aa65cc373a0dbe179e2b63cf12493c3b14abdbc Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Fri, 25 Apr 2025 08:00:17 -0500 Subject: [PATCH 30/46] 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 31/46] 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 32/46] 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 33/46] 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 34/46] 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 35/46] 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 36/46] 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 37/46] 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 38/46] 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 39/46] 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 40/46] 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 41/46] 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 42/46] 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 43/46] 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 44/46] 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 45/46] 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 From 90affdd4d9e87f4a82ed69e50ea7328ea2f821b4 Mon Sep 17 00:00:00 2001 From: hzrd149 <8001706+hzrd149@users.noreply.github.com> Date: Wed, 30 Jul 2025 12:55:58 -0500 Subject: [PATCH 46/46] Update to use cashu NUT-24 --- buds/07.md | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/buds/07.md b/buds/07.md index f996045..af8e278 100644 --- a/buds/07.md +++ b/buds/07.md @@ -10,12 +10,15 @@ Payment requirements for blob storage. ## Payment Required -Some servers MAY require payment for file storage. In such cases, these endpoints MUST return a **402 Payment Required** status code: +Some servers MAY require payment for uploads, downloads, or any other endpoint. In such cases, these endpoints MUST return a **402 Payment Required** status code. -- [HEAD /upload](./01.md#head-sha256---has-blob) (Optional, if [BUD-06](./06.md) is implemented) -- [PUT /upload](./02.md#put-upload---upload-blob) -- [HEAD /](./01.md#head-sha256---has-blob) -- [GET /](./01.md#get-sha256---get-blob) +Some endpoints a server may require payment for: + +- [`HEAD /upload`](./06.md) to signal that payment is required for the `PUT` request ( if [BUD-06](./06.md) is supported ) +- [`PUT /upload`](./02.md#put-upload---upload-blob) to require payment for uploads +- [`HEAD /`](./01.md#head-sha256---has-blob) to signal that payment is required for the `GET` request +- [`GET /`](./01.md#get-sha256---get-blob) to require payment for downloads ( maybe charge by MB downloaded? ) +- [`HEAD /media`](./05.md) and [`PUT /upload`](./05.md) to require payment for media optimizations ( if [BUD-06](./06.md) is supported ) When payment is required, the server MUST include one or more `X-{payment_method}` header(s), each corresponding to a supported payment method. @@ -25,7 +28,7 @@ The 402 status code and `X-{payment_method}` header is used by the server to inf Supported payment methods: -- `X-Cashu`: Payment details for the cashu payment method, adhering to the [NUT-18](https://github.com/cashubtc/nuts/blob/main/18.md) standard. +- `X-Cashu`: Payment details for the cashu payment method, adhering to the [NUT-24](https://github.com/cashubtc/nuts/blob/main/24.md) standard. - `X-Lightning`: Payment details for the lightning payment method, adhering to the [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) standard. If a server supports multiple payment methods, it MAY send multiple `X-{payment_method}` headers in the same response. @@ -39,7 +42,7 @@ X-{payment_method}: "" ### `X-Cashu` Header -When using the X-Cashu header, the server MUST adhere to the [NUT-23](https://github.com/cashubtc/nuts/pull/239) standard. +When using the X-Cashu header, the server MUST adhere to the [NUT-24](https://github.com/cashubtc/nuts/blob/main/24.md) standard. Example for cashu: @@ -64,7 +67,7 @@ Clients MUST parse and validate the `X-{payment_method}` header received from th The client MUST provide the payment proof when re-trying the request using the same `X-{payment_method}` header that was chosen. The payment proof MUST align with the payment method specification: -- For cashu the payment proof should be a serialized cashu token according to [NUT-00](https://github.com/cashubtc/nuts/blob/main/00.md#v4-tokens). +- For cashu the payment proof should be a serialized `cashuB` token in the `X-Cashu` header according to [NUT-24](https://github.com/cashubtc/nuts/blob/main/24.md#client-payment). - For lightning the payment proof should be the preimage of the payment request according to [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md). Schema: @@ -82,7 +85,7 @@ X-Cashu: cashuBo2F0gqJhaUgA_9SLj17PgGFwgaNhYQFhc3hAYWNjMTI0MzVlN2I4NDg0YzNjZjE4N Example for Lightning: ```http -X-Lightning: "966fcb8f153339372f9a187f725384ff4ceae0047c25b9ce607488d7c7e93bba" +X-Lightning: 966fcb8f153339372f9a187f725384ff4ceae0047c25b9ce607488d7c7e93bba ``` **Special Note on HEAD Requests** @@ -99,4 +102,4 @@ To support future payment methods (e.g., other Layer 2 solutions), the specifica New methods MUST use a unique `X-{payment_method}` header containing the specific payment details. -New methods MUST adhere their own specification, which MUST be publicly available and linked in the header. \ No newline at end of file +New methods MUST adhere their own specification, which MUST be publicly available and linked in the header.