mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-11-09 22:09:06 -05:00
multiple fixes and add contributions.
closes https://github.com/nostr-protocol/nips/pull/34
This commit is contained in:
parent
be92d650b3
commit
90bcbafb43
20
23.md
20
23.md
|
@ -4,7 +4,7 @@ NIP-23
|
||||||
Relays List
|
Relays List
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
`draft` `optional` `author:fiatjaf` `author:cameri`
|
`draft` `optional` `author:fiatjaf` `author:cameri` `author:monlovesango` `author:giszmo`
|
||||||
|
|
||||||
A special event with kind `10001`, meaning "relay list" is defined as having a list of tags, one for each relay the author uses.
|
A special event with kind `10001`, meaning "relay list" is defined as having a list of tags, one for each relay the author uses.
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ The content is not used.
|
||||||
|
|
||||||
The tags consist of arrays of 3 elements: the first is the relay URL, the second is the _read_ condition, the third is the _write_ condition.
|
The tags consist of arrays of 3 elements: the first is the relay URL, the second is the _read_ condition, the third is the _write_ condition.
|
||||||
|
|
||||||
The _read_ condition consists of a string containing a rule that follows a subset of the [runes](https://pypi.org/project/runes/) language. Specifically only the `|`, `&`, `!`, `>`, `<`, `/` and `=` operators are allowed. When the rule is an empty string it evaluates to `true`. When it consists of a single naked `"!"` it evaluates to `false`. All the operators must be tested against all possible values in the case of filter values that consist of lists of values and also in the case of event tags that can have multiple values for the same tag -- in other words, the `=` may be interpreted as a `values.any(v => v == runeValue)` instead of an `values == runeValue` operator; the `<` may be interpreted as a `values.any(v => v < runeValue)` and so on. Event tags are identified just by their tag key (for example, `e` or `p`) without the `#` prefix used in filters.
|
The _read_ condition consists of a string containing a rule that follows a subset of the [runes](https://pypi.org/project/runes/) language. Specifically only the `|`, `&`, `!`, `>`, `<`, `/` and `=` operators are allowed. When the rule is an empty string it evaluates to `true`. All the operators must be tested against all possible values in the case of filter values that consist of lists of values and also in the case of event tags that can have multiple values for the same tag -- in other words, the `=` may be interpreted as a `values.any(v => v == runeValue)` instead of an `values == runeValue` operator; the `<` may be interpreted as a `values.any(v => v < runeValue)` and so on. Event tags are identified just by their tag key (for example, `e` or `p`) without the `#` prefix used in filters.
|
||||||
|
|
||||||
The `read` rule operates on the values of the [NIP-01](01.md) **filter** object, while the `write` rule operates on the values of the **event** object.
|
The `read` rule operates on the values of the [NIP-01](01.md) **filter** object, while the `write` rule operates on the values of the **event** object.
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ When a rule is malformed or the client is unable to parse it for any reason (for
|
||||||
|
|
||||||
This NIP serves two purposes: (1) backup and interoperability of relay lists and relay specific rules between clients; and (2) sharing of relay URLs between users.
|
This NIP serves two purposes: (1) backup and interoperability of relay lists and relay specific rules between clients; and (2) sharing of relay URLs between users.
|
||||||
|
|
||||||
The first use case is meant to make it so users can open their client -- or different clients -- in different devices and have their list of relays automatically fetched from a coon global relay and start using their relays list without having to set everything up again.
|
The first use case is meant to make it so users can open their client -- or different clients -- in different devices and have their list of relays automatically fetched from a default relay and start using their relays list without having to set everything up again.
|
||||||
|
|
||||||
For the second purpose, if any client decides to, they can show to the user what relays other users are using, suggest that or automatically add these to the user's relay list, this can take into account the rules or more likely not. The possibility of sharing a list of relays in standardized format is good for spreading information about relays and contributes to the censorship-resistance of the network.
|
For the second purpose, if any client decides to, they can show to the user what relays other users are using, suggest that or automatically add these to the user's relay list, this can take into account the rules or more likely not. The possibility of sharing a list of relays in standardized format is good for spreading information about relays and contributes to the censorship-resistance of the network.
|
||||||
|
|
||||||
|
@ -35,12 +35,12 @@ A client can expose to the user a set of premade rule templates (the user doesn'
|
||||||
- "do not use this relay for DMs": sets _write_ to `kind/4`
|
- "do not use this relay for DMs": sets _write_ to `kind/4`
|
||||||
- "only use this relay for DMs": sets _write_ to `kind=4` and _read_ to `kinds=4`
|
- "only use this relay for DMs": sets _write_ to `kind=4` and _read_ to `kinds=4`
|
||||||
- "this is Bob's personal relay, only use it to fetch Bob's events": sets _write_ to `!` and _read_ to `authors=<bob-pubkey>`
|
- "this is Bob's personal relay, only use it to fetch Bob's events": sets _write_ to `!` and _read_ to `authors=<bob-pubkey>`
|
||||||
- "this relay is full of spambots, do not get note replies from this relay": sets _read_ to `(kinds=1&e!)|kinds/1`
|
- "this relay is full of spambots, do not get note replies from this relay": sets _read_ to `kinds=1&e!|kinds/1`
|
||||||
- "this is my personal relay, only store my stuff in it": sets _read_ to `authors=<my-pubkey>` _write_ to `pubkey=<my-pubkey>`
|
- "this is my personal relay, only store my stuff in it": sets _read_ to `authors=<my-pubkey>` _write_ to `pubkey=<my-pubkey>`
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
(Public keys are shortened to 3 characters for readability.)
|
(Public keys are shortened to 4 characters for readability.)
|
||||||
|
|
||||||
- Rule evaluation examples:
|
- Rule evaluation examples:
|
||||||
|
|
||||||
|
@ -49,7 +49,10 @@ A client can expose to the user a set of premade rule templates (the user doesn'
|
||||||
- for the filter `{"kinds": [0, 1, 2, 3], "authors": ["abcd", "1234"]}`
|
- for the filter `{"kinds": [0, 1, 2, 3], "authors": ["abcd", "1234"]}`
|
||||||
|
|
||||||
- `<empty>`: `true`
|
- `<empty>`: `true`
|
||||||
- `!`: `false`
|
- `!`: `invalid` -> `true`
|
||||||
|
- `zjhcxb`: `invalid` -> `true`
|
||||||
|
- `false`: `invalid` -> `true`
|
||||||
|
- `true`: `invalid` -> `true`
|
||||||
- `authors=7890`: `false`
|
- `authors=7890`: `false`
|
||||||
- `authors=7890|authors=1234`: `true`
|
- `authors=7890|authors=1234`: `true`
|
||||||
- `authors=7890&authors=1234`: `false`
|
- `authors=7890&authors=1234`: `false`
|
||||||
|
@ -58,13 +61,16 @@ A client can expose to the user a set of premade rule templates (the user doesn'
|
||||||
- `kinds=1|kinds=4`: `true`
|
- `kinds=1|kinds=4`: `true`
|
||||||
- `kinds<2`: `true`
|
- `kinds<2`: `true`
|
||||||
- `kinds>7`: `false`
|
- `kinds>7`: `false`
|
||||||
|
- `kinds=1|kinds=7&authors=8543|authors=1234`: `true`
|
||||||
|
|
||||||
- _write_
|
- _write_
|
||||||
|
|
||||||
- for the event `{"kind": 7, "content": "banana", "tags": ["p", "6677"], "created_at": 123456789, "pubkey": "e3e3"}`
|
- for the event `{"kind": 7, "content": "banana", "tags": ["p", "6677"], "created_at": 123456789, "pubkey": "e3e3"}`
|
||||||
|
|
||||||
- `<empty>`: `true`
|
- `<empty>`: `true`
|
||||||
- `!`: `false`
|
- `!`: `invalid` -> `false`
|
||||||
|
- `7237237`: `invalid` -> `false`
|
||||||
|
- `****`: `invalid` -> `false`
|
||||||
- `pubkey=7890`: `false`
|
- `pubkey=7890`: `false`
|
||||||
- `pubkey=e3e3`: `true`
|
- `pubkey=e3e3`: `true`
|
||||||
- `kind=7&p=6677`: `true`
|
- `kind=7&p=6677`: `true`
|
||||||
|
|
|
@ -18,8 +18,8 @@ NIPs stand for **Nostr Implementation Possibilities**. They exist to document wh
|
||||||
- [NIP-14: Subject tag in text events.](14.md)
|
- [NIP-14: Subject tag in text events.](14.md)
|
||||||
- [NIP-15: End of Stored Events Notice](15.md)
|
- [NIP-15: End of Stored Events Notice](15.md)
|
||||||
- [NIP-16: Event Treatment](16.md)
|
- [NIP-16: Event Treatment](16.md)
|
||||||
- [NIP-25: Reactions](25.md)
|
|
||||||
- [NIP-23: Relays List](23.md)
|
- [NIP-23: Relays List](23.md)
|
||||||
|
- [NIP-25: Reactions](25.md)
|
||||||
|
|
||||||
## Event Kinds
|
## Event Kinds
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user