mirror of
https://github.com/nostr-protocol/nips.git
synced 2025-12-09 00:28:51 +00:00
Compare commits
3 Commits
nip-17-typ
...
no-batchin
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85ea8ab124 | ||
|
|
0b3eea1053 | ||
|
|
0619f370bc |
4
01.md
4
01.md
@@ -113,7 +113,7 @@ Relays expose a websocket endpoint to which clients can connect. Clients SHOULD
|
|||||||
Clients can send 3 types of messages, which must be JSON arrays, according to the following patterns:
|
Clients can send 3 types of messages, which must be JSON arrays, according to the following patterns:
|
||||||
|
|
||||||
* `["EVENT", <event JSON as defined above>]`, used to publish events.
|
* `["EVENT", <event JSON as defined above>]`, used to publish events.
|
||||||
* `["REQ", <subscription_id>, <filters1>, <filters2>, ...]`, used to request events and subscribe to new updates.
|
* `["REQ", <subscription_id>, <filter>]`, used to request events and subscribe to new updates.
|
||||||
* `["CLOSE", <subscription_id>]`, used to stop previous subscriptions.
|
* `["CLOSE", <subscription_id>]`, used to stop previous subscriptions.
|
||||||
|
|
||||||
`<subscription_id>` is an arbitrary, non-empty string of max length 64 chars. It represents a subscription per connection. Relays MUST manage `<subscription_id>`s independently for each WebSocket connection. `<subscription_id>`s are not guaranteed to be globally unique.
|
`<subscription_id>` is an arbitrary, non-empty string of max length 64 chars. It represents a subscription per connection. Relays MUST manage `<subscription_id>`s independently for each WebSocket connection. `<subscription_id>`s are not guaranteed to be globally unique.
|
||||||
@@ -142,8 +142,6 @@ The `since` and `until` properties can be used to specify the time range of even
|
|||||||
|
|
||||||
All conditions of a filter that are specified must match for an event for it to pass the filter, i.e., multiple conditions are interpreted as `&&` conditions.
|
All conditions of a filter that are specified must match for an event for it to pass the filter, i.e., multiple conditions are interpreted as `&&` conditions.
|
||||||
|
|
||||||
A `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.
|
|
||||||
|
|
||||||
The `limit` property of a filter is only valid for the initial query and MUST be ignored afterwards. When `limit: n` is present it is assumed that the events returned in the initial query will be the last `n` events ordered by the `created_at`. Newer events should appear first, and in the case of ties the event with the lowest id (first in lexical order) should be first. 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.
|
The `limit` property of a filter is only valid for the initial query and MUST be ignored afterwards. When `limit: n` is present it is assumed that the events returned in the initial query will be the last `n` events ordered by the `created_at`. Newer events should appear first, and in the case of ties the event with the lowest id (first in lexical order) should be first. 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.
|
||||||
|
|
||||||
### From relay to client: sending events and notices
|
### From relay to client: sending events and notices
|
||||||
|
|||||||
14
17.md
14
17.md
@@ -57,7 +57,7 @@ Kind `14`s MUST never be signed. If it is signed, the message might leak to rela
|
|||||||
["file-type", "<file-mime-type>"],
|
["file-type", "<file-mime-type>"],
|
||||||
["encryption-algorithm", "<encryption-algorithm>"],
|
["encryption-algorithm", "<encryption-algorithm>"],
|
||||||
["decryption-key", "<decryption-key>"],
|
["decryption-key", "<decryption-key>"],
|
||||||
["decryptiion-nonce", "<decryption-nonce>"],
|
["decryption-nonce", "<decryption-nonce>"],
|
||||||
["x", "<the SHA-256 hexencoded string of the file>"],
|
["x", "<the SHA-256 hexencoded string of the file>"],
|
||||||
// rest of tags...
|
// rest of tags...
|
||||||
],
|
],
|
||||||
@@ -74,16 +74,16 @@ Kind 15 is used for sending encrypted file event messages:
|
|||||||
- `content`: The URL of the file (`<file-url>`).
|
- `content`: The URL of the file (`<file-url>`).
|
||||||
- `x` containing the SHA-256 hexencoded string of the file.
|
- `x` containing the SHA-256 hexencoded string of the file.
|
||||||
- `size` (optional) size of file in bytes
|
- `size` (optional) size of file in bytes
|
||||||
- `dim` (optional) size of file in pixels in the form `<width>x<height>`
|
- `dim` (optional) size of the file in pixels in the form `<width>x<height>`
|
||||||
- `blurhash`(optional) the [blurhash](https://github.com/woltapp/blurhash) to show while the file is being loaded by the client
|
- `blurhash`(optional) the [blurhash](https://github.com/woltapp/blurhash) to show while the client is loading the file
|
||||||
- `thumb` (optional) url of thumbnail with same aspect ratio
|
- `thumb` (optional) URL of thumbnail with same aspect ratio (encrypted with the same key, nonce)
|
||||||
- `fallback` (optional) zero or more fallback file sources in case `url` fails
|
- `fallback` (optional) zero or more fallback file sources in case `url` fails
|
||||||
|
|
||||||
Just like kind 14, kind `15`s MUST never be signed.
|
Just like kind 14, kind `15`s MUST never be signed.
|
||||||
|
|
||||||
## Chat Rooms
|
## Chat Rooms
|
||||||
|
|
||||||
The set of `pubkey` + `p` tags defines a chat room. If a new `p` tag is added or a current one is removed, a new room is created with clean message history.
|
The set of `pubkey` + `p` tags defines a chat room. If a new `p` tag is added or a current one is removed, a new room is created with a clean message history.
|
||||||
|
|
||||||
Clients SHOULD render messages of the same room in a continuous thread.
|
Clients SHOULD render messages of the same room in a continuous thread.
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ An optional `subject` tag defines the current name/topic of the conversation. An
|
|||||||
|
|
||||||
## Encrypting
|
## Encrypting
|
||||||
|
|
||||||
Following [NIP-59](59.md), the **unsigned** `kind:14` & `kind:15` chat message must be sealed (`kind:13`) and then gift-wrapped (`kind:1059`) to each receiver and the sender individually.
|
Following [NIP-59](59.md), the **unsigned** `kind:14` & `kind:15` chat messages must be sealed (`kind:13`) and then gift-wrapped (`kind:1059`) to each receiver and the sender individually.
|
||||||
|
|
||||||
```jsonc
|
```jsonc
|
||||||
{
|
{
|
||||||
@@ -173,7 +173,7 @@ The main limitation of this approach is having to send a separate encrypted even
|
|||||||
|
|
||||||
Clients implementing this NIP should by default only connect to the set of relays found in their `kind:10050` list. From that they should be able to load all messages both sent and received as well as get new live updates, making it for a very simple and lightweight implementation that should be fast.
|
Clients implementing this NIP should by default only connect to the set of relays found in their `kind:10050` list. From that they should be able to load all messages both sent and received as well as get new live updates, making it for a very simple and lightweight implementation that should be fast.
|
||||||
|
|
||||||
When sending a message to anyone, clients must then connect to the relays in the receiver's `kind:10050` and send the events there, but can disconnect right after unless more messages are expected to be sent (e.g. the chat tab is still selected). Clients should also send a copy of their outgoing messages to their own `kind:10050` relay set.
|
When sending a message to anyone, clients must then connect to the relays in the receiver's `kind:10050` and send the events there but can disconnect right after unless more messages are expected to be sent (e.g. the chat tab is still selected). Clients should also send a copy of their outgoing messages to their own `kind:10050` relay set.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
|||||||
2
50.md
2
50.md
@@ -31,7 +31,7 @@ not by the usual `.created_at`. The `limit` filter SHOULD be applied after sorti
|
|||||||
A query string may contain `key:value` pairs (two words separated by colon), these are extensions, relays SHOULD ignore
|
A query string may contain `key:value` pairs (two words separated by colon), these are extensions, relays SHOULD ignore
|
||||||
extensions they don't support.
|
extensions they don't support.
|
||||||
|
|
||||||
Clients may specify several search filters, i.e. `["REQ", "", { "search": "orange" }, { "kinds": [1, 2], "search": "purple" }]`. Clients may
|
Clients may specify several search filters, i.e. `["REQ", "_", {"kinds": [1], "search": "purple"}]`. Clients may
|
||||||
include `kinds`, `ids` and other filter field to restrict the search results to particular event kinds.
|
include `kinds`, `ids` and other filter field to restrict the search results to particular event kinds.
|
||||||
|
|
||||||
Clients SHOULD use the supported_nips field to learn if a relay supports `search` filter. Clients MAY send `search`
|
Clients SHOULD use the supported_nips field to learn if a relay supports `search` filter. Clients MAY send `search`
|
||||||
|
|||||||
Reference in New Issue
Block a user