added relays and fixed typos

This commit is contained in:
Egge 2023-05-16 07:28:10 +02:00
parent 9f8e49cbdb
commit 5d6b28c581

10
XX.md
View File

@ -10,16 +10,16 @@ The purpose of this NIP is to allow external resources that are protected by NIP
## Creating Zap Gated Resources (Creator) ## Creating Zap Gated Resources (Creator)
In order to create a Zap Gated Resource a creator uploads the resource (e.g, a text-, audio-, or image-file) to a NIP-XX enabled provider, specifying a price, the pubkey that will be used to publish the event, and a payment destination according to NIP-57. The provider returns an unsigned event of kind-X, containing relevant metadata and the resource url that the creator can then sign and publish. In order to create a Zap Gated Resource a creator uploads the resource (e.g, a text-, audio-, or image-file) to a NIP-XX enabled provider, specifying a price, the pubkey that will be used to publish the event, a payment destination according to NIP-57, as well as a list of relays that should be used for zapping. The provider returns an unsigned event of kind-X, containing relevant metadata and the resource url that the creator can then sign and publish.
## Protecting a Zap Gated Ressource (Provider) ## Protecting a Zap Gated Ressource (Provider)
Zap Gated Resources are protected using NIP-98 HTTP Auth. Zap Gated Resources are protected using NIP-98 HTTP Auth.
In order to only return the resource to users that have paid for the resource, the provider keeps track of all the Zap events that are targeting the event-id of a Kind-X event and curates a list of public keys that have zapped at least the amount specified by the creator when initially uploading the resource. If the NIP-98 AUTH header in the request matches one of those keys, the provider should respond with status code 200 and the requested resource, otherwise it should respond with a status code 402. In order to only return the resource to users that have paid for the resource, the provider keeps track of all the Zap events on the specified relays that are targeting the event-id of a Kind-X event and curates a list of public keys that have zapped at least the amount specified by the creator when initially uploading the resource. If the NIP-98 AUTH header in the request matches one of those keys, the provider should respond with status code 200 and the requested resource, otherwise it should respond with a status code 402.
## Accessing a Zap Gated Resource (User) ## Accessing a Zap Gated Resource (User)
When a client discovers a kind-X event, it should render the preview if applicable and let the user know that they need to pay in order to view the full resource (e.g., by showing a "pay to unlock" button). If the user wishes to pay for the resource, the client should facilitate a Zap according to NIP-57 on the kind-X event. After successful payment it should go ahead and construct an AUTH header according to NIP-98 and request the full resource from the `url` in the kind-X event. When a client discovers a kind-X event, it should render the preview if applicable and let the user know that they need to pay in order to view the full resource (e.g., by showing a "pay to unlock" button). If the user wishes to pay for the resource, the client should facilitate a Zap according to NIP-57 on the kind-X event, specifying the relays from the kind-X event relays tag. After successful payment it should go ahead and construct an AUTH header according to NIP-98 and request the full resource from the `url` in the kind-X event.
## Kind-X Event format ## Kind-X Event format
@ -28,6 +28,7 @@ This NIP specifies a `X` event kind for Zap Gated Resources, having in `content`
* `url` the url of the NIP-98 protected resource * `url` the url of the NIP-98 protected resource
* `m` a string indicating the data type of the file. The MIME types format must be used (https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types) * `m` a string indicating the data type of the file. The MIME types format must be used (https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types)
* `price` the price in SATS that is to be paid to access the resource. * `price` the price in SATS that is to be paid to access the resource.
* `relays` a list of relays that should be used for zapping.
* `preview` (optional) a preview of the protected ressource that should be accessible prior to paying (see preview examples) * `preview` (optional) a preview of the protected ressource that should be accessible prior to paying (see preview examples)
```json ```json
@ -35,12 +36,13 @@ This NIP specifies a `X` event kind for Zap Gated Resources, having in `content`
"id": <32-bytes lowercase hex-encoded sha256 of the the serialized event data>, "id": <32-bytes lowercase hex-encoded sha256 of the the serialized event data>,
"pubkey": <32-bytes lowercase hex-encoded public key of the user>, "pubkey": <32-bytes lowercase hex-encoded public key of the user>,
"created_at": <unix timestamp in seconds>, "created_at": <unix timestamp in seconds>,
"kind": 1063, "kind": X,
"tags": [ "tags": [
["url",<string with URI of file>], ["url",<string with URI of file>],
["m", <MIME type>], ["m", <MIME type>],
["price", <price in SATS>], ["price", <price in SATS>],
["preview",<preview tag> ], ["preview",<preview tag> ],
["relays", <list of relays>]
], ],
"content": <description>, "content": <description>,
"sig": <64-bytes hex of the signature of the sha256 hash of the serialized event data, which is the same as the "id" field> "sig": <64-bytes hex of the signature of the sha256 hash of the serialized event data, which is the same as the "id" field>