Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIP-91: Extension Negotiation #1671

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

NIP-91: Extension Negotiation #1671

wants to merge 3 commits into from

Conversation

Semisol
Copy link
Collaborator

@Semisol Semisol commented Jan 3, 2025

This NIP adds an extension negotiation scheme for clients and relays to negotiate new protocols. The intended goal is to replace NIP-11 for the discovery of relay supported features.

An extension feature negotiation scheme is also included.

@mikedilger
Copy link
Contributor

Might I suggest doing this with HTTP headers on websocket connect?

According to websocket standards we are supposed to be using the Sec-WebSocket-Protocol header and specifying something like "nostr" because there are plenty of websocket servers out there that are not nostr relays. But we never did anything like that.

By using an HTTP header you won't need another round trip. Also, if the relay doesn't support it you won't get a response header but the relay will continue talking to you, whereas with a new command the relay might drop the connection because you are speaking gibberish.

@Semisol
Copy link
Collaborator Author

Semisol commented Jan 3, 2025

According to websocket standards we are supposed to be using the Sec-WebSocket-Protocol header and specifying something like "nostr" because there are plenty of websocket servers out there that are not nostr relays. But we never did anything like that.

This does not allow negotiating specific protocol parameters, or gating access behind AUTH. This also is problematic as you can only pick 1 protocol, and does not allow you to know what protocols the server could have offered but didn't pick.

By using an HTTP header you won't need another round trip. Also, if the relay doesn't support it you won't get a response header but the relay will continue talking to you, whereas with a new command the relay might drop the connection because you are speaking gibberish.

The relay sends the first command, PN-OFFER, which does not add a round trip as it is sent at the same time the connection is opened, and only protocols that need parameter negotiation need another round trip.
A relay which will drop the connection on an invalid command is also defective.

@Semisol Semisol changed the title NIP-91: Protocol Negotiation NIP-91: Feature Negotiation Jan 3, 2025
The NIP has been renamed to represent the goals of the NIP more accurately.

The x/ extension namespace has been removed, and any features meant to be standardized as a NIP should create a preliminary PR and use the `nip/` namespace. Any extensions that are meant to be standardized externally should use their own namespace.
@Semisol Semisol changed the title NIP-91: Feature Negotiation NIP-91: Extension Negotiation Jan 3, 2025
@Semisol
Copy link
Collaborator Author

Semisol commented Jan 3, 2025

Updated the NIP to be more accurate about its goals.

The x/ namespace has been removed, to encourage standardization

@buttercat1791
Copy link
Contributor

@Semisol could relays use this to negotiate accepted kind numbers?

One might have a relay, for instance, that does not store parameterized replaceable events. Could this NIP be used by the relay to indicate this limitation to the client? Then the client would know not to try to published parameterized replaceable events to the relay.

This is distinct from merely indicating a supported NIP, as relays may support kind ranges that are not yet part of any widely-accepted NIP.

@Semisol
Copy link
Collaborator Author

Semisol commented Jan 3, 2025

@Semisol could relays use this to negotiate accepted kind numbers?

One might have a relay, for instance, that does not store parameterized replaceable events. Could this NIP be used by the relay to indicate this limitation to the client? Then the client would know not to try to published parameterized replaceable events to the relay.

I expect that most NIP-11 data for indicating capabilities and features can be moved here, even giving different users different privileges.

@mikedilger
Copy link
Contributor

This does not allow negotiating specific protocol parameters, or gating access behind AUTH. This also is problematic as you can only pick 1 protocol, and does not allow you to know what protocols the server could have offered but didn't pick.

I'm not saying to use Sec-WebSocket-Protocol itself, make up a new header. Put in the client's requested features. Then the server sends back that same header with the supported/accepted features. Of course in the way I envision it, the client starts the negotiation not the relay.

You are right it is not gated behind AUTH. I can't think why it should be.

A relay which will drop the connection on an invalid command is also defective.

NIP-01 does not define what a relay should do if it receives a command it does not understand.

@Semisol
Copy link
Collaborator Author

Semisol commented Jan 4, 2025

NIP-01 does not define what a relay should do if it receives a command it does not understand.

Again, in this case, the communication is initiated by the relay. A majority of clients and relays I use currently ignore and send errors on unknown commands, not close the connection.

@Semisol
Copy link
Collaborator Author

Semisol commented Jan 4, 2025

I'm not saying to use Sec-WebSocket-Protocol itself, make up a new header. Put in the client's requested features. Then the server sends back that same header with the supported/accepted features. Of course in the way I envision it, the client starts the negotiation not the relay.

@mikedilger Also, the problem here is you now break compatibility for all web clients.

You are right it is not gated behind AUTH. I can't think why it should be.

A goal of this NIP is to replace NIP-11 for relay information, which includes things like event constraints.

@staab
Copy link
Member

staab commented Jan 6, 2025

This seems too structured/interactive for nostr. NIP 11 is annoying in some ways, but it does the job for most things. For other things, #1434 seems preferable since it's more concrete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants