diff options
| author | nostr-wine <124309146+nostr-wine@users.noreply.github.com> | 2023-03-18 18:44:31 -0400 |
|---|---|---|
| committer | fiatjaf_ <fiatjaf@gmail.com> | 2023-03-19 16:22:45 -0300 |
| commit | f7b57e3735fc95482d9485d21c4439b9d21851ac (patch) | |
| tree | e39410b6693e5caa94653c072a3a3e13551efebc | |
| parent | dbbf7902d9e11f3515961ff026daf961cd0d10bd (diff) | |
Add proposed extensions to NIP-11
Take the proposed changes from https://github.com/nostr-protocol/nips/pull/163 and put them in NIP-11 under "Extra Fields"
| -rw-r--r-- | 11.md | 197 |
1 files changed, 197 insertions, 0 deletions
| @@ -56,3 +56,200 @@ The relay server implementation MAY be provided in the `software` attribute. If | |||
| 56 | ### Version ### | 56 | ### Version ### |
| 57 | 57 | ||
| 58 | The relay MAY choose to publish its software version as a string attribute. The string format is defined by the relay implementation. It is recommended this be a version number or commit identifier. | 58 | The relay MAY choose to publish its software version as a string attribute. The string format is defined by the relay implementation. It is recommended this be a version number or commit identifier. |
| 59 | |||
| 60 | Extra Fields | ||
| 61 | ----------------- | ||
| 62 | |||
| 63 | ### Server Limitations ### | ||
| 64 | |||
| 65 | These are limitations imposed by the relay on clients. Your client | ||
| 66 | should expect that requests which exceed these *practical* limitations | ||
| 67 | are rejected or fail immediately. | ||
| 68 | |||
| 69 | ```json | ||
| 70 | { | ||
| 71 | ... | ||
| 72 | limitation: { | ||
| 73 | max_message_length: 16384, | ||
| 74 | max_subscriptions: 20, | ||
| 75 | max_filters: 100, | ||
| 76 | max_limit: 5000, | ||
| 77 | max_subid_length: 100, | ||
| 78 | min_prefix: 4, | ||
| 79 | max_event_tags: 100, | ||
| 80 | max_content_length: 8196, | ||
| 81 | min_pow_difficulty: 30, | ||
| 82 | auth_required: true, | ||
| 83 | payment_required: true, | ||
| 84 | } | ||
| 85 | ... | ||
| 86 | } | ||
| 87 | ``` | ||
| 88 | |||
| 89 | - `max_message_length`: this is the maximum number of bytes for incoming JSON that the relay | ||
| 90 | will attempt to decode and act upon. When you send large subscriptions, you will be | ||
| 91 | limited by this value. It also effectively limits the maximum size of any event. Value is | ||
| 92 | calculated from `[` to `]` and is after UTF-8 serialization (so some unicode characters | ||
| 93 | will cost 2-3 bytes). It is equal to the maximum size of the WebSocket message frame. | ||
| 94 | |||
| 95 | - `max_subscriptions`: total number of subscriptions that may be | ||
| 96 | active on a single websocket connection to this relay. It's possible | ||
| 97 | that authenticated clients with a (paid) relationship to the relay | ||
| 98 | may have higher limits. | ||
| 99 | |||
| 100 | - `max_filters`: maximum number of filter values in each subscription. | ||
| 101 | Must be one or higher. | ||
| 102 | |||
| 103 | - `max_subid_length`: maximum length of subscription id as a string. | ||
| 104 | |||
| 105 | - `min_prefix`: for `authors` and `ids` filters which are to match against | ||
| 106 | a hex prefix, you must provide at least this many hex digits in the prefix. | ||
| 107 | |||
| 108 | - `max_limit`: the relay server will clamp each filter's `limit` value to this number. | ||
| 109 | This means the client won't be able to get more than this number | ||
| 110 | of events from a single subscription filter. This clamping is typically done silently | ||
| 111 | by the relay, but with this number, you can know that there are additional results | ||
| 112 | if you narrowed your filter's time range or other parameters. | ||
| 113 | |||
| 114 | - `max_event_tags`: in any event, this is the maximum number of elements in the `tags` list. | ||
| 115 | |||
| 116 | - `max_content_length`: maximum number of characters in the `content` | ||
| 117 | field of any event. This is a count of unicode characters. After | ||
| 118 | serializing into JSON it may be larger (in bytes), and is still | ||
| 119 | subject to the `max_message_length`, if defined. | ||
| 120 | |||
| 121 | - `min_pow_difficulty`: new events will require at least this difficulty of PoW, | ||
| 122 | based on [NIP-13](13.md), or they will be rejected by this server. | ||
| 123 | |||
| 124 | - `auth_required`: this relay requires [NIP-42](42.md) authentication | ||
| 125 | to happen before a new connection may perform any other action. | ||
| 126 | Even if set to False, authentication may be required for specific actions. | ||
| 127 | |||
| 128 | - `payment_required`: this relay requires payment before a new connection may perform any action. | ||
| 129 | |||
| 130 | ### Event Retention ### | ||
| 131 | |||
| 132 | There may be a cost associated with storing data forever, so relays | ||
| 133 | may wish to state retention times. The values stated here are defaults | ||
| 134 | for unauthenticated users and visitors. Paid users would likely have | ||
| 135 | other policies. | ||
| 136 | |||
| 137 | Retention times are given in seconds, with `null` indicating infinity. | ||
| 138 | If zero is provided, this means the event will not be stored at | ||
| 139 | all, and preferably an error will be provided when those are received. | ||
| 140 | |||
| 141 | ```json | ||
| 142 | { | ||
| 143 | ... | ||
| 144 | retention: [ | ||
| 145 | { kinds: [0, 1, [5, 7], [40, 49]], time: 3600 }, | ||
| 146 | { kinds: [[40000, 49999], time: 100 }, | ||
| 147 | { kinds: [[30000, 39999], count: 1000 }, | ||
| 148 | { time: 3600, count: 10000 } | ||
| 149 | ] | ||
| 150 | ... | ||
| 151 | } | ||
| 152 | ``` | ||
| 153 | |||
| 154 | `retention` is a list of specifications: each will apply to either all kinds, or | ||
| 155 | a subset of kinds. Ranges may be specified for the kind field as a tuple of inclusive | ||
| 156 | start and end values. Events of indicated kind (or all) are then limited to a `count` | ||
| 157 | and or time period. | ||
| 158 | |||
| 159 | It is possible to effectively blacklist Nostr-based protocols that rely on | ||
| 160 | a specific `kind` number, by giving a retention time of zero for those `kind` values. | ||
| 161 | While that is unfortunate, it does allow clients to discover servers that will | ||
| 162 | support their protocol quickly via a single HTTP fetch. | ||
| 163 | |||
| 164 | There is no need to specify retention times for _ephemeral events_ as defined | ||
| 165 | in [NIP-16](16.md) since they are not retained. | ||
| 166 | |||
| 167 | |||
| 168 | ### Content Limitations ### | ||
| 169 | |||
| 170 | Some relays may be governed by the arbitrary laws of a nation state. This | ||
| 171 | may limit what content can be stored in cleartext on those relays. All | ||
| 172 | clients are encouraged to use encryption to work around this limitation. | ||
| 173 | |||
| 174 | It is not possible to describe the limitations of each country's laws | ||
| 175 | and policies which themselves are typically vague and constantly shifting. | ||
| 176 | |||
| 177 | Therefore, this field allows the relay operator to indicate which | ||
| 178 | country's' laws might end up being enforced on them, and then | ||
| 179 | indirectly on their users's content. | ||
| 180 | |||
| 181 | Users should be able to avoid relays in countries they don't like, | ||
| 182 | and/or select relays in more favourable zones. Exposing this | ||
| 183 | flexibility is up to the client software. | ||
| 184 | |||
| 185 | ```json | ||
| 186 | { | ||
| 187 | ... | ||
| 188 | relay_countries: [ 'CA', 'US' ], | ||
| 189 | ... | ||
| 190 | } | ||
| 191 | ``` | ||
| 192 | |||
| 193 | - `relay_countries`: a list of two-level ISO country codes (ISO 3166-1 alpha-2) whose | ||
| 194 | laws and policies may affect this relay. `EU` may be used for European Union countries. | ||
| 195 | |||
| 196 | Remember that a relay may be hosted in a country which is not the | ||
| 197 | country of the legal entities who own the relay, so it's very | ||
| 198 | likely a number of countries are involved. | ||
| 199 | |||
| 200 | |||
| 201 | ### Community Preferences ### | ||
| 202 | |||
| 203 | For public text notes at least, a relay may try to foster a | ||
| 204 | local community. This would encourage users to follow the global | ||
| 205 | feed on that relay, in addition to their usual individual follows. | ||
| 206 | To support this goal, relays MAY specify some of the following values. | ||
| 207 | |||
| 208 | ```json | ||
| 209 | { | ||
| 210 | ... | ||
| 211 | language_tags: [ 'en', 'en-419' ], | ||
| 212 | tags: [ 'sfw-only', 'bitcoin-only', 'anime' ], | ||
| 213 | posting_policy: 'https://example.com/posting-policy.html', | ||
| 214 | ... | ||
| 215 | } | ||
| 216 | ``` | ||
| 217 | |||
| 218 | - `language_tags` is an ordered list | ||
| 219 | of [IETF language tags](https://en.wikipedia.org/wiki/IETF_language_tag) indicating | ||
| 220 | the major languages spoken on the relay. | ||
| 221 | |||
| 222 | - `tags` is a list of limitations on the topics to be discussed. | ||
| 223 | For example `sfw-only` indicates hat only "Safe For Work" content | ||
| 224 | is encouraged on this relay. This relies on assumptions of what the | ||
| 225 | "work" "community" feels "safe" talking about. In time, a common | ||
| 226 | set of tags may emerge that allow users to find relays that suit | ||
| 227 | their needs, and client software will be able to parse these tags easily. | ||
| 228 | The `bitcoin-only` tag indicates that any *altcoin*, *"crypto"* or *blockchain* | ||
| 229 | comments will be ridiculed without mercy. | ||
| 230 | |||
| 231 | - `posting_policy` is a link to a human-readable page which specifies the | ||
| 232 | community policies for the relay. In cases where `sfw-only` is True, it's | ||
| 233 | important to link to a page which gets into the specifics of your posting policy. | ||
| 234 | |||
| 235 | The `description` field should be used to describe your community | ||
| 236 | goals and values, in brief. The `posting_policy` is for additional | ||
| 237 | detail and legal terms. Use the `tags` field to signify limitations | ||
| 238 | on content, or topics to be discussed, which could be machine | ||
| 239 | processed by appropriate client software. | ||
| 240 | |||
| 241 | ### Pay-To-Relay ### | ||
| 242 | |||
| 243 | Relays that require payments may want to expose their fee schedules. | ||
| 244 | |||
| 245 | ```json | ||
| 246 | { | ||
| 247 | ... | ||
| 248 | payments_url: "https://my-relay/payments", | ||
| 249 | fees: { | ||
| 250 | "admission": [{ amount: 1000000, unit: 'msats' }], | ||
| 251 | "subscription": [{ amount: 5000000, unit: 'msats', period: 2592000 }], | ||
| 252 | "publication": [{ kinds: [4], amount: 100, unit: 'msats' }], | ||
| 253 | }, | ||
| 254 | ... | ||
| 255 | } | ||