|
|
# Requirements
|
|
|
The Mailbox protocol assumes that all messages are encrypted and authenticated by an underlying protocol ([BTP](https://code.briarproject.org/briar/briar-spec/blob/master/protocols/BTP.md)).
|
|
|
|
|
|
# Messages
|
|
|
Mailbox messages are implemented as [BDF lists](https://code.briarproject.org/briar/briar-spec/blob/master/BDF.md) with the following format:
|
|
|
|
|
|
`[TYPE, MESSAGE_ID, BODY]`
|
|
|
|
|
|
+ **TYPE:** An `Integer` identifying the Message Type:
|
|
|
+ RESPONSE (0)
|
|
|
+ END (1)
|
|
|
+ STORE (2)
|
|
|
+ TAKE (3)
|
|
|
+ SYNC (4)
|
|
|
|
|
|
+ **MESSAGE_ID:** An `Integer` which must be unique only to **active requests**.
|
|
|
|
|
|
+ **BODY:** A `List` which is formatted depending on the message type
|
|
|
|
|
|
## Responses
|
|
|
Depending on the TYPE, a Request may have a response. Currently these responses either indicate *success* or and *error* if an error occurred.
|
|
|
|
|
|
+ **MESSAGE_ID:** The Id must match the corresponding request's Id.
|
|
|
|
|
|
+ **BODY:** May either contain a `String`, if an error occurred or `Null` id the matching request was successful.
|
|
|
|
|
|
## Requests
|
|
|
### STORE
|
|
|
A STORE request indicates that the connected peer wants to store an encrypted stream on the mailbox.
|
|
|
|
|
|
+ **RESPONSE:** yes
|
|
|
|
|
|
+ **BODY:** [CONTACT_ID, STREAM]
|
|
|
+ **CONTACT_ID:** Either `Null`, if the contact's id is identified by the connection (A contact of the owner connecting to the owner's mailbox is only allowed to store their own streams) or `Integer` to indicate for which id the stream should be stored (Used by the owner storing streams for contacts without their own mailbox)
|
|
|
|
|
|
+ **STREAM:** `Raw` containing a [BTP](https://code.briarproject.org/briar/briar-spec/blob/master/protocols/BTP.md) *stream* which contains [BSP](https://code.briarproject.org/briar/briar-spec/blob/master/protocols/BSP.md) messages.
|
|
|
|
|
|
### TAKE
|
|
|
A TAKE request indicates that the mailbox wants to pass an encrypted stream to the connected peer.
|
|
|
|
|
|
+ **RESPONSE:** yes
|
|
|
|
|
|
+ **BODY:** [STREAM]
|
|
|
+ **STREAM:** `Raw` containing a [BTP](https://code.briarproject.org/briar/briar-spec/blob/master/protocols/BTP.md) *stream* which contains [BSP](https://code.briarproject.org/briar/briar-spec/blob/master/protocols/BSP.md) messages.
|
|
|
|
|
|
### SYNC
|
|
|
SYNC requests are used to carry [BSP](https://code.briarproject.org/briar/briar-spec/blob/master/protocols/BSP.md) messages between the mailbox and the connected client.
|
|
|
|
|
|
+ **RESPONSE:** no
|
|
|
|
|
|
+ **BODY:** [STREAM]
|
|
|
+ **STREAM:** Either `Raw` containing a collection of [BSP](https://code.briarproject.org/briar/briar-spec/blob/master/protocols/BSP.md) messages or `null` to indicate an "end of stream"
|
|
|
|
|
|
|
|
|
### END
|
|
|
The END request indicates that the sending peer does not have any messages left to send and wishes to close the connection. If both peers have received an END request, the connection can be closed.
|
|
|
|
|
|
+ **RESPONSE:** no
|
|
|
+ **BODY:** No elements |
|
|
\ No newline at end of file |