1
0
Fork 0
mirror of https://github.com/besterprotocol/besterd synced 2023-12-13 21:00:32 +01:00
besterd/spec.md

93 lines
1.6 KiB
Markdown
Raw Normal View History

2020-04-16 14:54:53 +02:00
Bester protocol
===============
## What is bester?
Bester is a protocol for authenticated message-passing in a federated network.
## Protocol
Every message in bester contains the following:
````
2020-04-16 14:58:41 +02:00
[8 bytes - message size][JSON message]
2020-04-16 21:39:06 +02:00
````
### JSON payload
The JSON message *MUST* be a JSON object and *MUST* include
a field named `header`.
Received message:
````
"header" : {
}
````
This `header` field *MUST* contain the following fields of which
are JSON objects, `authentication`.
2020-04-16 22:55:57 +02:00
The `header` field *MUST* contain two field of which are of type
JSON string, `scope` and `type`.
2020-04-16 21:39:06 +02:00
Received message:
````
"header" : {
2020-04-16 22:55:57 +02:00
"scope" : "scope",
"type" : "type",
"authentication" : {}
2020-04-16 21:39:06 +02:00
}
````
The `authentication` field *MUST* be a JSON object and must contain
two fields `username` and `password` which *MUST* both be JSON strings.
2020-04-16 22:55:57 +02:00
The `scope` field *MUST* be a JSON string.
2020-04-16 21:39:06 +02:00
The `type` field *MUST* be a JSON string.
Received message:
````
"header" : {
2020-04-16 22:55:57 +02:00
"scope" : "scope",
"type" : "type",
2020-04-16 21:39:06 +02:00
"authentication" : {
"username" : "username",
"password" : "password"
2020-04-16 22:55:57 +02:00
}
2020-04-16 21:39:06 +02:00
}
2020-04-17 13:46:45 +02:00
````
There *MUST* also be a field in the original JSON message named `payload`,
the JSON type doesn't matter.
Received message:
````
"header" : {
"scope" : "scope",
"type" : "type",
"authentication" : {
"username" : "username",
"password" : "password"
}
},
"payload" : anything
````
## Message handling
The way messages are handled depends on their `type`. The way the server deals with it
works like this.
The server configuration looks like this:
````
"handlers" : {
"type1" : {"handlerBinary"}
}
2020-04-16 14:54:53 +02:00
````