mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-11-14 15:59:07 -05:00
Update 01.md
Improves type definitions in each json
This commit is contained in:
parent
b36336b937
commit
5d06af8af5
49
01.md
49
01.md
|
@ -12,19 +12,19 @@ This NIP defines the mandatory part of the Nostr protocol. New NIPs may add new
|
||||||
|
|
||||||
Event is the only object type available. It is a hashed and signed payload in the following format:
|
Event is the only object type available. It is a hashed and signed payload in the following format:
|
||||||
|
|
||||||
```json
|
```jsonc
|
||||||
{
|
{
|
||||||
"id": <32-byte lowercase hex-encoded sha256 of the serialized event data>,
|
"id": <string 32-byte lowercase hex-encoded sha256 of the serialized event data>,
|
||||||
"pubkey": <32-byte lowercase hex-encoded public key used to sign>,
|
"pubkey": <string 32-byte lowercase hex-encoded public key used to sign>,
|
||||||
"created_at": <unix timestamp in seconds>,
|
"created_at": <integer unix timestamp in seconds>,
|
||||||
"kind": <integer between 0 and 65535>,
|
"kind": <integer between 0 and 65535>,
|
||||||
"tags": [
|
"tags": [
|
||||||
[<tag1-name>, <tag1-value>, ...],
|
[<string tag1-name>, <string tag1-value>, ...],
|
||||||
[<tag2-name>, <tag2-value>, ...],
|
[<string tag2-name>, <string tag2-value>, ...],
|
||||||
...
|
...
|
||||||
],
|
],
|
||||||
"content": <arbitrary string>,
|
"content": <string>,
|
||||||
"sig": <64-byte lowercase hex of the signature of the id>
|
"sig": <string 64-byte lowercase hex of the signature of the id>
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -36,14 +36,14 @@ Signatures and encodings are done according to the [Schnorr signatures standard
|
||||||
|
|
||||||
To assemble the `.id`, hex encode the result of a `sha256` of the UTF-8 byte array of a JSON-serialized string in the following structure:
|
To assemble the `.id`, hex encode the result of a `sha256` of the UTF-8 byte array of a JSON-serialized string in the following structure:
|
||||||
|
|
||||||
```
|
```js
|
||||||
[
|
[
|
||||||
0,
|
0,
|
||||||
<pubkey, as a lowercase hex string>,
|
<string pubkey, as a lowercase hex>,
|
||||||
<created_at, as a number>,
|
<integer created_at>,
|
||||||
<kind, as a number>,
|
<integer kind>,
|
||||||
<tags, as an array of arrays of non-null strings>,
|
<stringarray tags, as an array of arrays of non-null strings>,
|
||||||
<content, as a string>
|
<string content>
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -136,16 +136,17 @@ To open and update, and close subscriptions, Clients MUST use the following form
|
||||||
|
|
||||||
`<filterX>` is a JSON object that determines what events will be sent in that subscription, it can have the following attributes:
|
`<filterX>` is a JSON object that determines what events will be sent in that subscription, it can have the following attributes:
|
||||||
|
|
||||||
```json
|
```js
|
||||||
{
|
{
|
||||||
"ids": [<id1>, <id2>, ...],
|
"ids": [<string id1>, <string id2>, ...],
|
||||||
"authors": [<pubkey1>, <pubkey2>, ...],
|
"authors": [<string pubkey1>, <string pubkey2>, ...],
|
||||||
"kinds": [<kind1>, <kind2>, ...],
|
"kinds": [<integer kind1>, <integer kind2>, ...],
|
||||||
"#<tag-name1 (single-letter a-zA-Z)>": [<tag value1>, <tag value2>, ...],
|
"#<tag1-name (single-letter a-zA-Z)>": [<string tag1 value1>, <string tag1 value2>, ...],
|
||||||
"#<tag-name2 (single-letter a-zA-Z)>": [<tag value1>, <tag value2>, ...],
|
"#<tag2-name (single-letter a-zA-Z)>": [<string tag2 value1>, <string tag2 value2>, ...],
|
||||||
"since": <an integer unix timestamp in seconds, events must be newer than this to pass>,
|
...,
|
||||||
"until": <an integer unix timestamp in seconds, events must be older than this to pass>,
|
"since": <integer unix timestamp in seconds, events must be newer than this to pass>,
|
||||||
"limit": <maximum number of events to return, sorted by created_at desc>
|
"until": <integer unix timestamp in seconds, events must be older than this to pass>,
|
||||||
|
"limit": <integer maximum number of events to return, sorted by created_at desc>
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -212,4 +213,4 @@ Some examples:
|
||||||
* `["CLOSED", "sub1", "duplicate: sub1 already opened"]`
|
* `["CLOSED", "sub1", "duplicate: sub1 already opened"]`
|
||||||
* `["CLOSED", "sub1", "unsupported: filter contains unknown elements"]`
|
* `["CLOSED", "sub1", "unsupported: filter contains unknown elements"]`
|
||||||
* `["CLOSED", "sub1", "error: could not connect to the database"]`
|
* `["CLOSED", "sub1", "error: could not connect to the database"]`
|
||||||
* `["CLOSED", "sub1", "error: shutting down idle subscription"]`
|
* `["CLOSED", "sub1", "error: shutting down idle subscription"]`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user