diff options
| author | Vitor Pamplona <vitor@vitorpamplona.com> | 2025-10-15 16:09:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-15 16:09:36 -0400 |
| commit | 7b24bf803f99e6bfe7a34b22f74f8a0942fca158 (patch) | |
| tree | 1160dce31c9ca9bb6416d72ad8077e0d33885481 | |
| parent | d54c4267091987f035819ff4714910e388f5d701 (diff) | |
NIP-37: Improving Draft events (#2016)
| -rw-r--r-- | 37.md | 39 |
1 files changed, 23 insertions, 16 deletions
| @@ -1,50 +1,57 @@ | |||
| 1 | NIP-37 | 1 | NIP-37 |
| 2 | ====== | 2 | ====== |
| 3 | 3 | ||
| 4 | Draft Events | 4 | Draft Wraps |
| 5 | ------------ | 5 | ----------- |
| 6 | 6 | ||
| 7 | `draft` `optional` | 7 | `draft` `optional` |
| 8 | 8 | ||
| 9 | This NIP defines kind `31234` as a private wrap for drafts of any other event kind. | 9 | This NIP defines kind `31234` as an encrypted storage for unsigned draft events of any other kind. |
| 10 | 10 | ||
| 11 | The draft event is JSON-stringified, [NIP44-encrypted](44.md) to the signer's public key and placed inside the `.content` of the event. | 11 | The draft is JSON-stringified, [NIP44-encrypted](44.md) to the signer's public key and placed inside the `.content`. |
| 12 | 12 | ||
| 13 | An additional `k` tag identifies the kind of the draft event. | 13 | `k` tags identify the kind of the draft. |
| 14 | 14 | ||
| 15 | ```js | 15 | ```js |
| 16 | { | 16 | { |
| 17 | "kind": 31234, | 17 | "kind": 31234, |
| 18 | "tags": [ | 18 | "tags": [ |
| 19 | ["d", "<identifier>"], | 19 | ["d", "<identifier>"], |
| 20 | ["k", "<kind of the draft event>"], | 20 | ["k", "<kind of the draft event>"], // required |
| 21 | ["e", "<anchor event event id>", "<relay-url>"], | 21 | ["expiration", "now + 90 days"] // recommended |
| 22 | ["a", "<anchor event address>", "<relay-url>"], | ||
| 23 | ], | 22 | ], |
| 24 | "content": nip44Encrypt(JSON.stringify(draft_event)), | 23 | "content": nip44Encrypt(JSON.stringify(draft_event)), |
| 25 | // other fields | 24 | // other fields |
| 26 | } | 25 | } |
| 27 | ``` | 26 | ``` |
| 28 | 27 | ||
| 29 | A blanked `.content` means this draft has been deleted by a client but relays still have the event. | 28 | A blanked `.content` field signals that the draft has been deleted. |
| 30 | 29 | ||
| 31 | Tags `e` and `a` identify one or more anchor events, such as parent events on replies. | 30 | [NIP-40](40.md) `expiration` tags are recommended. |
| 31 | |||
| 32 | Clients SHOULD publish kind `31234` events to relays listed on kind `10013` below. | ||
| 32 | 33 | ||
| 33 | ## Relay List for Private Content | 34 | ## Relay List for Private Content |
| 34 | 35 | ||
| 35 | Kind `10013` indicates the user's preferred relays to store private events like Drafts. The event MUST include a list of `relay` URLs in private tags. Private tags are JSON Stringified, NIP-44-encrypted to the signer's keys and placed inside the .content of the event. | 36 | Kind `10013` indicates the user's preferred relays to store private events like Draft Wraps. |
| 37 | |||
| 38 | The event MUST include a list of `relay` URLs in private tags. Private tags are JSON Stringified, [NIP44-encrypted](44.md) to the signer's keys and placed inside the .content of the event. | ||
| 36 | 39 | ||
| 37 | ```js | 40 | ```js |
| 38 | { | 41 | { |
| 39 | "kind": 10013, | 42 | "kind": 10013, |
| 40 | "tags": [], | 43 | "tags": [], |
| 41 | "content": nip44Encrypt(JSON.stringify([ | 44 | "content": nip44Encrypt( |
| 42 | ["relay", "wss://myrelay.mydomain.com"] | 45 | JSON.stringify( |
| 43 | ])) | 46 | [ |
| 47 | ["relay", "wss://myrelay.mydomain.com"] | ||
| 48 | ] | ||
| 49 | ) | ||
| 50 | ) | ||
| 44 | //...other fields | 51 | //...other fields |
| 45 | } | 52 | } |
| 46 | ``` | 53 | ``` |
| 47 | 54 | ||
| 48 | Relays listed in this event SHOULD be authed and only allow downloads to events signed by the authed user. | 55 | It's recommended that Private Storage relays SHOULD be [NIP-42](42.md)-authed and only allow downloads of events signed by the authed user. |
| 49 | 56 | ||
| 50 | Clients SHOULD publish kind `10013` events to the author's [NIP-65](65.md) `write` relays. | 57 | Clients MUST publish kind `10013` events to the author's [NIP-65](65.md) `write` relays. |