upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiatjaf <fiatjaf@gmail.com>2022-05-08 21:31:29 -0300
committerfiatjaf <fiatjaf@gmail.com>2022-05-08 21:34:27 -0300
commita4aea5337fe6b93e55f9dae1974ead962c1997e8 (patch)
tree8935b1fef0dfc66a4ddfa33b8a7ff9a02c5bec8e
parent57b86d2482509bad04067e646b130c41f9433923 (diff)
sneak filter.limit in nip-01.
-rw-r--r--01.md9
-rw-r--r--05.md6
2 files changed, 9 insertions, 6 deletions
diff --git a/01.md b/01.md
index 39aac0e..8b81828 100644
--- a/01.md
+++ b/01.md
@@ -4,7 +4,7 @@ NIP-01
4Basic protocol flow description 4Basic protocol flow description
5------------------------------- 5-------------------------------
6 6
7`draft` `mandatory` `author:fiatjaf` `author:distbit` `author:scsibug` `author:kukks` 7`draft` `mandatory` `author:fiatjaf` `author:distbit` `author:scsibug` `author:kukks` `author:jb55`
8 8
9This NIP defines the basic protocol that should be implemented by everybody. New NIPs may add new optional (or mandatory) fields and messages and features to the structures and flows described here. 9This NIP defines the basic protocol that should be implemented by everybody. New NIPs may add new optional (or mandatory) fields and messages and features to the structures and flows described here.
10 10
@@ -62,16 +62,17 @@ Clients can send 3 types of messages, which must be JSON arrays, according to th
62``` 62```
63{ 63{
64 "ids": <a list of event ids or prefixes>, 64 "ids": <a list of event ids or prefixes>,
65 "authors": <a list of pubkeys or prefixes, the pubkey of an event must be one of these>,
65 "kinds": <a list of a kind numbers>, 66 "kinds": <a list of a kind numbers>,
66 "#e": <a list of event ids that are referenced in an "e" tag>, 67 "#e": <a list of event ids that are referenced in an "e" tag>,
67 "#p": <a list of pubkeys that are referenced in a "p" tag>, 68 "#p": <a list of pubkeys that are referenced in a "p" tag>,
68 "since": <a timestamp, events must be newer than this to pass>, 69 "since": <a timestamp, events must be newer than this to pass>,
69 "until": <a timestamp, events must be older than this to pass>, 70 "until": <a timestamp, events must be older than this to pass>,
70 "authors": <a list of pubkeys or prefixes, the pubkey of an event must be one of these> 71 "limit": <maximum number of events to be returned in the initial query>
71} 72}
72``` 73```
73 74
74Upon receiving a `REQ` message, the relay MUST query its internal database and return events that match the filter, then store that filter and send again all future events it receives to that same websocket until the websocket is closed. The `CLOSE` event is received with the same `<subscription_id>` or a new `REQ` is sent using the same `<subscription_id>`, in which case it should overwrite the previous subscription. 75Upon receiving a `REQ` message, the relay SHOULD query its internal database and return events that match the filter, then store that filter and send again all future events it receives to that same websocket until the websocket is closed. The `CLOSE` event is received with the same `<subscription_id>` or a new `REQ` is sent using the same `<subscription_id>`, in which case it should overwrite the previous subscription.
75 76
76Filter attributes containing lists (such as `ids`, `kinds`, or `#e`) are JSON arrays with one or more values. At least one of the array's values must match the relevant field in an event for the condition itself to be considered a match. For scalar event attributes such as `kind`, the attribute from the event must be contained in the filter list. For tag attributes such as `#e`, where an event may have multiple values, the event and filter condition values must have at least one item in common. 77Filter attributes containing lists (such as `ids`, `kinds`, or `#e`) are JSON arrays with one or more values. At least one of the array's values must match the relevant field in an event for the condition itself to be considered a match. For scalar event attributes such as `kind`, the attribute from the event must be contained in the filter list. For tag attributes such as `#e`, where an event may have multiple values, the event and filter condition values must have at least one item in common.
77 78
@@ -81,6 +82,8 @@ All conditions of a filter that are specified must match for an event for it to
81 82
82A `REQ` message may contain multiple filters. In this case events that match any of the filters are to be returned, i.e., multiple filters are to be interpreted as `||` conditions. 83A `REQ` message may contain multiple filters. In this case events that match any of the filters are to be returned, i.e., multiple filters are to be interpreted as `||` conditions.
83 84
85The `limit` property of a filter is only valid for the initial query and can be ignored afterwards. When `limit: n` is present it is assumed that the the events returned in the initial query will be the latest `n` events. It is safe to return less events than `limit` specifies, but it is expected that relays do not return (much) more events than requested so clients don't get unnecessarily overwhelmed by data.
86
84### From relay to client: sending events and notices 87### From relay to client: sending events and notices
85 88
86Relays can send 2 types of messages, which must also be JSON arrays, according to the following patterns: 89Relays can send 2 types of messages, which must also be JSON arrays, according to the following patterns:
diff --git a/05.md b/05.md
index 3267960..1741aae 100644
--- a/05.md
+++ b/05.md
@@ -51,15 +51,15 @@ Clients may treat the identifier `_@domain` as the "root" identifier, and choose
51 51
52By adding the `<local-part>` as a query string instead of as part of the path the protocol can support both dynamic servers that can generate JSON on-demand and static servers with a JSON file in it that may contain multiple names. 52By adding the `<local-part>` as a query string instead of as part of the path the protocol can support both dynamic servers that can generate JSON on-demand and static servers with a JSON file in it that may contain multiple names.
53 53
54### Allowing access from Javascript apps 54### Allowing access from JavaScript apps
55 55
56Javascript Nostr apps may be restricted by browser [CORS][] policies that prevent them from accesing `nostr.json` on the user's domain. When CORS prevents JS from loading a resource, the JS program sees it as a network failure identical to the resource not existing, so it is not possible for a pure-JS app to tell the user for certain that the failure was caused by a CORS issue. JS Nostr apps that see network failures requesting `nostr.json` files may want to recommend to users that they check the CORS policy of their servers, e.g.: 56JavaScript Nostr apps may be restricted by browser [CORS][] policies that prevent them from accesing `/.well-known/nostr.json` on the user's domain. When CORS prevents JS from loading a resource, the JS program sees it as a network failure identical to the resource not existing, so it is not possible for a pure-JS app to tell the user for certain that the failure was caused by a CORS issue. JS Nostr apps that see network failures requesting `/.well-known/nostr.json` files may want to recommend to users that they check the CORS policy of their servers, e.g.:
57 57
58```bash 58```bash
59$ curl -sI https://example.com/.well-known/nostr.json?name=bob | grep ^Access-Control 59$ curl -sI https://example.com/.well-known/nostr.json?name=bob | grep ^Access-Control
60Access-Control-Allow-Origin: * 60Access-Control-Allow-Origin: *
61``` 61```
62 62
63Users should ensure that their `nostr.json` is served with the HTTP header `Access-Control-Allow-Origin: *` to ensure it can be validated by pure JS apps running in modern browsers. 63Users should ensure that their `/.well-known/nostr.json` is served with the HTTP header `Access-Control-Allow-Origin: *` to ensure it can be validated by pure JS apps running in modern browsers.
64 64
65[CORS]: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS 65[CORS]: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS