Merge 7cb0e77d3e87c326c8da42ace99c8f3d1dc01a57 into 0619f370bca3485bb9c5870bc2defa03c7c3d10e

This commit is contained in:
Water Blower 2025-03-15 10:40:04 +08:00 committed by GitHub
commit 94eafd8365
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

35
1078.md Normal file
View File

@ -0,0 +1,35 @@
# NIP-1078
## Arbitrary custom app data
`draft` `optional` `author:BlowaterNostr`
## Nostr event
This NIP specifies the use of event kind `1078` which is almost identical to [30078](https://github.com/nostr-protocol/nips/blob/master/78.md) except that it's not a replacible event.
### Format
#### Private Configs
Private config should be encrypted using Kind-4's algorithm and stored in `content`. Technically the plain text content can be in any format, but it's best to use a JSON format of the following shape
```
content: {
"client": "the client name, url for web client or NIP-89 identifier"
... the rest can be whatever the client author decides to be.
}
```
#### Public Configs
Similar to [NIP-78](https://github.com/BlowaterNostr/nips/blob/master/78.md#nostr-event), configs should be stored in `tags` and can be anything.
## Some use cases
The reason to not having a 30078 is that some clients want to implement local state changes as [CRDTs](https://crdt.tech/), meaning support cumulative and associative mutations
Cumulative and associative means the order of applying operations doesn't change the final result as long as the same set of operations are applied.
Using regular events can reserve the event/operation history thus the client can recompute the final state easily. [Figma uses CRDT to implement their vector design system.](https://www.figma.com/blog/how-figmas-multiplayer-technology-works/)
## Implementations
For example, in [Blowater](https://blowater.deno.dev), Pin/Unpin Contacts is implemented as regular events to achieve better consistency.
Event set [`Pin Npub X`, `Unpin NpubX`, `Pin Npub Y`] will result in a pin list of `[Y]` no matter how the order is shifted.
Many other operations are best implemented as CRDTs as well.