From e0d16a0a99f4ed6defc2bb4538aa2947fa1ea00b Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 19 Aug 2024 14:53:42 -0400 Subject: [PATCH] Adds a LIMITS payload with strict definitions on how clients should work. --- 20.md | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/20.md b/20.md index 6feed6a9..f1048706 100644 --- a/20.md +++ b/20.md @@ -1,9 +1,40 @@ NIP-20 ====== -Command Results ---------------- +Connection Limitations +---------------------- -`final` `mandatory` +`draft` `optional` -Moved to [NIP-01](01.md). +Upon connection, and at any point during the connection, the Relay can send a `LIMITS` payload to the Client reflecting the current state of the user's rights in the relay. + +```json +["LIMITS", { }] +``` + +Where `limit_properties` includes properties that are specifically designed to change the way Clients communicate. Options are: + +- `can_write: `, If false, Clients MUST NOT publish events to the relay. +- `can_read: `, If true, Clients MUST NOT send `REQ` commands to the relay. + +- `accepted_event_kinds: [, , ...]`, Clients MUST filter publishing events by these types. +- `blocked_event_kinds: [, , ...]`, Clients MUST remove these types from publishing actions. + +- `min_pow_difficulty: `: Clients MUST filter publishing events if they don't have at least this PoW bit difficulty. + +- `max_message_length: `, Clients MUST filter publishing events and crop/chunk `REQ` filters by this length. +- `max_subscriptions: `, Clients MUST reduce the number of subscriptions to this amount. +- `max_filters: `, Clients MUST crop/chunk `REQ` filters by this amount. +- `max_limit: `, Clients MUST clump each filter's `limit` value to this number and use `since` and `until` to get additional results. +- `max_event_tags: `, Clients MUST filter publishing events by this `.tags` length. +- `max_content_length: `, Clients MUST filter publishing events by this `.content` length. + +- `created_at_lower_limit: `, Clients MUST filter publishing events whose `.created_at` is smaller than this number +- `created_at_upper_limit: `, Clients MUST filter publishing events whose `.created_at` is bigger than this number + +- `filter_rate_limit: `: Clients MUST debounce filter changes after by this amount in milliseconds. +- `publishing_rate_limit: `: Clients MUST debounce publishing events by this amount in milliseconds. + +- `required_tags: [ [ , ], [ , ] ]`, Clients MUST filter publishing events that don't include all listed tag names and values. + +This payload SHOULD be cached in the Client's Relay connection object and updated as many times as the relay requests. Clients should use the information here to apply filters when sending events and `REQs` to the relay. \ No newline at end of file