25 lines
2.5 KiB
Markdown
25 lines
2.5 KiB
Markdown
# MEOW Protocol Spec
|
|
## Files
|
|
### Server Files
|
|
The files on the server determine the members of the homeserver, and contain a copy of all the rooms which have at least one member of that homserver. In the root directory, there is a `users` file which contains a list of users registered to the homeserver, their default name and public key, and a list of room they're in.
|
|
|
|
Each room is then a subdirectory of the root folder, containing a `members` file, a `messages` file and a `media` folder. The members file contains a list of all members of the room, with their names for that room and their public key. The messages file contains a list of all sent messages, with each message being represented by an object containing the time the message was sent, the publickey of the sender, the type of message and the content. When the message type is `text`, the content is the pgp message block, with each new line being replaced with a `\n`. When the message type is media, the content is the name of the relevant file from the media folder. The media folder contains all files send in the room, with the file names being the sha256sum of the *encrypted* file, and the extension preserved.
|
|
|
|
### Client Files
|
|
The client device should be sent copies of each room folder the user is in, and these should be kept up to date with the server.
|
|
|
|
## Transmission
|
|
The communication between server and client should be done through REST API POST requests with JSON bodies in the following format:
|
|
``` json
|
|
{
|
|
"room": "room-name",
|
|
"file": "affected-file",
|
|
"content": "diff"
|
|
}
|
|
```
|
|
Where `room-name` is the room the message was sent in, `affected file` is either `"members"` if the event is a member joining or `"messages"` if the event is a message update (either sending, editing or deleting), and `diff` is the difference between the old file and the updated file, with new line characters being replaced with `\n`. This diff should be in the format of the `diff` unix command.
|
|
|
|
When a message event is received, either by the server or the client, the releven files should be updated, and if the receiver is the server, the event should then be forwarded to other clients.
|
|
|
|
## Message format
|
|
Messages should exclusively be send and stored through pgp encryption. When being transmitted and stored, the message block should have new lines replaced with `\n`, and it should then be re-formatted for decryption. Messages should be encrypted with `gpg -ea`, with a `-r <fingerprint>` for every fingerprint listed in the members file of the relevant room. This allows the message to the be decrypted using `gpg -d`
|