|
|
@ -15,7 +15,7 @@
|
|
|
|
Room Version 3
|
|
|
|
Room Version 3
|
|
|
|
==============
|
|
|
|
==============
|
|
|
|
|
|
|
|
|
|
|
|
This room version builds off of `version 2 <v2.html>`_ with an improved event format.
|
|
|
|
This room version builds on `version 2 <v2.html>`_ with an improved event format.
|
|
|
|
|
|
|
|
|
|
|
|
.. note:
|
|
|
|
.. note:
|
|
|
|
All requirements listed in this room version specification are scoped to rooms
|
|
|
|
All requirements listed in this room version specification are scoped to rooms
|
|
|
@ -49,29 +49,32 @@ Server implementation components
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Room version 3 uses the state resolution algorithm defined in `room version 2 <v2.html>`_,
|
|
|
|
Room version 3 uses the state resolution algorithm defined in `room version 2 <v2.html>`_,
|
|
|
|
and the event format defined here. Other event formats and applicable algorithms
|
|
|
|
and the event format defined here.
|
|
|
|
may be used in other room versions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Event IDs
|
|
|
|
Event IDs
|
|
|
|
~~~~~~~~~
|
|
|
|
~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
|
|
In other room versions (namely version 1 and 2) the event ID is a distinct field
|
|
|
|
.. admonition:: Rationale
|
|
|
|
from the remainder of the event, which must be tracked as such. This leads to
|
|
|
|
|
|
|
|
complications where servers receive multiple events with the same ID in either the
|
|
|
|
|
|
|
|
same or different rooms where the server cannot easily keep track of which event it
|
|
|
|
|
|
|
|
should be using. By removing the use of a dedicated event ID, servers are required
|
|
|
|
|
|
|
|
to track the hashes on an event to determine its ID.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The event ID must be a sha256 hash of the event, encoded using `Unpadded Base64`_
|
|
|
|
In other room versions (namely version 1 and 2) the event ID is a distinct field
|
|
|
|
and prefixed with `$`. For example, an event ID might be
|
|
|
|
from the remainder of the event, which must be tracked as such. This leads to
|
|
|
|
``$CD66HAED5npg6074c6pDtLKalHjVfYb2q4Q3LZgrW6o``.
|
|
|
|
complications where servers receive multiple events with the same ID in either the
|
|
|
|
|
|
|
|
same or different rooms where the server cannot easily keep track of which event it
|
|
|
|
|
|
|
|
should be using. By removing the use of a dedicated event ID, servers are required
|
|
|
|
|
|
|
|
to track the hashes on an event to determine its ID.
|
|
|
|
|
|
|
|
|
|
|
|
The hash itself is calculated the same as previous reference hashes are:
|
|
|
|
The event ID is calculated using the following algorithm. Note that the hashing
|
|
|
|
|
|
|
|
algorithm used is the same as in previous room versions.
|
|
|
|
|
|
|
|
|
|
|
|
1. Redact the event.
|
|
|
|
1. Redact the event.
|
|
|
|
2. Remove the `signatures` field from the event.
|
|
|
|
2. Remove the `signatures` field from the event.
|
|
|
|
3. Serialize the event into `Canonical JSON`_.
|
|
|
|
3. Serialize the event into `Canonical JSON`_.
|
|
|
|
4. Compute the hash of the JSON bytes.
|
|
|
|
4. Compute the hash of the JSON bytes.
|
|
|
|
|
|
|
|
5. Encode the sha256 hash using `Unpadded Base64`_.
|
|
|
|
|
|
|
|
6. Use the resulting string as the event ID prefixed with ``$``.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A resulting event ID using this approach should look similar to
|
|
|
|
|
|
|
|
``$CD66HAED5npg6074c6pDtLKalHjVfYb2q4Q3LZgrW6o``.
|
|
|
|
|
|
|
|
|
|
|
|
Event IDs should not be sent over federation to servers when the room uses
|
|
|
|
Event IDs should not be sent over federation to servers when the room uses
|
|
|
|
this room version. On the receiving end of an event, the server should compute
|
|
|
|
this room version. On the receiving end of an event, the server should compute
|
|
|
@ -91,11 +94,10 @@ APIs which currently accept an event ID must do so with the new format. Servers
|
|
|
|
must append the calculated event ID to all events sent to clients where an event
|
|
|
|
must append the calculated event ID to all events sent to clients where an event
|
|
|
|
ID would normally be expected.
|
|
|
|
ID would normally be expected.
|
|
|
|
|
|
|
|
|
|
|
|
Because servers are not communicating the event ID over the wire to each other,
|
|
|
|
Because the format of events has changed, servers must be aware of the room version
|
|
|
|
servers must be aware of the room version where the event resides so that the
|
|
|
|
where the event resides so that the server may parse and handle the event. The
|
|
|
|
server may parse and handle the event. The federation API has taken this concern
|
|
|
|
federation API has taken this concern into consideration by ensuring that servers
|
|
|
|
into consideration by ensuring that servers are aware of (or can find) the room
|
|
|
|
are aware of (or can find) the room version during a request.
|
|
|
|
version during a request.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Authorization rules for events
|
|
|
|
Authorization rules for events
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
@ -108,9 +110,12 @@ to the change in event format:
|
|
|
|
domain.
|
|
|
|
domain.
|
|
|
|
|
|
|
|
|
|
|
|
* Previously, redactions were allowed if the sender's domain matched the domain
|
|
|
|
* Previously, redactions were allowed if the sender's domain matched the domain
|
|
|
|
in the event ID it was redacting, allowing self redaction. This check is removed
|
|
|
|
in the event ID it was redacting, allowing self redaction. Due to changes in
|
|
|
|
and redaction events are always accepted. Redaction events only take effect
|
|
|
|
the event format, this check is now impossible to do. Instead, servers should
|
|
|
|
when the original event is received, and the domain of the each event matches.
|
|
|
|
allow redactions from servers of the same origin to redact other events as a
|
|
|
|
|
|
|
|
self-redaction mechanism. The rules for allowing other servers to redact events
|
|
|
|
|
|
|
|
(as done by moderators) is unchanged. Redaction events only take effect when
|
|
|
|
|
|
|
|
the original event is received, and the domain of the each event matches.
|
|
|
|
Servers should not send redactions down to clients until the redaction has
|
|
|
|
Servers should not send redactions down to clients until the redaction has
|
|
|
|
taken effect.
|
|
|
|
taken effect.
|
|
|
|
|
|
|
|
|
|
|
|