upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSemisol <45574030+Semisol@users.noreply.github.com>2025-01-03 10:38:04 +0300
committerGitHub <noreply@github.com>2025-01-03 10:38:04 +0300
commit01926e3da2baaf5bb519658473944283da812bd7 (patch)
tree05e733fb2b8b5ed49d185454202ac7dda568bcb9
parentc91098af862630418aeaa1e94752d2ddb03dccdb (diff)
Create NIP-91
-rw-r--r--91.md87
1 files changed, 87 insertions, 0 deletions
diff --git a/91.md b/91.md
new file mode 100644
index 0000000..f18ef15
--- /dev/null
+++ b/91.md
@@ -0,0 +1,87 @@
1NIP-91
2======
3
4Protocol Negotiation
5--------------------
6
7`draft` `optional`
8
9This NIP defines a method for clients to negotiate extension protocols with relays.
10
11## Protocol Names
12
13Each protocol has a **protocol name** that can uniquely identify the protocol. Currently the following formats are recommended:
14- `nip-XX-<description>`: For protocols standardized in NIPs. Experimental protocols are recommended to have a unique description to not conflict.
15- `<namespace>/<protocol>`: For custom protocols. The namespace should uniquely identify the standardizing body for this protocol with a DNS name. (example: `example.com/example-protocol`)
16- `x/<protocol>`: For custom protocols without a namespace.
17
18Any protocol name outside this list MUST NOT be used.
19
20## Protocol Offers
21
22The relay may send a protocol offer as a `PN-OFFER` message:
23```jsonc
24[
25 "PN-OFFER",
26 {
27 "example.com/example-protocol": {...},
28 "nip-XX-example-protocol": {...}
29 }
30]
31```
32
33The first entry MUST be an object, with the keys being protocol names, and the values being objects. The format of the object is up to the protocol to define.
34
35A protocol offer can be sent multiple times in a connection, such as to update availability based off of their [NIP-42](./42.md) authentication status.
36
37Clients SHOULD be able to handle protocol offers being able to be withdrawn. The removal of a protocol from a `PN-OFFER` does not affect existing active protocols, a `PN-SHUTDOWN` must be sent if that is required.
38
39## Protocol Requests
40
41A client may request a protocol offered by the relay be enabled with the `PN-REQUEST` message:
42```jsonc
43[
44 "PN-REQUEST",
45 "example.com/example-protocol",
46 {...}
47]
48```
49
50The first entry MUST be the protocol name, and the second entry MUST be a protocol-dependent object for the protocol enable request.
51
52The relay SHOULD respond with a `PN-OK` or `PN-ERROR` message:
53```jsonc
54[
55 "PN-OK",
56 "example.com/example-protocol",
57 {...}
58]
59```
60```jsonc
61[
62 "PN-ERROR",
63 "example.com/example-protocol",
64 "improper protocol request data"
65]
66```
67
68In both messages, the first entry MUST be the protocol name. The second entry depends on the type:
69- `PN-OK`: Response data for the protocol negotiation. After this message, the protocol can be used.
70- `PN-ERROR`: An error message.
71
72An error message SHOULD start with a single-word prefix, followed by a colon (:) and space character, and a human readable message. The following types are defined:
73- `error`: An internal error has occurred in the relay.
74- `not-offered`: The protocol was not offered. This may happen due to a `PN-REQUEST` being sent at the same time as a new `PN-OFFER`.
75- `bad-data`: The client has sent improper protocol negotiation data.
76
77## Protocol Shutdown
78
79The relay or client may shut down the usage of the protocol any time with a `PN-SHUTDOWN` message:
80```jsonc
81[
82 "PN-SHUTDOWN",
83 "example.com/example-protocol"
84]
85```
86
87After this message, the sending party will no longer accept and send new protocol messages, and the receiver should not continue attempting to use the protocol functionality.