diff --git a/status-group-chats-spec.md b/status-group-chats-spec.md index b8694aa..d885584 100644 --- a/status-group-chats-spec.md +++ b/status-group-chats-spec.md @@ -34,7 +34,7 @@ The format is: ``` { - "events": [], + "events": [struct {"type": string, "member": string, "members": [string], "clock-value": uint, "name": string], "signature": string, "chat-id": string } @@ -43,11 +43,12 @@ The format is: ### Chat ID Each membership update MUST be sent with a corresponding `chat-id`. -The format of this chat id MUST be a string, [UUID](https://tools.ietf.org/html/rfc4122 ), concatenated with the hex-encoded public key of the creator of the chat. This chat-id MUST be validated by all clients, and should be discarded if it does not follow these rules. +The format of this chat id MUST be a string, [UUID](https://tools.ietf.org/html/rfc4122 ), concatenated with the hex-encoded public key of the creator of the chat. This chat-id MUST be validated by all clients, and MUST be discarded if it does not follow these rules. ### Signature -The signature for each event is calculated by creating a JSON array of all the `events` sorted by `clock-value` in ascending order, where each event is transformed in an array of tuples `field-name`, `value`. The last element of the array MUST be the `chat-id`. +The signature for each event is calculated by creating a JSON array of all the `events` sorted by `clock-value` in ascending order, where each event is transformed in an array of tuples `field-name`, `value`, sorted by `field-name` in ascending alphabetical order. The last element of the array MUST be the `chat-id`. +Empty fields MUST be removed. For example the event: @@ -89,12 +90,13 @@ Results in the structure: ] ``` -This structure is then stringified and the `Keccak256` of the string is then signed using its private key by the author and added to the payload. +This structure is then stringified collapsing all whitespaces and the `Keccak256` of the string is then signed using its private key by the author and added to the payload. ### Group membership event -Any group membership event receive MUST be verified using by calculating the signature as in the method described above, and the author MUST be extracted from it, if the verification fails the event MUST be discarded. +Any group membership event received MUST be verified by calculating the signature as per the method described above. +The author MUST be extracted from it, if the verification fails the event MUST be discarded. #### chat-created @@ -137,7 +139,7 @@ If the event is valid the chat name SHOULD be changed to `name`. A members added event is used by admins to add members to the chat. Upon receiving this event a client MUST validate the `chat-id` provided with the updates and MUST ensure the author of the event is an admin of the chat, otherwise the event MUST be ignored. -If the event is valid a client SHOULD update the list of members of the chat who have not joined, adding the `members` received. +If the event is valid a client MUST update the list of members of the chat who have not joined, adding the `members` received. `members` is an array of hex encoded public keys. #### member-joined @@ -152,7 +154,7 @@ If the event is valid a client SHOULD update the list of members of the chat who A members joined event is used by a member of the chat to signal that they want to start receiving messages from this chat. Upon receiving this event a client MUST validate the `chat-id` provided with the updates and MUST ensure the author of the event is the same as the one specified by the `member` field. -If the event is valid a client SHOULD update the list of members of the chat who joined, adding `member`. Any `message` sent to the group chat should now include the newly joined member. +If the event is valid a client MUST update the list of members of the chat who joined, adding `member`. Any `message` sent to the group chat should now include the newly joined member. #### admins-added @@ -166,7 +168,7 @@ If the event is valid a client SHOULD update the list of members of the chat who An admins added event is used by admins to add make other admins in the chat. Upon receiving this event a client MUST validate the `chat-id` provided with the updates, MUST ensure the author of the event is an admin of the chat and MUST ensure all `members` are already `members` of the chat, otherwise the event MUST be ignored. -If the event is valid a client SHOULD update the list of admins of the chat, adding the `members` received. +If the event is valid a client MUST update the list of admins of the chat, adding the `members` received. `members` is an array of hex encoded public keys. #### member-removed @@ -184,7 +186,7 @@ Upon receiving this event a client MUST validate the `chat-id` provided with the - If the author of the event is an admin, target can only be themselves or a non-admin member. - If the author of the event is not an admin, the target of the event can only be themselves. - -If the event is valid a client SHOULD remove the member from the list of `members`/`admins` of the chat, and no further message should be sent to them. +If the event is valid a client MUST remove the member from the list of `members`/`admins` of the chat, and no further message should be sent to them. #### admin-removed @@ -199,4 +201,4 @@ If the event is valid a client SHOULD remove the member from the list of `member An admin-removed event is used to drop admin privileges. Upon receiving this event a client MUST validate the `chat-id` provided with the updates, MUST ensure that the author of the event is also the target of the event. -If the event is valid a client SHOULD remove the member from the list of `admins` of the chat. +If the event is valid a client MUST remove the member from the list of `admins` of the chat. diff --git a/status-payloads-spec.md b/status-payloads-spec.md index 13a3fc6..81f8ca8 100644 --- a/status-payloads-spec.md +++ b/status-payloads-spec.md @@ -90,7 +90,7 @@ Payload is a struct (a compound data type) with the following fields (order is i #### Content types -Content types are required for a proper interpretation of incoming messages. Not each message is a plain text but may carry a different information. +Content types are required for a proper interpretation of incoming messages. Not each message is plain text but may carry a different information. The following content types MUST be supported: * `text/plain` identifies a message which content is a plain text. @@ -143,18 +143,16 @@ All incoming messages can be matched against a chat. Below you can find a table ### Contact Requests -These messages are used to notify the receiving end that it has been added to the sender's contact. They are identified by the transit tags `c2`, `c3`, `c4` respectively, but they are all interchangeable, meaning a client SHOULD handle them in exactly the same way. +Contact requests consists in 3 kind of messages: `ContactRequest`, `ContactRequestConfirmed` and `ContactUpdate`. +These messages are used to notify the receiving end that it has been added to the sender's contact. They are identified by the transit tags `c2`, `c3`, `c4` respectively, but they are all interchangeable, meaning a client SHOULD handle them in exactly the same way. The payload of the 3 messages is identical. #### Payload -Payload is a struct (a compound data type) with the following fields (order is important): - - | Field | Name | Type | Description | | ----- | ---- | ---- | ---- | | 1 | name | `string` | The self-assigned name of the user (DEPRECATED) | | 2 | profile image | `string` | The base64 encoded profile picture of the user | -| 3 | address | `string` | The ethereum address of the user | +| 3 | address | `string` | The ethereum address of the user | | 4 | fcm-token | `string` | The FCM Token used by mobile devices for push notifications (DEPRECATED) | | 5 | device-info | `[struct { id string, fcm-token string }]` | A list of pair `installation-id`, `fcm-token` for each device that is currently paired | @@ -166,7 +164,7 @@ A client SHOULD send a `ContactUpdate` to all the contacts each time: - The profile image is edited - A new device has been paired -A client SHOULD also periodically send a `ContactUpdate` to all the contacts, the interval is up to the client. +A client SHOULD also periodically send a `ContactUpdate` to all the contacts, the interval is up to the client, the Status official client sends these updates every 48 hours. #### Handling contact messages @@ -179,9 +177,6 @@ A client SHOULD handle any `Contact*` message in the same way. Any `Contact*` me #### Payload -Payload is a struct (a compound data type) with the following fields (order is important): - - | Field | Name | Type | Description | | ----- | ---- | ---- | ---- | | 1| contacts | `[struct { name string last-updated int device-info struct {id string fcm-token string } pending? bool}` | An array of contacts | @@ -194,9 +189,6 @@ Payload is a struct (a compound data type) with the following fields (order is i #### Payload -Payload is a struct (a compound data type) with the following fields (order is important): - - | Field | Name | Type | Description | | ----- | ---- | ---- | ---- | | 1| installation-id | `string` | A randomly generated id that identifies this device | @@ -211,9 +203,6 @@ The details are in the [Group chats specs](status-group-chats-spec.md) #### Payload -Payload is a struct (a compound data type) with the following fields (order is important): - - | Field | Name | Type | Description | | ----- | ---- | ---- | ---- | | 1| chat-id | `string` | The chat id of the chat where the change is to take place | @@ -224,7 +213,7 @@ Payload is a struct (a compound data type) with the following fields (order is i There are two ways to upgrade the protocol without breaking compatibility: -- Map fields can be enriched with a new key, which will be ignored by old clients. +- Struct fields can be enriched with a new key, which will be ignored by old clients. - An element can be appended to the `Transit` array, which will also be ignored by old clients. ## Security Considerations