diff options
Diffstat (limited to '43.md')
| -rw-r--r-- | 43.md | 146 |
1 files changed, 146 insertions, 0 deletions
| @@ -0,0 +1,146 @@ | |||
| 1 | NIP-43 | ||
| 2 | ====== | ||
| 3 | |||
| 4 | Relay Access Metadata and Requests | ||
| 5 | ---------------------------------- | ||
| 6 | |||
| 7 | `draft` `optional` `relay` | ||
| 8 | |||
| 9 | This NIP defines a way for relays to advertise membership lists, and for clients to request admission to relays on behalf of users. | ||
| 10 | |||
| 11 | ## Membership Lists | ||
| 12 | |||
| 13 | Relays MAY publish a `kind 13534` event which indicates pubkeys that have access to a given relay. This event MUST be signed by the pubkey specified in the `self` field of the relay's [NIP 11](./11.md) document. | ||
| 14 | |||
| 15 | The following tags are required: | ||
| 16 | |||
| 17 | - A [NIP 70](./70.md) `-` tag | ||
| 18 | - A `member` tag containing a hex pubkey should be included for each member | ||
| 19 | |||
| 20 | This list should not be considered exhaustive or authoritative. To determine membership, both a `kind 13534` event by the relay, and a `kind 10010` event by the member should be consulted. | ||
| 21 | |||
| 22 | Example: | ||
| 23 | |||
| 24 | ```jsonc | ||
| 25 | { | ||
| 26 | "kind": 13534, | ||
| 27 | "pubkey": "<nip11.self>", | ||
| 28 | "tags": [ | ||
| 29 | ["-"], | ||
| 30 | ["member", "c308e1f882c1f1dff2a43d4294239ddeec04e575f2d1aad1fa21ea7684e61fb5"], | ||
| 31 | ["member", "ee1d336e13779e4d4c527b988429d96de16088f958cbf6c074676ac9cfd9c958"] | ||
| 32 | ], | ||
| 33 | // ...other fields | ||
| 34 | } | ||
| 35 | ``` | ||
| 36 | |||
| 37 | ## Add User | ||
| 38 | |||
| 39 | Relays MAY publish a `kind 8000` event when a member is added to the relay. This event MUST be signed by the pubkey specified in the `self` field of the relay's [NIP 11](./11.md) document. | ||
| 40 | |||
| 41 | The following tags are required: | ||
| 42 | |||
| 43 | - A [NIP 70](./70.md) `-` tag | ||
| 44 | - A `p` tag indicating the member's hex pubkey | ||
| 45 | |||
| 46 | Example: | ||
| 47 | |||
| 48 | ```jsonc | ||
| 49 | { | ||
| 50 | "kind": 8000, | ||
| 51 | "pubkey": "<nip11.self>", | ||
| 52 | "tags": [ | ||
| 53 | ["-"], | ||
| 54 | ["p", "c308e1f882c1f1dff2a43d4294239ddeec04e575f2d1aad1fa21ea7684e61fb5"] | ||
| 55 | ], | ||
| 56 | // ...other fields | ||
| 57 | } | ||
| 58 | ``` | ||
| 59 | |||
| 60 | ## Remove User | ||
| 61 | |||
| 62 | Relays MAY publish a `kind 8001` event when a member is removed from the relay. This event MUST be signed by the pubkey specified in the `self` field of the relay's [NIP 11](./11.md) document. | ||
| 63 | |||
| 64 | The following tags are required: | ||
| 65 | |||
| 66 | - A [NIP 70](./70.md) `-` tag | ||
| 67 | - A `p` tag indicating the member's hex pubkey | ||
| 68 | |||
| 69 | Example: | ||
| 70 | |||
| 71 | ```jsonc | ||
| 72 | { | ||
| 73 | "kind": 8001, | ||
| 74 | "pubkey": "<nip11.self>", | ||
| 75 | "tags": [ | ||
| 76 | ["-"], | ||
| 77 | ["p", "c308e1f882c1f1dff2a43d4294239ddeec04e575f2d1aad1fa21ea7684e61fb5"] | ||
| 78 | ], | ||
| 79 | // ...other fields | ||
| 80 | } | ||
| 81 | ``` | ||
| 82 | |||
| 83 | ## Join Request | ||
| 84 | |||
| 85 | A user MAY send a `kind 28934` to a relay in order to request admission. It MUST have a `claim` tag containing an invite code. The event's `created_at` MUST be now, plus or minus a few minutes. | ||
| 86 | |||
| 87 | ```jsonc | ||
| 88 | { | ||
| 89 | "kind": 28934, | ||
| 90 | "pubkey": "<user pubkey>", | ||
| 91 | "tags": [ | ||
| 92 | ["-"], | ||
| 93 | ["claim", "<invite code>"] | ||
| 94 | ], | ||
| 95 | // ...other fields | ||
| 96 | } | ||
| 97 | ``` | ||
| 98 | |||
| 99 | Upon receiving a claim, a relay MUST notify the client as to what the status of the claim is using an `OK` message. Failed claims SHOULD use the same standard `"restricted: "` prefix specified by NIP 42. | ||
| 100 | |||
| 101 | Relays SHOULD update their `kind 13534` member list and MAY publish a `kind 8000` "add member" event. | ||
| 102 | |||
| 103 | Some examples: | ||
| 104 | |||
| 105 | ``` | ||
| 106 | ["OK", <event-id>, false, "restricted: that invite code is expired."] | ||
| 107 | ["OK", <event-id>, false, "restricted: that is an invalid invite code."] | ||
| 108 | ["OK", <event-id>, true, "duplicate: you are already a member of this relay."] | ||
| 109 | ["OK", <event-id>, true, "info: welcome to wss://relay.bunk.skunk!"] | ||
| 110 | ``` | ||
| 111 | |||
| 112 | ## Invite Request | ||
| 113 | |||
| 114 | Users may request a claim string from a relay by making a request for `kind 28935` events. This event MUST be signed by the pubkey specified in the `self` field of the relay's [NIP 11](./11.md) document. | ||
| 115 | |||
| 116 | ```jsonc | ||
| 117 | { | ||
| 118 | "kind": 28935, | ||
| 119 | "pubkey": "<nip11.self>", | ||
| 120 | "tags": [ | ||
| 121 | ["-"], | ||
| 122 | ["claim", "<invite code>"], | ||
| 123 | ], | ||
| 124 | // ...other fields | ||
| 125 | } | ||
| 126 | ``` | ||
| 127 | |||
| 128 | Note that these events are in the `ephemeral` range, which means relays must explicitly opt-in to this behavior by generating claims on the fly when requested. This allows relays to improve security by issuing a different claim for each request, only issuing claims to certain users, or expiring claims. | ||
| 129 | |||
| 130 | ## Leave Request | ||
| 131 | |||
| 132 | A user MAY send a `kind 28936` to a relay in order to request that their access be revoked. The event's `created_at` MUST be now, plus or minus a few minutes. This event MUST include a [NIP 70](./70.md) `-` tag. | ||
| 133 | |||
| 134 | ```jsonc | ||
| 135 | { | ||
| 136 | "kind": 28936, | ||
| 137 | "tags": [["-"]], | ||
| 138 | // ...other fields | ||
| 139 | } | ||
| 140 | ``` | ||
| 141 | |||
| 142 | Relays SHOULD update their `kind 13534` member list and MAY publish a `kind 8001` "remove member" event. | ||
| 143 | |||
| 144 | ## Implementation | ||
| 145 | |||
| 146 | Clients MUST only request `kind 28935` events from and send `kind 28934` events to relays which include this NIP in the `supported_nips` section of its [NIP 11](./11.md) relay information document. | ||