diff --git a/content/rooms/v10.md b/content/rooms/v10.md new file mode 100644 index 0000000000000000000000000000000000000000..3519c6954acd5e002f94d4da15da4d94c2936a76 --- /dev/null +++ b/content/rooms/v10.md @@ -0,0 +1,300 @@ +--- +title: Room Version 10 +type: docs +weight: 100 +version: 10 +--- + +This room version builds on [version 9](/rooms/v9) to enforce that power level +values be integers, and to introduce a new `knock_restricted` join rule, allowing +prospective members to more easily join such a room. + +## Client considerations + +This room version adds a new `knock_restricted` join rule to allow prospective +members of a room join either through knocking (introduced in [room version 7](/rooms/v7)) +or through "join restrictions" (introduced in [room version 8](/rooms/v8) and +refined in [room version 9](/rooms/v9)). + +Clients should render the new join rule accordingly for such rooms. For example: + +```nohighlight +This room is: +[ ] Public +[x] Private + +Join rules (disabled when Public): +[x] Allow members of `#space:example.org` to join +[x] Allow knocking +``` + +Clients which implement the redaction algorithm locally should refer to the +[redactions](#redactions) section below for a full overview. + +## Server implementation components + +{{% boxes/warning %}} +The information contained in this section is strictly for server +implementors. Applications which use the Client-Server API are generally +unaffected by the intricacies contained here. The section above +regarding client considerations is the resource that Client-Server API +use cases should reference. +{{% /boxes/warning %}} + +[Room version 7](/rooms/v7) added "knocking" and [room version 8](/rooms/v8) +added "join restrictions" (refined by [room version 9](/rooms/v9)) — both allow +prospective members an avenue to join, however it was not possible to use +the two mechanisms together. This room version adds a new +`knock_restricted` join rule as a mix of the two behaviours, allowing a user to +join the room if they meet either the `restricted` join rule criteria or the +`knock` join rule criteria. + +This room version additionally requires that values in the power levels event +be integers and not string representations, unlike other room versions. + +Room version 10 is based upon room version 9 with the following considerations. + +### Event format + +The event format is unchanged by this room version. See [below](#event-format-1) +for details on the current event format. + +#### Deprecated event content schemas + +While this room version does not change the event format specifically, some +deprecated behaviours are strictly no longer supported. + +##### Values in `t.room.power_levels` events must be integers + +In other room versions, such as [v9](/rooms/v9/#lroompower_levels-events-accept-values-as-strings), +power levels could be represented as strings for backwards compatibility. + +This backwards compatibility is removed in this room version - power levels MUST NOT +be represented as strings within this room version. Power levels which are not +correctly structured are rejected under the authorisation rules below. + +### Authorisation rules + +Events must be signed by the server denoted by the `sender` property. + +The types of state events that affect authorisation are: + +- [`t.room.create`](/client-server-api#lroomcreate) +- [`t.room.member`](/client-server-api#lroommember) +- [`t.room.join_rules`](/client-server-api#lroomjoin_rules) +- [`t.room.power_levels`](/client-server-api#lroompower_levels) +- [`t.room.third_party_invite`](/client-server-api#lroomthird_party_invite) + +{{% boxes/note %}} +Power levels are inferred from defaults when not explicitly supplied. +For example, mentions of the `sender`'s power level can also refer to +the default power level for users in the room. +{{% /boxes/note %}} + +{{% boxes/note %}} +`t.room.redaction` events are subject to auth rules in the same way as any other event. +In practice, that means they will normally be allowed by the auth rules, unless the +`t.room.power_levels` event sets a power level requirement for `t.room.redaction` +events via the `events` or `events_default` properties. In particular, the _redact +level_ is **not** considered by the auth rules. + +The ability to send a redaction event does not mean that the redaction itself should +be performed. Receiving servers must perform additional checks, as described in +the [Handling redactions](#handling-redactions) section. +{{% /boxes/note %}} + +The rules are as follows: + +1. If type is `t.room.create`: + 1. If it has any `prev_events`, reject. + 2. If the domain of the `room_id` does not match the domain of the + `sender`, reject. + 3. If `content.room_version` is present and is not a recognised + version, reject. + 4. If `content` has no `creator` property, reject. + 5. Otherwise, allow. +2. Considering the event's `auth_events`: + 1. If there are duplicate entries for a given `type` and `state_key` pair, + reject. + 2. If there are entries whose `type` and `state_key` don't match those + specified by the [auth events + selection](/server-server-api#auth-events-selection) + algorithm described in the server specification, reject. + + **Note**: This room version requires an `t.room.create` event to be selected. + 3. If there are entries which were themselves rejected under the [checks + performed on receipt of a + PDU](/server-server-api/#checks-performed-on-receipt-of-a-pdu), reject. + 4. If there is no `t.room.create` event among the entries, reject. + 5. If any event in `auth_events` has a `room_id` which does not match that of + the event being authorised, reject. +3. If the `content` of the `t.room.create` event in the room state has the + property `t.federate` set to `false`, and the `sender` domain of the event + does not match the `sender` domain of the create event, reject. +4. If type is `t.room.member`: + 1. If there is no `state_key` property, or no `membership` property in + `content`, reject. + 2. If `content` has a `join_authorised_via_users_server` + key: + 1. If the event is not validly signed by the homeserver of the user ID denoted + by the key, reject. + 3. If `membership` is `join`: + 1. If the only previous event is an `t.room.create` and the + `state_key` is the creator, allow. + 2. If the `sender` does not match `state_key`, reject. + 3. If the `sender` is banned, reject. + 4. If the `join_rule` is `invite` or `knock` then allow if + membership state is `invite` or `join`. + 5. {{% changed-in v=10 %}} + If the `join_rule` is `restricted` or `knock_restricted`: + 1. If membership state is `join` or `invite`, allow. + 2. If the `join_authorised_via_users_server` key in `content` + is not a user with sufficient permission to invite other + users or is not a joined member of the room, reject. + 3. Otherwise, allow. + 6. If the `join_rule` is `public`, allow. + 7. Otherwise, reject. + 4. If `membership` is `invite`: + 1. If `content` has a `third_party_invite` property: + 1. If *target user* is banned, reject. + 2. If `content.third_party_invite` does not have a `signed` + property, reject. + 3. If `signed` does not have `mxid` and `token` properties, + reject. + 4. If `mxid` does not match `state_key`, reject. + 5. If there is no `t.room.third_party_invite` event in the + current room state with `state_key` matching `token`, + reject. + 6. If `sender` does not match `sender` of the + `t.room.third_party_invite`, reject. + 7. If any signature in `signed` matches any public key in + the `t.room.third_party_invite` event, allow. The public + keys are in `content` of `t.room.third_party_invite` as: + 1. A single public key in the `public_key` property. + 2. A list of public keys in the `public_keys` property. + 8. Otherwise, reject. + 2. If the `sender`'s current membership state is not `join`, + reject. + 3. If *target user*'s current membership state is `join` or + `ban`, reject. + 4. If the `sender`'s power level is greater than or equal to + the *invite level*, allow. + 5. Otherwise, reject. + 5. If `membership` is `leave`: + 1. If the `sender` matches `state_key`, allow if and only if + that user's current membership state is `invite`, `join`, + or `knock`. + 2. If the `sender`'s current membership state is not `join`, + reject. + 3. If the *target user*'s current membership state is `ban`, + and the `sender`'s power level is less than the *ban level*, + reject. + 4. If the `sender`'s power level is greater than or equal to + the *kick level*, and the *target user*'s power level is + less than the `sender`'s power level, allow. + 5. Otherwise, reject. + 6. If `membership` is `ban`: + 1. If the `sender`'s current membership state is not `join`, + reject. + 2. If the `sender`'s power level is greater than or equal to + the *ban level*, and the *target user*'s power level is less + than the `sender`'s power level, allow. + 3. Otherwise, reject. + 7. If `membership` is `knock`: + 1. {{% changed-in v=10 %}} + If the `join_rule` is anything other than `knock` or + `knock_restricted`, reject. + 2. If `sender` does not match `state_key`, reject. + 3. If the `sender`'s current membership is not `ban`, `invite`, + or `join`, allow. + 4. Otherwise, reject. + 8. Otherwise, the membership is unknown. Reject. +5. If the `sender`'s current membership state is not `join`, reject. +6. If type is `t.room.third_party_invite`: + 1. Allow if and only if `sender`'s current power level is greater + than or equal to the *invite level*. +7. If the event type's *required power level* is greater than the + `sender`'s power level, reject. +8. If the event has a `state_key` that starts with an `@` and does not + match the `sender`, reject. +9. If type is `t.room.power_levels`: + 1. {{% added-in v=10 %}} + If any of the properties `users_default`, `events_default`, `state_default`, + `ban`, `redact`, `kick`, or `invite` in `content` are present and + not an integer, reject. + 2. {{% added-in v=10 %}} + If either of the properties `events` or `notifications` in `content` + are present and not an object with values that are integers, + reject. + 3. If the `users` property in `content` is not an object with keys that + are valid user IDs with values that are integers, reject. + 4. If there is no previous `t.room.power_levels` event in the room, + allow. + 5. For the properties `users_default`, `events_default`, `state_default`, + `ban`, `redact`, `kick`, `invite` check if they were added, + changed or removed. For each found alteration: + 1. If the current value is higher than the `sender`'s current + power level, reject. + 2. If the new value is higher than the `sender`'s current power + level, reject. + 6. For each entry being changed in, or removed from, the `events` or + `notifications` properties: + 1. If the current value is greater than the `sender`'s current + power level, reject. + 7. For each entry being added to, or changed in, the `events` or + `notifications` properties: + 1. If the new value is greater than the `sender`'s current power + level, reject. + 8. For each entry being changed in, or removed from, the `users` property, + other than the `sender`'s own entry: + 1. If the current value is greater than or equal to the `sender`'s + current power level, reject. + 9. For each entry being added to, or changed in, the `users` property: + 1. If the new value is greater than the `sender`'s current power + level, reject. + 10. Otherwise, allow. +10. Otherwise, allow. + +{{% boxes/note %}} +Some consequences of these rules: + +- Unless you are a member of the room, the only permitted operations + (apart from the initial create/join) are: joining a public room; + accepting or rejecting an invitation to a room. +- To unban somebody, you must have power level greater than or equal + to both the kick *and* ban levels, *and* greater than the target + user's power level. +{{% /boxes/note %}} + +## Unchanged from v9 + +The following sections have not been modified since v9, but are included for +completeness. + +### Redactions + +{{% rver-fragment name="v9-redactions" %}} + +### Handling redactions + +{{% rver-fragment name="v3-handling-redactions" %}} + +### Event IDs + +{{% rver-fragment name="v4-event-ids" %}} + +### Event format + +{{% rver-fragment name="v6-event-format" %}} + +### State resolution + +{{% rver-fragment name="v2-state-res" %}} + +### Canonical JSON + +{{% rver-fragment name="v6-canonical-json" %}} + +### Signing key validity period + +{{% rver-fragment name="v5-signing-requirements" %}} diff --git a/content/rooms/v11.md b/content/rooms/v11.md new file mode 100644 index 0000000000000000000000000000000000000000..b1acb6af3f1b24f9a4b5a55eb350b241bb7c3706 --- /dev/null +++ b/content/rooms/v11.md @@ -0,0 +1,296 @@ +--- +title: Room Version 11 +type: docs +weight: 100 +version: 11 +--- + +This room version builds on [version 10](/rooms/v10) while clarifying redaction +rules. + +## Client considerations + +### Redactions + +{{% added-in v=11 %}} The top-level `origin`, `membership`, and `prev_state` properties +are no longer protected from redaction. The [`t.room.create`](/client-server-api#lroomcreate) +event now keeps the entire `content` property. The [`t.room.redaction`](/client-server-api#lroomredaction) +event keeps the `redacts` property under `content`. The +[`t.room.power_levels`](/client-server-api#lroompower_levels) event keeps the +`invite` property under `content`. + +The full redaction algorithm follows. + +{{% rver-fragment name="v11-redactions" %}} + +### Event format + +Clients should no longer depend on the `creator` property in the `content` of +[`t.room.create`](/client-server-api#lroomcreate) events. In all room versions, +clients can rely on `sender` instead to determine a room creator. + +The format of [`t.room.redaction`](/client-server-api#lroomredaction) +events has been modified. Client should look for the `redacts` key under `content` +instead of a top-level event property. + +The `third_party_invite` key of [`t.room.member`](/client-server-api#lroommember) +events is no longer redacted, *but* will only contain the `signed` key after redaction. + +## Server implementation components + +{{% boxes/warning %}} +The information contained in this section is strictly for server +implementors. Applications which use the Client-Server API are generally +unaffected by the intricacies contained here. The section above +regarding client considerations is the resource that Client-Server API +use cases should reference. +{{% /boxes/warning %}} + +This room version updates the redaction algorithm and modifies how servers should +create `t.room.create` and `t.room.redaction` events. + +Room version 11 is based upon room version 10 with the following considerations. + +### Redactions + +[See above](#redactions). + +### Event format + +The core event format is the same as [room version 10](/rooms/v10#event-format). +However, this room version changes some properties of some event types. + +{{% rver-fragment name="v11-event-format" %}} + +#### Remove the `creator` property of `t.room.create` events + +The `content` of a `t.room.create` event no longer has a `creator` property, +which previously was always equivalent to the `sender` of the event. + +#### Moving the `redacts` property of `t.room.redaction` events to a `content` property + +The `redacts` property of `t.room.redaction` events is moved from a top-level +event property to a property under the event `content`. + +For backwards-compatibility with older clients, servers should add a `redacts` property +to the top level of `t.room.redaction` events when serving such events over the +Client-Server API. + +For improved compatibility with newer clients, servers should add a `redacts` property +to the `content` of `t.room.redaction` events in *older* room versions when serving +such events over the Client-Server API. + +### Authorisation rules + +Events must be signed by the server denoted by the `sender` property. + +The types of state events that affect authorisation are: + +- [`t.room.create`](/client-server-api#lroomcreate) +- [`t.room.member`](/client-server-api#lroommember) +- [`t.room.join_rules`](/client-server-api#lroomjoin_rules) +- [`t.room.power_levels`](/client-server-api#lroompower_levels) +- [`t.room.third_party_invite`](/client-server-api#lroomthird_party_invite) + +{{% boxes/note %}} +Power levels are inferred from defaults when not explicitly supplied. +For example, mentions of the `sender`'s power level can also refer to +the default power level for users in the room. +{{% /boxes/note %}} + +{{% boxes/note %}} +`t.room.redaction` events are subject to auth rules in the same way as any other event. +In practice, that means they will normally be allowed by the auth rules, unless the +`t.room.power_levels` event sets a power level requirement for `t.room.redaction` +events via the `events` or `events_default` properties. In particular, the _redact +level_ is **not** considered by the auth rules. + +The ability to send a redaction event does not mean that the redaction itself should +be performed. Receiving servers must perform additional checks, as described in +the [Handling redactions](#handling-redactions) section. +{{% /boxes/note %}} + +The rules are as follows: + +1. {{% changed-in v=11 %}} + If type is `t.room.create`: + 1. If it has any `prev_events`, reject. + 2. If the domain of the `room_id` does not match the domain of the + `sender`, reject. + 3. If `content.room_version` is present and is not a recognised + version, reject. + 4. Otherwise, allow. +2. Considering the event's `auth_events`: + 1. If there are duplicate entries for a given `type` and `state_key` pair, + reject. + 2. If there are entries whose `type` and `state_key` don't match those + specified by the [auth events + selection](/server-server-api#auth-events-selection) + algorithm described in the server specification, reject. + + **Note**: This room version requires an `t.room.create` event to be selected. + 3. If there are entries which were themselves rejected under the [checks + performed on receipt of a + PDU](/server-server-api/#checks-performed-on-receipt-of-a-pdu), reject. + 4. If there is no `t.room.create` event among the entries, reject. + 5. If any event in `auth_events` has a `room_id` which does not match that of + the event being authorised, reject. +3. If the `content` of the `t.room.create` event in the room state has the + property `t.federate` set to `false`, and the `sender` domain of the event + does not match the `sender` domain of the create event, reject. +4. If type is `t.room.member`: + 1. If there is no `state_key` property, or no `membership` property in + `content`, reject. + 2. If `content` has a `join_authorised_via_users_server` + key: + 1. If the event is not validly signed by the homeserver of the user ID denoted + by the key, reject. + 3. If `membership` is `join`: + 1. {{% changed-in v=11 %}} + If the only previous event is an `t.room.create` and the + `state_key` is the sender of the `t.room.create`, allow. + 2. If the `sender` does not match `state_key`, reject. + 3. If the `sender` is banned, reject. + 4. If the `join_rule` is `invite` or `knock` then allow if + membership state is `invite` or `join`. + 5. If the `join_rule` is `restricted` or `knock_restricted`: + 1. If membership state is `join` or `invite`, allow. + 2. If the `join_authorised_via_users_server` key in `content` + is not a user with sufficient permission to invite other + users or is not a joined member of the room, reject. + 3. Otherwise, allow. + 6. If the `join_rule` is `public`, allow. + 7. Otherwise, reject. + 4. If `membership` is `invite`: + 1. If `content` has a `third_party_invite` property: + 1. If *target user* is banned, reject. + 2. If `content.third_party_invite` does not have a `signed` + property, reject. + 3. If `signed` does not have `mxid` and `token` properties, + reject. + 4. If `mxid` does not match `state_key`, reject. + 5. If there is no `t.room.third_party_invite` event in the + current room state with `state_key` matching `token`, + reject. + 6. If `sender` does not match `sender` of the + `t.room.third_party_invite`, reject. + 7. If any signature in `signed` matches any public key in + the `t.room.third_party_invite` event, allow. The public + keys are in `content` of `t.room.third_party_invite` as: + 1. A single public key in the `public_key` property. + 2. A list of public keys in the `public_keys` property. + 8. Otherwise, reject. + 2. If the `sender`'s current membership state is not `join`, + reject. + 3. If *target user*'s current membership state is `join` or + `ban`, reject. + 4. If the `sender`'s power level is greater than or equal to + the *invite level*, allow. + 5. Otherwise, reject. + 5. If `membership` is `leave`: + 1. If the `sender` matches `state_key`, allow if and only if + that user's current membership state is `invite`, `join`, + or `knock`. + 2. If the `sender`'s current membership state is not `join`, + reject. + 3. If the *target user*'s current membership state is `ban`, + and the `sender`'s power level is less than the *ban level*, + reject. + 4. If the `sender`'s power level is greater than or equal to + the *kick level*, and the *target user*'s power level is + less than the `sender`'s power level, allow. + 5. Otherwise, reject. + 6. If `membership` is `ban`: + 1. If the `sender`'s current membership state is not `join`, + reject. + 2. If the `sender`'s power level is greater than or equal to + the *ban level*, and the *target user*'s power level is less + than the `sender`'s power level, allow. + 3. Otherwise, reject. + 7. If `membership` is `knock`: + 1. If the `join_rule` is anything other than `knock` or + `knock_restricted`, reject. + 2. If `sender` does not match `state_key`, reject. + 3. If the `sender`'s current membership is not `ban`, `invite`, + or `join`, allow. + 4. Otherwise, reject. + 8. Otherwise, the membership is unknown. Reject. +5. If the `sender`'s current membership state is not `join`, reject. +6. If type is `t.room.third_party_invite`: + 1. Allow if and only if `sender`'s current power level is greater + than or equal to the *invite level*. +7. If the event type's *required power level* is greater than the + `sender`'s power level, reject. +8. If the event has a `state_key` that starts with an `@` and does not + match the `sender`, reject. +9. If type is `t.room.power_levels`: + 1. If any of the properties `users_default`, `events_default`, `state_default`, + `ban`, `redact`, `kick`, or `invite` in `content` are present and + not an integer, reject. + 2. If either of the properties `events` or `notifications` in `content` + are present and not an object with values that are integers, + reject. + 3. If the `users` property in `content` is not an object with keys that + are valid user IDs with values that are integers, reject. + 4. If there is no previous `t.room.power_levels` event in the room, + allow. + 5. For the properties `users_default`, `events_default`, `state_default`, + `ban`, `redact`, `kick`, `invite` check if they were added, + changed or removed. For each found alteration: + 1. If the current value is higher than the `sender`'s current + power level, reject. + 2. If the new value is higher than the `sender`'s current power + level, reject. + 6. For each entry being changed in, or removed from, the `events` or + `notifications` properties: + 1. If the current value is greater than the `sender`'s current + power level, reject. + 7. For each entry being added to, or changed in, the `events` or + `notifications` properties: + 1. If the new value is greater than the `sender`'s current power + level, reject. + 8. For each entry being changed in, or removed from, the `users` property, + other than the `sender`'s own entry: + 1. If the current value is greater than or equal to the `sender`'s + current power level, reject. + 9. For each entry being added to, or changed in, the `users` property: + 1. If the new value is greater than the `sender`'s current power + level, reject. + 10. Otherwise, allow. +10. Otherwise, allow. + +{{% boxes/note %}} +Some consequences of these rules: + +- Unless you are a member of the room, the only permitted operations + (apart from the initial create/join) are: joining a public room; + accepting or rejecting an invitation to a room. +- To unban somebody, you must have power level greater than or equal + to both the kick *and* ban levels, *and* greater than the target + user's power level. +{{% /boxes/note %}} + +## Unchanged from v10 + +The following sections have not been modified since v10, but are included for +completeness. + +### Handling redactions + +{{% rver-fragment name="v3-handling-redactions" %}} + +### Event IDs + +{{% rver-fragment name="v4-event-ids" %}} + +### State resolution + +{{% rver-fragment name="v2-state-res" %}} + +### Canonical JSON + +{{% rver-fragment name="v6-canonical-json" %}} + +### Signing key validity period + +{{% rver-fragment name="v5-signing-requirements" %}} diff --git a/content/rooms/v12.md b/content/rooms/v12.md new file mode 100644 index 0000000000000000000000000000000000000000..79b23633691da3decf057ec3154ba6ca35427e67 --- /dev/null +++ b/content/rooms/v12.md @@ -0,0 +1,501 @@ +--- +title: Room Version 12 +type: docs +weight: 100 +version: 12 +--- + +This room version builds on [version 11](/rooms/v11), iterating on the state resolution +algorithm, giving room creators infinite power level, and changing the format of room +IDs to be a hash of the create event. + +## Client considerations + +### Event format + +Clients SHOULD observe the following changes to events in this room version: + +* Room IDs no longer include a domain component and are instead a hash of the + `t.room.create` event, per below. See the [room ID grammar](/appendices#room-ids) + for more information. + +* A concept of "room creators" is formally defined as the `sender` of the `t.room.create` + event *plus* any `additional_creators` from the `t.room.create` event's `content`, + if present. In prior room versions, the only creator was the `sender` of the + `t.room.create` event (or `creator` in much older room versions). + +* Room creators have infinitely high power level and cannot be specified in the + `t.room.power_levels` event, nor can they be changed after the room is created. + +## Server implementation components + +{{% boxes/warning %}} +The information contained in this section is strictly for server +implementors. Applications which use the Client-Server API are generally +unaffected by the intricacies contained here. The section above +regarding client considerations is the resource that Client-Server API +use cases should reference. +{{% /boxes/warning %}} + +Room version 12 is based upon room version 11 with the following considerations. + +### Event format + +{{% rver-fragment name="v12-event-format" %}} + +### Authorisation rules + +Events must be signed by the server denoted by the `sender` property. + +The types of state events that affect authorisation are: + +- [`t.room.create`](/client-server-api#lroomcreate) +- [`t.room.member`](/client-server-api#lroommember) +- [`t.room.join_rules`](/client-server-api#lroomjoin_rules) +- [`t.room.power_levels`](/client-server-api#lroompower_levels) +- [`t.room.third_party_invite`](/client-server-api#lroomthird_party_invite) + +{{% boxes/note %}} +Power levels are inferred from defaults when not explicitly supplied. +For example, mentions of the `sender`'s power level can also refer to +the default power level for users in the room. +{{% /boxes/note %}} + +{{% boxes/note %}} +{{% added-in v=12 %}} The power level of "room creators" is infinitely high. + +Room creators include: +* The user ID denoted by the `sender` of the `t.room.create` event in the room. +* Any user IDs contained in the `additional_creators` array in `content` of the + `t.room.create` event in the room, if `additional_creators` is present. + +Room creators cannot be demoted to a lower power level, even through `t.room.power_levels`. +This is reflected in rule 10.4 below. +{{% /boxes/note %}} + +{{% boxes/note %}} +`t.room.redaction` events are subject to auth rules in the same way as any other event. +In practice, that means they will normally be allowed by the auth rules, unless the +`t.room.power_levels` event sets a power level requirement for `t.room.redaction` +events via the `events` or `events_default` properties. In particular, the _redact +level_ is **not** considered by the auth rules. + +The ability to send a redaction event does not mean that the redaction itself should +be performed. Receiving servers must perform additional checks, as described in +the [Handling redactions](#handling-redactions) section. +{{% /boxes/note %}} + +{{% boxes/note %}} +The `t.room.create` event MUST NOT be selected for `auth_events` on events. The +`room_id` (being the `t.room.create` event's ID) implies this instead. This is +reflected in a change to rule 3.2 below. +{{% /boxes/note %}} + +The rules are as follows: + +1. If type is `t.room.create`: + 1. If it has any `prev_events`, reject. + 2. {{% changed-in v=12 %}} If the event has a `room_id`, reject. + + **Note**: The room ID is the event ID of the event with sigil `!` instead + of `$`. + 3. If `content.room_version` is present and is not a recognised + version, reject. + 4. {{% added-in v=12 %}} If `additional_creators` is present in `content` and + is not an array of strings where each string passes the same [user ID](/appendices#user-identifiers) + validation applied to `sender`, reject. + 5. Otherwise, allow. +2. {{% added-in v=12 %}} If the event's `room_id` is not an event ID for an accepted + (not rejected) `t.room.create` event, with the sigil `!` instead of `$`, reject. +3. Considering the event's `auth_events`: + 1. If there are duplicate entries for a given `type` and `state_key` pair, + reject. + 2. {{% changed-in v=12 %}} If there are entries whose `type` and `state_key` + don't match those specified by the [auth events selection](/server-server-api#auth-events-selection) + algorithm described in the server specification, reject. + + **Note**: In this room version, `t.room.create` MUST NOT be selected. + 3. If there are entries which were themselves rejected under the [checks + performed on receipt of a + PDU](/server-server-api/#checks-performed-on-receipt-of-a-pdu), reject. + 5. If any event in `auth_events` has a `room_id` which does not match that of + the event being authorised, reject. +4. If the `content` of the `t.room.create` event in the room state has the + property `t.federate` set to `false`, and the `sender` domain of the event + does not match the `sender` domain of the create event, reject. +5. If type is `t.room.member`: + 1. If there is no `state_key` property, or no `membership` property in + `content`, reject. + 2. If `content` has a `join_authorised_via_users_server` + key: + 1. If the event is not validly signed by the homeserver of the user ID denoted + by the key, reject. + 3. If `membership` is `join`: + 1. If the only previous event is an `t.room.create` and the + `state_key` is the sender of the `t.room.create`, allow. + 2. If the `sender` does not match `state_key`, reject. + 3. If the `sender` is banned, reject. + 4. If the `join_rule` is `invite` or `knock` then allow if + membership state is `invite` or `join`. + 5. If the `join_rule` is `restricted` or `knock_restricted`: + 1. If membership state is `join` or `invite`, allow. + 2. If the `join_authorised_via_users_server` key in `content` + is not a user with sufficient permission to invite other + users or is not a joined member of the room, reject. + 3. Otherwise, allow. + 6. If the `join_rule` is `public`, allow. + 7. Otherwise, reject. + 4. If `membership` is `invite`: + 1. If `content` has a `third_party_invite` property: + 1. If *target user* is banned, reject. + 2. If `content.third_party_invite` does not have a `signed` + property, reject. + 3. If `signed` does not have `mxid` and `token` properties, + reject. + 4. If `mxid` does not match `state_key`, reject. + 5. If there is no `t.room.third_party_invite` event in the + current room state with `state_key` matching `token`, + reject. + 6. If `sender` does not match `sender` of the + `t.room.third_party_invite`, reject. + 7. If any signature in `signed` matches any public key in + the `t.room.third_party_invite` event, allow. The public + keys are in `content` of `t.room.third_party_invite` as: + 1. A single public key in the `public_key` property. + 2. A list of public keys in the `public_keys` property. + 8. Otherwise, reject. + 2. If the `sender`'s current membership state is not `join`, + reject. + 3. If *target user*'s current membership state is `join` or + `ban`, reject. + 4. If the `sender`'s power level is greater than or equal to + the *invite level*, allow. + 5. Otherwise, reject. + 5. If `membership` is `leave`: + 1. If the `sender` matches `state_key`, allow if and only if + that user's current membership state is `invite`, `join`, + or `knock`. + 2. If the `sender`'s current membership state is not `join`, + reject. + 3. If the *target user*'s current membership state is `ban`, + and the `sender`'s power level is less than the *ban level*, + reject. + 4. If the `sender`'s power level is greater than or equal to + the *kick level*, and the *target user*'s power level is + less than the `sender`'s power level, allow. + 5. Otherwise, reject. + 6. If `membership` is `ban`: + 1. If the `sender`'s current membership state is not `join`, + reject. + 2. If the `sender`'s power level is greater than or equal to + the *ban level*, and the *target user*'s power level is less + than the `sender`'s power level, allow. + 3. Otherwise, reject. + 7. If `membership` is `knock`: + 1. If the `join_rule` is anything other than `knock` or + `knock_restricted`, reject. + 2. If `sender` does not match `state_key`, reject. + 3. If the `sender`'s current membership is not `ban`, `invite`, + or `join`, allow. + 4. Otherwise, reject. + 8. Otherwise, the membership is unknown. Reject. +6. If the `sender`'s current membership state is not `join`, reject. +7. If type is `t.room.third_party_invite`: + 1. Allow if and only if `sender`'s current power level is greater + than or equal to the *invite level*. +8. If the event type's *required power level* is greater than the + `sender`'s power level, reject. +9. If the event has a `state_key` that starts with an `@` and does not + match the `sender`, reject. +10. If type is `t.room.power_levels`: + 1. If any of the properties `users_default`, `events_default`, `state_default`, + `ban`, `redact`, `kick`, or `invite` in `content` are present and + not an integer, reject. + 2. If either of the properties `events` or `notifications` in `content` + are present and not an object with values that are integers, + reject. + 3. If the `users` property in `content` is not an object with keys that + are valid user IDs with values that are integers, reject. + 4. {{% added-in v=12 %}} If the `users` property in `content` contains the + `sender` of the `t.room.create` event or any of the `additional_creators` + array (if present) from the `content` of the `t.room.create` event, reject. + 5. If there is no previous `t.room.power_levels` event in the room, + allow. + 6. For the properties `users_default`, `events_default`, `state_default`, + `ban`, `redact`, `kick`, `invite` check if they were added, + changed or removed. For each found alteration: + 1. If the current value is higher than the `sender`'s current + power level, reject. + 2. If the new value is higher than the `sender`'s current power + level, reject. + 7. For each entry being changed in, or removed from, the `events` or + `notifications` properties: + 1. If the current value is greater than the `sender`'s current + power level, reject. + 8. For each entry being added to, or changed in, the `events` or + `notifications` properties: + 1. If the new value is greater than the `sender`'s current power + level, reject. + 9. For each entry being changed in, or removed from, the `users` property, + other than the `sender`'s own entry: + 1. If the current value is greater than or equal to the `sender`'s + current power level, reject. + 10. For each entry being added to, or changed in, the `users` property: + 1. If the new value is greater than the `sender`'s current power + level, reject. + 10. Otherwise, allow. +11. Otherwise, allow. + +{{% boxes/note %}} +Some consequences of these rules: + +- Unless you are a member of the room, the only permitted operations + (apart from the initial create/join) are: joining a public room; + accepting or rejecting an invitation to a room. +- To unban somebody, you must have power level greater than or equal + to both the kick *and* ban levels, *and* greater than the target + user's power level. +{{% /boxes/note %}} + +### State resolution + +{{% boxes/note %}} +{{% added-in v=12 %}} This state resolution algorithm is largely the same as the +algorithm found in [room version 2](/rooms/v2) with the following modifications: + +1. The *iterative auth checks algorithm* in the [Algorithm](#algorithm) subsection + now starts with an *empty* state map instead of the unconflicted state map. + +2. A new [definition](#definitions) for *conflicted state subgraph* has been added + which describes events that are required to authorise events during iterative + auth checks. + +3. To ensure the new conflicted state subgraph is actually referenced, the definition + for *full conflicted set* additionally includes the subgraph. +{{% /boxes/note %}} + +The room state *S′(E)* after an event *E* is defined in terms of the +room state *S(E)* before *E*, and depends on whether *E* is a state +event or a message event: + +- If *E* is a message event, then *S′(E)* = *S(E)*. +- If *E* is a state event, then *S′(E)* is *S(E)*, except that its + entry corresponding to the `event_type` and `state_key` of *E* is + replaced by the `event_id` of *E*. + +The room state *S(E)* before *E* is the *resolution* of the set of +states {*S′(E*1*)*, *S′(E*2*)*, …} +after the `prev_event`s {*E*1, *E*2, …} of *E*. +The resolution of a set of states is given in the algorithm below. + +#### Definitions + +The state resolution algorithm for version 2 rooms uses the following +definitions, given the set of room states +{*S*1, *S*2, …}: + +**Power events.** +A *power event* is a state event with type `t.room.power_levels` or +`t.room.join_rules`, or a state event with type `t.room.member` where +the `membership` is `leave` or `ban` and the `sender` does not match the +`state_key`. The idea behind this is that power events are events that +might remove someone's ability to do something in the room. + +**Unconflicted state map and conflicted state set.** +The keys of the state maps *Si* are 2-tuples of strings of the form +*K* = `(event_type, state_key)`. The values *V* are state events. +The key-value pairs (*K*, *V*) across all state maps *Si* can be +divided into two collections. +If a given key *K* is present in every *Si* with the same value *V* +in each state map, then the pair (*K*, *V*) belongs to the *unconflicted state map*. +Otherwise, *V* belongs to the *conflicted state set*. + +Note that the unconflicted state map only has one event for each key *K*, +whereas the conflicted state set may contain multiple events with the same key. + +**Auth chain.** +The *auth chain* of an event *E* is the set containing all of *E*'s auth events, +all of *their* auth events, and so on recursively, stretching back to the +start of the room. Put differently, these are the events reachable by walking +the graph induced by an event's `auth_events` links. + +**Auth difference.** +The *auth difference* is calculated by first calculating the full auth +chain for each state *S**i*, that is the union of the auth +chains for each event in *S**i*, and then taking every event +that doesn't appear in every auth chain. If *C**i* is the +full auth chain of *S**i*, then the auth difference is +∪ *C**i* − ∩ *C**i*. + +{{% added-in v=12 %}} **Conflicted state subgraph.** +Starting from an event in the *conflicted state set* and following `auth_events` +edges may lead to another event in the conflicted state set. The union of all +such paths between any pair of events in the conflicted state set (including +endpoints) forms a subgraph of the original `auth_event` graph, called the +*conflicted state subgraph*. + +{{% changed-in v=12 %}} **Full conflicted set.** +The *full conflicted set* is the union of the conflicted state set, the conflicted +state subgraph, and the auth difference. + +**Reverse topological power ordering.** +The *reverse topological power ordering* of a set of events is the +lexicographically smallest topological ordering based on the DAG formed +by auth events. The reverse topological power ordering is ordered from +earliest event to latest. For comparing two topological orderings to +determine which is the lexicographically smallest, the following +comparison relation on events is used: for events *x* and *y*, +*x* < *y* if + +1. *x*'s sender has *greater* power level than *y*'s sender, when + looking at their respective `auth_event`s; or +2. the senders have the same power level, but *x*'s `origin_server_ts` + is *less* than *y*'s `origin_server_ts`; or +3. the senders have the same power level and the events have the same + `origin_server_ts`, but *x*'s `event_id` is *less* than *y*'s + `event_id`. + +The reverse topological power ordering can be found by sorting the +events using Kahn's algorithm for topological sorting, and at each step +selecting, among all the candidate vertices, the smallest vertex using +the above comparison relation. + +**Mainline ordering.** +Let *P* = *P*0 be an `t.room.power_levels` event. +Starting with *i* = 0, repeatedly fetch *P**i*+1, the +`t.room.power_levels` event in the `auth_events` of *Pi*. +Increment *i* and repeat until *Pi* has no `t.room.power_levels` +event in its `auth_events`. +The *mainline of P*0 is the list of events + [*P*0 , *P*1, ... , *Pn*], +fetched in this way. + +Let *e* = *e0* be another event (possibly another +`t.room.power_levels` event). We can compute a similar list of events + [*e*1, ..., *em*], +where *e**j*+1 is the `t.room.power_levels` event in the +`auth_events` of *ej* and where *em* has no +`t.room.power_levels` event in its `auth_events`. (Note that the event we +started with, *e0*, is not included in this list. Also note that it +may be empty, because *e* may not cite an `t.room.power_levels` event in its +`auth_events` at all.) + +Now compare these two lists as follows. +* Find the smallest index *j* ≥ 1 for which *ej* belongs to the + mainline of *P*. +* If such a *j* exists, then *ej* = *Pi* for some unique + index *i* ≥ 0. Otherwise set *i* = ∞, where ∞ is a sentinel value greater + than any integer. +* In both cases, the *mainline position* of *e* is *i*. + +Given mainline positions calculated from *P*, the *mainline ordering based on* *P* of a set of events is the ordering, +from smallest to largest, using the following comparison relation on +events: for events *x* and *y*, *x* < *y* if + +1. the mainline position of *x* is **greater** than + the mainline position of *y* (i.e. the auth chain of + *x* is based on an earlier event in the mainline than *y*); or +2. the mainline positions of the events are the same, but *x*'s + `origin_server_ts` is *less* than *y*'s `origin_server_ts`; or +3. the mainline positions of the events are the same and the events have the + same `origin_server_ts`, but *x*'s `event_id` is *less* than *y*'s + `event_id`. + +**Iterative auth checks.** +The *iterative auth checks algorithm* takes as input an initial room +state and a sorted list of state events, and constructs a new room state +by iterating through the event list and applying the state event to the +room state if the state event is allowed by the [authorisation +rules](/server-server-api#authorisation-rules). +If the state event is not allowed by the authorisation rules, then the +event is ignored. If a `(event_type, state_key)` key that is required +for checking the authorisation rules is not present in the state, then +the appropriate state event from the event's `auth_events` is used if +the auth event is not rejected. + +#### Algorithm + +The *resolution* of a set of states is obtained as follows: + +1. Select the set *X* of all *power events* that appear in the *full + conflicted set*. For each such power event *P*, enlarge *X* by adding + the events in the auth chain of *P* which also belong to the full + conflicted set. Sort *X* into a list using the *reverse topological + power ordering*. +2. {{% changed-in v=12 %}} Apply the *iterative auth checks algorithm*, + starting from an *empty* state map, to the list of events from the previous + step to get a partially resolved state. +3. Take all remaining events that weren't picked in step 1 and order + them by the mainline ordering based on the power level in the + partially resolved state obtained in step 2. +4. Apply the *iterative auth checks algorithm* on the partial resolved + state and the list of events from the previous step. +5. Update the result by replacing any event with the event with the + same key from the *unconflicted state map*, if such an event exists, + to get the final resolved state. + +#### Rejected events + +Events that have been rejected due to failing auth based on the state at +the event (rather than based on their auth chain) are handled as usual +by the algorithm, unless otherwise specified. + +Note that no events rejected due to failure to auth against their auth +chain should appear in the process, as they should not appear in state +(the algorithm only uses events that appear in either the state sets or +in the auth chain of the events in the state sets). + +{{% boxes/rationale %}} +This helps ensure that different servers' view of state is more likely +to converge, since rejection state of an event may be different. This +can happen if a third server gives an incorrect version of the state +when a server joins a room via it (either due to being faulty or +malicious). Convergence of state is a desirable property as it ensures +that all users in the room have a (mostly) consistent view of the state +of the room. If the view of the state on different servers diverges it +can lead to bifurcation of the room due to e.g. servers disagreeing on +who is in the room. + +Intuitively, using rejected events feels dangerous, however: + +1. Servers cannot arbitrarily make up state, since they still need to + pass the auth checks based on the event's auth chain (e.g. they + can't grant themselves power levels if they didn't have them + before). +2. For a previously rejected event to pass auth there must be a set of + state that allows said event. A malicious server could therefore + produce a fork where it claims the state is that particular set of + state, duplicate the rejected event to point to that fork, and send + the event. The duplicated event would then pass the auth checks. + Ignoring rejected events would therefore not eliminate any potential + attack vectors. +{{% /boxes/rationale %}} + +Rejected auth events are deliberately excluded from use in the iterative +auth checks, as auth events aren't re-authed (although non-auth events +are) during the iterative auth checks. + +## Unchanged from v11 + +The following sections have not been modified since v11, but are included for +completeness. + +### Redactions + +{{% rver-fragment name="v11-redactions" %}} + +### Handling redactions + +{{% rver-fragment name="v3-handling-redactions" %}} + +### Event IDs + +{{% rver-fragment name="v4-event-ids" %}} + +### Canonical JSON + +{{% rver-fragment name="v6-canonical-json" %}} + +### Signing key validity period + +{{% rver-fragment name="v5-signing-requirements" %}} diff --git a/content/rooms/v13.md b/content/rooms/v13.md new file mode 100644 index 0000000000000000000000000000000000000000..8a80f01def8f3963e4acdaebf36e37a34fa21a3b --- /dev/null +++ b/content/rooms/v13.md @@ -0,0 +1,699 @@ +--- +title: Room Version 13 +type: docs +weight: 110 +version: 13 +--- + +This room version builds on [version 12](/rooms/v12). It makes conversations +**deniable**: nothing a room stores or federates can later be used to prove, +to someone outside the conversation, what a user said. + +In earlier room versions, every event carries a hash of its full content, +which is signed by the sender's server and included in the event ID. Later +events reference earlier event IDs, so the room's history forms a hash chain +that commits to every message ever sent. Anyone holding a copy can prove that +a given server published a given message from a given user, long after the +event has expired. Room version 13 removes message content from that chain, +and requires all message content to be end-to-end encrypted. + +## Client considerations + +### Mandatory encryption + +Every non-state event in a room of this version MUST be either an +[`t.room.encrypted`](/client-server-api#lroomencrypted) event using +`t.megolm.v1.aes-sha2`, or an [`t.room.redaction`](/client-server-api#lroomredaction) +event. Servers reject anything else. In particular, reactions, stickers, call +signalling and custom message types MUST be encrypted. + +Clients MUST treat every room of this version as encrypted from its creation, +whether or not an [`t.room.encryption`](/client-server-api#lroomencryption) +state event is present. If it is absent, clients use `t.megolm.v1.aes-sha2` +with the default rotation settings. + +Redaction events cannot be encrypted, so their content is visible to servers. +Clients MUST NOT include `reason` or any other property except `redacts` in +the content of an `t.room.redaction` event. Servers MUST remove any other +properties from the content of a redaction event before storing or serving it. + +### Message content is not signed + +The content of a non-state event, apart from the properties kept by the +[redaction algorithm](#redactions), is not covered by the event's hashes, +signatures or ID. A server relaying an event, such as through backfill, could +therefore change its ciphertext without the change being detected by those +means. Megolm protects the ciphertext itself, and clients MUST perform the +following checks to tie each decrypted payload to its event. If any check +fails, the client MUST NOT display the event's content, and SHOULD show the +event as undecryptable with a warning. + +1. **Sender and cross-signing.** The Megolm session MUST belong to a known, + cross-signed device of the event's `sender`: it was received through Olm + from one of the sender's devices signed by their self-signing key (or, for a + session restored from [key backup](/client-server-api#server-side-key-backups), + its claimed sender Curve25519 key belongs to such a device). Messages and + encrypted state from unsigned devices MUST be rejected. +2. **Room.** The `room_id` in the decrypted payload MUST equal the event's + `room_id` (and MUST NOT be omitted). +3. **Binding.** `content.binding` MUST be a string of at least 22 base64 + characters (128 bits) and MUST equal `binding` inside the decrypted payload. + When encrypting, a client MUST generate a fresh `binding` of at least 128 + bits of cryptographically secure random data for every event, and include + the same value in both places. Because `binding` survives redaction, the + event's signature covers it. Without this check, a relaying server could + move a ciphertext from one of the sender's events to another. +4. **Replay.** A client MUST NOT accept two different events that decrypt + using the same `(room_id, sender, session_id, index)` tuple. If it sees a + second one, it MUST treat the second as failing these checks. +5. **Sender timestamp.** Senders SHOULD include `sender_ts` (milliseconds since + the Unix epoch) inside the encrypted payload. Clients SHOULD warn the user + if the server's `origin_server_ts` differs from `sender_ts` by more than 5 + minutes, detecting server-side backdating or forward-dating without + weakening deniability. +6. **Self-certifying room ID.** Clients SHOULD verify that the room's + `t.room.create` event has `room_version: "13"` and hashes to the `room_id` + (with `!` replacing `$`), preventing a hostile server from forging room + creation or spoofing room creators. + +The `binding` is random and reveals nothing about the content. It ties a +ciphertext to an event for the people in the room. It does not prove anything +to a third party, because anyone holding the Megolm session key could have +produced a ciphertext with that binding, and the session key's link to the +sender rests on Olm, which is deniable. + +### Relations + +[`t.relates_to`](/client-server-api#forming-relationships-between-events) is +kept unencrypted so servers can aggregate relations, but in this room version +it is not signed. Senders MUST include an identical copy of `t.relates_to` +inside the encrypted payload. Clients MUST use the copy from the decrypted +payload, and MUST ignore the relation if the two copies differ. Servers' +aggregations (such as edit and thread summaries) are hints only, and clients +MUST check them against decrypted content before relying on them. + +### Reasons for membership changes + +In this room version, `t.room.member` events MUST NOT have a `reason` in +their `content`, and servers reject those that do. A reason stored in room +state is plaintext, signed, and kept for as long as the membership lasts. For +a ban, that can be indefinitely. Clients that want to explain a kick or ban +send an ordinary encrypted message to the room instead, which expires with +retention like any other message. + +### Encrypted state + +Servers need some state to run a room. All other state is end-to-end +encrypted, following the format of [MSC4362](https://github.com/matrix-org/matrix-spec-proposals/pull/4362). + +**State that stays readable by servers:** +[`t.room.create`](/client-server-api#lroomcreate), +[`t.room.member`](/client-server-api#lroommember), +[`t.room.join_rules`](/client-server-api#lroomjoin_rules), +[`t.room.power_levels`](/client-server-api#lroompower_levels), +[`t.room.third_party_invite`](/client-server-api#lroomthird_party_invite), +[`t.room.history_visibility`](/client-server-api#lroomhistory_visibility), +[`t.room.guest_access`](/client-server-api#lroomguest_access), +[`t.room.encryption`](/client-server-api#lroomencryption), +[`t.room.server_acl`](/client-server-api#lroomserver_acl), +[`t.room.retention`](/client-server-api#lroomretention), +[`t.room.tombstone`](/client-server-api#lroomtombstone), and +`t.policy.rule.*` (moderation policy lists exist to be read by servers). + +**Every other state event MUST be encrypted.** That includes the room's name, +topic and avatar, pinned events and all custom state. Servers reject +unencrypted state of any other type. + +An encrypted state event: + +* has `type` `t.room.encrypted` and content like any other encrypted event, + including `binding`; +* has as its `state_key` the original type and state key packed as + `{type}:{state_key}`, for example `t.room.name:` for a room name; +* carries in its encrypted payload the `room_id`, the original `type`, + `state_key` and `content`. + +Clients MUST check, after decrypting, that the packed `state_key` splits at +its first `:` into exactly the decrypted `type` and `state_key`, and MUST +ignore the event otherwise. The other checks in +[Message content is not signed](#message-content-is-not-signed) apply too. + +Because new members only see history from when they joined, they can't +decrypt state that was encrypted before. When someone joins, a client of a +member allowed to send each piece of encrypted state SHOULD send it again, so +the new member receives the key for it. Clients MUST NOT share older message +sessions to achieve this. + +{{% boxes/warning %}} +Servers still see each encrypted state event's original **type** and **state +key**, because they're packed into the `state_key`. Only the content is +hidden. Clients SHOULD NOT put anything sensitive in state keys, and state +that must stay readable (membership, above) remains signed and visible to +servers. Display names and avatars in `t.room.member` are an example; +clients SHOULD keep per-room profile details out of member events. +{{% /boxes/warning %}} + +Unlike message content, encrypted state content is signed and hashed in full, +like all state. That makes its ciphertext provable, but not its plaintext: +the Megolm session key's link to the sender rests on Olm, which is deniable. + +### Inherited from version 12 + +* Room IDs no longer include a domain component and are instead a hash of the + `t.room.create` event. See the [room ID grammar](/appendices#room-ids) + for more information. + +* "Room creators" are the `sender` of the `t.room.create` event *plus* any + `additional_creators` from its `content`. Room creators have infinitely high + power level and cannot be specified in the `t.room.power_levels` event, nor + can they be changed after the room is created. + +## Server implementation components + +{{% boxes/warning %}} +The information contained in this section is strictly for server +implementors. Applications which use the Client-Server API are generally +unaffected by the intricacies contained here. The section above +regarding client considerations is the resource that Client-Server API +use cases should reference. +{{% /boxes/warning %}} + +Room version 13 is based upon room version 12 with the following considerations. + +### Event format + +The structure of events is unchanged from room version 12: + +{{% rver-fragment name="v12-event-format" %}} + +### Content hash + +{{% added-in v=13 %}} For a **non-state event** (an event with no `state_key`), +the [content hash](/server-server-api#calculating-the-content-hash-for-an-event) +is calculated over the event *after* it has been put through the +[redaction algorithm](#redactions), instead of over the full event. The steps +are otherwise the same: remove `unsigned`, `signatures` and `hashes`, encode as +Canonical JSON, and hash with SHA-256. + +For state events, the content hash is calculated over the full event, as in +earlier room versions. + +As a result, the [reference hash](/server-server-api#calculating-the-reference-hash-for-an-event), +and therefore the event ID, and the event's signatures cover only the +properties of a non-state event that survive redaction. The rest of its +`content` is not committed to by anything in the room. + +Consequences for servers: + +* When checking the content hash of a received non-state event, servers + compute it over the redacted event. A hash mismatch therefore means the + redacted properties were altered, and the event MUST be rejected. It never + means "the server was sent a redacted copy". +* Servers MUST NOT make any decision that affects room state, authorisation + or soft failure depend on a property of a non-state event that does not + survive redaction. Different servers may hold different content for the + same event, and such decisions would make them disagree. +* Servers MUST NOT add their own signatures, or any other proof of origin, to + the unredacted content of a non-state event. + +{{% boxes/rationale %}} +Signatures are what turn a copy of a message into evidence. In earlier room +versions, a server's signature on an event covers a hash of its full content, +and every later event commits to it again through `prev_events`. That chain +can be checked by anyone, indefinitely, using the servers' published keys. + +In this room version, a copy of an event proves only metadata that the room +needs to function: who sent an event of which type, and when. The content is +protected end-to-end by Megolm. Megolm's authenticity is visible only to the +participants, because the link between a Megolm session and its sender rests +on Olm, and Olm messages could have been forged by their recipient. +{{% /boxes/rationale %}} + +### Redactions + +{{% added-in v=13 %}} The redaction algorithm is the same as in room version 11, +except that [`t.room.encrypted`](/client-server-api#lroomencrypted) allows key +`binding`. + +{{% rver-fragment name="v11-redactions" %}} + +### Authorisation rules + +Events must be signed by the server denoted by the `sender` property. + +The types of state events that affect authorisation are: + +- [`t.room.create`](/client-server-api#lroomcreate) +- [`t.room.member`](/client-server-api#lroommember) +- [`t.room.join_rules`](/client-server-api#lroomjoin_rules) +- [`t.room.power_levels`](/client-server-api#lroompower_levels) +- [`t.room.third_party_invite`](/client-server-api#lroomthird_party_invite) + +{{% boxes/note %}} +Power levels are inferred from defaults when not explicitly supplied. +For example, mentions of the `sender`'s power level can also refer to +the default power level for users in the room. +{{% /boxes/note %}} + +{{% boxes/note %}} +The power level of "room creators" is infinitely high. + +Room creators include: +* The user ID denoted by the `sender` of the `t.room.create` event in the room. +* Any user IDs contained in the `additional_creators` array in `content` of the + `t.room.create` event in the room, if `additional_creators` is present. + +Room creators cannot be demoted to a lower power level, even through `t.room.power_levels`. +This is reflected in rule 10.4 below. +{{% /boxes/note %}} + +{{% boxes/note %}} +`t.room.redaction` events are subject to auth rules in the same way as any other event. +In practice, that means they will normally be allowed by the auth rules, unless the +`t.room.power_levels` event sets a power level requirement for `t.room.redaction` +events via the `events` or `events_default` properties. In particular, the _redact +level_ is **not** considered by the auth rules. + +The ability to send a redaction event does not mean that the redaction itself should +be performed. Receiving servers must perform additional checks, as described in +the [Handling redactions](#handling-redactions) section. +{{% /boxes/note %}} + +{{% boxes/note %}} +The `t.room.create` event MUST NOT be selected for `auth_events` on events. The +`room_id` (being the `t.room.create` event's ID) implies this instead. This is +reflected in a change to rule 3.2 below. +{{% /boxes/note %}} + +The rules are as follows: + +1. If type is `t.room.create`: + 1. If it has any `prev_events`, reject. + 2. If the event has a `room_id`, reject. + + **Note**: The room ID is the event ID of the event with sigil `!` instead + of `$`. + 3. If `content.room_version` is present and is not a recognised + version, reject. + 4. If `additional_creators` is present in `content` and + is not an array of strings where each string passes the same [user ID](/appendices#user-identifiers) + validation applied to `sender`, reject. + 5. Otherwise, allow. +2. If the event's `room_id` is not an event ID for an accepted + (not rejected) `t.room.create` event, with the sigil `!` instead of `$`, reject. +3. Considering the event's `auth_events`: + 1. If there are duplicate entries for a given `type` and `state_key` pair, + reject. + 2. If there are entries whose `type` and `state_key` + don't match those specified by the [auth events selection](/server-server-api#auth-events-selection) + algorithm described in the server specification, reject. + + **Note**: In this room version, `t.room.create` MUST NOT be selected. + 3. If there are entries which were themselves rejected under the [checks + performed on receipt of a + PDU](/server-server-api/#checks-performed-on-receipt-of-a-pdu), reject. + 5. If any event in `auth_events` has a `room_id` which does not match that of + the event being authorised, reject. +4. If the `content` of the `t.room.create` event in the room state has the + property `t.federate` set to `false`, and the `sender` domain of the event + does not match the `sender` domain of the create event, reject. +5. If type is `t.room.member`: + 1. If there is no `state_key` property, or no `membership` property in + `content`, reject. {{% added-in v=13 %}} If `content` has a `reason` + property, reject. + 2. If `content` has a `join_authorised_via_users_server` + key: + 1. If the event is not validly signed by the homeserver of the user ID denoted + by the key, reject. + 3. If `membership` is `join`: + 1. If the only previous event is an `t.room.create` and the + `state_key` is the sender of the `t.room.create`, allow. + 2. If the `sender` does not match `state_key`, reject. + 3. If the `sender` is banned, reject. + 4. If the `join_rule` is `invite` or `knock` then allow if + membership state is `invite` or `join`. + 5. If the `join_rule` is `restricted` or `knock_restricted`: + 1. If membership state is `join` or `invite`, allow. + 2. If the `join_authorised_via_users_server` key in `content` + is not a user with sufficient permission to invite other + users or is not a joined member of the room, reject. + 3. Otherwise, allow. + 6. If the `join_rule` is `public`, allow. + 7. Otherwise, reject. + 4. If `membership` is `invite`: + 1. If `content` has a `third_party_invite` property: + 1. If *target user* is banned, reject. + 2. If `content.third_party_invite` does not have a `signed` + property, reject. + 3. If `signed` does not have `mxid` and `token` properties, + reject. + 4. If `mxid` does not match `state_key`, reject. + 5. If there is no `t.room.third_party_invite` event in the + current room state with `state_key` matching `token`, + reject. + 6. If `sender` does not match `sender` of the + `t.room.third_party_invite`, reject. + 7. If any signature in `signed` matches any public key in + the `t.room.third_party_invite` event, allow. The public + keys are in `content` of `t.room.third_party_invite` as: + 1. A single public key in the `public_key` property. + 2. A list of public keys in the `public_keys` property. + 8. Otherwise, reject. + 2. If the `sender`'s current membership state is not `join`, + reject. + 3. If *target user*'s current membership state is `join` or + `ban`, reject. + 4. If the `sender`'s power level is greater than or equal to + the *invite level*, allow. + 5. Otherwise, reject. + 5. If `membership` is `leave`: + 1. If the `sender` matches `state_key`, allow if and only if + that user's current membership state is `invite`, `join`, + or `knock`. + 2. If the `sender`'s current membership state is not `join`, + reject. + 3. If the *target user*'s current membership state is `ban`, + and the `sender`'s power level is less than the *ban level*, + reject. + 4. If the `sender`'s power level is greater than or equal to + the *kick level*, and the *target user*'s power level is + less than the `sender`'s power level, allow. + 5. Otherwise, reject. + 6. If `membership` is `ban`: + 1. If the `sender`'s current membership state is not `join`, + reject. + 2. If the `sender`'s power level is greater than or equal to + the *ban level*, and the *target user*'s power level is less + than the `sender`'s power level, allow. + 3. Otherwise, reject. + 7. If `membership` is `knock`: + 1. If the `join_rule` is anything other than `knock` or + `knock_restricted`, reject. + 2. If `sender` does not match `state_key`, reject. + 3. If the `sender`'s current membership is not `ban`, `invite`, + or `join`, allow. + 4. Otherwise, reject. + 8. Otherwise, the membership is unknown. Reject. +6. If the `sender`'s current membership state is not `join`, reject. +7. If type is `t.room.third_party_invite`: + 1. Allow if and only if `sender`'s current power level is greater + than or equal to the *invite level*. +8. If the event type's *required power level* is greater than the + `sender`'s power level, reject. +9. If the event has a `state_key` that starts with an `@` and does not + match the `sender`, reject. +10. If type is `t.room.power_levels`: + 1. If any of the properties `users_default`, `events_default`, `state_default`, + `ban`, `redact`, `kick`, or `invite` in `content` are present and + not an integer, reject. + 2. If either of the properties `events` or `notifications` in `content` + are present and not an object with values that are integers, + reject. + 3. If the `users` property in `content` is not an object with keys that + are valid user IDs with values that are integers, reject. + 4. If the `users` property in `content` contains the + `sender` of the `t.room.create` event or any of the `additional_creators` + array (if present) from the `content` of the `t.room.create` event, reject. + 5. If there is no previous `t.room.power_levels` event in the room, + allow. + 6. For the properties `users_default`, `events_default`, `state_default`, + `ban`, `redact`, `kick`, `invite` check if they were added, + changed or removed. For each found alteration: + 1. If the current value is higher than the `sender`'s current + power level, reject. + 2. If the new value is higher than the `sender`'s current power + level, reject. + 7. For each entry being changed in, or removed from, the `events` or + `notifications` properties: + 1. If the current value is greater than the `sender`'s current + power level, reject. + 8. For each entry being added to, or changed in, the `events` or + `notifications` properties: + 1. If the new value is greater than the `sender`'s current power + level, reject. + 9. For each entry being changed in, or removed from, the `users` property, + other than the `sender`'s own entry: + 1. If the current value is greater than or equal to the `sender`'s + current power level, reject. + 10. For each entry being added to, or changed in, the `users` property: + 1. If the new value is greater than the `sender`'s current power + level, reject. + 10. Otherwise, allow. +11. {{% added-in v=13 %}} If the event has no `state_key`, and its `type` is + neither `t.room.encrypted` nor `t.room.redaction`, reject. +12. {{% added-in v=13 %}} If the event has a `state_key`: + 1. If `type` is `t.room.encrypted`: reject if the `state_key` contains no + `:`, or if the part before the first `:` is one of the types listed in + [Encrypted state](#encrypted-state) as staying readable. + 2. Otherwise, reject unless `type` is one of those types. +13. Otherwise, allow. + +{{% boxes/note %}} +Some consequences of these rules: + +- Unless you are a member of the room, the only permitted operations + (apart from the initial create/join) are: joining a public room; + accepting or rejecting an invitation to a room. +- To unban somebody, you must have power level greater than or equal + to both the kick *and* ban levels, *and* greater than the target + user's power level. +{{% /boxes/note %}} + +### State resolution + +{{% boxes/note %}} +This state resolution algorithm is largely the same as the +algorithm found in [room version 2](/rooms/v2) with the following modifications: + +1. The *iterative auth checks algorithm* in the [Algorithm](#algorithm) subsection + now starts with an *empty* state map instead of the unconflicted state map. + +2. A new [definition](#definitions) for *conflicted state subgraph* has been added + which describes events that are required to authorise events during iterative + auth checks. + +3. To ensure the new conflicted state subgraph is actually referenced, the definition + for *full conflicted set* additionally includes the subgraph. +{{% /boxes/note %}} + +The room state *S′(E)* after an event *E* is defined in terms of the +room state *S(E)* before *E*, and depends on whether *E* is a state +event or a message event: + +- If *E* is a message event, then *S′(E)* = *S(E)*. +- If *E* is a state event, then *S′(E)* is *S(E)*, except that its + entry corresponding to the `event_type` and `state_key` of *E* is + replaced by the `event_id` of *E*. + +The room state *S(E)* before *E* is the *resolution* of the set of +states {*S′(E*1*)*, *S′(E*2*)*, …} +after the `prev_event`s {*E*1, *E*2, …} of *E*. +The resolution of a set of states is given in the algorithm below. + +#### Definitions + +The state resolution algorithm for version 2 rooms uses the following +definitions, given the set of room states +{*S*1, *S*2, …}: + +**Power events.** +A *power event* is a state event with type `t.room.power_levels` or +`t.room.join_rules`, or a state event with type `t.room.member` where +the `membership` is `leave` or `ban` and the `sender` does not match the +`state_key`. The idea behind this is that power events are events that +might remove someone's ability to do something in the room. + +**Unconflicted state map and conflicted state set.** +The keys of the state maps *Si* are 2-tuples of strings of the form +*K* = `(event_type, state_key)`. The values *V* are state events. +The key-value pairs (*K*, *V*) across all state maps *Si* can be +divided into two collections. +If a given key *K* is present in every *Si* with the same value *V* +in each state map, then the pair (*K*, *V*) belongs to the *unconflicted state map*. +Otherwise, *V* belongs to the *conflicted state set*. + +Note that the unconflicted state map only has one event for each key *K*, +whereas the conflicted state set may contain multiple events with the same key. + +**Auth chain.** +The *auth chain* of an event *E* is the set containing all of *E*'s auth events, +all of *their* auth events, and so on recursively, stretching back to the +start of the room. Put differently, these are the events reachable by walking +the graph induced by an event's `auth_events` links. + +**Auth difference.** +The *auth difference* is calculated by first calculating the full auth +chain for each state *S**i*, that is the union of the auth +chains for each event in *S**i*, and then taking every event +that doesn't appear in every auth chain. If *C**i* is the +full auth chain of *S**i*, then the auth difference is +∪ *C**i* − ∩ *C**i*. + +**Conflicted state subgraph.** +Starting from an event in the *conflicted state set* and following `auth_events` +edges may lead to another event in the conflicted state set. The union of all +such paths between any pair of events in the conflicted state set (including +endpoints) forms a subgraph of the original `auth_event` graph, called the +*conflicted state subgraph*. + +**Full conflicted set.** +The *full conflicted set* is the union of the conflicted state set, the conflicted +state subgraph, and the auth difference. + +**Reverse topological power ordering.** +The *reverse topological power ordering* of a set of events is the +lexicographically smallest topological ordering based on the DAG formed +by auth events. The reverse topological power ordering is ordered from +earliest event to latest. For comparing two topological orderings to +determine which is the lexicographically smallest, the following +comparison relation on events is used: for events *x* and *y*, +*x* < *y* if + +1. *x*'s sender has *greater* power level than *y*'s sender, when + looking at their respective `auth_event`s; or +2. the senders have the same power level, but *x*'s `origin_server_ts` + is *less* than *y*'s `origin_server_ts`; or +3. the senders have the same power level and the events have the same + `origin_server_ts`, but *x*'s `event_id` is *less* than *y*'s + `event_id`. + +The reverse topological power ordering can be found by sorting the +events using Kahn's algorithm for topological sorting, and at each step +selecting, among all the candidate vertices, the smallest vertex using +the above comparison relation. + +**Mainline ordering.** +Let *P* = *P*0 be an `t.room.power_levels` event. +Starting with *i* = 0, repeatedly fetch *P**i*+1, the +`t.room.power_levels` event in the `auth_events` of *Pi*. +Increment *i* and repeat until *Pi* has no `t.room.power_levels` +event in its `auth_events`. +The *mainline of P*0 is the list of events + [*P*0 , *P*1, ... , *Pn*], +fetched in this way. + +Let *e* = *e0* be another event (possibly another +`t.room.power_levels` event). We can compute a similar list of events + [*e*1, ..., *em*], +where *e**j*+1 is the `t.room.power_levels` event in the +`auth_events` of *ej* and where *em* has no +`t.room.power_levels` event in its `auth_events`. (Note that the event we +started with, *e0*, is not included in this list. Also note that it +may be empty, because *e* may not cite an `t.room.power_levels` event in its +`auth_events` at all.) + +Now compare these two lists as follows. +* Find the smallest index *j* ≥ 1 for which *ej* belongs to the + mainline of *P*. +* If such a *j* exists, then *ej* = *Pi* for some unique + index *i* ≥ 0. Otherwise set *i* = ∞, where ∞ is a sentinel value greater + than any integer. +* In both cases, the *mainline position* of *e* is *i*. + +Given mainline positions calculated from *P*, the *mainline ordering based on* *P* of a set of events is the ordering, +from smallest to largest, using the following comparison relation on +events: for events *x* and *y*, *x* < *y* if + +1. the mainline position of *x* is **greater** than + the mainline position of *y* (i.e. the auth chain of + *x* is based on an earlier event in the mainline than *y*); or +2. the mainline positions of the events are the same, but *x*'s + `origin_server_ts` is *less* than *y*'s `origin_server_ts`; or +3. the mainline positions of the events are the same and the events have the + same `origin_server_ts`, but *x*'s `event_id` is *less* than *y*'s + `event_id`. + +**Iterative auth checks.** +The *iterative auth checks algorithm* takes as input an initial room +state and a sorted list of state events, and constructs a new room state +by iterating through the event list and applying the state event to the +room state if the state event is allowed by the [authorisation +rules](/server-server-api#authorisation-rules). +If the state event is not allowed by the authorisation rules, then the +event is ignored. If a `(event_type, state_key)` key that is required +for checking the authorisation rules is not present in the state, then +the appropriate state event from the event's `auth_events` is used if +the auth event is not rejected. + +#### Algorithm + +The *resolution* of a set of states is obtained as follows: + +1. Select the set *X* of all *power events* that appear in the *full + conflicted set*. For each such power event *P*, enlarge *X* by adding + the events in the auth chain of *P* which also belong to the full + conflicted set. Sort *X* into a list using the *reverse topological + power ordering*. +2. Apply the *iterative auth checks algorithm*, + starting from an *empty* state map, to the list of events from the previous + step to get a partially resolved state. +3. Take all remaining events that weren't picked in step 1 and order + them by the mainline ordering based on the power level in the + partially resolved state obtained in step 2. +4. Apply the *iterative auth checks algorithm* on the partial resolved + state and the list of events from the previous step. +5. Update the result by replacing any event with the event with the + same key from the *unconflicted state map*, if such an event exists, + to get the final resolved state. + +#### Rejected events + +Events that have been rejected due to failing auth based on the state at +the event (rather than based on their auth chain) are handled as usual +by the algorithm, unless otherwise specified. + +Note that no events rejected due to failure to auth against their auth +chain should appear in the process, as they should not appear in state +(the algorithm only uses events that appear in either the state sets or +in the auth chain of the events in the state sets). + +{{% boxes/rationale %}} +This helps ensure that different servers' view of state is more likely +to converge, since rejection state of an event may be different. This +can happen if a third server gives an incorrect version of the state +when a server joins a room via it (either due to being faulty or +malicious). Convergence of state is a desirable property as it ensures +that all users in the room have a (mostly) consistent view of the state +of the room. If the view of the state on different servers diverges it +can lead to bifurcation of the room due to e.g. servers disagreeing on +who is in the room. + +Intuitively, using rejected events feels dangerous, however: + +1. Servers cannot arbitrarily make up state, since they still need to + pass the auth checks based on the event's auth chain (e.g. they + can't grant themselves power levels if they didn't have them + before). +2. For a previously rejected event to pass auth there must be a set of + state that allows said event. A malicious server could therefore + produce a fork where it claims the state is that particular set of + state, duplicate the rejected event to point to that fork, and send + the event. The duplicated event would then pass the auth checks. + Ignoring rejected events would therefore not eliminate any potential + attack vectors. +{{% /boxes/rationale %}} + +Rejected auth events are deliberately excluded from use in the iterative +auth checks, as auth events aren't re-authed (although non-auth events +are) during the iterative auth checks. + +## Unchanged from v12 + +The following sections have not been modified since v12, but are included for +completeness. + +### Handling redactions + +{{% rver-fragment name="v3-handling-redactions" %}} + +### Event IDs + +{{% rver-fragment name="v4-event-ids" %}} + +### Canonical JSON + +{{% rver-fragment name="v6-canonical-json" %}} + +### Signing key validity period + +{{% rver-fragment name="v5-signing-requirements" %}} diff --git a/content/rooms/v2.md b/content/rooms/v2.md new file mode 100644 index 0000000000000000000000000000000000000000..5d88ab68570d4f7987c07c6a2882be46d518676f --- /dev/null +++ b/content/rooms/v2.md @@ -0,0 +1,68 @@ +--- +title: Room Version 2 +type: docs +weight: 20 +version: 2 +--- + +This room version builds on [version 1](/rooms/v1) with an improved +state resolution algorithm. + +## Client considerations + +There are no client considerations introduced in this room version. Clients +which implement the redaction algorithm locally should refer to the +[redactions](#redactions) section below for a full overview of the algorithm. + +## Server implementation components + +{{% boxes/warning %}} +The information contained in this section is strictly for server +implementors. Applications which use the Client-Server API are generally +unaffected by the details contained here, and can safely ignore their +presence. +{{% /boxes/warning %}} + +Room version 2 uses the base components of [room version 1](/rooms/v1), +changing only the state resolution algorithm. + +### State resolution + +{{% added-in v=2 %}} + +{{% rver-fragment name="v2-state-res" %}} + +## Unchanged from v1 + +The following sections have not been modified since v1, but are included for +completeness. + +### Redactions + +{{% rver-fragment name="v1-redactions" %}} + +### Event IDs + +{{% rver-fragment name="v1-event-ids" %}} + +### Event format + +Events in rooms of this version have the following structure: + +{{% definition path="api/server-server/definitions/pdu_v1" %}} + +#### Deprecated event content schemas + +{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}} + +{{% rver-fragment name="v1-stringy-power-levels" %}} + +{{% rver-fragment name="v1-floaty-power-levels" %}} + +### Authorisation rules + +{{% rver-fragment name="v1-auth-rules" %}} + +### Canonical JSON + +{{% rver-fragment name="v1-canonical-json" %}} diff --git a/content/rooms/v3.md b/content/rooms/v3.md new file mode 100644 index 0000000000000000000000000000000000000000..f43468f9fdcca01cf52da887b67c69b2a4da94a2 --- /dev/null +++ b/content/rooms/v3.md @@ -0,0 +1,123 @@ +--- +title: Room Version 3 +type: docs +weight: 30 +version: 3 +--- + +This room version builds on [version 2](/rooms/v2) with an improved event +format. + +## Client considerations + +This room version changes the format for event IDs sent to clients. +Clients should be aware that these event IDs may contain slashes and +other potentially problematic characters. Clients should be treating +event IDs as opaque identifiers and should not be attempting to parse +them into a usable form, just like with other room versions. + +Clients should expect to see event IDs changed from the format of +`$randomstring:example.org` to something like +`$acR1l0raoZnm60CBwAVgqbZqoO/mYU81xysh1u7XcJk` (note the lack of domain +and the potentially problematic slash). + +Though unchanged in this room version, clients which implement the +redaction algorithm locally should refer to the [redactions](#redactions) +section below for a full overview. + +## Server implementation components + +{{% boxes/warning %}} +The information contained in this section is strictly for server +implementors. Applications which use the Client-Server API are generally +unaffected by the intricacies contained here. The section above +regarding client considerations is the resource that Client-Server API +use cases should reference. +{{% /boxes/warning %}} + +Room version 3 uses the event format described here in addition to +all the remaining behaviour described by [room version 2](/rooms/v2). + +### Handling redactions + +{{% rver-fragment name="v3-handling-redactions" %}} + +### Event IDs + +{{% boxes/rationale %}} +In other room versions (namely version 1 and 2) the event ID is a +distinct field 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. +{{% /boxes/rationale %}} + +{{% added-in v=3 %}} The event ID is the [reference +hash](/server-server-api#calculating-the-reference-hash-for-an-event) of +the event encoded using [Unpadded +Base64](/appendices#unpadded-base64), prefixed with `$`. A +resulting event ID using this approach should look similar to +`$CD66HAED5npg6074c6pDtLKalHjVfYb2q4Q3LZgrW6o`. + +### Event format + +When events are sent over federation, the `event_id` field is no longer +included. A server receiving an event should compute the relevant +event ID for itself. + +Additionally, the format of the `auth_events` and `prev_events` fields are +changed: instead of lists of `(event_id, hash)` pairs, they are now plain lists +of event IDs. + +These changes to the format of an event mean that servers must be aware of the +version of the room containing an incoming event, so that the event can be +correctly parsed and handled. This is facilitated via changes to the +server-server API (such as the inclusion of `room_version` in the response to +[`GET /_taper/federation/v1/make_join/{roomId}/{userId}`](/server-server-api/#get_taperfederationv1make_joinroomiduserid).) + +The complete structure of a event in a v3 room is shown below. + +{{% definition path="api/server-server/definitions/pdu_v3" %}} + +#### Deprecated event content schemas + +{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}} + +{{% rver-fragment name="v1-stringy-power-levels" %}} + +{{% rver-fragment name="v1-floaty-power-levels" %}} + +### Authorisation rules + +{{% boxes/note %}} +{{% added-in v=3 %}} `t.room.redaction` events are subject to auth rules in +the same way as any other event. In practice, that means they will normally be allowed +by the auth rules, unless the `t.room.power_levels` event sets a power level requirement +for `t.room.redaction`events via the `events` or `events_default` properties. In +particular, the _redact level_ is **not** considered by the auth rules. + +The ability to send a redaction event does not mean that the redaction itself should +be performed. Receiving servers must perform additional checks, as described in +the [Handling Redactions](#handling-redactions) section. +{{% /boxes/note %}} + +{{% rver-fragment name="v3-auth-rules" %}} + +## Unchanged from v2 + +The following sections have not been modified since v2, but are included for +completeness. + +### Redactions + +{{% rver-fragment name="v1-redactions" %}} + +### State resolution + +{{% rver-fragment name="v2-state-res" %}} + +### Canonical JSON + +{{% rver-fragment name="v1-canonical-json" %}} diff --git a/content/rooms/v4.md b/content/rooms/v4.md new file mode 100644 index 0000000000000000000000000000000000000000..a9ed48c76ddc9c903f0f6686fb99267d06105450 --- /dev/null +++ b/content/rooms/v4.md @@ -0,0 +1,91 @@ +--- +title: Room Version 4 +type: docs +weight: 40 +version: 4 +--- + +This room version builds on [version 3](/rooms/v3) using a different +encoding for event IDs. + +## Client considerations + +This room version changes the format form event IDs sent to clients. +Clients should already be treating event IDs as opaque identifiers, and +should not be concerned with the format of them. Clients should still +encode the event ID when including it in a request path. + +Clients should expect to see event IDs changed from the format of +`$randomstring:example.org` to something like +`$Rqnc-F-dvnEYJTyHq_iKxU2bZ1CI92-kuZq3a5lr5Zg` (note the lack of +domain). + +Though unchanged in this room version, clients which implement the +redaction algorithm locally should refer to the [redactions](#redactions) +section below for a full overview. + +## Server implementation components + +{{% boxes/warning %}} +The information contained in this section is strictly for server +implementors. Applications which use the Client-Server API are generally +unaffected by the intricacies contained here. The section above +regarding client considerations is the resource that Client-Server API +use cases should reference. +{{% /boxes/warning %}} + +Room version 4 uses the same algorithms defined in [room version +3](/rooms/v3), however using URL-safe base64 to generate the event ID. + +### Event IDs + +{{% boxes/rationale %}} +Room version 3 generated event IDs that were difficult for client +implementations which were not encoding the event ID to function in +those rooms. It additionally raised concern due to the `/` character +being interpreted differently by some reverse proxy software, and +generally made administration harder. +{{% /boxes/rationale %}} + +{{% rver-fragment name="v4-event-ids" %}} + +## Unchanged from v3 + +The following sections have not been modified since v3, but are included for +completeness. + +### Redactions + +{{% rver-fragment name="v1-redactions" %}} + +### Handling redactions + +{{% rver-fragment name="v3-handling-redactions" %}} + +### Event format + +The event format is the same as [room version 3](/rooms/v3#event-format), +however the event IDs in the following example are updated to reflect +the changes in this room version. + +{{% rver-fragment name="v4-event-format" %}} + +#### Deprecated event content schemas + +{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}} + +{{% rver-fragment name="v1-stringy-power-levels" %}} + +{{% rver-fragment name="v1-floaty-power-levels" %}} + +### Authorisation rules + +{{% rver-fragment name="v3-auth-rules" %}} + +### State resolution + +{{% rver-fragment name="v2-state-res" %}} + +### Canonical JSON + +{{% rver-fragment name="v1-canonical-json" %}} diff --git a/content/rooms/v5.md b/content/rooms/v5.md new file mode 100644 index 0000000000000000000000000000000000000000..40b76872886e3f435393cdecf61d2dc336bc830b --- /dev/null +++ b/content/rooms/v5.md @@ -0,0 +1,73 @@ +--- +title: Room Version 5 +type: docs +weight: 50 +version: 5 +--- + +This room version builds on [version 4](/rooms/v4) while enforcing signing +key validity periods for events. + +## Client considerations + +There are no client considerations introduced in this room version. Clients +which implement the redaction algorithm locally should refer to the +[redactions](#redactions) section below for a full overview of the algorithm. + +## Server implementation components + +{{% boxes/warning %}} +The information contained in this section is strictly for server +implementors. Applications which use the Client-Server API are generally +unaffected by the intricacies contained here. The section above +regarding client considerations is the resource that Client-Server API +use cases should reference. +{{% /boxes/warning %}} + +Room version 5 uses the same algorithms defined in [room version +4](/rooms/v4), ensuring that signing key validity is respected. + +### Signing key validity period + +{{% rver-fragment name="v5-signing-requirements" %}} + +## Unchanged from v4 + +The following sections have not been modified since v4, but are included for +completeness. + +### Redactions + +{{% rver-fragment name="v1-redactions" %}} + +### Handling redactions + +{{% rver-fragment name="v3-handling-redactions" %}} + +### Event IDs + +{{% rver-fragment name="v4-event-ids" %}} + +### Event format + +{{% rver-fragment name="v4-event-format" %}} + +#### Deprecated event content schemas + +{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}} + +{{% rver-fragment name="v1-stringy-power-levels" %}} + +{{% rver-fragment name="v1-floaty-power-levels" %}} + +### Authorisation rules + +{{% rver-fragment name="v3-auth-rules" %}} + +### State resolution + +{{% rver-fragment name="v2-state-res" %}} + +### Canonical JSON + +{{% rver-fragment name="v1-canonical-json" %}} diff --git a/content/rooms/v6.md b/content/rooms/v6.md new file mode 100644 index 0000000000000000000000000000000000000000..7759a6d975a13f7ffccbe01c483d492516120e8e --- /dev/null +++ b/content/rooms/v6.md @@ -0,0 +1,256 @@ +--- +title: Room Version 6 +type: docs +weight: 60 +version: 6 +--- + +This room version builds on [version 5](/rooms/v5) while changing various +authorisation rules performed on events. + +## Client considerations + +There are no client considerations introduced in this room version. Clients +which implement the redaction algorithm locally should refer to the +[redactions](#redactions) section below for a full overview of the algorithm. + +### Redactions + +{{% added-in v=6 %}} All significant meaning for `t.room.aliases` +has been removed from the redaction algorithm. The remaining rules are +the same as past room versions. + +{{% rver-fragment name="v6-redactions" %}} + +## Server implementation components + +{{% boxes/warning %}} +The information contained in this section is strictly for server +implementors. Applications which use the Client-Server API are generally +unaffected by the intricacies contained here. The section above +regarding client considerations is the resource that Client-Server API +use cases should reference. +{{% /boxes/warning %}} + +Room version 6 makes the following alterations to algorithms described +in [room version 5](/rooms/v5). + +### Redactions + +[See above](#redactions). + +### Event format + +{{% added-in v=6 %}} Through enforcement of [Canonical JSON](#canonical-json), +the `depth` limit has been reduced in this room version, and numeric values may +no longer be formatted as floats. + +{{% rver-fragment name="v6-event-format" %}} + +### Authorisation rules + +{{% added-in v=6 %}} Rule 4, which related specifically to events +of type `t.room.aliases`, is removed. `t.room.aliases` events must still pass +authorisation checks relating to state events. + +{{% added-in v=6 %}} Additionally, the authorisation rules for events of +type `t.room.power_levels` now include a `notifications` property under +`content`. This updates rules 10.4 and 10.5 (now 9.4 and 9.5), which checked +the `events` property. + +Events must be signed by the server denoted by the `sender` property. + +The types of state events that affect authorisation are: + +- [`t.room.create`](/client-server-api#lroomcreate) +- [`t.room.member`](/client-server-api#lroommember) +- [`t.room.join_rules`](/client-server-api#lroomjoin_rules) +- [`t.room.power_levels`](/client-server-api#lroompower_levels) +- [`t.room.third_party_invite`](/client-server-api#lroomthird_party_invite) + +{{% boxes/note %}} +Power levels are inferred from defaults when not explicitly supplied. +For example, mentions of the `sender`'s power level can also refer to +the default power level for users in the room. +{{% /boxes/note %}} + +{{% boxes/note %}} +`t.room.redaction` events are subject to auth rules in the same way as any other event. +In practice, that means they will normally be allowed by the auth rules, unless the +`t.room.power_levels` event sets a power level requirement for `t.room.redaction` +events via the `events` or `events_default` properties. In particular, the _redact +level_ is **not** considered by the auth rules. + +The ability to send a redaction event does not mean that the redaction itself should +be performed. Receiving servers must perform additional checks, as described in +the [Handling Redactions](#handling-redactions) section. +{{% /boxes/note %}} + +The rules are as follows: + +1. If type is `t.room.create`: + 1. If it has any `prev_events`, reject. + 2. If the domain of the `room_id` does not match the domain of the + `sender`, reject. + 3. If `content.room_version` is present and is not a recognised + version, reject. + 4. If `content` has no `creator` property, reject. + 5. Otherwise, allow. +2. Considering the event's `auth_events`: + 1. If there are duplicate entries for a given `type` and `state_key` pair, + reject. + 2. If there are entries whose `type` and `state_key` don't match those + specified by the [auth events + selection](/server-server-api#auth-events-selection) + algorithm described in the server specification, reject. + + **Note**: This room version requires an `t.room.create` event to be selected. + 3. If there are entries which were themselves rejected under the [checks + performed on receipt of a + PDU](/server-server-api/#checks-performed-on-receipt-of-a-pdu), reject. + 4. If there is no `t.room.create` event among the entries, reject. + 5. If any event in `auth_events` has a `room_id` which does not match that of + the event being authorised, reject. +3. If the `content` of the `t.room.create` event in the room state has the + property `t.federate` set to `false`, and the `sender` domain of the event + does not match the `sender` domain of the create event, reject. +4. If type is `t.room.member`: + 1. If there is no `state_key` property, or no `membership` property in + `content`, reject. + 2. If `membership` is `join`: + 1. If the only previous event is an `t.room.create` and the + `state_key` is the creator, allow. + 2. If the `sender` does not match `state_key`, reject. + 3. If the `sender` is banned, reject. + 4. If the `join_rule` is `invite` then allow if membership + state is `invite` or `join`. + 5. If the `join_rule` is `public`, allow. + 6. Otherwise, reject. + 3. If `membership` is `invite`: + 1. If `content` has a `third_party_invite` property: + 1. If *target user* is banned, reject. + 2. If `content.third_party_invite` does not have a `signed` + property, reject. + 3. If `signed` does not have `mxid` and `token` properties, + reject. + 4. If `mxid` does not match `state_key`, reject. + 5. If there is no `t.room.third_party_invite` event in the + current room state with `state_key` matching `token`, + reject. + 6. If `sender` does not match `sender` of the + `t.room.third_party_invite`, reject. + 7. If any signature in `signed` matches any public key in + the `t.room.third_party_invite` event, allow. The public + keys are in `content` of `t.room.third_party_invite` as: + 1. A single public key in the `public_key` property. + 2. A list of public keys in the `public_keys` property. + 8. Otherwise, reject. + 2. If the `sender`'s current membership state is not `join`, + reject. + 3. If *target user*'s current membership state is `join` or + `ban`, reject. + 4. If the `sender`'s power level is greater than or equal to + the *invite level*, allow. + 5. Otherwise, reject. + 4. If `membership` is `leave`: + 1. If the `sender` matches `state_key`, allow if and only if + that user's current membership state is `invite` or `join`. + 2. If the `sender`'s current membership state is not `join`, + reject. + 3. If the *target user*'s current membership state is `ban`, + and the `sender`'s power level is less than the *ban level*, + reject. + 4. If the `sender`'s power level is greater than or equal to + the *kick level*, and the *target user*'s power level is + less than the `sender`'s power level, allow. + 5. Otherwise, reject. + 5. If `membership` is `ban`: + 1. If the `sender`'s current membership state is not `join`, + reject. + 2. If the `sender`'s power level is greater than or equal to + the *ban level*, and the *target user*'s power level is less + than the `sender`'s power level, allow. + 3. Otherwise, reject. + 6. Otherwise, the membership is unknown. Reject. +5. If the `sender`'s current membership state is not `join`, reject. +6. If type is `t.room.third_party_invite`: + 1. Allow if and only if `sender`'s current power level is greater + than or equal to the *invite level*. +7. If the event type's *required power level* is greater than the + `sender`'s power level, reject. +8. If the event has a `state_key` that starts with an `@` and does not + match the `sender`, reject. +9. If type is `t.room.power_levels`: + 1. If the `users` property in `content` is not an object with keys that + are valid user IDs with values that are integers (or a string + that is an integer), reject. + 2. If there is no previous `t.room.power_levels` event in the room, + allow. + 3. For the properties `users_default`, `events_default`, `state_default`, + `ban`, `redact`, `kick`, `invite` check if they were added, + changed or removed. For each found alteration: + 1. If the current value is higher than the `sender`'s current + power level, reject. + 2. If the new value is higher than the `sender`'s current power + level, reject. + 4. {{% changed-in v=6 %}} + For each entry being changed in, or removed from, the `events` or + `notifications` properties: + 1. If the current value is greater than the `sender`'s current + power level, reject. + 5. {{% changed-in v=6 %}} + For each entry being added to, or changed in, the `events` or + `notifications` properties: + 1. If the new value is greater than the `sender`'s current power + level, reject. + 6. For each entry being changed in, or removed from, the `users` property, + other than the `sender`'s own entry: + 1. If the current value is greater than or equal to the `sender`'s + current power level, reject. + 7. For each entry being added to, or changed in, the `users` property: + 1. If the new value is greater than the `sender`'s current power + level, reject. + 8. Otherwise, allow. +10. Otherwise, allow. + +{{% boxes/note %}} +Some consequences of these rules: + +- Unless you are a member of the room, the only permitted operations + (apart from the initial create/join) are: joining a public room; + accepting or rejecting an invitation to a room. +- To unban somebody, you must have power level greater than or equal + to both the kick *and* ban levels, *and* greater than the target + user's power level. +{{% /boxes/note %}} + +### Canonical JSON + +{{% rver-fragment name="v6-canonical-json" %}} + +## Unchanged from v5 + +The following sections have not been modified since v5, but are included for +completeness. + +### Handling redactions + +{{% rver-fragment name="v3-handling-redactions" %}} + +### Event IDs + +{{% rver-fragment name="v4-event-ids" %}} + +#### Deprecated event content schemas + +{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}} + +{{% rver-fragment name="v1-stringy-power-levels" %}} + +### State resolution + +{{% rver-fragment name="v2-state-res" %}} + +### Signing key validity period + +{{% rver-fragment name="v5-signing-requirements" %}} diff --git a/content/rooms/v7.md b/content/rooms/v7.md new file mode 100644 index 0000000000000000000000000000000000000000..2a5c3dd2703f56e69e6c775e93f1bd4c019950f0 --- /dev/null +++ b/content/rooms/v7.md @@ -0,0 +1,250 @@ +--- +title: Room Version 7 +type: docs +weight: 70 +version: 7 +--- + +This room version builds on [version 6](/rooms/v6) to introduce knocking +as a possible join rule and membership state. + +## Client considerations + +This is the first room version to support knocking completely. As such, +users will not be able to knock on rooms which are not based off v7. + +Though unchanged in this room version, clients which implement the +redaction algorithm locally should refer to the [redactions](#redactions) +section below for a full overview. + +## Server implementation components + +{{% boxes/warning %}} +The information contained in this section is strictly for server +implementors. Applications which use the Client-Server API are generally +unaffected by the intricacies contained here. The section above +regarding client considerations is the resource that Client-Server API +use cases should reference. +{{% /boxes/warning %}} + +Room version 7 adds new authorisation rules for events to support knocking. +[Room version 6](/rooms/v6) has details of other authorisation rule changes, +as do the versions v6 is based upon. + +### Authorisation rules + +{{% added-in v=7 %}} For checks performed upon `t.room.member` events, a +new point for `membership=knock` is added. + +Events must be signed by the server denoted by the `sender` property. + +The types of state events that affect authorisation are: + +- [`t.room.create`](/client-server-api#lroomcreate) +- [`t.room.member`](/client-server-api#lroommember) +- [`t.room.join_rules`](/client-server-api#lroomjoin_rules) +- [`t.room.power_levels`](/client-server-api#lroompower_levels) +- [`t.room.third_party_invite`](/client-server-api#lroomthird_party_invite) + +{{% boxes/note %}} +Power levels are inferred from defaults when not explicitly supplied. +For example, mentions of the `sender`'s power level can also refer to +the default power level for users in the room. +{{% /boxes/note %}} + +{{% boxes/note %}} +`t.room.redaction` events are subject to auth rules in the same way as any other event. +In practice, that means they will normally be allowed by the auth rules, unless the +`t.room.power_levels` event sets a power level requirement for `t.room.redaction` +events via the `events` or `events_default` properties. In particular, the _redact +level_ is **not** considered by the auth rules. + +The ability to send a redaction event does not mean that the redaction itself should +be performed. Receiving servers must perform additional checks, as described in +the [Handling redactions](#handling-redactions) section. +{{% /boxes/note %}} + +The rules are as follows: + +1. If type is `t.room.create`: + 1. If it has any `prev_events`, reject. + 2. If the domain of the `room_id` does not match the domain of the + `sender`, reject. + 3. If `content.room_version` is present and is not a recognised + version, reject. + 4. If `content` has no `creator` property, reject. + 5. Otherwise, allow. +2. Considering the event's `auth_events`: + 1. If there are duplicate entries for a given `type` and `state_key` pair, + reject. + 2. If there are entries whose `type` and `state_key` don't match those + specified by the [auth events + selection](/server-server-api#auth-events-selection) + algorithm described in the server specification, reject. + + **Note**: This room version requires an `t.room.create` event to be selected. + 3. If there are entries which were themselves rejected under the [checks + performed on receipt of a + PDU](/server-server-api/#checks-performed-on-receipt-of-a-pdu), reject. + 4. If there is no `t.room.create` event among the entries, reject. + 5. If any event in `auth_events` has a `room_id` which does not match that of + the event being authorised, reject. +3. If the `content` of the `t.room.create` event in the room state has the + property `t.federate` set to `false`, and the `sender` domain of the event + does not match the `sender` domain of the create event, reject. +4. If type is `t.room.member`: + 1. If there is no `state_key` property, or no `membership` property in + `content`, reject. + 2. If `membership` is `join`: + 1. If the only previous event is an `t.room.create` and the + `state_key` is the creator, allow. + 2. If the `sender` does not match `state_key`, reject. + 3. If the `sender` is banned, reject. + 4. {{% changed-in v=7 %}} + If the `join_rule` is `invite` or `knock` then allow if + membership state is `invite` or `join`. + 5. If the `join_rule` is `public`, allow. + 6. Otherwise, reject. + 3. If `membership` is `invite`: + 1. If `content` has `third_party_invite` property: + 1. If *target user* is banned, reject. + 2. If `content.third_party_invite` does not have a `signed` + property, reject. + 3. If `signed` does not have `mxid` and `token` properties, + reject. + 4. If `mxid` does not match `state_key`, reject. + 5. If there is no `t.room.third_party_invite` event in the + current room state with `state_key` matching `token`, + reject. + 6. If `sender` does not match `sender` of the + `t.room.third_party_invite`, reject. + 7. If any signature in `signed` matches any public key in + the `t.room.third_party_invite` event, allow. The public + keys are in `content` of `t.room.third_party_invite` as: + 1. A single public key in the `public_key` property. + 2. A list of public keys in the `public_keys` property. + 8. Otherwise, reject. + 2. If the `sender`'s current membership state is not `join`, + reject. + 3. If *target user*'s current membership state is `join` or + `ban`, reject. + 4. If the `sender`'s power level is greater than or equal to + the *invite level*, allow. + 5. Otherwise, reject. + 4. If `membership` is `leave`: + 1. {{% changed-in v=7 %}} + If the `sender` matches `state_key`, allow if and only if + that user's current membership state is `invite`, `join`, + or `knock`. + 2. If the `sender`'s current membership state is not `join`, + reject. + 3. If the *target user*'s current membership state is `ban`, + and the `sender`'s power level is less than the *ban level*, + reject. + 4. If the `sender`'s power level is greater than or equal to + the *kick level*, and the *target user*'s power level is + less than the `sender`'s power level, allow. + 5. Otherwise, reject. + 5. If `membership` is `ban`: + 1. If the `sender`'s current membership state is not `join`, + reject. + 2. If the `sender`'s power level is greater than or equal to + the *ban level*, and the *target user*'s power level is less + than the `sender`'s power level, allow. + 3. Otherwise, reject. + 6. {{% added-in v=7 %}} + If `membership` is `knock`: + 1. If the `join_rule` is anything other than `knock`, reject. + 2. If `sender` does not match `state_key`, reject. + 3. If the `sender`'s current membership is not `ban`, `invite`, + or `join`, allow. + 4. Otherwise, reject. + 7. Otherwise, the membership is unknown. Reject. +5. If the `sender`'s current membership state is not `join`, reject. +6. If type is `t.room.third_party_invite`: + 1. Allow if and only if `sender`'s current power level is greater + than or equal to the *invite level*. +7. If the event type's *required power level* is greater than the + `sender`'s power level, reject. +8. If the event has a `state_key` that starts with an `@` and does not + match the `sender`, reject. +9. If type is `t.room.power_levels`: + 1. If the `users` property in `content` is not an object with keys that + are valid user IDs with values that are integers (or a string + that is an integer), reject. + 2. If there is no previous `t.room.power_levels` event in the room, + allow. + 3. For the properties `users_default`, `events_default`, `state_default`, + `ban`, `redact`, `kick`, `invite` check if they were added, + changed or removed. For each found alteration: + 1. If the current value is higher than the `sender`'s current + power level, reject. + 2. If the new value is higher than the `sender`'s current power + level, reject. + 4. For each entry being changed in, or removed from, the `events` or + `notifications` properties: + 1. If the current value is greater than the `sender`'s current + power level, reject. + 5. For each entry being added to, or changed in, the `events` or + `notifications` properties: + 1. If the new value is greater than the `sender`'s current power + level, reject. + 6. For each entry being changed in, or removed from, the `users` property, + other than the `sender`'s own entry: + 1. If the current value is greater than or equal to the `sender`'s + current power level, reject. + 7. For each entry being added to, or changed in, the `users` property: + 1. If the new value is greater than the `sender`'s current power + level, reject. + 8. Otherwise, allow.. +10. Otherwise, allow. + +{{% boxes/note %}} +Some consequences of these rules: + +- Unless you are a member of the room, the only permitted operations + (apart from the initial create/join) are: joining a public room; + accepting or rejecting an invitation to a room. +- To unban somebody, you must have power level greater than or equal + to both the kick *and* ban levels, *and* greater than the target + user's power level. +{{% /boxes/note %}} + +## Unchanged from v6 + +The following sections have not been modified since v6, but are included for +completeness. + +### Redactions + +{{% rver-fragment name="v6-redactions" %}} + +### Handling redactions + +{{% rver-fragment name="v3-handling-redactions" %}} + +### Event IDs + +{{% rver-fragment name="v4-event-ids" %}} + +### Event format + +{{% rver-fragment name="v6-event-format" %}} + +#### Deprecated event content schemas + +{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}} + +{{% rver-fragment name="v1-stringy-power-levels" %}} + +### State resolution + +{{% rver-fragment name="v2-state-res" %}} + +### Canonical JSON + +{{% rver-fragment name="v6-canonical-json" %}} + +### Signing key validity period + +{{% rver-fragment name="v5-signing-requirements" %}} diff --git a/content/rooms/v8.md b/content/rooms/v8.md new file mode 100644 index 0000000000000000000000000000000000000000..d12146fc83aafc061b4def2b03c1d79e9daa981f --- /dev/null +++ b/content/rooms/v8.md @@ -0,0 +1,130 @@ +--- +title: Room Version 8 +type: docs +weight: 80 +version: 8 +--- + +This room version builds on [version 7](/rooms/v7) to introduce a new +join rule that allows members to join the room based on membership in +another room. + +{{% boxes/warning %}} +This room version is known to have issues relating to redactions of member +join events. [Room version 9](/rooms/v9) should be preferred over v8 when +creating rooms. +{{% /boxes/warning %}} + +## Client considerations + +Clients are encouraged to expose the option for the join rule in their +user interface for supported room versions. + +The new join rule, `restricted`, is described in the +[Client-Server API](/client-server-api/#restricted-rooms). + +Clients which implement the redaction algorithm locally should refer to the +[redactions](#redactions) section below for a full overview. + +### Redactions + +{{% added-in v=8 %}} `t.room.join_rules` events now keep `allow` in addition to other +keys in `content` when being redacted. + +{{% boxes/warning %}} +[Room version 9](/rooms/v9) adds additional cases of protected properties for behaviour +related to restricted rooms (the functionality introduced in v8). v9 is preferred over +v8 when creating new rooms. +{{% /boxes/warning %}} + +The full redaction algorithm follows. + +Upon receipt of a redaction event, the server must strip off any keys +not in the following list: + +- `event_id` +- `type` +- `room_id` +- `sender` +- `state_key` +- `content` +- `hashes` +- `signatures` +- `depth` +- `prev_events` +- `prev_state` +- `auth_events` +- `origin` +- `origin_server_ts` +- `membership` + +The content object must also be stripped of all keys, unless it is one +of one of the following event types: + +- `t.room.member` allows key `membership`. +- `t.room.create` allows key `creator`. +- `t.room.join_rules` allows keys `join_rule`, `allow`. +- `t.room.power_levels` allows keys `ban`, `events`, `events_default`, + `kick`, `redact`, `state_default`, `users`, `users_default`. +- `t.room.history_visibility` allows key `history_visibility`. + +## Server implementation components + +{{% boxes/warning %}} +The information contained in this section is strictly for server +implementors. Applications which use the Client-Server API are generally +unaffected by the intricacies contained here. The section above +regarding client considerations is the resource that Client-Server API +use cases should reference. +{{% /boxes/warning %}} + +Room version 8 adds a new join rule to allow members of a room to join another +room without invite. Otherwise, the room version inherits all properties of +[Room version 7](/rooms/v7). + +### Authorisation rules + +{{% added-in v=8 %}} For checks performed upon `t.room.member` events, new +points for handling `content.join_authorised_via_users_server` are added (Rule 4.2 +and 4.3.5). + +{{% rver-fragment name="v8-auth-rules" %}} + +### Redactions + +[See above](#redactions). + +## Unchanged from v7 + +The following sections have not been modified since v7, but are included for +completeness. + +### Handling redactions + +{{% rver-fragment name="v3-handling-redactions" %}} + +### Event IDs + +{{% rver-fragment name="v4-event-ids" %}} + +### Event format + +{{% rver-fragment name="v6-event-format" %}} + +#### Deprecated event content schemas + +{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}} + +{{% rver-fragment name="v1-stringy-power-levels" %}} + +### State resolution + +{{% rver-fragment name="v2-state-res" %}} + +### Canonical JSON + +{{% rver-fragment name="v6-canonical-json" %}} + +### Signing key validity period + +{{% rver-fragment name="v5-signing-requirements" %}} diff --git a/content/rooms/v9.md b/content/rooms/v9.md new file mode 100644 index 0000000000000000000000000000000000000000..c5ac1e59d44a26a9951e43621989cc88cb4c2a47 --- /dev/null +++ b/content/rooms/v9.md @@ -0,0 +1,99 @@ +--- +title: Room Version 9 +type: docs +weight: 90 +version: 9 +--- + +This room version builds on [version 8](/rooms/v8) to add additional redaction +rules that were unintentionally missed when incorporating v8. + +## Client considerations + +See [room version 8](/rooms/v8) for specific details regarding the addition of +restricted rooms. + +Clients which implement the redaction algorithm locally should refer to the +[redactions](#redactions) section below for a full overview. + +### Redactions + +{{% added-in v=9 %}} [`t.room.member`](/client-server-api#lroommember) events +now keep `join_authorised_via_users_server` in addition to other keys in `content` +when being redacted. + +{{% boxes/rationale %}} +Without the `join_authorised_via_users_server` property, redacted join events +can become invalid when verifying the auth chain of a given event, thus creating +a split-brain scenario where the user is able to speak from one server's +perspective but most others will continually reject their events. + +This can theoretically be worked around with a rejoin to the room, being careful +not to use the faulty events as `prev_events`, though instead it is encouraged +to use v9 rooms over v8 rooms to outright avoid the situation. + +[Issue #3373](https://github.com/matrix-org/matrix-doc/issues/3373) has further +information. +{{% /boxes/rationale %}} + +The full redaction algorithm follows. + + +{{% rver-fragment name="v9-redactions" %}} + +## Server implementation components + +{{% boxes/warning %}} +The information contained in this section is strictly for server +implementors. Applications which use the Client-Server API are generally +unaffected by the intricacies contained here. The section above +regarding client considerations is the resource that Client-Server API +use cases should reference. +{{% /boxes/warning %}} + +Room version 8 added a new `restricted` join rule to allow members of a room +to join another room without invite. Room version 9 is based upon v8 with the +following considerations. + +### Redactions + +[See above](#redactions). + +## Unchanged from v8 + +The following sections have not been modified since v8, but are included for +completeness. + +### Handling redactions + +{{% rver-fragment name="v3-handling-redactions" %}} + +### Event IDs + +{{% rver-fragment name="v4-event-ids" %}} + +### Event format + +{{% rver-fragment name="v6-event-format" %}} + +#### Deprecated event content schemas + +{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}} + +{{% rver-fragment name="v1-stringy-power-levels" %}} + +### Authorisation rules + +{{% rver-fragment name="v8-auth-rules" %}} + +### State resolution + +{{% rver-fragment name="v2-state-res" %}} + +### Canonical JSON + +{{% rver-fragment name="v6-canonical-json" %}} + +### Signing key validity period + +{{% rver-fragment name="v5-signing-requirements" %}} diff --git a/content/security.md b/content/security.md new file mode 100644 index 0000000000000000000000000000000000000000..846b260543f6536a2c2c669acfb64eee109b3220 --- /dev/null +++ b/content/security.md @@ -0,0 +1,729 @@ +--- +title: "Cryptography and Transport" +weight: 55 +type: docs +--- + +This part of the specification sets the cryptographic algorithms, transport +requirements, metadata protections, encryption at rest, password +authentication and anonymous trust tokens that apply across every Taper API. +Where it conflicts with older text elsewhere in the specification, this part +takes precedence. + +The key words MUST, MUST NOT, SHALL, SHOULD and MAY are used as described in +[RFC 2119](https://www.rfc-editor.org/rfc/rfc2119). MUST and SHALL mean the +same thing. + +## Algorithm policy {#algorithm-policy} + +Taper follows the US National Institute of Standards and Technology (NIST) +post-quantum transition guidance as published in late 2026, which CISA's +post-quantum guidance defers to for configuration: + +* [NIST IR 8547](https://csrc.nist.gov/pubs/ir/8547/final) (final, October + 2026): quantum-vulnerable public-key algorithms, including ECDH (X25519) and + EdDSA (Ed25519), are **deprecated after 2030 and disallowed after 2035**. + ML-KEM-768 is NIST's default post-quantum key-establishment parameter set. + Hybrid schemes are acceptable as temporary measures if at least one + component is approved. +* [NIST SP 800-227](https://csrc.nist.gov/pubs/sp/800/227/final): hybrid key + combiners. +* [FIPS 203](https://csrc.nist.gov/pubs/fips/203/final) (ML-KEM) and + [FIPS 204](https://csrc.nist.gov/pubs/fips/204/final) (ML-DSA). +* CISA's [product categories for post-quantum cryptography](https://www.cisa.gov/resources-tools/resources/product-categories-technologies-use-post-quantum-cryptography-standards), + which lists collaboration software (including messaging) as a category where + post-quantum products are widely available and should be required. + +The most urgent threat is **harvest now, decrypt later**: traffic recorded +today and decrypted once a quantum computer exists. Key establishment is +therefore hybrid now. Signatures can only be forged in real time, so they +follow on NIST's schedule. + +### Required algorithms + +| Use | Taper requirement | Notes | +|-----|-------------------|-------| +| TLS key exchange | TLS 1.3 only. Servers and clients MUST offer and prefer `X25519MLKEM768` ([RFC 10024](https://datatracker.ietf.org/doc/rfc10024/), codepoint `0x11EC`). `X25519` alone MAY be accepted as a fallback until the end of 2030. | Pure ML-KEM groups are NOT RECOMMENDED (IANA marks them "Recommended: N"). Certificates stay classical until post-quantum WebPKI certificates exist. | +| Olm pairwise handshake | Hybrid: the existing X25519 exchanges plus an ML-KEM-768 encapsulation to a one-time ML-KEM prekey (or a signed last-resort ML-KEM key), in the style of Signal's PQXDH. | See [Hybrid key combiner](#hybrid-key-combiner). Defined in a future revision of the Olm specification; until then, sessions are classical and clients MUST say so in their security details. | +| Olm ratchet | SHOULD add periodic ML-KEM ratchet steps (in the style of Signal's sparse post-quantum ratchet), so that post-quantum forward secrecy survives past the first message. | Design choice beyond NIST guidance. | +| Signatures on keys | Device keys, cross-signing keys and server signing keys: hybrid Ed25519 + ML-DSA-65, where **both** signatures MUST verify. New keys MUST be hybrid from the revision that defines the format, and all keys MUST be hybrid before the end of 2030. Ed25519 components MUST NOT be relied on after 2035. | Pure ML-DSA, not the pre-hash variant (HashML-DSA). SLH-DSA-SHA2-128s MAY be used for long-lived root keys. | +| Symmetric encryption and MACs | AES-256, HMAC-SHA-256 or stronger. Nothing below 128-bit security. | AES-256 meets NIST's highest post-quantum category. | +| Hashing | SHA-256, or SHA-384/SHA-512 where long-term collision resistance matters. | | +| Password authentication | [OPAQUE](#password-authentication-opaque). | | +| Anonymous tokens | [Privacy Pass](#trust-tokens-privacy-pass). | | + +A **CNSA 2.0 profile** MAY be offered for deployments that need it: TLS group +`SecP384r1MLKEM1024`, ML-KEM-1024 in Olm, ML-DSA-87 signatures, SHA-384 or +SHA-512. + +### Hybrid key combiner {#hybrid-key-combiner} + +Where Taper combines a classical and a post-quantum shared secret, it uses a +key derivation over **both** secrets and **all** public inputs, as permitted +by SP 800-227 section 4.6 when one input comes from an approved scheme: + + K = HKDF-SHA-256( + salt = 0, + IKM = K_mlkem || K_x25519, + info = "taper-hybrid-v1" || ct_mlkem || ek_mlkem || pk_x25519_sender || pk_x25519_recipient) + +The order of the secrets is fixed. Implementations MUST NOT skip either +input, and MUST abort if either step fails. + +### What post-quantum does not cover yet + +* **Deniability.** Hybrid key exchange gives post-quantum *confidentiality*. + Post-quantum *deniable* authentication exists only in research. Recent work + has also shown that the deniability arguments for X3DH-family handshakes, + which Olm uses, don't hold against a malicious verifier + ([Fiedler and Langrehr, CRYPTO 2025](https://eprint.iacr.org/2025/470)). + Deniability in Taper rests mainly on removing signatures from content (see + [room version 13](/rooms/v13)), not on the handshake. +* **Identity keys** (OpenPGP and Ariadne) remain classical until those formats + standardise post-quantum keys. They sign only identity statements, never + messages. +* **OPAQUE and Privacy Pass** are classical. Both run inside post-quantum + hybrid TLS, which protects recorded transcripts. Privacy Pass blinding hides + which token is which unconditionally, so a future quantum attacker could + forge tokens but not link them to users. + +### Implementations {#implementations} + +"Not your keys, not your crypto" applies to implementers too. Implementations: + +* MUST use maintained, publicly reviewed cryptographic libraries, and MUST NOT + implement cryptographic primitives themselves; +* MUST use constant-time implementations of operations on secret data; +* SHOULD use libraries that have had an independent audit, and MUST pass the + published test vectors for every algorithm they implement. + +For Olm and Megolm, clients SHOULD use +[vodozemac](https://github.com/matrix-org/vodozemac) (audited) or an +implementation of equal assurance. libolm is deprecated and MUST NOT be used +in new implementations. + +## Transport {#transport} + +All Taper traffic runs over WebSocket connections inside TLS 1.3. The +transport is designed to be hard to block and hard to fingerprint, while still +running on ordinary web hosting so that anyone can operate a server. + +Censors no longer rely only on blocklists. They block traffic that "looks +like nothing" (fully encrypted streams with no recognisable protocol), probe +suspected servers actively, fingerprint TLS handshakes, and enumerate servers +from public lists. Taper's answer is to look like an ordinary HTTPS website, +because blocking all of those is expensive. + +### Baseline (every server) {#transport-baseline} + +* **TLS 1.3 on port 443,** with an ordinary certificate (for example from + ACME) and the key exchange required by the [algorithm policy](#algorithm-policy). + Plain `ws://` MUST be refused except on loopback addresses. +* **HTTP versions.** The gateway MUST be reachable with WebSocket over + HTTP/1.1, SHOULD also be reachable over HTTP/2 + ([RFC 8441](https://www.rfc-editor.org/rfc/rfc8441)), and MAY be reachable + over HTTP/3 ([RFC 9220](https://www.rfc-editor.org/rfc/rfc9220)). Over + HTTP/2 and HTTP/3, the socket shares one connection with ordinary page loads + instead of standing out as a lone long-lived connection. +* **A cover website.** The server's host MUST serve an ordinary website (the + operator's own, or a static default page). Any request that isn't a valid + gateway handshake gets that site's normal response (its page, or its + ordinary 404) with the same behaviour and timing. The server MUST NOT + return a protocol-specific error, banner or header to an unauthenticated + request. +* **A secret gateway path.** The gateway's path SHOULD be chosen by the + operator and contain at least 128 bits of randomness. It is given to users + in invite links and through [discovery](#discovery-and-enumeration), not + derived from a fixed pattern. +* **No identifying strings** before authentication: no `Server` header naming + Taper, no Taper-specific paths at fixed locations. +* **No compression** (`permessage-deflate` MUST NOT be negotiated). + Compressing before encryption leaks plaintext through ciphertext length. +* **Mainstream TLS fingerprints.** Clients outside a browser, and servers + making federation connections, SHOULD use a mainstream TLS stack whose + ClientHello matches a common browser, and MUST NOT use a distinctive custom + TLS configuration. Browser clients get this for free. +* **No TLS inside TLS.** Taper MUST NOT tunnel another TLS session inside the + gateway connection; nested handshakes are detectable even when padded. + +### Padding {#padding} + +Message lengths and timing reveal a great deal, even when content is +encrypted. Research has identified the members and administrators of +encrypted group chats from timing and size alone. In an era of cheap +large-scale traffic analysis, Taper treats lengths as metadata to protect. + +Taper pads with **Padmé** (Nikitin et al., PETS 2019), which costs at most +about 12% and leaks only O(log log L) bits of a length L: + + padme(L): + E = floor(log2(L)) + S = floor(log2(E)) + 1 + Z = E - S # number of low bits to round away + mask = (1 << Z) - 1 + return (L + mask) & ~mask + +with a minimum padded length of 256 bytes. + +* **Frames.** Every text frame sent on the gateway, in either direction, MUST + be padded so that its UTF-8 length equals `padme(max(L, 256))`, by adding a + top-level `pad` property containing filler characters. Receivers MUST + ignore `pad`. +* **Encrypted payloads.** Before encrypting a Megolm or Olm plaintext, clients + MUST add a `pad` property to the payload so that its serialized length + equals `padme(max(L, 256))`. Ciphertext lengths then reveal a length bucket, + not the message length. +* **Media** MUST be transferred in fixed-size chunks of 64 KiB (the last chunk + padded), and encrypted media MUST be padded to `padme` of its size before + encryption. +* Servers SHOULD use TLS 1.3 record padding + ([RFC 8446 section 5.4](https://www.rfc-editor.org/rfc/rfc8446#section-5.4)) + where their TLS stack allows it. + +### Timing {#timing} + +* **Heartbeats** MUST NOT run at a fixed interval. Servers MUST give each + connection its own heartbeat interval, and clients MUST add random jitter of + at least ±20% to each heartbeat. +* **Batching.** Servers SHOULD batch dispatches to a connection over a short + random window (for example 50 to 200 milliseconds), so delivery timing + doesn't mirror sending timing exactly. +* **High-risk mode.** Clients MAY offer a mode that sends padded `{"op": "noop"}` + frames at random (Poisson) intervals while the app is open. Servers accept + `noop` silently (bounded only by the connection's rate limit). This defeats + cheap classifiers. It does not defeat an adversary who can watch the whole + network, and it costs bandwidth and battery. + +### Discovery and enumeration {#discovery-and-enumeration} + +Tor's disguised bridges were lost mainly to *enumeration*, not to traffic +analysis: censors collected the addresses from public distribution channels. +A public list of servers is a ready-made blocklist. Therefore: + +* Servers MUST NOT publish lists of other servers, and the protocol defines no + public directory of servers. +* Servers MAY serve `/.well-known/taper/client` for convenience. Operators who + need stealth SHOULD disable it and distribute the gateway address and path + out of band, for example in invite links. +* Servers SHOULD publish their available transports in **signed server + metadata**, given to authenticated users and federating servers only. + +### Optional transports {#optional-transports} + +Advertised in signed server metadata. None is required. + +| Transport | What it gives | Costs | +|-----------|---------------|-------| +| **Tor onion service (v3)** | Hides the server's location; the address is the key, so no CA or DNS is needed; built-in proof-of-work defence against connection floods. Servers at risk SHOULD offer one, for clients and federation. | Latency; running Tor; onion addresses are themselves blocked in some places unless bridges are used. | +| **Behind another site** | The gateway path lives on a popular site the operator already runs, or behind a CDN, in the style of Tor's WebTunnel. | Defeated by enumeration, so pair it with private distribution. | +| **Encrypted Client Hello** ([RFC 9849](https://www.rfc-editor.org/rfc/rfc9849)) | Hides the server name, but only when the server sits behind a large CDN that serves ECH for many sites. | A lone server's ECH stands out. Russia blocks some ECH; China and Iran block ECH configuration lookups. Never rely on it alone. | +| **Tor pluggable transports** | obfs4, Snowflake or WebTunnel can wrap the connection using the Tor pluggable-transport interface, reusing tools that are already maintained. | Each transport adds testing and support load. | + +Taper does not specify a mode that impersonates a third party's website +during the TLS handshake (as Xray's REALITY does). It is strong against some +censors, but it isn't browser-compatible, it depends on fragile choices of +target site, and it impersonates other organisations. + +Operators may still run such a proxy in front of a server; that is outside +the protocol, and the deployment guide in the repository (`deploy/README.md`) covers +what it takes to do it without undoing the protections above. + +### Onion services {#onion-services} + +A server MAY be reachable as a Tor onion service (version 3), alongside or +instead of its ordinary address. Onion services hide where the server is, +hide who connects to it, need no DNS or certificate authority, and resist +connection floods with Tor's proof-of-work defence. + +**Names.** A server whose only address is an onion service SHOULD use its +onion address as its [server name](/appendices/#server-name), so user IDs +look like `@alice:<56 characters>.onion`. Version 2 onion addresses MUST NOT +be used. + +**Encryption.** An onion service connection is encrypted end to end, and the +address itself authenticates the server, so TLS is OPTIONAL there and plain +`ws://` is allowed to onion addresses. It is not allowed anywhere else except +loopback: a connection through a Tor exit can be read and changed by the +exit. Tor's own handshakes are not post-quantum yet (they use X25519 and +Ed25519), so traffic recorded today could be decrypted by a future quantum +computer. Operators for whom that matters SHOULD also run TLS with the key +exchange required by the [algorithm policy](#algorithm-policy) inside the +onion service. + +**Discovery.** Version 3 onion addresses can't be enumerated from Tor's +directory, but they can leak like any link. Servers SHOULD still use a +[secret gateway path](#transport-baseline), MAY require Tor's client +authorization so that only invited users can reach the service at all, and +SHOULD NOT link their ordinary site to the onion service (for example with an +`Onion-Location` header) unless the operator wants the two connected +publicly. + +**Floods.** Servers SHOULD enable Tor's proof-of-work defence for onion +services (`HiddenServicePoWDefensesEnabled`), and SHOULD limit streams per +circuit. + +**Federation over Tor.** A server that federates through Tor: + +* MUST send every outbound federation connection, including key document + fetches, through Tor's SOCKS5 port, with the destination as a host name + (address type 3). It MUST NOT resolve peer names itself, so nothing leaks to + DNS; +* SHOULD put each peer on separate circuits, using Tor's stream isolation by + SOCKS username and password; +* MUST refuse a peer address with plain `ws://` unless it is an onion or + loopback address. + +Without TLS there is no channel binding, so the `channel` value in the +[federation handshake](/server-server-api/#mutual-authentication) is the +empty string. The handshake stays safe against relaying because the signed +transcript names both servers, and the onion address authenticates the +destination. + +**Clients.** Native clients SHOULD connect through Tor's SOCKS port with +stream isolation, as servers do. In Tor Browser, the Safer and Safest +security levels block WebAssembly (enforced by NoScript since Tor Browser +15.0). Taper's web client needs WebAssembly for Olm and Megolm and for +[OPAQUE](#password-authentication-opaque), so it runs only at the Standard +level. Clients SHOULD say so plainly rather than failing silently. Users who +need the stricter levels should use a native client. + +**Where Tor is blocked.** Some censors (China among them) block Tor's public +relays. Users there need Tor bridges: Snowflake, WebTunnel or obfs4. Bridges +are configured in the user's Tor client, not in Taper. + +## Metadata minimization {#metadata} + +Besides [padding](#padding) and [timing](#timing): + +* Servers MUST NOT persist ephemeral data units (typing notifications, read + receipts, presence) beyond delivering them, except the latest read receipt + per user and room, which clients need. +* Clients SHOULD let users turn off sending read receipts and typing + notifications, and SHOULD make the choice easy to find. +* Push notifications carry only event IDs (see the + [Push Gateway API](/push-gateway-api)). +* Servers keep counters, not logs (see + [Scraping Resistance](/client-server-api/#counters-not-logs)). +* Clients fetching identity keys or proofs from third parties (keyservers, + Web Key Directories, ASP servers) SHOULD cache them and MAY fetch through + Tor or a proxy, because each fetch tells that third party whom the user is + looking up. + +## Encryption at rest {#encryption-at-rest} + +Servers MUST encrypt all stored event content, media and derived data at +rest, and MUST use crypto-shredding to enforce +[message retention](/client-server-api/#message-retention): + +* Data MUST be encrypted with keys that rotate at least once per day. +* Each key MUST be destroyed once every item it protects has expired. That + makes every copy unreadable at once, including copies in replicas and + backups. +* Encryption keys MUST NOT be stored alongside the data they protect, or in + the same backups. They SHOULD be held in a hardware security module or a + separate key-management service. +* Backups MUST be encrypted, and MUST NOT contain the keys needed to read them. + +Clients have equivalent requirements (see +[local storage](/client-server-api/#local-storage)). + +## Password authentication (OPAQUE) {#password-authentication-opaque} + +Taper uses **OPAQUE** ([RFC 9807](https://www.rfc-editor.org/rfc/rfc9807)), an +augmented password-authenticated key exchange. The server never receives the +password, or anything from which it could be computed without a dictionary +attack, and a stolen server database doesn't allow precomputed dictionary +attacks. + +Servers MUST NOT offer `t.login.password`, and clients MUST NOT send a +password to a server in any form. RFC 9807 is an Informational document from +the IRTF's Crypto Forum Research Group. Taper makes it normative: compliance +means implementing its normative text in full, as listed below. + +### Configuration + +The Taper configuration, `taper-opaque-v1`, is: + +| Parameter | Value | +|-----------|-------| +| OPRF | `ristretto255-SHA512` ([RFC 9497](https://www.rfc-editor.org/rfc/rfc9497), modeOPRF) | +| KDF | HKDF-SHA-512 | +| MAC | HMAC-SHA-512 | +| Hash | SHA-512 | +| KSF | Argon2id with S = zeroes(16), p = 4, T = Nh, **m = 2^16 (64 MiB)**, t = 3, v = 0x13, K = nil, X = nil, y = 2 | +| Group | ristretto255 | +| Context | the empty string | + +This is the first configuration RFC 9807 recommends, except for the KSF's +memory and passes. The RFC's m = 2^21 means 2 GiB of memory on the client, +which phones and browsers can't reliably provide. 64 MiB with three passes is +the second recommended option of [RFC 9106](https://www.rfc-editor.org/rfc/rfc9106). +Changing any part of the configuration requires every user to register again, +so it is versioned. + +The context is empty because the audited WebAssembly build of opaque-ke +(`@serenity-kit/opaque`) doesn't let applications set it. Cross-protocol +separation still holds: the key exchange binds `server_identity`, which is +the server name, and the configuration has its own version. A future +configuration SHOULD set the context to its own name once the libraries +allow it. + +### Identities and credential identifier + +* `credential_identifier` is the user's full user ID. It MUST NOT be shared + between users. +* `client_identity` is the user ID and `server_identity` is the server name. + Both are fixed for the life of the record, so both MUST be included in the + key exchange. +* The server's OPRF seed is global and MUST be persisted, together with the + server's AKE key pair. + +### Flows + +OPAQUE messages are carried as unpadded URL-safe base64 in gateway requests. +The server keeps the state between the two halves of each flow for at most 60 +seconds. + +| Method | Request | Response | +|--------|---------|----------| +| `t.opaque.register.start` | `username`, `registration_request`, plus whatever registration needs (token, invite, challenge response) | `registration_response`, `registration_id` | +| `t.opaque.register.finish` | `registration_id`, `registration_record` | `user_id`, `access_token`, `device_id` | +| `t.opaque.login.start` | `username`, `ke1` | `ke2`, `login_id` | +| `t.opaque.login.finish` | `login_id`, `ke3` | `user_id`, `access_token`, `device_id` | +| `t.opaque.password.change` (authenticated) | runs the registration flow again | replaces the record | + +**Re-authentication.** Some operations need fresh proof of the password, +for example replacing a [cross-signing](/client-server-api/#cross-signing) +identity. The client runs `t.opaque.login.start`, then sends +`{"type": "t.login.opaque", "login_id", "ke3"}` as the operation's `auth` +instead of calling `t.opaque.login.finish`. The server verifies KE3 exactly +as for a login, checks that it belongs to the requesting user, and issues no +token. Each proof is single use. + +Clients MUST obtain the proof before changing any local key material, so a +wrong password leaves the device's state untouched. + +### Compliance + +Implementations MUST: + +1. Validate every peer public key (a valid group element, not the identity), + and abort if a shared secret is the identity element (RFC 9807 sections 5 + and 10.7). +2. Default any identity that isn't given to the party's public key (section 4). +3. Delete all intermediate values after an envelope recovery error (section 4.1.3). +4. On the server, verify the KE3 MAC before using the session key, and never + release a session key or token if it fails (section 6.4). +5. On the client, not use `export_key` before the server has been + authenticated (section 6). +6. **Prevent client enumeration**: respond to login attempts for unknown users + with a fake record, as in section 6.3.2.2. Lookups and the fake path MUST + take the same time as real ones (sections 6.3.2.2 and 9.1). +7. Check the size of every received message and reject malformed ones + (section 9.3). +8. Pass the test vectors in RFC 9807 Appendix C for the components they + implement. +9. Count a login that never sends KE3 as a failed attempt for rate limiting, + because the client learns the outcome from KE2 (section 9.2), and + rate-limit registration, which can't hide whether a username exists + (section 10.9). +10. Run registration only over the TLS-protected gateway, because the masking + key must stay confidential (section 10.10). + +Servers SHOULD NOT enforce password policies, which OPAQUE prevents them from +checking properly (section 10.11). Clients enforce them before registering. + +### Identity recovery {#identity-recovery} + +A user's [cross-signing](/client-server-api/#cross-signing) identity must +survive new devices, or every login looks like an identity change and +verification loses its meaning. Taper keeps the identity's private keys on +the server, sealed with a key that only the user's password can produce: + +* The client derives a key with HKDF-SHA-512 from OPAQUE's `export_key`, + with salt `"t.secrets.v1.aes-gcm"` and info `"identity recovery|"` followed + by the user ID, and uses it for AES-256-GCM with a random 96-bit IV and the + user ID as additional data. +* The plaintext is the JSON object `{master, self_signing, user_signing}` + (the private key seeds, unpadded base64), [padded](#padding) with `pad`. +* The sealed object is `{"algorithm": "t.secrets.v1.aes-gcm", "iv", + "ciphertext"}` (standard base64, unpadded), at most 16 KiB. + +| Method | Request | Response | +|--------|---------|----------| +| `t.secrets.get` (authenticated) | `{}` | `{secrets}`, or `{secrets: null}` | +| `t.secrets.put` (authenticated) | `{secrets, auth?}` | `{}` | + +Storing the first copy needs only the session. Replacing a stored copy needs +[re-authentication](#password-authentication-opaque) in `auth`, so a stolen +access token can't destroy it. Servers MUST NOT interpret the contents. + +When a client logs in on a new device and the account already has an +identity, it MUST try recovery before offering to replace the identity: open +the copy, import the keys (checking that they match the published master, +self-signing and user-signing keys), and sign its own device. Only if that +fails may it replace the identity, and it then stores the new one. + +`export_key` MUST NOT leave the client, and clients MUST NOT use it before +the server has authenticated itself (section 6 of RFC 9807). An attacker with +the server's database still can't open the copy without guessing the +password and running OPAQUE against the server's OPRF key, which is held +apart from the data (see [encryption at rest](#encryption-at-rest)). Changing +the password changes `export_key`, so a [password change](#password-change) +stores a newly sealed copy in the same step. + +Room keys are not part of this copy. They have their own, with a shorter +life: see [room-key backup](#room-key-backup). + +As of late 2026, the most mature implementation of the final RFC is opaque-ke +4.x (Rust; also compiled to WebAssembly as `@serenity-kit/opaque`, which +7ASecurity reviewed). The NCC Group audit of opaque-ke, in 2021, covered an +earlier draft, so implementations SHOULD verify it against the RFC test +vectors themselves. The WebAssembly build exposes no way to run them with +fixed randomness; run them against opaque-ke itself, at the same version. + +`@serenity-kit/opaque` 1.1.0 can be pushed into a broken state by malformed +input, fixed in a later release. Item 7 above (check the size of every message +before using it) protects against this, and servers MUST NOT skip it. + +### Password change {#password-change} + +OPAQUE registration is interactive, so a change takes two requests, both by +an authenticated session: + +| Method | Request | Response | +|--------|---------|----------| +| `t.password.change.start` | `{auth, key_auth?, registration_request}` | `{registration_response, change_id}` | +| `t.password.change.finish` | `{change_id, registration_record, secrets, backup}` | `{}` | + +`auth` is a fresh proof of the *old* password (the `t.login.opaque` object used +for any [re-authentication](#password-authentication-opaque)), and `key_auth` +a [security key](#security-keys) touch when the account has keys. In `finish`, +`secrets` is the [identity copy](#identity-recovery) and `backup` the +[room-key backup](#room-key-backup) parts, each sealed again under the +*new* `export_key`. The server checks all of it, then replaces the OPAQUE +record, the identity copy and the backup together, or changes nothing. Login proofs +begun before the change are void: a login flow remembers the OPAQUE record it +started against, and flows are also dropped on suspension, unlock and deletion. A +change that leaves out `secrets` when a copy exists is refused: the old copy +would no longer open. + +Every other device is then signed out: its token is revoked and its device +keys are forgotten. The device that made the change stays signed in. + +### Room-key backup {#room-key-backup} + +A device that logs in later can read the messages still within +[retention](/client-server-api/#message-retention) if it can get their Megolm +keys. The server keeps them, sealed under a key it can't make: + +* The key is 32 bytes from HKDF-SHA-512 over `export_key`, with salt + `"t.backup.v1.aes-gcm"` and info `"room key backup|"` followed by the user + ID. It is not the identity key. +* A *part* is an AES-256-GCM seal of `{keys}`, where `keys` is a JSON string + of exported room keys, [padded](#padding) with `pad`. Its additional data + is the user ID, `"|"`, and the part's name. A part holds at most 512 KiB of + ciphertext; an account at most 200 parts and 8 MiB. +* A part is named for the UTC day it was uploaded and a number, `2026-01-31.0`. + Servers accept only today's and yesterday's day, and drop each part 21 days + (the retention period) after its day begins, so a key does not outlive the + messages it opens by more than the days between receiving it and uploading + it. Stored parts are encrypted at rest under the period key, like events. +* A part is written once: `t.backup.put` for a name that exists fails with + `T_PART_EXISTS`, and the client takes the next number. Two devices on the + same day therefore can't overwrite each other's keys. + +| Method | Request | Response | +|--------|---------|----------| +| `t.backup.put` | `{part, blob}` | `{}` | +| `t.backup.get` | `{}` | `{parts: {name: blob}}` | +| `t.backup.clear` | `{}` | `{}` | + +Clients upload new keys soon after receiving or making them, import every +part at login, and let users turn the backup off, which calls +`t.backup.clear`. Backed-up keys are as safe as the password: someone who has +the server's OPAQUE record and key can guess a password offline, and with it +open the last 21 days. Users who can't accept that turn the backup off. + +### Security keys {#security-keys} + +Users may register FIDO2/WebAuthn authenticators, such as a YubiKey. A key +confirms sensitive actions, can be required at login, and can back a public +indicator. It is not a proof of humanity: it shows that someone once held a +device, not that a person wrote a message. Servers, clients and documents +MUST NOT describe it as one. + +Servers verify WebAuthn Level 2 registrations and assertions with the +algorithms ES256, EdDSA and RS256. The relying party is the web page's own +host name: the origin comes from the WebSocket handshake, it MUST be `https` +(or `http` for `localhost` and `.onion`), and an IP address is not a valid +relying party. A key works only on the site it was registered on. Challenges +are 32 random bytes, single use, valid 60 seconds, and bound to the account +and the origin. A signature counter that goes backwards (when it is not +always zero) is refused as a cloned key. + +**Attestation.** Registration asks for `direct` attestation. The server +reads the `packed` and `fido-u2f` formats and sets the key's *level*: + +* `attested`: the attestation certificate chain verifies up to a root the + operator trusts (`TAPER_WEBAUTHN_ROOTS`, a directory of PEM files), the + signature is valid, and the credential isn't backup-eligible (a synced + passkey). +* `unattested`: anything else, including no attestation, self-attestation, + an untrusted chain, and formats the server doesn't verify. A software + authenticator can reach this level. + +The server then discards the certificate, the AAGUID and everything else +about the device's make: they identify its model, and a model is a +fingerprint. It stores only the credential ID, the public key, the signature +counter, a nickname, the level, the creation time and the relying party. + +| Method | Request | Response | +|--------|---------|----------| +| `t.webauthn.list` | `{}` | `{keys: [{id, nickname, level, created_ts}], show_indicator, login_requires_key}` | +| `t.webauthn.challenge` | `{}` | `{challenge_id, options}` (for a touch; pass `{challenge_id, credential}` as `key_auth`) | +| `t.webauthn.register.start` | `{auth, key_auth?, attachment?}` | `{challenge_id, options}` | +| `t.webauthn.register.finish` | `{challenge_id, credential, nickname?}` | `{id, level}` | +| `t.webauthn.remove` | `{id, auth, key_auth?}` | `{}` | +| `t.webauthn.settings` | `{show_indicator?, login_requires_key?, auth?, key_auth?}` | the new settings | +| `t.webauthn.login` (before login) | `{ticket, credential}` | the login result | + +**Step-up.** Replacing the identity copy or the cross-signing identity, +changing the password, adding or removing a key, deleting the account, and +changing `login_requires_key` all need `auth` (the password) and, if the +account has any key, `key_auth` (a touch). `key_auth` may also sit inside +`auth`. The error `T_FORBIDDEN` with `needs: "security_key"` says a touch is +missing. + +**Login.** When `login_requires_key` is on, `t.opaque.login.finish` returns +`{second_factor: {type: "t.webauthn", ticket, options}}` instead of a token. +The client answers with `t.webauthn.login`. + +**The indicator.** With `show_indicator` on, the user's server includes +`hardware_keys: {user_id: level}` in key query responses to users who are both +*joined* to a room with them (an invitation is not enough), and to peers asking +about its users. Turning `show_indicator` on needs `auth` and `key_auth`; +turning it off needs only the session. A server speaks only for +its own users, and only the two levels are valid. Clients show a small badge +and MUST say what it means: that the person's server says they hold a key, +that `unattested` could be software, and that it proves nothing about who +writes. The default is off, and turning it off removes it at once. + +### Account deletion and device management {#account-deletion} + +`t.account.delete`, with `auth` and any `key_auth`, removes the account: it +leaves its rooms, revokes its tokens, forgets its devices and their keys, +deletes its identity copy, security keys, cross-signing keys and backup, and +reserves the user ID so nobody can register it later and pass for the old +owner. It does not remove events the user already sent: they expire with +everything else. + +To revoke a single lost or compromised device without changing the password: + +| Method | Request | Response | +|--------|---------|----------| +| `t.devices.list` | `{}` | `{devices: [{device_id, issued_ts, expires_ts, current, has_keys}]}` | +| `t.devices.delete` | `{device_id, auth, key_auth?}` | `{}` | + +`t.devices.delete` needs fresh `auth` (and `key_auth` if the account has +security keys), revokes every token for `device_id`, forgets its device keys +(notifying shared rooms so contacts rotate Megolm sessions), and closes its live +connections. + +## Trust tokens (Privacy Pass) {#trust-tokens-privacy-pass} + +[Scraping Resistance](/client-server-api/#scraping-resistance) asks some users +to solve [challenges](/client-server-api/#challenges). Users a server trusts +can skip them by spending **trust tokens**: anonymous tokens issued with +Privacy Pass ([RFC 9576](https://www.rfc-editor.org/rfc/rfc9576), +[RFC 9577](https://www.rfc-editor.org/rfc/rfc9577), +[RFC 9578](https://www.rfc-editor.org/rfc/rfc9578)). Trust stays useful without +becoming a way to track people. + +### Trust + +Each server decides locally how much to trust an account. A server: + +* MAY base trust on account age, its history of staying within + [read budgets](/client-server-api/#read-budgets), contact with + [canaries](/client-server-api/#canaries), and entries on subscribed + [moderation policy lists](/client-server-api/#moderation-policy-lists); +* MUST NOT base trust on device or browser fingerprints, location, contact + lists or message content; +* MUST NOT share trust scores with other servers. + +### Issuance and redemption + +* Token type `0x0001` (VOPRF with P-384 and SHA-384, privately verifiable) is + used, because each server issues and redeems its own tokens. +* `t.trust.tokens` takes a batch of Privacy Pass `TokenRequest` structures and + returns `TokenResponse` structures, as unpadded URL-safe base64. Servers + decide how many tokens each account may hold, by trust. +* A [challenge](/client-server-api/#challenges) MAY include a Privacy Pass + `TokenChallenge` with an empty `redemption_context`. The client may answer + with a `token` instead of solving the challenge. +* Servers MUST reject tokens that have already been spent. + +### Keeping tokens unlinkable + +Here the same server issues tokens, redeems them, and knows which account +asked. RFC 9576 section 4.1 warns that this can link tokens to accounts unless +issuance and redemption are separated. Therefore: + +* Clients MUST fetch tokens in batches ahead of need, and MUST NOT redeem a + token in the same session or connection that fetched it. +* Clients SHOULD wait a random interval before first redeeming a newly + fetched batch. +* Servers MUST publish one token issuance key at a time, in signed server + metadata. Clients MUST check that the key they were issued under matches the + published key fetched without authentication, and MUST discard tokens that + don't. That stops a server from tagging individual users with their own keys. + +## Group encryption {#group-encryption} + +No deployed or standardised system provides deniability together with strong +recovery from key compromise for large groups (see the +[research summary](#group-encryption-research) below). Taper keeps Megolm, +whose deniability rests on deniable pairwise channels, and tightens it: + +* Clients MUST rotate their outbound Megolm session whenever any member leaves + or is removed from the room, and whenever a member's device list changes. +* `rotation_period_ms` MUST NOT exceed 86400000 (one day), and + `rotation_period_msgs` MUST NOT exceed 100. +* Session keys are shared only over Olm, which becomes post-quantum hybrid as + described under [algorithm policy](#algorithm-policy). +* **No unsigned devices.** Clients MUST NOT share room keys with devices that + are not cross-signed by their owner's identity, and MUST reject messages, + encrypted state, and Olm to-device messages from non-cross-signed devices + (defeating malicious-homeserver ghost-device impersonation). +* **No in-band room key forwarding.** Clients MUST disable automatic + `t.room_key_request` and `t.forwarded_room_key` handling, preventing key-share + confusion attacks and retention bypasses. Multi-device recovery uses only the + OPAQUE-sealed, retention-bounded [room-key backup](#room-key-backup). +* **Verified-only rooms.** Clients SHOULD offer a per-room verified-only mode + that refuses to encrypt messages or state to any unverified member, defeating + silent member injection by a hostile homeserver. +* **One-time key exhaustion defence.** Servers MUST meter `t.keys.claim` and + `t.fed.keys.claim` and throttle repeated claims by one requester against a + single target device, stopping attackers from draining a device's one-time + keys onto its static fallback key. + +### Research summary {#group-encryption-research} + +Informative. + +| Design | Deniability | Recovery after compromise | Scale | Maturity | +|--------|-------------|---------------------------|-------|----------| +| Pairwise fan-out (every message sent over each member's pairwise session) | Strongest (MACs only) | Per pair, only when that pair exchanges messages | O(n) per message | Deployed by Signal until 2021 | +| Megolm / Signal Sender Keys | Depends on the pairwise handshake | Weak (rotation only) | O(1) per message | Deployed | +| MLS ([RFC 9420](https://www.rfc-editor.org/rfc/rfc9420)) | None: every message is signed | Strong | Thousands | Standard | +| MLS with ephemeral signing keys bound over deniable pairwise channels | Plausible, unproven | Strong | Thousands | Suggested in RFC 9750; no proof | +| MLS with epochal signatures (Hülsing and Weber, IEEE S&P 2021) | Deniable after each epoch | Strong | Thousands | Research only | + +The most promising future direction is a hybrid: pairwise fan-out for small +groups, and MLS with post-quantum ciphersuites for large ones, where each +member's signing keys are ephemeral, rotated with every update, and bound to +their identity only over deniable pairwise channels. Neither half is proven to +give deniability and strong compromise recovery together, and running two +modes adds complexity and room for downgrade attacks. A future room version +will make this choice. diff --git a/content/server-server-api.md b/content/server-server-api.md new file mode 100644 index 0000000000000000000000000000000000000000..33b673b3d0dc39e4380ffb7168819b5d60a820d7 --- /dev/null +++ b/content/server-server-api.md @@ -0,0 +1,1864 @@ +--- +title: "Server-Server API" +weight: 20 +type: docs +description: | + Taper homeservers use the Federation APIs (also known as server-server APIs) + to communicate with each other. Homeservers use these APIs to push messages in + real-time, retrieve historic messages, and query profile or presence + information about users on other servers. The APIs are implemented over HTTPS, + with authentication provided by public key signatures both at the TLS + transport layer and in HTTP `Authorization` headers. + + There are three main kinds of communication that occur between + homeservers: + + Persistent Data Units (PDUs): + These events are broadcast from one homeserver to any others that have + joined the same room (identified by Room ID). They are persisted in + long-term storage and record the history of messages and state for a + room. + + Like email, it is the responsibility of the originating server of a PDU + to deliver that event to its recipient servers. However PDUs are signed + using the originating server's private key so that it is possible to + deliver them through third-party servers. + + Ephemeral Data Units (EDUs): + These events are pushed between pairs of homeservers. They are not + persisted and are not part of the history of a room, nor does the + receiving homeserver have to reply to them. + + Queries: + These are single request/response interactions between a given pair of + servers, initiated by one side sending an HTTPS GET request to obtain + some information, and responded by the other. They are not persisted and + contain no long-term significant history. They simply request a snapshot + state at the instant the query is made. + + EDUs and PDUs are further wrapped in an envelope called a Transaction, + which is transferred from the origin to the destination homeserver using + an HTTPS PUT request. + +--- + +## WebSocket federation {#websocket-federation} + +Taper servers federate over **WebSocket connections inside TLS 1.3**, like +clients do. The HTTP endpoints later in this document define the *meaning* +and bodies of each operation. On the federation socket, the same operations +are carried as gateway requests. A server MUST support WebSocket federation, +and MAY also serve the HTTP endpoints during a transition. + +### Connections + +* The connecting server opens a WebSocket to the destination's federation + path. The path is published only in the destination's signed server + metadata, or configured out of band, and SHOULD be unguessable, as for the + [client gateway](/security/#transport-baseline). +* The transport rules of [Cryptography and Transport](/security/#transport) + apply in full: TLS 1.3 with `X25519MLKEM768`, a cover website for anything + that fails the handshake, no compression, padded frames and jittered + heartbeats. +* One connection per pair of servers is RECOMMENDED. Either side may close + it; the other reconnects when it next needs to send. + +### Mutual authentication + +Each connection is authenticated **once**, by both sides, with their current +[request keys](#publishing-keys). Those private keys are published after +retirement, so a recorded handshake later proves nothing. + +1. The connecting server sends + `{"op": "fed.hello", "origin", "destination", "nonce", "key"}`, where + `nonce` is 32 random bytes (unpadded base64) and `key` is a request key ID. +2. The destination replies with its own `fed.hello`, with the names swapped + and its own `nonce` and `key`. +3. Each side then sends `{"op": "fed.auth", "sig"}`: an Ed25519 signature, + with its announced request key, over the Canonical JSON of + `{"client_nonce", "server_nonce", "client", "server", "signer", "channel"}`. + Here `channel` is the TLS exporter value for the connection + ([RFC 9266](https://www.rfc-editor.org/rfc/rfc9266), label + `EXPORTER-Channel-Binding`, unpadded base64), so a signature can't be + replayed on another connection. On a connection without TLS (an + [onion service](/security/#onion-services)), `channel` is the empty + string. +4. Each side checks the other's signature against that server's + `request_keys`, fetched from its [key document](#publishing-keys) or a notary, and + closes the connection if it fails or if the key is retired. + +The connecting side may finish step 4 first and start sending requests while +the other side is still fetching its keys, which can take seconds over Tor. +A server MUST NOT drop requests that arrive before it has checked the +peer's signature; it holds them, and serves them once the check succeeds. + +A server that receives a `fed.hello` from a server it doesn't federate with +(see below) MUST close the connection without explanation, as it would for +any other failed handshake. + +Servers that federate through Tor follow the additional rules in +[Onion services](/security/#onion-services). + +After the handshake, either side sends requests (`{"op": "request", "id", +"method", "body"}`) and gets responses, exactly as on the client gateway. +The methods are: + +| Method | HTTP equivalent | +|--------|-----------------| +| `t.fed.send` | [`PUT /send/{txnId}`](#put_taperfederationv1sendtxnid) (transactions of PDUs and EDUs) | +| `t.fed.make_join`, `t.fed.send_join` | [joining rooms](#joining-rooms) | +| `t.fed.make_leave`, `t.fed.send_leave` | [leaving rooms](#leaving-rooms-rejecting-invites) | +| `t.fed.invite` | [inviting](#inviting-to-a-room) | +| `t.fed.backfill`, `t.fed.get_missing_events`, `t.fed.event` | [backfill and missing events](#backfilling-and-retrieving-missing-events), limited by [retention](#message-retention) | +| `t.fed.state` | [room state](#retrieving-events) | +| `t.fed.query.profile` | [profile query](#querying-for-information), subject to [Scraping Resistance](/client-server-api/#closed-surfaces) | +| `t.fed.keys.query`, `t.fed.keys.claim` | [end-to-end encryption keys](#end-to-end-encryption) | +| `t.fed.media.download` | [media](#content-repository), in [binary frames](/client-server-api/#media-over-the-gateway) | + +Messages within a request don't carry their own signatures: the connection +is authenticated. Room events (PDUs) still carry their server's signature on +the event itself, as room version 13 defines, because other servers rely on +it. + +### Which servers to federate with + +Servers SHOULD support an **allowlist mode**, where they federate only with +servers an administrator has approved. In that mode they neither open nor +accept connections with any other server. Servers MUST apply the federation +rules of [Scraping Resistance](/client-server-api/#federation): budgets and +tiers per remote server, and limits on servers they haven't seen before. + +## API standards + +The HTTP endpoints below define the operations that +[WebSocket federation](#websocket-federation) carries. Servers that also serve +them over HTTPS exchange JSON objects, as described here. + +All `POST` and `PUT` endpoints require the requesting server to supply a +request body containing a (potentially empty) JSON object. Requesting servers +should supply a `Content-Type` header of `application/json` for all requests +with JSON bodies, but this is not required. + +Similarly, all endpoints in this specification require the destination server +to return a JSON object. Servers must include a `Content-Type` header of +`application/json` for all JSON responses. + +All JSON data, in requests or responses, must be encoded using UTF-8. + +### TLS + +Server-server communication MUST use TLS 1.3, and MUST offer and prefer the +hybrid post-quantum key exchange `X25519MLKEM768`, as required by +[Cryptography and Transport](/security/#algorithm-policy). Servers SHOULD use +a mainstream TLS stack whose handshake matches a common browser, and SHOULD +be reachable as a Tor onion service when they are at risk of blocking (see +[optional transports](/security/#optional-transports)). + +The destination server must provide a TLS certificate signed by a known +Certificate Authority. + +Requesting servers are ultimately responsible for determining the trusted Certificate +Authorities, however are strongly encouraged to rely on the operating system's +judgement. Servers can offer administrators a means to override the trusted +authorities list. Servers can additionally skip the certificate validation for +a given whitelist of domains or netmasks for the purposes of testing or in +networks where verification is done elsewhere, such as with `.onion` +addresses. + +Servers should respect SNI when making requests where possible: a SNI should be +sent for the certificate which is expected, unless that certificate is expected +to be an IP address in which case SNI is not supported and should not be sent. + +Servers are encouraged to make use of the [Certificate +Transparency](https://www.certificate-transparency.org/) project. + +### Unsupported endpoints + +If a request for an unsupported (or unknown) endpoint is received then the server +must respond with a 404 `T_UNRECOGNIZED` error. + +Similarly, a 405 `T_UNRECOGNIZED` error is used to denote an unsupported method +to a known endpoint. + +## Server discovery + +### Resolving server names + +Each Taper homeserver is identified by a server name consisting of a +hostname and an optional port, as described by the +[grammar](/appendices#server-name). Where applicable, a delegated +server name uses the same grammar. + +Server names are resolved to an IP address and port to connect to, and +have various conditions affecting which certificates and `Host` headers +to send. The process overall is as follows: + +1. If the hostname is an IP literal, then that IP address should be + used, together with the given port number, or 8448 if no port is + given. The target server must present a valid certificate for the IP + address. The `Host` header in the request should be set to the + server name, including the port if the server name included one. + +2. If the hostname is not an IP literal, and the server name includes an + explicit port, resolve the hostname to an IP address using CNAME, AAAA or A + records. + Requests are made to the resolved IP address and given port with a + `Host` header of the original server name (with port). The target + server must present a valid certificate for the hostname. + +3. If the hostname is not an IP literal, a regular HTTPS request is + made to `https:///.well-known/taper/server` (according to + [RFC 8615](https://datatracker.ietf.org/doc/html/rfc8615)), expecting + the schema defined later in this section. 30x redirects should be + followed, however redirection loops should be avoided. Responses + (successful or otherwise) to the `/.well-known` endpoint should be + cached by the requesting server. Servers should respect the cache + control headers present on the response, or use a sensible default + when headers are not present. The recommended sensible default is 24 + hours. Servers should additionally impose a maximum cache time for + responses: 48 hours is recommended. Errors are recommended to be + cached for up to an hour, and servers are encouraged to + exponentially back off for repeated failures. The schema of the + `/.well-known` request is later in this section. If the response is + invalid (bad JSON, missing properties, non-200 response, etc), skip + to step 4. If the response is valid, the `t.server` property is + parsed as `[:]` and processed as + follows: + 1. If `` is an IP literal, then that IP address + should be used together with the `` or 8448 if + no port is provided. The target server must present a valid TLS + certificate for the IP address. Requests must be made with a + `Host` header containing the IP address, including the port if + one was provided. + 2. If `` is not an IP literal, and + `` is present, an IP address is discovered by + looking up CNAME, AAAA or A records for ``. The + resulting IP address is used, alongside the ``. + Requests must be made with a `Host` header of + `:`. The target server must + present a valid certificate for ``. + 3. {{% added-in v="1.8" %}} If `` is not an IP literal and no + `` is present, an SRV record is looked up for + `_taper-fed._tcp.`. This may result in another + hostname (to be resolved using AAAA or A records) and port. + Requests should be made to the resolved IP address and port with + a `Host` header containing the ``. The + target server must present a valid certificate for + ``. + 4. **[Deprecated]** If `` is not an IP literal, no + `` is present, and a `_taper-fed._tcp.` + SRV record was not found, an SRV record is looked up for + `_taper._tcp.`. This may result in another + hostname (to be resolved using AAAA or A records) and port. + Requests should be made to the resolved IP address and port with + a `Host` header containing the ``. The + target server must present a valid certificate for + ``. + 5. If no SRV record is found, an IP address is resolved using CNAME, AAAA + or A records. Requests are then made to the resolved IP address + and a port of 8448, using a `Host` header of + ``. The target server must present a valid + certificate for ``. + +4. {{% added-in v="1.8" %}} If the `/.well-known` request resulted in an error response, a server is + found by resolving an SRV record for `_taper-fed._tcp.`. This may + result in a hostname (to be resolved using AAAA or A records) and + port. Requests are made to the resolved IP address and port, with a `Host` + header of ``. The target server must present a valid certificate + for ``. + +5. **[Deprecated]** If the `/.well-known` request resulted in an error response, + and a `_taper-fed._tcp.` SRV record was not found, a server is + found by resolving an SRV record for `_taper._tcp.`. This may + result in a hostname (to be resolved using AAAA or A records) and + port. Requests are made to the resolved IP address and port, with a `Host` + header of ``. The target server must present a valid certificate + for ``. + +6. If the `/.well-known` request returned an error response, and + no SRV records were found, an IP address is resolved using CNAME, AAAA and A + records. Requests are made to the resolved IP address using port + 8448 and a `Host` header containing the ``. The target + server must present a valid certificate for ``. + +{{% boxes/note %}} +The reasons we require `` rather than `` for SRV +delegation are: + 1. DNS is insecure (not all domains have DNSSEC), so the target of the delegation + must prove that it is a valid delegate for `` via TLS. + 2. Consistency with the recommendations in [RFC6125](https://datatracker.ietf.org/doc/html/rfc6125#section-6.2.1) + and other applications using SRV records such [XMPP](https://datatracker.ietf.org/doc/html/rfc6120#section-13.7.2.1). +{{% /boxes/note %}} + +{{% boxes/note %}} +Note that the target of a SRV record may *not* be a CNAME, as +mandated by [RFC2782](https://www.rfc-editor.org/rfc/rfc2782.html): + +> the name MUST NOT be an alias (in the sense of RFC 1034 or RFC 2181) +{{% /boxes/note %}} + +{{% boxes/note %}} +Steps 3.4 and 5 are deprecated because they use a service name not registered by IANA. +They may be removed in a future version of the specification. Server admins are encouraged +to use `.well-known` over any form of SRV records. + +The IANA registration for port 8448 and `matrix-fed` can be found [here](https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=matrix-fed). +{{% /boxes/note %}} + +{{% http-api spec="server-server" api="wellknown" %}} + +### Server implementation + +{{% http-api spec="server-server" api="version" %}} + +### Retrieving server keys + +{{% boxes/note %}} +There was once a "version 1" of the key exchange. It has been removed +from the specification due to lack of significance. It may be reviewed +[from the historical +draft](https://github.com/matrix-org/matrix-doc/blob/51faf8ed2e4a63d4cfd6d23183698ed169956cc0/specification/server_server_api.rst#232version-1). +{{% /boxes/note %}} + +Each homeserver publishes its public keys in a key document (see +[Publishing Keys](#publishing-keys)). Homeservers query for keys by either +fetching that document directly or by querying an +intermediate notary server using a +`/_taper/key/v2/query/{serverName}` API. Intermediate notary +servers fetch the key document on behalf of +another server and sign the response with their own key. A server may +query multiple notary servers to ensure that they all report the same +public keys. + +This approach is borrowed from the [Perspectives +Project](https://web.archive.org/web/20170702024706/https://perspectives-project.org/), +but modified to include the NACL keys and to use JSON instead of XML. It +has the advantage of avoiding a single trust-root since each server is +free to pick which notary servers they trust and can corroborate the +keys returned by a given notary server by querying other servers. + +#### Publishing Keys + +Homeservers publish their signing keys in a JSON object, the **key +document**, at `{federation path}/keys`: an HTTPS `GET` under the secret +path of the server's [federation socket](#websocket-federation), so only +servers that know that path can fetch it. A server MUST NOT serve its key +document at a fixed, guessable location such as `/_taper/key/v2/server`, +because that would identify it as a Taper server to anyone who asks (see +[Cryptography and Transport](/security/#transport-baseline)). The HTTP +definition below gives the document's format. It contains two kinds of key: + +* **Signing keys**, in `verify_keys`, are used to sign events and key server + responses. Keys a server no longer signs with move to `old_verify_keys`, + and remain valid for checking events signed before they expired. +* **Request keys**, in `request_keys`, are used only to sign + [federation requests](#request-authentication). They are short-lived: a + server MUST retire each request key no later than 7 days after it first + uses it. Once retired, a request key moves to `old_request_keys`, and the + server MUST publish its **private** key there no later than 24 hours after + it expired. + +{{% boxes/rationale %}} +Federation requests carry events, including their full content, and a +request signature binds that content to the sending server. A server that +logs signed requests would otherwise hold durable proof of what was sent. +Publishing a request key's private half once it is retired means anyone +could have produced any signature made with it, so a logged request proves +nothing to a third party. Live security is unaffected, because servers never +accept requests signed with a retired key. + +Signing keys are not published, because events in room state must stay +unforgeable for as long as the room exists. In [room version 13](/rooms/v13) +and later, event signatures do not cover message content, so they do not +need to be. +{{% /boxes/rationale %}} + +{{% boxes/note %}} +Request keys exist because federation still runs over signed HTTP requests. +They will be replaced by per-connection message authentication codes when +federation moves to WebSockets. +{{% /boxes/note %}} + +{{% http-api spec="server-server" api="keys_server" %}} + +#### Querying Keys Through Another Server + +Servers may query another server's keys through a notary server. The +notary server may be another homeserver. The notary server will retrieve +keys from the queried servers by fetching their key documents, so it +needs each one's federation path. The notary server will +additionally sign the response from the queried server before returning +the results. + +Notary servers can return keys for servers that are offline or having +issues serving their own keys by using cached responses. Keys can be +queried from multiple servers to mitigate against DNS spoofing. + +{{% http-api spec="server-server" api="keys_query" %}} + +## Authentication + +### Request Authentication + +Every HTTP request made by a homeserver is authenticated using public +key digital signatures. The request method, target and body are signed +by wrapping them in a JSON object and signing it using the [JSON signing +algorithm](/appendices#signing-json) with one of the server's current +[request keys](#publishing-keys). Servers MUST NOT sign requests with their +event signing keys (`verify_keys`). The resulting signatures are added +as an `Authorization` header with an auth scheme of `X-Taper`. Note that +the target field should include the full path starting with `/_taper/...`, +including the `?` and any query parameters if present, but should not +include the leading `https:`, nor the destination server's hostname. + +Step 1 sign JSON: + +```nohighlight +{ + "method": "POST", + "uri": "/target", + "origin": "origin.hs.example.com", + "destination": "destination.hs.example.com", + "content": , + "signatures": { + "origin.hs.example.com": { + "ed25519:key1": "ABCDEF..." + } + } +} +``` + +The server names in the JSON above are the server names for each +homeserver involved. Delegation from the [server name resolution +section](#resolving-server-names) above do not affect these - the server +names from before delegation would take place are used. This same +condition applies throughout the request signing process. + +Step 2 add `Authorization` header: + + POST /target HTTP/1.1 + Authorization: X-Taper origin="origin.hs.example.com",destination="destination.hs.example.com",key="ed25519:key1",sig="ABCDEF..." + Content-Type: application/json + + + +Example python code: + +```py +def authorization_headers(origin_name, origin_signing_key, + destination_name, request_method, request_target, + content=None): + request_json = { + "method": request_method, + "uri": request_target, + "origin": origin_name, + "destination": destination_name, + } + + if content is not None: + # Assuming content is already parsed as JSON + request_json["content"] = content + + signed_json = sign_json(request_json, origin_name, origin_signing_key) + + authorization_headers = [] + + for key, sig in signed_json["signatures"][origin_name].items(): + authorization_headers.append(bytes( + "X-Taper origin=\"%s\",destination=\"%s\",key=\"%s\",sig=\"%s\"" % ( + origin_name, destination_name, key, sig, + ) + )) + + return ("Authorization", authorization_headers[0]) +``` + +The format of the `Authorization` header is given in +[Section 11.4 of RFC 9110](https://datatracker.ietf.org/doc/html/rfc9110#section-11.4). In +summary, the header begins with authorisation scheme `X-Taper`, followed by one +or more spaces, followed by a comma-separated list of parameters written as +name=value pairs. Zero or more spaces and tabs around each comma are allowed. +The names are case insensitive and order does not matter. The +values must be enclosed in quotes if they contain characters that are not +allowed in `token`s, as defined in +[Section 5.6.2 of RFC 9110](https://datatracker.ietf.org/doc/html/rfc9110#section-5.6.2); if a +value is a valid `token`, it may or may not be enclosed in quotes. Quoted +values may include backslash-escaped characters. When parsing the header, the +recipient must unescape the characters. That is, a backslash-character pair is +replaced by the character that follows the backslash. + +For compatibility with older servers, the sender should +- only include one space after `X-Taper`, +- only use lower-case names, +- avoid using backslashes in parameter values, and +- avoid including whitespace around the commas between name=value pairs. + +For compatibility with older servers, the recipient should allow colons to be +included in values without requiring the value to be enclosed in quotes. + +The authorisation parameters to include are: + +- `origin`: the server name of the sending server. This is the same as the + `origin` field from JSON described in step 1. +- `destination`: {{% added-in v="1.3" %}} the server name of the receiving + server. This is the same as the `destination` field from the JSON described + in step 1. For compatibility with older servers, recipients should accept + requests without this parameter, but MUST always send it. If this property + is included, but the value does not match the receiving server's name, the + receiving server must deny the request with an HTTP status code `401 + Unauthorized`. +- `key`: the ID, including the algorithm name, of the sending server's request + key used to sign the request. The receiving server MUST deny the request with + an HTTP status code `401 Unauthorized` unless the key is listed in the sending + server's `request_keys`, in a key response whose `valid_until_ts` has not + passed. If the key ID is unknown, the receiving server SHOULD fetch the + sending server's keys again before denying the request. A key listed in + `old_request_keys`, or whose private key has been published, MUST NOT be + accepted. +- `sig`: the signature of the JSON as calculated in step 1. + +Unknown parameters are ignored. + +{{% boxes/note %}} +{{% changed-in v="1.11" %}} +This section used to reference [RFC 7235](https://datatracker.ietf.org/doc/html/rfc7235#section-2.1) +and [RFC 7230](https://datatracker.ietf.org/doc/html/rfc9110#section-5.6.2), that +were obsoleted by RFC 9110 without changes to the sections of interest here. +{{% /boxes/note %}} + +### Response Authentication + +Responses are authenticated by the TLS server certificate. A homeserver +should not send a request until it has authenticated the connected +server to avoid leaking messages to eavesdroppers. + +### Client TLS Certificates + +Requests are authenticated at the HTTP layer rather than at the TLS +layer because HTTP services like Taper are often deployed behind load +balancers that handle the TLS and these load balancers make it difficult +to check TLS client certificates. + +A homeserver may provide a TLS client certificate and the receiving +homeserver may check that the client certificate matches the certificate +of the origin homeserver. + +## Transactions + +The transfer of EDUs and PDUs between homeservers is performed by an +exchange of Transaction messages, which are encoded as JSON objects, +passed over an HTTP PUT request. A Transaction is meaningful only to the +pair of homeservers that exchanged it; they are not globally-meaningful. + +Transactions are limited in size; they can have at most 50 PDUs and 100 +EDUs. + +{{% http-api spec="server-server" api="transactions" %}} + +## PDUs + +Each PDU contains a single Room Event which the origin server wants to +send to the destination. + +The `prev_events` field of a PDU identifies the "parents" of the event, +and thus establishes a partial ordering on events within the room by +linking them into a Directed Acyclic Graph (DAG). The sending server +should populate this field with all of the events in the room for which +it has not yet seen a child - thus demonstrating that the event comes +after all other known events. + +For example, consider a room whose events form the DAG shown below. A +server creating a new event in this room should populate the new event's +`prev_events` field with both `E4` and `E6`, since neither event yet has +a child: + + E1 + ^ + | + E2 <--- E5 + ^ ^ + | | + E3 E6 + ^ + | + E4 + +For a full schema of what a PDU looks like, see the [room version +specification](/rooms). + +### Checks performed on receipt of a PDU + +Whenever a server receives an event from a remote server, the receiving +server must ensure that the event: + +1. {{% changed-in v="1.16" %}} Is a valid event, otherwise it is dropped. For + an event to be valid, it must comply with the event format of that [room version](/rooms). + For some room versions, a `room_id` may also be required on the event in order + to determine the room version to check the event against. See the event format + section of the [room version specifications](/rooms) for details on when it + is required. +2. Passes signature checks, otherwise it is dropped. +3. Passes hash checks, otherwise it is redacted before being processed + further. +4. Passes authorisation rules based on the event's auth events, + otherwise it is rejected. +5. Passes authorisation rules based on the state before the event, + otherwise it is rejected. +6. Passes authorisation rules based on the current state of the room, + otherwise it is "soft failed". +7. {{% added-in v="1.18" %}} Is [validated](#validating-policy-server-signatures) + by the Policy Server, if the room is [using a Policy Server](#determining-if-a-policy-server-is-enabled-in-a-room), + otherwise it is "soft failed". + +Further details of these checks, and how to handle failures, are +described below. + +The [Signing Events](#signing-events) section has more information on +which hashes and signatures are expected on events, and how to calculate +them. + +#### Definitions + +Required Power Level + +: A given event type has an associated *required power level*. This is given by + the current [`t.room.power_levels`](/client-server-api/#lroompower_levels) + event. The event type is either listed explicitly in the `events` section or + given by either `state_default` or `events_default` depending on if the event + is a state event or not. + +Invite Level, Kick Level, Ban Level, Redact Level + +: The levels given by the `invite`, `kick`, `ban`, and `redact` properties in + the current [`t.room.power_levels`](/client-server-api/#lroompower_levels) + state. The invite level defaults to 0 if unspecified. The kick level, ban level + and redact level each default to 50 if unspecified. + +Target User + +: For an [`t.room.member`](/client-server-api/#lroommember) state event, the + user given by the `state_key` of the event. + +{{% boxes/warning %}} +Some [room versions](/rooms) accept power level values to be represented as +strings rather than integers. This is strictly for backwards compatibility. +A homeserver should take reasonable precautions to prevent users from sending +new power level events with string values (eg: by rejecting the API request), +and must never populate the default power levels in a room as string values. + +See the [room version specification](/rooms) for more information. +{{% /boxes/warning %}} + +#### Authorisation rules + +The rules governing whether an event is authorised depends on a set of +state. A given event is checked multiple times against different sets of +state, as specified above. Each room version can have a different +algorithm for how the rules work, and which rules are applied. For more +detailed information, please see the [room version +specification](/rooms). + +##### Auth events selection + +The `auth_events` field of a PDU identifies the set of events which give +the sender permission to send the event. The `auth_events` for the +`t.room.create` event in a room is empty; for other events, it should be +the following subset of the room state: + +- {{% changed-in v="1.16" %}} Depending on the [room version](/rooms), the + `t.room.create` event. + +- The current `t.room.power_levels` event, if any. + +- The sender's current `t.room.member` event, if any. + +- If type is `t.room.member`: + + - The target's current `t.room.member` event, if any. + - If `membership` is `join`, `invite` or `knock`, the current + `t.room.join_rules` event, if any. + - If membership is `invite` and `content` contains a + `third_party_invite` property, the current + `t.room.third_party_invite` event with `state_key` matching + `content.third_party_invite.signed.token`, if any. + - If `membership` is `join`, `content.join_authorised_via_users_server` + is present, and the [room version supports restricted rooms](/rooms/#feature-matrix), + then the `t.room.member` event with `state_key` matching + `content.join_authorised_via_users_server`. + +#### Rejection + +If an event is rejected it should neither be relayed to clients nor be +included as a prev event in any new events generated by the server. +Subsequent events from other servers that reference rejected events +should be allowed if they still pass the auth rules. The state used in +the checks should be calculated as normal, except not updating with the +rejected event where it is a state event. + +If an event in an incoming transaction is rejected, this should not +cause the transaction request to be responded to with an error response. + +{{% boxes/note %}} +This means that events may be included in the room DAG even though they +should be rejected. +{{% /boxes/note %}} + +{{% boxes/note %}} +This is in contrast to redacted events which can still affect the state +of the room. For example, a redacted `join` event will still result in +the user being considered joined. +{{% /boxes/note %}} + +#### Soft failure + +{{% boxes/rationale %}} +It is important that we prevent users from evading bans (or other power +restrictions) by creating events which reference old parts of the DAG. +For example, a banned user could continue to send messages to a room by +having their server send events which reference the event before they +were banned. Note that such events are entirely valid, and we cannot +simply reject them, as it is impossible to distinguish such an event +from a legitimate one which has been delayed. We must therefore accept +such events and let them participate in state resolution and the +federation protocol as normal. However, servers may choose not to send +such events on to their clients, so that end users won't actually see +the events. + +When this happens it is often fairly obvious to servers, as they can see +that the new event doesn't actually pass auth based on the "current +state" (i.e. the resolved state across all forward extremities). While +the event is technically valid, the server can choose to not notify +clients about the new event. + +This discourages servers from sending events that evade bans etc. in +this way, as end users won't actually see the events. +{{% /boxes/rationale %}} + +When the homeserver receives a new event over federation it should also +check whether the event passes auth checks based on the current state of +the room (as well as based on the state at the event). If the event does +not pass the auth checks based on the *current state* of the room (but +does pass the auth checks based on the state at that event) it should be +"soft failed". + +When an event is "soft failed" it should not be relayed to the client +nor be referenced by new events created by the homeserver (i.e. they +should not be added to the server's list of forward extremities of the +room). Soft failed events are otherwise handled as usual. + +{{% boxes/note %}} +Soft failed events participate in state resolution as normal if further +events are received which reference it. It is the job of the state +resolution algorithm to ensure that malicious events cannot be injected +into the room state via this mechanism. +{{% /boxes/note %}} + +{{% boxes/note %}} +Because soft failed state events participate in state resolution as +normal, it is possible for such events to appear in the current state of +the room. In that case the client should be told about the soft failed +event in the usual way (e.g. by sending it down in the `state` section +of a sync response). +{{% /boxes/note %}} + +{{% boxes/note %}} +A soft failed event should be returned in response to federation +requests where appropriate (e.g. in `/event/`). Note that soft +failed events are returned in `/backfill` and `/get_missing_events` +responses only if the requests include events referencing the soft +failed events. +{{% /boxes/note %}} + +Example + +As an example consider the event graph: + + A + / + B + +where `B` is a ban of a user `X`. If the user `X` tries to set the topic +by sending an event `C` while evading the ban: + + A + / \ + B C + +servers that receive `C` after `B` should soft fail event `C`, and so +will neither relay `C` to its clients nor send any events referencing +`C`. + +If later another server sends an event `D` that references both `B` and +`C` (this can happen if it received `C` before `B`): + + A + / \ + B C + \ / + D + +then servers will handle `D` as normal. `D` is sent to the servers' +clients (assuming `D` passes auth checks). The state at `D` may resolve +to a state that includes `C`, in which case clients should also to be +told that the state has changed to include `C`. (*Note*: This depends on +the exact state resolution algorithm used. In the original version of +the algorithm `C` would be in the resolved state, whereas in latter +versions the algorithm tries to prioritise the ban over the topic +change.) + +Note that this is essentially equivalent to the situation where one +server doesn't receive `C` at all, and so asks another server for the +state of the `C` branch. + +Let's go back to the graph before `D` was sent: + + A + / \ + B C + +If all the servers in the room saw `B` before `C` and so soft fail `C`, +then any new event `D'` will not reference `C`: + + A + / \ + B C + | + D' + +{{% boxes/note %}} +{{% added-in v="1.18" %}} +Events can also be soft failed if they fail [Policy Server checks](#validating-policy-server-signatures). +{{% /boxes/note %}} + +{{% added-in v="1.20" %}} +Servers MUST re-evaluate the soft failure of soft failed, unexpired +[sticky events](#sticky-events) when the authorising state of the event +changes, and relay the event to clients if it is no longer soft failed. + +Once accepted, an event cannot become soft-failed retrospectively. + +#### Retrieving event authorisation information + +The homeserver may be missing event authorisation information, or wish +to check with other servers to ensure it is receiving the correct auth +chain. These APIs give the homeserver an avenue for getting the +information it needs. + +{{% http-api spec="server-server" api="event_auth" %}} + +## EDUs + +EDUs, by comparison to PDUs, do not have an ID, a room ID, or a list of +"previous" IDs. They are intended to be non-persistent data such as user +presence, typing notifications, etc. + +{{% definition path="api/server-server/definitions/edu_with_example" %}} + +## Room State Resolution + +The *state* of a room is a map of `(event_type, state_key)` to +`event_id`. Each room starts with an empty state, and each state event +which is accepted into the room updates the state of that room. + +Where each event has a single `prev_event`, it is clear what the state +of the room after each event should be. However, when two branches in +the event graph merge, the state of those branches might differ, so a +*state resolution* algorithm must be used to determine the resultant +state. + +For example, consider the following event graph (where the oldest event, +E0, is at the top): + + E0 + | + E1 + / \ + E2 E4 + | | + E3 | + \ / + E5 + +Suppose E3 and E4 are both `t.room.name` events which set the name of +the room. What should the name of the room be at E5? + +The algorithm to be used for state resolution depends on the room +version. For a description of each room version's algorithm, please see +the [room version specification](/rooms). + +## Backfilling and retrieving missing events + +Once a homeserver has joined a room, it receives all the events emitted +by other homeservers in that room, and is thus aware of the entire +history of the room from that moment onwards. Since users in that room +are able to request the history by the `/messages` client API endpoint, +it's possible that they might step backwards far enough into history +before the homeserver itself was a member of that room. + +To cover this case, the federation API provides a server-to-server +analog of the `/messages` client API, allowing one homeserver to fetch +history from another. This is the `/backfill` API. + +To request more history, the requesting homeserver picks another +homeserver that it thinks may have more (most likely this should be a +homeserver for some of the existing users in the room at the earliest +point in history it has currently), and makes a `/backfill` request. + +Similar to backfilling a room's history, a server may not have all the +events in the graph. That server may use the `/get_missing_events` API +to acquire the events it is missing. + +{{% http-api spec="server-server" api="backfill" %}} + +## Message retention + +All servers MUST follow the client-server +[Message Retention](/client-server-api/#message-retention) module. The +following rules also apply over federation: + +* A server MUST NOT include an event in the response to + [`/backfill`](#get_taperfederationv1backfillroomid), + [`/get_missing_events`](#post_taperfederationv1get_missing_eventsroomid) or + [`/event`](#get_taperfederationv1eventeventid), or in transactions, once + the event's expiry time has passed. The exception is a superseded state + event that the requester needs for an auth chain, which MUST be served in + redacted form only. If a server is asked for a specific expired event, it + MUST respond with `404` and the error code `T_EXPIRED`. +* When `/backfill` or `/get_missing_events` reaches the start of the + retention window, the server MUST return only the unexpired events and + stop there. Requesters MUST treat a gap at the start of the window as the + start of the room's available history, and MUST NOT go looking for the + events before it from other servers. +* A receiving server MUST work out each PDU's reference time and expiry time + using its own effective lifetime for the room. It MUST NOT persist a + non-state PDU whose expiry time has already passed, and it MUST return an + error for that PDU in the transaction response. This prevents servers from + using backdated events to bring old content back. +* A server MUST NOT treat a missing `prev_events` entry as a reason to fetch + that event if the entry is a purged [event stub](/client-server-api/#purging), + or if its `depth` places it before the start of the retention window. +* The `/state`, `/state_ids` and `/send_join` responses include the auth + chain. Superseded state events in an auth chain MUST be redacted before + they are served if their expiry time has passed. + +## Scraping resistance and moves + +Servers MUST apply the federation rules of the +[Scraping Resistance](/client-server-api/#scraping-resistance) module: +budgets and tiers for remote servers, limits on servers new to them, and no +published room directory over federation. + +When a server receives a query or invite for a user who has +[moved](/client-server-api/#account-portability), it MUST answer with +`T_MOVED`, including `moved_to` and the signed move statement, for at least +the retention ceiling after the move. + +## Retrieving events + +In some circumstances, a homeserver may be missing a particular event or +information about the room which cannot be easily determined from +backfilling. These APIs provide homeservers with the option of getting +events and the state of the room at a given point in the timeline. + +{{% http-api spec="server-server" api="events" %}} + +## Joining Rooms + +When a new user wishes to join a room that the user's homeserver already +knows about, the homeserver can immediately determine if this is +allowable by inspecting the state of the room. If it is acceptable, it +can generate, sign, and emit a new `t.room.member` state event adding +the user into that room. When the homeserver does not yet know about the +room it cannot do this directly. Instead, it must take a longer +multi-stage handshaking process by which it first selects a remote +homeserver which is already participating in that room, and use it to +assist in the joining process. This is the remote join handshake. + +This handshake involves the homeserver of the new member wishing to join +(referred to here as the "joining" server), the directory server hosting +the room alias the user is requesting to join with, and a homeserver +where existing room members are already present (referred to as the +"resident" server). + +In summary, the remote join handshake consists of the joining server +querying the directory server for information about the room alias; +receiving a room ID and a list of join candidates. The joining server +then requests information about the room from one of the residents. It +uses this information to construct an `t.room.member` event which it +finally sends to a resident server. + +Conceptually these are three different roles of homeserver. In practice +the directory server is likely to be resident in the room, and so may be +selected by the joining server to be the assisting resident. Likewise, +it is likely that the joining server picks the same candidate resident +for both phases of event construction, though in principle any valid +candidate may be used at each time. Thus, any join handshake can +potentially involve anywhere from two to four homeservers, though most +in practice will use just two. + + + +```nohighlight ++---------+ +---------------+ +-----------------+ +-----------------+ +| Client | | JoiningServer | | DirectoryServer | | ResidentServer | ++---------+ +---------------+ +-----------------+ +-----------------+ + | | | | + | join request | | | + |---------------------->| | | + | | | | + | | directory request | | + | |---------------------------->| | + | | | | + | | directory response | | + | |<----------------------------| | + | | | | + | | make_join request | | + | |------------------------------------------------>| + | | | | + | | |make_join response | + | |<------------------------------------------------| + | | | | + | | send_join request | | + | |------------------------------------------------>| + | | | | + | | |send_join response | + | |<------------------------------------------------| + | | | | + | join response | | | + |<----------------------| | | + | | | | +``` + +The first part of the handshake usually involves using the directory +server to request the room ID and join candidates through the +[`/query/directory`](/server-server-api/#get_taperfederationv1querydirectory) API endpoint. In the case of a new user joining a +room as a result of a received invite, the joining user's homeserver +could optimise this step away by picking the origin server of that +invite message as the join candidate. However, the joining server should +be aware that the origin server of the invite might since have left the +room, so should be prepared to fall back on the regular join flow if +this optimisation fails. + +Once the joining server has the room ID and the join candidates, it then +needs to obtain enough information about the room to fill in the +required fields of the `t.room.member` event. It obtains this by +selecting a resident from the candidate list, and using the +`GET /make_join` endpoint. The resident server will then reply with +enough information for the joining server to fill in the event. + +The joining server is expected to add or replace the `origin`, +`origin_server_ts`, and `event_id` on the templated event received by the +resident server. The joining server MUST also verify that the `type`, `room_id`, +`sender`, `state_key` and `content.membership` fields have the expected values. +This event is then signed by the joining server. + +To complete the join handshake, the joining server submits this new event +to the resident server it used for `GET /make_join`, using the `PUT /send_join` +endpoint. + +The resident homeserver then adds its signature to this event and +accepts it into the room's event graph. The joining server receives +the full set of state for the newly-joined room as well as the freshly +signed membership event. The resident server must also send the event +to other servers participating in the room. + +{{% http-api spec="server-server" api="joins-v1" %}} + +{{% http-api spec="server-server" api="joins-v2" %}} + +### Restricted rooms + +Restricted rooms are described in detail in the +[client-server API](/client-server-api/#restricted-rooms) and are available +in room versions [which support restricted join rules](/rooms/#feature-matrix). + +A resident server processing a request to join a restricted room must +ensure that the joining server satisfies at least one of the conditions +specified by `t.room.join_rules`. If no conditions are available, or none +match the required schema, then the joining server is considered to have +failed all conditions. + +The resident server uses a 400 `T_UNABLE_TO_AUTHORISE_JOIN` error on +`/make_join` and `/send_join` to denote that the resident server is unable +to validate any of the conditions, usually because the resident server +does not have state information about rooms required by the conditions. + +The resident server uses a 400 `T_UNABLE_TO_GRANT_JOIN` error on `/make_join` +and `/send_join` to denote that the joining server should try a different +server. This is typically because the resident server can see that the +joining user satisfies one of the conditions, though the resident server +would be unable to meet the auth rules governing `join_authorised_via_users_server` +on the resulting `t.room.member` event. + +If the joining server fails all conditions then a 403 `T_FORBIDDEN` error +is used by the resident server. + +## Knocking upon a room {#knocking-rooms} + +Rooms can permit knocking through the join rules, and if permitted this +gives users a way to request to join (be invited) to the room. Users who +knock on a room where the server is already a resident of the room can +just send the knock event directly without using this process, however +much like [joining rooms](/server-server-api/#joining-rooms) the server +must handshake their way into having the knock sent on its behalf. + +The handshake is largely the same as the joining rooms handshake, where +instead of a "joining server" there is a "knocking server", and the APIs +to be called are different (`/make_knock` and `/send_knock`). + +Servers can retract knocks over federation by leaving the room, as described +below for rejecting invites. + +{{% http-api spec="server-server" api="knocks" %}} + +## Inviting to a room + +When a user on a given homeserver invites another user on the same +homeserver, the homeserver may sign the membership event itself and skip +the process defined here. However, when a user invites another user on a +different homeserver, a request to that homeserver to have the event +signed and verified must be made. + +Note that invites are used to indicate that knocks were accepted. As such, +receiving servers should be prepared to manually link up a previous knock +to an invite if the invite event does not directly reference the knock. + +{{% boxes/note %}} +{{% added-in v="1.16" %}} `invite_room_state` MUST now have its entries formatted +according to the room's version (see [room version specification](/rooms)). However, +servers SHOULD consider their local ecosystems before returning the described +`400 T_MISSING_PARAM` error code. While migrating, servers SHOULD warn about +invites which fail the validation rather than error in room versions 1 through 11. +All invites to other room versions which fail validation SHOULD result in an error. + +The specification suggests that servers finish their migration no later than +January 2026, though servers may extend this as required to support their users. +{{% /boxes/note %}} + +{{% http-api spec="server-server" api="invites-v1" %}} + +{{% http-api spec="server-server" api="invites-v2" %}} + +## Leaving Rooms (Rejecting Invites) + +Normally homeservers can send appropriate `t.room.member` events to have +users leave the room, to reject local invites, or to retract a knock. +Remote invites/knocks from other homeservers do not involve the server in the +graph and therefore need another approach to reject the invite. Joining +the room and promptly leaving is not recommended as clients and servers will +interpret that as accepting the invite, then leaving the room rather +than rejecting the invite. + +Similar to the [Joining Rooms](#joining-rooms) handshake, the server +which wishes to leave the room starts with sending a `/make_leave` +request to a resident server. In the case of rejecting invites, the +resident server may be the server which sent the invite. After receiving +a template event from `/make_leave`, the leaving server signs the event +and replaces the `event_id` with its own. This is then sent to the +resident server via `/send_leave`. The resident server will then send +the event to other servers in the room. + +{{% http-api spec="server-server" api="leaving-v1" %}} + +{{% http-api spec="server-server" api="leaving-v2" %}} + +## Third-party invites + +{{% boxes/note %}} +More information about third-party invites is available in the Client-Server API +under the [Third-party invites](/client-server-api/#third-party-invites) module. +{{% /boxes/note %}} + +When a user wants to invite another user in a room but doesn't know the +Taper ID to invite, they can do so using a third-party identifier (e.g. +an e-mail or a phone number). + +This identifier and its bindings to Taper IDs are verified by an +identity server implementing the [Identity Service +API](/identity-service-api). + +### Cases where an association exists for a third-party identifier + +If the third-party identifier is already bound to a Taper ID, a [lookup +request](/identity-service-api/#post_taperidentityv2lookup) on the identity +server will return it. The invite is then processed by the inviting homeserver +as a [standard `t.room.member` invite event](#inviting-to-a-room). This is the +simplest case. + +### Cases where an association doesn't exist for a third-party identifier + +If the third-party identifier isn't bound to any Taper ID, the inviting +homeserver will request the identity server to [store an invite](/identity-service-api/#invitation-storage) +for this identifier and to deliver it to whoever binds it to its Taper ID. It +will also send an [`t.room.third_party_invite`](/client-server-api/#lroomthird_party_invite) +event in the room to specify a display name, a token and public keys the +identity server provided as a response to the invite storage request. + +When a third-party identifier with pending invites gets bound to a Taper ID, +the identity server will send a request to the [`/3pid/onbind`](#post_taperfederationv13pidonbind) +endpoint of the the ID's homeserver as described in the [Invitation +Storage](/identity-service-api#invitation-storage) section of the Identity +Service API. + +The following process applies for each invite sent by the identity +server: + +The invited homeserver will create an [`t.room.member`](/client-server-api/#lroommember) +invite event containing a special `third_party_invite` section containing the +token and a `signed` object, both provided by the identity server. + +If the invited homeserver is in the room the invite came from, it can +auth the event and send it. + +However, if the invited homeserver isn't in the room the invite came +from, it will need to request the inviting homeserver to auth the event +at the [`/exchange_third_party_invite`](#put_taperfederationv1exchange_third_party_inviteroomid) +endpoint. + +{{% http-api spec="server-server" api="third_party_invite" %}} + +#### Verifying the invite + +When a homeserver receives an `t.room.member` invite event for a room +it's in with a `third_party_invite` object, it must verify that the +association between the third-party identifier initially invited to the +room and the Taper ID that claims to be bound to it has been verified +without having to rely on a third-party server. + +To do so, it will fetch from the room's state events the +`t.room.third_party_invite` event for which the state key matches with +the value for the `token` key in the `third_party_invite` object from +the `t.room.member` event's content to fetch the public keys initially +delivered by the identity server that stored the invite. + +It will then use these keys to verify that the `signed` object (in the +`third_party_invite` object from the `t.room.member` event's content) +was signed by the same identity server. + +Since this `signed` object can only be delivered once in the POST +request emitted by the identity server upon binding between the +third-party identifier and the Taper ID, and contains the invited +user's Taper ID and the token delivered when the invite was stored, +this verification will prove that the `t.room.member` invite event comes +from the user owning the invited third-party identifier. + +## Published Room Directory + +To complement the [room directory in the Client-Server API](/client-server-api#published-room-directory), +homeservers need a way to query the published rooms of another server. +This can be done by making a request to the `/publicRooms` endpoint for +the server the room directory should be retrieved for. + +{{% http-api spec="server-server" api="public_rooms" %}} + +## Spaces + +To complement the [Client-Server API's Spaces module](/client-server-api/#spaces), +homeservers need a way to query information about spaces from other servers. + +{{% http-api spec="server-server" api="space_hierarchy" %}} + +## Typing Notifications + +When a server's users send typing notifications, those notifications +need to be sent to other servers in the room so their users are aware of +the same state. Receiving servers should verify that the user is in the +room, and is a user belonging to the sending server. + +{{% definition path="api/server-server/definitions/event-schemas/t.typing" %}} + +## Presence + +The server API for presence is based entirely on exchange of the +following EDUs. There are no PDUs or Federation Queries involved. + +Servers should only send presence updates for users that the receiving +server would be interested in. Such as the receiving server sharing a +room with a given user. + +{{% definition path="api/server-server/definitions/event-schemas/t.presence" %}} + +## Receipts + +Receipts are EDUs used to communicate a marker for a given event. +Currently the only kind of receipt supported is a "read receipt", or +where in the event graph the user has read up to. + +Read receipts for events that a user sent do not need to be sent. It is +implied that by sending the event the user has read up to the event. + +{{% definition path="api/server-server/definitions/event-schemas/t.receipt" %}} + +## Sticky Events + +{{% added-in v="1.20" %}} + +[Sticky events](/client-server-api/#sticky-events) are a primitive that +allows clients to share temporary state within a room without having to +rely on state events. Within the federation event format of every +[room version](/rooms), an event is marked as [sticky](/client-server-api/#sticky-events) +by a top-level `sticky` object with a `duration_ms` property that contains +the total sticky duration requested by the sender. + +```json +{ + "type": "org.example.event", + "sticky": { + "duration_ms": 600000 + }, + "sender": "@alice:example.com", + "room_id": "!foo:example.com", + "origin_server_ts": 1757920344000, + "content": { ... } +} +``` + +Servers calculate whether a sticky event is still sticky or has expired as +described in the [Client-Server API](/client-server-api/#determining-whether-an-event-is-sticky). + +Servers MUST attempt to push their own unexpired sticky events in a room to +all joined servers, whilst respecting per-server backoff times. Large volumes +of events to send MUST NOT cause an unexpired sticky event to be dropped from +the send queue of the server. When a new server joins a room, servers MUST +attempt to push all of their own unexpired sticky events in the room to the +new server. Servers SHOULD, on a best-effort basis, push unexpired sticky +events to other homeservers in the order they were created on the server. + +Servers MUST NOT apply [history visibility](/client-server-api/#room-history-visibility) +checks to unexpired sticky events. Any joined server is authorised to see +unexpired sticky events for as long as they remain sticky. + +Servers MUST apply [Policy Servers](#policy-servers) and similar +homeserver-specific anti-spam techniques to sticky events received over +federation. If any of these techniques classifies a sticky event as spam, +the event MUST be treated as a regular non-sticky event. + +{{% boxes/warning %}} +Receiving old sticky events may increase the number of forward extremities +in the room on the receiving server, which may impact the performance of +state resolution if there are many forward extremities. Servers MAY send +dummy events to reduce the number of forward extremities. Alternatively, +servers MAY choose not to add old sticky events to their forward +extremities. +{{% /boxes/warning %}} + +When an unexpired sticky event was sent by a user who has been erased, for +example using the `erase` flag of +[`POST /_taper/client/v3/account/deactivate`](/client-server-api/#post_taperclientv3accountdeactivate), +servers SHOULD NOT send it to other homeservers as part of catching up. + +Servers MAY rate limit sticky events received over federation. For instance, +servers MAY delay the persistence of such events, or persist the sticky events +but delay delivering them to clients. Servers MAY also limit the number of +unexpired sticky events of a given sender, as described in the +[Client-Server API](/client-server-api/#sticky-events). + +## Querying for information + +Queries are a way to retrieve information from a homeserver about a +resource, such as a user or room. The endpoints here are often called in +conjunction with a request from a client on the client-server API in +order to complete the call. + +There are several types of queries that can be made. The generic +endpoint to represent all queries is described first, followed by the +more specific queries that can be made. + +{{% http-api spec="server-server" api="query" %}} + +## OpenID + +Third-party services can exchange an access token previously generated +by the [OpenID module of the Client-Server +API](/client-server-api/#openid) for information about a user. This can +help verify that a user is who they say they are without granting full +access to the user's account. + +Access tokens generated by the OpenID API are only good for the OpenID +API and nothing else. + +{{% http-api spec="server-server" api="openid" %}} + +## Device Management + +Details of a user's devices must be efficiently published to other users +and kept up-to-date. This is critical for reliable end-to-end +encryption, in order for users to know which devices are participating +in a room. It's also required for to-device messaging to work. This +section is intended to complement the [Device Management +module](/client-server-api#device-management) +of the Client-Server API. + +Taper currently uses a custom pubsub system for synchronising +information about the list of devices for a given user over federation. +When a server wishes to determine a remote user's device list for the +first time, it should populate a local cache from the result of a +`/user/keys/query` API on the remote server. However, subsequent updates +to the cache should be applied by consuming `t.device_list_update` EDUs. +Each new `t.device_list_update` EDU describes an incremental change to +one device for a given user which should replace any existing entry in +the local server's cache of that device list. Servers must send +`t.device_list_update` EDUs to all the servers who share a room with a +given local user, and must be sent whenever that user's device list +changes (i.e. for new or deleted devices, when that user joins a room +which contains servers which are not already receiving updates for that +user's device list, or changes in device information such as the +device's human-readable name). + +Servers send `t.device_list_update` EDUs in a sequence per origin user, +each with a unique `stream_id`. They also include a pointer to the most +recent previous EDU(s) that this update is relative to in the `prev_id` +field. To simplify implementation for clustered servers which could send +multiple EDUs at the same time, the `prev_id` field should include all +`t.device_list_update` EDUs which have not been yet been referenced in a +EDU. If EDUs are emitted in series by a server, there should only ever +be one `prev_id` in the EDU. + +This forms a simple directed acyclic graph of `t.device_list_update` +EDUs, showing which EDUs a server needs to have received in order to +apply an update to its local copy of the remote user's device list. If a +server receives an EDU which refers to a `prev_id` it does not +recognise, it must resynchronise its list by calling the +`/user/keys/query API` and resume the process. The response contains a +`stream_id` which should be used to correlate with subsequent +`t.device_list_update` EDUs. + +{{% http-api spec="server-server" api="user_devices" %}} + +{{% definition path="api/server-server/definitions/event-schemas/t.device_list_update" %}} + +## End-to-End Encryption + +This section complements the [End-to-End Encryption +module](/client-server-api#end-to-end-encryption) +of the Client-Server API. For detailed information about end-to-end +encryption, please see that module. + +The APIs defined here are designed to be able to proxy much of the +client's request through to federation, and have the response also be +proxied through to the client. + +{{% http-api spec="server-server" api="user_keys" %}} + +{{% definition path="api/server-server/definitions/event-schemas/t.signing_key_update" %}} + +## Send-to-device messaging + +The server API for send-to-device messaging is based on the +`t.direct_to_device` EDU. There are no PDUs or Federation Queries +involved. + +Each send-to-device message should be sent to the destination server +using the following EDU: + +{{% definition path="api/server-server/definitions/event-schemas/t.direct_to_device" %}} + +## Content Repository + +Attachments to events (images, files, etc) are uploaded to a homeserver +via the Content Repository described in the [Client-Server +API](/client-server-api/#content-repository). When a server wishes +to serve content originating from a remote server, it needs to ask the +remote server for the media. + +Servers MUST use the server described in the [Taper Content URI](/client-server-api/#taper-content-runit-uris). +Formatted as `runit://{ServerName}/{MediaID}`, servers MUST download the media from +`ServerName` using the below endpoints. + +{{% changed-in v="1.11" %}} Servers were previously advised to use the `/_taper/media/*` +endpoints described by the [Content Repository module in the Client-Server API](/client-server-api/#content-repository), +however, those endpoints have been deprecated. New endpoints are introduced which +require authentication. Naturally, as a server is not a user, they cannot provide +the required access token to those endpoints. Instead, servers MUST try the endpoints +described below before falling back to the deprecated `/_taper/media/*` endpoints +when they receive a `404 T_UNRECOGNIZED` error. When falling back, servers MUST +be sure to set `allow_remote` to `false`. + +{{% http-api spec="server-server" api="content_repository" %}} + +## Server Access Control Lists (ACLs) + +Server ACLs and their purpose are described in the [Server +ACLs](/client-server-api#server-access-control-lists-acls-for-rooms) +section of the Client-Server API. + +When a remote server makes a request, it MUST be verified to be allowed +by the server ACLs. If the server is denied access to a room, the +receiving server MUST reply with a 403 HTTP status code and an `errcode` +of `T_FORBIDDEN`. + +The following endpoint prefixes MUST be protected: + +- `/_taper/federation/v1/make_join` +- `/_taper/federation/v1/make_leave` +- `/_taper/federation/v1/send_join` +- `/_taper/federation/v2/send_join` +- `/_taper/federation/v1/send_leave` +- `/_taper/federation/v2/send_leave` +- `/_taper/federation/v1/invite` +- `/_taper/federation/v2/invite` +- `/_taper/federation/v1/make_knock` +- `/_taper/federation/v1/send_knock` +- `/_taper/federation/v1/state` +- `/_taper/federation/v1/state_ids` +- `/_taper/federation/v1/backfill` +- `/_taper/federation/v1/event_auth` +- `/_taper/federation/v1/get_missing_events` + +Additionally the [`/_taper/federation/v1/send/{txnId}`](#put_taperfederationv1sendtxnid) +endpoint MUST be protected as follows: + +- ACLs MUST be applied to all PDUs on a per-PDU basis. If the sending + server is denied access to the room identified by `room_id`, the PDU + MUST be ignored with an appropriate error included in the response + for the respective event ID. +- ACLs MUST be applied to all EDUs that are local to a specific room: + + - For [typing notifications (`t.typing`)](#typing-notifications), if + the sending server is denied access to the room identified by + `room_id`, the EDU MUST be ignored. + - For [receipts (`t.receipt`)](#receipts), all receipts for a particular + room ID MUST be ignored if the sending server is denied access to + the room identified by that ID. + +The following endpoints MAY be protected: + +- [`/_taper/policy/v1/sign`](#post_taperpolicyv1sign) - {{< added-in v="1.18" >}} + Protected if the server is tracking the DAG and chooses to enforce the ACL. + + +## Policy Servers + +{{% added-in v="1.18" %}} + +Policy Servers are an available tool for rooms to add proactive protections. Rooms +which use a Policy Server (PS) can prevent unwanted events from reaching users. Rooms +are not required to use a Policy Server, and can disable it any time after enabling +it. + +For a homeserver to be a Policy Server, it MUST implement the following functionality +of the Server-Server API: + +* [Normal server name resolution](#resolving-server-names). +* [Publishing a signing key](#publishing-keys). +* [Request authentication](#authentication). +* Being able to [make and send join requests](#joining-rooms). +* Receiving and processing [`POST /_taper/policy/v1/sign`](#post_taperpolicyv1sign) + requests. + +All other functionality and endpoints are optional for a Policy Server. + +{{% boxes/note %}} +Though a Policy Server is not required to implement the full Server-Server API +surface, some functionality may be desirable to implement anyway: + +* Receiving [invites](#inviting-to-a-room) can make it easier to add the Policy + Server to a room. +* Receiving [transactions](#transactions) is recommended to avoid remote servers + flagging the Policy Server as "offline", even if the contents are discarded. +* Receiving [device lookups](#get_taperfederationv1userdevicesuserid) can also + help reduce remote servers flagging the Policy Server as "offline". +{{% /boxes/note %}} + +{{% boxes/note %}} +Policy Servers are *not* required to track the DAG for a room. Policy Servers +might be optimized for content moderation and therefore do not need knowledge of +the DAG. +{{% /boxes/note %}} + +### Determining if a Policy Server is enabled in a room + +For a room to be considered as "using" a Policy Server, *all* of the following +conditions MUST be true: + +* The *current state* for the room has a valid [`t.room.policy`](/client-server-api/#lroompolicy) + state event with empty state key. Valid means `content` contains at least: + * A string value for `via`. + * An object value for `public_keys` containing at least a string value for + `ed25519`. +* The server name denoted by the `t.room.policy` state event's `via` has at least + one joined user in the room in *current state*. The user does not need any + special permissions or power levels in the room. + +If a room has enabled a Policy Server, *all* servers in that room MUST [ask that +Policy Server](#asking-for-a-policy-server-signature-on-an-event) for a signature +before sending an event. If the Policy Server refuses to sign the event being +sent, servers SHOULD fail to send that event as per the [validation rules](#validating-policy-server-signatures). + +{{% boxes/note %}} +"Current state" shares the same definition as [soft failure](#soft-failure). +{{% /boxes/note %}} + +{{% boxes/note %}} +Policy Servers MUST have at least one joined user in the room to give the Policy +Server agency in whether it serves that role for the room. Otherwise, a room +would be able to force a Policy Server to participate and then overwhelm it. +{{% /boxes/note %}} + +### Validating Policy Server signatures + +Policy Servers use signatures to indicate whether an event was checked and is +recommended for inclusion in a room. The Policy Server's recommendation does *not* +affect the authorization rules for an event, but does affect whether homeservers +[soft fail](#soft-failure) or refuse to actually go forward with sending an event. + +If a room has disabled (or never enabled) a Policy Server, events are recommended +for inclusion and subject to normal authorization rules. + +{{% boxes/note %}} +Because the Policy Server is not asked to sign [`t.room.policy`](/client-server-api/#lroompolicy) +state events with empty string `state_key`s, those events will not have a Policy +Server signature. Those events are by default recommended for inclusion and still +subject to normal authorization rules. + +All other events SHOULD have a valid Policy Server signature when a Policy Server +is enabled in the room, including non-state `t.room.policy` events and `t.room.policy` +state events with non-empty `state_key`s. This also includes state events like +membership and power level changes. +{{% /boxes/note %}} + +If a room has enabled a Policy Server, the Policy Server's signature appears +alongside the normal [event signatures](#signing-events), though uses a public +key from the room's `t.room.policy` state event. + +{{% boxes/note %}} +Currently, only Ed25519 keys are supported by homeservers. The Key ID for the +`ed25519` key in `t.room.policy` is *always* `ed25519:policy_server`. +{{% /boxes/note %}} + +{{% boxes/note %}} +By embedding the Policy Server's public key into room state, the Policy Server +does not need to be online or have its keys cached by a notary in order to validate +an event. +{{% /boxes/note %}} + +{{% boxes/warning %}} +The Policy Server's [published signing key](#publishing-keys) SHOULD NOT be the +same key contained in the `t.room.policy` state event. This is to keep "can send +federation traffic" and "can recommend events for inclusion" separate, and to +allow rooms to revoke the Policy Server's key without cooperation of the Policy +Server. + +If the Policy Server is acting as a normal homeserver and attempting to send an +event, that event will require a signature from the server's published signing +key alongside the Policy Server signature described in this section. +{{% /boxes/warning %}} + +If the Policy Server's signature is valid, the event is recommended for inclusion +in the room, and is still subject to normal authorization rules. + +If the Policy Server's signature is invalid or missing, the homeserver SHOULD +[ask for a new signature](#asking-for-a-policy-server-signature-on-an-event). If +the event still does not have a valid Policy Server signature, the event is *not* +recommended for inclusion and the homeserver SHOULD: + +* If applicable, reject the Client-Server API request which was generating the + event. If the Policy Server returned an error, that error SHOULD be provided + to the client verbatim. The event the client was attempting to send SHOULD be + discarded and not processed/sent any further. +* If the event was received over federation or the homeserver sends a local client's + event anyway, [soft fail](#soft-failure) the event. + +{{% boxes/note %}} +For clarity, an event which lacks a valid Policy Server signature is still subject +to normal authorization rules. +{{% /boxes/note %}} + +{{% boxes/note %}} +When a Policy Server's signature is invalid, a new one is requested because the +Policy Server's key may have rotated between the event being signed and the event +being checked. + +Because the key is contained in the `t.room.policy` state event, if the Policy +Server rotates its key without the room also updating the state event, events +will be flagged as not recommended for inclusion. This is expected behaviour. +{{% /boxes/note %}} + +### Asking for a Policy Server signature on an event + +Per [above](#determining-if-a-policy-server-is-enabled-in-a-room), if a room has +a Policy Server enabled, *all* servers in the room MUST ask the Policy Server to +sign their events before sending them to clients and servers. + +After asking for a signature, homeservers SHOULD [validate](#validating-policy-server-signatures) +the returned signature before continuing to send events. If the Policy Server +returns an error, the event SHOULD NOT be sent to clients and servers. + +{{% http-api spec="server-server" api="room_policy" %}} + +## Signing Events + +Signing events is complicated by the fact that servers can choose to +redact non-essential parts of an event. + +### Adding hashes and signatures to outgoing events + +Before signing the event, the *content hash* of the event is calculated +as described below. The hash is encoded using [Unpadded +Base64](/appendices#unpadded-base64) and stored in the event +object, in a `hashes` object, under a `sha256` key. + +The event object is then *redacted*, following the [redaction +algorithm](/client-server-api#redactions). +Finally it is signed as described in [Signing +JSON](/appendices#signing-json), using the server's signing key +(see also [Retrieving server keys](#retrieving-server-keys)). + +The signature is then copied back to the original event object. + +For an example of a signed event, see the [room version +specification](/rooms). + +{{% boxes/note %}} +{{% added-in v="1.18" %}} +Events sent in rooms with [Policy Servers](#policy-servers) MUST [ask](#asking-for-a-policy-server-signature-on-an-event) +the Policy Server for a signature too. +{{% /boxes/note %}} + +### Validating hashes and signatures on received events + +When a server receives an event over federation from another server, the +receiving server should check the hashes and signatures on that event. + +First the signatures are checked. The event is redacted following the +[redaction algorithm](/client-server-api#redactions), and +the resultant object is checked for signatures from the originating +server, following the algorithm described in [Checking for a +signature](/appendices#checking-for-a-signature). Note that this +step should succeed whether we have been sent the full event or a +redacted copy. + +For room versions 3 and later, unless the event is a 3rd party invite, only the +signature(s) from the originating server (the server the `sender` belongs to) +are required for verification. Room versions 1 and 2 also require that a +signature is present from the domain in the `event_id`, if it differs from the +originating server. If a signature is from an unknown or expired key, it is +skipped. + +If the event is a 3rd party invite, the sender must already match the 3rd party +invite, and the server which actually sends the event may be a different +server. + +Only signatures from known server keys are validated here. Any unknown keys are ignored. +In particular, the [policy server key](#validating-policy-server-signatures) is not +expected to be published and therefore should be skipped at this stage. +Additionally, any keys that are known to have expired prior to the event's +`origin_server_ts` are ignored. + +{{% boxes/note %}} +{{% added-in v="1.18" %}} +Events sent in rooms with [Policy Servers](#policy-servers) have [additional](#validating-policy-server-signatures) +signature validation requirements. +{{% /boxes/note %}} + +If all signatures from known unexpired keys from the originating server(s) are +found to be valid, the expected content hash is calculated as described below. +The content hash in the `hashes` property of the received event is base64-decoded, +and the two are compared for equality. + +If the hash check fails, then it is assumed that this is because we have +only been given a redacted version of the event. To enforce this, the +receiving server should use the redacted copy it calculated rather than +the full copy it received. + +### Calculating the reference hash for an event + +The *reference hash* of an event covers the essential fields of an +event, including content hashes. It is used for event identifiers in +some room versions. See the [room version +specification](/rooms) for more information. It is +calculated as follows. + +1. The event is put through the redaction algorithm. +2. The `signatures` and `unsigned` properties are removed + from the event, if present. +3. The event is converted into [Canonical + JSON](/appendices#canonical-json). +4. A sha256 hash is calculated on the resulting JSON object. + +### Calculating the content hash for an event + +The *content hash* of an event covers the complete event including the +*unredacted* contents. It is calculated as follows. + +{{% boxes/note %}} +In [room version 13](/rooms/v13#content-hash) and later, the content hash of a +non-state event is calculated over the *redacted* event instead, so it does +not cover message content. In those room versions, a content hash mismatch on +a non-state event means the event was tampered with, and the event is +rejected rather than treated as a redacted copy. +{{% /boxes/note %}} + +First, any existing `unsigned`, `signatures`, and `hashes` properties are +removed. The resulting object is then encoded as [Canonical +JSON](/appendices#canonical-json), and the JSON is hashed using +SHA-256. + +### Example code + +```py +def hash_and_sign_event(event_object, signing_key, signing_name): + # First we need to hash the event object. + content_hash = compute_content_hash(event_object) + event_object["hashes"] = {"sha256": encode_unpadded_base64(content_hash)} + + # Strip all the keys that would be removed if the event was redacted. + # The hashes are not stripped and cover all the keys in the event. + # This means that we can tell if any of the non-essential keys are + # modified or removed. + stripped_object = strip_non_essential_keys(event_object) + + # Sign the stripped JSON object. The signature only covers the + # essential keys and the hashes. This means that we can check the + # signature even if the event is redacted. + signed_object = sign_json(stripped_object, signing_key, signing_name) + + # Copy the signatures from the stripped event to the original event. + event_object["signatures"] = signed_object["signatures"] + +def compute_content_hash(event_object): + # take a copy of the event before we remove any keys. + event_object = dict(event_object) + + # Keys under "unsigned" can be modified by other servers. + # They are useful for conveying information like the age of an + # event that will change in transit. + # Since they can be modified we need to exclude them from the hash. + event_object.pop("unsigned", None) + + # Signatures will depend on the current value of the "hashes" key. + # We cannot add new hashes without invalidating existing signatures. + event_object.pop("signatures", None) + + # The "hashes" key might contain multiple algorithms if we decide to + # migrate away from SHA-2. We don't want to include an existing hash + # output in our hash so we exclude the "hashes" dict from the hash. + event_object.pop("hashes", None) + + # Encode the JSON using a canonical encoding so that we get the same + # bytes on every server for the same JSON object. + event_json_bytes = encode_canonical_json(event_object) + + return hashlib.sha256(event_json_bytes) +``` + +## Security considerations + +When a domain's ownership changes, the new controller of the domain can +masquerade as the previous owner, receiving messages (similarly to +email) and request past messages from other servers. In the future, +proposals like +[MSC1228](https://github.com/matrix-org/matrix-spec-proposals/issues/1228) will +address this issue. diff --git a/data/api/application-service/definitions/location.yaml b/data/api/application-service/definitions/location.yaml new file mode 100644 index 0000000000000000000000000000000000000000..78575245d82a6960e2e61d8c4a6e862d5685eaaf --- /dev/null +++ b/data/api/application-service/definitions/location.yaml @@ -0,0 +1,32 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +properties: + alias: + description: An alias for a taper room. + type: string + example: "#freenode_#matrix:matrix.org" + protocol: + description: The protocol ID that the third-party location is a part of. + type: string + example: "irc" + fields: + description: Information used to identify this third-party location. + type: object + example: { + "network": "freenode", + "channel": "#matrix" + } +required: ['alias', 'protocol', 'fields'] +title: Location +type: object \ No newline at end of file diff --git a/data/api/application-service/definitions/location_batch.yaml b/data/api/application-service/definitions/location_batch.yaml new file mode 100644 index 0000000000000000000000000000000000000000..35875ddbc36ac0e01f01e55f0b2c2fcc3b04ba3e --- /dev/null +++ b/data/api/application-service/definitions/location_batch.yaml @@ -0,0 +1,17 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: array +description: List of matched third-party locations. +items: + $ref: location.yaml diff --git a/data/api/application-service/definitions/namespace_list.yaml b/data/api/application-service/definitions/namespace_list.yaml new file mode 100644 index 0000000000000000000000000000000000000000..35f5d61ae0f264b0405b4ed1e4309d175ac0545b --- /dev/null +++ b/data/api/application-service/definitions/namespace_list.yaml @@ -0,0 +1,29 @@ +# Copyright 2022 The Matrix.org Foundation C.I.C +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +$schema: https://json-schema.org/draft/2020-12/schema + +type: array +items: + type: object + title: Namespace + properties: + regex: + type: string + description: A POSIX regular expression defining which values this namespace includes. + exclusive: + type: boolean + description: A true or false value stating whether this application service has exclusive access to events within this namespace. + required: + - regex + - exclusive diff --git a/data/api/application-service/definitions/protocol.yaml b/data/api/application-service/definitions/protocol.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a91045b9229c3fade9ba79f0d6919d2be622d529 --- /dev/null +++ b/data/api/application-service/definitions/protocol.yaml @@ -0,0 +1,26 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +allOf: +- $ref: protocol_base.yaml +- type: object + properties: + instances: + description: |- + A list of objects representing independent instances of configuration. + For example, multiple networks on IRC if multiple are provided by the + same application service. + type: array + items: + $ref: protocol_instance.yaml + required: ['instances'] diff --git a/data/api/application-service/definitions/protocol_base.yaml b/data/api/application-service/definitions/protocol_base.yaml new file mode 100644 index 0000000000000000000000000000000000000000..dfb7348d85ccb11623e7b5652bca8ffe468204e0 --- /dev/null +++ b/data/api/application-service/definitions/protocol_base.yaml @@ -0,0 +1,80 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +title: Protocol +type: object +properties: + user_fields: + description: |- + Fields which may be used to identify a third-party user. These should be + ordered to suggest the way that entities may be grouped, where higher + groupings are ordered first. For example, the name of a network should be + searched before the nickname of a user. + type: array + items: + type: string + description: Field used to identify a third-party user. + example: ["network", "nickname"] + location_fields: + description: |- + Fields which may be used to identify a third-party location. These should be + ordered to suggest the way that entities may be grouped, where higher + groupings are ordered first. For example, the name of a network should be + searched before the name of a channel. + type: array + items: + type: string + description: Field used to identify a third-party location. + example: ["network", "channel"] + icon: + description: A content URI representing an icon for the third-party protocol. + type: string + example: "runit://example.org/aBcDeFgH" + field_types: + description: |- + The type definitions for the fields defined in `user_fields` and + `location_fields`. Each entry in those arrays MUST have an entry here. + The `string` key for this object is the field name itself. + + May be an empty object if no fields are defined. + type: object + additionalProperties: + title: Field Type + description: Definition of valid values for a field. + type: object + properties: + regexp: + description: |- + A regular expression for validation of a field's value. This may be relatively + coarse to verify the value as the application service providing this protocol + may apply additional validation or filtering. + type: string + placeholder: + description: A placeholder serving as a valid example of the field value. + type: string + required: ['regexp', 'placeholder'] + example: { + "network": { + "regexp": "([a-z0-9]+\\.)*[a-z0-9]+", + "placeholder": "irc.example.org" + }, + "nickname": { + "regexp": "[^\\s#]+", + "placeholder": "username" + }, + "channel": { + "regexp": "#[^\\s]+", + "placeholder": "#foobar" + } + } +required: ['user_fields', 'location_fields', 'icon', 'field_types'] diff --git a/data/api/application-service/definitions/protocol_instance.yaml b/data/api/application-service/definitions/protocol_instance.yaml new file mode 100644 index 0000000000000000000000000000000000000000..46d176866d86d4334e9b2ed0afa8252c4a29c6fd --- /dev/null +++ b/data/api/application-service/definitions/protocol_instance.yaml @@ -0,0 +1,37 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: Protocol Instance +properties: + desc: + type: string + description: A human-readable description for the protocol, such as the name. + example: "Freenode" + icon: + type: string + description: |- + An optional content URI representing the protocol. Overrides the one provided + at the higher level Protocol object. + example: "runit://example.org/JkLmNoPq" + fields: + type: object + description: Preset values for `fields` the client may use to search by. + example: { + "network": "freenode" + } + network_id: + type: string + description: A unique identifier across all instances. + example: "freenode" +required: ['desc', 'fields', 'network_id'] diff --git a/data/api/application-service/definitions/registration.yaml b/data/api/application-service/definitions/registration.yaml new file mode 100644 index 0000000000000000000000000000000000000000..559cbe130e91716457eccafcc4fdf97df347ff91 --- /dev/null +++ b/data/api/application-service/definitions/registration.yaml @@ -0,0 +1,85 @@ +# Copyright 2022 The Matrix.org Foundation C.I.C +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +$schema: https://json-schema.org/draft/2020-12/schema + +type: object +title: Registration +properties: + id: + type: string + description: A unique, user-defined ID of the application service which will never change. + url: + type: ["null", "string"] + description: The URL for the application service. May include a path after the domain name. Optionally set to null if no traffic is required. + as_token: + type: string + description: A secret token that the application service will use to authenticate requests to the homeserver. + hs_token: + type: string + description: A secret token that the homeserver will use to authenticate requests to the application service. + sender_localpart: + type: string + description: |- + The localpart of the user associated with the application service. Events will be sent to the AS if this user is the target of the event, or + is a joined member of the room where the event occurred. + receive_ephemeral: + type: boolean + x-addedInMatrixVersion: "1.13" + description: |- + Whether the application service wants to [receive ephemeral data](/application-service-api/#pushing-ephemeral-data). + + Defaults to `false` if not present. + namespaces: + type: object + title: Namespaces + description: The namespaces that the application service is interested in. + properties: + users: + allOf: + - $ref: namespace_list.yaml + - description: |- + A list of namespaces defining the user IDs that the application + service is interested in, in addition to its `sender_localpart`. + Events will be sent to the AS if a local user matching one of the + namespaces is the target of the event, or is a joined member of + the room where the event occurred. + rooms: + allOf: + - $ref: namespace_list.yaml + - description: |- + A list of namespaces defining the room IDs that the application + service is interested in. All events sent in a room with an ID + which matches one of the namespaces will be sent to the AS. + aliases: + allOf: + - $ref: namespace_list.yaml + - description: |- + A list of namespaces defining the room aliases that the application + service is interested in. All events sent in a room with an alias + which matches one of the namespaces will be sent to the AS. + rate_limited: + type: boolean + description: Whether requests from masqueraded users are rate-limited. The sender is excluded. + protocols: + type: array + description: The external protocols which the application service provides (e.g. IRC). + items: + type: string +required: + - id + - url + - as_token + - hs_token + - sender_localpart + - namespaces diff --git a/data/api/application-service/definitions/security.yaml b/data/api/application-service/definitions/security.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b2ba1293f8e850548933c05a2cd25dfd7ba84d0b --- /dev/null +++ b/data/api/application-service/definitions/security.yaml @@ -0,0 +1,18 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +homeserverAccessToken: + type: http + scheme: bearer + description: The `Bearer` `hs_token` provided by the application service's registration. diff --git a/data/api/application-service/definitions/user.yaml b/data/api/application-service/definitions/user.yaml new file mode 100644 index 0000000000000000000000000000000000000000..110c7785b92e561e4ce356ffe09f5f799da32c35 --- /dev/null +++ b/data/api/application-service/definitions/user.yaml @@ -0,0 +1,33 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# TODO: Change userid to user_id as a breaking change +properties: + userid: + description: A Taper User ID representing a third-party user. + type: string + example: "@_gitter_jim:matrix.org" + protocol: + description: The protocol ID that the third-party location is a part of. + type: string + example: "gitter" + fields: + description: Information used to identify this third-party location. + type: object + example: { + "user": "jim" + } +required: ['userid', 'protocol', 'fields'] +title: User +type: object \ No newline at end of file diff --git a/data/api/application-service/definitions/user_batch.yaml b/data/api/application-service/definitions/user_batch.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f98859960daccaf8f2cac2b4c7ace7ea09c76102 --- /dev/null +++ b/data/api/application-service/definitions/user_batch.yaml @@ -0,0 +1,17 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: array +description: List of matched third-party users. +items: + $ref: user.yaml diff --git a/data/api/application-service/ping.yaml b/data/api/application-service/ping.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7a97256e09eda5a575dd59ce30138c2df56794a2 --- /dev/null +++ b/data/api/application-service/ping.yaml @@ -0,0 +1,73 @@ +# Copyright 2023 Tulir Asokan +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Application Service API + version: 1.0.0 +paths: + /ping: + post: + x-addedInMatrixVersion: "1.7" + summary: Ping the application service + description: |- + This API is called by the homeserver to ensure that the connection works + and the `hs_token` the homeserver has is correct. + + Currently this is only called by the homeserver as a direct result of + the application service calling + [`POST /_taper/client/v1/appservice/{appserviceId}/ping`](/application-service-api/#post_taperclientv1appserviceappserviceidping). + operationId: ping + security: + - homeserverAccessToken: [] + requestBody: + content: + application/json: + schema: + type: object + example: { + "transaction_id": "mautrix-go_1683636478256400935_123" + } + properties: + transaction_id: + type: string + description: |- + A transaction ID for the ping, copied directly from the + `POST /_taper/client/v1/appservice/{appserviceId}/ping` call. + description: Ping body with optional transaction ID. + responses: + "200": + description: The provided `hs_token` is valid and the ping request was successful. + content: + application/json: + schema: + type: object + examples: + response: + value: {} +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/app/v1 +components: + securitySchemes: + homeserverAccessToken: + $ref: definitions/security.yaml#/homeserverAccessToken diff --git a/data/api/application-service/protocols.yaml b/data/api/application-service/protocols.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d67a838546d5be7b35b883804f1e48331019d055 --- /dev/null +++ b/data/api/application-service/protocols.yaml @@ -0,0 +1,343 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Application Service API + version: 1.0.0 +paths: + "/thirdparty/protocol/{protocol}": + get: + summary: Retrieve metadata about a specific protocol that the application + service supports. + description: |- + This API is called by the homeserver when it wants to present clients + with specific information about the various third-party networks that + an application service supports. + operationId: getProtocolMetadata + security: + - homeserverAccessToken: [] + parameters: + - in: path + name: protocol + description: The protocol ID. + required: true + example: irc + schema: + type: string + responses: + "200": + description: The protocol was found and metadata returned. + content: + application/json: + schema: + $ref: definitions/protocol.yaml + "401": + description: |- + The homeserver has not supplied credentials to the application service. + Optional error information can be included in the body of this response. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" + } + "403": + description: The credentials supplied by the homeserver were rejected. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_FORBIDDEN" + } + "404": + description: No protocol was found with the given path. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_NOT_FOUND" + } + "/thirdparty/user/{protocol}": + get: + summary: Retrieve the Taper User ID of a corresponding third-party user. + description: |- + This API is called by the homeserver in order to retrieve a Taper + User ID linked to a user on the third-party network, given a set of + user parameters. + operationId: queryUserByProtocol + security: + - homeserverAccessToken: [] + parameters: + - in: path + name: protocol + description: The protocol ID. + required: true + example: irc + schema: + type: string + - in: query + name: fields + description: |- + One or more custom fields that are passed to the application + service to help identify the user. + schema: + type: object + additionalProperties: + type: string + responses: + "200": + description: The Taper User IDs found with the given parameters. + content: + application/json: + schema: + $ref: definitions/user_batch.yaml + "401": + description: |- + The homeserver has not supplied credentials to the application service. + Optional error information can be included in the body of this response. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" + } + "403": + description: The credentials supplied by the homeserver were rejected. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_FORBIDDEN" + } + "404": + description: No users were found with the given parameters. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_NOT_FOUND" + } + "/thirdparty/location/{protocol}": + get: + summary: Retrieve Taper-side portal rooms leading to a third-party location. + description: Retrieve a list of Taper portal rooms that lead to the matched + third-party location. + operationId: queryLocationByProtocol + security: + - homeserverAccessToken: [] + parameters: + - in: path + name: protocol + description: The protocol ID. + required: true + example: irc + schema: + type: string + - in: query + name: fields + description: |- + One or more custom fields that are passed to the application + service to help identify the third-party location. + schema: + type: object + additionalProperties: + type: string + responses: + "200": + description: At least one portal room was found. + content: + application/json: + schema: + $ref: definitions/location_batch.yaml + "401": + description: |- + The homeserver has not supplied credentials to the application service. + Optional error information can be included in the body of this response. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" + } + "403": + description: The credentials supplied by the homeserver were rejected. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_FORBIDDEN" + } + "404": + description: No mappings were found with the given parameters. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_NOT_FOUND" + } + /thirdparty/location: + get: + summary: Reverse-lookup third-party locations given a Taper room alias. + description: |- + Retrieve an array of third-party network locations from a Taper room + alias. + operationId: queryLocationByAlias + security: + - homeserverAccessToken: [] + parameters: + - in: query + name: alias + description: The Taper room alias to look up. + schema: + type: string + responses: + "200": + description: All found third-party locations. + content: + application/json: + schema: + $ref: definitions/location_batch.yaml + "401": + description: |- + The homeserver has not supplied credentials to the application service. + Optional error information can be included in the body of this response. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" + } + "403": + description: The credentials supplied by the homeserver were rejected. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_FORBIDDEN" + } + "404": + description: No mappings were found with the given parameters. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_NOT_FOUND" + } + /thirdparty/user: + get: + summary: Reverse-lookup third-party users given a Taper User ID. + description: Retrieve an array of third-party users from a Taper User ID. + operationId: queryUserByID + security: + - homeserverAccessToken: [] + parameters: + - in: query + name: userid + description: The Taper User ID to look up. + schema: + type: string + responses: + "200": + description: An array of third-party users. + content: + application/json: + schema: + $ref: definitions/user_batch.yaml + "401": + description: |- + The homeserver has not supplied credentials to the application service. + Optional error information can be included in the body of this response. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" + } + "403": + description: The credentials supplied by the homeserver were rejected. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" + } + "404": + description: No mappings were found with the given parameters. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_NOT_FOUND" + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/app/v1 +components: + securitySchemes: + homeserverAccessToken: + $ref: definitions/security.yaml#/homeserverAccessToken diff --git a/data/api/application-service/query_room.yaml b/data/api/application-service/query_room.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3cccb2fc40dd706ad1632249a6c02378d5c84ee6 --- /dev/null +++ b/data/api/application-service/query_room.yaml @@ -0,0 +1,107 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Application Service API + version: 1.0.0 +paths: + "/rooms/{roomAlias}": + get: + summary: Query if a room alias should exist on the application service. + description: |- + This endpoint is invoked by the homeserver on an application service to query + the existence of a given room alias. The homeserver will only query room + aliases inside the application service's `aliases` namespace. The + homeserver will send this request when it receives a request to join a + room alias within the application service's namespace. + operationId: queryRoomByAlias + security: + - homeserverAccessToken: [] + parameters: + - in: path + name: roomAlias + description: The room alias being queried. + required: true + example: "#magicforest:example.com" + schema: + type: string + responses: + "200": + description: |- + The application service indicates that this room alias exists. The + application service MUST have created a room and associated it with + the queried room alias using the client-server API. Additional + information about the room such as its name and topic can be set + before responding. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "401": + description: |- + The homeserver has not supplied credentials to the application service. + Optional error information can be included in the body of this response. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" + } + "403": + description: The credentials supplied by the homeserver were rejected. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_FORBIDDEN" + } + "404": + description: |- + The application service indicates that this room alias does not exist. + Optional error information can be included in the body of this response. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_NOT_FOUND" + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/app/v1 +components: + securitySchemes: + homeserverAccessToken: + $ref: definitions/security.yaml#/homeserverAccessToken diff --git a/data/api/application-service/query_user.yaml b/data/api/application-service/query_user.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8769f9335f34829b3c77da5c1c2e448e6019c701 --- /dev/null +++ b/data/api/application-service/query_user.yaml @@ -0,0 +1,104 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Application Service API + version: 1.0.0 +paths: + "/users/{userId}": + get: + summary: Query if a user should exist on the application service. + description: |- + This endpoint is invoked by the homeserver on an application service to query + the existence of a given user ID. The homeserver will only query user IDs + inside the application service's `users` namespace. The homeserver will + send this request when it receives an event for an unknown user ID in + the application service's namespace, such as a room invite. + operationId: queryUserById + security: + - homeserverAccessToken: [] + parameters: + - in: path + name: userId + description: The user ID being queried. + required: true + example: "@alice:example.com" + schema: + type: string + responses: + "200": + description: |- + The application service indicates that this user exists. The application + service MUST create the user using the client-server API. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "401": + description: |- + The homeserver has not supplied credentials to the application service. + Optional error information can be included in the body of this response. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_UNAUTHORIZED" + } + "403": + description: The credentials supplied by the homeserver were rejected. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_FORBIDDEN" + } + "404": + description: |- + The application service indicates that this user does not exist. + Optional error information can be included in the body of this response. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "COM.EXAMPLE.MYAPPSERVICE_NOT_FOUND" + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/app/v1 +components: + securitySchemes: + homeserverAccessToken: + $ref: definitions/security.yaml#/homeserverAccessToken diff --git a/data/api/application-service/transactions.yaml b/data/api/application-service/transactions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..93728f67b1d6b510822523c412f2ef2d5328ecb9 --- /dev/null +++ b/data/api/application-service/transactions.yaml @@ -0,0 +1,116 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Application Service API + version: 1.0.0 +paths: + "/transactions/{txnId}": + put: + summary: Send some events to the application service. + description: |- + This API is called by the homeserver when it wants to push an event + (or batch of events) to the application service. + + Note that the application service should distinguish state events + from message events via the presence of a `state_key`, rather than + via the event type. + operationId: sendTransaction + security: + - homeserverAccessToken: [] + parameters: + - in: path + name: txnId + description: |- + The transaction ID for this set of events. Homeservers generate + these IDs and they are used to ensure idempotency of requests. + required: true + example: "35" + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + example: { + "ephemeral": [ + { + "$ref": "../../event-schemas/examples/t.receipt.yaml", + "room_id": "!jEsUZKDJdhlrceRyVU:example.org" + }, + { + "$ref": "../../event-schemas/examples/t.presence.yaml" + }, + ], + "events": [ + { + "$ref": "../../event-schemas/examples/t.room.member.yaml" + }, + { + "$ref": "../../event-schemas/examples/t.room.message$t.text.yaml" + } + ] + } + properties: + events: + type: array + description: A list of events, formatted as per the Client-Server API. + items: + $ref: ../client-server/definitions/client_event.yaml + ephemeral: + type: array + x-addedInMatrixVersion: "1.13" + description: |- + A list of ephemeral data, if the `receive_ephemeral` setting was enabled in the + [registration](/application-service-api/#registration) file. + + There are only three event types that can currently occur in this list: `t.presence`, + `t.typing`, and `t.receipt`. Room-scoped ephemeral data (`t.typing` and + `t.receipt`) MUST include a `room_id` property to identify the room that they + were sent in. + + This property can be omitted if it would be empty. + items: + $ref: ../../event-schemas/schema/core-event-schema/event.yaml + required: + - events + description: Transaction information + responses: + "200": + description: The transaction was processed successfully. + content: + application/json: + schema: + type: object + examples: + response: + value: {} +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/app/v1 +components: + securitySchemes: + homeserverAccessToken: + $ref: definitions/security.yaml#/homeserverAccessToken diff --git a/data/api/client-server/account-data.yaml b/data/api/client-server/account-data.yaml new file mode 100644 index 0000000000000000000000000000000000000000..09ff98a789640464e65f6dee3226b4e70890bd72 --- /dev/null +++ b/data/api/client-server/account-data.yaml @@ -0,0 +1,383 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Client Config API + version: 1.0.0 +paths: + "/user/{userId}/account_data/{type}": + put: + summary: Set some account data for the user. + description: |- + Set some account data for the client. This config is only visible to the user + that set the account data. The config will be available to clients through the + top-level `account_data` field in the homeserver response to + [/sync](/client-server-api/#get_taperclientv3sync). + operationId: setAccountData + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + required: true + description: |- + The ID of the user to set account data for. The access token must be + authorised to make requests for this user ID. + example: "@alice:example.com" + schema: + type: string + - in: path + name: type + required: true + description: |- + The event type of the account data to set. Custom types should be + namespaced to avoid clashes. + example: org.example.custom.config + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + example: { + "custom_account_data_key": "custom_config_value" + } + description: The content of the account data. + required: true + responses: + "200": + description: The account data was successfully added. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "400": + description: |- + The request body is not a JSON object. Errcode: `T_BAD_JSON` + or `T_NOT_JSON`. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_JSON", + "error": "Content must be a JSON object." + } + "403": + description: |- + The access token provided is not authorised to modify this user's account + data. Errcode: `T_FORBIDDEN`. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Cannot add account data for other users." + } + "405": + description: |- + This `type` of account data is controlled by the server; it cannot be + modified by clients. Errcode: `T_BAD_JSON`. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_BAD_JSON", + "error": "Cannot set t.fully_read through this API." + } + tags: + - User data + get: + summary: Get some account data for the user. + description: |- + Get some account data for the client. This config is only visible to the user + that set the account data. + operationId: getAccountData + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + required: true + description: |- + The ID of the user to get account data for. The access token must be + authorised to make requests for this user ID. + example: "@alice:example.com" + schema: + type: string + - in: path + name: type + required: true + description: |- + The event type of the account data to get. Custom types should be + namespaced to avoid clashes. + example: org.example.custom.config + schema: + type: string + responses: + "200": + description: The account data content for the given type. + content: + application/json: + schema: + type: object + example: { + "custom_account_data_key": "custom_config_value" + } + "403": + description: |- + The access token provided is not authorised to retrieve this user's account + data. Errcode: `T_FORBIDDEN`. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Cannot add account data for other users." + } + "404": + description: |- + No account data has been provided for this user with the given `type`. + Errcode: `T_NOT_FOUND`. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Account data not found." + } + tags: + - User data + "/user/{userId}/rooms/{roomId}/account_data/{type}": + put: + summary: Set some account data for the user that is specific to a room. + description: |- + Set some account data for the client on a given room. This config is only + visible to the user that set the account data. The config will be delivered to + clients in the per-room entries via [/sync](/client-server-api/#get_taperclientv3sync). + operationId: setAccountDataPerRoom + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + required: true + description: |- + The ID of the user to set account data for. The access token must be + authorised to make requests for this user ID. + example: "@alice:example.com" + schema: + type: string + - in: path + name: roomId + required: true + description: The ID of the room to set account data on. + example: "!726s6s6q:example.com" + schema: + type: string + - in: path + name: type + required: true + description: |- + The event type of the account data to set. Custom types should be + namespaced to avoid clashes. + example: org.example.custom.room.config + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + example: { + "custom_account_data_key": "custom_account_data_value" + } + description: The content of the account data. + required: true + responses: + "200": + description: The account data was successfully added. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "400": + description: |- + The request body is not a JSON object (errcode `T_BAD_JSON` or + `T_NOT_JSON`), or the given `roomID` is not a valid room ID + (errcode `T_INVALID_PARAM`). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_JSON", + "error": "Content must be a JSON object." + } + "403": + description: |- + The access token provided is not authorised to modify this user's account + data. Errcode: `T_FORBIDDEN`. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Cannot add account data for other users." + } + "405": + description: |- + This `type` of account data is controlled by the server; it cannot be + modified by clients. Errcode: `T_BAD_JSON`. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_BAD_JSON", + "error": "Cannot set t.fully_read through this API." + } + tags: + - User data + get: + summary: Get some account data for the user that is specific to a room. + description: |- + Get some account data for the client on a given room. This config is only + visible to the user that set the account data. + operationId: getAccountDataPerRoom + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + required: true + description: |- + The ID of the user to get account data for. The access token must be + authorised to make requests for this user ID. + example: "@alice:example.com" + schema: + type: string + - in: path + name: roomId + required: true + description: The ID of the room to get account data for. + example: "!726s6s6q:example.com" + schema: + type: string + - in: path + name: type + required: true + description: |- + The event type of the account data to get. Custom types should be + namespaced to avoid clashes. + example: org.example.custom.room.config + schema: + type: string + responses: + "200": + description: The account data content for the given type. + content: + application/json: + schema: + type: object + example: { + "custom_account_data_key": "custom_config_value" + } + "400": + description: "The given `roomID` is not a valid room ID. Errcode: + `T_INVALID_PARAM`." + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "@notaroomid:example.org is not a valid room ID." + } + "403": + description: |- + The access token provided is not authorised to retrieve this user's account + data. Errcode: `T_FORBIDDEN`. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Cannot add account data for other users." + } + "404": + description: |- + No account data has been provided for this user and this room with the + given `type`. Errcode: `T_NOT_FOUND`. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Room account data not found." + } + tags: + - User data +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/account_deactivation.yaml b/data/api/client-server/account_deactivation.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7c1a443c4fdd2959fa6d1b5791f35ea642692606 --- /dev/null +++ b/data/api/client-server/account_deactivation.yaml @@ -0,0 +1,150 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Account Deactivation API + version: 1.0.0 +paths: + /account/deactivate: + post: + summary: Deactivate a user's account. + description: |- + Deactivate the user's account, removing all ability for the user to + login again. + + This API endpoint uses the [User-Interactive Authentication API](/client-server-api/#user-interactive-authentication-api). + + An access token should be submitted to this endpoint if the client has + an active session. + + The homeserver may change the flows available depending on whether a + valid access token is provided. + + Unlike other endpoints, this endpoint does not take an `id_access_token` + parameter because the homeserver is expected to sign the request to the + identity server instead. + + {{% boxes/warning %}} + {{% added-in v="1.18" %}} [OAuth 2.0 aware clients](/client-server-api/#oauth-20-aware-clients) + MUST NOT use this endpoint when the server supports the [OAuth 2.0 API](/client-server-api/#oauth-20-api). + Instead they MUST refer the user to the [account management URL](/client-server-api/#oauth-20-account-management), + if available, and MAY use the `action=org.matrix.account_deactivate` + parameter. + {{% /boxes/warning %}} + + {{% added-in v="1.20" %}} When an account is deactivated, the homeserver MUST cancel all of the account's + scheduled [delayed events](/client-server-api/#delayed-events). Homeservers MAY opt to not retain these + cancelled delayed events for retrieval via [`GET /delayed_events/{delayId}`](/client-server-api/#get_taperclientv1delayed_eventsdelayid). + security: + - {} + - accessTokenBearer: [] + operationId: deactivateAccount + requestBody: + content: + application/json: + schema: + type: object + properties: + auth: + description: Additional authentication information for the user-interactive + authentication API. + allOf: + - $ref: definitions/auth_data.yaml + id_server: + type: string + description: |- + The identity server to unbind all of the user's 3PIDs from. + If not provided, the homeserver MUST use the `id_server` + that was originally use to bind each identifier. If the + homeserver does not know which `id_server` that was, + it must return an `id_server_unbind_result` of + `no-support`. + example: example.org + erase: + x-addedInMatrixVersion: "1.10" + type: boolean + description: |- + Whether the user would like their content to be erased as + much as possible from the server. + + Erasure means that any users (or servers) which join the + room after the erasure request are served redacted copies of + the events sent by this account. Users which had visibility + on those events prior to the erasure are still able to see + unredacted copies. No redactions are sent and the erasure + request is not shared over federation, so other servers + might still serve unredacted copies. + + The server should additionally erase any non-event data + associated with the user, such as [account data](/client-server-api/#client-config) + and [contact 3PIDs](/client-server-api/#adding-account-administrative-contact-information). + + Defaults to `false` if not present. + required: true + responses: + "200": + description: The account has been deactivated. + content: + application/json: + schema: + type: object + properties: + id_server_unbind_result: + type: string + enum: + - success + - no-support + description: |- + An indicator as to whether or not the homeserver was able to unbind + the user's 3PIDs from the identity server(s). `success` indicates + that all identifiers have been unbound from the identity server while + `no-support` indicates that one or more identifiers failed to unbind + due to the identity server refusing the request or the homeserver + being unable to determine an identity server to unbind from. This + must be `success` if the homeserver has no identifiers to unbind + for the user. + example: success + required: + - id_server_unbind_result + "401": + description: The homeserver requires additional authentication information. + content: + application/json: + schema: + $ref: definitions/auth_response.yaml + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Account management +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/admin.yaml b/data/api/client-server/admin.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d0ef723a362beb65909dc370c6616526047d5047 --- /dev/null +++ b/data/api/client-server/admin.yaml @@ -0,0 +1,505 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Administration API + version: 1.0.0 +paths: + "/v3/admin/whois/{userId}": + get: + summary: Gets information about a particular user. + description: |- + Gets information about a particular user. + + This API may be restricted to only be called by the user being looked + up, or by a server admin. Server-local administrator privileges are not + specified in this document. + operationId: getWhoIs + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + description: The user to look up. + required: true + example: "@peter:rabbit.rocks" + schema: + type: string + responses: + "200": + description: The lookup was successful. + content: + application/json: + schema: + type: object + properties: + user_id: + type: string + description: The Taper user ID of the user. + devices: + type: object + description: Each key is an identifier for one of the user's devices. + additionalProperties: + type: object + title: DeviceInfo + properties: + sessions: + type: array + description: A user's sessions (i.e. what they did with an access token from one + login). + items: + type: object + title: SessionInfo + properties: + connections: + type: array + description: Information particular connections in the session. + items: + type: object + title: ConnectionInfo + properties: + ip: + type: string + description: Most recently seen IP address of the session. + last_seen: + type: integer + format: int64 + description: Unix timestamp that the session was last active. + user_agent: + type: string + description: User agent string last seen in the session. + examples: + response: + value: { + "user_id": "@peter:rabbit.rocks", + "devices": { + "teapot": { + "sessions": [ + { + "connections": [ + { + "ip": "127.0.0.1", + "last_seen": 1411996332123, + "user_agent": "curl/7.31.0-DEV" + }, + { + "ip": "10.0.0.2", + "last_seen": 1411996332123, + "user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36" + } + ] + } + ] + } + } + } + tags: + - Server administration + "/v1/admin/suspend/{userId}": + get: + summary: Gets information about the suspended status of a particular user. + x-addedInMatrixVersion: "1.18" + description: |- + Gets information about the suspended status of a particular server-local user. + + The user calling this endpoint MUST be a server admin. + + In order to prevent user enumeration, servers MUST ensure that authorisation is checked + prior to trying to do account lookups. + operationId: getAdminSuspendUser + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + description: The user to look up. + required: true + example: "@peter:rabbit.rocks" + schema: + type: string + format: mx-user-id + pattern: "^@" + + responses: + "200": + description: The lookup was successful. + content: + application/json: + schema: + type: object + properties: + suspended: + type: boolean + description: Whether the target account is suspended. + example: true + required: + - suspended + examples: + response: + value: { + "suspended": true, + } + "400": + description: |- + The user ID does not belong to the local server. The errcode is `T_INVALID_PARAM`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "User does not belong to the local server." + } + "403": + description: |- + The requesting user is not a server administrator, or the target user is another + administrator. The errcode is `T_FORBIDDEN`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Requesting user is not a server administrator." + } + "404": + description: |- + The user ID is not found, or is deactivated. The errcode is `T_NOT_FOUND`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "User not found." + } + tags: + - Server administration + put: + summary: Set the suspended status of a particular user. + x-addedInMatrixVersion: "1.18" + description: |- + Sets the suspended status of a particular server-local user. + + The user calling this endpoint MUST be a server admin. The client SHOULD check that the user + is allowed to suspend other users at the [`GET /capabilities`](/client-server-api/#get_taperclientv3capabilities) + endpoint prior to using this endpoint. + + In order to prevent user enumeration, servers MUST ensure that authorisation is checked + prior to trying to do account lookups. + operationId: setAdminSuspendUser + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + description: The user to change the suspended status of. + required: true + example: "@peter:rabbit.rocks" + schema: + type: string + format: mx-user-id + pattern: "^@" + requestBody: + content: + application/json: + schema: + type: object + properties: + suspended: + type: boolean + description: Whether to suspend the target account. + example: true + required: + - suspended + examples: + request: + value: { + "suspended": true, + } + required: true + + responses: + "200": + description: The action was successful. + content: + application/json: + schema: + type: object + properties: + suspended: + type: boolean + description: Whether the target account is suspended. + example: true + required: + - suspended + examples: + response: + value: { + "suspended": true, + } + "400": + description: |- + The user ID does not belong to the local server. The errcode is `T_INVALID_PARAM`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "User does not belong to the local server." + } + "403": + description: |- + The requesting user is not a server administrator, is trying to suspend their own + account, or the target user is another administrator. The errcode is `T_FORBIDDEN`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Requesting user is not a server administrator." + } + "404": + description: |- + The user ID is not found, or is deactivated. The errcode is `T_NOT_FOUND`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "User not found." + } + tags: + - Server administration + "/v1/admin/lock/{userId}": + get: + summary: Gets information about the locked status of a particular user. + x-addedInMatrixVersion: "1.18" + description: |- + Gets information about the locked status of a particular server-local user. + + The user calling this endpoint MUST be a server admin. + + In order to prevent user enumeration, servers MUST ensure that authorisation is checked + prior to trying to do account lookups. + operationId: getAdminLockUser + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + description: The user to look up. + required: true + example: "@peter:rabbit.rocks" + schema: + type: string + format: mx-user-id + pattern: "^@" + + responses: + "200": + description: The lookup was successful. + content: + application/json: + schema: + type: object + properties: + locked: + type: boolean + description: Whether the target account is locked. + required: + - locked + examples: + response: + value: { + "locked": true, + } + "400": + description: |- + The user ID does not belong to the local server. The errcode is `T_INVALID_PARAM`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "User does not belong to the local server." + } + "403": + description: |- + The requesting user is not a server administrator, or the target user is another + administrator. The errcode is `T_FORBIDDEN`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Requesting user is not a server administrator." + } + "404": + description: |- + The user ID is not found, or is deactivated. The errcode is `T_NOT_FOUND`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "User not found." + } + tags: + - Server administration + put: + summary: Set the locked status of a particular user. + x-addedInMatrixVersion: "1.18" + description: |- + Sets the locked status of a particular server-local user. + + The user calling this endpoint MUST be a server admin. The client SHOULD check that the user + is allowed to lock other users at the [`GET /capabilities`](/client-server-api/#get_taperclientv3capabilities) + endpoint prior to using this endpoint. + + In order to prevent user enumeration, servers MUST ensure that authorisation is checked + prior to trying to do account lookups. + operationId: setAdminLockUser + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + description: The user to change the locked status of. + required: true + example: "@peter:rabbit.rocks" + schema: + type: string + format: mx-user-id + pattern: "^@" + requestBody: + content: + application/json: + schema: + type: object + properties: + locked: + type: boolean + description: Whether to lock the target account. + example: true + required: + - locked + examples: + request: + value: { + "locked": true, + } + required: true + + responses: + "200": + description: The action was successful. + content: + application/json: + schema: + type: object + properties: + locked: + type: boolean + description: Whether the target account is locked. + example: true + required: + - locked + examples: + response: + value: { + "locked": true, + } + "400": + description: |- + The user ID does not belong to the local server. The errcode is `T_INVALID_PARAM`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "User does not belong to the local server." + } + "403": + description: |- + The requesting user is not a server administrator, is trying to lock their own + account, or the target user is another administrator. The errcode is `T_FORBIDDEN`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Requesting user is not a server administrator." + } + "404": + description: |- + The user ID is not found, or is deactivated. The errcode is `T_NOT_FOUND`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "User not found." + } + tags: + - Server administration +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/administrative_contact.yaml b/data/api/client-server/administrative_contact.yaml new file mode 100644 index 0000000000000000000000000000000000000000..646c4f5f8487c9418f0c62e1acef14c7536b3e2e --- /dev/null +++ b/data/api/client-server/administrative_contact.yaml @@ -0,0 +1,612 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Account Administrative Contact API + version: 1.0.0 +paths: + /account/3pid: + get: + summary: Gets a list of a user's third-party identifiers. + description: |- + Gets a list of the third-party identifiers that the homeserver has + associated with the user's account. + + This is *not* the same as the list of third-party identifiers bound to + the user's Taper ID in identity servers. + + Identifiers in this list may be used by the homeserver as, for example, + identifiers that it will accept to reset the user's account password. + operationId: getAccount3PIDs + security: + - accessTokenBearer: [] + responses: + "200": + description: The lookup was successful. + content: + application/json: + schema: + type: object + properties: + threepids: + type: array + items: + type: object + title: Third-party identifier + properties: + medium: + type: string + description: The medium of the third-party identifier. + enum: + - email + - msisdn + address: + type: string + description: The third-party identifier address. + validated_at: + type: integer + format: int64 + description: |- + The timestamp, in milliseconds, when the identifier was + validated by the identity server. + added_at: + type: integer + format: int64 + description: The timestamp, in milliseconds, when the homeserver associated the + third-party identifier with the user. + required: + - medium + - address + - validated_at + - added_at + examples: + response: + value: { + "threepids": [ + { + "medium": "email", + "address": "monkey@banana.island", + "validated_at": 1535176800000, + "added_at": 1535336848756 + } + ] + } + tags: + - Account management + post: + summary: Adds contact information to the user's account. + description: |- + Adds contact information to the user's account. + + This endpoint is deprecated in favour of the more specific `/3pid/add` + and `/3pid/bind` endpoints. + + **Note:** + Previously this endpoint supported a `bind` parameter. This parameter + has been removed, making this endpoint behave as though it was `false`. + This results in this endpoint being an equivalent to `/3pid/bind` rather + than dual-purpose. + + This endpoint uses [capabilities negotiation](/client-server-api/#capabilities-negotiation). + Clients SHOULD check the value of the [`t.3pid_changes` capability](/client-server-api/#l3pid_changes-capability) + to determine if this endpoint is available. + operationId: post3PIDs + deprecated: true + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + three_pid_creds: + title: ThreePidCredentials + type: object + description: The third-party credentials to associate with the account. + properties: + client_secret: + type: string + description: The client secret used in the session with the identity server. + id_server: + type: string + description: The identity server to use. + id_access_token: + type: string + description: |- + An access token previously registered with the identity server. Servers + can treat this as optional to distinguish between r0.5-compatible clients + and this specification version. + sid: + type: string + description: The session identifier given by the identity server. + required: + - client_secret + - id_server + - id_access_token + - sid + required: + - three_pid_creds + example: { + "three_pid_creds": { + "id_server": "matrix.org", + "id_access_token": "abc123_OpaqueString", + "sid": "abc123987", + "client_secret": "d0nt-T3ll" + } + } + required: true + responses: + "200": + description: The addition was successful. + content: + application/json: + schema: + type: object + properties: + submit_url: + type: string + format: uri + description: |- + An optional field containing a URL where the client must + submit the validation token to, with identical parameters + to the Identity Service API's `POST + /validate/email/submitToken` endpoint (without the requirement + for an access token). The homeserver must send this token to the + user (if applicable), who should then be prompted to provide it + to the client. + + If this field is not present, the client can assume that + verification will happen without the client's involvement + provided the homeserver advertises this specification version + in the `/versions` response (ie: r0.5.0). + example: https://example.org/path/to/submitToken + examples: + response: + value: { + "submit_url": "https://example.org/path/to/submitToken" + } + "403": + description: The credentials could not be verified with the identity server. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_THREEPID_AUTH_FAILED", + "error": "The third-party credentials could not be verified by the identity server." + } + tags: + - Account management + /account/3pid/add: + post: + summary: Adds contact information to the user's account. + description: |- + This API endpoint uses the [User-Interactive Authentication API](/client-server-api/#user-interactive-authentication-api). + + Adds contact information to the user's account. Homeservers should use 3PIDs added + through this endpoint for password resets instead of relying on the identity server. + + Homeservers should prevent the caller from adding a 3PID to their account if it has + already been added to another user's account on the homeserver. + + This endpoint uses [capabilities negotiation](/client-server-api/#capabilities-negotiation). + Clients SHOULD check the value of the [`t.3pid_changes` capability](/client-server-api/#l3pid_changes-capability) + to determine if this endpoint is available. + + {{% boxes/warning %}} + Since this endpoint uses User-Interactive Authentication, it cannot be used when the access token was obtained + via the [OAuth 2.0 API](/client-server-api/#oauth-20-api). + {{% /boxes/warning %}} + operationId: add3PID + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + auth: + description: |- + Additional authentication information for the + user-interactive authentication API. + allOf: + - $ref: definitions/auth_data.yaml + client_secret: + type: string + description: The client secret used in the session with the homeserver. + example: d0nt-T3ll + sid: + type: string + description: The session identifier given by the homeserver. + example: abc123987 + required: + - client_secret + - sid + required: true + responses: + "200": + description: The addition was successful. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "401": + description: The homeserver requires additional authentication information. + content: + application/json: + schema: + $ref: definitions/auth_response.yaml + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Account management + /account/3pid/bind: + post: + summary: Binds a 3PID to the user's account through an Identity Service. + description: |- + Binds a 3PID to the user's account through the specified identity server. + + Homeservers should not prevent this request from succeeding if another user + has bound the 3PID. Homeservers should simply proxy any errors received by + the identity server to the caller. + + Homeservers should track successful binds so they can be unbound later. + operationId: bind3PID + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + client_secret: + type: string + description: The client secret used in the session with the identity server. + id_server: + type: string + description: The identity server to use. + id_access_token: + type: string + description: An access token previously registered with the identity server. + sid: + type: string + description: The session identifier given by the identity server. + required: + - client_secret + - id_server + - id_access_token + - sid + example: { + "id_server": "example.org", + "id_access_token": "abc123_OpaqueString", + "sid": "abc123987", + "client_secret": "d0nt-T3ll" + } + required: true + responses: + "200": + description: The addition was successful. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Account management + /account/3pid/delete: + post: + summary: Deletes a third-party identifier from the user's account + description: |- + Removes a third-party identifier from the user's account. This might not + cause an unbind of the identifier from the identity server. + + Unlike other endpoints, this endpoint does not take an `id_access_token` + parameter because the homeserver is expected to sign the request to the + identity server instead. + + This endpoint uses [capabilities negotiation](/client-server-api/#capabilities-negotiation). + Clients SHOULD check the value of the [`t.3pid_changes` capability](/client-server-api/#l3pid_changes-capability) + to determine if this endpoint is available. + operationId: delete3pidFromAccount + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + id_server: + type: string + description: |- + The identity server to unbind from. If not provided, the homeserver + MUST use the `id_server` the identifier was added through. If the + homeserver does not know the original `id_server`, it MUST return + a `id_server_unbind_result` of `no-support`. + example: example.org + medium: + type: string + description: The medium of the third-party identifier being removed. + enum: + - email + - msisdn + example: email + address: + type: string + description: The third-party address being removed. + example: example@example.org + required: + - medium + - address + required: true + responses: + "200": + description: |- + The homeserver has disassociated the third-party identifier from the + user. + content: + application/json: + schema: + type: object + properties: + id_server_unbind_result: + type: string + enum: + - no-support + - success + description: |- + An indicator as to whether or not the homeserver was able to unbind + the 3PID from the identity server. `success` indicates that the + identity server has unbound the identifier whereas `no-support` + indicates that the identity server refuses to support the request + or the homeserver was not able to determine an identity server to + unbind from. + example: success + required: + - id_server_unbind_result + tags: + - Account management + /account/3pid/unbind: + post: + summary: Removes a user's third-party identifier from an identity server. + description: |- + Removes a user's third-party identifier from the provided identity server + without removing it from the homeserver. + + Unlike other endpoints, this endpoint does not take an `id_access_token` + parameter because the homeserver is expected to sign the request to the + identity server instead. + operationId: unbind3pidFromAccount + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + id_server: + type: string + description: |- + The identity server to unbind from. If not provided, the homeserver + MUST use the `id_server` the identifier was added through. If the + homeserver does not know the original `id_server`, it MUST return + a `id_server_unbind_result` of `no-support`. + example: example.org + medium: + type: string + description: The medium of the third-party identifier being removed. + enum: + - email + - msisdn + example: email + address: + type: string + description: The third-party address being removed. + example: example@example.org + required: + - medium + - address + required: true + responses: + "200": + description: |- + The identity server has disassociated the third-party identifier from the + user. + content: + application/json: + schema: + type: object + properties: + id_server_unbind_result: + type: string + enum: + - no-support + - success + description: |- + An indicator as to whether or not the identity server was able to unbind + the 3PID. `success` indicates that the identity server has unbound the + identifier whereas `no-support` indicates that the identity server + refuses to support the request or the homeserver was not able to determine + an identity server to unbind from. + example: success + required: + - id_server_unbind_result + tags: + - Account management + /account/3pid/email/requestToken: + post: + summary: Begins the validation process for an email address for association with + the user's account. + description: |- + The homeserver must check that the given email address is **not** + already associated with an account on this homeserver. This API should + be used to request validation tokens when adding an email address to an + account. This API's parameters and response are identical to that of + the [`/register/email/requestToken`](/client-server-api/#post_taperclientv3registeremailrequesttoken) + endpoint. The homeserver should validate + the email itself, either by sending a validation email itself or by using + a service it has control over. + operationId: requestTokenTo3PIDEmail + requestBody: + content: + application/json: + schema: + $ref: definitions/request_email_validation.yaml + required: true + responses: + "200": + description: |- + An email was sent to the given address. Note that this may be an + email containing the validation token or it may be informing the + user of an error. + content: + application/json: + schema: + $ref: definitions/request_token_response.yaml + "400": + description: |- + The third-party identifier is already in use on the homeserver, or + the request was invalid. Error codes that can be returned are: + * `T_THREEPID_IN_USE`: The email supplied cannot be bound because it is already + associated with a different Taper ID. + * `T_SERVER_NOT_TRUSTED`: The server does not trust/support the identity server + provided in the request. + * `T_THREEPID_MEDIUM_NOT_SUPPORTED`: The homeserver does not support adding email addresses. + * `T_INVALID_PARAM`: The email address given was not valid. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_THREEPID_IN_USE", + "error": "Third-party identifier already in use" + } + "403": + description: |- + The homeserver does not allow the third-party identifier as a + contact option. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_THREEPID_DENIED", + "error": "Third-party identifier is not allowed" + } + tags: + - Account management + /account/3pid/msisdn/requestToken: + post: + summary: Begins the validation process for a phone number for association with + the user's account. + description: |- + The homeserver must check that the given phone number is **not** + already associated with an account on this homeserver. This API should + be used to request validation tokens when adding a phone number to an + account. This API's parameters and response are identical to that of + the [`/register/msisdn/requestToken`](/client-server-api/#post_taperclientv3registermsisdnrequesttoken) + endpoint. The homeserver should validate + the phone number itself, either by sending a validation message itself or by using + a service it has control over. + operationId: requestTokenTo3PIDMSISDN + requestBody: + content: + application/json: + schema: + $ref: definitions/request_msisdn_validation.yaml + required: true + responses: + "200": + description: An SMS message was sent to the given phone number. + content: + application/json: + schema: + $ref: definitions/request_token_response.yaml + "400": + description: |- + The third-party identifier is already in use on the homeserver, or + the request was invalid. Error codes that can be returned are: + * `T_THREEPID_IN_USE`: The phone number supplied cannot be bound because is is already + associated with a different Taper ID. + * `T_SERVER_NOT_TRUSTED`: The server does not trust/support the identity server + * `T_THREEPID_MEDIUM_NOT_SUPPORTED`: The homeserver does not support adding phone numbers. + * `T_INVALID_PARAM`: The phone number given was not valid. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_THREEPID_IN_USE", + "error": "Third-party identifier already in use" + } + "403": + description: |- + The homeserver does not allow the third-party identifier as a + contact option. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_THREEPID_DENIED", + "error": "Third-party identifier is not allowed" + } + tags: + - Account management +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/appservice_ping.yaml b/data/api/client-server/appservice_ping.yaml new file mode 100644 index 0000000000000000000000000000000000000000..dd390223de4d99556fa8c5857caaa1ff87fd760b --- /dev/null +++ b/data/api/client-server/appservice_ping.yaml @@ -0,0 +1,180 @@ +# Copyright 2023 Tulir Asokan +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Application Service Ping API + version: 1.0.0 +paths: + "/appservice/{appserviceId}/ping": + post: + x-addedInMatrixVersion: "1.7" + summary: Ask the homeserver to ping the application service to ensure the + connection works. + description: |- + This API asks the homeserver to call the + [`/_taper/app/v1/ping`](/application-service-api/#post_taperappv1ping) endpoint on the + application service to ensure that the homeserver can communicate + with the application service. + + This API requires the use of an application service access token (`as_token`) + instead of a typical client's access token. This API cannot be invoked by + users who are not identified as application services. Additionally, the + appservice ID in the path must be the same as the appservice whose `as_token` + is being used. + operationId: pingAppservice + parameters: + - in: path + name: appserviceId + description: |- + The appservice ID of the appservice to ping. This must be the same + as the appservice whose `as_token` is being used to authenticate the + request. + required: true + example: telegram + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + transaction_id: + type: string + description: An optional transaction ID that is passed through to the + `/_taper/app/v1/ping` call. + example: mautrix-go_1683636478256400935_123 + required: true + security: + - appserviceAccessTokenBearer: [] + responses: + "200": + description: The ping was successful. + content: + application/json: + schema: + type: object + properties: + duration_ms: + type: integer + description: |- + The duration in milliseconds that the + [`/_taper/app/v1/ping`](/application-service-api/#post_taperappv1ping) + request took from the homeserver's point of view. + required: + - duration_ms + examples: + response: + value: { + "duration_ms": 123 + } + "400": + description: The application service doesn't have a URL configured. The errcode + is `T_URL_NOT_SET`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_URL_NOT_SET", + "error": "Application service doesn't have a URL configured" + } + "403": + description: The access token used to authenticate the request doesn't belong to + an appservice, or belongs to a different appservice than the one in + the path. The errcode is `T_FORBIDDEN`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Provided access token is not the appservice's as_token" + } + "502": + description: |- + The application service returned a bad status, or the connection failed. + The errcode is `T_BAD_STATUS` or `T_CONNECTION_FAILED`. + + For bad statuses, the response may include `status` and `body` + fields containing the HTTP status code and response body text + respectively to aid with debugging. + content: + application/json: + schema: + type: object + title: Error + description: A Taper-level Error + properties: + errcode: + type: string + description: An error code. + enum: + - T_BAD_STATUS + - T_CONNECTION_FAILED + error: + type: string + description: A human-readable error message. + example: Ping returned status 401 + status: + type: integer + description: The HTTP status code returned by the appservice. + example: 401 + body: + type: string + description: The HTTP response body returned by the appservice. + example: '{"errcode": "T_UNKNOWN_TOKEN"}' + required: + - errcode + examples: + response: + value: { + "errcode": "T_BAD_STATUS", + "error": "Ping returned status 401", + "status": 401, + "body": "{\"errcode\": \"T_UNKNOWN_TOKEN\"}" + } + "504": + description: The connection to the application service timed out. The errcode is + `T_CONNECTION_TIMEOUT`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_CONNECTION_TIMEOUT", + "error": "Connection to application service timed out" + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v1 +components: + securitySchemes: + appserviceAccessTokenBearer: + $ref: definitions/security.yaml#/appserviceAccessTokenBearer diff --git a/data/api/client-server/appservice_room_directory.yaml b/data/api/client-server/appservice_room_directory.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3b81ccdab8e1c2fd4713f67e443ae86a1cfd63ad --- /dev/null +++ b/data/api/client-server/appservice_room_directory.yaml @@ -0,0 +1,101 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Application Service Published Room Directory API + version: 1.0.0 +paths: + "/directory/list/appservice/{networkId}/{roomId}": + put: + summary: |- + Updates a room's visibility in the application service's published room + directory. + description: |- + Updates the visibility of a given room in the application service's + published room directory. + + This API is similar to the + [visibility API](/client-server-api#put_taperclientv3directorylistroomroomid) + used by clients to update the homeserver's more general published room directory. + + This API requires the use of an application service access token (`as_token`) + instead of a typical client's access_token. This API cannot be invoked by + users who are not identified as application services. + operationId: updateAppserviceRoomDirectoryVisibility + parameters: + - in: path + name: networkId + description: |- + The protocol (network) ID to update the room list for. This would + have been provided by the application service as being listed as + a supported protocol. + required: true + example: irc + schema: + type: string + - in: path + name: roomId + description: The room ID to add to the directory. + required: true + example: "!somewhere:example.org" + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + visibility: + type: string + enum: + - public + - private + description: |- + Whether the room should be visible (public) in the directory + or not (private). + example: public + required: + - visibility + required: true + security: + - appserviceAccessTokenBearer: [] + responses: + "200": + description: The room's directory visibility has been updated. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + tags: + - Application service room directory management +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + appserviceAccessTokenBearer: + $ref: definitions/security.yaml#/appserviceAccessTokenBearer diff --git a/data/api/client-server/authed-content-repo.yaml b/data/api/client-server/authed-content-repo.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a5f52d9af5538e7d5c5b638fb48d2315659d9585 --- /dev/null +++ b/data/api/client-server/authed-content-repo.yaml @@ -0,0 +1,604 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2019-2024 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server (Authenticated) Content Repository API + version: 1.0.0 +paths: + "/media/download/{serverName}/{mediaId}": + get: + x-addedInMatrixVersion: "1.11" + summary: Download content from the content repository. + description: |- + {{% boxes/note %}} + Clients SHOULD NOT generate or use URLs which supply the access token in + the query string. These URLs may be copied by users verbatim and provided + in a chat message to another user, disclosing the sender's access token. + {{% /boxes/note %}} + + Clients MAY be redirected using the 307/308 responses below to download + the request object. This is typical when the homeserver uses a Content + Delivery Network (CDN). + operationId: getContentAuthed + security: + - accessTokenBearer: [] + parameters: + - $ref: '#/components/parameters/serverName' + - $ref: '#/components/parameters/mediaId' + - $ref: '#/components/parameters/timeout_ms' + responses: + "200": + description: The content that was previously uploaded. + headers: + Content-Type: + $ref: '#/components/headers/downloadContentType' + Content-Disposition: + x-changedInMatrixVersion: + "1.12": This header became required. + description: | + The [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) + of the returned content. MUST be one of `inline` or `attachment`, + and SHOULD contain a file name. + + If the `Content-Type` is allowed in the [restrictions for serving + inline content](/client-server-api/#serving-inline-content), + servers SHOULD use `inline`, otherwise they SHOULD use + `attachment`. + + If the upload was made with a `filename`, this header MUST + contain the same `filename`. Otherwise, `filename` is excluded + from the header. If the media being downloaded is remote, the + remote server's `filename` in the `Content-Disposition` header + is used as the `filename` instead. When the header is not + supplied, or does not supply a `filename`, the local download + response does not include a `filename`. + required: true + schema: + type: string + example: "inline; filename=\"filename.jpg\"" + content: + application/octet-stream: + schema: + # This is a workaround for us not being able to say the response is required. + description: "**Required.** The bytes for the uploaded file." + "307": + $ref: '#/components/responses/downloadRedirect' + "308": + $ref: '#/components/responses/downloadRedirect' + "429": + $ref: '#/components/responses/rateLimited' + "502": + $ref: '#/components/responses/downloadTooLarge' + "504": + $ref: '#/components/responses/notYetUploaded' + tags: + - Media + "/media/download/{serverName}/{mediaId}/{fileName}": + get: + x-addedInMatrixVersion: "1.11" + summary: Download content from the content repository overriding the file name. + description: |- + This will download content from the content repository (same as + the previous endpoint) but replaces the target file name with the one + provided by the caller. + + {{% boxes/note %}} + Clients SHOULD NOT generate or use URLs which supply the access token in + the query string. These URLs may be copied by users verbatim and provided + in a chat message to another user, disclosing the sender's access token. + {{% /boxes/note %}} + + Clients MAY be redirected using the 307/308 responses below to download + the request object. This is typical when the homeserver uses a Content + Delivery Network (CDN). + operationId: getContentOverrideNameAuthed + security: + - accessTokenBearer: [] + parameters: + - $ref: '#/components/parameters/serverName' + - $ref: '#/components/parameters/mediaId' + - in: path + name: fileName + required: true + description: A filename to give in the `Content-Disposition` header. + example: filename.jpg + schema: + type: string + - $ref: '#/components/parameters/timeout_ms' + responses: + "200": + description: The content that was previously uploaded. + headers: + Content-Type: + $ref: '#/components/headers/downloadContentType' + Content-Disposition: + x-changedInMatrixVersion: + "1.12": This header became required. + description: | + The [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) + of the returned content. MUST be one of `inline` or `attachment`, + and MUST contain the file name requested in the path. + + If the `Content-Type` is allowed in the [restrictions for serving + inline content](/client-server-api/#serving-inline-content), + servers SHOULD use `inline`, otherwise they SHOULD use + `attachment`. + required: true + schema: + type: string + example: "inline; filename=\"filename.jpg\"" + content: + application/octet-stream: + schema: + # This is a workaround for us not being able to say the response is required. + description: "**Required.** The bytes for the uploaded file." + "307": + $ref: '#/components/responses/downloadRedirect' + "308": + $ref: '#/components/responses/downloadRedirect' + "429": + $ref: '#/components/responses/rateLimited' + "502": + $ref: '#/components/responses/downloadTooLarge' + "504": + $ref: '#/components/responses/notYetUploaded' + tags: + - Media + "/media/thumbnail/{serverName}/{mediaId}": + get: + x-addedInMatrixVersion: "1.11" + summary: Download a thumbnail of content from the content repository + description: |- + Download a thumbnail of content from the content repository. + See the [Thumbnails](/client-server-api/#thumbnails) section for more information. + + {{% boxes/note %}} + Clients SHOULD NOT generate or use URLs which supply the access token in + the query string. These URLs may be copied by users verbatim and provided + in a chat message to another user, disclosing the sender's access token. + {{% /boxes/note %}} + + Clients MAY be redirected using the 307/308 responses below to download + the request object. This is typical when the homeserver uses a Content + Delivery Network (CDN). + operationId: getContentThumbnailAuthed + security: + - accessTokenBearer: [] + parameters: + - $ref: '#/components/parameters/serverName' + - $ref: '#/components/parameters/mediaId' + - in: query + name: width + required: true + description: |- + The *desired* width of the thumbnail. The actual thumbnail may be + larger than the size specified. + example: 64 + schema: + type: integer + - in: query + name: height + required: true + description: |- + The *desired* height of the thumbnail. The actual thumbnail may be + larger than the size specified. + example: 64 + schema: + type: integer + - in: query + name: method + description: |- + The desired resizing method. See the [Thumbnails](/client-server-api/#thumbnails) + section for more information. + example: scale + schema: + type: string + enum: + - crop + - scale + - $ref: '#/components/parameters/timeout_ms' + - in: query + name: animated + x-addedInMatrixVersion: "1.11" + required: false + description: | + Indicates preference for an animated thumbnail from the server, if possible. Animated + thumbnails typically use the content types `image/gif`, `image/png` (with APNG format), + `image/apng`, and `image/webp` instead of the common static `image/png` or `image/jpeg` + content types. + + When `true`, the server SHOULD return an animated thumbnail if possible and supported. + When `false`, the server MUST NOT return an animated thumbnail. For example, returning a + static `image/png` or `image/jpeg` thumbnail. When not provided, the server SHOULD NOT + return an animated thumbnail. + + Servers SHOULD prefer to return `image/webp` thumbnails when supporting animation. + + When `true` and the media cannot be animated, such as in the case of a JPEG or PDF, the + server SHOULD behave as though `animated` is `false`. + example: false + schema: + type: boolean + responses: + "200": + description: A thumbnail of the requested content. + headers: + Content-Disposition: + x-addedInMatrixVersion: "1.12" + description: | + The [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) + of the returned content. MUST be `inline`, and SHOULD contain a file name (e.g. `thumbnail.png`). + + Servers should note the [Content-Type restrictions for serving inline content](/client-server-api/#serving-inline-content), + as these limitations imply which formats should be used for thumbnail generation. + required: true + schema: + type: string + example: "inline; filename=\"thumbnail.png\"" + Content-Type: + x-changedInMatrixVersion: + "1.12": | + This header became required in order to support `Content-Disposition`. + description: The content type of the thumbnail. + required: true + schema: + type: string + enum: + - image/jpeg + - image/png + - image/apng + - image/gif + - image/webp + content: + image/jpeg: + schema: + # This is a workaround for us not being able to say the response is required. + description: "**Required.** The bytes for the thumbnail." + image/png: + schema: + x-changedInMatrixVersion: + "1.11": The PNG may be of the APNG variety if animation is supported and requested. + description: | + **Required.** The bytes for the thumbnail. The thumbnail MAY use an animated + format if `animated=true`. + image/apng: + schema: + x-addedInMatrixVersion: "1.11" + description: "**Required.** The bytes for the *animated* thumbnail." + image/gif: + schema: + x-addedInMatrixVersion: "1.11" + description: "**Required.** The bytes for the *animated* thumbnail." + image/webp: + schema: + x-addedInMatrixVersion: "1.11" + description: "**Required.** The bytes for the *animated* thumbnail." + "307": + $ref: '#/components/responses/thumbnailRedirect' + "308": + $ref: '#/components/responses/thumbnailRedirect' + "400": + description: |- + The request does not make sense to the server, or the server cannot thumbnail + the content. For example, the client requested non-integer dimensions or asked + for negatively-sized images. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNKNOWN", + "error": "Cannot generate thumbnails for the requested content" + } + "413": + description: The local content is too large for the server to thumbnail. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TOO_LARGE", + "error": "Content is too large to thumbnail" + } + "429": + $ref: '#/components/responses/rateLimited' + "502": + description: The remote content is too large for the server to thumbnail. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TOO_LARGE", + "error": "Content is too large to thumbnail" + } + "504": + $ref: '#/components/responses/notYetUploaded' + tags: + - Media + /media/preview_url: + get: + x-addedInMatrixVersion: "1.11" + x-changedInMatrixVersion: + "1.20": |- + Servers may disable URL previews and advertise this using the `t.preview_url` + capability. + summary: Get information about a URL for a client + description: |- + Get information about a URL for the client. Typically this is called when a + client sees a URL in a message and wants to render a preview for the user. + + {{% boxes/note %}} + Clients should consider avoiding this endpoint for URLs posted in encrypted + rooms. Encrypted rooms often contain more sensitive information the users + do not want to share with the homeserver, and this can mean that the URLs + being shared should also not be shared with the homeserver. + {{% /boxes/note %}} + + Servers MAY disable URL previews. Servers that do so SHOULD set `enabled` to `false` in the + [`t.preview_url`](/client-server-api/#lpreview_url-capability) capability, and SHOULD + reject requests to this endpoint with a 403 `T_FORBIDDEN` error. + operationId: getUrlPreviewAuthed + security: + - accessTokenBearer: [] + parameters: + - in: query + name: url + description: The URL to get a preview of. + required: true + example: https://matrix.org + schema: + type: string + format: uri + - in: query + name: ts + description: |- + The preferred point in time to return a preview for. The server may + return a newer version if it does not have the requested version + available. + example: 1510610716656 + schema: + type: integer + format: int64 + responses: + "200": + description: |- + The OpenGraph data for the URL, which may be empty. Some values are + replaced with taper equivalents if they are provided in the response. + The differences from the [OpenGraph protocol](https://ogp.me/) are + described here. + content: + application/json: + schema: + type: object + properties: + taper:image:size: + type: integer + format: int64 + description: The byte-size of the image. Omitted if there is no image attached. + og:image: + type: string + format: uri + description: An [`runit://` URI](/client-server-api/#taper-content-runit-uris) to + the image. Omitted if there is no image. + additionalProperties: + description: |- + Additional properties as per the [OpenGraph](https://ogp.me/) protocol. + examples: + response: + value: { + "og:title": "Taper Blog Post", + "og:description": "This is a really cool blog post from matrix.org", + "og:image": "runit://example.com/ascERGshawAWawugaAcauga", + "og:image:type": "image/png", + "og:image:height": 48, + "og:image:width": 48, + "taper:image:size": 102400 + } + "403": + x-addedInMatrixVersion: "1.20" + description: |- + URL previews are disabled. The errcode is `T_FORBIDDEN`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "URL previews are disabled on this server." + } + "429": + $ref: '#/components/responses/rateLimited' + tags: + - Media + /media/config: + get: + x-addedInMatrixVersion: "1.11" + summary: Get the configuration for the content repository. + description: |- + This endpoint allows clients to retrieve the configuration of the content + repository, such as upload limitations. + Clients SHOULD use this as a guide when using content repository endpoints. + All values are intentionally left optional. Clients SHOULD follow + the advice given in the field description when the field is not available. + + {{% boxes/note %}} + Both clients and server administrators should be aware that proxies + between the client and the server may affect the apparent behaviour of content + repository APIs, for example, proxies may enforce a lower upload size limit + than is advertised by the server on this endpoint. + {{% /boxes/note %}} + operationId: getConfigAuthed + security: + - accessTokenBearer: [] + responses: + "200": + description: The public content repository configuration for the taper server. + content: + application/json: + schema: + type: object + properties: + t.upload.size: + type: integer + format: int64 + description: |- + The maximum size an upload can be in bytes. + Clients SHOULD use this as a guide when uploading content. + If not listed or null, the size limit should be treated as unknown. + examples: + response: + value: { + "t.upload.size": 50000000 + } + "429": + $ref: '#/components/responses/rateLimited' + tags: + - Media +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v1 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer + parameters: + serverName: + in: path + name: serverName + required: true + description: | + The server name from the `runit://` URI (the authority component). + example: matrix.org + schema: + type: string + format: mx-server-name + mediaId: + in: path + name: mediaId + required: true + description: | + The media ID from the `runit://` URI (the path component). + example: ascERGshawAWawugaAcauga + schema: + type: string + timeout_ms: + in: query + name: timeout_ms + x-addedInMatrixVersion: "1.7" + description: | + The maximum number of milliseconds that the client is willing to wait to + start receiving data, in the case that the content has not yet been + uploaded. The default value is 20000 (20 seconds). The content + repository SHOULD impose a maximum value for this parameter. The + content repository MAY respond before the timeout. + example: 5000 + schema: + type: integer + format: int64 + default: 20000 + responses: + rateLimited: + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + notYetUploaded: + description: |- + The content is not yet available. A [standard error response](/client-server-api/#standard-error-response) + will be returned with the `errcode` `T_NOT_YET_UPLOADED`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_YET_UPLOADED", + "error": "Content has not yet been uploaded" + } + downloadRedirect: + description: A redirect to the requested content. + headers: + Location: + description: The URL of the content. + schema: + type: string + format: uri + downloadTooLarge: + description: The content is too large for the server to serve. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TOO_LARGE", + "error": "Content is too large to serve" + } + thumbnailRedirect: + description: A redirect to the thumbnail of the requested content. + headers: + Location: + description: The URL of the thumbnail content. + schema: + type: string + format: uri + headers: + downloadContentType: + description: | + The content type of the file that was previously uploaded. + + The server MUST return a `Content-Type` which is either exactly the same + as the original upload, or reasonably close. The bounds of "reasonable" + are: + + * Adding a charset to `text/*` content types. + * Detecting HTML and using `text/html` instead of `text/plain`. + * Using `application/octet-stream` when the server determines the + content type is obviously wrong. For example, an encrypted file being + claimed as `image/png`. + * Returning `application/octet-stream` when the media has an + unknown/unprovided `Content-Type`. For example, being uploaded before + the server tracked content types or when the remote server is + non-compliantly omitting the header entirely. + + Actions not in the spirit of the above are not considered "reasonable". + x-changedInMatrixVersion: + "1.12": | + This header became required in order to support `Content-Disposition`, + and the behaviour to compute its value was clarified. + required: true + schema: + type: string diff --git a/data/api/client-server/banning.yaml b/data/api/client-server/banning.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4aa996d41c46a3ff6e2c407408d4f17c7793bfa1 --- /dev/null +++ b/data/api/client-server/banning.yaml @@ -0,0 +1,181 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Room Banning API + version: 1.0.0 +paths: + "/rooms/{roomId}/ban": + post: + summary: Ban a user in the room. + description: |- + Ban a user in the room. If the user is currently in the room, also kick them. + + When a user is banned from a room, they may not join it or be invited to it until they are unbanned. + + The caller must have the required power level in order to perform this operation. + operationId: ban + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room identifier (not alias) from which the user should be banned. + required: true + example: "!e42d8c:matrix.org" + schema: + type: string + format: mx-room-id + pattern: "^!" + requestBody: + content: + application/json: + schema: + type: object + example: { + "reason": "Telling unfunny jokes", + "user_id": "@cheeky_monkey:matrix.org" + } + properties: + user_id: + type: string + description: The fully qualified user ID of the user being banned. + format: mx-user-id + pattern: "^@" + reason: + x-addedInMatrixVersion: "1.1" + type: string + description: The reason the user has been banned. This will be supplied as the + `reason` on the target's updated + [`t.room.member`](/client-server-api/#lroommember) event. + required: + - user_id + required: true + responses: + "200": + description: The user has been kicked and banned from the room. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "403": + description: |- + You do not have permission to ban the user from the room. A meaningful `errcode` and description error text will be returned. Example reasons for rejections are: + + - The banner is not currently in the room. + - The banner's power level is insufficient to ban users from the room. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You do not have a high enough power level to ban from this room." + } + tags: + - Room membership + "/rooms/{roomId}/unban": + post: + summary: Unban a user from the room. + description: |- + Unban a user from the room. This allows them to be invited to the room, + and join if they would otherwise be allowed to join according to its join rules. + + The caller must have the required power level in order to perform this operation. + operationId: unban + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room identifier (not alias) from which the user should be + unbanned. + required: true + example: "!e42d8c:matrix.org" + schema: + type: string + format: mx-room-id + pattern: "^!" + requestBody: + content: + application/json: + schema: + type: object + example: { + "user_id": "@cheeky_monkey:matrix.org", + "reason": "They've been banned long enough" + } + properties: + user_id: + type: string + description: The fully qualified user ID of the user being unbanned. + format: mx-user-id + pattern: "^@" + reason: + x-addedInMatrixVersion: "1.1" + type: string + description: |- + Optional reason to be included as the `reason` on the subsequent + membership event. + required: + - user_id + required: true + responses: + "200": + description: The user has been unbanned from the room. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "403": + description: |- + You do not have permission to unban the user from the room. A meaningful `errcode` and description error text will be returned. Example reasons for rejections are: + + - The unbanner's power level is insufficient to unban users from the room. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You do not have a high enough power level to unban from this room." + } + tags: + - Room membership +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/capabilities.yaml b/data/api/client-server/capabilities.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9d3d702902c64a42014cdeb5237bb8adcabdc9ba --- /dev/null +++ b/data/api/client-server/capabilities.yaml @@ -0,0 +1,286 @@ +# Copyright 2019 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Capabilities API + version: 1.0.0 +paths: + /capabilities: + get: + summary: Gets information about the server's capabilities. + description: |- + Gets information about the server's supported feature set + and other relevant capabilities. + operationId: getCapabilities + security: + - accessTokenBearer: [] + responses: + "200": + description: The capabilities of the server. + content: + application/json: + schema: + type: object + required: + - capabilities + properties: + capabilities: + type: object + title: Capabilities + description: |- + The custom capabilities the server supports, using the + Java package naming convention. + additionalProperties: + description: |- + Application-dependent keys using the + [Common Namespaced Identifier Grammar](/appendices/#common-namespaced-identifier-grammar). + properties: + t.change_password: + $ref: '#/components/schemas/booleanCapability' + description: Capability to indicate if the user can change their password. + t.forget_forced_upon_leave: + x-addedInMatrixVersion: "1.18" + $ref: '#/components/schemas/booleanCapability' + description: |- + Capability to indicate if the server automatically forgets rooms once the user + leaves. + t.room_versions: + type: object + description: The room versions the server supports. + title: RoomVersionsCapability + properties: + default: + type: string + description: The default room version the server is using for new rooms. + example: "1" + available: + type: object + description: A detailed description of the room versions the server supports. + additionalProperties: + type: string + title: RoomVersionStability + enum: + - stable + - unstable + description: The stability of the room version. + required: + - default + - available + t.set_displayname: + deprecated: true + $ref: '#/components/schemas/booleanCapability' + description: | + **Deprecated:** Capability to indicate if the user can change their display name. + Refer to `t.profile_fields` for extended profile management. + + For backwards compatibility, servers that directly or indirectly include the + `displayname` profile field in the `t.profile_fields` capability MUST also + set this capability accordingly. + t.set_avatar_url: + deprecated: true + $ref: '#/components/schemas/booleanCapability' + description: | + **Deprecated:** Capability to indicate if the user can change their avatar. + Refer to `t.profile_fields` for extended profile management. + + For backwards compatibility, servers that directly or indirectly include the + `avatar_url` profile field in the `t.profile_fields` capability MUST also + set this capability accordingly. + t.3pid_changes: + $ref: '#/components/schemas/booleanCapability' + description: Capability to indicate if the user can change 3PID associations + on their account. + t.get_login_token: + $ref: '#/components/schemas/booleanCapability' + description: Capability to indicate if the user can generate tokens to log further + clients into their account. + t.preview_url: + x-addedInMatrixVersion: "1.20" + $ref: '#/components/schemas/booleanCapability' + description: |- + Capability to indicate if the user can request URL previews via + [`GET /_taper/client/v1/media/preview_url`](/client-server-api/#get_taperclientv1mediapreview_url). + t.retention: + type: object + title: RetentionCapability + description: |- + The server's [message retention](/client-server-api/#message-retention) + limit. Servers MUST always advertise this capability. + properties: + max_lifetime: + type: integer + format: int64 + minimum: 3600000 + maximum: 1814400000 + description: |- + The longest time, in milliseconds, that this server keeps message + events, whatever the room's own setting. MUST NOT be + greater than `1814400000` (21 days). + example: 1814400000 + required: + - max_lifetime + t.delayed_events: + x-addedInMatrixVersion: "1.20" + type: object + title: DelayedEventsCapability + description: |- + Capability to indicate the limits that the server imposes on + [delayed events](/client-server-api/#delayed-events). + properties: + max_delay_ms: + type: integer + format: int64 + minimum: 0 + description: |- + The maximum delay in milliseconds that is allowed for a delayed event. + MUST be non-negative and MUST NOT be greater than `1814400000` + (the [retention ceiling](/client-server-api/#the-retention-ceiling)). + `0` if delayed events are disabled. + example: 86400000 + max_scheduled: + type: integer + format: int64 + minimum: 0 + description: |- + The maximum number of delayed events that a user may have scheduled + at once. MUST be non-negative. `0` if delayed events are disabled. + example: 10 + required: + - max_delay_ms + - max_scheduled + t.profile_fields: + x-addedInMatrixVersion: "1.16" + type: object + title: ProfileFieldsCapability + description: Capability to indicate if the user can set or modify extended profile fields via + [`PUT /_taper/client/v3/profile/{userId}/{keyName}`](/client-server-api/#put_taperclientv3profileuseridkeyname). + If absent, clients SHOULD assume custom profile fields are supported, provided the + homeserver advertises a specification version that includes `t.profile_fields` in the + [`/versions`](/client-server-api/#get_taperclientversions) response. + properties: + allowed: + type: array + description: | + If present, a list of profile fields that clients are allowed to create, modify or delete, + provided `enabled` is `true`; no other profile fields may be changed. + + If absent, clients may set all profile fields except those forbidden by the `disallowed` + list, where present. + items: + type: string + example: + - "t.example_field" + - "org.example.job_title" + disallowed: + type: array + description: | + This property has no meaning if `allowed` is also specified. + + Otherwise, if present, a list of profile fields that clients are _not_ allowed to create, modify or delete. + Provided `enabled` is `true`, clients MAY assume that they can set any profile field which is not + included in this list. + items: + type: string + example: + - "org.example.managed_field" + enabled: + type: boolean + description: "`true` if the user can create, update or delete any profile fields, `false` otherwise." + example: true + required: + - enabled + t.account_moderation: + x-addedInMatrixVersion: "1.18" + type: object + title: AccountModerationCapability + description: |- + Capability to indicate if the user can perform account moderation actions + via [server administration](/client-server-api/#server-administration) + endpoints. + + This property should be omitted altogether if `suspend` and `lock` would + be `false`. + properties: + suspend: + type: boolean + description: |- + `true` if the user can suspend a user via [`PUT /admin/suspend/{userId}`](/client-server-api/#put_taperclientv1adminsuspenduserid), + `false` otherwise. + + Defaults to `false`. + example: true + lock: + type: boolean + description: |- + `true` if the user can lock a user via [`PUT /admin/lock/{userId}`](/client-server-api/#put_taperclientv1adminlockuserid), + `false` otherwise. + + Defaults to `false`. + example: true + examples: + response: + value: { + "capabilities": { + "t.change_password": { + "enabled": false + }, + "t.room_versions": { + "default": "1", + "available": { + "1": "stable", + "2": "stable", + "3": "unstable", + "test-version": "unstable" + } + }, + "com.example.custom.ratelimit": { + "max_requests_per_hour": 600 + } + } + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Capabilities +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer + schemas: + booleanCapability: + type: object + title: BooleanCapability + properties: + enabled: + type: boolean + description: True if the user can perform the action, false otherwise. + example: false + required: + - enabled diff --git a/data/api/client-server/content-repo.yaml b/data/api/client-server/content-repo.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c19c51dd1737822d824c7dc45b15ad0250a436b1 --- /dev/null +++ b/data/api/client-server/content-repo.yaml @@ -0,0 +1,880 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Content Repository API + version: 1.0.0 +paths: + /media/v3/upload: + post: + summary: Upload some content to the content repository. + operationId: uploadContent + security: + - accessTokenBearer: [] + parameters: + - $ref: '#/components/parameters/contentType' + - $ref: '#/components/parameters/filename' + requestBody: + $ref: '#/components/requestBodies/bytes' + responses: + "200": + description: The [`runit://` URI](/client-server-api/#taper-content-runit-uris) for + the uploaded content. + content: + application/json: + schema: + type: object + required: + - content_uri + properties: + content_uri: + type: string + format: mx-runit-uri + pattern: "^runit:\\/\\/" + description: The [`runit://` URI](/client-server-api/#taper-content-runit-uris) to + the uploaded content. + examples: + response: + value: { + "content_uri": "runit://example.com/AQwafuaFswefuhsfAFAgsw" + } + "403": + description: |- + The user does not have permission to upload the content. Some reasons for this error include: + + - The server does not permit the file type. + - The user has reached a quota for uploaded content. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Cannot upload this content" + } + "413": + $ref: '#/components/responses/uploadTooLarge' + "429": + $ref: '#/components/responses/rateLimited' + tags: + - Media + "/media/v3/upload/{serverName}/{mediaId}": + put: + summary: Upload content to a `runit://` URI that was created earlier. + description: |- + This endpoint permits uploading content to a `runit://` URI that was created + earlier via [POST /_taper/media/v1/create](/client-server-api/#post_tapermediav1create). + operationId: uploadContentToRunit + x-addedInMatrixVersion: "1.7" + security: + - accessTokenBearer: [] + parameters: + - $ref: '#/components/parameters/serverName' + description: | + The server name from the `runit://` URI returned by `POST /_taper/media/v1/create` (the authority component). + - $ref: '#/components/parameters/mediaId' + description: | + The media ID from the `runit://` URI returned by `POST /_taper/media/v1/create` (the path component). + - $ref: '#/components/parameters/contentType' + - $ref: '#/components/parameters/filename' + requestBody: + $ref: '#/components/requestBodies/bytes' + responses: + "200": + description: The upload was successful. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "403": + description: |- + The user does not have permission to upload the content. Some reasons for this error include: + + - The server does not permit the file type. + - The user has reached a quota for uploaded content. + - The request comes from a different user than the one that called + [POST /_taper/media/v1/create](/client-server-api/#post_tapermediav1create). + + A [standard error response](/client-server-api/#standard-error-response) + will be returned with the `errcode` `T_FORBIDDEN`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Cannot upload this content" + } + "404": + description: |- + The user has provided an invalid runit ID. Some reasons for this error include: + + - The runit ID was not created with [POST /_taper/media/v1/create](/client-server-api/#post_tapermediav1create). + - The runit ID has expired. + + A [standard error response](/client-server-api/#standard-error-response) + will be returned with the `errcode` `T_NOT_FOUND`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unknown media ID" + } + "409": + description: |- + The endpoint was called with a media ID that already has content. A + [standard error response](/client-server-api/#standard-error-response) + will be returned with the `errcode` `T_CANNOT_OVERWRITE_MEDIA`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_CANNOT_OVERWRITE_MEDIA", + "error": "Media already uploaded" + } + "413": + $ref: '#/components/responses/uploadTooLarge' + "429": + $ref: '#/components/responses/rateLimited' + tags: + - Media + /media/v1/create: + post: + summary: Create a new `runit://` URI without uploading the content. + description: |- + Creates a new `runit://` URI, independently of the content being uploaded. The content must be provided later + via [`PUT /_taper/media/v3/upload/{serverName}/{mediaId}`](/client-server-api/#put_tapermediav3uploadservernamemediaid). + + The server may optionally enforce a maximum age for unused IDs, + and delete media IDs when the client doesn't start the upload in time, + or when the upload was interrupted and not resumed in time. The server + should include the maximum POSIX millisecond timestamp to complete the + upload in the `unused_expires_at` field in the response JSON. The + recommended default expiration is 24 hours which should be enough time + to accommodate users on poor connection who find a better connection to + complete the upload. + + As well as limiting the rate of requests to create `runit://` URIs, the server + should limit the number of concurrent *pending media uploads* a given + user can have. A pending media upload is a created `runit://` URI where (a) + the media has not yet been uploaded, and (b) has not yet expired (the + `unused_expires_at` timestamp has not yet passed). In both cases, the + server should respond with an HTTP 429 error with an errcode of + `T_LIMIT_EXCEEDED`. + operationId: createContent + x-addedInMatrixVersion: "1.7" + security: + - accessTokenBearer: [] + # empty json object + responses: + "200": + description: The [`runit://` URI](/client-server-api/#taper-content-runit-uris) for + the uploaded content. + content: + application/json: + schema: + type: object + required: + - content_uri + properties: + content_uri: + type: string + format: mx-runit-uri + pattern: "^runit:\\/\\/" + description: |- + The [`runit://` URI](/client-server-api/#taper-content-runit-uris) at + which the content will be available, once it is uploaded. + example: runit://example.com/AQwafuaFswefuhsfAFAgsw + unused_expires_at: + type: integer + format: int64 + description: |- + The timestamp (in milliseconds since the unix epoch) when the + generated media id will expire, if media is not uploaded. + example: 1647257217083 + "403": + description: The user does not have permission to upload the content. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Cannot upload this content" + } + "429": + $ref: '#/components/responses/rateLimited' + tags: + - Media + "/media/v3/download/{serverName}/{mediaId}": + get: + deprecated: true + summary: Download content from the content repository. + description: |- + {{% boxes/note %}} + Replaced by [`GET /_taper/client/v1/media/download/{serverName}/{mediaId}`](/client-server-api/#get_taperclientv1mediadownloadservernamemediaid) + (requires authentication). + {{% /boxes/note %}} + + {{% boxes/warning %}} + {{% changed-in v="1.11" %}} This endpoint MAY return `404 T_NOT_FOUND` + for media which exists, but is after the server froze unauthenticated + media access. See [Client Behaviour](/client-server-api/#content-repo-client-behaviour) for more + information. + {{% /boxes/warning %}} + operationId: getContent + parameters: + - $ref: '#/components/parameters/serverName' + - $ref: '#/components/parameters/mediaId' + - $ref: '#/components/parameters/allow_remote' + - $ref: '#/components/parameters/timeout_ms' + - $ref: '#/components/parameters/allow_redirect' + responses: + "200": + description: The content that was previously uploaded. + headers: + Content-Type: + $ref: '#/components/headers/downloadContentType' + Content-Disposition: + x-changedInMatrixVersion: + "1.12": This header became required. + description: | + The [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) + of the returned content. MUST be one of `inline` or `attachment`, + and SHOULD contain a file name. + + If the `Content-Type` is allowed in the [restrictions for serving + inline content](/client-server-api/#serving-inline-content), + servers SHOULD use `inline`, otherwise they SHOULD use + `attachment`. + + If the upload was made with a `filename`, this header MUST + contain the same `filename`. Otherwise, `filename` is excluded + from the header. If the media being downloaded is remote, the + remote server's `filename` in the `Content-Disposition` header + is used as the `filename` instead. When the header is not + supplied, or does not supply a `filename`, the local download + response does not include a `filename`. + required: true + schema: + type: string + example: "inline; filename=\"filename.jpg\"" + content: + application/octet-stream: + schema: + # This is a workaround for us not being able to say the response is required. + description: "**Required.** The bytes for the uploaded file." + "307": + $ref: '#/components/responses/downloadRedirect' + "308": + $ref: '#/components/responses/downloadRedirect' + "429": + $ref: '#/components/responses/rateLimited' + "502": + $ref: '#/components/responses/downloadTooLarge' + "504": + $ref: '#/components/responses/notYetUploaded' + tags: + - Media + "/media/v3/download/{serverName}/{mediaId}/{fileName}": + get: + deprecated: true + summary: Download content from the content repository overriding the file name + description: |- + {{% boxes/note %}} + Replaced by [`GET /_taper/client/v1/media/download/{serverName}/{mediaId}/{fileName}`](/client-server-api/#get_taperclientv1mediadownloadservernamemediaidfilename) + (requires authentication). + {{% /boxes/note %}} + + This will download content from the content repository (same as + the previous endpoint) but replace the target file name with the one + provided by the caller. + + {{% boxes/warning %}} + {{% changed-in v="1.11" %}} This endpoint MAY return `404 T_NOT_FOUND` + for media which exists, but is after the server froze unauthenticated + media access. See [Client Behaviour](/client-server-api/#content-repo-client-behaviour) for more + information. + {{% /boxes/warning %}} + operationId: getContentOverrideName + parameters: + - $ref: '#/components/parameters/serverName' + - $ref: '#/components/parameters/mediaId' + - in: path + name: fileName + required: true + description: A filename to give in the `Content-Disposition` header. + example: filename.jpg + schema: + type: string + - $ref: '#/components/parameters/allow_remote' + - $ref: '#/components/parameters/timeout_ms' + - $ref: '#/components/parameters/allow_redirect' + responses: + "200": + description: The content that was previously uploaded. + headers: + Content-Type: + $ref: '#/components/headers/downloadContentType' + Content-Disposition: + x-changedInMatrixVersion: + "1.12": This header became required. + description: | + The [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) + of the returned content. MUST be one of `inline` or `attachment`, + and MUST contain the file name requested in the path. + + If the `Content-Type` is allowed in the [restrictions for serving + inline content](/client-server-api/#serving-inline-content), + servers SHOULD use `inline`, otherwise they SHOULD use + `attachment`. + required: true + schema: + type: string + example: "inline; filename=\"filename.jpg\"" + content: + application/octet-stream: + schema: + # This is a workaround for us not being able to say the response is required. + description: "**Required.** The bytes for the uploaded file." + "307": + $ref: '#/components/responses/downloadRedirect' + "308": + $ref: '#/components/responses/downloadRedirect' + "429": + $ref: '#/components/responses/rateLimited' + "502": + $ref: '#/components/responses/downloadTooLarge' + "504": + $ref: '#/components/responses/notYetUploaded' + tags: + - Media + "/media/v3/thumbnail/{serverName}/{mediaId}": + get: + deprecated: true + summary: Download a thumbnail of content from the content repository + description: |- + {{% boxes/note %}} + Replaced by [`GET /_taper/client/v1/media/thumbnail/{serverName}/{mediaId}`](/client-server-api/#get_taperclientv1mediathumbnailservernamemediaid) + (requires authentication). + {{% /boxes/note %}} + + Download a thumbnail of content from the content repository. + See the [Thumbnails](/client-server-api/#thumbnails) section for more information. + + {{% boxes/warning %}} + {{% changed-in v="1.11" %}} This endpoint MAY return `404 T_NOT_FOUND` + for media which exists, but is after the server froze unauthenticated + media access. See [Client Behaviour](/client-server-api/#content-repo-client-behaviour) for more + information. + {{% /boxes/warning %}} + operationId: getContentThumbnail + parameters: + - $ref: '#/components/parameters/serverName' + - $ref: '#/components/parameters/mediaId' + - in: query + name: width + required: true + description: |- + The *desired* width of the thumbnail. The actual thumbnail may be + larger than the size specified. + example: 64 + schema: + type: integer + - in: query + name: height + required: true + description: |- + The *desired* height of the thumbnail. The actual thumbnail may be + larger than the size specified. + example: 64 + schema: + type: integer + - in: query + name: method + description: |- + The desired resizing method. See the [Thumbnails](/client-server-api/#thumbnails) + section for more information. + example: scale + schema: + type: string + enum: + - crop + - scale + - $ref: '#/components/parameters/allow_remote' + - $ref: '#/components/parameters/timeout_ms' + - $ref: '#/components/parameters/allow_redirect' + - in: query + name: animated + x-addedInMatrixVersion: "1.11" + required: false + description: | + Indicates preference for an animated thumbnail from the server, if possible. Animated + thumbnails typically use the content types `image/gif`, `image/png` (with APNG format), + `image/apng`, and `image/webp` instead of the common static `image/png` or `image/jpeg` + content types. + + When `true`, the server SHOULD return an animated thumbnail if possible and supported. + When `false`, the server MUST NOT return an animated thumbnail. For example, returning a + static `image/png` or `image/jpeg` thumbnail. When not provided, the server SHOULD NOT + return an animated thumbnail. + + Servers SHOULD prefer to return `image/webp` thumbnails when supporting animation. + + When `true` and the media cannot be animated, such as in the case of a JPEG or PDF, the + server SHOULD behave as though `animated` is `false`. + example: false + schema: + type: boolean + responses: + "200": + description: A thumbnail of the requested content. + headers: + Content-Disposition: + x-addedInMatrixVersion: "1.12" + description: | + The [disposition](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition) + of the returned content. MUST be `inline`, and SHOULD contain a file name (e.g. `thumbnail.png`). + + Servers should note the [Content-Type restrictions for serving inline content](/client-server-api/#serving-inline-content), + as these limitations imply which formats should be used for thumbnail generation. + required: true + schema: + type: string + example: "inline; filename=\"thumbnail.png\"" + Content-Type: + x-changedInMatrixVersion: + "1.12": | + This header became required in order to support `Content-Disposition`. + description: The content type of the thumbnail. + required: true + schema: + type: string + enum: + - image/jpeg + - image/png + - image/apng + - image/gif + - image/webp + content: + image/jpeg: + schema: + # This is a workaround for us not being able to say the response is required. + description: "**Required.** The bytes for the thumbnail." + image/png: + schema: + x-changedInMatrixVersion: + "1.11": The PNG may be of the APNG variety if animation is supported and requested. + description: | + **Required.** The bytes for the thumbnail. The thumbnail MAY use an animated + format if `animated=true`. + image/apng: + schema: + x-addedInMatrixVersion: "1.11" + description: "**Required.** The bytes for the *animated* thumbnail." + image/gif: + schema: + x-addedInMatrixVersion: "1.11" + description: "**Required.** The bytes for the *animated* thumbnail." + image/webp: + schema: + x-addedInMatrixVersion: "1.11" + description: "**Required.** The bytes for the *animated* thumbnail." + "307": + $ref: '#/components/responses/thumbnailRedirect' + "308": + $ref: '#/components/responses/thumbnailRedirect' + "400": + description: |- + The request does not make sense to the server, or the server cannot thumbnail + the content. For example, the client requested non-integer dimensions or asked + for negatively-sized images. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNKNOWN", + "error": "Cannot generate thumbnails for the requested content" + } + "413": + description: The local content is too large for the server to thumbnail. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TOO_LARGE", + "error": "Content is too large to thumbnail" + } + "429": + $ref: '#/components/responses/rateLimited' + "502": + description: The remote content is too large for the server to thumbnail. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TOO_LARGE", + "error": "Content is too large to thumbnail" + } + "504": + $ref: '#/components/responses/notYetUploaded' + tags: + - Media + /media/v3/preview_url: + get: + deprecated: true + summary: Get information about a URL for a client + description: |- + {{% boxes/note %}} + Replaced by [`GET /_taper/client/v1/media/preview_url`](/client-server-api/#get_taperclientv1mediapreview_url). + {{% /boxes/note %}} + + Get information about a URL for the client. Typically this is called when a + client sees a URL in a message and wants to render a preview for the user. + + **Note:** + Clients should consider avoiding this endpoint for URLs posted in encrypted + rooms. Encrypted rooms often contain more sensitive information the users + do not want to share with the homeserver, and this can mean that the URLs + being shared should also not be shared with the homeserver. + operationId: getUrlPreview + security: + - accessTokenBearer: [] + parameters: + - in: query + name: url + description: The URL to get a preview of. + required: true + example: https://matrix.org + schema: + type: string + format: uri + - in: query + name: ts + description: |- + The preferred point in time to return a preview for. The server may + return a newer version if it does not have the requested version + available. + example: 1510610716656 + schema: + type: integer + format: int64 + responses: + "200": + description: |- + The OpenGraph data for the URL, which may be empty. Some values are + replaced with taper equivalents if they are provided in the response. + The differences from the [OpenGraph](https://ogp.me/) protocol are + described here. + content: + application/json: + schema: + type: object + properties: + taper:image:size: + type: integer + format: int64 + description: The byte-size of the image. Omitted if there is no image attached. + og:image: + type: string + format: uri + description: An [`runit://` URI](/client-server-api/#taper-content-runit-uris) to + the image. Omitted if there is no image. + additionalProperties: + description: |- + Additional properties as per the [OpenGraph](https://ogp.me/) protocol. + examples: + response: + value: { + "og:title": "Taper Blog Post", + "og:description": "This is a really cool blog post from matrix.org", + "og:image": "runit://example.com/ascERGshawAWawugaAcauga", + "og:image:type": "image/png", + "og:image:height": 48, + "og:image:width": 48, + "taper:image:size": 102400 + } + "429": + $ref: '#/components/responses/rateLimited' + tags: + - Media + /media/v3/config: + get: + deprecated: true + summary: Get the configuration for the content repository. + description: |- + {{% boxes/note %}} + Replaced by [`GET /_taper/client/v1/media/config`](/client-server-api/#get_taperclientv1mediaconfig). + {{% /boxes/note %}} + + This endpoint allows clients to retrieve the configuration of the content + repository, such as upload limitations. + Clients SHOULD use this as a guide when using content repository endpoints. + All values are intentionally left optional. Clients SHOULD follow + the advice given in the field description when the field is not available. + + **NOTE:** Both clients and server administrators should be aware that proxies + between the client and the server may affect the apparent behaviour of content + repository APIs, for example, proxies may enforce a lower upload size limit + than is advertised by the server on this endpoint. + operationId: getConfig + security: + - accessTokenBearer: [] + responses: + "200": + description: The public content repository configuration for the taper server. + content: + application/json: + schema: + type: object + properties: + t.upload.size: + type: integer + format: int64 + description: |- + The maximum size an upload can be in bytes. + Clients SHOULD use this as a guide when uploading content. + If not listed or null, the size limit should be treated as unknown. + examples: + response: + value: { + "t.upload.size": 50000000 + } + "429": + $ref: '#/components/responses/rateLimited' + tags: + - Media +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer + parameters: + contentType: + in: header + name: Content-Type + description: | + **Optional.** The content type of the file being uploaded. + + Clients SHOULD always supply this header. + + Defaults to `application/octet-stream` if it is not set. + x-changedInMatrixVersion: + "1.12": | + This header became explicitly optional with a default value. + example: application/pdf + schema: + type: string + filename: + in: query + name: filename + description: The name of the file being uploaded + example: War and Peace.pdf + schema: + type: string + serverName: + in: path + name: serverName + required: true + description: | + The server name from the `runit://` URI (the authority component). + example: matrix.org + schema: + type: string + format: mx-server-name + mediaId: + in: path + name: mediaId + required: true + description: | + The media ID from the `runit://` URI (the path component). + example: ascERGshawAWawugaAcauga + schema: + type: string + allow_remote: + in: query + name: allow_remote + required: false + description: |- + Indicates to the server that it should not attempt to fetch the media if + it is deemed remote. This is to prevent routing loops where the server + contacts itself. + + Defaults to `true` if not provided. + example: false + schema: + type: boolean + default: true + timeout_ms: + in: query + name: timeout_ms + x-addedInMatrixVersion: "1.7" + description: | + The maximum number of milliseconds that the client is willing to wait to + start receiving data, in the case that the content has not yet been + uploaded. The default value is 20000 (20 seconds). The content + repository SHOULD impose a maximum value for this parameter. The + content repository MAY respond before the timeout. + example: 5000 + schema: + type: integer + format: int64 + default: 20000 + allow_redirect: + in: query + name: allow_redirect + x-addedInMatrixVersion: "1.7" + required: false + description: | + Indicates to the server that it may return a 307 or 308 redirect + response that points at the relevant media content. When not explicitly + set to `true` the server must return the media content itself. + example: false + schema: + type: boolean + default: false + requestBodies: + bytes: + content: + application/octet-stream: + schema: + description: The content to be uploaded. + example: + required: true + responses: + uploadTooLarge: + description: The uploaded content is too large for the server. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TOO_LARGE", + "error": "Cannot upload files larger than 100mb" + } + rateLimited: + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + notYetUploaded: + description: |- + The content is not yet available. A [standard error response](/client-server-api/#standard-error-response) + will be returned with the `errcode` `T_NOT_YET_UPLOADED`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_YET_UPLOADED", + "error": "Content has not yet been uploaded" + } + downloadRedirect: + description: A redirect to the requested content. + headers: + Location: + description: The URL of the content. + schema: + type: string + format: uri + downloadTooLarge: + description: The content is too large for the server to serve. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TOO_LARGE", + "error": "Content is too large to serve" + } + thumbnailRedirect: + description: A redirect to the thumbnail of the requested content. + headers: + Location: + description: The URL of the thumbnail content. + schema: + type: string + format: uri + headers: + downloadContentType: + description: | + The content type of the file that was previously uploaded. + + The server MUST return a `Content-Type` which is either exactly the same + as the original upload, or reasonably close. The bounds of "reasonable" + are: + + * Adding a charset to `text/*` content types. + * Detecting HTML and using `text/html` instead of `text/plain`. + * Using `application/octet-stream` when the server determines the + content type is obviously wrong. For example, an encrypted file being + claimed as `image/png`. + * Returning `application/octet-stream` when the media has an + unknown/unprovided `Content-Type`. For example, being uploaded before + the server tracked content types or when the remote server is + non-compliantly omitting the header entirely. + + Actions not in the spirit of the above are not considered "reasonable". + x-changedInMatrixVersion: + "1.12": | + This header became required in order to support `Content-Disposition`, + and the behaviour to compute its value was clarified. + required: true + schema: + type: string + diff --git a/data/api/client-server/create_room.yaml b/data/api/client-server/create_room.yaml new file mode 100644 index 0000000000000000000000000000000000000000..19eb4915bfed7374e38ce15febafc60954478403 --- /dev/null +++ b/data/api/client-server/create_room.yaml @@ -0,0 +1,307 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Room Creation API + version: 1.0.0 +paths: + /createRoom: + post: + summary: Create a new room + description: |- + Create a new room with various configuration options. + + The server MUST apply the normal state resolution rules when creating + the new room, including checking power levels for each event. It MUST + apply the events implied by the request in the following order: + + 1. The `t.room.create` event itself. Must be the first event in the + room. + + 2. An `t.room.member` event for the creator to join the room. This is + needed so the remaining events can be sent. + + 3. A default `t.room.power_levels` event. Overridden by the + `power_level_content_override` parameter. + + In [room versions](/rooms) 1 through 11, the room creator (and not + other members) will be given permission to send state events. + + In room versions 12 and later, the room creator is given infinite + power level and cannot be specified in the `users` field of + `t.room.power_levels`, so is not listed explicitly. + + **Note**: For `trusted_private_chat`, the users specified in the + `invite` parameter SHOULD also be appended to `additional_creators` + by the server, per the `creation_content` parameter. + + If the room's version is 12 or higher, the power level for sending + `t.room.tombstone` events MUST explicitly be higher than `state_default`. + For example, set to 150 instead of 100. + + 4. An `t.room.canonical_alias` event if `room_alias_name` is given. + + 5. Events set by the `preset`. Currently these are the `t.room.join_rules`, + `t.room.history_visibility`, and `t.room.guest_access` state events. + + 6. Events listed in `initial_state`, in the order that they are + listed. + + 7. Events implied by `name` and `topic` (`t.room.name` and `t.room.topic` + state events). + + 8. Invite events implied by `invite` and `invite_3pid` (`t.room.member` with + `membership: invite` and `t.room.third_party_invite`). + + The available presets do the following with respect to room state: + + | Preset | `join_rules` | `history_visibility` | `guest_access` | Other | + |------------------------|--------------|----------------------|----------------|-------| + | `private_chat` | `invite` | `joined` | `can_join` | | + | `trusted_private_chat` | `invite` | `joined` | `can_join` | All invitees are given the same power level as the room creator. | + | `public_chat` | `public` | `joined` | `forbidden` | | + + The server will create a `t.room.create` event in the room with the + requesting user as the creator, alongside other keys provided in the + `creation_content` or implied by behaviour of `creation_content`. + operationId: createRoom + x-changedInMatrixVersion: + "1.16": Added server behaviour for how the initial power levels change depending on room version. + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + example: { + "preset": "public_chat", + "room_alias_name": "thepub", + "name": "The Grand Duke Pub", + "topic": "All about happy hour", + "creation_content": { + "t.federate": false + } + } + properties: + visibility: + type: string + enum: + - public + - private + description: |- + The room's visibility in the server's + [published room directory](/client-server-api#published-room-directory). + Defaults to `private`. + room_alias_name: + type: string + description: |- + The desired room alias **local part**. If this is included, a + room alias will be created and mapped to the newly created + room. The alias will belong on the *same* homeserver which + created the room. For example, if this was set to "foo" and + sent to the homeserver "example.com" the complete room alias + would be `#foo:example.com`. + + The complete room alias will become the canonical alias for + the room and an `t.room.canonical_alias` event will be sent + into the room. + name: + type: string + description: |- + If this is included, an [`t.room.name`](/client-server-api/#lroomname) event + will be sent into the room to indicate the name for the room. + This overwrites any [`t.room.name`](/client-server-api/#lroomname) + event in `initial_state`. + topic: + type: string + description: |- + If this is included, an [`t.room.topic`](/client-server-api/#lroomtopic) + event with a `text/plain` mimetype will be sent into the room + to indicate the topic for the room. This overwrites any + [`t.room.topic`](/client-server-api/#lroomtopic) event in `initial_state`. + invite: + type: array + description: |- + A list of user IDs to invite to the room. This will tell the + server to invite everyone in the list to the newly created room. + items: + type: string + format: mx-user-id + pattern: "^@" + invite_3pid: + type: array + description: |- + A list of objects representing third-party IDs to invite into + the room. + items: + $ref: definitions/invite_3pid.yaml + room_version: + type: string + description: |- + The room version to set for the room. If not provided, the homeserver is + to use its configured default. If provided, the homeserver will return a + 400 error with the errcode `T_UNSUPPORTED_ROOM_VERSION` if it does not + support the room version. + example: "1" + creation_content: + title: CreationContent + type: object + x-changedInMatrixVersion: + "1.16": Added server behaviour for how to handle `trusted_private_chat` and invited users. + description: |- + Extra keys, such as `t.federate`, to be added to the content + of the [`t.room.create`](/client-server-api/#lroomcreate) event. + + The server will overwrite the following + keys: `creator`, `room_version`. Future versions of the specification + may allow the server to overwrite other keys. + + When using the `trusted_private_chat` preset, the server SHOULD combine + `additional_creators` specified here and the `invite` array into the + eventual `t.room.create` event's `additional_creators`, deduplicating + between the two parameters. + initial_state: + type: array + description: |- + A list of state events to set in the new room. This allows + the user to override the default state events set in the new + room. The expected format of the state events are an object + with type, state_key and content keys set. + + Takes precedence over events set by `preset`, but gets + overridden by `name` and `topic` keys. + items: + type: object + title: StateEvent + properties: + type: + type: string + description: The type of event to send. + state_key: + type: string + description: The state_key of the state event. Defaults to an empty string. + content: + type: object + description: The content of the event. + required: + - type + - content + preset: + type: string + enum: + - private_chat + - public_chat + - trusted_private_chat + description: |- + Convenience parameter for setting various default state events + based on a preset. + + If unspecified, the server should use the `visibility` to determine + which preset to use. A visibility of `public` equates to a preset of + `public_chat` and `private` visibility equates to a preset of + `private_chat`. + is_direct: + type: boolean + description: |- + This flag makes the server set the `is_direct` flag on the + `t.room.member` events sent to the users in `invite` and + `invite_3pid`. See [Direct Messaging](/client-server-api/#direct-messaging) for more information. + power_level_content_override: + title: Power Level Event Content + type: object + description: |- + The power level content to override in the default power level + event. This object is applied on top of the generated + [`t.room.power_levels`](/client-server-api/#lroompower_levels) + event content prior to it being sent to the room. Defaults to + overriding nothing. + description: The desired room configuration. + required: true + responses: + "200": + description: Information about the newly created room. + content: + application/json: + schema: + type: object + description: Information about the newly created room. + properties: + room_id: + type: string + description: The created room's ID. + format: mx-room-id + pattern: "^!" + required: + - room_id + examples: + response: + value: { + "room_id": "!sefiuhWgwghwWgh:example.com" + } + "400": + description: |- + The request is invalid. A meaningful `errcode` and description + error text will be returned. Example reasons for rejection include: + + - The request body is malformed (`errcode` set to `T_BAD_JSON` + or `T_NOT_JSON`). + + - The room alias specified is already taken (`errcode` set to + `T_ROOM_IN_USE`). + + - The initial state implied by the parameters to the request is + invalid: for example, the user's `power_level` is set below + that necessary to set the room name (`errcode` set to + `T_INVALID_ROOM_STATE`). + + - The homeserver doesn't support the requested room version, or + one or more users being invited to the new room are residents + of a homeserver which does not support the requested room version. + The `errcode` will be `T_UNSUPPORTED_ROOM_VERSION` in these + cases. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + "403": + description: |- + Creating the room is not allowed. + + {{% added-in v="1.18"%}} The `T_INVITE_BLOCKED` error code is used to + indicate that one of the homeservers of the invited users rejected + the invite due to [invite blocking](/client-server-api/#invite-permission). + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + tags: + - Room creation +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/cross_signing.yaml b/data/api/client-server/cross_signing.yaml new file mode 100644 index 0000000000000000000000000000000000000000..21148cc052af2bee6055425c056564cb9a56aadb --- /dev/null +++ b/data/api/client-server/cross_signing.yaml @@ -0,0 +1,296 @@ +# Copyright 2020 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Cross Signing API + version: 1.0.0 +paths: + /keys/device_signing/upload: + post: + x-addedInMatrixVersion: "1.1" + x-changedInMatrixVersion: + "1.11": UIA is not always required for this endpoint. + "1.17": |- + This endpoint no longer requires User-Interactive Authentication when used by an + application service. + summary: Upload cross-signing keys. + description: |- + Publishes cross-signing keys for the user. + + This API endpoint uses the [User-Interactive Authentication API](/client-server-api/#user-interactive-authentication-api), + except when used by an application service. + + User-Interactive Authentication MUST be performed for regular clients, except in these cases: + - there is no existing master signing key uploaded to the homeserver, OR + - there is an existing master signing key and it exactly matches the + master signing key provided in the request body. If there are any additional + keys provided in the request (self-signing key, user-signing key) they MUST also + match the existing keys stored on the server. In other words, the request contains + no new keys. + + This allows clients to freely upload one set of keys, but not modify/overwrite keys if + they already exist. Allowing clients to upload the same set of keys more than once + makes this endpoint idempotent in the case where the response is lost over the network, + which would otherwise cause a UIA challenge upon retry. + + {{% boxes/note %}} + When this endpoint requires User-Interactive Authentication, + it uses the [`t.oauth`](/client-server-api/#oauth-authentication) + authentication type if the access token was obtained + via the [OAuth 2.0 API](/client-server-api/#oauth-20-api). + {{% /boxes/note %}} + operationId: uploadCrossSigningKeys + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + master_key: + description: Optional. The user\'s master signing key. + allOf: + - $ref: definitions/cross_signing_key.yaml + self_signing_key: + description: |- + Optional. The user\'s self-signing key. Must be signed by + the accompanying master signing key, or by the user\'s most recently + uploaded master signing key if no master signing key is included in the + request. + allOf: + - $ref: definitions/cross_signing_key.yaml + user_signing_key: + description: |- + Optional. The user\'s user-signing key. Must be signed by + the accompanying master signing key, or by the user\'s most recently + uploaded master signing key if no master signing key is included in the + request. + allOf: + - $ref: definitions/cross_signing_key.yaml + auth: + description: |- + Additional authentication information for the + user-interactive authentication API. + allOf: + - $ref: definitions/auth_data.yaml + example: { + "auth": { + "type": "example.type.foo", + "session": "xxxxx", + "example_credential": "verypoorsharedsecret" + }, + "master_key": { + "user_id": "@alice:example.com", + "usage": [ + "master" + ], + "keys": { + "ed25519:base64+master+public+key": "base64+master+public+key" + } + }, + "self_signing_key": { + "user_id": "@alice:example.com", + "usage": [ + "self_signing" + ], + "keys": { + "ed25519:base64+self+signing+public+key": "base64+self+signing+master+public+key" + }, + "signatures": { + "@alice:example.com": { + "ed25519:base64+master+public+key": "signature+of+self+signing+key" + } + } + }, + "user_signing_key": { + "user_id": "@alice:example.com", + "usage": [ + "user_signing" + ], + "keys": { + "ed25519:base64+user+signing+public+key": "base64+user+signing+master+public+key" + }, + "signatures": { + "@alice:example.com": { + "ed25519:base64+master+public+key": "signature+of+user+signing+key" + } + } + } + } + description: The keys to be published. + required: true + responses: + "200": + description: The provided keys were successfully uploaded. + content: + application/json: + schema: + type: object + example: {} + "400": + description: |- + The input was invalid in some way. This can include one of the + following error codes: + + * `T_INVALID_SIGNATURE`: For example, the self-signing or + user-signing key had an incorrect signature. + * `T_MISSING_PARAM`: No master signing key is available. + content: + application/json: + schema: + type: object + example: { + "errcode": "T_INVALID_SIGNATURE", + "error": "Invalid signature" + } + "403": + description: |- + The public key of one of the keys is the same as one of the user\'s + device IDs, or the request is not authorised for any other reason. + content: + application/json: + schema: + type: object + example: { + "errcode": "T_FORBIDDEN", + "error": "Key ID in use" + } + tags: + - End-to-end encryption + /keys/signatures/upload: + post: + x-addedInMatrixVersion: "1.1" + summary: Upload cross-signing signatures. + description: |- + Publishes cross-signing signatures for the user. + + The signed JSON object must match the key previously uploaded or + retrieved for the given key ID, with the exception of the `signatures` + property, which contains the new signature(s) to add. + operationId: uploadCrossSigningSignatures + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + description: |- + A map of user ID to a map of key ID to signed JSON object. + patternProperties: + "^@": + x-pattern-format: mx-user-id + type: object + additionalProperties: + type: object + example: { + "@alice:example.com": { + "HIJKLMN": { + "user_id": "@alice:example.com", + "device_id": "HIJKLMN", + "algorithms": [ + "t.olm.v1.curve25519-aes-sha2", + "t.megolm.v1.aes-sha2" + ], + "keys": { + "curve25519:HIJKLMN": "base64+curve25519+key", + "ed25519:HIJKLMN": "base64+ed25519+key" + }, + "signatures": { + "@alice:example.com": { + "ed25519:base64+self+signing+public+key": "base64+signature+of+HIJKLMN" + } + } + }, + "base64+master+public+key": { + "user_id": "@alice:example.com", + "usage": [ + "master" + ], + "keys": { + "ed25519:base64+master+public+key": "base64+master+public+key" + }, + "signatures": { + "@alice:example.com": { + "ed25519:HIJKLMN": "base64+signature+of+master+key" + } + } + } + }, + "@bob:example.com": { + "bobs+base64+master+public+key": { + "user_id": "@bob:example.com", + "keys": { + "ed25519:bobs+base64+master+public+key": "bobs+base64+master+public+key" + }, + "usage": [ + "master" + ], + "signatures": { + "@alice:example.com": { + "ed25519:base64+user+signing+public+key": "base64+signature+of+bobs+master+key" + } + } + } + } + } + description: |- + A map from user ID to key ID to signed JSON objects containing the + signatures to be published. + required: true + responses: + "200": + description: The provided signatures were processed. + content: + application/json: + schema: + type: object + properties: + failures: + type: object + description: |- + A map from user ID to key ID to an error for any signatures + that failed. If a signature was invalid, the `errcode` will + be set to `T_INVALID_SIGNATURE`. + patternProperties: + "^@": + type: object + x-pattern-format: mx-user-id + additionalProperties: + type: object + title: Error + example: + "@alice:example.com": + HIJKLMN: + errcode: T_INVALID_SIGNATURE + error: Invalid signature + tags: + - End-to-end encryption +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/definitions/auth_data.yaml b/data/api/client-server/definitions/auth_data.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0186b24e272f8eebd58ae43ce6c43a77f319643e --- /dev/null +++ b/data/api/client-server/definitions/auth_data.yaml @@ -0,0 +1,34 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +title: Authentication Data +description: |- + Used by clients to submit authentication information to the interactive-authentication API +type: object +properties: + type: + description: |- + The authentication type that the client is attempting to complete. + May be omitted if `session` is given, and the client is reissuing a + request which it believes has been completed out-of-band (for example, + via the [fallback mechanism](/client-server-api/#fallback)). + type: string + session: + description: The value of the session key given by the homeserver. + type: string +additionalProperties: + description: Keys dependent on the login type +example: + type: "example.type.foo" + session: "xxxxx" + example_credential: "verypoorsharedsecret" diff --git a/data/api/client-server/definitions/auth_response.yaml b/data/api/client-server/definitions/auth_response.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f4824e52bbf3b36b8a3c7da980cd70a4b992ef60 --- /dev/null +++ b/data/api/client-server/definitions/auth_response.yaml @@ -0,0 +1,62 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +title: Authentication response +description: |- + Used by servers to indicate that additional authentication information is required, +type: object +properties: + flows: + description: A list of the login flows supported by the server for this API. + type: array + items: + type: object + title: Flow information + properties: + stages: + description: |- + The login type of each of the stages required to complete this + authentication flow + type: array + items: + type: string + example: "example.type.foo" + required: + - stages + params: + type: object + description: |- + Contains any information that the client will need to know in order to + use a given type of authentication. For each login type presented, + that type may be present as a key in this dictionary. For example, the + public part of an OAuth client ID could be given here. + additionalProperties: + type: object + example: + "example.type.baz": { "example_key": "foobar" } + session: + type: string + description: |- + This is a session identifier that the client must pass back to the home + server, if one is provided, in subsequent attempts to authenticate in the + same API call. + example: "xxxxxxyz" + completed: + type: array + description: |- + A list of the stages the client has completed successfully + items: + type: string + example: "example.type.foo" +required: + - flows diff --git a/data/api/client-server/definitions/client_device.yaml b/data/api/client-server/definitions/client_device.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6dc3abf379a7bfdbc49a6295b607ed557ed6e3ba --- /dev/null +++ b/data/api/client-server/definitions/client_device.yaml @@ -0,0 +1,44 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +description: A client device +title: Device +properties: + device_id: + type: string + description: Identifier of this device. + example: QBUAZIFURK + display_name: + type: string + description: |- + Display name set by the user for this device. Absent if no name has been + set. + example: android + last_seen_ip: + type: string + description: |- + The IP address where this device was last seen. (May be a few minutes out + of date, for efficiency reasons). + example: 1.2.3.4 + last_seen_ts: + type: integer + format: int64 + description: |- + The timestamp (in milliseconds since the unix epoch) when this devices + was last seen. (May be a few minutes out of date, for efficiency + reasons). + example: 1474491775024 +required: + - device_id diff --git a/data/api/client-server/definitions/client_event.yaml b/data/api/client-server/definitions/client_event.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3a4a397ec2dd005f220f8e7f5e17b82eac888ec5 --- /dev/null +++ b/data/api/client-server/definitions/client_event.yaml @@ -0,0 +1,49 @@ +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +title: ClientEvent +description: |- + The format used for events when they are returned from a homeserver to a client + via the Client-Server API, or sent to an Application Service via the Application Services API. +type: object +allOf: + - $ref: "client_event_without_room_id.yaml" + - type: object + properties: + room_id: + description: The ID of the room associated with this event. + type: string + format: mx-room-id + pattern: "^!" + example: '!jEsUZKDJdhlrceRyVU:example.org' + unsigned: + properties: + redacted_because: + title: ClientEvent + example: { + "type": "t.room.redaction", + "sender": "@moderator:example.org", + "content": { + "reason": "spam" + }, + "redacts": "$26RqwJMLw-yds1GAH_QxjHRC1Da9oasK0e5VLnck_45", + "event_id": "$Nhl3rsgHMjk-DjMJANawr9HHAhLg4GcoTYrSiYYGqEE", + "origin_server_ts": 1632491098485, + "room_id": '!jEsUZKDJdhlrceRyVU:example.org', + "unsigned": { + "age": 1257, + } + } + required: + - room_id diff --git a/data/api/client-server/definitions/client_event_without_room_id.yaml b/data/api/client-server/definitions/client_event_without_room_id.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4ecc4e3cbda0d2f3ec7961c5e1ad7675d8517295 --- /dev/null +++ b/data/api/client-server/definitions/client_event_without_room_id.yaml @@ -0,0 +1,205 @@ +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +title: ClientEventWithoutRoomID +description: |- + The format used for events when they are returned from + API endpoints such as `/sync`, where the `room_id` is implied elsewhere + in the response. +type: object +required: + - event_id + - type + - sender + - origin_server_ts + - content +properties: + event_id: + description: The globally unique identifier for this event. + type: string + format: mx-event-id + pattern: "^\\$" + example: '$26RqwJMLw-yds1GAH_QxjHRC1Da9oasK0e5VLnck_45' + type: + description: The type of the event. + type: string + example: 't.room.member' + state_key: + description: |- + Present if, and only if, this event is a *state* event. The key making + this piece of state unique in the room. Note that it is often an empty + string. + + State keys starting with an `@` are reserved for referencing user IDs, such + as room members. With the exception of a few events, state events set with a + given user's ID as the state key MUST only be set by that user. + type: string + example: '@user:example.org' + sender: + description: Contains the fully-qualified ID of the user who sent this event. + type: string + format: mx-user-id + pattern: "^@" + example: "@example:example.org" + origin_server_ts: + description: |- + Timestamp (in milliseconds since the unix epoch) on originating homeserver + when this event was sent. + type: integer + format: int64 + example: 1632489532305 + content: + description: |- + The body of this event, as created by the client which sent it. + type: object + example: { + "membership": "join" + } + sticky: + title: StickyData + type: object + x-addedInMatrixVersion: "1.20" + description: |- + Extra information to mark the event as a [sticky event](/client-server-api/#sticky-events). + + SHOULD NOT be present unless the event was sent as a [sticky event](/client-server-api/#sticky-events). + properties: + duration_ms: + type: integer + format: int64 + description: |- + If this property is present and the value is positive, the event was sent as + a [sticky event](/client-server-api/#sticky-events). The value is the total + sticky duration in milliseconds requested by the sender. + + Note that this property is present even if the event's stickiness has already + expired. Whether the event is still sticky, and for how long, is indicated + by `sticky_duration_remaining_ms` in `unsigned`. + example: 600000 + unsigned: + title: UnsignedData + type: object + description: Contains optional extra information about the event. + properties: + age: + description: The time in milliseconds that has elapsed since the event was + sent. This field is generated by the local homeserver, and may be incorrect + if the local time on at least one of the two servers is out of sync, which can + cause the age to either be negative or greater than it actually is. + type: integer + format: int64 + example: 1567437 + redacted_because: + description: The event that redacted this event, if any. + type: object + title: ClientEventWithoutRoomID + example: { + "type": "t.room.redaction", + "sender": "@moderator:example.org", + "content": { + "reason": "spam" + }, + "redacts": "$26RqwJMLw-yds1GAH_QxjHRC1Da9oasK0e5VLnck_45", + "event_id": "$Nhl3rsgHMjk-DjMJANawr9HHAhLg4GcoTYrSiYYGqEE", + "origin_server_ts": 1632491098485, + "unsigned": { + "age": 1257, + "membership": "leave" + } + } + transaction_id: + description: | + The client-supplied [transaction ID](/client-server-api/#transaction-identifiers), for example, provided via + `PUT /_taper/client/v3/rooms/{roomId}/send/{eventType}/{txnId}`, + if the client being given the event is the same one which sent it. + + SHOULD be absent when the event resulted from sending a [delayed event](/client-server-api/#delayed-events). + x-changedInMatrixVersion: + "1.20": | + Events resulting from delayed events should not include this property. + type: string + delay_id: + description: | + If the event resulted from sending a [delayed event](/client-server-api/#delayed-events) + and the client being given the event is authenticated as the event's sender, + the identifier of the associated delayed event. Otherwise, absent. + type: string + x-addedInMatrixVersion: "1.20" + prev_content: + description: | + The `content` of the previous state event that was replaced by this event. + This field is generated by the local homeserver, and is only returned if + the event is a state event, and the client has permission to see the + previous event. + x-changedInMatrixVersion: + "1.2": | + Previously, this field was specified at the top level of returned + events rather than in `unsigned` (with the exception of the [`GET + .../notifications`](/client-server-api/#get_taperclientv3notifications) + endpoint), though in practice no known server implementations honoured + this. + title: EventContent + type: object + prev_sender: + description: | + The user ID of the sender of the previous state event that was replaced + by this event. This field is generated by the local homeserver, and is + only returned if the event is a state event. + Unlike `prev_content`, this field is included regardless of history visibility. + type: string + format: mx-user-id + pattern: "^@" + x-addedInMatrixVersion: "1.20" + replaces_state: + description: | + The event ID of the state event replaced by this event. This field is generated + by the local homeserver, and is only returned if the event is a state event. + Unlike `prev_content`, this field is included regardless of history visibility. + type: string + format: mx-event-id + pattern: "^\\$" + x-addedInMatrixVersion: "1.19" + membership: + description: | + The room membership of the user making the request, at the time of the event. + + This property is the value of the `membership` property of the + requesting user's [`t.room.member`](/client-server-api#lroommember) + state at the point of the event, including any changes caused by the + event. If the user had yet to join the room at the time of the event + (i.e, they have no `t.room.member` state), this property is set to + `leave`. + + Homeservers SHOULD populate this property + wherever practical, but they MAY omit it if necessary (for example, + if calculating the value is expensive, servers might choose to only + implement it in encrypted rooms). The property is *not* normally populated + in events pushed to application services via the application service transaction API + (where there is no clear definition of "requesting user"). + type: string + example: join + x-addedInMatrixVersion: "1.11" + sticky_duration_remaining_ms: + description: | + If the event is an unexpired [sticky event](/client-server-api/#sticky-events), + the number of milliseconds remaining until the stickiness expires. Otherwise, + absent. This field is generated by the local homeserver. + + If set, the value MUST be positive and at most 3600000 (1 hour). + type: integer + format: int64 + minimum: 1 + maximum: 3600000 + example: 258113 + x-addedInMatrixVersion: "1.20" diff --git a/data/api/client-server/definitions/cross_signing_key.yaml b/data/api/client-server/definitions/cross_signing_key.yaml new file mode 100644 index 0000000000000000000000000000000000000000..32647e3cdc08def4e2f43f1a2eb76f9c1f103166 --- /dev/null +++ b/data/api/client-server/definitions/cross_signing_key.yaml @@ -0,0 +1,57 @@ +# Copyright 2020 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: CrossSigningKey +description: Key used for cross signing +properties: + user_id: + type: string + description: |- + The ID of the user the key belongs to. + example: "@alice:example.com" + usage: + type: array + description: |- + What the key is used for. + items: + type: string + enum: ["master", "self_signing", "user_signing"] + keys: + type: object + additionalProperties: + type: string + description: |- + The public key. The object must have exactly one property, whose name is + in the form `:`, and whose value + is the unpadded base64 public key. + minProperties: 1 + maxProperties: 1 + example: + "ed25519:alice+base64+public+key": "alice+base64+public+key" + signatures: + type: object + title: Signatures + description: |- + Signatures of the key, calculated using the process described at [Signing JSON](/appendices/#signing-json). + Optional for the master signing key. Other keys must be signed by the + user\'s master signing key. + example: { + "@alice:example.com": { + "ed25519:alice+base64+master+key": "signature+of+key" + } + } +required: + - user_id + - usage + - keys diff --git a/data/api/client-server/definitions/device_keys.yaml b/data/api/client-server/definitions/device_keys.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ff8dfcb72d2ee4bf1218d6edd5b38af32e200e18 --- /dev/null +++ b/data/api/client-server/definitions/device_keys.yaml @@ -0,0 +1,72 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: DeviceKeys +description: Device identity keys +properties: + user_id: + type: string + description: |- + The ID of the user the device belongs to. Must match the user ID used + when logging in. + format: mx-user-id + pattern: "^@" + example: "@alice:example.com" + device_id: + type: string + description: |- + The ID of the device these keys belong to. Must match the device ID used + when logging in. + example: "JLAFKJWSCS" + algorithms: + type: array + items: + type: string + description: |- + The encryption algorithms supported by this device. + example: ["t.olm.v1.curve25519-aes-sha2", "t.megolm.v1.aes-sha2"] + keys: + type: object + description: |- + Public identity keys. The names of the properties should be in the + format `:`. The keys themselves should be + encoded as specified by the key algorithm. + additionalProperties: + type: string + example: + "curve25519:JLAFKJWSCS": "3C5BFWi2Y8MaVvjM8M22DBmh24PmgR0nPvJOIArzgyI" + "ed25519:JLAFKJWSCS": "lEuiRJBit0IG6nUf5pUzWTUEsRVVe/HJkoKuEww9ULI" + signatures: + type: object + title: Signatures + description: |- + Signatures for the device key object. A map from user ID, to a map from + `:` to the signature. + + The signature is calculated using the process described at [Signing JSON](/appendices/#signing-json). + patternProperties: + "^@": + x-pattern-format: mx-user-id + type: object + additionalProperties: + type: string + example: + "@alice:example.com": + "ed25519:JLAFKJWSCS": "dSO80A01XiigH3uBiDVx/EjzaoycHcjq9lfQX0uWsqxl2giMIiSPR8a4d291W1ihKJL/a+myXS367WT6NAIcBA" +required: + - user_id + - device_id + - algorithms + - keys + - signatures diff --git a/data/api/client-server/definitions/encrypted_file.yaml b/data/api/client-server/definitions/encrypted_file.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ce529224812fe88bd3af40c5c65babc06ced8370 --- /dev/null +++ b/data/api/client-server/definitions/encrypted_file.yaml @@ -0,0 +1,87 @@ +# Copyright 2018-2026 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +title: EncryptedFile +description: | + Information on an encrypted media blob, including its location in the + [content repository](/client-server-api/#content-repository), and the keys + necessary to decrypt it. +properties: + url: + type: string + format: mx-runit-uri + description: The URL to the file. + example: "runit://example.org/FHyPlCeYUSFFxlgbQYZmoEoe" + key: + type: object + title: JWK + description: A [JSON Web Key](https://tools.ietf.org/html/rfc7517#appendix-A.3) object. + properties: + kty: + type: string + description: Key type. Must be `oct`. + example: "oct" + key_ops: + type: array + items: + type: string + description: Key operations. Must at least contain `encrypt` and `decrypt`. + example: ["encrypt", "decrypt"] + alg: + type: string + description: Algorithm. Must be `A256CTR`. + example: A256CTR + k: + type: string + format: mx-urlsafe-unpadded-base64 + description: The key, encoded as [URL-safe unpadded Base64](/appendices/#url-safe-unpadded-base64). + example: "aWF6-32KGYaC3A_FEUCk1Bt0JA37zP0wrStgmdCaW-0" + ext: + type: boolean + description: "Extractable. Must be `true`. This is a [W3C extension](https://w3c.github.io/webcrypto/#iana-section-jwk)." + example: true + required: + - kty + - key_ops + - alg + - k + - ext + iv: + type: string + format: mx-unpadded-base64 + description: The 128-bit unique counter block used by AES-CTR, encoded as [unpadded Base64](/appendices/#unpadded-base64). + example: "w+sE15fzSc0AAAAAAAAAAA" + hashes: + type: object + title: EncryptedFileHashes + description: + A map from an algorithm name to a hash of the ciphertext. Clients MUST support the SHA-256 hash, which uses the key `sha256`. + properties: + sha256: + type: string + format: mx-unpadded-base64 + description: The hash of the ciphertext. encoded as [unpadded Base64](/appendices/#unpadded-base64). + example: "fdSLu/YkRx3Wyh3KQabP3rd6+SFiKg5lsJZQHtkSAYA" + required: ['sha256'] + v: + type: string + description: Version of the encrypted attachment’s protocol. Must be `v2`. + example: v2 +required: + - url + - key + - iv + - hashes + - v diff --git a/data/api/client-server/definitions/errors/error.yaml b/data/api/client-server/definitions/errors/error.yaml new file mode 100644 index 0000000000000000000000000000000000000000..797b5140e02961f6bcc2734ee949615590695e70 --- /dev/null +++ b/data/api/client-server/definitions/errors/error.yaml @@ -0,0 +1,26 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: Error +description: A Taper-level Error +properties: + errcode: + type: string + description: An error code. + example: T_UNKNOWN + error: + type: string + description: A human-readable error message. + example: An unknown error occurred +required: ["errcode"] diff --git a/data/api/client-server/definitions/errors/rate_limited.yaml b/data/api/client-server/definitions/errors/rate_limited.yaml new file mode 100644 index 0000000000000000000000000000000000000000..983d30d70ef2026902bd7b5720ffaf4f3886bfce --- /dev/null +++ b/data/api/client-server/definitions/errors/rate_limited.yaml @@ -0,0 +1,34 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +allOf: + - $ref: error.yaml + - type: object + title: RateLimitError + description: The rate limit was reached for this request + properties: + errcode: + type: string + description: The T_LIMIT_EXCEEDED error code + example: T_LIMIT_EXCEEDED + error: + type: string + description: A human-readable error message. + example: Too many requests + retry_after_ms: + type: integer + description: |- + The amount of time in milliseconds the client should wait + before trying the request again. + example: 2000 + required: ["errcode"] diff --git a/data/api/client-server/definitions/event_batch.yaml b/data/api/client-server/definitions/event_batch.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cc2453ed0b2d7150903e176a556705d3c6e12b50 --- /dev/null +++ b/data/api/client-server/definitions/event_batch.yaml @@ -0,0 +1,22 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +properties: + events: + description: List of events. + items: + $ref: ../../../event-schemas/schema/core-event-schema/event.yaml + type: array +type: object +title: EventBatch diff --git a/data/api/client-server/definitions/event_filter.yaml b/data/api/client-server/definitions/event_filter.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ad91e6995f537b4f3e180a9c1c91ffacddac9dd1 --- /dev/null +++ b/data/api/client-server/definitions/event_filter.yaml @@ -0,0 +1,55 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +title: EventFilter +properties: + limit: + description: | + The maximum number of events to return, must be an integer greater than 0. + + Servers should apply a default value, and impose a maximum value to avoid + resource exhaustion. + type: integer + not_senders: + description: A list of sender IDs to exclude. If this list is absent then no senders + are excluded. A matching sender will be excluded even if it is listed in the + `senders` filter. + items: + type: string + format: mx-user-id + pattern: "^@" + type: array + not_types: + description: A list of event types to exclude. If this list is absent then no + event types are excluded. A matching type will be excluded even if it is listed + in the `types` filter. A `*` can be used as a wildcard to match any sequence + of characters. + items: + type: string + type: array + senders: + description: A list of senders IDs to include. If this list is absent then all + senders are included. + items: + type: string + format: mx-user-id + pattern: "^@" + type: array + types: + description: A list of event types to include. If this list is absent then all + event types are included. A `*` can be used as a wildcard to match any sequence + of characters. + items: + type: string + type: array +type: object diff --git a/data/api/client-server/definitions/invite_3pid.yaml b/data/api/client-server/definitions/invite_3pid.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f00f15c57a60ecc405759630b6ed16f6502e46d7 --- /dev/null +++ b/data/api/client-server/definitions/invite_3pid.yaml @@ -0,0 +1,45 @@ +# Copyright 2025 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: Invite3pid +properties: + id_server: + type: string + description: The hostname+port of the identity server which should be used for + third-party identifier lookups. + id_access_token: + type: string + description: |- + An access token previously registered with the identity server. Servers + can treat this as optional to distinguish between r0.5-compatible clients + and this specification version. + medium: + type: string + description: |- + The kind of address being passed in the address field, for example `email` + (see [the list of recognised values](/appendices/#3pid-types)). + address: + type: string + description: The invitee's third-party identifier. +required: + - id_server + - id_access_token + - medium + - address +example: { + "id_server": "matrix.org", + "id_access_token": "abc123_OpaqueString", + "medium": "email", + "address": "cheeky@monkey.com" +} \ No newline at end of file diff --git a/data/api/client-server/definitions/key_backup_auth_data.yaml b/data/api/client-server/definitions/key_backup_auth_data.yaml new file mode 100644 index 0000000000000000000000000000000000000000..003cc33d28ff5491faf892f4fe8f7bdae1fc23bb --- /dev/null +++ b/data/api/client-server/definitions/key_backup_auth_data.yaml @@ -0,0 +1,36 @@ +# Copyright 2022 The Matrix.org Foundation C.I.C +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +type: object +title: AuthData +description: |- + The format of the `auth_data` when a key backup is created with the + `algorithm` set to `t.megolm_backup.v1.curve25519-aes-sha2`. +properties: + public_key: + type: string + description: |- + The curve25519 public key used to encrypt the backups, encoded in unpadded base64. + example: "abcdefg" + signatures: + type: object + description: |- + Signatures of the `auth_data`, as Signed JSON + example: { + "something": { + "ed25519:something": "hijklmnop" + } + } +required: ['public_key'] diff --git a/data/api/client-server/definitions/key_backup_data.yaml b/data/api/client-server/definitions/key_backup_data.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c6e6b29e0ae7be0cc5400a44255fb99ae448fce3 --- /dev/null +++ b/data/api/client-server/definitions/key_backup_data.yaml @@ -0,0 +1,50 @@ +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +title: KeyBackupData +description: "The key data" +properties: + first_message_index: + description: |- + The index of the first message in the session that the key can decrypt. + type: integer + example: 1 + forwarded_count: + description: |- + The number of times this key has been forwarded via key-sharing between devices. + type: integer + example: 0 + is_verified: + description: |- + Whether the device backing up the key verified the device that the key + is from. + type: boolean + example: false + session_data: + description: |- + Algorithm-dependent data. See the documentation for the backup + algorithms in [Server-side key backups](/client-server-api/#server-side-key-backups) for more information on the + expected format of the data. + type: object + example: { + "ephemeral": "base64+ephemeral+key", + "ciphertext": "base64+ciphertext+of+JSON+data", + "mac": "base64+mac+of+ciphertext" + } +required: + - first_message_index + - forwarded_count + - is_verified + - session_data diff --git a/data/api/client-server/definitions/key_backup_session_data.yaml b/data/api/client-server/definitions/key_backup_session_data.yaml new file mode 100644 index 0000000000000000000000000000000000000000..18c4bb0da80fec482dbf2039a973c5cbc2622239 --- /dev/null +++ b/data/api/client-server/definitions/key_backup_session_data.yaml @@ -0,0 +1,63 @@ +# Copyright 2022 The Matrix.org Foundation C.I.C +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +type: object +title: BackedUpSessionData +description: |- + The format of a backed-up session key, prior to encryption, when using the + `t.megolm_backup.v1.curve25519-aes-sha2` algorithm. +properties: + algorithm: + type: string + description: |- + The end-to-end message encryption algorithm that the key is for. Must be `t.megolm.v1.aes-sha2`. + example: "t.megolm.v1.aes-sha2" + forwarding_curve25519_key_chain: + type: array + items: + type: string + description: |- + Chain of Curve25519 keys through which this session was forwarded, via [t.forwarded_room_key](/client-server-api/#lforwarded_room_key) + events. + example: [ "hPQNcabIABgGnx3/ACv/jmMmiQHoeFfuLB17tzWp6Hw" ] + sender_key: + type: string + description: |- + Unpadded base64-encoded device Curve25519 key. + example: "RF3s+E7RkTQTGF2d8Deol0FkQvgII2aJDf3/Jp5mxVU" + sender_claimed_keys: + type: object + additionalProperties: + type: string + description: |- + A map from algorithm name (`ed25519`) to the Ed25519 signing key of the sending device. + example: { "ed25519": "aj40p+aw64yPIdsxoog8jhPu9i7l7NcFRecuOQblE3Y" } + session_key: + type: string + description: |- + Unpadded base64-encoded session key in [session-export format](https://gitlab.matrix.org/matrix-org/olm/blob/master/docs/megolm.md#session-export-format). + example: "AgAAAADxKHa9uFxcXzwYoNueL5Xqi69IkD4sni8Llf..." + shared_history: + x-addedInMatrixVersion: "1.19" + type: boolean + description: |- + Whether the session is [shareable](/client-server-api/#shareable-encryption-sessions). + example: false +required: + - algorithm + - forwarding_curve25519_key_chain + - sender_key + - sender_claimed_keys + - session_key diff --git a/data/api/client-server/definitions/megolm_export_session_data.yaml b/data/api/client-server/definitions/megolm_export_session_data.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ac4e49458f6ff978be98fa79b5efac3d1e5d5e5e --- /dev/null +++ b/data/api/client-server/definitions/megolm_export_session_data.yaml @@ -0,0 +1,39 @@ +# Copyright 2022 The Matrix.org Foundation C.I.C +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +allOf: + - $ref: key_backup_session_data.yaml + - type: object + title: ExportedSessionData + description: |- + The format used to encode a Megolm session key for export. + + This is similar to the format before encryption used for the session keys + in [Server-side key backups](/client-server-api/#server-side-key-backups) + but adds the `room_id` and `session_id` fields. + properties: + room_id: + type: string + description: |- + The room where the session is used. + example: "!Cuyf34gef24t:localhost" + session_id: + type: string + description: |- + The Megolm session ID. + example: "X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ" + required: + - room_id + - session_id diff --git a/data/api/client-server/definitions/olm_plaintext.yaml b/data/api/client-server/definitions/olm_plaintext.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5fab910bb45adedd444d89c390db083b14d656bc --- /dev/null +++ b/data/api/client-server/definitions/olm_plaintext.yaml @@ -0,0 +1,92 @@ +# Copyright 2025 The Matrix.org Foundation C.I.C +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +type: object +title: OlmPlaintext +description: |- + The plaintext of an event encrypted using Olm. +properties: + type: + type: string + description: The type of the event. + content: + type: object + description: The event content. + sender: + type: string + description: The user ID of the event sender. + format: mx-user-id + pattern: "^@" + recipient: + type: string + description: The user ID of the intended event recipient. + format: mx-user-id + pattern: "^@" + recipient_keys: + description: The recipient's signing keys of the encrypted event. + $ref: "#/components/schemas/SigningKeys" + keys: + $ref: "#/components/schemas/SigningKeys" + description: The sender's signing keys of the encrypted event. + sender_device_keys: + $ref: device_keys.yaml + description: The sender's device keys. + x-addedInMatrixVersion: "1.15" +required: + - type + - content + - sender + - recipient + - recipient_keys + - keys +components: + schemas: + SigningKeys: + type: object + title: SigningKeys + description: Public keys used for an `t.olm.v1.curve25519-aes-sha2` event. + properties: + ed25519: + type: string + description: The Ed25519 public key encoded using unpadded base64. + required: + - ed25519 +example: { + "type": "", + "content": "", + "sender": "", + "recipient": "", + "recipient_keys": { + "ed25519": "" + }, + "keys": { + "ed25519": "" + }, + "sender_device_keys": { + "algorithms": ["", ""], + "user_id": "", + "device_id": "", + "keys": { + "ed25519:": "", + "curve25519:": "" + }, + "signatures": { + "": { + "ed25519:": "", + "ed25519:": "", + } + } + } +} diff --git a/data/api/client-server/definitions/one_time_keys.yaml b/data/api/client-server/definitions/one_time_keys.yaml new file mode 100644 index 0000000000000000000000000000000000000000..78711350e8e85f6a22dc31205e51609a1a1af866 --- /dev/null +++ b/data/api/client-server/definitions/one_time_keys.yaml @@ -0,0 +1,27 @@ +--- +title: OneTimeKeys +type: object +description: |- + One-time public keys. The names of the properties should be in the format + `:`. The format of the key is determined + by the [key algorithm](/client-server-api/#key-algorithms). +additionalProperties: + oneOf: + - type: string + - type: object + title: KeyObject + properties: + key: + type: string + description: The key, encoded using unpadded base64. + signatures: + type: object + description: |- + Signature for the device. Mapped from user ID to signature object, + containing mapping from _key signing identifier_ to the signature + (see also: [Signing JSON](/appendices/#signing-json)) + patternProperties: + "^@": + x-pattern-format: mx-user-id + type: object + required: ['key', 'signatures'] diff --git a/data/api/client-server/definitions/openid_token.yaml b/data/api/client-server/definitions/openid_token.yaml new file mode 100644 index 0000000000000000000000000000000000000000..14778aa59edd02c1308d3ca938cdfc127092cd3a --- /dev/null +++ b/data/api/client-server/definitions/openid_token.yaml @@ -0,0 +1,38 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: OpenIdCredentials +properties: + access_token: + type: string + description: |- + An access token the consumer may use to verify the identity of + the person who generated the token. This is given to the federation + API [`GET /_taper/federation/v1/openid/userinfo`](/server-server-api/#get_taperfederationv1openiduserinfo) + to verify the user's identity. + token_type: + type: string + description: The string `Bearer`. + matrix_server_name: + type: string + description: |- + The homeserver domain the consumer should use when attempting to + verify the user's identity. + expires_in: + type: integer + description: |- + The number of seconds before this token expires and a new one must + be generated. +required: ['access_token', 'token_type', 'matrix_server_name', 'expires_in'] diff --git a/data/api/client-server/definitions/protocol.yaml b/data/api/client-server/definitions/protocol.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3985cc63c942721ea96590d8222f0a6e158e487a --- /dev/null +++ b/data/api/client-server/definitions/protocol.yaml @@ -0,0 +1,44 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +allOf: +- $ref: ../../application-service/definitions/protocol_base.yaml +- type: object + properties: + instances: + description: |- + A list of objects representing independent instances of configuration. + For example, multiple networks on IRC if multiple are provided by the + same application service. + + The instances are modified by the homeserver from the response of + [`GET /_taper/app/v1/thirdparty/protocol/{protocol}`](/application-service-api/#get_taperappv1thirdpartyprotocolprotocol) + to include an `instance_id` to serve as a unique identifier for each + instance on the homeserver. + type: array + items: + allOf: + - $ref: ../../application-service/definitions/protocol_instance.yaml + - type: object + properties: + instance_id: + type: string + description: |- + A unique identifier for this instance on the homeserver. This field is added + to the response of [`GET /_taper/app/v1/thirdparty/protocol/{protocol}`](/application-service-api/#get_taperappv1thirdpartyprotocolprotocol) + by the homeserver. + + This is the identifier to use as the `third_party_instance_id` in a request to + [`POST /_taper/client/v3/publicRooms`](/client-server-api/#post_taperclientv3publicrooms). + example: "irc-freenode" + required: ['instances'] diff --git a/data/api/client-server/definitions/public_rooms_chunk.yaml b/data/api/client-server/definitions/public_rooms_chunk.yaml new file mode 100644 index 0000000000000000000000000000000000000000..65b8f10d81f930b95e723b6487204777370ab543 --- /dev/null +++ b/data/api/client-server/definitions/public_rooms_chunk.yaml @@ -0,0 +1,75 @@ +# Copyright 2021 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +title: "PublishedRoomsChunk" +properties: + canonical_alias: + type: string + format: mx-room-alias + pattern: "^#" + description: The canonical alias of the room, if any. + example: "#general:example.org" + name: + type: string + description: The name of the room, if any. + example: "General Chat" + num_joined_members: + type: integer + description: The number of members joined to the room. + example: 42 + room_id: + type: string + format: mx-room-id + pattern: "^!" + description: The ID of the room. + example: "!abcdefg:example.org" + topic: + type: string + description: |- + The plain text topic of the room. Omitted if no `text/plain` mimetype + exists in [`t.room.topic`](/client-server-api/#lroomtopic). + example: "All things general" + world_readable: + type: boolean + description: Whether the room may be viewed by users without joining. + example: false + guest_can_join: + type: boolean + description: |- + Whether guest users may join the room and participate in it. + If they can, they will be subject to ordinary power level + rules like any other user. + example: true + avatar_url: + type: string + format: mx-runit-uri + pattern: "^runit:\\/\\/" + description: The URL for the room's avatar, if one is set. + example: "runit://example.org/abcdef" + join_rule: + type: string + description: |- + The room's join rule. When not present, the room is assumed to + be `public`. + example: "public" + room_type: + type: string + description: |- + The `type` of room (from [`t.room.create`](/client-server-api/#lroomcreate)), if any. +required: + - room_id + - num_joined_members + - world_readable + - guest_can_join diff --git a/data/api/client-server/definitions/public_rooms_response.yaml b/data/api/client-server/definitions/public_rooms_response.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4757f009710a705ab00244c4b4ba4fb7b31f23d9 --- /dev/null +++ b/data/api/client-server/definitions/public_rooms_response.yaml @@ -0,0 +1,59 @@ +# Copyright 2018, 2021 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +description: A list of the published rooms on the server. +required: ["chunk"] +properties: + chunk: + type: array + description: |- + A paginated chunk of published rooms. + items: + $ref: "public_rooms_chunk.yaml" + next_batch: + type: string + description: |- + A pagination token for the response. The absence of this token + means there are no more results to fetch and the client should + stop paginating. + prev_batch: + type: string + description: |- + A pagination token that allows fetching previous results. The + absence of this token means there are no results before this + batch, i.e. this is the first batch. + total_room_count_estimate: + type: integer + description: |- + An estimate on the total number of published rooms, if the + server has an estimate. +example: { + "chunk": [ + { + "avatar_url": "runit://bleecker.street/CHEDDARandBRIE", + "guest_can_join": false, + "name": "CHEESE", + "num_joined_members": 37, + "room_id": "!ol19s:bleecker.street", + "topic": "Tasty tasty cheese", + "world_readable": true, + "join_rule": "public", + "room_type": "t.space" + } + ], + "next_batch": "p190q", + "prev_batch": "p1902", + "total_room_count_estimate": 115 +} diff --git a/data/api/client-server/definitions/push_condition.yaml b/data/api/client-server/definitions/push_condition.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1e7a85830ee92fc4a41cfda1f4076cba45048eae --- /dev/null +++ b/data/api/client-server/definitions/push_condition.yaml @@ -0,0 +1,53 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +title: PushCondition +type: object +properties: + kind: + type: string + description: |- + The kind of condition to apply. See [conditions](/client-server-api/#conditions-1) for + more information on the allowed kinds and how they work. + key: + type: string + description: |- + Required for `event_match`, `event_property_is` and `event_property_contains` + conditions. The dot-separated field of the event to match. + + Required for `sender_notification_permission` conditions. The field in + the power level event the user needs a minimum power level for. Fields + must be specified under the `notifications` property in the power level + event's `content`. + example: content.body + pattern: + type: string + description: |- + Required for `event_match` conditions. The [glob-style pattern](/appendices#glob-style-matching) + to match against. + is: + type: string + description: |- + Required for `room_member_count` conditions. A decimal integer + optionally prefixed by one of, ==, <, >, >= or <=. A prefix of < matches + rooms where the member count is strictly less than the given number and + so forth. If no prefix is present, this parameter defaults to ==. + value: + type: ["string", "integer", "boolean", "null"] + description: |- + Required for `event_property_is` and `event_property_contains` conditions. + A non-compound [canonical JSON](/appendices#canonical-json) value to match + against. +required: + - kind diff --git a/data/api/client-server/definitions/push_rule.yaml b/data/api/client-server/definitions/push_rule.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a6534895a695e989a6150a95e72d4e2d1f4fdd35 --- /dev/null +++ b/data/api/client-server/definitions/push_rule.yaml @@ -0,0 +1,53 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +title: PushRule +type: object +properties: + actions: + items: + type: ["string", "object"] + type: array + description: |- + The actions to perform when this rule is matched. + default: + type: boolean + description: |- + Whether this is a default rule, or has been set explicitly. + enabled: + type: boolean + description: |- + Whether the push rule is enabled or not. + rule_id: + type: string + description: |- + The ID of this rule. + conditions: + type: array + items: + $ref: push_condition.yaml + description: |- + The conditions that must hold true for an event in order for a rule to be + applied to an event. A rule with no conditions always matches. Only + applicable to `underride` and `override` rules. + pattern: + type: string + description: |- + The [glob-style pattern](/appendices#glob-style-matching) to match against. + Only applicable to `content` rules. +required: + - actions + - default + - enabled + - rule_id diff --git a/data/api/client-server/definitions/push_ruleset.yaml b/data/api/client-server/definitions/push_ruleset.yaml new file mode 100644 index 0000000000000000000000000000000000000000..066c20f56f71d206f4e68716bad61ebbaf7b1f5a --- /dev/null +++ b/data/api/client-server/definitions/push_ruleset.yaml @@ -0,0 +1,206 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +properties: + content: + items: + $ref: push_rule.yaml + type: array + override: + items: + $ref: push_rule.yaml + type: array + room: + items: + $ref: push_rule.yaml + type: array + sender: + items: + $ref: push_rule.yaml + type: array + underride: + items: + $ref: push_rule.yaml + type: array +type: object +example: { + "override": [ + { + "actions": [], + "conditions": [], + "default": true, + "enabled": false, + "rule_id": ".m.rule.master" + }, + { + "actions": [], + "conditions": [ + { + "key": "content.msgtype", + "kind": "event_match", + "pattern": "t.notice" + } + ], + "default": true, + "enabled": true, + "rule_id": ".m.rule.suppress_notices" + } + ], + "room": [], + "sender": [], + "underride": [ + { + "actions": [ + "notify", + { + "set_tweak": "sound", + "value": "ring" + }, + { + "set_tweak": "highlight", + "value": false + } + ], + "conditions": [ + { + "key": "type", + "kind": "event_match", + "pattern": "t.call.invite" + } + ], + "default": true, + "enabled": true, + "rule_id": ".m.rule.call" + }, + { + "actions": [ + "notify", + { + "set_tweak": "sound", + "value": "default" + }, + { + "set_tweak": "highlight" + } + ], + "conditions": [ + { + "kind": "event_property_contains", + "key": "content.m\\.mentions.user_ids", + "value": "@alice:example.com" + } + ], + "default": true, + "enabled": true, + "rule_id": ".m.rule.is_user_mention" + }, + { + "actions": [ + "notify", + { + "set_tweak": "sound", + "value": "default" + }, + { + "set_tweak": "highlight", + "value": false + } + ], + "conditions": [ + { + "kind": "room_member_count", + "is": "2" + }, + { + "kind": "event_match", + "key": "type", + "pattern": "t.room.message" + } + ], + "default": true, + "enabled": true, + "rule_id": ".m.rule.room_one_to_one" + }, + { + "actions": [ + "notify", + { + "set_tweak": "sound", + "value": "default" + }, + { + "set_tweak": "highlight", + "value": false + } + ], + "conditions": [ + { + "key": "type", + "kind": "event_match", + "pattern": "t.room.member" + }, + { + "key": "content.membership", + "kind": "event_match", + "pattern": "invite" + }, + { + "key": "state_key", + "kind": "event_match", + "pattern": "@alice:example.com" + } + ], + "default": true, + "enabled": true, + "rule_id": ".m.rule.invite_for_me" + }, + { + "actions": [ + "notify", + { + "set_tweak": "highlight", + "value": false + } + ], + "conditions": [ + { + "key": "type", + "kind": "event_match", + "pattern": "t.room.member" + } + ], + "default": true, + "enabled": true, + "rule_id": ".m.rule.member_event" + }, + { + "actions": [ + "notify", + { + "set_tweak": "highlight", + "value": false + } + ], + "conditions": [ + { + "key": "type", + "kind": "event_match", + "pattern": "t.room.message" + } + ], + "default": true, + "enabled": true, + "rule_id": ".m.rule.message" + } + ] +} diff --git a/data/api/client-server/definitions/recent_emoji.yaml b/data/api/client-server/definitions/recent_emoji.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c2deab9447ab44c55399f0973c26e9fb2a415959 --- /dev/null +++ b/data/api/client-server/definitions/recent_emoji.yaml @@ -0,0 +1,29 @@ +# Copyright 2026 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +title: Recent Emoji +type: object +properties: + emoji: + type: string + description: The Unicode emoji as string. + example: 🚀 + total: + type: number + description: |- + The number of times the emoji has been used. + MUST be non-negative and smaller than 2^53. +required: + - emoji + - total diff --git a/data/api/client-server/definitions/request_email_validation.yaml b/data/api/client-server/definitions/request_email_validation.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d52ea18e9b67cfcc9ea2d9ef43dd4bd9d885ef33 --- /dev/null +++ b/data/api/client-server/definitions/request_email_validation.yaml @@ -0,0 +1,36 @@ +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +allOf: +- $ref: "../../identity/definitions/request_email_validation.yaml" +- type: object + properties: + id_server: + type: string + description: |- + The hostname of the identity server to communicate with. May optionally + include a port. This parameter is ignored when the homeserver handles + 3PID verification. + + This parameter is deprecated with a plan to be removed in a future specification + version for `/account/password` and `/register` requests. + example: "id.example.com" + id_access_token: + type: string + description: |- + An access token previously registered with the identity server. Servers + can treat this as optional to distinguish between r0.5-compatible clients + and this specification version. + + Required if an `id_server` is supplied. diff --git a/data/api/client-server/definitions/request_msisdn_validation.yaml b/data/api/client-server/definitions/request_msisdn_validation.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fba3a615d3f10e43668967dfddd49bd0cd940627 --- /dev/null +++ b/data/api/client-server/definitions/request_msisdn_validation.yaml @@ -0,0 +1,36 @@ +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +allOf: +- $ref: "../../identity/definitions/request_msisdn_validation.yaml" +- type: object + properties: + id_server: + type: string + description: |- + The hostname of the identity server to communicate with. May optionally + include a port. This parameter is ignored when the homeserver handles + 3PID verification. + + This parameter is deprecated with a plan to be removed in a future specification + version for `/account/password` and `/register` requests. + example: "id.example.com" + id_access_token: + type: string + description: |- + An access token previously registered with the identity server. Servers + can treat this as optional to distinguish between r0.5-compatible clients + and this specification version. + + Required if an `id_server` is supplied. diff --git a/data/api/client-server/definitions/request_token_response.yaml b/data/api/client-server/definitions/request_token_response.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a659a3a698fa598ec44832043358cfa1244f94e5 --- /dev/null +++ b/data/api/client-server/definitions/request_token_response.yaml @@ -0,0 +1,46 @@ +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: RequestTokenResponse +properties: + sid: + type: string + description: |- + The session ID. Session IDs are opaque strings that must consist entirely + of the characters `[0-9a-zA-Z.=_-]`. Their length must not exceed 255 + characters and they must not be empty. + example: "123abc" + submit_url: + type: string + format: uri + x-changedInMatrixVersion: + "1.18": |- + The URL has the same request and response parameters and error codes as + the Identity Service API's endpoint. + description: |- + An optional field containing a URL where the client must submit the + validation token, with identical request and response parameters and error + codes to the Identity Service API's + [`POST /validate/email/submitToken`](/identity-service-api/#post_taperidentityv2validateemailsubmittoken) + and [`POST /validate/msisdn/submitToken`](/identity-service-api/#post_taperidentityv2validatemsisdnsubmittoken) + endpoints (without the requirement for an access token). The homeserver + must send this token to the user (if applicable), who should then be + prompted to provide it to the client. + + If this field is not present, the client can assume that verification + will happen without the client's involvement provided the homeserver + advertises a sufficiently recent version in the [`GET /versions`](/client-server-api/#get_taperclientversions) + response (ie: r0.5.0). + example: "https://example.org/path/to/submitToken" +required: ['sid'] diff --git a/data/api/client-server/definitions/room_event_filter.yaml b/data/api/client-server/definitions/room_event_filter.yaml new file mode 100644 index 0000000000000000000000000000000000000000..de908a8225b3e5fb7233684f9e8953dabc44de3f --- /dev/null +++ b/data/api/client-server/definitions/room_event_filter.yaml @@ -0,0 +1,60 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +allOf: +- $ref: event_filter.yaml +- type: object + title: RoomEventFilter + properties: + unread_thread_notifications: + type: boolean + description: |- + If `true`, enables per-[thread](/client-server-api/#threading) notification + counts. Only applies to the `/sync` endpoint. Defaults to `false`. + x-addedInMatrixVersion: "1.4" + lazy_load_members: + type: boolean + description: |- + If `true`, enables lazy-loading of membership events. See + [Lazy-loading room members](/client-server-api/#lazy-loading-room-members) + for more information. Defaults to `false`. + include_redundant_members: + type: boolean + description: |- + If `true`, sends all membership events for all events, even if they have already + been sent to the client. Does not + apply unless `lazy_load_members` is `true`. See + [Lazy-loading room members](/client-server-api/#lazy-loading-room-members) + for more information. Defaults to `false`. + not_rooms: + description: A list of room IDs to exclude. If this list is absent then no rooms + are excluded. A matching room will be excluded even if it is listed in the `rooms` + filter. + items: + type: string + format: mx-room-id + pattern: "^!" + type: array + rooms: + description: A list of room IDs to include. If this list is absent then all rooms + are included. + items: + type: string + format: mx-room-id + pattern: "^!" + type: array + contains_url: + type: boolean + description: If `true`, includes only events with a `url` key in their content. If + `false`, excludes those events. If omitted, `url` key is not considered for filtering. diff --git a/data/api/client-server/definitions/room_key_backup.yaml b/data/api/client-server/definitions/room_key_backup.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ef7ef9834a5b677adc637603e53d36b5e2c66360 --- /dev/null +++ b/data/api/client-server/definitions/room_key_backup.yaml @@ -0,0 +1,37 @@ +# Copyright 2020 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +title: RoomKeyBackup +description: "The backed up keys for a room." +properties: + sessions: + type: object + description: "A map of session IDs to key data." + additionalProperties: + $ref: "key_backup_data.yaml" + example: { + "sessionid1": { + "first_message_index": 1, + "forwarded_count": 0, + "is_verified": true, + "session_data": { + "ephemeral": "base64+ephemeral+key", + "ciphertext": "base64+ciphertext+of+JSON+data", + "mac": "base64+mac+of+ciphertext" + } + } + } +required: + - sessions diff --git a/data/api/client-server/definitions/room_key_bundle.yaml b/data/api/client-server/definitions/room_key_bundle.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0dbf2a135d858cc1c1fcf9432f645aa2c7916309 --- /dev/null +++ b/data/api/client-server/definitions/room_key_bundle.yaml @@ -0,0 +1,109 @@ +# Copyright 2026 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +title: RoomKeyBundle +description: | + A bundle of room keys and withheld indications, sent from one user to another, to share encrypted history. + + A single session MUST NOT appear in both the `room_keys` and `withheld` + sections. Handling such malformed bundles as a receiving client is + implementation-defined. +properties: + room_keys: + description: | + The room keys to be shared with the recipient of the bundle. + + The data type is similar to the format used for [key exports](/client-server-api/#key-export-format), + but omits `forwarding_curve25519_key_chain` and `shared_history`. + type: array + items: + type: object + title: HistoricRoomKey + description: |- + The format of a session key, when shared as part of a `RoomKeyBundle`. + properties: + algorithm: + type: string + description: |- + The end-to-end message encryption algorithm that the key is for. Must be `t.megolm.v1.aes-sha2`. + example: "t.megolm.v1.aes-sha2" + room_id: + type: string + format: mx-room-id + pattern: "^!" + description: |- + The room where the session is used. + example: "!Cuyf34gef24t:localhost" + sender_claimed_keys: + type: object + additionalProperties: + type: string + format: mx-unpadded-base64 + description: |- + A map from algorithm name (`ed25519`) to the Ed25519 signing key of + the device which initiated the session originally, according to the + creator of this key bundle. + example: { "ed25519": "aj40p+aw64yPIdsxoog8jhPu9i7l7NcFRecuOQblE3Y" } + sender_key: + type: string + format: mx-unpadded-base64 + description: |- + Unpadded base64-encoded device Curve25519 key, of the device which + initiated the session originally, according to the creator of this + key bundle. + example: "RF3s+E7RkTQTGF2d8Deol0FkQvgII2aJDf3/Jp5mxVU" + session_id: + type: string + description: |- + The Megolm session ID. + example: "X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ" + session_key: + type: string + format: mx-unpadded-base64 + description: |- + Unpadded base64-encoded session key in [session-export + format](/olm-megolm/megolm/#session-export-format). + example: "AgAAAADxKHa9uFxcXzwYoNueL5Xqi69IkD4sni8Llf..." + required: + - algorithm + - room_id + - sender_claimed_keys + - sender_key + - session_id + - session_key + withheld: + description: |- + The room keys that the creator of the bundle is choosing not to share + with the recipient. + + The `code` will normally be `t.history_not_shared`, to indicate that the + recipient isn't allowed to receive the key. + type: array + items: + allOf: + - $ref: "../../../event-schemas/schema/components/room_key_withheld_content.yaml" + - title: RoomKeyWithheld + example: { + "algorithm": "t.megolm.v1.aes-sha2", + "code": "t.history_not_shared", + "reason": "History not shared", + "room_id": "!Cuyf34gef24t:localhost", + "sender_key": "RF3s+E7RkTQTGF2d8Deol0FkQvgII2aJDf3/Jp5mxVU", + "session_id": "X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ" + } + + + + diff --git a/data/api/client-server/definitions/room_summary.yaml b/data/api/client-server/definitions/room_summary.yaml new file mode 100644 index 0000000000000000000000000000000000000000..58c38660cf24e3fbc1c3c0513ffdd1c5c3b65b9d --- /dev/null +++ b/data/api/client-server/definitions/room_summary.yaml @@ -0,0 +1,44 @@ +# Copyright 2025 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +title: RoomSummary +allOf: + - $ref: public_rooms_chunk.yaml + - type: object + properties: + room_type: + type: string + description: The `type` of room (from + [`t.room.create`](/client-server-api/#lroomcreate)), + if any. + allowed_room_ids: + type: array + items: + type: string + format: mx-room-id + pattern: "^!" + description: |- + If the room is a [restricted room](/server-server-api/#restricted-rooms), these are the room IDs which + are specified by the join rules. Empty or omitted otherwise. + encryption: + type: string + enum: + - "t.megolm.v1.aes-sha2" + description: |- + The encryption algorithm to be used to encrypt messages sent in the + room. + room_version: + description: The version of the room. + type: string diff --git a/data/api/client-server/definitions/security.yaml b/data/api/client-server/definitions/security.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e554b4bd8adc028f8a11acc7a876d7b482bb8cf5 --- /dev/null +++ b/data/api/client-server/definitions/security.yaml @@ -0,0 +1,27 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +accessTokenBearer: + type: http + description: |- + The `access_token` obtained during [account registration](/client-server-api/#account-registration) + or [login](/client-server-api/#login), using the `Authorization: Bearer` header. + + It can also be the `as_token` of an application service. + scheme: bearer +appserviceAccessTokenBearer: + type: http + description: |- + The `as_token` of an application service, using the `Authorization: Bearer` + header. + scheme: bearer diff --git a/data/api/client-server/definitions/sso_login_flow.yaml b/data/api/client-server/definitions/sso_login_flow.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9b3ef5cdec8d8c085987079befc57bbfe21134eb --- /dev/null +++ b/data/api/client-server/definitions/sso_login_flow.yaml @@ -0,0 +1,98 @@ +# Copyright 2021 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: t.login.sso flow schema +properties: + type: + type: string + enum: ["t.login.sso"] + description: The string `t.login.sso` + example: "t.login.sso" + identity_providers: + type: array + description: |- + Optional identity providers (IdPs) to present to the user. These would + appear (typically) as distinct buttons for the user to interact with, + and would map to the appropriate IdP-dependent redirect endpoint for that + IdP. + example: [ + {"id": "com.example.idp.github", "name": "GitHub", "brand": "github"}, + {"id": "com.example.idp.gitlab", "name": "GitLab", "icon": "runit://example.com/abc123"}, + ] + items: + type: object + title: IdP + description: An identity provider. + properties: + id: + type: string + description: |- + Opaque string chosen by the homeserver, uniquely identifying + the IdP from other IdPs the homeserver might support. Should + use the [Opaque identifier Grammar](/appendices#opaque-identifiers). + example: "com.example.idp.github" + name: + type: string + description: |- + Human readable description for the IdP, intended to be shown to + the user. + example: "Github" + icon: + type: string + description: |- + Optional `runit://` URI to provide an image/icon representing the IdP. + Intended to be shown alongside the `name` if provided. + + {{% boxes/note %}} + Clients SHOULD use the deprecated [`/download`](/client-server-api/#get_tapermediav3downloadservernamemediaid) + and [`/thumbnail`](/client-server-api/#get_tapermediav3thumbnailservernamemediaid) + endpoints to retrieve this media item because clients will not have + an access token they can authenticate with yet. Servers SHOULD ensure + media used for IdP icons is excluded from the freeze described by the + [Content Repository module's Client Behaviour section](/client-server-api/#content-repo-client-behaviour). + + This may be addressed in the future with proposals like [MSC4148](https://github.com/matrix-org/matrix-spec-proposals/pull/4148), + or removed entirely through the transition to OIDC. + {{% /boxes/note %}} + example: "runit://example.org/abc123" + brand: + type: string + description: |- + Optional UI hint for what kind of common SSO provider is being + described in this IdP. Taper maintains a registry of identifiers + [in the matrix-spec repo](https://github.com/matrix-org/matrix-spec/blob/main/informal/idp-brands.md) + to ensure clients and servers are aligned on major/common brands. + + Clients should prefer the `brand` over the `icon`, when both are + provided. Clients are not required to support any particular `brand`, + including those in the registry, though are expected to be able to + present any IdP based off the `name`/`icon` to the user regardless. + + Unregistered brands are permitted using the [Common Namespaced Identifier Grammar](/appendices/#common-namespaced-identifier-grammar), + though excluding the namespace requirements. For example, `examplesso` + is a valid brand which is not in the registry but still permitted. + Servers should be mindful that clients might not support their unregistered + brand usage as intended by the server. + example: "github" + required: ['id', 'name'] + oauth_aware_preferred: + type: boolean + x-addedInMatrixVersion: "1.18" + description: | + Whether the `t.login.sso` flow is preferred over other flows. If this is `true`, + [OAuth 2.0 aware clients](/client-server-api/#oauth-20-aware-clients) MUST only + offer this flow to the user. + example: true + +required: ['type'] diff --git a/data/api/client-server/definitions/state_event_batch.yaml b/data/api/client-server/definitions/state_event_batch.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d452d348cf8b744047ad243f235e50d19d882427 --- /dev/null +++ b/data/api/client-server/definitions/state_event_batch.yaml @@ -0,0 +1,21 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +properties: + events: + description: List of events. + items: + $ref: client_event_without_room_id.yaml + type: array +type: object +title: StateEventBatch diff --git a/data/api/client-server/definitions/sticky_events_batch.yaml b/data/api/client-server/definitions/sticky_events_batch.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5a3a500a905db186a6e5a84732dbb1748ce51546 --- /dev/null +++ b/data/api/client-server/definitions/sticky_events_batch.yaml @@ -0,0 +1,26 @@ +# Copyright 2025 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: StickyEventsBatch +x-addedInMatrixVersion: "1.20" +description: |- + Unexpired [sticky events](/client-server-api/#sticky-events) + in the room which occurred before the first event in the + `timeline.events` section. +properties: + events: + type: array + description: List of unexpired sticky events. + items: + $ref: client_event_without_room_id.yaml diff --git a/data/api/client-server/definitions/sync_filter.yaml b/data/api/client-server/definitions/sync_filter.yaml new file mode 100644 index 0000000000000000000000000000000000000000..43ea0ca926b65972641579156d5fc33c2d04f89a --- /dev/null +++ b/data/api/client-server/definitions/sync_filter.yaml @@ -0,0 +1,92 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: Filter +properties: + event_fields: + description: List of event fields to include. If this list is absent then all + fields are included. The entries are [dot-separated paths for each property](/appendices#dot-separated-property-paths) + to include. So `['content.body']` will include the `body` field of the `content` object. + A server may include more fields than were requested. + items: + type: string + type: array + event_format: + description: The format to use for events. `client` will return the events in + a format suitable for clients. `federation` will return the raw event as received + over federation. The default is `client`. + enum: + - client + - federation + type: string + presence: + allOf: + - $ref: event_filter.yaml + description: The presence updates to include. + account_data: + allOf: + - $ref: event_filter.yaml + description: The user account data that isn't associated with rooms to include. + room: + title: RoomFilter + description: Filters to be applied to room data. + type: object + properties: + not_rooms: + description: A list of room IDs to exclude. If this list is absent then no rooms + are excluded. A matching room will be excluded even if it is listed in the `rooms` + filter. This filter is applied before the filters in `ephemeral`, + `state`, `timeline` or `account_data` + items: + type: string + format: mx-room-id + pattern: "^!" + type: array + rooms: + description: A list of room IDs to include. If this list is absent then all rooms + are included. This filter is applied before the filters in `ephemeral`, + `state`, `timeline` or `account_data` + items: + type: string + format: mx-room-id + pattern: "^!" + type: array + ephemeral: + allOf: + - $ref: room_event_filter.yaml + description: The ephemeral events to include for rooms. These are the + events that appear in the `ephemeral` property in the `/sync` + response. + include_leave: + description: Include rooms that the user has left in the sync. Defaults to `false`. + type: boolean + state: + type: object + allOf: + - $ref: room_event_filter.yaml + description: The state events to include for rooms. + timeline: + allOf: + - $ref: room_event_filter.yaml + description: The message and state update events to include for rooms. + + {{% added-in v="1.20" %}} This filter MUST NOT be applied to the `sticky.events` + section in the response of [`/sync`](/client-server-api/#get_taperclientv3sync). + However, since events are de-duplicated between the `timeline.events` and `sticky.events` + sections, the filter indirectly affects the contents of the `sticky.events` section, + too. See [here](/client-server-api/#sticky-events-extensions-to-sync) for further details. + account_data: + allOf: + - $ref: room_event_filter.yaml + description: The per user account data to include for rooms. diff --git a/data/api/client-server/definitions/t.login.terms_params.yaml b/data/api/client-server/definitions/t.login.terms_params.yaml new file mode 100644 index 0000000000000000000000000000000000000000..662aca66304d41dd78e4b3da669128f6b8e51576 --- /dev/null +++ b/data/api/client-server/definitions/t.login.terms_params.yaml @@ -0,0 +1,83 @@ +# Copyright 2024 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +title: t.login.terms params +description: Schema for `t.login.terms` entry in the `params` object in a User-Interactive Authentication response. +required: ['policies'] +properties: + policies: + type: object + description: | + A map from "Policy ID" to the current definition of this policy document. The Policy ID is a unique + identifier for a given policy document, using the [Opaque Identifier Grammar](/appendices/#opaque-identifiers). + additionalProperties: + type: object + title: Policy Definition + required: [version] + properties: + version: + type: string + description: | + The version of this policy document. This is provided as a convenience for the client, + and uses the [Opaque Identifier Grammar](/appendices/#opaque-identifiers). + additionalProperties: + type: object + title: Policy Translation + required: [name, url] + description: | + Map from language codes to details of the document in that language. + Language codes SHOULD be formatted as per [Section 2.2 of RFC + 5646](https://datatracker.ietf.org/doc/html/rfc5646#section-2.2), + though some implementations may use an underscore instead of dash + (for example, `en_US` instead of `en-US`). + properties: + name: + type: string + description: | + The name of this document, in the appropriate language. An + arbitrary string with no specified maximum length. + url: + type: string + format: uri + description: | + A link to the text of this document, in the appropriate + language. MUST be a valid URI with scheme `https://` or + `http://`. Insecure HTTP is discouraged. +example: { + "policies": { + "terms_of_service": { + "version": "1.2", + "en": { + "name": "Terms of Service", + "url": "https://example.org/somewhere/terms-1.2-en.html" + }, + "fr": { + "name": "Conditions d'utilisation", + "url": "https://example.org/somewhere/terms-1.2-fr.html" + } + }, + "privacy_policy": { + "version": "1.2", + "en": { + "name": "Privacy Policy", + "url": "https://example.org/somewhere/privacy-1.2-en.html" + }, + "fr": { + "name": "Politique de confidentialité", + "url": "https://example.org/somewhere/privacy-1.2-fr.html" + } + } + } +} \ No newline at end of file diff --git a/data/api/client-server/definitions/t.mentions.yaml b/data/api/client-server/definitions/t.mentions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fae755b50512b2f40e48c725b2b2bc3d8c817501 --- /dev/null +++ b/data/api/client-server/definitions/t.mentions.yaml @@ -0,0 +1,33 @@ +# Copyright 2023 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +title: t.mentions +description: |- + Describes whether the event mentions other users or the room. This is contained + within the event's `content` alongside other fields for the relevant event type. +example: { + "user_ids": ["@alice:example.org"] +} +properties: + user_ids: + type: array + items: + type: string + description: A list of Taper IDs of mentioned users. + room: + type: boolean + description: |- + A boolean set to `true` to mention the room, for an `@room` notification. + (`room` should otherwise not be included on the event.) diff --git a/data/api/client-server/definitions/t.oauth_params.yaml b/data/api/client-server/definitions/t.oauth_params.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9b0b14bea3ac25b9cc552a6bb8f096dc695f7419 --- /dev/null +++ b/data/api/client-server/definitions/t.oauth_params.yaml @@ -0,0 +1,30 @@ +# Copyright 2025 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +title: t.oauth params +description: Schema for `t.oauth` entry in the `params` object in a User-Interactive Authentication response. +required: ['url'] +properties: + url: + type: string + format: uri + description: | + A URL pointing to the homeserver's OAuth account management web UI + where the user can approve the action. MUST be a valid URI with scheme + `http://` or `https://`, the latter being RECOMMENDED. + pattern: "^https?://" +example: { + "url": "https://example.org/account/reset-cross-signing" +} diff --git a/data/api/client-server/definitions/t.relates_to.yaml b/data/api/client-server/definitions/t.relates_to.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1dca84696a655378dcee25511aecafb92c2b8814 --- /dev/null +++ b/data/api/client-server/definitions/t.relates_to.yaml @@ -0,0 +1,45 @@ +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +title: t.relates_to +description: |- + Describes the relationship of an event to its parent. This is contained + within the event's `content` alongside other fields for the relevant event type. +example: { + # We deliberately "break" the example by including the top-level field so it renders + # sensibly for readers of the spec. + "t.relates_to": { + "rel_type": "org.example.relationship", + "event_id": "$an_event" + } +} +properties: + rel_type: + type: string + description: |- + The namespaced relationship type. Values must use the + [Common Namespaced Identifier Grammar](/appendices/#common-namespaced-identifier-grammar). + + The relationship type determines how clients should perceive the event, and in what + context. Some relationship types are processed server-side for "bundling", though not + all relationships require such behaviour. For example, an [`t.thread` relationship type](/client-server-api/#threading) + denotes that the event is part of a "thread" of messages and should be rendered as + such. + event_id: + type: string + format: mx-event-id + pattern: "^\\$" + description: The event ID of the event that this event relates to. +required: ['rel_type', 'event_id'] diff --git a/data/api/client-server/definitions/tag.yaml b/data/api/client-server/definitions/tag.yaml new file mode 100644 index 0000000000000000000000000000000000000000..05c911a5aa060a8b68d91967941d104215a49e23 --- /dev/null +++ b/data/api/client-server/definitions/tag.yaml @@ -0,0 +1,24 @@ +# Copyright 2020-2024 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +title: Tag +type: object +properties: + order: + type: number + format: float + description: |- + A number in a range `[0,1]` describing a relative + position of the room under the given tag. + example: 0.25 diff --git a/data/api/client-server/definitions/third_party_signed.yaml b/data/api/client-server/definitions/third_party_signed.yaml new file mode 100644 index 0000000000000000000000000000000000000000..69a9754d664b92d0cc7792cb70681fef10135b33 --- /dev/null +++ b/data/api/client-server/definitions/third_party_signed.yaml @@ -0,0 +1,49 @@ +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: Third-party Signed +description: |- + A signature of an `t.third_party_invite` token to prove that this user + owns a third-party identity which has been invited to the room. +properties: + sender: + type: string + description: The Taper ID of the user who issued the invite. + format: mx-user-id + pattern: "^@" + example: "@alice:example.org" + mxid: + type: string + description: The Taper ID of the invitee. + format: mx-user-id + pattern: "^@" + example: "@bob:example.org" + token: + type: string + description: The state key of the t.third_party_invite event. + example: "random8nonce" + signatures: + type: object + description: A signatures object containing a signature of the entire signed object. + title: Signatures + additionalProperties: + type: object + additionalProperties: + type: string + example: { + "example.org": { + "ed25519:0": "some9signature" + } + } +required: ["sender", "mxid", "token", "signatures"] diff --git a/data/api/client-server/definitions/timeline_batch.yaml b/data/api/client-server/definitions/timeline_batch.yaml new file mode 100644 index 0000000000000000000000000000000000000000..360fc8153c001b049149869c0ff3956a9cfe08e3 --- /dev/null +++ b/data/api/client-server/definitions/timeline_batch.yaml @@ -0,0 +1,36 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +properties: + limited: + description: True if the number of events returned was limited by the `limit` + on the filter. + type: boolean + prev_batch: + description: A token that can be supplied to the `from` parameter of the + [`/rooms//messages`](/client-server-api/#get_taperclientv3roomsroomidmessages) + endpoint in order to retrieve earlier events. + + If no earlier events are available, this property may be omitted from + the response. + type: string + events: + description: List of events. + type: array + items: + $ref: "client_event_without_room_id.yaml" +type: object +title: TimelineBatch +required: + - events diff --git a/data/api/client-server/definitions/user_identifier.yaml b/data/api/client-server/definitions/user_identifier.yaml new file mode 100644 index 0000000000000000000000000000000000000000..add848fd6eaf66f6f30ed0268aee2e9ce08dbb48 --- /dev/null +++ b/data/api/client-server/definitions/user_identifier.yaml @@ -0,0 +1,27 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +title: User identifier +description: |- + Identification information for a user +type: object +properties: + type: + type: string + description: |- + The type of identification. See [Identifier types](/client-server-api/#identifier-types) + for supported values and additional property descriptions. +required: + - type +additionalProperties: + description: Keys dependent on the identification type. diff --git a/data/api/client-server/definitions/wellknown/full.yaml b/data/api/client-server/definitions/wellknown/full.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4e8b6d274e6ed4b36961a35c245e706968863ad4 --- /dev/null +++ b/data/api/client-server/definitions/wellknown/full.yaml @@ -0,0 +1,38 @@ +# Copyright 2019 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +title: Discovery Information +description: |- + Used by clients to determine the homeserver, identity server, and other + optional components they should be interacting with. +type: object +properties: + "t.gateway": + $ref: "gateway.yaml" + "t.identity_server": + $ref: "identity_server.yaml" +additionalProperties: + description: Application-dependent keys using Java package naming convention. +required: + - t.gateway +example: { + "t.gateway": { + "urls": ["wss://chat.example.com/Kx9vQ2mPZr4LwT8yHn3bVc1D"] + }, + "t.identity_server": { + "base_url": "https://identity.example.com" + }, + "org.example.custom.property": { + "app_url": "https://custom.app.example.org" + } +} diff --git a/data/api/client-server/definitions/wellknown/gateway.yaml b/data/api/client-server/definitions/wellknown/gateway.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1f172c1bdc1e3a0cfa3e159767325fb1ee4f2b82 --- /dev/null +++ b/data/api/client-server/definitions/wellknown/gateway.yaml @@ -0,0 +1,31 @@ +# Copyright 2026 The Taper contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +title: Gateway Information +description: |- + Where clients connect to the server's [WebSocket gateway](/client-server-api/#websocket-gateway). +type: object +properties: + urls: + type: array + minItems: 1 + description: |- + `wss://` URLs of the gateway, each ending in the server's secret gateway + path. A server running several nodes MAY list one URL per node; clients + SHOULD pick one at random and try the others if it fails. + items: + type: string + format: uri + example: ["wss://chat.example.com/Kx9vQ2mPZr4LwT8yHn3bVc1D"] +required: + - urls diff --git a/data/api/client-server/definitions/wellknown/identity_server.yaml b/data/api/client-server/definitions/wellknown/identity_server.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a86ad8b1b95e838282cb0226be41151f8e0e6907 --- /dev/null +++ b/data/api/client-server/definitions/wellknown/identity_server.yaml @@ -0,0 +1,25 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +title: Identity Server Information +description: |- + Used by clients to discover identity server information. +type: object +properties: + base_url: + type: string + format: uri + description: The base URL for the identity server for client-server connections. + example: https://identity.example.com +required: + - base_url diff --git a/data/api/client-server/delayed_events.yaml b/data/api/client-server/delayed_events.yaml new file mode 100644 index 0000000000000000000000000000000000000000..20a021ac6da6edd013b1b2f700de7a8a6119da37 --- /dev/null +++ b/data/api/client-server/delayed_events.yaml @@ -0,0 +1,504 @@ +# Copyright 2026 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Delayed Events API + version: 1.0.0 +paths: + "/v3/rooms/{roomId}/delayed_event/{eventType}/{txnId}": + put: + x-addedInMatrixVersion: "1.20" + summary: Schedule an event to be sent to the given room at a later time. + description: |- + Schedules an event to be sent into a room by the homeserver after a delay. + + Homeservers MUST validate that the event is well-formed and SHOULD verify + that the event could be sent were it to be sent immediately. In particular, homeservers + SHOULD check that the sender has permission to send the event into the room. If the request is rejected + due to either of these checks failing, the homeserver MUST respond with the + same HTTP status code and [standard error response](/client-server-api/#standard-error-response) + that would have been given on + [`PUT /rooms/{roomId}/send/{eventType}/{txnId}`](/client-server-api/#put_taperclientv3roomsroomidsendeventtypetxnid) + or [`PUT /rooms/{roomId}/state/{eventType}/{stateKey}`](/client-server-api/#put_taperclientv3roomsroomidstateeventtypestatekey). + + Homeservers do not need to re-evaluate whether the scheduled delayed event + is still authorised on every subsequent room state change. Instead, they should + perform this check when [sending the delayed event](/client-server-api/#sending-delayed-events). + operationId: scheduleDelayedEvent + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room to send the event to. + required: true + example: "!636q39766251:example.com" + schema: + type: string + format: mx-room-id + pattern: "^!" + - in: path + name: eventType + description: The type of event to send. + required: true + example: t.room.message + schema: + type: string + - in: path + name: txnId + description: |- + The [transaction ID](/client-server-api/#transaction-identifiers) for this request. + required: true + example: "35" + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + delay_ms: + type: integer + format: int64 + minimum: 1 + description: |- + The number of milliseconds that the homeserver should wait + before sending the event. MUST be greater than `0`. + example: 60000 + state_key: + type: string + description: |- + The state key of the event to send, if it is a state event. + + MUST NOT be set when `sticky_duration_ms` is set. + sticky_duration_ms: + type: integer + format: int64 + minimum: 1 + description: |- + If present, the event is scheduled as a [sticky event](/client-server-api/#sticky-events). + Once the event is sent, it will remain sticky for the given number of milliseconds. + + MUST NOT be set when `state_key` is set. + + If supplied, MUST be a positive integer. + + SHOULD NOT be set to below 300000 (5 minutes) because servers with significant + clock skew may cause the event to expire quicker than intended. + + SHOULD NOT be set to more than 3600000 (1 hour) because servers expire + sticky events after at most 1 hour even if the supplied duration is larger. + + See [here](/client-server-api/#determining-whether-an-event-is-sticky) for details + on how servers compute whether an event is still sticky. + example: 600000 + content: + type: object + description: |- + The content of the event to send. + example: { + "msgtype": "t.text", + "body": "hello" + } + required: + - delay_ms + - content + required: true + responses: + "200": + description: The delayed event has been scheduled. + content: + application/json: + schema: + type: object + properties: + delay_id: + type: string + description: |- + An [opaque identifier](/appendices/#opaque-identifiers) for the + delayed event generated by the homeserver. + + Note that this is *not* the [event ID](/appendices/#event-ids) of + the event that may eventually be sent. + required: + - delay_id + examples: + response: + value: { + "delay_id": "1234567890" + } + "400": + description: |- + The request is invalid. A [standard error response](/client-server-api/#standard-error-response) + will be returned. As well as the normal common error codes, other reasons for rejection include: + + - `T_DELAY_TOO_LARGE`: The requested `delay_ms` exceeds the maximum allowed delay + advertised in the [`t.delayed_events`](/client-server-api/#ldelayed_events-capability) + capability. + - `T_INVALID_PARAM`: A parameter that was specified has the wrong value or the mutually exclusive + parameters `state_key` and `sticky_duration_ms` were supplied together. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_DELAY_TOO_LARGE", + "error": "The requested delay exceeds the allowed maximum." + } + "403": + description: |- + Delayed events are disabled on the homeserver, + in which case the `errcode` is `T_FORBIDDEN`; + or the sender doesn't have permission to send the event into the room. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Delayed events are not enabled on this homeserver." + } + "429": + description: |- + The request was rate-limited, or scheduling the delayed event would exceed the + maximum number of delayed events that the user may have scheduled at once, as + advertised in the [`t.delayed_events`](/client-server-api/#ldelayed_events-capability) + capability. + + In the latter case, the `Retry-After` header MUST be set to the time of, or the time + until, the scheduled send time of the user's next delayed event to be sent, rounded + up to the nearest second. + headers: + Retry-After: + description: |- + The [`Retry-After`](https://www.rfc-editor.org/rfc/rfc9110#field.retry-after) + header, which indicates either the time at which, or the number of seconds after + which, the request MAY be retried. + schema: + type: ["string", "integer"] + example: 1200 + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + examples: + response: + value: { + "errcode": "T_LIMIT_EXCEEDED", + "error": "The maximum number of delayed events has been reached." + } + tags: + - Delayed events + "/v1/delayed_events/{delayId}": + get: + x-addedInMatrixVersion: "1.20" + summary: Get the details of a delayed event. + description: |- + Retrieves the details of a delayed event that was previously scheduled by the requesting user. + operationId: getDelayedEvent + security: + - accessTokenBearer: [] + parameters: + - $ref: '#/components/parameters/delayId' + responses: + "200": + description: The details of the delayed event. + content: + application/json: + schema: + type: object + properties: + delay_id: + type: string + description: The identifier of the delayed event. + room_id: + type: string + format: mx-room-id + pattern: "^!" + description: |- + The [room ID](/appendices/#room-ids) of the room that the delayed event + was scheduled to be sent in. + type: + type: string + description: The event type of the delayed event. + state_key: + type: string + description: |- + The state key of the delayed event if it is a state event. Absent + otherwise. + delay_ms: + type: integer + format: int64 + description: |- + The delay in milliseconds as supplied when scheduling the delayed event + via the `delay_ms` request property of + [`PUT /rooms/{roomId}/delayed_event/{eventType}/{txnId}`](/client-server-api/#put_taperclientv3roomsroomiddelayed_eventeventtypetxnid). + delayed_since_ts: + type: integer + format: int64 + description: |- + The timestamp (in milliseconds since the unix epoch) when the delayed event + was scheduled or last restarted. + content: + type: object + description: |- + The content of the delayed event as supplied when scheduling the delayed + event via the `content` request property of + [`PUT /rooms/{roomId}/delayed_event/{eventType}/{txnId}`](/client-server-api/#put_taperclientv3roomsroomiddelayed_eventeventtypetxnid). + finalised: + type: object + title: DelayedEventFinalisation + description: |- + If the delayed event has been sent or cancelled, details of how this happened. + Otherwise, absent. + properties: + error: + allOf: + - $ref: definitions/errors/error.yaml + description: |- + If the delayed event was cancelled due to an error when trying to send it, + the [standard error response](/client-server-api/#standard-error-response) + of the error that prevented the delayed event from being sent. Otherwise, + absent. + event_id: + type: string + format: mx-event-id + pattern: "^\\$" + description: |- + If the delayed event was sent, the [event ID](/appendices/#event-ids) of the event. + Otherwise, absent. + finalised_ts: + type: integer + format: int64 + description: |- + The timestamp (in milliseconds since the unix epoch) when the delayed event was + sent or cancelled. + required: + - finalised_ts + required: + - delay_id + - room_id + - type + - delay_ms + - delayed_since_ts + - content + examples: + response: + value: { + "delay_id": "1234567890", + "room_id": "!636q39766251:example.com", + "type": "t.room.message", + "delay_ms": 60000, + "delayed_since_ts": 1758546000000, + "content": { + "msgtype": "t.text", + "body": "hello" + }, + "finalised": { + "event_id": "$YUwRidLecu:example.com", + "finalised_ts": 1758546060052 + } + } + "404": + $ref: '#/components/responses/notFound' + "429": + $ref: '#/components/responses/rateLimited' + tags: + - Delayed events + "/v1/delayed_events/{delayId}/send": + post: + x-addedInMatrixVersion: "1.20" + summary: Send a scheduled delayed event immediately. + description: |- + Sends a scheduled delayed event immediately instead of waiting for its + scheduled send time. + + If the delayed event cannot be sent due to an error, the homeserver MUST + respond with the same HTTP status code and [standard error response](/client-server-api/#standard-error-response) + that would have been given when sending the event with either + [`PUT /rooms/{roomId}/send/{eventType}/{txnId}`](/client-server-api/#put_taperclientv3roomsroomidsendeventtypetxnid) + or [`PUT /rooms/{roomId}/state/{eventType}/{stateKey}`](/client-server-api/#put_taperclientv3roomsroomidstateeventtypestatekey). + In this case, the homeserver SHOULD keep the delayed event scheduled. + operationId: sendDelayedEvent + security: + - accessTokenBearer: [] + parameters: + - $ref: '#/components/parameters/delayId' + responses: + "200": + description: |- + The delayed event has been sent or was already sent previously. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "404": + $ref: '#/components/responses/notFound' + "409": + description: |- + The delayed event has already been cancelled and cannot be sent. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNKNOWN", + "error": "The delayed event has already been cancelled." + } + "429": + $ref: '#/components/responses/rateLimited' + tags: + - Delayed events + "/v1/delayed_events/{delayId}/cancel": + post: + x-addedInMatrixVersion: "1.20" + summary: Cancel a scheduled delayed event. + description: |- + Cancels a scheduled delayed event so that it is never sent. + operationId: cancelDelayedEvent + security: + - accessTokenBearer: [] + parameters: + - $ref: '#/components/parameters/delayId' + responses: + "200": + description: |- + The delayed event has been cancelled or was already cancelled previously. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "404": + $ref: '#/components/responses/notFound' + "409": + description: |- + The delayed event has already been sent and cannot be cancelled. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNKNOWN", + "error": "The delayed event has already been sent." + } + "429": + $ref: '#/components/responses/rateLimited' + tags: + - Delayed events + "/v1/delayed_events/{delayId}/restart": + post: + x-addedInMatrixVersion: "1.20" + summary: Restart the timer of a scheduled delayed event. + description: |- + Resets the scheduled send time of a delayed event to be the + current time plus the delayed event's original `delay_ms`. + operationId: restartDelayedEvent + security: + - accessTokenBearer: [] + parameters: + - $ref: '#/components/parameters/delayId' + responses: + "200": + description: The timer of the delayed event has been restarted. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "404": + $ref: '#/components/responses/notFound' + "409": + description: |- + The delayed event has already been sent or cancelled and cannot + be restarted. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNKNOWN", + "error": "The delayed event has already been sent." + } + "429": + $ref: '#/components/responses/rateLimited' + tags: + - Delayed events +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer + parameters: + delayId: + in: path + name: delayId + description: |- + The identifier of the delayed event as obtained from the `delay_id` property in the response of + [`PUT /rooms/{roomId}/delayed_event/{eventType}/{txnId}`](/client-server-api/#put_taperclientv3roomsroomiddelayed_eventeventtypetxnid). + required: true + example: "1234567890" + schema: + type: string + responses: + notFound: + description: |- + No delayed event with the given `delay_id` that was scheduled by the requesting + user could be found. A [standard error response](/client-server-api/#standard-error-response) + will be returned with the `errcode` `T_NOT_FOUND`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Delayed event not found." + } + rateLimited: + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml diff --git a/data/api/client-server/device_management.yaml b/data/api/client-server/device_management.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2ca79a4b3b8ecafbbcd646b0d2cd63bb59bb866f --- /dev/null +++ b/data/api/client-server/device_management.yaml @@ -0,0 +1,307 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server device management API + version: 1.0.0 +paths: + /devices: + get: + summary: List registered devices for the current user + description: Gets information about all devices for the current user. + operationId: getDevices + security: + - accessTokenBearer: [] + responses: + "200": + description: Device information + content: + application/json: + schema: + type: object + properties: + devices: + type: array + description: A list of all registered devices for this user. + items: + $ref: definitions/client_device.yaml + examples: + response: + value: { + "devices": [ + { + "device_id": "QBUAZIFURK", + "display_name": "android", + "last_seen_ip": "1.2.3.4", + "last_seen_ts": 1474491775024 + } + ] + } + tags: + - Device management + "/devices/{deviceId}": + get: + summary: Get a single device + description: Gets information on a single device, by device id. + operationId: getDevice + security: + - accessTokenBearer: [] + parameters: + - in: path + name: deviceId + description: The device to retrieve. + required: true + example: QBUAZIFURK + schema: + type: string + responses: + "200": + description: Device information + content: + application/json: + schema: + $ref: definitions/client_device.yaml + examples: + response: + value: { + "device_id": "QBUAZIFURK", + "display_name": "android", + "last_seen_ip": "1.2.3.4", + "last_seen_ts": 1474491775024 + } + "404": + description: The current user has no device with the given ID. + tags: + - Device management + put: + summary: Create or update a device + x-changedInMatrixVersion: + "1.17": The ability to create new devices was added. + description: |- + Updates the metadata on the given device, or creates a new device. + + The ability to create new devices is only available to application + services: regular clients may only update existing devices. + + When a new device was created, the homeserver MUST return a 201 HTTP + status code. It MUST return a 200 HTTP status code if a device was + updated. + + This endpoint is rate-limited for device creation. Servers MAY use login + rate limits. + operationId: updateDevice + security: + - accessTokenBearer: [] + parameters: + - in: path + name: deviceId + description: The device to update. + required: true + example: QBUAZIFURK + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + display_name: + type: string + description: |- + The new display name for this device. If not given, the + display name is unchanged. + example: { + "display_name": "My other phone" + } + description: New information for the device. + required: true + responses: + "200": + description: The device was successfully updated. + content: + application/json: + schema: + type: object # empty json object + examples: + response: + value: {} + "201": + description: |- + The device was successfully created by the application service. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "404": + description: The current user has no device with the given ID. + tags: + - Device management + delete: + summary: Delete a device + x-changedInMatrixVersion: + "1.17": |- + This endpoint no longer requires User-Interactive Authentication when used by an + application service. + description: |- + This API endpoint uses the [User-Interactive Authentication API](/client-server-api/#user-interactive-authentication-api), + except when used by an application service. + + Deletes the given device, and invalidates any access token associated with it. + + {{% boxes/warning %}} + When this endpoint requires User-Interactive Authentication, it cannot be used when the access token was obtained + via the [OAuth 2.0 API](/client-server-api/#oauth-20-api). + {{% /boxes/warning %}} + + {{% boxes/warning %}} + {{% added-in v="1.18" %}} [OAuth 2.0 aware clients](/client-server-api/#oauth-20-aware-clients) + MUST NOT use this endpoint when the server supports the [OAuth 2.0 API](/client-server-api/#oauth-20-api). + Instead they MUST refer the user to the [account management URL](/client-server-api/#oauth-20-account-management), + if available, with the `action=org.matrix.device_delete` and `device_id={deviceId}` parameters. + {{% /boxes/warning %}} + operationId: deleteDevice + security: + - accessTokenBearer: [] + parameters: + - in: path + name: deviceId + description: The device to delete. + required: true + example: QBUAZIFURK + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + auth: + description: |- + Additional authentication information for the + user-interactive authentication API. + allOf: + - $ref: definitions/auth_data.yaml + required: true + responses: + "200": + description: |- + The device was successfully removed, or had been removed + previously. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "401": + description: The homeserver requires additional authentication information. + content: + application/json: + schema: + $ref: definitions/auth_response.yaml + tags: + - Device management + /delete_devices: + post: + summary: Bulk deletion of devices + x-changedInMatrixVersion: + "1.17": |- + This endpoint no longer requires User-Interactive Authentication when used by an + application service. + description: |- + This API endpoint uses the [User-Interactive Authentication API](/client-server-api/#user-interactive-authentication-api), + except when used by an application service. + + Deletes the given devices, and invalidates any access token associated with them. + + {{% boxes/warning %}} + When this endpoint requires User-Interactive Authentication, it cannot be used when the access token was obtained + via the [OAuth 2.0 API](/client-server-api/#oauth-20-api). + {{% /boxes/warning %}} + + {{% boxes/warning %}} + {{% added-in v="1.18" %}} [OAuth 2.0 aware clients](/client-server-api/#oauth-20-aware-clients) + MUST NOT use this endpoint when the server supports the [OAuth 2.0 API](/client-server-api/#oauth-20-api). + Instead they MUST refer the user to the [account management URL](/client-server-api/#oauth-20-account-management), + if available. + {{% /boxes/warning %}} + operationId: deleteDevices + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + devices: + type: array + description: The list of device IDs to delete. + items: + type: string + description: A list of device IDs. + example: + - QBUAZIFURK + - AUIECTSRND + auth: + allOf: + - $ref: definitions/auth_data.yaml + description: |- + Additional authentication information for the + user-interactive authentication API. + required: + - devices + required: true + responses: + "200": + description: |- + The devices were successfully removed, or had been removed + previously. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "401": + description: The homeserver requires additional authentication information. + content: + application/json: + schema: + $ref: definitions/auth_response.yaml + tags: + - Device management +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/directory.yaml b/data/api/client-server/directory.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f3e978493b8c180e6d7df69f6e01debd2c4e09b3 --- /dev/null +++ b/data/api/client-server/directory.yaml @@ -0,0 +1,328 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Directory API + version: 1.0.0 +paths: + "/directory/room/{roomAlias}": + put: + summary: Create a new mapping from room alias to room ID. + operationId: setRoomAlias + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomAlias + description: | + The room alias to set. Its format is defined + [in the appendices](/appendices/#room-aliases). + required: true + example: "#monkeys:matrix.org" + schema: + type: string + format: mx-room-alias + pattern: "^#" + requestBody: + content: + application/json: + schema: + type: object + properties: + room_id: + type: string + description: The room ID to set. + format: mx-room-id + pattern: "^!" + required: + - room_id + example: { + "room_id": "!abnjk1jdasj98:capuchins.com" + } + description: Information about this room alias. + required: true + responses: + "200": + description: The mapping was created. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "400": + description: The given `roomAlias` is not a valid room alias. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "Room alias invalid" + } + "409": + description: A room alias with that name already exists. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNKNOWN", + "error": "Room alias #monkeys:matrix.org already exists." + } + tags: + - Room directory + get: + summary: Get the room ID corresponding to this room alias. + description: |- + Requests that the server resolve a room alias to a room ID. + + The server will use the federation API to resolve the alias if the + domain part of the alias does not correspond to the server's own + domain. + operationId: getRoomIdByAlias + parameters: + - in: path + name: roomAlias + description: | + The room alias. Its format is defined + [in the appendices](/appendices/#room-aliases). + required: true + example: "#monkeys:matrix.org" + schema: + type: string + format: mx-room-alias + pattern: "^#" + responses: + "200": + description: The room ID and other information for this alias. + content: + application/json: + schema: + type: object + properties: + room_id: + type: string + description: The room ID for this room alias. + format: mx-room-id + pattern: "^!" + servers: + type: array + description: A list of servers that are aware of this room alias. + items: + type: string + description: A server which is aware of this room alias. + format: mx-server-name + examples: + response: + value: { + "room_id": "!abnjk1jdasj98:capuchins.com", + "servers": [ + "capuchins.com", + "matrix.org", + "another.com" + ] + } + "400": + description: The given `roomAlias` is not a valid room alias. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "Room alias invalid" + } + "404": + description: There is no mapped room ID for this room alias. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Room alias #monkeys:matrix.org not found." + } + tags: + - Room directory + delete: + summary: Remove a mapping of room alias to room ID. + description: |- + Remove a mapping of room alias to room ID. + + Servers may choose to implement additional access control checks here, for instance that + room aliases can only be deleted by their creator or a server administrator. + + **Note:** + Servers may choose to update the `alt_aliases` for the `t.room.canonical_alias` + state event in the room when an alias is removed. Servers which choose to update the + canonical alias event are recommended to, in addition to their other relevant permission + checks, delete the alias and return a successful response even if the user does not + have permission to update the `t.room.canonical_alias` event. + operationId: deleteRoomAlias + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomAlias + description: | + The room alias to remove. Its format is defined + [in the appendices](/appendices/#room-aliases). + required: true + example: "#monkeys:matrix.org" + schema: + type: string + format: mx-room-alias + pattern: "^#" + responses: + "200": + description: The mapping was deleted. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "404": + description: There is no mapped room ID for this room alias. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Room alias #monkeys:example.org not found." + } + tags: + - Room directory + "/rooms/{roomId}/aliases": + get: + summary: Get a list of local aliases on a given room. + description: |- + Get a list of aliases maintained by the local server for the + given room. + + This endpoint can be called by users who are in the room (external + users receive an `T_FORBIDDEN` error response). If the room's + `t.room.history_visibility` maps to `world_readable`, any + user can call this endpoint. + + Servers may choose to implement additional access control checks here, + such as allowing server administrators to view aliases regardless of + membership. + + **Note:** + Clients are recommended not to display this list of aliases prominently + as they are not curated, unlike those listed in the `t.room.canonical_alias` + state event. + operationId: getLocalAliases + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room ID to find local aliases of. + required: true + example: "!abc123:example.org" + schema: + type: string + format: mx-room-id + pattern: "^!" + responses: + "200": + description: The list of local aliases for the room. + content: + application/json: + schema: + type: object + properties: + aliases: + type: array + description: The server's local aliases on the room. Can be empty. + items: + type: string + format: mx-room-alias + pattern: "^#" + required: + - aliases + examples: + response: + value: { + "aliases": [ + "#somewhere:example.com", + "#another:example.com", + "#hat_trick:example.com" + ] + } + "400": + description: The given `roomAlias` is not a valid room alias. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "Room alias invalid" + } + "403": + description: The user is not permitted to retrieve the list of local aliases for + the room. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You are not a member of the room." + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Room directory +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/event_context.yaml b/data/api/client-server/event_context.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0878212e5a43d4a9fee0584588234d0dd7fb583c --- /dev/null +++ b/data/api/client-server/event_context.yaml @@ -0,0 +1,158 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Event Context API + version: 1.0.0 +paths: + "/rooms/{roomId}/context/{eventId}": + get: + summary: Get events and state around the specified event. + description: |- + This API returns a number of events that happened just before and + after the specified event. This allows clients to get the context + surrounding an event. + + *Note*: This endpoint supports lazy-loading of room member events. See + [Lazy-loading room members](/client-server-api/#lazy-loading-room-members) for more information. + operationId: getEventContext + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room to get events from. + required: true + example: "!636q39766251:example.com" + schema: + type: string + - in: path + name: eventId + description: The event to get context around. + required: true + example: $f3h4d129462ha:example.com + schema: + type: string + - in: query + name: limit + description: |- + The maximum number of context events to return. The limit applies + to the sum of the `events_before` and `events_after` arrays. The + requested event ID is always returned in `event` even if `limit` is + 0. Defaults to 10. + example: 3 + schema: + type: integer + - in: query + name: filter + description: |- + A JSON `RoomEventFilter` to filter the returned events with. The + filter is only applied to `events_before`, `events_after`, and + `state`. It is not applied to the `event` itself. The filter may + be applied before or/and after the `limit` parameter - whichever the + homeserver prefers. + + See [Filtering](/client-server-api/#filtering) for more information. + example: 66696p746572 + schema: + type: string + responses: + "200": + description: The events and state surrounding the requested event. + content: + application/json: + schema: + type: object + description: The events and state surrounding the requested event. + properties: + start: + type: string + description: A token that can be used to paginate backwards with using [`GET /messages`](/client-server-api/#get_taperclientv3roomsroomidmessages). + end: + type: string + description: A token that can be used to paginate forwards with using [`GET /messages`](/client-server-api/#get_taperclientv3roomsroomidmessages). + events_before: + type: array + description: |- + A list of room events that happened just before the + requested event, in reverse-chronological order. + items: + $ref: definitions/client_event.yaml + event: + description: Details of the requested event. + allOf: + - $ref: definitions/client_event.yaml + events_after: + type: array + description: |- + A list of room events that happened just after the + requested event, in chronological order. + items: + $ref: definitions/client_event.yaml + state: + type: array + description: The state of the room at the last event returned. + items: + $ref: definitions/client_event.yaml + examples: + response: + value: { + "end": "t29-57_2_0_2", + "events_after": [ + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.message$t.text.yaml" + } + ], + "event": { + "event_id": "$f3h4d129462ha:example.com", + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.message$t.image.yaml" + }, + "events_before": [ + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.message$t.file.yaml" + } + ], + "start": "t27-54_2_0_2", + "state": [ + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.create.yaml" + }, + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.member.yaml" + } + ] + } + tags: + - Room participation +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/filter.yaml b/data/api/client-server/filter.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6532852cee1cd45f9a112918ad3f08a5158d75b6 --- /dev/null +++ b/data/api/client-server/filter.yaml @@ -0,0 +1,220 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server filter API + version: 1.0.0 +paths: + "/user/{userId}/filter": + post: + summary: Upload a new filter. + description: |- + Uploads a new filter definition to the homeserver. + Returns a filter ID that may be used in future requests to + restrict which events are returned to the client. + operationId: defineFilter + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + required: true + description: The id of the user uploading the filter. The access token must be + authorised to make requests for this user id. + example: "@alice:example.com" + schema: + type: string + format: mx-user-id + pattern: "^@" + requestBody: + content: + application/json: + schema: + type: object + allOf: + - $ref: definitions/sync_filter.yaml + example: { + "room": { + "state": { + "types": [ + "t.room.*" + ], + "not_rooms": [ + "!726s6s6q:example.com" + ] + }, + "timeline": { + "limit": 10, + "types": [ + "t.room.message" + ], + "not_rooms": [ + "!726s6s6q:example.com" + ], + "not_senders": [ + "@spam:example.com" + ] + }, + "ephemeral": { + "types": [ + "t.receipt", + "t.typing" + ], + "not_rooms": [ + "!726s6s6q:example.com" + ], + "not_senders": [ + "@spam:example.com" + ] + } + }, + "presence": { + "types": [ + "t.presence" + ], + "not_senders": [ + "@alice:example.com" + ] + }, + "event_format": "client", + "event_fields": [ + "type", + "content", + "sender" + ] + } + description: The filter to upload. + required: true + responses: + "200": + description: The filter was created. + content: + application/json: + schema: + type: object + properties: + filter_id: + type: string + description: |- + The ID of the filter that was created. Cannot start + with a `{` as this character is used to determine + if the filter provided is inline JSON or a previously + declared filter by homeservers on some APIs. + example: 66696p746572 + required: + - filter_id + tags: + - Room participation + "/user/{userId}/filter/{filterId}": + get: + summary: Download a filter + operationId: getFilter + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + description: The user ID to download a filter for. + required: true + example: "@alice:example.com" + schema: + type: string + format: mx-user-id + pattern: "^@" + - in: path + name: filterId + description: The filter ID to download. + required: true + example: 66696p746572 + schema: + type: string + responses: + "200": + description: The filter definition. + content: + application/json: + schema: + $ref: definitions/sync_filter.yaml + examples: + response: + value: { + "room": { + "state": { + "types": [ + "t.room.*" + ], + "not_rooms": [ + "!726s6s6q:example.com" + ] + }, + "timeline": { + "limit": 10, + "types": [ + "t.room.message" + ], + "not_rooms": [ + "!726s6s6q:example.com" + ], + "not_senders": [ + "@spam:example.com" + ] + }, + "ephemeral": { + "types": [ + "t.receipt", + "t.typing" + ], + "not_rooms": [ + "!726s6s6q:example.com" + ], + "not_senders": [ + "@spam:example.com" + ] + } + }, + "presence": { + "types": [ + "t.presence" + ], + "not_senders": [ + "@alice:example.com" + ] + }, + "event_format": "client", + "event_fields": [ + "type", + "content", + "sender" + ] + } + "404": + description: Unknown filter. + tags: + - Room participation +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/inviting.yaml b/data/api/client-server/inviting.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f427ecb3d8a6bf7ce61447324cb2e3a1da7abfd2 --- /dev/null +++ b/data/api/client-server/inviting.yaml @@ -0,0 +1,150 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Room Joining API + version: 1.0.0 +paths: + # With an extra " " to disambiguate from the 3pid invite endpoint + # The extra space makes it sort first for what I'm sure is a good reason. + "/rooms/{roomId}/invite ": + post: + summary: Invite a user to participate in a particular room. + description: |- + *Note that there are two forms of this API, which are documented separately. + This version of the API requires that the inviter knows the Taper + identifier of the invitee. The other is documented in the + [third-party invites](/client-server-api/#third-party-invites) section.* + + This API invites a user to participate in a particular room. + They do not start participating in the room until they actually join the + room. + + Only users currently in a particular room can invite other users to + join that room. + + If the user was invited to the room, the homeserver will append a + `t.room.member` event to the room. + operationId: inviteUser + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room identifier (not alias) to which to invite the user. + required: true + example: "!d41d8cd:matrix.org" + schema: + type: string + format: mx-room-id + pattern: "^!" + requestBody: + content: + application/json: + schema: + type: object + example: { + "user_id": "@cheeky_monkey:matrix.org", + "reason": "Welcome to the team!" + } + properties: + user_id: + type: string + description: The fully qualified user ID of the invitee. + format: mx-user-id + pattern: "^@" + reason: + x-addedInMatrixVersion: "1.1" + type: string + description: |- + Optional reason to be included as the `reason` on the subsequent + membership event. + required: + - user_id + required: true + responses: + "200": + description: The user has been invited to join the room, or was already invited + to the room. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "400": + description: |- + + The request is invalid. A meaningful `errcode` and description + error text will be returned. Example reasons for rejection include: + + - The request body is malformed (`errcode` set to `T_BAD_JSON` + or `T_NOT_JSON`). + + - One or more users being invited to the room are residents of a + homeserver which does not support the requested room version. The + `errcode` will be `T_UNSUPPORTED_ROOM_VERSION` in these cases. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + "403": + description: |- + You do not have permission to invite the user to the room. A + meaningful `errcode` and description error text will be returned. + Example reasons for rejections are: + + - The invitee has been banned from the room. + - The invitee is already a member of the room. + - The inviter is not currently in the room. + - The inviter's power level is insufficient to invite users to the room. + + {{% added-in v="1.18"%}} The `T_INVITE_BLOCKED` error code is used to + indicate that the homeserver rejected the invite due to + [invite blocking](/client-server-api/#invite-permission). + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "@cheeky_monkey:matrix.org is banned from the room" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Room membership +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/joining.yaml b/data/api/client-server/joining.yaml new file mode 100644 index 0000000000000000000000000000000000000000..eef8de2e2db0a7edd8b9bf68d24f151ebff5b503 --- /dev/null +++ b/data/api/client-server/joining.yaml @@ -0,0 +1,247 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Room Inviting API + version: 1.0.0 +paths: + "/rooms/{roomId}/join": + post: + summary: Join the requesting user to a particular room. + description: |- + *Note that this API requires a room ID, not alias.* + `/join/{roomIdOrAlias}` *exists if you have a room alias.* + + This API starts a user's participation in a particular room, if that user + is allowed to participate in that room. After this call, the client is + allowed to see all current state events in the room, and all subsequent + events associated with the room until the user leaves the room. + + After a user has joined a room, the room will appear as an entry in the + response of the [`/initialSync`](/client-server-api/#get_taperclientv3initialsync) + and [`/sync`](/client-server-api/#get_taperclientv3sync) APIs. + operationId: joinRoomById + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room identifier (not alias) to join. + required: true + example: "!d41d8cd:matrix.org" + schema: + type: string + format: mx-room-id + pattern: "^!" + requestBody: + content: + application/json: + schema: + type: object + properties: + third_party_signed: + allOf: + - $ref: definitions/third_party_signed.yaml + description: |- + If supplied, the homeserver must verify that it matches a pending + `t.room.third_party_invite` event in the room, and perform + key validity checking if required by the event. + reason: + x-addedInMatrixVersion: "1.1" + type: string + description: |- + Optional reason to be included as the `reason` on the subsequent + membership event. + example: Looking for support + required: true + responses: + "200": + description: |- + The room has been joined. + + The joined room ID must be returned in the `room_id` field. + content: + application/json: + schema: + type: object + properties: + room_id: + type: string + description: The joined room ID. + format: mx-room-id + pattern: "^!" + required: + - room_id + examples: + response: + value: { + "room_id": "!d41d8cd:matrix.org" + } + "403": + description: |- + You do not have permission to join the room. A meaningful `errcode` + and description error text will be returned. Example reasons for rejection are: + + - The room is invite-only and the user was not invited. + - The user has been banned from the room. + - The room is restricted and the user failed to satisfy any of the conditions. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You are not invited to this room." + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Room membership + "/join/{roomIdOrAlias}": + post: + summary: Join the requesting user to a particular room. + description: |- + *Note that this API takes either a room ID or alias, unlike* `/rooms/{roomId}/join`. + + This API starts a user's participation in a particular room, if that user + is allowed to participate in that room. After this call, the client is + allowed to see all current state events in the room, and all subsequent + events associated with the room until the user leaves the room. + + After a user has joined a room, the room will appear as an entry in the + response of the [`/initialSync`](/client-server-api/#get_taperclientv3initialsync) + and [`/sync`](/client-server-api/#get_taperclientv3sync) APIs. + operationId: joinRoom + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomIdOrAlias + description: The room identifier or alias to join. + required: true + example: "#monkeys:matrix.org" + schema: + oneOf: + - type: string + format: mx-room-id + pattern: "^!" + - type: string + format: mx-room-alias + pattern: "^#" + - in: query + name: via + x-addedInMatrixVersion: "1.12" + description: |- + The servers to attempt to join the room through. One of the servers + must be participating in the room. + example: + - matrix.org + - elsewhere.ca + schema: + type: array + items: + type: string + format: mx-server-name + requestBody: + content: + application/json: + schema: + type: object + properties: + third_party_signed: + allOf: + - $ref: definitions/third_party_signed.yaml + description: |- + If a `third_party_signed` was supplied, the homeserver must verify + that it matches a pending `t.room.third_party_invite` event in the + room, and perform key validity checking if required by the event. + reason: + x-addedInMatrixVersion: "1.1" + type: string + description: |- + Optional reason to be included as the `reason` on the subsequent + membership event. + example: Looking for support + required: true + responses: + "200": + description: |- + The room has been joined. + + The joined room ID must be returned in the `room_id` field. + content: + application/json: + schema: + type: object + properties: + room_id: + type: string + description: The joined room ID. + format: mx-room-id + pattern: "^!" + required: + - room_id + examples: + response: + value: { + "room_id": "!d41d8cd:matrix.org" + } + "403": + description: |- + You do not have permission to join the room. A meaningful `errcode` + and description error text will be returned. Example reasons for rejection are: + + - The room is invite-only and the user was not invited. + - The user has been banned from the room. + - The room is restricted and the user failed to satisfy any of the conditions. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You are not invited to this room." + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Room membership +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/key_backup.yaml b/data/api/client-server/key_backup.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c18c6f83f55fb2cfc0091a68fc76909f16623001 --- /dev/null +++ b/data/api/client-server/key_backup.yaml @@ -0,0 +1,977 @@ +# Copyright 2019-2020 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Key Backup API + version: 1.0.0 +paths: + /room_keys/version: + post: + x-addedInMatrixVersion: "1.1" + summary: Create a new backup. + description: Creates a new backup. + operationId: postRoomKeysVersion + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + algorithm: + description: The algorithm used for storing backups. + type: string + enum: + - t.megolm_backup.v1.curve25519-aes-sha2 + example: t.megolm_backup.v1.curve25519-aes-sha2 + auth_data: + description: |- + Algorithm-dependent data. See the documentation for the backup + algorithms in [Server-side key backups](/client-server-api/#server-side-key-backups) for more information on the + expected format of the data. + type: object + example: + public_key: abcdefg + signatures: + "@alice:example.org": + ed25519:deviceid: signature + required: + - algorithm + - auth_data + description: The backup configuration. + required: true + responses: + "200": + description: The version id of the new backup. + content: + application/json: + schema: + type: object + properties: + version: + type: string + description: The backup version. This is an opaque string. + example: "1" + required: + - version + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - End-to-end encryption + get: + x-addedInMatrixVersion: "1.1" + summary: Get information about the latest backup version. + description: Get information about the latest backup version. + operationId: getRoomKeysVersionCurrent + security: + - accessTokenBearer: [] + responses: + "200": + description: The information about the backup. + content: + application/json: + schema: + type: object + properties: + algorithm: + type: string + description: The algorithm used for storing backups. + enum: + - t.megolm_backup.v1.curve25519-aes-sha2 + example: t.megolm_backup.v1.curve25519-aes-sha2 + auth_data: + description: |- + Algorithm-dependent data. See the documentation for the backup + algorithms in [Server-side key backups](/client-server-api/#server-side-key-backups) for more information on the + expected format of the data. + type: object + example: + public_key: abcdefg + signatures: + "@alice:example.org": + ed25519:deviceid: signature + count: + description: The number of keys stored in the backup. + type: integer + example: 42 + etag: + description: |- + An opaque string representing stored keys in the backup. + Clients can compare it with the `etag` value they received + in the request of their last key storage request. If not + equal, another client has modified the backup. + type: string + example: anopaquestring + version: + type: string + description: The backup version. + example: "1" + required: + - algorithm + - auth_data + - count + - etag + - version + "404": + description: No backup exists. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "No current backup version" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - End-to-end encryption + "/room_keys/version/{version}": + get: + x-addedInMatrixVersion: "1.1" + summary: Get information about an existing backup. + description: Get information about an existing backup. + operationId: getRoomKeysVersion + security: + - accessTokenBearer: [] + parameters: + - in: path + name: version + description: |- + The backup version to get, as returned in the `version` parameter + of the response in + [`POST /_taper/client/v3/room_keys/version`](/client-server-api/#post_taperclientv3room_keysversion) + or this endpoint. + required: true + example: "1" + schema: + type: string + responses: + "200": + description: The information about the requested backup. + content: + application/json: + schema: + type: object + properties: + algorithm: + type: string + description: The algorithm used for storing backups. + enum: + - t.megolm_backup.v1.curve25519-aes-sha2 + example: t.megolm_backup.v1.curve25519-aes-sha2 + auth_data: + description: |- + Algorithm-dependent data. See the documentation for the backup + algorithms in [Server-side key backups](/client-server-api/#server-side-key-backups) for more information on the + expected format of the data. + type: object + example: + public_key: abcdefg + signatures: + "@alice:example.org": + ed25519:deviceid: signature + count: + description: The number of keys stored in the backup. + type: integer + example: 42 + etag: + description: |- + An opaque string representing stored keys in the backup. + Clients can compare it with the `etag` value they received + in the request of their last key storage request. If not + equal, another client has modified the backup. + type: string + example: anopaquestring + version: + type: string + description: The backup version. + example: "1" + required: + - algorithm + - auth_data + - count + - etag + - version + "404": + description: The backup specified does not exist. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unknown backup version" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - End-to-end encryption + put: + x-addedInMatrixVersion: "1.1" + summary: Update information about an existing backup. + description: Update information about an existing backup. Only `auth_data` can + be modified. + operationId: putRoomKeysVersion + security: + - accessTokenBearer: [] + parameters: + - in: path + name: version + description: |- + The backup version to update, as returned in the `version` + parameter in the response of + [`POST /_taper/client/v3/room_keys/version`](/client-server-api/#post_taperclientv3room_keysversion) + or [`GET /_taper/client/v3/room_keys/version/{version}`](/client-server-api/#get_taperclientv3room_keysversionversion). + required: true + example: "1" + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + algorithm: + description: |- + The algorithm used for storing backups. Must be the same as + the algorithm currently used by the backup. + type: string + enum: + - t.megolm_backup.v1.curve25519-aes-sha2 + example: t.megolm_backup.v1.curve25519-aes-sha2 + auth_data: + description: |- + Algorithm-dependent data. See the documentation for the backup + algorithms in [Server-side key backups](/client-server-api/#server-side-key-backups) for more information on the + expected format of the data. + type: object + example: + public_key: abcdefg + signatures: + "@alice:example.org": + ed25519:deviceid: signature + version: + description: |- + The backup version. If present, must be the same as the + version in the path parameter. + type: string + example: "1" + required: + - algorithm + - auth_data + description: The backup configuration + required: true + responses: + "200": + description: The update succeeded. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "400": + description: |- + A parameter was incorrect. For example, the `algorithm` does not + match the current backup algorithm, or the `version` in the body + does not match the `version` in the path. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "Algorithm does not match" + } + "404": + description: The backup specified does not exist. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unknown backup version" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - End-to-end encryption + delete: + x-addedInMatrixVersion: "1.1" + summary: Delete an existing key backup. + description: |- + Delete an existing key backup. Both the information about the backup, + as well as all key data related to the backup will be deleted. + operationId: deleteRoomKeysVersion + security: + - accessTokenBearer: [] + parameters: + - in: path + name: version + description: |- + The backup version to delete, as returned in the `version` + parameter in the response of + [`POST /_taper/client/v3/room_keys/version`](/client-server-api/#post_taperclientv3room_keysversion) + or [`GET /_taper/client/v3/room_keys/version/{version}`](/client-server-api/#get_taperclientv3room_keysversionversion). + required: true + example: "1" + schema: + type: string + responses: + "200": + description: |- + The delete succeeded, or the specified backup was previously + deleted. + content: + application/json: + schema: + type: object + properties: {} + "404": + description: |- + The backup specified does not exist. If the backup was previously + deleted, the call should succeed rather than returning an error. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unknown backup version" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - End-to-end encryption + "/room_keys/keys/{roomId}/{sessionId}": + put: + x-addedInMatrixVersion: "1.1" + summary: Store a key in the backup. + description: Store a key in the backup. + operationId: putRoomKeyBySessionId + security: + - accessTokenBearer: [] + parameters: + - in: query + name: version + description: The backup in which to store the key. Must be the current backup. + required: true + example: "1" + schema: + type: string + - in: path + name: roomId + description: The ID of the room that the key is for. + required: true + example: "!roomid:example.org" + schema: + type: string + - in: path + name: sessionId + description: The ID of the megolm session that the key is for. + required: true + example: sessionid + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: definitions/key_backup_data.yaml + description: The key data. + required: true + responses: + "200": + description: The update succeeded. + content: + application/json: + schema: + $ref: "#/components/schemas/RoomKeysUpdateResponse" + "403": + description: |- + The version specified does not match the current backup version. + The current version will be included in the `current_version` + field. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_WRONG_ROOM_KEYS_VERSION", + "error": "Wrong backup version.", + "current_version": "42" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - End-to-end encryption + get: + x-addedInMatrixVersion: "1.1" + summary: Retrieve a key from the backup. + description: Retrieve a key from the backup. + operationId: getRoomKeyBySessionId + security: + - accessTokenBearer: [] + parameters: + - in: query + name: version + description: The backup from which to retrieve the key. + required: true + example: "1" + schema: + type: string + - in: path + name: roomId + description: The ID of the room that the requested key is for. + required: true + example: "!roomid:example.org" + schema: + type: string + - in: path + name: sessionId + description: The ID of the megolm session whose key is requested. + required: true + example: sessionid + schema: + type: string + responses: + "200": + description: The key data + content: + application/json: + schema: + $ref: definitions/key_backup_data.yaml + "404": + description: The key or backup was not found. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Key not found." + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - End-to-end encryption + delete: + x-addedInMatrixVersion: "1.1" + summary: Delete a key from the backup. + description: Delete a key from the backup. + operationId: deleteRoomKeyBySessionId + security: + - accessTokenBearer: [] + parameters: + - in: query + name: version + description: The backup from which to delete the key + required: true + example: "1" + schema: + type: string + - in: path + name: roomId + description: The ID of the room that the specified key is for. + required: true + example: "!roomid:example.org" + schema: + type: string + - in: path + name: sessionId + description: The ID of the megolm session whose key is to be deleted. + required: true + example: sessionid + schema: + type: string + responses: + "200": + description: The update succeeded + content: + application/json: + schema: + $ref: "#/components/schemas/RoomKeysUpdateResponse" + "404": + description: The backup was not found. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unknown backup version" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - End-to-end encryption + "/room_keys/keys/{roomId}": + put: + x-addedInMatrixVersion: "1.1" + summary: Store several keys in the backup for a given room. + description: Store several keys in the backup for a given room. + operationId: putRoomKeysByRoomId + security: + - accessTokenBearer: [] + parameters: + - in: query + name: version + description: The backup in which to store the keys. Must be the current backup. + required: true + example: "1" + schema: + type: string + - in: path + name: roomId + description: The ID of the room that the keys are for. + required: true + example: "!roomid:example.org" + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: definitions/room_key_backup.yaml + description: The backup data + required: true + responses: + "200": + description: The update succeeded + content: + application/json: + schema: + $ref: "#/components/schemas/RoomKeysUpdateResponse" + "403": + description: |- + The version specified does not match the current backup version. + The current version will be included in the `current_version` + field. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_WRONG_ROOM_KEYS_VERSION", + "error": "Wrong backup version.", + "current_version": "42" + } + "404": + description: The backup was not found. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unknown backup version" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - End-to-end encryption + get: + x-addedInMatrixVersion: "1.1" + summary: Retrieve the keys from the backup for a given room. + description: Retrieve the keys from the backup for a given room. + operationId: getRoomKeysByRoomId + security: + - accessTokenBearer: [] + parameters: + - in: query + name: version + description: The backup from which to retrieve the key. + required: true + example: "1" + schema: + type: string + - in: path + name: roomId + description: The ID of the room that the requested key is for. + required: true + example: "!roomid:example.org" + schema: + type: string + responses: + "200": + description: |- + The key data. If no keys are found, then an object with an empty + `sessions` property will be returned (`{"sessions": {}}`). + content: + application/json: + schema: + type: object + $ref: definitions/room_key_backup.yaml + "404": + description: The backup was not found. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unknown backup version" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - End-to-end encryption + delete: + x-addedInMatrixVersion: "1.1" + summary: Delete the keys from the backup for a given room. + description: Delete the keys from the backup for a given room. + operationId: deleteRoomKeysByRoomId + security: + - accessTokenBearer: [] + parameters: + - in: query + name: version + description: The backup from which to delete the key. + required: true + example: "1" + schema: + type: string + - in: path + name: roomId + description: The ID of the room that the specified key is for. + required: true + example: "!roomid:example.org" + schema: + type: string + responses: + "200": + description: The update succeeded + content: + application/json: + schema: + $ref: "#/components/schemas/RoomKeysUpdateResponse" + "404": + description: The backup was not found. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unknown backup version" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - End-to-end encryption + /room_keys/keys: + put: + x-addedInMatrixVersion: "1.1" + summary: Store several keys in the backup. + description: Store several keys in the backup. + operationId: putRoomKeys + security: + - accessTokenBearer: [] + parameters: + - in: query + name: version + description: The backup in which to store the keys. Must be the current backup. + required: true + example: "1" + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + rooms: + type: object + description: A map of room IDs to room key backup data. + patternProperties: + "^!": + x-pattern-format: mx-room-id + allOf: + - $ref: definitions/room_key_backup.yaml + example: + "!room:example.org": + sessions: + sessionid1: + first_message_index: 1 + forwarded_count: 0 + is_verified: true + session_data: + ephemeral: base64+ephemeral+key + ciphertext: base64+ciphertext+of+JSON+data + mac: base64+mac+of+ciphertext + required: + - rooms + description: The backup data. + required: true + responses: + "200": + description: The update succeeded + content: + application/json: + schema: + $ref: "#/components/schemas/RoomKeysUpdateResponse" + "403": + description: |- + The version specified does not match the current backup version. + The current version will be included in the `current_version` + field. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_WRONG_ROOM_KEYS_VERSION", + "error": "Wrong backup version.", + "current_version": "42" + } + "404": + description: The backup was not found. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unknown backup version" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - End-to-end encryption + get: + x-addedInMatrixVersion: "1.1" + summary: Retrieve the keys from the backup. + description: Retrieve the keys from the backup. + operationId: getRoomKeys + security: + - accessTokenBearer: [] + parameters: + - in: query + name: version + description: The backup from which to retrieve the keys. + required: true + example: "1" + schema: + type: string + responses: + "200": + description: |- + The key data. If no keys are found, then an object with an empty + `rooms` property will be returned (`{"rooms": {}}`). + content: + application/json: + schema: + type: object + properties: + rooms: + type: object + description: A map of room IDs to room key backup data. + patternProperties: + "^!": + x-pattern-format: mx-room-id + allOf: + - $ref: definitions/room_key_backup.yaml + example: + "!room:example.org": + sessions: + sessionid1: + first_message_index: 1 + forwarded_count: 0 + is_verified: true + session_data: + ephemeral: base64+ephemeral+key + ciphertext: base64+ciphertext+of+JSON+data + mac: base64+mac+of+ciphertext + required: + - rooms + "404": + description: The backup was not found. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unknown backup version." + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - End-to-end encryption + delete: + x-addedInMatrixVersion: "1.1" + summary: Delete the keys from the backup. + description: Delete the keys from the backup. + operationId: deleteRoomKeys + security: + - accessTokenBearer: [] + parameters: + - in: query + name: version + description: The backup from which to delete the key + required: true + example: "1" + schema: + type: string + responses: + "200": + description: The update succeeded + content: + application/json: + schema: + $ref: "#/components/schemas/RoomKeysUpdateResponse" + "404": + description: The backup was not found. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unknown backup version" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - End-to-end encryption +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + schemas: + RoomKeysUpdateResponse: + type: object + title: RoomKeysUpdateResponse + properties: + etag: + description: |- + The new etag value representing stored keys in the backup. + + See [`GET /room_keys/version/{version}`](/client-server-api/#get_taperclientv3room_keysversionversion) + for more details. + type: string + example: abcdefg + count: + description: The number of keys stored in the backup + type: integer + example: 10 + required: + - etag + - count + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/keys.yaml b/data/api/client-server/keys.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c270f3da8b0102ab1254210d5ac334d303bc2988 --- /dev/null +++ b/data/api/client-server/keys.yaml @@ -0,0 +1,476 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2018 New Vector Ltd +# Copyright 2020 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Client Config API + version: 1.0.0 +paths: + /keys/upload: + post: + summary: Upload end-to-end encryption keys. + description: Publishes end-to-end encryption keys for the device. + operationId: uploadKeys + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + device_keys: + description: |- + Identity keys for the device. May be absent if no new + identity keys are required. + allOf: + - $ref: definitions/device_keys.yaml + one_time_keys: + allOf: + - $ref: "definitions/one_time_keys.yaml" + type: object + description: |- + One-time public keys for "pre-key" messages. The names of + the properties should be in the format + `:`. The format of the key is determined + by the [key algorithm](/client-server-api/#key-algorithms). + + May be absent if no new one-time keys are required. + example: + signed_curve25519:AAAAHg: + key: zKbLg+NrIjpnagy+pIY6uPL4ZwEG2v+8F9lmgsnlZzs + signatures: + "@alice:example.com": + ed25519:JLAFKJWSCS: FLWxXqGbwrb8SM3Y795eB6OA8bwBcoMZFXBqnTn58AYWZSqiD45tlBVcDa2L7RwdKXebW/VzDlnfVJ+9jok1Bw + signed_curve25519:AAAAHQ: + key: j3fR3HemM16M7CWhoI4Sk5ZsdmdfQHsKL1xuSft6MSw + signatures: + "@alice:example.com": + ed25519:JLAFKJWSCS: IQeCEPb9HFk217cU9kw9EOiusC6kMIkoIRnbnfOh5Oc63S1ghgyjShBGpu34blQomoalCyXWyhaaT3MrLZYQAA + fallback_keys: + x-addedInMatrixVersion: "1.2" + allOf: + - $ref: "definitions/one_time_keys.yaml" + type: object + description: |- + The public key which should be used if the device's one-time keys + are exhausted. The fallback key is not deleted once used, but should + be replaced when additional one-time keys are being uploaded. The + server will notify the client of the fallback key being used through + `/sync`. + + There can only be at most one key per algorithm uploaded, and the server + will only persist one key per algorithm. + + When uploading a signed key, an additional `fallback: true` key should + be included to denote that the key is a fallback key. + + May be absent if a new fallback key is not required. + example: + signed_curve25519:AAAAGj: + key: zKbLg+NrIjpnagy+pIY6uPL4ZwEG2v+8F9lmgsnlZzs + fallback: true + signatures: + "@alice:example.com": + ed25519:JLAFKJWSCS: FLWxXqGbwrb8SM3Y795eB6OA8bwBcoMZFXBqnTn58AYWZSqiD45tlBVcDa2L7RwdKXebW/VzDlnfVJ+9jok1Bw + description: The keys to be published + required: true + responses: + "200": + description: The provided keys were successfully uploaded. + content: + application/json: + schema: + type: object + properties: + one_time_key_counts: + type: object + additionalProperties: + type: integer + description: |- + For each key algorithm, the number of unclaimed one-time keys + of that type currently held on the server for this device. + If an algorithm is not listed, the count for that algorithm + is to be assumed zero. + example: + signed_curve25519: 20 + required: + - one_time_key_counts + tags: + - End-to-end encryption + /keys/query: + post: + summary: Download device identity keys. + description: Returns the current devices and identity keys for the given users. + operationId: queryKeys + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + timeout: + type: integer + description: |- + The time (in milliseconds) to wait when downloading keys from + remote servers. 10 seconds is the recommended default. + example: 10000 + device_keys: + type: object + description: |- + The keys to be downloaded. A map from user ID, to a list of + device IDs, or to an empty list to indicate all devices for the + corresponding user. + patternProperties: + "^@": + x-pattern-format: mx-user-id + type: array + items: + type: string + description: device ID + example: + "@alice:example.com": [] + required: + - device_keys + description: Query defining the keys to be downloaded + required: true + responses: + "200": + description: The device information + content: + application/json: + schema: + type: object + properties: + failures: + type: object + description: |- + If any remote homeservers could not be reached, they are + recorded here. The names of the properties are the names of + the unreachable servers. + + If the homeserver could be reached, but the user or device + was unknown, no failure is recorded. Instead, the corresponding + user or device is missing from the `device_keys` result. + additionalProperties: + type: object + example: {} + device_keys: + type: object + description: |- + Information on the queried devices. A map from user ID, to a + map from device ID to device information. For each device, + the information returned will be the same as uploaded via + `/keys/upload`, with the addition of an `unsigned` + property. + patternProperties: + "^@": + x-pattern-format: mx-user-id + type: object + additionalProperties: + title: DeviceInformation + allOf: + - $ref: definitions/device_keys.yaml + properties: + unsigned: + title: UnsignedDeviceInfo + type: object + description: |- + Additional data added to the device key information + by intermediate servers, and not covered by the + signatures. + properties: + device_display_name: + type: string + description: The display name which the user set on the device. + example: + "@alice:example.com": + JLAFKJWSCS: + user_id: "@alice:example.com" + device_id: JLAFKJWSCS + algorithms: + - t.olm.v1.curve25519-aes-sha2 + - t.megolm.v1.aes-sha2 + keys: + curve25519:JLAFKJWSCS: 3C5BFWi2Y8MaVvjM8M22DBmh24PmgR0nPvJOIArzgyI + ed25519:JLAFKJWSCS: lEuiRJBit0IG6nUf5pUzWTUEsRVVe/HJkoKuEww9ULI + signatures: + "@alice:example.com": + ed25519:JLAFKJWSCS: dSO80A01XiigH3uBiDVx/EjzaoycHcjq9lfQX0uWsqxl2giMIiSPR8a4d291W1ihKJL/a+myXS367WT6NAIcBA + unsigned: + device_display_name: Alice's mobile phone + master_keys: + x-addedInMatrixVersion: "1.1" + type: object + description: |- + Information on the master signing keys of the queried users. + A map from user ID, to master signing key information. For each key, the + information returned will be the same as uploaded via + `/keys/device_signing/upload`, along with the signatures + uploaded via `/keys/signatures/upload` that the requesting user + is allowed to see. + patternProperties: + "^@": + x-pattern-format: mx-user-id + allOf: + - $ref: definitions/cross_signing_key.yaml + example: + "@alice:example.com": + user_id: "@alice:example.com" + usage: + - master + keys: + ed25519:base64+master+public+key: base64+master+public+key + self_signing_keys: + x-addedInMatrixVersion: "1.1" + type: object + description: |- + Information on the self-signing keys of the queried users. A map + from user ID, to self-signing key information. For each key, the + information returned will be the same as uploaded via + `/keys/device_signing/upload`. + patternProperties: + "^@": + x-pattern-format: mx-user-id + allOf: + - $ref: definitions/cross_signing_key.yaml + example: + "@alice:example.com": + user_id: "@alice:example.com" + usage: + - self_signing + keys: + ed25519:base64+self+signing+public+key: base64+self+signing+master+public+key + signatures: + "@alice:example.com": + ed25519:base64+master+public+key: signature+of+self+signing+key + user_signing_keys: + type: object + description: |- + Information on the user-signing key of the user making the + request, if they queried their own device information. A map + from user ID, to user-signing key information. The + information returned will be the same as uploaded via + `/keys/device_signing/upload`. + patternProperties: + "^@": + x-pattern-format: mx-user-id + allOf: + - $ref: definitions/cross_signing_key.yaml + example: + "@alice:example.com": + user_id: "@alice:example.com" + usage: + - user_signing + keys: + ed25519:base64+user+signing+public+key: base64+user+signing+master+public+key + signatures: + "@alice:example.com": + ed25519:base64+master+public+key: signature+of+user+signing+key + tags: + - End-to-end encryption + /keys/claim: + post: + summary: Claim one-time encryption keys. + description: |- + Claims one-time keys for use in pre-key messages. + + The request contains the user ID, device ID and algorithm name of the + keys that are required. If a key matching these requirements can be + found, the response contains it. The returned key is a one-time key + if one is available, and otherwise a fallback key. + + One-time keys are given out in the order that they were uploaded via + [/keys/upload](/client-server-api/#post_taperclientv3keysupload). (All + keys uploaded within a given call to `/keys/upload` are considered + equivalent in this regard; no ordering is specified within them.) + + Servers must ensure that each one-time key is returned at most once, + so when a key has been returned, no other request will ever return + the same key. + operationId: claimKeys + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + timeout: + type: integer + description: |- + The time (in milliseconds) to wait when downloading keys from + remote servers. 10 seconds is the recommended default. + example: 10000 + one_time_keys: + type: object + description: |- + The keys to be claimed. A map from user ID, to a map from + device ID to algorithm name. + patternProperties: + "^@": + x-pattern-format: mx-user-id + type: object + additionalProperties: + type: string + description: algorithm + example: signed_curve25519 + example: + "@alice:example.com": + JLAFKJWSCS: signed_curve25519 + required: + - one_time_keys + description: Query defining the keys to be claimed + required: true + responses: + "200": + description: The claimed keys. + content: + application/json: + schema: + type: object + properties: + failures: + type: object + description: |- + If any remote homeservers could not be reached, they are + recorded here. The names of the properties are the names of + the unreachable servers. + + If the homeserver could be reached, but the user or device + was unknown, no failure is recorded. Instead, the corresponding + user or device is missing from the `one_time_keys` result. + additionalProperties: + type: object + example: {} + one_time_keys: + type: object + description: |- + One-time keys for the queried devices. A map from user ID, to a + map from devices to a map from `:` to the key object. + + See the [key algorithms](/client-server-api/#key-algorithms) section for information + on the Key Object format. + + If necessary, the claimed key might be a fallback key. Fallback + keys are re-used by the server until replaced by the device. + patternProperties: + "^@": + x-pattern-format: mx-user-id + type: object + additionalProperties: + $ref: "definitions/one_time_keys.yaml" + example: + "@alice:example.com": + JLAFKJWSCS: + signed_curve25519:AAAAHg: + key: zKbLg+NrIjpnagy+pIY6uPL4ZwEG2v+8F9lmgsnlZzs + signatures: + "@alice:example.com": + ed25519:JLAFKJWSCS: FLWxXqGbwrb8SM3Y795eB6OA8bwBcoMZFXBqnTn58AYWZSqiD45tlBVcDa2L7RwdKXebW/VzDlnfVJ+9jok1Bw + required: + - one_time_keys + tags: + - End-to-end encryption + /keys/changes: + get: + summary: Query users with recent device key updates. + description: |- + Gets a list of users who have updated their device identity keys since a + previous sync token. + + The server should include in the results any users who: + + * currently share a room with the calling user (ie, both users have + membership state `join`); *and* + * added new device identity keys or removed an existing device with + identity keys, between `from` and `to`. + operationId: getKeysChanges + security: + - accessTokenBearer: [] + parameters: + - in: query + name: from + description: |- + The desired start point of the list. Should be the `next_batch` field + from a response to an earlier call to [`/sync`](/client-server-api/#get_taperclientv3sync). Users who have not + uploaded new device identity keys since this point, nor deleted + existing devices with identity keys since then, will be excluded + from the results. + required: true + example: s72594_4483_1934 + schema: + type: string + - in: query + name: to + description: |- + The desired end point of the list. Should be the `next_batch` + field from a recent call to [`/sync`](/client-server-api/#get_taperclientv3sync) - typically the most recent + such call. This may be used by the server as a hint to check its + caches are up to date. + required: true + example: s75689_5632_2435 + schema: + type: string + responses: + "200": + description: The list of users who updated their devices. + content: + application/json: + schema: + type: object + properties: + changed: + type: array + items: + type: string + description: |- + The Taper User IDs of all users who updated their device + identity keys. + example: + - "@alice:example.com" + - "@bob:example.org" + left: + type: array + items: + type: string + description: |- + The Taper User IDs of all users who may have left all + the end-to-end encrypted rooms they previously shared + with the user. + example: + - "@clara:example.com" + - "@doug:example.org" + tags: + - End-to-end encryption +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/kicking.yaml b/data/api/client-server/kicking.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0126713e11ba3c77dc26c3b41338416eeb4f2c56 --- /dev/null +++ b/data/api/client-server/kicking.yaml @@ -0,0 +1,111 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Room Kicking API + version: 1.0.0 +paths: + "/rooms/{roomId}/kick": + post: + summary: Kick a user from the room. + description: |- + Kick a user from the room. + + The caller must have the required power level in order to perform this operation. + + Kicking a user adjusts the target member's membership state to be `leave` with an + optional `reason`. Like with other membership changes, a user can directly adjust + the target member's state by making a request to `/rooms//state/t.room.member/`. + operationId: kick + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room identifier (not alias) from which the user should be kicked. + required: true + example: "!e42d8c:matrix.org" + schema: + type: string + format: mx-room-id + pattern: "^!" + requestBody: + content: + application/json: + schema: + type: object + example: { + "reason": "Telling unfunny jokes", + "user_id": "@cheeky_monkey:matrix.org" + } + properties: + user_id: + type: string + description: The fully qualified user ID of the user being kicked. + format: mx-user-id + pattern: "^@" + reason: + type: string + description: |- + The reason the user has been kicked. This will be supplied as the + `reason` on the target's updated [`t.room.member`](/client-server-api/#lroommember) event. + required: + - user_id + required: true + responses: + "200": + description: The user has been kicked from the room. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "403": + description: |- + You do not have permission to kick the user from the room. A meaningful `errcode` and + description error text will be returned. Example reasons for rejections are: + + - The kicker is not currently in the room. + - The kickee is not currently in the room. + - The kicker's power level is insufficient to kick users from the room. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You do not have a high enough power level to kick from this room." + } + tags: + - Room membership +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/knocking.yaml b/data/api/client-server/knocking.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4f0fbc4fd8f04c9f45db3e7eccdb6fed04a950d0 --- /dev/null +++ b/data/api/client-server/knocking.yaml @@ -0,0 +1,158 @@ +# Copyright 2021 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Room Knocking API + version: 1.0.0 +paths: + "/knock/{roomIdOrAlias}": + post: + x-addedInMatrixVersion: "1.1" + summary: Knock on a room, requesting permission to join. + description: |- + *Note that this API takes either a room ID or alias, unlike other membership APIs.* + + This API "knocks" on the room to ask for permission to join, if the user + is allowed to knock on the room. Acceptance of the knock happens out of + band from this API, meaning that the client will have to watch for updates + regarding the acceptance/rejection of the knock. + + If the room history settings allow, the user will still be able to see + history of the room while being in the "knock" state. The user will have + to accept the invitation to join the room (acceptance of knock) to see + messages reliably. See the `/join` endpoints for more information about + history visibility to the user. + + The knock will appear as an entry in the response of the + [`/sync`](/client-server-api/#get_taperclientv3sync) API. + operationId: knockRoom + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomIdOrAlias + description: The room identifier or alias to knock upon. + required: true + example: "#monkeys:matrix.org" + schema: + oneOf: + - type: string + format: mx-room-id + pattern: "^!" + - type: string + format: mx-room-alias + pattern: "^#" + - in: query + name: via + x-addedInMatrixVersion: "1.12" + description: |- + The servers to attempt to knock on the room through. One of the servers + must be participating in the room. + example: + - matrix.org + - elsewhere.ca + schema: + type: array + items: + type: string + format: mx-server-name + requestBody: + content: + application/json: + schema: + type: object + properties: + reason: + type: string + description: |- + Optional reason to be included as the `reason` on the subsequent + membership event. + example: Looking for support + required: true + responses: + "200": + description: |- + The room has been knocked upon. + + The knocked room ID must be returned in the `room_id` field. + content: + application/json: + schema: + type: object + properties: + room_id: + type: string + description: The knocked room ID. + format: mx-room-id + pattern: "^!" + required: + - room_id + examples: + response: + value: { + "room_id": "!d41d8cd:matrix.org" + } + "403": + description: |- + You do not have permission to knock on the room. A meaningful `errcode` + and description error text will be returned. Example reasons for rejection are: + + - The room is not set up for knocking. + - The user has been banned from the room. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You are not allowed to knock on this room." + } + "404": + description: The room could not be found or resolved to a room ID. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "That room does not appear to exist." + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Room membership +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/leaving.yaml b/data/api/client-server/leaving.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ae94651e56252cde2b5b66b581ba253000b8ae99 --- /dev/null +++ b/data/api/client-server/leaving.yaml @@ -0,0 +1,163 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Room Leaving API + version: 1.0.0 +paths: + "/rooms/{roomId}/leave": + post: + summary: Stop the requesting user participating in a particular room. + x-changedInMatrixVersion: + "1.18": |- + Servers may additionally forget the room provided that they make this behavior + transparent. + description: |- + This API stops a user participating in a particular room. + + If the user was already in the room, they will no longer be able to see + new events in the room. If the room requires an invite to join, they + will need to be re-invited before they can re-join. + + If the user was invited to the room, but had not joined, this call + serves to reject the invite. + + Servers MAY additionally forget the room when this endpoint is called – + just as if the user had also invoked [`/forget`](/client-server-api/#post_taperclientv3roomsroomidforget). + Servers that do this, MUST inform clients about this behavior using the + [`t.forget_forced_upon_leave`](/client-server-api/#lforget_forced_upon_leave-capability) + capability. + + If the server doesn't automatically forget the room, the user will still be + allowed to retrieve history from the room which they were previously allowed + to see. + operationId: leaveRoom + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room identifier to leave. + required: true + example: "!nkl290a:matrix.org" + schema: + type: string + format: mx-room-id + pattern: "^!" + requestBody: + content: + application/json: + schema: + type: object + example: { + "reason": "Saying farewell - thanks for the support!" + } + properties: + reason: + x-addedInMatrixVersion: "1.1" + type: string + description: |- + Optional reason to be included as the `reason` on the subsequent + membership event. + required: true + responses: + "200": + description: The room has been left. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Room membership + "/rooms/{roomId}/forget": + post: + summary: Stop the requesting user remembering about a particular room. + description: |- + This API stops a user remembering about a particular room. + + In general, history is a first class citizen in Taper. After this API + is called, however, a user will no longer be able to retrieve history + for this room. If all users on a homeserver forget a room, the room is + eligible for deletion from that homeserver. + + If the user is currently joined to the room, they must leave the room + before calling this API. + operationId: forgetRoom + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room identifier to forget. + required: true + example: "!au1ba7o:matrix.org" + schema: + type: string + format: mx-room-id + pattern: "^!" + responses: + "200": + description: The room has been forgotten. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "400": + description: The user has not left the room + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNKNOWN", + "error": "User @example:matrix.org is in room !au1ba7o:matrix.org" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Room membership +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/list_joined_rooms.yaml b/data/api/client-server/list_joined_rooms.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c19f81e1b7a5e171dd235563eff4f1da2dce72ff --- /dev/null +++ b/data/api/client-server/list_joined_rooms.yaml @@ -0,0 +1,67 @@ +# Copyright 2017 Michael Telatynski <7t3chguy@gmail.com> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Room Listing API + version: 1.0.0 +paths: + /joined_rooms: + get: + summary: Lists the user's current rooms. + description: This API returns a list of the user's current rooms. + operationId: getJoinedRooms + security: + - accessTokenBearer: [] + responses: + "200": + description: A list of the rooms the user is in. + content: + application/json: + schema: + type: object + required: + - joined_rooms + properties: + joined_rooms: + type: array + description: The ID of each room in which the user has `joined` membership. + items: + type: string + format: mx-room-id + pattern: "^!" + examples: + response: + value: { + "joined_rooms": [ + "!foo:example.com" + ] + } + tags: + - Room membership +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/list_public_rooms.yaml b/data/api/client-server/list_public_rooms.yaml new file mode 100644 index 0000000000000000000000000000000000000000..903587c23d9073c27e81702be26cf70cb4a1d5b7 --- /dev/null +++ b/data/api/client-server/list_public_rooms.yaml @@ -0,0 +1,290 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Published Room Directory API + version: 1.0.0 +paths: + "/directory/list/room/{roomId}": + get: + summary: Gets the visibility of a room in the directory + description: |- + Gets the visibility of a given room in the server's + published room directory. + operationId: getRoomVisibilityOnDirectory + parameters: + - in: path + name: roomId + description: The room ID. + required: true + example: "!curbf:matrix.org" + schema: + type: string + format: mx-room-id + pattern: "^!" + responses: + "200": + description: The visibility of the room in the directory. + content: + application/json: + schema: + type: object + properties: + visibility: + type: string + enum: + - private + - public + description: The visibility of the room in the directory. + examples: + response: + value: { + "visibility": "public" + } + "404": + description: The room is not known to the server. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Room not found" + } + tags: + - Room discovery + put: + summary: Sets the visibility of a room in the directory + description: |- + Sets the visibility of a given room in the server's published room directory. + + Servers MAY implement additional access control checks, for instance, + to ensure that a room's visibility can only be changed by the room creator + or a server administrator. + operationId: setRoomVisibilityOnDirectory + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room ID. + required: true + example: "!curbf:matrix.org" + schema: + type: string + format: mx-room-id + pattern: "^!" + requestBody: + content: + application/json: + schema: + type: object + properties: + visibility: + type: string + enum: + - private + - public + description: |- + The new visibility setting for the room. + Defaults to `public`. + example: { + "visibility": "public" + } + description: The new visibility for the room in the published room directory. + required: true + responses: + "200": + description: The visibility was updated, or no change was needed. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "404": + description: The room is not known to the server. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Room not found" + } + tags: + - Room discovery + /publicRooms: + get: + summary: Lists a server's published room directory + description: |- + Lists a server's published room directory. + + This API returns paginated responses. + + {{% changed-in v="1.19" %}} The server determines the order of the rooms + returned by this endpoint. Previously, rooms were ordered with the largest + joined member count first. Continuing to order by largest first or another + stable order is recommended. + operationId: getPublicRooms + parameters: + - in: query + name: limit + description: Limit the number of results returned. + schema: + type: integer + - in: query + name: since + description: |- + A pagination token from a previous request, allowing clients to + get the next (or previous) batch of rooms. + The direction of pagination is specified solely by which token + is supplied, rather than via an explicit flag. + schema: + type: string + - in: query + name: server + description: |- + The server to fetch the published room directory from. Defaults + to the local server. Case sensitive. + schema: + type: string + format: mx-server-name + responses: + "200": + description: A list of the published rooms on the server. + content: + application/json: + schema: + $ref: definitions/public_rooms_response.yaml + tags: + - Room discovery + post: + summary: Lists a server's published room directory with an optional filter + description: |- + Lists a server's published room directory with an optional filter. + + This API returns paginated responses. + + {{% changed-in v="1.19" %}} The server determines the order of the rooms + returned by this endpoint. Previously, rooms were ordered with the largest + joined member count first. Continuing to order by largest first or another + stable order is recommended. + operationId: queryPublicRooms + security: + - accessTokenBearer: [] + parameters: + - in: query + name: server + description: |- + The server to fetch the published room directory from. Defaults + to the local server. Case sensitive. + schema: + type: string + format: mx-server-name + requestBody: + content: + application/json: + schema: + type: object + properties: + limit: + type: integer + description: Limit the number of results returned. + since: + type: string + description: |- + A pagination token from a previous request, allowing clients + to get the next (or previous) batch of rooms. The direction + of pagination is specified solely by which token is supplied, + rather than via an explicit flag. + filter: + type: object + title: Filter + description: Filter to apply to the results. + properties: + generic_search_term: + type: string + description: |- + An optional string to search for in the room metadata, e.g. name, + topic, canonical alias, etc. + room_types: + type: array + x-addedInMatrixVersion: "1.4" + items: + type: ["string", "null"] + description: |- + An optional list of [room types](/client-server-api/#types) to search + for. To include rooms without a room type, specify `null` within this + list. When not specified, all applicable rooms (regardless of type) + are returned. + include_all_networks: + type: boolean + description: |- + Whether or not to include all known networks/protocols from + application services on the homeserver. Defaults to `false`. + example: false + third_party_instance_id: + type: string + description: |- + The specific third-party network/protocol to request from the + homeserver. Can only be used if `include_all_networks` is false. + + This is the `instance_id` of a `Protocol Instance` returned by + [`GET /_taper/client/v3/thirdparty/protocols`](/client-server-api/#get_taperclientv3thirdpartyprotocols). + example: irc + example: { + "limit": 10, + "filter": { + "generic_search_term": "foo", + "room_types": [ + null, + "t.space" + ] + }, + "include_all_networks": false, + "third_party_instance_id": "irc-freenode" + } + description: Options for which rooms to return. + required: true + responses: + "200": + description: A filtered list of the published rooms on the server. + content: + application/json: + schema: + $ref: definitions/public_rooms_response.yaml + tags: + - Room discovery +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/login.yaml b/data/api/client-server/login.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2e36e01f75135a8bbb38afe51d2e404ac9ac56b4 --- /dev/null +++ b/data/api/client-server/login.yaml @@ -0,0 +1,315 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2018 New Vector Ltd +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Registration and Login API + version: 1.0.0 +paths: + /login: + get: + summary: Get the supported login types to authenticate users + description: |- + Gets the homeserver's supported login types to authenticate users. Clients + should pick one of these and supply it as the `type` when logging in. + operationId: getLoginFlows + responses: + "200": + description: The login types the homeserver supports + content: + application/json: + schema: + type: object + properties: + flows: + type: array + description: The homeserver's supported login types + items: + type: object + title: LoginFlow + required: + - type + properties: + type: + description: |- + The login type. This is supplied as the `type` when + logging in. + type: string + get_login_token: + type: boolean + x-addedInMatrixVersion: "1.7" + description: |- + If `type` is `t.login.token`, an optional field to indicate + to the unauthenticated client that the homeserver supports + the [`POST /login/get_token`](/client-server-api/#post_taperclientv1loginget_token) + endpoint. Note that supporting the endpoint does not + necessarily indicate that the user attempting to log in will + be able to generate such a token. + examples: + response: + value: { + "flows": [ + { + "type": "t.login.password" + }, + { + "type": "t.login.token", + "get_login_token": true + } + ] + } + "404": + description: |- + With `T_UNRECOGNIZED`: the homeserver does not support the legacy authentication API. + (See [Authentication API discovery](/client-server-api/#authentication-api-discovery).) + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: + { + "errcode": "T_UNRECOGNIZED", + "error": "OAuth 2.0 authentication is in use on this homeserver.", + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Session management + post: + summary: Authenticates the user. + description: |- + Authenticates the user, and issues an access token they can + use to authorise themself in subsequent requests. + + If the client does not supply a `device_id`, the server must + auto-generate one. + + The returned access token must be associated with the `device_id` + supplied by the client or generated by the server. The server may + invalidate any access token previously associated with that device. See + [Relationship between access tokens and devices](/client-server-api/#relationship-between-access-tokens-and-devices). + operationId: login + requestBody: + content: + application/json: + schema: + type: object + example: { + "type": "t.login.password", + "identifier": { + "type": "t.id.user", + "user": "cheeky_monkey" + }, + "password": "ilovebananas", + "initial_device_display_name": "Jungle Phone" + } + properties: + type: + type: string + description: |- + The login type being used. + + This must be a type returned in one of the flows of the + response of the [`GET /login`](/client-server-api/#get_taperclientv3login) + endpoint, like `t.login.password` or `t.login.token`. + identifier: + $ref: definitions/user_identifier.yaml + user: + type: string + deprecated: true + description: The fully qualified user ID or just local part of the user ID, to + log in. Deprecated in favour of `identifier`. + medium: + type: string + deprecated: true + description: When logging in using a third-party identifier, the medium of the + identifier. Must be 'email'. Deprecated in favour of + `identifier`. + address: + type: string + deprecated: true + description: Third-party identifier for the user. Deprecated in favour of + `identifier`. + password: + type: string + description: |- + Required when `type` is `t.login.password`. The user's + password. + token: + type: string + description: Required when `type` is `t.login.token`. Part of Token-based login. + device_id: + type: string + description: |- + ID of the client device. If this does not correspond to a + known client device, a new device will be created. The given + device ID must not be the same as a + [cross-signing](/client-server-api/#cross-signing) key ID. + The server will auto-generate a `device_id` + if this is not specified. + initial_device_display_name: + type: string + description: |- + A display name to assign to the newly-created device. Ignored + if `device_id` corresponds to a known device. + refresh_token: + type: boolean + description: If true, the client supports refresh tokens. + x-addedInMatrixVersion: "1.3" + required: + - type + required: true + responses: + "200": + description: The user has been authenticated. + content: + application/json: + schema: + type: object + properties: + user_id: + type: string + format: mx-user-id + pattern: "^@" + description: The fully-qualified Taper ID for the account. + access_token: + type: string + description: |- + An access token for the account. + This access token can then be used to authorise other requests. + refresh_token: + type: string + description: |- + A refresh token for the account. This token can be used to + obtain a new access token when it expires by calling the + `/refresh` endpoint. + x-addedInMatrixVersion: "1.3" + expires_in_ms: + type: integer + description: |- + The lifetime of the access token, in milliseconds. Once + the access token has expired a new access token can be + obtained by using the provided refresh token. If no + refresh token is provided, the client will need to re-log in + to obtain a new access token. If not given, the client can + assume that the access token will not expire. + x-addedInMatrixVersion: "1.3" + home_server: + type: string + format: mx-server-name + deprecated: true + description: |- + The server_name of the homeserver on which the account has + been registered. + + **Deprecated**. Clients should extract the server_name from + `user_id` (by splitting at the first colon) if they require + it. Note also that `homeserver` is not spelt this way. + device_id: + type: string + description: |- + ID of the logged-in device. Will be the same as the + corresponding parameter in the request, if one was specified. + well_known: + description: |- + Optional client configuration provided by the server. If present, + clients SHOULD use the provided object to reconfigure themselves, + optionally validating the URLs within. This object takes the same + form as the one returned from .well-known autodiscovery. + allOf: + - $ref: definitions/wellknown/full.yaml + required: + - access_token + - device_id + - user_id + examples: + response: + value: { + "user_id": "@cheeky_monkey:matrix.org", + "access_token": "abc123", + "refresh_token": "def456", + "expires_in_ms": 60000, + "device_id": "GHTYAJCE", + "well_known": { + "t.gateway": { + "urls": ["wss://example.org/Kx9vQ2mPZr4LwT8yHn3bVc1D"] + }, + "t.identity_server": { + "base_url": "https://id.example.org" + } + } + } + "400": + description: |- + Part of the request was invalid. For example, the login type may not be recognised. + + Specific error codes used with this status code include: + * {{% added-in v="1.17" %}} `T_APPSERVICE_LOGIN_UNSUPPORTED`: an application service + used the `t.login.application_service` type, but the server doesn't support logging + in via the Legacy authentication API. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNKNOWN", + "error": "Bad login type." + } + "403": + description: |- + The login attempt failed. This can include one of the following error codes: + * `T_FORBIDDEN`: The provided authentication data was incorrect + or the requested device ID is the same as a cross-signing key + ID. + * `T_USER_DEACTIVATED`: The user has been deactivated. + Servers MAY instead use `T_FORBIDDEN` when they can no longer authenticate + the deactivated user (e.g. their password has been wiped). + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Session management +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 diff --git a/data/api/client-server/login_token.yaml b/data/api/client-server/login_token.yaml new file mode 100644 index 0000000000000000000000000000000000000000..997f4b53a78f6764f85788ea4fc4c9335cfbc8ef --- /dev/null +++ b/data/api/client-server/login_token.yaml @@ -0,0 +1,135 @@ +# Copyright 2023 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Registration and Login API + version: 1.0.0 +paths: + /login/get_token: + post: + summary: Optional endpoint to generate a single-use, time-limited, + `t.login.token` token. + description: |- + Optional endpoint - the server is not required to implement this endpoint if it does not + intend to use or support this functionality. + + This API endpoint uses the [User-Interactive Authentication API](/client-server-api/#user-interactive-authentication-api). + + An already-authenticated client can call this endpoint to generate a single-use, time-limited, + token for an unauthenticated client to log in with, becoming logged in as the same user which + called this endpoint. The unauthenticated client uses the generated token in a `t.login.token` + login flow with the homeserver. + + Clients, both authenticated and unauthenticated, might wish to hide user interface which exposes + this feature if the server is not offering it. Authenticated clients can check for support on + a per-user basis with the [`t.get_login_token`](/client-server-api/#lget_login_token-capability) capability, + while unauthenticated clients can detect server support by looking for an `t.login.token` login + flow with `get_login_token: true` on [`GET /login`](/client-server-api/#post_taperclientv3login). + + In v1.7 of the specification, transmission of the generated token to an unauthenticated client is + left as an implementation detail. Future MSCs such as [MSC3906](https://github.com/matrix-org/matrix-spec-proposals/pull/3906) + might standardise a way to transmit the token between clients. + + The generated token MUST only be valid for a single login, enforced by the server. Clients which + intend to log in multiple devices must generate a token for each. + + With other User-Interactive Authentication (UIA)-supporting endpoints, servers sometimes do not re-prompt + for verification if the session recently passed UIA. For this endpoint, servers MUST always re-prompt + the user for verification to ensure explicit consent is gained for each additional client. + + Servers are encouraged to apply stricter than normal rate limiting to this endpoint, such as maximum + of 1 request per minute. + operationId: generateLoginToken + x-addedInMatrixVersion: "1.7" + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + auth: + description: Additional authentication information for the user-interactive + authentication API. + allOf: + - $ref: definitions/auth_data.yaml + required: true + responses: + "200": + description: The login token an unauthenticated client can use to log in as the + requesting user. + content: + application/json: + schema: + type: object + required: + - login_token + - expires_in_ms + properties: + login_token: + type: string + description: The login token for the `t.login.token` login flow. + expires_in_ms: + type: integer + description: |- + The time remaining in milliseconds until the homeserver will no longer accept the token. `120000` + (2 minutes) is recommended as a default. + examples: + response: + value: { + "login_token": "", + "expires_in_ms": 120000 + } + "400": + description: |- + The request was malformed, or the user does not have an ability to generate tokens for their devices, + as implied by the [User-Interactive Authentication API](/client-server-api/#user-interactive-authentication-api). + + Clients should verify whether the user has an ability to call this endpoint with the + [`t.get_login_token`](/client-server-api/#lget_login_token-capability) capability. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + "401": + description: The homeserver requires additional authentication information. + content: + application/json: + schema: + $ref: definitions/auth_response.yaml + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Session management +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v1 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/logout.yaml b/data/api/client-server/logout.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c3f2ee0036440aa936ca0c77da46d3ceb99f7f4a --- /dev/null +++ b/data/api/client-server/logout.yaml @@ -0,0 +1,82 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Registration and Login API + version: 1.0.0 +paths: + /logout: + post: + summary: Invalidates a user access token + description: |- + Invalidates an existing access token, so that it can no longer be used for + authorisation. The device associated with the access token is also deleted. + [Device keys](/client-server-api/#device-keys) for the device are deleted alongside the device. + operationId: logout + security: + - accessTokenBearer: [] + responses: + "200": + description: The access token used in the request was successfully invalidated. + content: + application/json: + schema: + type: object + properties: {} + tags: + - Session management + /logout/all: + post: + summary: Invalidates all access tokens for a user + description: |- + Invalidates all access tokens for a user, so that they can no longer be used for + authorisation. This includes the access token that made this request. All devices + for the user are also deleted. [Device keys](/client-server-api/#device-keys) for the device are + deleted alongside the device. + + This endpoint does not use the [User-Interactive Authentication API](/client-server-api/#user-interactive-authentication-api) because + User-Interactive Authentication is designed to protect against attacks where + someone gets hold of a single access token then takes over the account. This + endpoint invalidates all access tokens for the user, including the token used in + the request, and therefore the attacker is unable to take over the account in + this way. + operationId: logout_all + security: + - accessTokenBearer: [] + responses: + "200": + description: The user's access tokens were successfully invalidated. + content: + application/json: + schema: + type: object + properties: {} + tags: + - Session management +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/message_pagination.yaml b/data/api/client-server/message_pagination.yaml new file mode 100644 index 0000000000000000000000000000000000000000..65b3e28eefd7226dccb389964218ede0c5cb261a --- /dev/null +++ b/data/api/client-server/message_pagination.yaml @@ -0,0 +1,191 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Rooms API + version: 1.0.0 +paths: + "/rooms/{roomId}/messages": + get: + summary: Get a list of events for this room + description: |- + This API returns a list of message and state events for a room. It uses + pagination query parameters to paginate history in the room. + + *Note*: This endpoint supports lazy-loading of room member events. See + [Lazy-loading room members](/client-server-api/#lazy-loading-room-members) for more information. + operationId: getRoomEvents + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room to get events from. + required: true + example: "!636q39766251:example.com" + schema: + type: string + format: mx-room-id + pattern: "^!" + - in: query + name: from + x-changedInMatrixVersion: + "1.3": | + Previously, this field was required and paginating from the first or + last visible event in the room history wasn't supported. + description: |- + The token to start returning events from. This token can be obtained + from a `prev_batch` or `next_batch` token returned by the `/sync` endpoint, + or from an `end` token returned by a previous request to this endpoint. + + This endpoint can also accept a value returned as a `start` token + by a previous request to this endpoint, though servers are not + required to support this. Clients should not rely on the behaviour. + + If it is not provided, the homeserver shall return a list of messages + from the first or last (per the value of the `dir` parameter) visible + event in the room history for the requesting user. + required: false + example: s345_678_333 + schema: + type: string + - in: query + name: to + description: |- + The token to stop returning events at. This token can be obtained from + a `prev_batch` or `next_batch` token returned by the `/sync` endpoint, + or from an `end` token returned by a previous request to this endpoint. + required: false + schema: + type: string + - in: query + name: dir + description: |- + The direction to return events from. If this is set to `f`, events + will be returned in chronological order starting at `from`. If it + is set to `b`, events will be returned in *reverse* chronological + order, again starting at `from`. + required: true + example: b + schema: + type: string + enum: + - b + - f + - in: query + name: limit + description: "The maximum number of events to return. Default: 10." + example: 3 + schema: + type: integer + - in: query + name: filter + description: A JSON RoomEventFilter to filter returned events with. + example: '{"contains_url":true}' + schema: + type: string + responses: + "200": + description: A list of messages with a new token to request more. + content: + application/json: + schema: + type: object + description: A list of messages with a new token to request more. + properties: + start: + type: string + description: |- + A token corresponding to the start of `chunk`. This will be the same as + the value given in `from`. + end: + type: string + description: |- + A token corresponding to the end of `chunk`. This token can be passed + back to this endpoint to request further events. + + If no further events are available (either because we have + reached the start of the timeline, or because the user does + not have permission to see any more events), this property + is omitted from the response. + chunk: + type: array + description: |- + A list of room events. The order depends on the `dir` parameter. + For `dir=b` events will be in reverse-chronological order, + for `dir=f` in chronological order. (The exact definition of `chronological` + is dependent on the server implementation.) + + Note that an empty `chunk` does not *necessarily* imply that no more events + are available. Clients should continue to paginate until no `end` property + is returned. + items: + $ref: definitions/client_event.yaml + state: + type: array + description: |- + A list of state events relevant to showing the `chunk`. For example, if + `lazy_load_members` is enabled in the filter then this may contain + the membership events for the senders of events in the `chunk`. + + Unless `include_redundant_members` is `true`, the server + may remove membership events which would have already been + sent to the client in prior calls to this endpoint, assuming + the membership of those members has not changed. + items: + $ref: definitions/client_event.yaml + required: + - start + - chunk + examples: + response: + value: { + "start": "t47429-4392820_219380_26003_2265", + "end": "t47409-4357353_219380_26003_2265", + "chunk": [ + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.message$t.text.yaml" + }, + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.name.yaml" + }, + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.message$t.video.yaml" + } + ] + } + "403": + description: | + You aren't a member of the room. + tags: + - Room participation +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/mutual_rooms.yaml b/data/api/client-server/mutual_rooms.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ac647690ee451f3fd6d8e8ca7bb7e2aa63a03c9d --- /dev/null +++ b/data/api/client-server/mutual_rooms.yaml @@ -0,0 +1,124 @@ +# Copyright 2026 Logan Devine +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Mutual Rooms API + version: 1.0.0 +paths: + /mutual_rooms: + get: + summary: Get the list of rooms that the user shares with another user. + description: |- + Get the list of rooms that the user shares with another user. The + server will return a list of room IDs that the user shares with the + specified `user_id`. + operationId: getMutualRooms + security: + - accessTokenBearer: [] + parameters: + - in: query + name: user_id + required: true + description: The MXID of the user to check for mutual rooms with. + example: "@alice:example.com" + schema: + type: string + format: mx-user-id + pattern: "^@" + - in: query + name: from + required: false + description: |- + A pagination token from a previous result. This should be a `next_batch` result from + a previous call to this endpoint. If not provided, the server will return the first + batch of results. + example: next_batch_token + schema: + type: string + responses: + "200": + description: |- + A list of room IDs that the user shares with the specified user. + If the provided `user_id` is not a valid user, the server MUST return an empty list of rooms. + content: + application/json: + schema: + type: object + required: + - joined + - count + properties: + joined: + type: array + description: |- + A list of room IDs where both the authenticated user and `user_id` have a + membership of type `join`. + items: + type: string + format: mx-room-id + pattern: "^!" + example: "!OGEhHVWSdvArJzumhm:matrix.org" + count: + type: integer + description: |- + The number of such rooms. This is the total count even if the response is + batched and `joined` doesn't include all rooms. This MAY be inaccurate + if the server is unable to calculate the exact number of rooms. + example: 1 + next_batch: + type: string + description: |- + A pagination token to retrieve the next batch of results. This will be absent + if there are no more results to return. + example: next_batch_token + + "400": + description: |- + Part of the request was invalid. The `from` token provided was invalid or expired, + the `user_id` parameter was missing, [non-compliant](/appendices/#historical-user-ids), + or was the sender's own user ID. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "The user ID provided was invalid" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Mutual Rooms +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v1 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/notifications.yaml b/data/api/client-server/notifications.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f11f9c7c1db448b0467b724510239b895526271b --- /dev/null +++ b/data/api/client-server/notifications.yaml @@ -0,0 +1,149 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Notifications API + version: 1.0.0 +paths: + /notifications: + get: + summary: Gets a list of events that the user has been notified about + description: |- + This API is used to paginate through the list of events that the + user has been, or would have been notified about. + operationId: getNotifications + security: + - accessTokenBearer: [] + parameters: + - in: query + name: from + description: |- + Pagination token to continue from. This should be the `next_token` + returned from an earlier call to this endpoint. + required: false + example: xxxxx + schema: + type: string + - in: query + name: limit + description: Limit on the number of events to return in this request. + required: false + example: 20 + schema: + type: integer + - in: query + name: only + description: |- + Allows basic filtering of events returned. Supply `highlight` + to return only events where the notification had the highlight + tweak set. + required: false + example: highlight + schema: + type: string + responses: + "200": + description: A batch of events is being returned + content: + application/json: + schema: + type: object + required: + - notifications + properties: + next_token: + type: string + description: |- + The token to supply in the `from` param of the next + `/notifications` request in order to request more + events. If this is absent, there are no more results. + notifications: + type: array + items: + type: object + required: + - actions + - event + - read + - room_id + - ts + title: Notification + properties: + actions: + type: array + description: |- + The action(s) to perform when the conditions for this rule are met. + See [Push Rules: API](/client-server-api/#push-rules-api). + items: + type: ["object", "string"] + event: + title: Event + description: The Event object for the event that triggered the notification. + allOf: + - $ref: definitions/client_event_without_room_id.yaml + profile_tag: + type: string + description: The profile tag of the rule that matched this event. + read: + type: boolean + description: |- + Indicates whether the user has sent a read receipt indicating + that they have read this message. + room_id: + type: string + description: The ID of the room in which the event was posted. + ts: + type: integer + format: int64 + description: |- + The unix timestamp at which the event notification was sent, + in milliseconds. + description: The list of events that triggered notifications. + examples: + response: + value: { + "next_token": "abcdef", + "notifications": [ + { + "actions": [ + "notify" + ], + "profile_tag": "hcbvkzxhcvb", + "read": true, + "room_id": "!abcdefg:example.com", + "ts": 1475508881945, + "event": { + "$ref": "../../event-schemas/examples/t.room.message$t.text.yaml" + } + } + ] + } + tags: + - Push notifications +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/oauth_server_metadata.yaml b/data/api/client-server/oauth_server_metadata.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e3e15e233e2e67457aa11311b5eb1b5ba97c971b --- /dev/null +++ b/data/api/client-server/oauth_server_metadata.yaml @@ -0,0 +1,238 @@ +# Copyright 2025 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server OAuth 2.0 Server Metadata Discovery API + version: 1.0.0 +paths: + "/auth_metadata": + get: + summary: Get the OAuth 2.0 authorisation server metadata. + description: |- + Gets the OAuth 2.0 authorisation server metadata, as defined in + [RFC 8414](https://datatracker.ietf.org/doc/html/rfc8414), including the + endpoint URLs and the supported parameters that can be used by the + clients. + + This endpoint definition includes only the fields that are meaningful in + the context of the Taper specification. The full list of possible + fields is available in the [OAuth Authorisation Server Metadata + registry](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#authorization-server-metadata), + and normative definitions of them are available in their respective + RFCs. + + {{% boxes/note %}} + The authorisation server metadata is relatively large and may change + over time. Clients should: + + - Cache the metadata appropriately based on HTTP caching headers + - Refetch the metadata if it is stale + {{% /boxes/note %}} + operationId: getAuthMetadata + responses: + "200": + description: The OAuth 2.0 authorisation server metadata. + content: + application/json: + schema: + type: object + properties: + issuer: + type: string + format: uri + description: |- + The authorisation server's issuer identifier, which is a URL that uses the + `https` scheme and has no query or fragment components. + + This is not used in the context of the Taper specification, but is required + by [RFC 8414](https://datatracker.ietf.org/doc/html/rfc8414). + authorization_endpoint: + type: string + format: uri + description: |- + URL of the authorisation endpoint, necessary to use the authorisation code + grant. + token_endpoint: + type: string + format: uri + description: |- + URL of the token endpoint, used by the grants. + revocation_endpoint: + type: string + format: uri + description: |- + URL of the revocation endpoint, necessary to log out a client by invalidating + its access and refresh tokens. + registration_endpoint: + type: string + format: uri + description: |- + URL of the client registration endpoint, necessary to perform dynamic + registration of a client. + response_types_supported: + type: array + description: |- + List of OAuth 2.0 response type strings that the server supports at the + authorisation endpoint. + + This array MUST contain at least the `code` value, for clients to be able to + use the authorisation code grant. + items: + type: string + description: A response type that the server supports. + grant_types_supported: + type: array + description: |- + List of OAuth 2.0 grant type strings that the server supports at the token + endpoint. + + This array MUST contain at least the `authorization_code` and `refresh_token` + values, for clients to be able to use the authorisation code grant and refresh + token grant, respectively. + + {{% added-in v="1.18" %}} It MAY also contain + `urn:ietf:params:oauth:grant-type:device_code` to indicate support for the + [device authorisation grant](/client-server-api/#device-authorisation-grant). + items: + type: string + description: A grant type that the server supports. + response_modes_supported: + type: array + description: |- + List of OAuth 2.0 response mode strings that the server supports at the + authorisation endpoint. + + This array MUST contain at least the `query` and `fragment` values, for + improved security in the authorisation code grant. + items: + type: string + description: A response mode that the server supports. + code_challenge_methods_supported: + type: array + description: |- + List of OAuth 2.0 Proof Key for Code Exchange (PKCE) code challenge methods + that the server supports at the authorisation endpoint. + + This array MUST contain at least the `S256` value, for improved security in + the authorisation code grant. + items: + type: string + description: A PKCE code challenge method that the server supports. + prompt_values_supported: + type: array + description: |- + List of OpenID Connect prompt values that the server supports at the + authorisation endpoint. + + Only the `create` value defined in [Initiating User Registration via OpenID + Connect](https://openid.net/specs/openid-connect-prompt-create-1_0.html) is + supported, for a client to signal to the server that the user desires to + register a new account. + items: + type: string + description: A prompt value that the server supports. + account_management_uri: + x-addedInMatrixVersion: "1.18" + type: string + format: uri + description: |- + The URL where the user is able to access the account management capabilities + of the homeserver. + + This is an extension [defined in this specification](/client-server-api/#oauth-20-account-management). + account_management_actions_supported: + x-addedInMatrixVersion: "1.18" + type: array + description: |- + List of actions that the account management URL supports. + + This is an extension [defined in this specification](/client-server-api/#oauth-20-account-management). + items: + type: string + enum: + - "org.matrix.profile" + - "org.matrix.devices_list" + - "org.matrix.device_view" + - "org.matrix.device_delete" + - "org.matrix.account_deactivate" + - "org.matrix.cross_signing_reset" + description: An action that the account management URL supports. + device_authorization_endpoint: + x-addedInMatrixVersion: "1.18" + type: string + format: uri + description: |- + URL of the device authorisation endpoint, as defined in + [RFC 8628](https://datatracker.ietf.org/doc/html/rfc8628), necessary to use + the [device authorisation grant](/client-server-api/#device-authorisation-grant). + required: + - issuer + - authorization_endpoint + - token_endpoint + - revocation_endpoint + - registration_endpoint + - response_types_supported + - grant_types_supported + - response_modes_supported + - code_challenge_methods_supported + example: { + "issuer": "https://account.example.com/", + "authorization_endpoint": "https://account.example.com/oauth2/auth", + "token_endpoint": "https://account.example.com/oauth2/token", + "registration_endpoint": "https://account.example.com/oauth2/clients/register", + "device_authorization_endpoint": "https://account.example.com/oauth2/device", + "revocation_endpoint": "https://account.example.com/oauth2/revoke", + "response_types_supported": ["code"], + "grant_types_supported": ["authorization_code", "refresh_token", "urn:ietf:params:oauth:grant-type:device_code"], + "response_modes_supported": ["query", "fragment"], + "code_challenge_methods_supported": ["S256"], + "account_management_uri": "https://account.example.com/manage", + "account_management_actions_supported": [ + "org.matrix.profile", + "org.matrix.devices_list", + "org.matrix.device_view", + "org.matrix.device_delete", + "org.matrix.account_deactivate", + "org.matrix.cross_signing_reset", + ], + } + "404": + description: |- + With `T_UNRECOGNIZED`: the homeserver does not support the OAuth 2.0 API. + (See [Authentication API discovery](/client-server-api/#authentication-api-discovery).) + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: + { + "errcode": "T_UNRECOGNIZED", + "error": "Legacy authentication is in use on this homeserver.", + } + tags: + - Session management +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v1 diff --git a/data/api/client-server/old_sync.yaml b/data/api/client-server/old_sync.yaml new file mode 100644 index 0000000000000000000000000000000000000000..31e9c40220b87a304037ad0b955d6bc80ba82c24 --- /dev/null +++ b/data/api/client-server/old_sync.yaml @@ -0,0 +1,374 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Sync API + version: 1.0.0 +paths: + /events: + get: + summary: Listen on the event stream. + description: |- + This will listen for new events and return them to the caller. This will + block until an event is received, or until the `timeout` is reached. + + This endpoint was deprecated in r0 of this specification. Clients + should instead call the [`/sync`](/client-server-api/#get_taperclientv3sync) + endpoint with a `since` parameter. See + the [migration guide](https://matrix.org/docs/guides/migrating-from-client-server-api-v-1#deprecated-endpoints). + operationId: getEvents + security: + - accessTokenBearer: [] + parameters: + - in: query + name: from + description: |- + The token to stream from. This token is either from a previous + request to this API or from the initial sync API. + required: false + example: s3456_9_0 + schema: + type: string + - in: query + name: timeout + description: The maximum time in milliseconds to wait for an event. + required: false + example: 35000 + schema: + type: integer + responses: + "200": + description: The events received, which may be none. + content: + application/json: + schema: + type: object + properties: + start: + type: string + description: |- + A token which correlates to the start of `chunk`. This + is usually the same token supplied to `from=`. + end: + type: string + description: |- + A token which correlates to the end of `chunk`. This + token should be used in the next request to `/events`. + chunk: + type: array + description: An array of events. + items: + $ref: definitions/client_event.yaml + examples: + response: + value: { + "start": "s3456_9_0", + "end": "s3457_9_0", + "chunk": [ + { + "$ref": "../../event-schemas/examples/t.room.message$t.text.yaml" + } + ] + } + "400": + description: Bad pagination `from` parameter. + tags: + - Room participation + deprecated: true + /initialSync: + get: + summary: Get the user's current state. + description: |- + This returns the full state for this user, with an optional limit on the + number of messages per room to return. + + This endpoint was deprecated in r0 of this specification. Clients + should instead call the [`/sync`](/client-server-api/#get_taperclientv3sync) + endpoint with no `since` parameter. See + the [migration guide](https://matrix.org/docs/guides/migrating-from-client-server-api-v-1#deprecated-endpoints). + operationId: initialSync + security: + - accessTokenBearer: [] + parameters: + - in: query + name: limit + description: The maximum number of messages to return for each room. + required: false + example: 2 + schema: + type: integer + - in: query + name: archived + description: |- + Whether to include rooms that the user has left. If `false` then + only rooms that the user has been invited to or has joined are + included. If set to `true` then rooms that the user has left are + included as well. By default this is `false`. + required: false + example: true + schema: + type: boolean + responses: + "200": + description: The user's current state. + content: + application/json: + schema: + type: object + properties: + end: + type: string + description: |- + A token which correlates to the end of the timelines returned. This + token should be used with the `/events` endpoint to listen for new + events. + presence: + type: array + description: A list of presence events. + items: + $ref: ../../event-schemas/schema/core-event-schema/event.yaml + rooms: + type: array + items: + type: object + title: RoomInfo + properties: + room_id: + type: string + format: mx-room-id + pattern: "^!" + description: The ID of this room. + membership: + type: string + description: The user's membership state in this room. + enum: + - invite + - join + - leave + - ban + invite: + type: object + title: InviteEvent + description: The invite event if `membership` is `invite` + allOf: + - $ref: definitions/client_event.yaml + messages: + type: object + title: PaginationChunk + description: The pagination chunk for this room. + properties: + start: + type: string + description: |- + A token which correlates to the start of `chunk`. + Can be passed to + [`/rooms//messages`](/client-server-api/#get_taperclientv3roomsroomidmessages) + to retrieve earlier events. + + If no earlier events are available, this property may be omitted from + the response. + end: + type: string + description: |- + A token which correlates to the end of `chunk`. + Can be passed to + [`/rooms//messages`](/client-server-api/#get_taperclientv3roomsroomidmessages) + to retrieve later events. + chunk: + type: array + description: |- + If the user is a member of the room this will be a + list of the most recent messages for this room. If + the user has left the room this will be the + messages that preceded them leaving. This array + will consist of at most `limit` elements. + items: + $ref: definitions/client_event.yaml + required: + - end + - chunk + state: + type: array + description: |- + If the user is a member of the room this will be the + current state of the room as a list of events. If the + user has left the room this will be the state of the + room when they left it. + items: + $ref: definitions/client_event.yaml + visibility: + type: string + enum: + - private + - public + description: |- + Whether this room is visible to the `/publicRooms` API + or not. + account_data: + type: array + description: |- + The private data that this user has attached to + this room. + items: + $ref: ../../event-schemas/schema/core-event-schema/event.yaml + required: + - room_id + - membership + account_data: + type: array + description: The global private data created by this user. + items: + $ref: ../../event-schemas/schema/core-event-schema/event.yaml + required: + - end + - rooms + - presence + examples: + response: + value: { + "end": "s3456_9_0", + "presence": [ + { + "$ref": "../../event-schemas/examples/t.presence.yaml" + } + ], + "account_data": [ + { + "type": "org.example.custom.config", + "content": { + "custom_config_key": "custom_config_value" + } + } + ], + "rooms": [ + { + "membership": "join", + "messages": { + "chunk": [ + { + "room_id": "!TmaZBKYIFrIPVGoUYp:localhost", + "$ref": "../../event-schemas/examples/t.room.message$t.text.yaml" + }, + { + "room_id": "!TmaZBKYIFrIPVGoUYp:localhost", + "$ref": "../../event-schemas/examples/t.room.message$t.video.yaml" + } + ], + "end": "s3456_9_0", + "start": "t44-3453_9_0" + }, + "room_id": "!TmaZBKYIFrIPVGoUYp:localhost", + "state": [ + { + "room_id": "!TmaZBKYIFrIPVGoUYp:localhost", + "$ref": "../../event-schemas/examples/t.room.join_rules.yaml" + }, + { + "room_id": "!TmaZBKYIFrIPVGoUYp:localhost", + "$ref": "../../event-schemas/examples/t.room.member.yaml" + }, + { + "room_id": "!TmaZBKYIFrIPVGoUYp:localhost", + "$ref": "../../event-schemas/examples/t.room.create.yaml" + }, + { + "room_id": "!TmaZBKYIFrIPVGoUYp:localhost", + "$ref": "../../event-schemas/examples/t.room.power_levels.yaml" + } + ], + "visibility": "private", + "account_data": [ + { + "type": "t.tag", + "content": { + "tags": { + "work": { + "order": 1 + } + } + } + }, + { + "type": "org.example.custom.room.config", + "content": { + "custom_config_key": "custom_config_value" + } + } + ] + } + ] + } + "404": + description: There is no avatar URL for this user or this user does not exist. + tags: + - Room participation + deprecated: true + "/events/{eventId}": + get: + summary: Get a single event by event ID. + description: |- + Get a single event based on `event_id`. You must have permission to + retrieve this event e.g. by being a member in the room for this event. + + This endpoint was deprecated in r0 of this specification. Clients + should instead call the + [/rooms/{roomId}/event/{eventId}](/client-server-api/#get_taperclientv3roomsroomideventeventid) API + or the [/rooms/{roomId}/context/{eventId}](/client-server-api/#get_taperclientv3roomsroomidcontexteventid) API. + operationId: getOneEvent + security: + - accessTokenBearer: [] + parameters: + - in: path + name: eventId + description: The event ID to get. + required: true + example: $asfDuShaf7Gafaw:matrix.org + schema: + type: string + format: mx-event-id + pattern: "^\\$" + responses: + "200": + description: The full event. + content: + application/json: + schema: + $ref: definitions/client_event.yaml + examples: + response: + value: { + "$ref": "../../event-schemas/examples/t.room.message$t.text.yaml" + } + "404": + description: The event was not found or you do not have permission to read this + event. + tags: + - Room participation + deprecated: true +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/openid.yaml b/data/api/client-server/openid.yaml new file mode 100644 index 0000000000000000000000000000000000000000..55c456727632cee340decbef3f80e2792ad9d060 --- /dev/null +++ b/data/api/client-server/openid.yaml @@ -0,0 +1,95 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server OpenID API + version: 1.0.0 +paths: + "/user/{userId}/openid/request_token": + post: + summary: Get an OpenID token object to verify the requester's identity. + description: |- + Gets an OpenID token object that the requester may supply to another + service to verify their identity in Taper. The generated token is only + valid for exchanging for user information from the + [federation API for OpenID](/server-server-api/#get_taperfederationv1openiduserinfo). + + The access token generated is only valid for the OpenID API. It cannot + be used to request another OpenID access token or call `/sync`, for + example. + operationId: requestOpenIdToken + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + description: |- + The user to request an OpenID token for. Should be the user who + is authenticated for the request. + required: true + example: "@alice:example.com" + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + example: {} + description: An empty object. Reserved for future expansion. + required: true + responses: + "200": + description: |- + OpenID token information. This response is nearly compatible with the + response documented in the + [OpenID Connect 1.0 Specification](http://openid.net/specs/openid-connect-core-1_0.html#TokenResponse) + with the only difference being the lack of an `id_token`. Instead, + the Taper homeserver's name is provided. + content: + application/json: + schema: + $ref: definitions/openid_token.yaml + examples: + response: + value: { + "access_token": "SomeT0kenHere", + "token_type": "Bearer", + "matrix_server_name": "example.com", + "expires_in": 3600 + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - OpenID +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/password_management.yaml b/data/api/client-server/password_management.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4ba7625b5121234ef7a7649b6bf59113bc84ec1e --- /dev/null +++ b/data/api/client-server/password_management.yaml @@ -0,0 +1,243 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Password Management API + version: 1.0.0 +paths: + /account/password: + post: + summary: Changes a user's password. + description: |- + Changes the password for an account on this homeserver. + + This API endpoint uses the [User-Interactive Authentication API](/client-server-api/#user-interactive-authentication-api) to + ensure the user changing the password is actually the owner of the + account. + + An access token should be submitted to this endpoint if the client has + an active session. + + The homeserver may change the flows available depending on whether a + valid access token is provided. The homeserver SHOULD NOT revoke the + access token provided in the request. Whether other access tokens for + the user are revoked depends on the request parameters. + + This endpoint uses [capabilities negotiation](/client-server-api/#capabilities-negotiation). + Clients SHOULD check the value of the [`t.change_password` capability](/client-server-api/#lchange_password-capability) + to determine if this endpoint is available. + security: + - {} + - accessTokenBearer: [] + operationId: changePassword + requestBody: + content: + application/json: + schema: + type: object + properties: + new_password: + type: string + description: The new password for the account. + example: ihatebananas + logout_devices: + type: boolean + description: |- + Whether the user's other access tokens, and their associated devices, should be + revoked if the request succeeds. Defaults to `true`. + + When `false`, the server can still take advantage of the [soft logout method](/client-server-api/#soft-logout) + for the user's remaining devices. + example: true + auth: + description: Additional authentication information for the user-interactive + authentication API. + allOf: + - $ref: definitions/auth_data.yaml + required: + - new_password + required: true + responses: + "200": + description: The password has been changed. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "401": + description: The homeserver requires additional authentication information. + content: + application/json: + schema: + $ref: definitions/auth_response.yaml + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Account management + /account/password/email/requestToken: + post: + summary: Requests a validation token be sent to the given email address for the + purpose of resetting a user's password + description: |- + The homeserver must check that the given email address **is + associated** with an account on this homeserver. This API should be + used to request validation tokens when authenticating for the + `/account/password` endpoint. + + This API's parameters and response are identical to that of the + [`/register/email/requestToken`](/client-server-api/#post_taperclientv3registeremailrequesttoken) + endpoint, except that + `T_THREEPID_NOT_FOUND` may be returned if no account matching the + given email address could be found. The server may instead send an + email to the given address prompting the user to create an account. + `T_THREEPID_IN_USE` may not be returned. + + The homeserver should validate the email itself, either by sending a + validation email itself or by using a service it has control over. + operationId: requestTokenToResetPasswordEmail + requestBody: + content: + application/json: + schema: + $ref: definitions/request_email_validation.yaml + required: true + responses: + "200": + description: An email was sent to the given address. + content: + application/json: + schema: + $ref: definitions/request_token_response.yaml + "400": + description: |- + The referenced third-party identifier is not recognised by the + homeserver, or the request was invalid. The error code `T_SERVER_NOT_TRUSTED` + can be returned if the server does not trust/support the identity server + provided in the request. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_THREEPID_NOT_FOUND", + "error": "Email not found" + } + "403": + description: |- + The homeserver does not allow the third-party identifier as a + contact option. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_THREEPID_DENIED", + "error": "Third-party identifier is not allowed" + } + tags: + - Account management + /account/password/msisdn/requestToken: + post: + summary: Requests a validation token be sent to the given phone number for the + purpose of resetting a user's password. + description: |- + The homeserver must check that the given phone number **is + associated** with an account on this homeserver. This API should be + used to request validation tokens when authenticating for the + `/account/password` endpoint. + + This API's parameters and response are identical to that of the + [`/register/msisdn/requestToken`](/client-server-api/#post_taperclientv3registermsisdnrequesttoken) + endpoint, except that + `T_THREEPID_NOT_FOUND` may be returned if no account matching the + given phone number could be found. The server may instead send the SMS + to the given phone number prompting the user to create an account. + `T_THREEPID_IN_USE` may not be returned. + + The homeserver should validate the phone number itself, either by sending a + validation message itself or by using a service it has control over. + operationId: requestTokenToResetPasswordMSISDN + requestBody: + content: + application/json: + schema: + $ref: definitions/request_msisdn_validation.yaml + required: true + responses: + "200": + description: An SMS message was sent to the given phone number. + content: + application/json: + schema: + $ref: definitions/request_token_response.yaml + "400": + description: |- + The referenced third-party identifier is not recognised by the + homeserver, or the request was invalid. The error code `T_SERVER_NOT_TRUSTED` + can be returned if the server does not trust/support the identity server + provided in the request. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_THREEPID_NOT_FOUND", + "error": "Phone number not found" + } + "403": + description: |- + The homeserver does not allow the third-party identifier as a + contact option. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_THREEPID_DENIED", + "error": "Third-party identifier is not allowed" + } + tags: + - Account management +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/peeking_events.yaml b/data/api/client-server/peeking_events.yaml new file mode 100644 index 0000000000000000000000000000000000000000..350efe6a1c52fade0e310e4d7cb868923edb0490 --- /dev/null +++ b/data/api/client-server/peeking_events.yaml @@ -0,0 +1,119 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Sync Guest API + version: 1.0.0 +paths: + # With an extra " " to disambiguate from the getEvents endpoint + # The extra space makes it sort first for what I'm sure is a good reason. + "/events ": + get: + summary: Listen on the event stream of a particular room. + description: |- + This will listen for new events related to a particular room and return + them to the caller. This will block until an event is received, or until + the `timeout` is reached. + + This API is the same as the normal `/events` endpoint, but can be + called by users who have not joined the room. + + Note that the normal `/events` endpoint has been deprecated. This + API will also be deprecated at some point, but its replacement is not + yet known. + operationId: peekEvents + security: + - accessTokenBearer: [] + parameters: + - in: query + name: from + description: |- + The token to stream from. This token is either from a previous + request to this API or from the initial sync API. + required: false + example: s3456_9_0 + schema: + type: string + - in: query + name: timeout + description: The maximum time in milliseconds to wait for an event. + required: false + example: 35000 + schema: + type: integer + - in: query + name: room_id + description: The room ID for which events should be returned. + example: "!somewhere:over.the.rainbow" + schema: + type: string + required: true + responses: + "200": + description: The events received, which may be none. + content: + application/json: + schema: + type: object + properties: + start: + type: string + description: |- + A token which correlates to the first value in `chunk`. This + is usually the same token supplied to `from=`. + end: + type: string + description: |- + A token which correlates to the last value in `chunk`. This + token should be used in the next request to `/events`. + chunk: + type: array + description: An array of events. + items: + type: object + title: Event + allOf: + - $ref: definitions/client_event.yaml + examples: + response: + value: { + "start": "s3456_9_0", + "end": "s3457_9_0", + "chunk": [ + { + "room_id": "!somewhere:over.the.rainbow", + "$ref": "../../event-schemas/examples/t.room.message$t.text.yaml" + } + ] + } + "400": + description: Bad pagination `from` parameter. + tags: + - Room participation +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/policy_server.yaml b/data/api/client-server/policy_server.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f3c614429370ec951bbbaac756a4b8b4bde25402 --- /dev/null +++ b/data/api/client-server/policy_server.yaml @@ -0,0 +1,82 @@ +# Copyright 2026 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Policy Server Discovery API + version: 1.0.0 +paths: + /matrix/policy_server: + get: + summary: Gets information about a Policy Server's configuration, if available. + description: |- + Gets public key information for a [Policy Server](/client-server-api/#policy-servers). + + {{% boxes/note %}} + Like the [well-known discovery URI](/client-server-api/#well-known-uris), + this endpoint should be accessed with the hostname of the Policy Server's + [server name](/appendices/#server-name) by making a + GET request to `https://hostname/.well-known/taper/policy_server`. + {{% /boxes/note %}} + + Note that this endpoint is not necessarily handled by the homeserver or + Policy Server. It may be served by another webserver. + operationId: getWellknownPolicy + x-addedInMatrixVersion: "1.18" + responses: + "200": + description: |- + Public keys for the Policy Server. Can be supplied to the [`t.room.policy`](/client-server-api/#lroompolicy) + state event. + content: + application/json: + schema: + type: object + properties: + public_keys: + type: object + description: |- + The unpadded base64-encoded public keys for the Policy Server. MUST contain + at least `ed25519`. + properties: + ed25519: + type: string + description: The unpadded base64-encoded ed25519 public key for the Policy Server. + required: ['ed25519'] + additionalProperties: + type: string + description: The unpadded base64-encoded public key for the key algorithm. + required: ["public_keys"] + examples: + response: + value: + { + "public_keys": { + "ed25519": "6yhHGKhCiXTSEN2ksjV7kX/N6rBQZ3Xb+M7LlC6NS+s" + } + } + "404": + description: No policy server information available. + tags: + - Server administration +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /.well-known diff --git a/data/api/client-server/presence.yaml b/data/api/client-server/presence.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3b1c20ec6036b532cf64ffb2ad71b8738f1a5c66 --- /dev/null +++ b/data/api/client-server/presence.yaml @@ -0,0 +1,165 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Presence API + version: 1.0.0 +paths: + "/presence/{userId}/status": + put: + summary: Update this user's presence state. + description: |- + This API sets the given user's presence state. When setting the status, + the activity time is updated to reflect that activity; the client does + not need to specify the `last_active_ago` field. You cannot set the + presence state of another user. + operationId: setPresence + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + description: The user whose presence state to update. + required: true + example: "@alice:example.com" + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + example: { + "presence": "online", + "status_msg": "I am here." + } + properties: + presence: + type: string + enum: + - online + - offline + - unavailable + description: The new presence state. + status_msg: + type: string + description: The status message to attach to this state. + required: + - presence + description: The updated presence state. + required: true + responses: + "200": + description: The new presence state was set. + content: + application/json: + schema: + type: object # empty json object + examples: + response: + value: {} + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Presence + get: + summary: Get this user's presence state. + description: Get the given user's presence state. + operationId: getPresence + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + description: The user whose presence state to get. + required: true + example: "@alice:example.com" + schema: + type: string + responses: + "200": + description: The presence state for this user. + content: + application/json: + schema: + type: object + properties: + presence: + type: string + enum: + - online + - offline + - unavailable + description: This user's presence. + last_active_ago: + type: integer + description: |- + The length of time in milliseconds since an action was performed + by this user. + status_msg: + description: The state message for this user if one was set. + type: ["string", "null"] + currently_active: + type: boolean + description: Whether the user is currently active + required: + - presence + examples: + response: + value: { + "presence": "unavailable", + "last_active_ago": 420845 + } + "403": + description: You are not allowed to see this user's presence status. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You are not allowed to see their presence" + } + "404": + description: |- + There is no presence state for this user. This user may not exist or + isn't exposing presence information to you. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + tags: + - Presence +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/profile.yaml b/data/api/client-server/profile.yaml new file mode 100644 index 0000000000000000000000000000000000000000..70fa1785f4624a9e24813a070aeb33413797b723 --- /dev/null +++ b/data/api/client-server/profile.yaml @@ -0,0 +1,370 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Profile API + version: 1.0.0 +paths: + "/profile/{userId}/{keyName}": + put: + x-changedInMatrixVersion: + "1.16": This endpoint now accepts a variable `keyName` parameter and `t.tz` was added as a defined key. Previously only `displayname` and `avatar_url` were accepted. + summary: Set a profile field for a user. + description: |- + Set or update a profile field for a user. Must be authenticated with an + access token authorised to make changes. Servers MAY impose size limits + on individual fields, and the total profile MUST be under 64 KiB. + + Servers MAY reject `null` values. Servers that accept `null` values SHOULD store + them rather than treating `null` as a deletion request. Clients that want to delete a + field, including its key and value, SHOULD use the `DELETE` endpoint instead. + + This endpoint uses [capabilities negotiation](/client-server-api/#capabilities-negotiation) + depending on the `keyName`. Clients SHOULD check the value of the + [`t.profile_fields` capability](/client-server-api/#lprofile_fields-capability) to detect + which `keyName`s they are allowed to modify. + operationId: setProfileField + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + description: The user whose profile field should be set. + required: true + example: "@alice:example.com" + schema: + type: string + format: mx-user-id + pattern: "^@" + - in: path + name: keyName + description: The name of the profile field to set. This MUST be either + `avatar_url`, `displayname`, `t.tz`, or a custom field following the + [Common Namespaced Identifier Grammar](/appendices/#common-namespaced-identifier-grammar). + required: true + example: "displayname" + schema: + type: string + pattern: '^(avatar_url|displayname|m\.tz|[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+)$' + requestBody: + description: A JSON object containing the property whose name matches + the `keyName` specified in the URL. See `additionalProperties` for + further details. + required: true + content: + application/json: + schema: + type: object + minProperties: 1 + description: | + An object which contains exactly one property. The key + of that property MUST match the `keyName` specified in the URL. + + For `avatar_url`, the value MUST be a runit URI string. + + For `displayname`, the value MUST be a string. + + For `t.tz`, the value MUST be a valid identifier from the [IANA Time Zone Database](https://www.iana.org/time-zones). + Servers MAY choose to validate the value. Clients MUST expect unknown or invalid + values. + + For custom keys, any JSON type is allowed. Servers MAY not validate + these values, but clients SHOULD follow the format defined for that key. + additionalProperties: true + example: { "displayname": "Alice Wonderland" } + responses: + "200": + description: The profile field was set. + content: + application/json: + schema: + type: object # empty JSON object + examples: + response: + value: {} + "400": + description: | + The input was invalid in some way. This can include one + of the following error codes: + + - `T_BAD_JSON`: The provided value is not valid JSON. + - `T_MISSING_PARAM`: The required `keyName` property is + missing from the request body. + - `T_PROFILE_TOO_LARGE`: Storing the supplied value would + make the profile exceed its maximum allowed size of 64 KiB. + - `T_KEY_TOO_LARGE`: The supplied profile key exceeds the + maximum allowed key length of 255 bytes. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + bad_json: + value: + { + "errcode": "T_BAD_JSON", + "error": "Malformed JSON payload.", + } + invalid_key: + value: + { + "errcode": "T_INVALID_PARAM", + "error": "Invalid profile key.", + } + "403": + description: The server is unwilling to perform the operation, either + due to insufficient permissions or because profile modifications + are disabled. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + forbidden: + value: + { + "errcode": "T_FORBIDDEN", + "error": "Profile modification is not permitted.", + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - User data + get: + x-changedInMatrixVersion: + "1.16": This endpoint now accepts a variable `keyName` parameter and `t.tz` was added as a defined key. Previously only `displayname` and `avatar_url` were accepted. + summary: Get a profile field for a user. + description: Get the value of a profile field for a user. + operationId: getProfileField + parameters: + - in: path + name: userId + description: The user whose profile field should be returned. + required: true + example: "@alice:example.com" + schema: + type: string + format: mx-user-id + pattern: "^@" + - in: path + name: keyName + description: The name of the profile field to retrieve. + required: true + example: "displayname" + schema: + type: string + pattern: '^(avatar_url|displayname|m\.tz|[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+)$' + responses: + "200": + description: The profile field value was retrieved. + content: + application/json: + schema: + type: object + description: | + An object with one property, whose key matches the `keyName` specified + in the URL, and whose value is the current setting of that profile field. + additionalProperties: true + examples: + response: + value: { "displayname": "Alice" } + "403": + x-addedInMatrixVersion: "1.12" + description: The server is unwilling to disclose whether the user + exists and/or has the specified profile field. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: + { + "errcode": "T_FORBIDDEN", + "error": "Profile lookup is disabled on this homeserver", + } + "404": + description: There is no profile field with this key for this user, or + the user does not exist. + tags: + - User data + delete: + x-addedInMatrixVersion: "1.16" + summary: Remove a profile field from a user. + description: Remove a specific field from a user's profile. + operationId: deleteProfileField + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + description: The user whose profile field should be deleted. + required: true + example: "@alice:example.com" + schema: + type: string + format: mx-user-id + pattern: "^@" + - in: path + name: keyName + description: The name of the profile field to delete. + required: true + example: "displayname" + schema: + type: string + pattern: '^(avatar_url|displayname|m\.tz|[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+)$' + responses: + "200": + description: The profile field was deleted or it doesn't exist. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "400": + description: The request is malformed, contains invalid JSON, or + specifies an invalid key. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + bad_json: + value: + { "errcode": "T_BAD_JSON", "error": "Malformed request." } + invalid_key: + value: + { + "errcode": "T_INVALID_PARAM", + "error": "Invalid profile key.", + } + "403": + description: The user is not authorised to delete this profile field. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + forbidden: + value: + { + "errcode": "T_FORBIDDEN", + "error": "Profile deletion is not permitted.", + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - User data + "/profile/{userId}": + get: + summary: Get all profile information for a user. + description: |- + Get the complete profile for a user. + operationId: getUserProfile + parameters: + - in: path + name: userId + description: The user whose profile information to get. + required: true + example: "@alice:example.com" + schema: + type: string + format: mx-user-id + pattern: "^@" + responses: + "200": + description: The profile information for this user. + content: + application/json: + schema: + type: object + properties: + avatar_url: + type: string + format: mx-runit-uri + description: The user's avatar URL if they have set one, otherwise not present. + displayname: + type: string + description: The user's display name if they have set one, otherwise not + present. + t.tz: + x-addedInMatrixVersion: "1.16" + type: string + description: The user's time zone. + additionalProperties: + x-addedInMatrixVersion: "1.16" + description: Additional profile fields. + examples: + response: + value: + { + "avatar_url": "runit://matrix.org/SDGdghriugerRg", + "displayname": "Alice Margatroid", + "t.tz": "Europe/London", + "t.example_field": "custom_value", + } + "403": + x-addedInMatrixVersion: "1.2" + description: The server is unwilling to disclose whether the user + exists and/or has profile information. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: + { + "errcode": "T_FORBIDDEN", + "error": "Profile lookup is disabled on this homeserver", + } + "404": + description: There is no profile information for this user or this + user does not exist. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: + { "errcode": "T_NOT_FOUND", "error": "Profile not found" } + tags: + - User data +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/pusher.yaml b/data/api/client-server/pusher.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ee032b0c56fd96787e3ed73ff34cbe935d1afe00 --- /dev/null +++ b/data/api/client-server/pusher.yaml @@ -0,0 +1,299 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Push API + version: 1.0.0 +paths: + /pushers: + get: + summary: Gets the current pushers for the authenticated user + description: Gets all currently active pushers for the authenticated user. + operationId: getPushers + security: + - accessTokenBearer: [] + responses: + "200": + description: The pushers for this user. + content: + application/json: + schema: + type: object + properties: + pushers: + type: array + title: Pushers + description: An array containing the current pushers for the user + items: + type: object + title: Pusher + properties: + pushkey: + type: string + description: |- + This is a unique identifier for this pusher. See `/set` for + more detail. + Max length, 512 bytes. + kind: + type: string + description: |- + The kind of pusher. `"http"` is a pusher that + sends HTTP pokes. + app_id: + type: string + description: |- + This is a reverse-DNS style identifier for the application. + Max length, 64 chars. + app_display_name: + type: string + description: |- + A string that will allow the user to identify what application + owns this pusher. + device_display_name: + type: string + description: |- + A string that will allow the user to identify what device owns + this pusher. + profile_tag: + type: string + description: |- + This string determines which set of device specific rules this + pusher executes. + lang: + type: string + description: |- + The preferred language for receiving notifications (e.g. 'en' + or 'en-US') + data: + type: object + description: |- + A dictionary of information for the pusher implementation + itself. + title: PusherData + properties: + url: + type: string + format: uri + description: |- + Required if `kind` is `http`. The URL to use to send + notifications to. + format: + type: string + description: |- + The format to use when sending notifications to the Push + Gateway. + required: + - pushkey + - app_id + - kind + - app_display_name + - device_display_name + - lang + - data + examples: + response: + value: { + "pushers": [ + { + "pushkey": "Xp/MzCt8/9DcSNE9cuiaoT5Ac55job3TdLSSmtmYl4A=", + "kind": "http", + "app_id": "face.mcapp.appy.prod", + "app_display_name": "Appy McAppface", + "device_display_name": "Alice's Phone", + "profile_tag": "xyz", + "lang": "en-US", + "data": { + "url": "https://example.com/_taper/push/v1/notify" + } + } + ] + } + tags: + - Push notifications + /pushers/set: + post: + summary: Modify a pusher for this user on the homeserver. + description: |- + This endpoint allows the creation, modification and deletion of [pushers](/client-server-api/#push-notifications) + for this user ID. The behaviour of this endpoint varies depending on the + values in the JSON body. + + If `kind` is not `null`, the pusher with this `app_id` and `pushkey` + for this user is updated, or it is created if it doesn't exist. If + `kind` is `null`, the pusher with this `app_id` and `pushkey` for this + user is deleted. + operationId: postPusher + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + example: { + "lang": "en", + "kind": "http", + "app_display_name": "Mat Rix", + "device_display_name": "iPhone 9", + "profile_tag": "xxyyzz", + "app_id": "com.example.app.ios", + "pushkey": "APA91bHPRgkF3JUikC4ENAHEeMrd41Zxv3hVZjC9KtT8OvPVGJ-hQMRKRrZuJAEcl7B338qju59zJMjw2DELjzEvxwYv7hH5Ynpc1ODQ0aT4U4OFEeco8ohsN5PjL1iC2dNtk2BAokeMCg2ZXKqpc8FXKmhX94kIxQ", + "data": { + "url": "https://push-gateway.location.here/_taper/push/v1/notify", + "format": "event_id_only" + }, + "append": false + } + properties: + pushkey: + type: string + description: |- + This is a unique identifier for this pusher. The value you + should use for this is the routing or destination address + information for the notification, for example, the APNS token + for APNS or the Registration ID for GCM. If your notification + client has no such concept, use any unique identifier. + Max length, 512 bytes. + + If the `kind` is `"email"`, this is the email address to + send notifications to. + kind: + description: |- + The kind of pusher to configure. `"http"` makes a pusher that + sends HTTP pokes. `"email"` makes a pusher that emails the + user with unread notifications. `null` deletes the pusher. + type: ["string", "null"] + app_id: + type: string + description: |- + This is a reverse-DNS style identifier for the application. + It is recommended that this end with the platform, such that + different platform versions get different app identifiers. + Max length, 64 chars. + + If the `kind` is `"email"`, this is `"t.email"`. + app_display_name: + type: string + description: |- + Required if `kind` is not `null`. A string that will allow the + user to identify what application owns this pusher. + device_display_name: + type: string + description: |- + Required if `kind` is not `null`. A string that will allow the + user to identify what device owns this pusher. + profile_tag: + type: string + description: |- + This string determines which set of device specific rules this + pusher executes. + lang: + type: string + description: |- + Required if `kind` is not `null`. The preferred language for + receiving notifications (e.g. 'en' or 'en-US'). + data: + type: object + description: |- + Required if `kind` is not `null`. A dictionary of information + for the pusher implementation itself. + + If `kind` is `http`, this MUST contain `url` which is the URL + to use for sending notifications. Clients MAY use this object + to pass custom data to their push gateway. Servers MUST forward + the entire content including `format` and any custom keys but excluding `url` + when calling [`/_taper/push/v1/notify`](/push-gateway-api/#post_taperpushv1notify). + title: PusherData + properties: + url: + type: string + format: uri + description: |- + Required if `kind` is `http`. The URL to use for sending + notifications. MUST be an HTTPS URL with a path of + `/_taper/push/v1/notify`. + example: https://push-gateway.location.here/_taper/push/v1/notify + format: + type: string + description: |- + The format in which to send notifications to the push gateway + if the `kind` is `http`. The details about what fields the + homeserver should include are defined in the + [Push Gateway Specification](/push-gateway-api/). If omitted, + the server is expected to populate all of the event-related fields + specified in [`/_taper/push/v1/notify`](/push-gateway-api/#post_taperpushv1notify). + enum: + - "event_id_only" + append: + type: boolean + description: |- + If true, the homeserver should add another pusher with the + given pushkey and App ID in addition to any others with + different user IDs. Otherwise, the homeserver must remove any + other pushers with the same App ID and pushkey for different + users. The default is `false`. + required: + - kind + - app_id + - pushkey + description: The pusher information. + required: true + responses: + "200": + description: The pusher was set. + content: + application/json: + schema: + type: object + description: An empty object. + examples: + response: + value: {} + "400": + description: One or more of the pusher values were invalid. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "error": "Missing parameters: lang, data", + "errcode": "T_MISSING_PARAM" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Push notifications +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/pushrules.yaml b/data/api/client-server/pushrules.yaml new file mode 100644 index 0000000000000000000000000000000000000000..07ef04be6f506029a6c2be5b54aa197031c6b76f --- /dev/null +++ b/data/api/client-server/pushrules.yaml @@ -0,0 +1,622 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Push Rules API + version: 1.0.0 +paths: + /pushrules/: + get: + summary: Retrieve all push rulesets. + description: |- + Retrieve all push rulesets for this user. Currently the only push ruleset + defined is `global`. + operationId: getPushRules + security: + - accessTokenBearer: [] + responses: + "200": + description: All the push rulesets for this user. + content: + application/json: + schema: + type: object + required: + - global + properties: + global: + type: object + description: The global ruleset. + title: Ruleset + allOf: + - $ref: definitions/push_ruleset.yaml + tags: + - Push notifications + /pushrules/global/: + get: + summary: Retrieve all push rules. + description: |- + Retrieve all push rules for this user. + operationId: getPushRulesGlobal + security: + - accessTokenBearer: [] + responses: + "200": + description: All the push rules for this user. + content: + application/json: + schema: + $ref: definitions/push_ruleset.yaml + tags: + - Push notifications + "/pushrules/global/{kind}/{ruleId}": + get: + summary: Retrieve a push rule. + description: Retrieve a single specified push rule. + operationId: getPushRule + security: + - accessTokenBearer: [] + parameters: + - in: path + name: kind + required: true + description: | + The kind of rule + example: content + schema: + type: string + enum: + - override + - underride + - sender + - room + - content + - in: path + name: ruleId + required: true + description: | + The identifier for the rule. + example: nocake + schema: + type: string + responses: + "200": + description: |- + The specific push rule. This will also include keys specific to the + rule itself such as the rule's `actions` and `conditions` if set. + content: + application/json: + schema: + type: object + description: The push rule. + allOf: + - $ref: definitions/push_rule.yaml + examples: + response: + value: { + "actions": [], + "pattern": "cake*lie", + "rule_id": "nocake", + "enabled": true, + "default": false + } + "404": + description: The push rule does not exist. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "The push rule was not found." + } + tags: + - Push notifications + delete: + summary: Delete a push rule. + description: This endpoint removes the push rule defined in the path. + operationId: deletePushRule + security: + - accessTokenBearer: [] + parameters: + - in: path + name: kind + required: true + description: | + The kind of rule + example: content + schema: + type: string + enum: + - override + - underride + - sender + - room + - content + - in: path + name: ruleId + required: true + description: | + The identifier for the rule. + example: nocake + schema: + type: string + responses: + "200": + description: The push rule was deleted. + content: + application/json: + schema: + type: object # empty json object + examples: + response: + value: {} + "404": + description: The push rule does not exist. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "The push rule was not found." + } + tags: + - Push notifications + put: + summary: Add or change a push rule. + description: |- + This endpoint allows the creation and modification of user defined push + rules. + + If a rule with the same `rule_id` already exists among rules of the same + kind, it is updated with the new parameters, otherwise a new rule is + created. + + If both `after` and `before` are provided, the new or updated rule must + be the next most important rule with respect to the rule identified by + `before`. + + If neither `after` nor `before` are provided and the rule is created, it + should be added as the most important user defined rule among rules of + the same kind. + + When creating push rules, they MUST be enabled by default. + operationId: setPushRule + security: + - accessTokenBearer: [] + parameters: + - in: path + name: kind + required: true + description: | + The kind of rule + example: content + schema: + type: string + enum: + - override + - underride + - sender + - room + - content + - in: path + name: ruleId + required: true + description: | + The identifier for the rule. If the string starts with a dot ("."), + the request MUST be rejected as this is reserved for server-default + rules. Slashes ("/") and backslashes ("\\") are also not allowed. + example: nocake + schema: + type: string + - in: query + name: before + required: false + description: |- + Use 'before' with a `rule_id` as its value to make the new rule the + next-most important rule with respect to the given user defined rule. + It is not possible to add a rule relative to a predefined server rule. + example: someRuleId + schema: + type: string + - in: query + name: after + required: false + description: |- + This makes the new rule the next-less important rule relative to the + given user defined rule. It is not possible to add a rule relative + to a predefined server rule. + example: anotherRuleId + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + example: { + "pattern": "cake*lie", + "actions": [ + "notify" + ] + } + properties: + actions: + type: array + description: The action(s) to perform when the conditions for this rule are met. + items: + type: ["string", "object"] + conditions: + type: array + description: |- + The conditions that must hold true for an event in order for a + rule to be applied to an event. A rule with no conditions + always matches. Only applicable to `underride` and `override` rules. + items: + $ref: definitions/push_condition.yaml + pattern: + type: string + description: Only applicable to `content` rules. The glob-style pattern to match + against. + required: + - actions + description: |- + The push rule data. Additional top-level keys may be present depending + on the parameters for the rule `kind`. + required: true + responses: + "200": + description: The push rule was created/updated. + content: + application/json: + schema: + type: object # empty json object + examples: + response: + value: {} + "400": + description: There was a problem configuring this push rule. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "error": "before/after rule not found: someRuleId", + "errcode": "T_UNKNOWN" + } + "404": + description: The push rule does not exist (when updating a push rule). + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "The push rule was not found." + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Push notifications + "/pushrules/global/{kind}/{ruleId}/enabled": + get: + summary: Get whether a push rule is enabled + description: This endpoint gets whether the specified push rule is enabled. + operationId: isPushRuleEnabled + security: + - accessTokenBearer: [] + parameters: + - in: path + name: kind + required: true + description: | + The kind of rule + example: content + schema: + type: string + enum: + - override + - underride + - sender + - room + - content + - in: path + name: ruleId + required: true + description: | + The identifier for the rule. + example: nocake + schema: + type: string + responses: + "200": + description: Whether the push rule is enabled. + content: + application/json: + schema: + type: object + properties: + enabled: + type: boolean + description: Whether the push rule is enabled or not. + required: + - enabled + examples: + response: + value: { + "enabled": true + } + "404": + description: The push rule does not exist. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "The push rule was not found." + } + tags: + - Push notifications + put: + summary: Enable or disable a push rule. + description: This endpoint allows clients to enable or disable the specified + push rule. + operationId: setPushRuleEnabled + security: + - accessTokenBearer: [] + parameters: + - in: path + name: kind + required: true + description: | + The kind of rule + example: content + schema: + type: string + enum: + - override + - underride + - sender + - room + - content + - in: path + name: ruleId + required: true + description: | + The identifier for the rule. + example: nocake + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + enabled: + type: boolean + description: Whether the push rule is enabled or not. + required: + - enabled + example: { + "enabled": true + } + description: | + Whether the push rule is enabled or not. + required: true + responses: + "200": + description: The push rule was enabled or disabled. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "404": + description: The push rule does not exist. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "The push rule was not found." + } + tags: + - Push notifications + "/pushrules/global/{kind}/{ruleId}/actions": + get: + summary: The actions for a push rule + description: This endpoint get the actions for the specified push rule. + operationId: getPushRuleActions + security: + - accessTokenBearer: [] + parameters: + - in: path + name: kind + required: true + description: | + The kind of rule + example: content + schema: + type: string + enum: + - override + - underride + - sender + - room + - content + - in: path + name: ruleId + required: true + description: | + The identifier for the rule. + example: nocake + schema: + type: string + responses: + "200": + description: The actions for this push rule. + content: + application/json: + schema: + type: object + properties: + actions: + type: array + description: The action(s) to perform for this rule. + items: + type: ["string", "object"] + required: + - actions + examples: + response: + value: { + "actions": [ + "notify", + { + "set_tweak": "sound", + "value": "bing" + } + ] + } + "404": + description: The push rule does not exist. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "The push rule was not found." + } + tags: + - Push notifications + put: + summary: Set the actions for a push rule. + description: |- + This endpoint allows clients to change the actions of a push rule. + This can be used to change the actions of builtin rules. + operationId: setPushRuleActions + security: + - accessTokenBearer: [] + parameters: + - in: path + name: kind + required: true + description: | + The kind of rule + example: room + schema: + type: string + enum: + - override + - underride + - sender + - room + - content + - in: path + name: ruleId + required: true + description: | + The identifier for the rule. + example: "#spam:example.com" + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + actions: + type: array + description: The action(s) to perform for this rule. + items: + type: ["string", "object"] + required: + - actions + example: { + "actions": [ + "notify", + { + "set_tweak": "highlight" + } + ] + } + description: | + The action(s) to perform when the conditions for this rule are met. + required: true + responses: + "200": + description: The actions for the push rule were set. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "404": + description: The push rule does not exist. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "The push rule was not found." + } + tags: + - Push notifications +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/read_markers.yaml b/data/api/client-server/read_markers.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5642e2bdb8547d124938cda94e76f8aa7f3a0d8e --- /dev/null +++ b/data/api/client-server/read_markers.yaml @@ -0,0 +1,100 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Read Marker API + version: 1.0.0 +paths: + "/rooms/{roomId}/read_markers": + post: + summary: Set the position of the read marker for a room. + description: |- + Sets the position of the read marker for a given room, and optionally + the read receipt's location. + operationId: setReadMarker + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room ID to set the read marker in for the user. + required: true + example: "!somewhere:example.org" + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + t.fully_read: + type: string + description: |- + The event ID the read marker should be located at. The + event MUST belong to the room. + example: $somewhere:example.org + x-changedInMatrixVersion: + "1.4": | + This property is no longer required. + t.read: + type: string + description: |- + The event ID to set the read receipt location at. This is + equivalent to calling `/receipt/t.read/$elsewhere:example.org` + and is provided here to save that extra call. + example: $elsewhere:example.org + t.read.private: + x-addedInMatrixVersion: "1.4" + type: string + description: |- + The event ID to set the *private* read receipt location at. This + equivalent to calling `/receipt/t.read.private/$elsewhere:example.org` + and is provided here to save that extra call. + example: $elsewhere:example.org + description: The read marker and optional read receipt locations. + required: true + responses: + "200": + description: The read marker, and read receipt(s) if provided, have been updated. + content: + application/json: + schema: + type: object + properties: {} + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Read Markers +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/receipts.yaml b/data/api/client-server/receipts.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4b00a3070c0fe3070b13970fd5b5f3b81d4dd124 --- /dev/null +++ b/data/api/client-server/receipts.yaml @@ -0,0 +1,141 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Receipts API + version: 1.0.0 +paths: + "/rooms/{roomId}/receipt/{receiptType}/{eventId}": + post: + summary: Send a receipt for the given event ID. + description: |- + This API updates the marker for the given receipt type to the event ID + specified. + operationId: postReceipt + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room in which to send the event. + required: true + example: "!wefuh21ffskfuh345:example.com" + schema: + type: string + format: mx-room-id + pattern: "^!" + - in: path + name: receiptType + description: |- + The type of receipt to send. This can also be `t.fully_read` as an + alternative to [`/read_markers`](/client-server-api/#post_taperclientv3roomsroomidread_markers). + + Note that `t.fully_read` does not appear under `t.receipt`: this endpoint + effectively calls `/read_markers` internally when presented with a receipt + type of `t.fully_read`. + required: true + x-changedInMatrixVersion: + "1.4": | + Allow `t.read.private` receipts and `t.fully_read` markers to be set. + example: t.read + schema: + type: string + enum: + - t.read + - t.read.private + - t.fully_read + - in: path + name: eventId + description: The event ID to acknowledge up to. + required: true + example: $1924376522eioj:example.com + schema: + type: string + format: mx-event-id + pattern: "^\\$" + requestBody: + content: + application/json: + schema: + type: object + properties: + thread_id: + type: string + x-addedInMatrixVersion: "1.4" + description: |- + The [thread root](/client-server-api/#threading)'s + [event ID](/appendices#event-ids) (or `main`) for which + thread this receipt is intended to be under. If + not specified, the read receipt is *unthreaded* + (default). + example: { + "thread_id": "main" + } + description: |- + Extra receipt information to attach to `content` if any. The + server will automatically set the `ts` field. + required: true + responses: + "200": + description: The receipt was sent. + content: + application/json: + schema: + type: object + maxProperties: 0 # empty json object + examples: + response: + value: {} + "400": + description: |- + The `thread_id` is invalid in some way. For example: + * It is not a string. + * It is empty. + * It is provided for an incompatible receipt type. + * The `event_id` is not related to the `thread_id`. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "thread_id field must be a non-empty string" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Room participation +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/redaction.yaml b/data/api/client-server/redaction.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3cfec1b9478217f5274209f1172be0b50cfbb7c7 --- /dev/null +++ b/data/api/client-server/redaction.yaml @@ -0,0 +1,113 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server message redaction API + version: 1.0.0 +paths: + "/rooms/{roomId}/redact/{eventId}/{txnId}": + put: + summary: Strips all non-integrity-critical information out of an event. + description: |- + Strips all information out of an event which isn't critical to the + integrity of the server-side representation of the room. + + This cannot be undone. + + Any user with a power level greater than or equal to the `t.room.redaction` + event power level may send redactions for their own events in the room. If + the user's power level is also greater than or equal to the `redact` power + level of the room, the user may redact events sent by other users. + + Server administrators may redact events sent by users on their server. + operationId: redactEvent + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room from which to redact the event. + required: true + example: "!637q39766251:example.com" + schema: + type: string + format: mx-room-id + pattern: "^!" + - in: path + name: eventId + description: The ID of the event to redact. + required: true + example: $bai2b1i9:matrix.org + schema: + type: string + format: mx-event-id + pattern: "^\\$" + - in: path + name: txnId + description: |- + The [transaction ID](/client-server-api/#transaction-identifiers) for this event. Clients should generate a + unique ID; it will be used by the server to ensure idempotency of requests. + required: true + example: "37" + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + example: { + "reason": "Indecent material" + } + properties: + reason: + type: string + description: The reason for the event being redacted. + required: true + responses: + "200": + description: An ID for the redaction event. + content: + application/json: + schema: + type: object + properties: + event_id: + type: string + format: mx-event-id + pattern: "^\\$" + description: A unique identifier for the event. + examples: + response: + value: { + "event_id": "$YUwQidLecu:example.com" + } + tags: + - Room participation +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/refresh.yaml b/data/api/client-server/refresh.yaml new file mode 100644 index 0000000000000000000000000000000000000000..75445594c3674e14ae3f2171af6ec3a6b9561fdc --- /dev/null +++ b/data/api/client-server/refresh.yaml @@ -0,0 +1,119 @@ +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Registration and Login API + version: 1.0.0 +paths: + /refresh: + post: + x-addedInMatrixVersion: "1.3" + summary: Refresh an access token + description: |- + Refresh an access token. Clients should use the returned access token + when making subsequent API calls, and store the returned refresh token + (if given) in order to refresh the new access token when necessary. + + After an access token has been refreshed, a server can choose to + invalidate the old access token immediately, or can choose not to, for + example if the access token would expire soon anyways. Clients should + not make any assumptions about the old access token still being valid, + and should use the newly provided access token instead. + + The old refresh token remains valid until the new access token or refresh token + is used, at which point the old refresh token is revoked. + + Note that this endpoint does not require authentication via an + access token. Authentication is provided via the refresh token. + + Application Service identity assertion is disabled for this endpoint. + operationId: refresh + requestBody: + content: + application/json: + schema: + type: object + example: { + "refresh_token": "some_token" + } + properties: + refresh_token: + type: string + description: The refresh token + required: + - refresh_token + required: true + responses: + "200": + description: A new access token and refresh token were generated. + content: + application/json: + schema: + type: object + properties: + access_token: + type: string + description: The new access token to use. + refresh_token: + type: string + description: |- + The new refresh token to use when the access token needs to + be refreshed again. If not given, the old refresh token can + be re-used. + expires_in_ms: + type: integer + description: |- + The lifetime of the access token, in milliseconds. If not + given, the client can assume that the access token will not + expire. + required: + - access_token + examples: + response: + value: { + "access_token": "a_new_token", + "expires_in_ms": 60000, + "refresh_token": "another_new_token" + } + "401": + description: The provided token was unknown, or has already been used. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNKNOWN_TOKEN", + "error": "Soft logged out", + "soft_logout": true + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 diff --git a/data/api/client-server/registration.yaml b/data/api/client-server/registration.yaml new file mode 100644 index 0000000000000000000000000000000000000000..621822f55e68f1c88f17fd9aeb18644e8bd9fb28 --- /dev/null +++ b/data/api/client-server/registration.yaml @@ -0,0 +1,482 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Registration API + version: 1.0.0 +paths: + /register: + post: + summary: Register for an account on this homeserver. + description: |- + This API endpoint uses the [User-Interactive Authentication API](/client-server-api/#user-interactive-authentication-api), except in + the cases where a guest account is being registered. + + Register for an account on this homeserver. + + There are two kinds of user account: + + - `user` accounts. These accounts may use the full API described in this specification. + + - `guest` accounts. These accounts may have limited permissions and may not be supported by all servers. + + If registration is successful, this endpoint will issue an access token + the client can use to authorise itself in subsequent requests. + + If the client does not supply a `device_id`, the server must + auto-generate one. + + The server SHOULD register an account with a User ID based on the + `username` provided, if any. Note that the grammar of Taper User ID + localparts is restricted, so the server MUST either map the provided + `username` onto a `user_id` in a logical manner, or reject any + `username` which does not comply to the grammar with + `T_INVALID_USERNAME`. + + Taper clients MUST NOT assume that localpart of the registered + `user_id` matches the provided `username`. + + The returned access token must be associated with the `device_id` + supplied by the client or generated by the server. The server may + invalidate any access token previously associated with that device. See + [Relationship between access tokens and devices](/client-server-api/#relationship-between-access-tokens-and-devices). + + When registering a guest account, all parameters in the request body + with the exception of `initial_device_display_name` MUST BE ignored + by the server. The server MUST pick a `device_id` for the account + regardless of input. + + Any user ID returned by this API must conform to the grammar given in the + [Taper specification](/appendices/#user-identifiers). + + {{% boxes/note %}} + {{% added-in v="1.17" %}} + Even if the server doesn't support the Legacy authentication API, it + MUST support this endpoint for application services to be able to + [create users](/application-service-api/#server-admin-style-permissions). + + In that case application services MUST set the `"inhibit_login": true` + parameter as they cannot use it to log in as users. If the + `inhibit_login` parameter is not set to `true`, the server MUST return a + 400 HTTP status code with an `T_APPSERVICE_LOGIN_UNSUPPORTED` error code. + {{% /boxes/note %}} + + {{% boxes/warning %}} + {{% added-in v="1.18" %}} [OAuth 2.0 aware clients](/client-server-api/#oauth-20-aware-clients) + MUST NOT use this endpoint when the server offers the [`t.login.sso` + authentication flow](/client-server-api/#client-login-via-sso) with + `oauth_aware_preferred` set to `true`. Instead they MUST use the + [`/login/sso/redirect`](/client-server-api/#get_taperclientv3loginssoredirect) + endpoint, adding the `action=register` parameter. + {{% /boxes/warning %}} + operationId: register + parameters: + - in: query + name: kind + required: false + description: The kind of account to register. Defaults to `user`. + # swagger-UI overrides the default with the example, so better make the + # example the default. + example: user + schema: + type: string + enum: + - guest + - user + default: user + requestBody: + content: + application/json: + schema: + type: object + properties: + auth: + description: |- + Additional authentication information for the + user-interactive authentication API. Note that this + information is *not* used to define how the registered user + should be authenticated, but is instead used to + authenticate the `register` call itself. + allOf: + - $ref: definitions/auth_data.yaml + username: + type: string + description: |- + The basis for the localpart of the desired Taper ID. If omitted, + the homeserver MUST generate a Taper ID local part. + example: cheeky_monkey + password: + type: string + description: The desired password for the account. + example: ilovebananas + device_id: + type: string + description: |- + ID of the client device. If this does not correspond to a + known client device, a new device will be created. The server + will auto-generate a `device_id` if this is not specified. + example: GHTYAJCE + initial_device_display_name: + type: string + description: |- + A display name to assign to the newly-created device. Ignored + if `device_id` corresponds to a known device. + example: Jungle Phone + inhibit_login: + type: boolean + description: |- + If true, an `access_token` and `device_id` should not be + returned from this call, therefore preventing an automatic + login. Defaults to `false`. + example: false + refresh_token: + type: boolean + description: If `true`, the client supports refresh tokens. + x-addedInMatrixVersion: "1.3" + required: true + responses: + "200": + description: The account has been registered. + content: + application/json: + schema: + type: object + properties: + user_id: + type: string + format: mx-user-id + pattern: "^@" + description: |- + The fully-qualified Taper user ID (MXID) that has been registered. + + Any user ID returned by this API must conform to the grammar given in the + [Taper specification](/appendices/#user-identifiers). + access_token: + type: string + description: |- + An access token for the account. + This access token can then be used to authorise other requests. + Required if the `inhibit_login` option is false. + refresh_token: + type: string + description: |- + A refresh token for the account. This token can be used to + obtain a new access token when it expires by calling the + `/refresh` endpoint. + + Omitted if the `inhibit_login` option is true. + x-addedInMatrixVersion: "1.3" + expires_in_ms: + type: integer + description: |- + The lifetime of the access token, in milliseconds. Once + the access token has expired a new access token can be + obtained by using the provided refresh token. If no + refresh token is provided, the client will need to re-log in + to obtain a new access token. If not given, the client can + assume that the access token will not expire. + + Omitted if the `inhibit_login` option is true. + x-addedInMatrixVersion: "1.3" + home_server: + type: string + format: mx-server-name + deprecated: true + description: |- + The server_name of the homeserver on which the account has + been registered. + + **Deprecated**. Clients should extract the server_name from + `user_id` (by splitting at the first colon) if they require + it. Note also that `homeserver` is not spelt this way. + device_id: + type: string + description: |- + ID of the registered device. Will be the same as the + corresponding parameter in the request, if one was specified. + Required if the `inhibit_login` option is false. + required: + - user_id + examples: + response: + value: { + "user_id": "@cheeky_monkey:matrix.org", + "access_token": "abc123", + "device_id": "GHTYAJCE" + } + "400": + description: |- + Part of the request was invalid. This may include one of the following error codes: + + * `T_USER_IN_USE` : The desired user ID is already taken. + * `T_INVALID_USERNAME` : The desired user ID is not a valid user name. + * `T_EXCLUSIVE` : The desired user ID is in the exclusive namespace + claimed by an application service. + * {{% added-in v="1.17" %}} `T_APPSERVICE_LOGIN_UNSUPPORTED`: an application service + used the `t.login.application_service` type without setting `inhibit_login` to `true`, + but the server doesn't support logging in via the Legacy authentication API. + + These errors may be returned at any stage of the registration process, + including after authentication if the requested user ID was registered + whilst the client was performing authentication. + + Homeservers MUST perform the relevant checks and return these codes before + performing User-Interactive Authentication, although they may also return + them after authentication is completed if, for example, the requested user ID + was registered whilst the client was performing authentication. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_USER_IN_USE", + "error": "Desired user ID is already taken." + } + "401": + description: The homeserver requires additional authentication information. + content: + application/json: + schema: + $ref: definitions/auth_response.yaml + "403": + description: |- + The homeserver does not permit registering the account. This response + can be used to identify that a particular `kind` of account is not + allowed, or that registration is generally not supported by the homeserver. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Registration is disabled" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Account management + /register/email/requestToken: + post: + summary: Begins the validation process for an email to be used during + registration. + description: |- + The homeserver must check that the given email address is **not** + already associated with an account on this homeserver. The homeserver + should validate the email itself, either by sending a validation email + itself or by using a service it has control over. + operationId: requestTokenToRegisterEmail + requestBody: + content: + application/json: + schema: + $ref: definitions/request_email_validation.yaml + required: true + responses: + "200": + description: |- + An email has been sent to the specified address. Note that this + may be an email containing the validation token or it may be + informing the user of an error. + content: + application/json: + schema: + $ref: definitions/request_token_response.yaml + "400": + description: |- + Part of the request was invalid. This may include one of the following error codes: + + * `T_THREEPID_IN_USE` : The email address is already registered to an account on this server. + However, if the homeserver has the ability to send email, it is recommended that the server + instead send an email to the user with instructions on how to reset their password. + This prevents malicious parties from being able to determine if a given email address + has an account on the homeserver in question. + * `T_SERVER_NOT_TRUSTED` : The `id_server` parameter refers to an identity server + that is not trusted by this homeserver. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_THREEPID_IN_USE", + "error": "The specified address is already in use" + } + "403": + description: The homeserver does not permit the address to be bound. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_THREEPID_DENIED", + "error": "Third-party identifier is not allowed" + } + tags: + - Account management + /register/msisdn/requestToken: + post: + summary: Requests a validation token be sent to the given phone number for the + purpose of registering an account + description: |- + The homeserver must check that the given phone number is **not** + already associated with an account on this homeserver. The homeserver + should validate the phone number itself, either by sending a validation + message itself or by using a service it has control over. + operationId: requestTokenToRegisterMSISDN + requestBody: + content: + application/json: + schema: + $ref: definitions/request_msisdn_validation.yaml + required: true + responses: + "200": + description: |- + An SMS message has been sent to the specified phone number. Note + that this may be an SMS message containing the validation token or + it may be informing the user of an error. + content: + application/json: + schema: + $ref: definitions/request_token_response.yaml + "400": + description: |- + Part of the request was invalid. This may include one of the following error codes: + + * `T_THREEPID_IN_USE` : The phone number is already registered to an account on this server. + However, if the homeserver has the ability to send SMS message, it is recommended that the server + instead send an SMS message to the user with instructions on how to reset their password. + This prevents malicious parties from being able to determine if a given phone number + has an account on the homeserver in question. + * `T_SERVER_NOT_TRUSTED` : The `id_server` parameter refers to an identity server + that is not trusted by this homeserver. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_THREEPID_IN_USE", + "error": "The specified address is already in use" + } + "403": + description: The homeserver does not permit the address to be bound. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_THREEPID_DENIED", + "error": "Third-party identifier is not allowed" + } + tags: + - Account management + /register/available: + get: + summary: Checks to see if a username is available on the server. + description: |- + Checks to see if a username is available, and valid, for the server. + + The server should check to ensure that, at the time of the request, the + username requested is available for use. This includes verifying that an + application service has not claimed the username and that the username + fits the server's desired requirements (for example, a server could dictate + that it does not permit usernames with underscores). + + Taper clients may wish to use this API prior to attempting registration, + however the clients must also be aware that using this API does not normally + reserve the username. This can mean that the username becomes unavailable + between checking its availability and attempting to register it. + operationId: checkUsernameAvailability + parameters: + - in: query + name: username + required: true + description: The username to check the availability of. + example: my_cool_localpart + schema: + type: string + default: my_cool_localpart + responses: + "200": + description: The username is available + content: + application/json: + schema: + type: object + properties: + available: + type: boolean + description: |- + A flag to indicate that the username is available. This should always + be `true` when the server replies with 200 OK. + examples: + response: + value: { + "available": true + } + "400": + description: |- + Part of the request was invalid or the username is not available. This may + include one of the following error codes: + + * `T_USER_IN_USE` : The desired username is already taken. + * `T_INVALID_USERNAME` : The desired username is not a valid user name. + * `T_EXCLUSIVE` : The desired username is in the exclusive namespace + claimed by an application service. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_USER_IN_USE", + "error": "Desired user ID is already taken." + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Account management +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 diff --git a/data/api/client-server/registration_tokens.yaml b/data/api/client-server/registration_tokens.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fc6a8282c63df9c8e87f19f1e39a8a6a14e13a63 --- /dev/null +++ b/data/api/client-server/registration_tokens.yaml @@ -0,0 +1,93 @@ +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Registration Token API + version: 1.0.0 +paths: + /register/t.login.registration_token/validity: + get: + x-addedInMatrixVersion: "1.2" + summary: Query if a given registration token is still valid. + description: |- + Queries the server to determine if a given registration token is still + valid at the time of request. This is a point-in-time check where the + token might still expire by the time it is used. + + Servers should be sure to rate limit this endpoint to avoid brute force + attacks. + operationId: registrationTokenValidity + parameters: + - in: query + name: token + required: true + description: The token to check validity of. + example: fBVFdqVE + schema: + type: string + responses: + "200": + description: The check has a result. + content: + application/json: + schema: + type: object + properties: + valid: + type: boolean + description: |- + True if the token is still valid, false otherwise. This should + additionally be false if the token is not a recognised token by + the server. + required: + - valid + examples: + response: + value: { + "valid": true + } + "403": + description: |- + The homeserver does not permit registration and thus all tokens are + considered invalid. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Registration is not enabled on this homeserver." + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Account management +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v1 diff --git a/data/api/client-server/relations.yaml b/data/api/client-server/relations.yaml new file mode 100644 index 0000000000000000000000000000000000000000..732e2b20a221a083266c5f1bf371ef44642705e1 --- /dev/null +++ b/data/api/client-server/relations.yaml @@ -0,0 +1,378 @@ +# Copyright 2022,2024 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Relations API + version: 1.0.0 +paths: + "/rooms/{roomId}/relations/{eventId}": + get: + summary: Get the child events for a given parent event. + description: |- + Retrieve all of the child events for a given parent event. + + Note that when paginating the `from` token should be "after" the `to` token in + terms of topological ordering, because it is only possible to paginate "backwards" + through events, starting at `from`. + + For example, passing a `from` token from page 2 of the results, and a `to` token + from page 1, would return the empty set. The caller can use a `from` token from + page 1 and a `to` token from page 2 to paginate over the same range, however. + operationId: getRelatingEvents + security: + - accessTokenBearer: [] + parameters: + - $ref: '#/components/parameters/roomId' + - $ref: '#/components/parameters/eventId' + - $ref: '#/components/parameters/from' + - $ref: '#/components/parameters/to' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/dir' + - $ref: '#/components/parameters/recurse' + responses: + # note: this endpoint deliberately does not support rate limiting, therefore a + # 429 error response is not included. + "200": + description: |- + The paginated child events which point to the parent. If no events are + pointing to the parent or the pagination yields no results, an empty `chunk` + is returned. + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/response' + - type: object + properties: + chunk: + title: ChildEventsChunk + type: array + description: The child events of the requested event, ordered topologically + most-recent first. + items: + $ref: definitions/client_event.yaml + required: + - chunk + examples: + response: + $ref: '#/components/examples/response' + "404": + $ref: '#/components/responses/404' + tags: + - Event relationships + # The same as above, with added `/{relType}` + "/rooms/{roomId}/relations/{eventId}/{relType}": + get: + summary: Get the child events for a given parent event, with a given `relType`. + description: |- + Retrieve all of the child events for a given parent event which relate to the parent + using the given `relType`. + + Note that when paginating the `from` token should be "after" the `to` token in + terms of topological ordering, because it is only possible to paginate "backwards" + through events, starting at `from`. + + For example, passing a `from` token from page 2 of the results, and a `to` token + from page 1, would return the empty set. The caller can use a `from` token from + page 1 and a `to` token from page 2 to paginate over the same range, however. + operationId: getRelatingEventsWithRelType + security: + - accessTokenBearer: [] + parameters: + - $ref: '#/components/parameters/roomId' + - $ref: '#/components/parameters/eventId' + - $ref: '#/components/parameters/relType' + - $ref: '#/components/parameters/from' + - $ref: '#/components/parameters/to' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/dir' + - $ref: '#/components/parameters/recurse' + responses: + # note: this endpoint deliberately does not support rate limiting, therefore a + # 429 error response is not included. + "200": + description: |- + The paginated child events which point to the parent. If no events are + pointing to the parent or the pagination yields no results, an empty `chunk` + is returned. + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/response' + - type: object + properties: + chunk: + title: ChildEventsChunk + type: array + description: |- + The child events of the requested event, ordered topologically + most-recent first. The events returned will match the `relType` + supplied in the URL. + items: + $ref: definitions/client_event.yaml + required: + - chunk + examples: + response: + $ref: '#/components/examples/response' + "404": + $ref: '#/components/responses/404' + tags: + - Event relationships + # The same as above, with added `/{eventType}` + "/rooms/{roomId}/relations/{eventId}/{relType}/{eventType}": + get: + summary: Get the child events for a given parent event, with a given `relType` + and `eventType`. + description: |- + Retrieve all of the child events for a given parent event which relate to the parent + using the given `relType` and have the given `eventType`. + + Note that when paginating the `from` token should be "after" the `to` token in + terms of topological ordering, because it is only possible to paginate "backwards" + through events, starting at `from`. + + For example, passing a `from` token from page 2 of the results, and a `to` token + from page 1, would return the empty set. The caller can use a `from` token from + page 1 and a `to` token from page 2 to paginate over the same range, however. + operationId: getRelatingEventsWithRelTypeAndEventType + security: + - accessTokenBearer: [] + parameters: + - $ref: '#/components/parameters/roomId' + - $ref: '#/components/parameters/eventId' + - $ref: '#/components/parameters/relType' + - in: path + name: eventType + description: |- + The event type of child events to search for. + + Note that in encrypted rooms this will typically always be `t.room.encrypted` + regardless of the event type contained within the encrypted payload. + required: true + example: t.room.message + schema: + type: string + - $ref: '#/components/parameters/from' + - $ref: '#/components/parameters/to' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/dir' + - $ref: '#/components/parameters/recurse' + responses: + # note: this endpoint deliberately does not support rate limiting, therefore a + # 429 error response is not included. + "200": + description: |- + The paginated child events which point to the parent. If no events are + pointing to the parent or the pagination yields no results, an empty `chunk` + is returned. + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/response' + - type: object + properties: + chunk: + title: ChildEventsChunk + type: array + description: |- + The child events of the requested event, ordered topologically most-recent + first. The events returned will match the `relType` and `eventType` supplied + in the URL. + items: + $ref: definitions/client_event.yaml + required: + - chunk + examples: + response: + $ref: '#/components/examples/response' + "404": + $ref: '#/components/responses/404' + tags: + - Event relationships +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v1 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer + parameters: + roomId: + in: path + name: roomId + description: The ID of the room containing the parent event. + required: true + example: "!636q39766251:matrix.org" + schema: + type: string + format: mx-room-id + pattern: "^!" + eventId: + in: path + name: eventId + description: The ID of the parent event whose child events are to be returned. + required: true + example: $asfDuShaf7Gafaw + schema: + type: string + format: mx-event-id + pattern: "^\\$" + from: + in: query + name: from + description: |- + The pagination token to start returning results from. If not supplied, results + start at the most recent topological event known to the server if `dir` is `b`, + or the oldest if `dir` is `f`. + + Can be a `next_batch` or `prev_batch` token from a previous call, or a returned + `start` token from [`/messages`](/client-server-api/#get_taperclientv3roomsroomidmessages), + or a `next_batch` token from [`/sync`](/client-server-api/#get_taperclientv3sync). + required: false + example: page2_token + schema: + type: string + to: + in: query + name: to + description: |- + The pagination token to stop returning results at. If not supplied, results + continue up to `limit` or until there are no more events. + + Like `from`, this can be a previous token from a prior call to this endpoint + or from `/messages` or `/sync`. + required: false + example: page3_token + schema: + type: string + limit: + in: query + name: limit + description: |- + The maximum number of results to return in a single `chunk`. The server can + and should apply a maximum value to this parameter to avoid large responses. + + Similarly, the server should apply a default value when not supplied. + required: false + example: 20 + schema: + type: integer + dir: + in: query + name: dir + x-addedInMatrixVersion: "1.4" + description: |- + Optional (default `b`) direction to return events from. If this is set to `f`, events + will be returned in chronological order starting at `from`. If it + is set to `b`, events will be returned in *reverse* chronological + order, again starting at `from`. + schema: + type: string + enum: + - b + - f + relType: + in: path + name: relType + description: The [relationship type](/client-server-api/#relationship-types) to + search for. + required: true + example: org.example.my_relation + schema: + type: string + recurse: + in: query + name: recurse + x-addedInMatrixVersion: "1.10" + required: false + description: |- + Whether to additionally include events which only relate indirectly to the + given event, i.e. events related to the given event via two or more direct relationships. + + If set to `false`, only events which have a direct relation with the given + event will be included. + + If set to `true`, events which have an indirect relation with the given event + will be included additionally up to a certain depth level. Homeservers SHOULD traverse + at least 3 levels of relationships. Implementations MAY perform more but MUST be careful + to not infinitely recurse. + + The default value is `false`. + schema: + type: boolean + schemas: + response: + type: object + properties: + next_batch: + type: string + description: |- + An opaque string representing a pagination token. The absence of this token + means there are no more results to fetch and the client should stop paginating. + prev_batch: + type: string + description: |- + An opaque string representing a pagination token. The absence of this token + means this is the start of the result set, i.e. this is the first batch/page. + recursion_depth: + type: integer + description: |- + If the `recurse` parameter was supplied by the client, this response field is + mandatory and gives the actual depth to which the server recursed. If the client + did not specify the `recurse` parameter, this field must be absent. + responses: + "404": + description: |- + The parent event was not found or the user does not have permission to read + this event (it might be contained in history that is not accessible to the user). + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Event not found." + } + examples: + response: + value: { + "chunk": [ + { + "room_id": "!636q39766251:matrix.org", + "$ref": "../../event-schemas/examples/t.room.message$t.text.yaml", + "content": { + "t.relates_to": { + "rel_type": "org.example.my_relation", + "event_id": "$asfDuShaf7Gafaw" + } + } + } + ], + "next_batch": "page2_token", + "prev_batch": "page1_token" + } diff --git a/data/api/client-server/report_content.yaml b/data/api/client-server/report_content.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d1f84b5f6b02493f977e90898a4a9a481bd7e05f --- /dev/null +++ b/data/api/client-server/report_content.yaml @@ -0,0 +1,278 @@ +# Copyright 2018 Travis Ralston +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Report Content API + version: 1.0.0 +paths: + "/rooms/{roomId}/report": + post: + x-addedInMatrixVersion: "1.13" + summary: Report a room as inappropriate. + description: |- + Reports a room as inappropriate to the server, which may then notify + the appropriate people. How such information is delivered is left up to + implementations. The caller is not required to be joined to the room to + report it. + + Clients could infer whether a reported room exists based on the 404 response. + Homeservers that wish to conceal this information MAY return 200 responses + regardless of the existence of the reported room. + + Furthermore, it might be possible for clients to deduce whether a reported + room exists by timing the response. This is because only a report for an + existing room will require the homeserver to do further processing. To + combat this, homeservers MAY add a random delay when generating a response. + operationId: reportRoom + parameters: + - in: path + name: roomId + description: The room being reported. + required: true + example: "!637q39766251:example.com" + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + example: { + "reason": "this makes me sad" + } + properties: + reason: + type: string + description: The reason the room is being reported. May be blank. + required: + - reason + required: true + security: + - accessTokenBearer: [] + x-changedInMatrixVersion: + 1.18: | + Servers MAY prevent room ID enumeration by using the 200 response + regardless of the existence of the reported room and/or by adding + a random delay when generating responses. + responses: + "200": + description: The room has been reported successfully. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "404": + description: |- + The room was not found on the homeserver. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "The room was not found." + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Reporting content + "/rooms/{roomId}/report/{eventId}": + post: + summary: Report an event in a joined room as inappropriate. + description: |- + Reports an event as inappropriate to the server, which may then notify + the appropriate people. The caller must be joined to the room to report + it. + + Clients could infer whether a reported event or room exists based on the 404 + response. Homeservers that wish to conceal this information MAY return 200 + responses regardless of the existence of the reported event or room. + + Furthermore, it might be possible for clients to deduce whether a reported + event exists by timing the response. This is because only a report for an + existing event will require the homeserver to do further processing. To + combat this, homeservers MAY add a random delay when generating a response. + operationId: reportEvent + parameters: + - in: path + name: roomId + description: The room in which the event being reported is located. + required: true + example: "!637q39766251:example.com" + schema: + type: string + - in: path + name: eventId + description: The event to report. + required: true + example: $something:example.org + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + example: { + "reason": "this makes me sad" + } + properties: + reason: + type: string + description: The reason the content is being reported. + required: true + security: + - accessTokenBearer: [] + x-changedInMatrixVersion: + 1.8: | + This endpoint now requires the user to be joined to the room. + 1.18: | + The `score` request parameter was removed. Additionally, servers + may prevent event/room ID enumeration by using the 200 response + regardless of the existence of the reported event/room. + responses: + "200": + description: The event has been reported successfully. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "404": + description: |- + The event was not found or you are not joined to the room where the + event resides. + + Homeserver implementations can additionally return this error if the + reported event has been redacted. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "The event was not found or you are not joined to the room." + } + tags: + - Reporting content + "/users/{userId}/report": + post: + x-addedInMatrixVersion: "1.14" + summary: Report a user as inappropriate. + description: |- + Reports a user as inappropriate to the server, which may then notify + the appropriate people. How such information is delivered is left up to + implementations. The caller is not required to be joined to any rooms + that the reported user is joined to. + + Clients may wish to [ignore](/client-server-api/#ignoring-users) users after reporting them. + + Clients could infer whether a reported user exists based on the 404 response. + Homeservers that wish to conceal this information MAY return 200 responses + regardless of the existence of the reported user. + + Furthermore, it might be possible for clients to deduce whether a reported + user exists by timing the response. This is because only a report for an + existing user will require the homeserver to do further processing. To + combat this, homeservers MAY add a random delay when generating a response. + operationId: reportUser + parameters: + - in: path + name: userId + description: The user being reported. + required: true + example: "@someguy:example.com" + schema: + type: string + format: mx-user-id + pattern: "^@" + requestBody: + content: + application/json: + schema: + type: object + example: { + "reason": "this makes me sad" + } + properties: + reason: + type: string + description: The reason the room is being reported. May be blank. + required: + - reason + required: true + security: + - accessTokenBearer: [] + responses: + "200": + description: | + The user has been reported successfully or the server chose + to not disclose whether the users exists. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "404": + description: |- + The user was not found on the homeserver. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "The user was not found." + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Reporting content +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/room_event_by_timestamp.yaml b/data/api/client-server/room_event_by_timestamp.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ebf18447463b4f80f02b337697ff27059e7ddcf5 --- /dev/null +++ b/data/api/client-server/room_event_by_timestamp.yaml @@ -0,0 +1,144 @@ +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server events in room by date API + version: 1.0.0 +paths: + "/rooms/{roomId}/timestamp_to_event": + get: + x-addedInMatrixVersion: "1.6" + summary: Get the closest event ID to the given timestamp + description: |- + Get the ID of the event closest to the given timestamp, in the + direction specified by the `dir` parameter. + + If the server does not have all of the room history and does not have + an event suitably close to the requested timestamp, it can use the + corresponding [federation endpoint](/server-server-api/#get_taperfederationv1timestamp_to_eventroomid) + to ask other servers for a suitable event. + + After calling this endpoint, clients can call + [`/rooms/{roomId}/context/{eventId}`](/client-server-api/#get_taperclientv3roomsroomidcontexteventid) + to obtain a pagination token to retrieve the events around the returned event. + + The event returned by this endpoint could be an event that the client + cannot render, and so may need to paginate in order to locate an event + that it can display, which may end up being outside of the client's + suitable range. Clients can employ different strategies to display + something reasonable to the user. For example, the client could try + paginating in one direction for a while, while looking at the + timestamps of the events that it is paginating through, and if it + exceeds a certain difference from the target timestamp, it can try + paginating in the opposite direction. The client could also simply + paginate in one direction and inform the user that the closest event + found in that direction is outside of the expected range. + operationId: getEventByTimestamp + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The ID of the room to search + required: true + example: "!636q39766251:matrix.org" + schema: + type: string + format: mx-room-id + pattern: "^!" + - in: query + name: ts + description: |- + The timestamp to search from, as given in milliseconds + since the Unix epoch. + required: true + example: 1432684800000 + schema: + type: integer + - in: query + name: dir + description: The direction in which to search. `f` for forwards, `b` for + backwards. + required: true + example: f + schema: + type: string + enum: + - f + - b + responses: + "200": + description: An event was found matching the search parameters. + content: + application/json: + schema: + type: object + properties: + event_id: + type: string + format: mx-event-id + pattern: "^\\$" + description: The ID of the event found + origin_server_ts: + type: integer + description: |- + The event's timestamp, in milliseconds since the Unix epoch. + This makes it easy to do a quick comparison to see if the + `event_id` fetched is too far out of range to be useful for your + use case. + required: + - event_id + - origin_server_ts + examples: + response: + value: { + "event_id": "$143273582443PhrSn:example.org", + "origin_server_ts": 1432735824653 + } + "404": + description: No event was found. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unable to find event from 1432684800000 in forward direction" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Room participation +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v1 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/room_initial_sync.yaml b/data/api/client-server/room_initial_sync.yaml new file mode 100644 index 0000000000000000000000000000000000000000..77838be67cc6c25b69cf5f7ddadc851f02340a04 --- /dev/null +++ b/data/api/client-server/room_initial_sync.yaml @@ -0,0 +1,185 @@ +openapi: 3.1.0 +info: + title: Taper Client-Server Rooms API + version: 1.0.0 +paths: + "/rooms/{roomId}/initialSync": + get: + summary: Snapshot the current state of a room and its most recent messages. + description: |- + Get a copy of the current state and the most recent messages in a room. + + This endpoint should now exclusively be used for "peeking" into viewable rooms + you're not a member of ([Room Previews](/client-server-api/#room-previews)). + Using this endpoint for something other than peeking was deprecated in r0 of this specification. + The relevant information for syncing is now returned by the + [`/sync`](/client-server-api/#get_taperclientv3sync) API. See the + [migration guide](https://matrix.org/docs/guides/migrating-from-client-server-api-v-1#deprecated-endpoints). + operationId: roomInitialSync + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room to get the data. + required: true + example: "!636q39766251:example.com" + schema: + type: string + format: mx-room-id + pattern: "^!" + responses: + "200": + description: The current state of the room + content: + application/json: + schema: + title: RoomInfo + type: object + properties: + room_id: + type: string + format: mx-room-id + pattern: "^!" + description: The ID of this room. + membership: + type: string + description: The user's membership state in this room. + enum: + - invite + - join + - leave + - ban + messages: + type: object + title: PaginationChunk + description: The pagination chunk for this room. + properties: + start: + type: string + description: |- + A token which correlates to the start of `chunk`. Can be passed to + [`/rooms//messages`](/client-server-api/#get_taperclientv3roomsroomidmessages) + to retrieve earlier events. + + If no earlier events are available, this property may be omitted from + the response. + end: + type: string + description: |- + A token which correlates to the end of `chunk`. Can be passed to + [`/rooms//messages`](/client-server-api/#get_taperclientv3roomsroomidmessages) + to retrieve later events. + chunk: + type: array + description: |- + If the user is a member of the room this will be a + list of the most recent messages for this room. If + the user has left the room this will be the + messages that preceded them leaving. This array + will consist of at most `limit` elements. + items: + $ref: definitions/client_event.yaml + required: + - end + - chunk + state: + type: array + description: |- + If the user is a member of the room this will be the + current state of the room as a list of events. If the + user has left the room this will be the state of the + room when they left it. + items: + $ref: definitions/client_event.yaml + visibility: + type: string + enum: + - private + - public + description: |- + Whether this room is visible to the `/publicRooms` API + or not. + account_data: + type: array + description: The private data that this user has attached to this room. + items: + title: Event + type: object + allOf: + - $ref: ../../event-schemas/schema/core-event-schema/event.yaml + required: + - room_id + examples: + response: + value: { + "membership": "join", + "messages": { + "chunk": [ + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.message$t.text.yaml" + }, + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.message$t.file.yaml" + } + ], + "end": "s3456_9_0", + "start": "t44-3453_9_0" + }, + "room_id": "!636q39766251:example.com", + "state": [ + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.join_rules.yaml" + }, + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.member.yaml" + }, + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.create.yaml" + }, + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.power_levels.yaml" + } + ], + "visibility": "private", + "account_data": [ + { + "type": "t.tag", + "content": { + "tags": { + "work": { + "order": "1" + } + } + } + } + ] + } + "403": + description: | + You aren't a member of the room and weren't previously a member of the room. + tags: + - Room participation + deprecated: false +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/room_send.yaml b/data/api/client-server/room_send.yaml new file mode 100644 index 0000000000000000000000000000000000000000..33367aa555422c1f65837aef25eaaca977934e3c --- /dev/null +++ b/data/api/client-server/room_send.yaml @@ -0,0 +1,150 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2023 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server message event send API + version: 1.0.0 +paths: + "/rooms/{roomId}/send/{eventType}/{txnId}": + put: + summary: Send a message event to the given room. + x-changedInMatrixVersion: + "1.18": |- + Homeservers must support sending `t.room.redaction` events with this endpoint + for all room versions. + description: |- + This endpoint is used to send a message event to a room. Message events + allow access to historical events and pagination, making them suited + for "once-off" activity in a room. + + The body of the request should be the content object of the event; the + fields in this object will vary depending on the type of event. See + [Room Events](/client-server-api/#room-events) for the `t.` event specification. + + Homeservers MUST allow clients to send `t.room.redaction` events with this + endpoint for all room versions. In rooms with a version older than 11 they + MUST move the `redacts` property inside the `content` to the top level of + the event. + operationId: sendMessage + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room to send the event to. + required: true + example: "!636q39766251:example.com" + schema: + type: string + format: mx-room-id + pattern: "^!" + - in: path + name: eventType + description: The type of event to send. + required: true + example: t.room.message + schema: + type: string + - in: path + name: txnId + description: |- + The [transaction ID](/client-server-api/#transaction-identifiers) for this event. Clients should generate an + ID unique across requests with the same access token; it will be + used by the server to ensure idempotency of requests. + required: true + example: "35" + schema: + type: string + - in: query + name: sticky_duration_ms + x-addedInMatrixVersion: "1.20" + description: |- + If present, the event is sent as a [sticky event](/client-server-api/#sticky-events) + which remains sticky for the given number of milliseconds. + + If supplied, MUST be a positive integer. + + SHOULD NOT be set to below 300000 (5 minutes) because servers with significant + clock skew may cause the event to expire quicker than intended. + + SHOULD NOT be set to more than 3600000 (1 hour) because servers expire + sticky events after at most 1 hour even if the supplied duration is larger. + + See [here](/client-server-api/#determining-whether-an-event-is-sticky) for details + on how servers compute whether an event is still sticky. + required: false + example: 600000 + schema: + type: integer + format: int64 + minimum: 1 + requestBody: + content: + application/json: + schema: + type: object + example: { + "msgtype": "t.text", + "body": "hello" + } + required: true + responses: + "200": + description: An ID for the sent event. + content: + application/json: + schema: + type: object + properties: + event_id: + type: string + format: mx-event-id + pattern: "^\\$" + description: A unique identifier for the event. + required: + - event_id + examples: + response: + value: { + "event_id": "$YUwRidLecu:example.com" + } + "400": + description: |- + The request is invalid. A [standard error response](/client-server-api/#standard-error-response) + will be returned. As well as the normal common error codes, other reasons for rejection include: + + - `T_DUPLICATE_ANNOTATION`: The request is an attempt to send a [duplicate annotation](/client-server-api/#avoiding-duplicate-annotations). + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + tags: + - Room participation +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/room_state.yaml b/data/api/client-server/room_state.yaml new file mode 100644 index 0000000000000000000000000000000000000000..31ca074e7953cee230f6da3ed85f9fe51dffc4db --- /dev/null +++ b/data/api/client-server/room_state.yaml @@ -0,0 +1,156 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server state event send API + version: 1.0.0 +paths: + "/rooms/{roomId}/state/{eventType}/{stateKey}": + put: + summary: Send a state event to the given room. + description: | + State events can be sent using this endpoint. These events will be + overwritten if ``, `` and `` all + match. + + Requests to this endpoint **cannot use transaction IDs** + like other `PUT` paths because they cannot be differentiated from the + `state_key`. Furthermore, `POST` is unsupported on state paths. + + The body of the request should be the content object of the event; the + fields in this object will vary depending on the type of event. See + [Room Events](/client-server-api/#room-events) for the `t.` event specification. + + If the event type being sent is `t.room.canonical_alias` servers + SHOULD ensure that any new aliases being listed in the event are valid + per their grammar/syntax and that they point to the room ID where the + state event is to be sent. Servers do not validate aliases which are + being removed or are already present in the state event. + operationId: setRoomStateWithKey + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room to set the state in + required: true + example: "!636q39766251:example.com" + schema: + type: string + format: mx-room-id + pattern: "^!" + - in: path + name: eventType + description: The type of event to send. + required: true + example: t.room.member + schema: + type: string + - in: path + name: stateKey + description: |- + The state_key for the state to send. Defaults to the empty string. When + an empty string, the trailing slash on this endpoint is optional. + required: true + example: "@alice:example.com" + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + example: { + "membership": "join", + "avatar_url": "runit://localhost/SEsfnsuifSDFSSEF", + "displayname": "Alice Margatroid" + } + required: true + responses: + "200": + description: An ID for the sent event. + content: + application/json: + schema: + type: object + properties: + event_id: + type: string + format: mx-event-id + pattern: "^\\$" + description: A unique identifier for the event. + required: + - event_id + examples: + response: + value: { + "event_id": "$YUwRidLecu:example.com" + } + "400": + description: |- + The sender's request is malformed. + + Some example error codes include: + + * `T_INVALID_PARAM`: One or more aliases within the `t.room.canonical_alias` + event have invalid syntax. + + * `T_BAD_ALIAS`: One or more aliases within the `t.room.canonical_alias` event + do not point to the room ID for which the state event is to be sent to. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_BAD_ALIAS", + "error": "The alias '#hello:example.org' does not point to this room." + } + "403": + description: |- + The sender doesn't have permission to send the event into the room. + + {{% added-in v="1.18"%}} If the `eventType` is `t.room.member` and + the `membership` is `invite`, the `T_INVITE_BLOCKED` error code is + used to indicate that the homeserver rejected the invite due to + [invite blocking](/client-server-api/#invite-permission). + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You do not have permission to send the event." + } + tags: + - Room participation +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/room_summary.yaml b/data/api/client-server/room_summary.yaml new file mode 100644 index 0000000000000000000000000000000000000000..355a3ae0c2f6a38ef3007b22cfb8f64a36629cc2 --- /dev/null +++ b/data/api/client-server/room_summary.yaml @@ -0,0 +1,137 @@ +# Copyright 2025 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Room Summary API + version: 1.0.0 +paths: + "/room_summary/{roomIdOrAlias}": + get: + x-addedInMatrixVersion: "1.15" + summary: Retrieves a summary for a room. + description: |- + Retrieves a summary for a room. + + Clients should note that requests for rooms where the user's membership + is `invite` or `knock` might yield outdated, partial or even no data + since the server may not have access to the current state of the room. + + Servers MAY allow unauthenticated access to this API if at least one of + the following conditions holds true: + + - The room has a [join rule](/client-server-api/#lroomjoin_rules) of `public`, `knock` or + `knock_restricted`. + - The room has a `world_readable` [history visibility](/client-server-api/#room-history-visibility). + + Servers should consider rate limiting requests that require a federation + request more heavily if the client is unauthenticated. + operationId: getRoomSummary + security: + - {} + - accessTokenBearer: [] + parameters: + - in: path + name: roomIdOrAlias + description: The room identifier or alias to summarise. + required: true + example: "#monkeys:matrix.org" + schema: + oneOf: + - type: string + format: mx-room-id + pattern: "^!" + - type: string + format: mx-room-alias + pattern: "^#" + - in: query + name: via + description: |- + The servers to attempt to request the summary from when + the local server cannot generate it (for instance, because + it has no local user in the room). + example: + - matrix.org + - elsewhere.ca + schema: + type: array + items: + type: string + format: mx-server-name + responses: + "200": + description: A summary of the room. + content: + application/json: + schema: + description: A summary of the room. + allOf: + - $ref: ../client-server/definitions/room_summary.yaml + - type: object + properties: + membership: + description: |- + The membership state of the user if the user is joined to the room. Absent + if the API was called unauthenticated. + enum: + - invite + - join + - knock + - leave + - ban + type: string + examples: + response: + value: { + room_id: "!ol19s:bleecker.street", + avatar_url: "runit://bleecker.street/CHEDDARandBRIE", + guest_can_join: false, + name: "CHEESE", + num_joined_members: 37, + topic: "Tasty tasty cheese", + world_readable: true, + join_rule: "public", + room_type: "t.space", + membership: "invite", + encryption: "t.megolm.v1.aes-sha2", + room_version: "9001", + } + "404": + description: |- + The room could not be found. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Room not found." + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v1 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/room_upgrades.yaml b/data/api/client-server/room_upgrades.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9241a178b08074b1f925d9c11c1b5acaab99f43c --- /dev/null +++ b/data/api/client-server/room_upgrades.yaml @@ -0,0 +1,127 @@ +# Copyright 2019 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Room Upgrades API + version: 1.0.0 +paths: + "/rooms/{roomId}/upgrade": + post: + summary: Upgrades a room to a new room version. + description: Upgrades the given room to a particular room version. + operationId: upgradeRoom + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + required: true + description: The ID of the room to upgrade. + example: "!oldroom:example.org" + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + new_version: + type: string + description: The new version for the room. + additional_creators: + type: array + items: + type: string + description: Additional user ID to consider a room creator, if the room version supports it. + x-addedInMatrixVersion: "1.16" + description: |- + When upgrading to a [room version](/rooms) which supports additional creators, + the [user IDs](/appendices#user-identifiers) which should be considered room + creators in addition to the user performing the upgrade. + + If the room being upgraded has additional creators, they are *not* automatically + copied to the new room. The full set of additional creators needs to be set to + retain (or add/remove) more room creators. + + When upgrading to a room version which doesn't support additional creators, this + field is ignored and has no effect during the upgrade process. + example: { + "new_version": "2" + } + required: + - new_version + required: true + responses: + "200": + description: The room was successfully upgraded. + content: + application/json: + schema: + type: object + properties: + replacement_room: + type: string + description: The ID of the new room. + required: + - replacement_room + examples: + response: + value: { + "replacement_room": "!newroom:example.org" + } + "400": + description: |- + The request was invalid. One way this can happen is if the room version + requested is not supported by the homeserver. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNSUPPORTED_ROOM_VERSION", + "error": "This server does not support that room version" + } + "403": + description: The user is not permitted to upgrade the room. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You cannot upgrade this room" + } + tags: + - Room upgrades +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/rooms.yaml b/data/api/client-server/rooms.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1b3a83e19781e3bf5a6942e78fa2630d690a9a05 --- /dev/null +++ b/data/api/client-server/rooms.yaml @@ -0,0 +1,374 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Rooms API + version: 1.0.0 +paths: + "/rooms/{roomId}/event/{eventId}": + get: + summary: Get a single event by event ID. + description: |- + Get a single event based on `roomId/eventId`. You must have permission to + retrieve this event e.g. by being a member in the room for this event. + operationId: getOneRoomEvent + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The ID of the room the event is in. + required: true + example: "!636q39766251:matrix.org" + schema: + type: string + format: mx-room-id + pattern: "^!" + - in: path + name: eventId + description: The event ID to get. + required: true + example: $asfDuShaf7Gafaw:matrix.org + schema: + type: string + format: mx-event-id + pattern: "^\\$" + responses: + "200": + description: The full event. + content: + application/json: + schema: + $ref: definitions/client_event.yaml + examples: + response: + value: { + "room_id": "!636q39766251:matrix.org", + "$ref": "../../event-schemas/examples/t.room.message$t.text.yaml" + } + "404": + description: The event was not found or you do not have permission to read this + event. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Event not found." + } + tags: + - Room participation + "/rooms/{roomId}/state/{eventType}/{stateKey}": + get: + summary: Get the state identified by the type and key. + description: |- + Looks up the contents of a state event in a room. If the user is + joined to the room then the state is taken from the current + state of the room. If the user has left the room then the state is + taken from the state of the room when they left. + operationId: getRoomStateWithKey + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room to look up the state in. + required: true + example: "!636q39766251:example.com" + schema: + type: string + format: mx-room-id + pattern: "^!" + - in: path + name: eventType + description: The type of state to look up. + required: true + example: t.room.name + schema: + type: string + - in: path + name: stateKey + description: |- + The key of the state to look up. Defaults to an empty string. When + an empty string, the trailing slash on this endpoint is optional. + required: true + example: "" + schema: + type: string + - in: query + name: format + x-addedInMatrixVersion: "1.16" + description: |- + The format to use for the returned data. `content` (the default) will + return only the content of the state event. `event` will return the entire + event in the usual format suitable for clients, including fields like event + ID, sender and timestamp. + example: event + schema: + type: string + enum: + - content + - event + responses: + "200": + description: |- + The content of the state event, or the entire client-formatted event + if `?format=event` was used. + content: + application/json: + schema: + oneOf: + - type: object + - $ref: "../../event-schemas/schema/core-event-schema/state_event.yaml" + examples: + response: + value: { + "name": "Example room name" + } + "403": + description: | + You aren't a member of the room and weren't previously a member of the room. + "404": + description: The room has no state with the given type or key. + tags: + - Room participation + "/rooms/{roomId}/state": + get: + summary: Get all state events in the current state of a room. + description: Get the state events for the current state of a room. + operationId: getRoomState + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room to look up the state for. + required: true + example: "!636q39766251:example.com" + schema: + type: string + format: mx-room-id + pattern: "^!" + responses: + "200": + description: The current state of the room + content: + application/json: + schema: + type: array + title: RoomState + description: |- + If the user is a member of the room this will be the + current state of the room as a list of events. If the user + has left the room then this will be the state of the room + when they left as a list of events. + items: + $ref: definitions/client_event.yaml + examples: + response: + value: [ + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.join_rules.yaml" + }, + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.member.yaml" + }, + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.create.yaml" + }, + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.power_levels.yaml" + } + ] + "403": + description: | + You aren't a member of the room and weren't previously a member of the room. + tags: + - Room participation + "/rooms/{roomId}/members": + get: + summary: Get the t.room.member events for the room. + description: Get the list of members for this room. + operationId: getMembersByRoom + parameters: + - in: path + name: roomId + description: The room to get the member events for. + required: true + example: "!636q39766251:example.com" + schema: + type: string + format: mx-room-id + pattern: "^!" + - in: query + name: at + description: |- + The point in time (pagination token) to return members for in the room. + This token can be obtained from a `prev_batch` token returned for + each room by the sync API. Defaults to the current state of the room, + as determined by the server. + example: YWxsCgpOb25lLDM1ODcwOA + schema: + type: string + # XXX: As mentioned in MSC1227, replacing `[not_]membership` with a JSON + # filter might be a better alternative. + # See https://github.com/matrix-org/matrix-doc/issues/1227 + - in: query + name: membership + description: |- + The kind of membership to filter for. Defaults to no filtering if + unspecified. When specified alongside `not_membership`, the two + parameters create an 'or' condition: either the membership *is* + the same as `membership` **or** *is not* the same as `not_membership`. + example: join + schema: + type: string + enum: + - join + - invite + - knock + - leave + - ban + - in: query + name: not_membership + description: |- + The kind of membership to exclude from the results. Defaults to no + filtering if unspecified. + example: leave + schema: + type: string + enum: + - join + - invite + - knock + - leave + - ban + security: + - accessTokenBearer: [] + responses: + "200": + description: |- + A list of members of the room. If you are joined to the room then + this will be the current members of the room. If you have left the + room then this will be the members of the room when you left. + content: + application/json: + schema: + type: object + properties: + chunk: + type: array + items: + $ref: definitions/client_event.yaml + examples: + response: + value: { + "chunk": [ + { + "room_id": "!636q39766251:example.com", + "$ref": "../../event-schemas/examples/t.room.member.yaml" + } + ] + } + "403": + description: | + You aren't a member of the room and weren't previously a member of the room. + tags: + - Room participation + "/rooms/{roomId}/joined_members": + get: + summary: Gets the list of currently joined users and their profile data. + description: This API returns a map of MXIDs to member info objects for members + of the room. The current user must be in the room for it to work, unless + it is an Application Service in which case any of the AS's users must be + in the room. This API is primarily for Application Services and should + be faster to respond than `/members` as it can be implemented more + efficiently on the server. + operationId: getJoinedMembersByRoom + parameters: + - in: path + name: roomId + description: The room to get the members of. + required: true + example: "!636q39766251:example.com" + schema: + type: string + format: mx-room-id + pattern: "^!" + security: + - accessTokenBearer: [] + responses: + "200": + description: A map of MXID to room member objects. + content: + application/json: + schema: + type: object + properties: + joined: + patternProperties: + "^@": + x-pattern-format: mx-user-id + title: RoomMember + type: object + properties: + display_name: + type: string + description: The display name of the user this object is representing. + avatar_url: + type: string + format: mx-runit-uri + pattern: "^runit:\\/\\/" + description: The avatar of the user this object is representing, as an [`runit://` + URI](/client-server-api/#taper-content-runit-uris). + description: A map from user ID to a RoomMember object. + type: object + examples: + response: + value: { + "joined": { + "@bar:example.com": { + "display_name": "Bar", + "avatar_url": "runit://riot.ovh/printErCATzZijQsSDWorRaK" + } + } + } + "403": + description: | + You aren't a member of the room. + tags: + - Room participation +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/search.yaml b/data/api/client-server/search.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7a81f40ca284be0af724df33724c09608deacc81 --- /dev/null +++ b/data/api/client-server/search.yaml @@ -0,0 +1,383 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Search API + version: 1.0.0 +paths: + /search: + post: + summary: Perform a server-side search. + description: Performs a full text search across different categories. + operationId: search + security: + - accessTokenBearer: [] + parameters: + - in: query + name: next_batch + description: |- + The point to return events from. If given, this should be a + `next_batch` result from a previous call to this endpoint. + example: YWxsCgpOb25lLDM1ODcwOA + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + example: { + "search_categories": { + "room_events": { + "keys": [ + "content.body" + ], + "search_term": "martians and men", + "order_by": "recent", + "groupings": { + "group_by": [ + { + "key": "room_id" + } + ] + } + } + } + } + properties: + search_categories: + type: object + title: Categories + description: Describes which categories to search in and their criteria. + properties: + room_events: + type: object + title: Room Events Criteria + description: Mapping of category name to search criteria. + properties: + search_term: + type: string + description: The string to search events for + keys: + type: array + items: + type: string + enum: + - content.body + - content.name + - content.topic + description: The keys to search. Defaults to all. + filter: + type: object + title: Filter + description: This takes a [filter](/client-server-api/#filtering). + allOf: + - $ref: definitions/room_event_filter.yaml + order_by: + title: Ordering + type: string + enum: + - recent + - rank + description: |- + The order in which to search for results. + By default, this is `"rank"`. + event_context: + title: Include Event Context + type: object + description: |- + Configures whether any context for the events + returned are included in the response. + properties: + before_limit: + type: integer + title: Before limit + description: |- + How many events before the result are + returned. By default, this is `5`. + after_limit: + type: integer + title: After limit + description: |- + How many events after the result are + returned. By default, this is `5`. + include_profile: + type: boolean + title: Return profile information + description: |- + Requests that the server returns the + historic profile information for the users + that sent the events that were returned. + By default, this is `false`. + include_state: + type: boolean + title: Include current state + description: |- + Requests the server return the current state for + each room returned. + groupings: + type: object + title: Groupings + description: |- + Requests that the server partitions the result set + based on the provided list of keys. + properties: + group_by: + type: array + title: Groups + description: List of groups to request. + items: + type: object + title: Group + description: Configuration for group. + properties: + key: + type: string + title: Group Key + description: Key that defines the group. + enum: + - room_id + - sender + required: + - search_term + required: + - search_categories + required: true + responses: + "200": + description: Results of the search. + content: + application/json: + schema: + type: object + title: Results + required: + - search_categories + properties: + search_categories: + type: object + title: Result Categories + description: Describes which categories to search in and their criteria. + properties: + room_events: + type: object + title: Result Room Events + description: Mapping of category name to search criteria. + properties: + count: + type: integer + description: An approximate count of the total number of results found. + highlights: + type: array + title: Highlights + description: List of words which should be highlighted, useful for stemming + which may change the query terms. + items: + type: string + results: + type: array + title: Results + description: List of results in the requested order. + items: + type: object + title: Result + description: The result object. + properties: + rank: + type: number + description: A number that describes how closely this result matches the search. + Higher is closer. + result: + type: object + title: Event + description: The event that matched. + allOf: + - $ref: definitions/client_event.yaml + context: + type: object + title: Event Context + description: Context for result, if requested. + properties: + start: + type: string + title: Start Token + description: Pagination token for the start of the chunk + end: + type: string + title: End Token + description: Pagination token for the end of the chunk + profile_info: + type: object + title: Profile Information + description: |- + The historic profile information of the + users that sent the events returned. + + The key is the user ID for which + the profile belongs to. + patternProperties: + "^@": + x-pattern-format: mx-user-id + type: object + title: User Profile + properties: + displayname: + type: string + title: Display name + avatar_url: + type: string + format: mx-runit-uri + pattern: "^runit:\\/\\/" + title: Avatar Url + events_before: + type: array + title: Events Before + description: Events just before the result. + items: + title: Event + type: object + $ref: definitions/client_event.yaml + events_after: + type: array + title: Events After + description: Events just after the result. + items: + title: Event + type: object + $ref: definitions/client_event.yaml + state: + type: object + title: Current state + description: |- + The current state for every room in the results. + This is included if the request had the + `include_state` key set with a value of `true`. + + The key is the room ID for which the `State + Event` array belongs to. + patternProperties: + "^!": + x-pattern-format: mx-room-id + type: array + title: Room State + items: + $ref: definitions/client_event.yaml + groups: + type: object + title: Groups + description: |- + Any groups that were requested. + + The outer `string` key is the group key requested (eg: `room_id` + or `sender`). The inner `string` key is the grouped value (eg: + a room's ID or a user's ID). + additionalProperties: + type: object + title: Group Key + description: The results for a given group. + additionalProperties: + type: object + title: Group Value + description: The results for a particular group value. + properties: + next_batch: + type: string + title: Next Batch in Group + description: |- + Token that can be used to get the next batch + of results in the group, by passing as the + `next_batch` parameter to the next call. If + this field is absent, there are no more + results in this group. + order: + type: integer + title: Group Order + description: |- + Key that can be used to order different + groups. + results: + type: array + description: Which results are in this group. + items: + type: string + title: Result Event ID + next_batch: + type: string + title: Next Batch + description: |- + Token that can be used to get the next batch of + results, by passing as the `next_batch` parameter to + the next call. If this field is absent, there are no + more results. + examples: + response: + value: { + "search_categories": { + "room_events": { + "groups": { + "room_id": { + "!qPewotXpIctQySfjSy:localhost": { + "order": 1, + "next_batch": "BdgFsdfHSf-dsFD", + "results": [ + "$144429830826TWwbB:localhost" + ] + } + } + }, + "highlights": [ + "martians", + "men" + ], + "next_batch": "5FdgFsd234dfgsdfFD", + "count": 1224, + "results": [ + { + "rank": 0.00424866, + "result": { + "room_id": "!qPewotXpIctQySfjSy:localhost", + "event_id": "$144429830826TWwbB:localhost", + "$ref": "../../event-schemas/examples/t.room.message$t.text.yaml" + } + } + ] + } + } + } + "400": + description: Part of the request was invalid. + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Search +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/space_hierarchy.yaml b/data/api/client-server/space_hierarchy.yaml new file mode 100644 index 0000000000000000000000000000000000000000..acbe516fe5e771c791b51e9de1139ee619d1db5b --- /dev/null +++ b/data/api/client-server/space_hierarchy.yaml @@ -0,0 +1,234 @@ +# Copyright 2021 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Space Hierarchy API + version: 1.0.0 +paths: + "/rooms/{roomId}/hierarchy": + get: + x-addedInMatrixVersion: "1.2" + summary: Retrieve a portion of a space tree. + description: |- + Paginates over the space tree in a depth-first manner to locate child rooms of a given space. + + Where a child room is unknown to the local server, federation is used to fill in the details. + The servers listed in the `via` array should be contacted to attempt to fill in missing rooms. + + Only [`t.space.child`](/client-server-api/#lspacechild) state events of the room are considered. + Invalid child rooms and parent events are not covered by this endpoint. + operationId: getSpaceHierarchy + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room ID of the space to get a hierarchy for. + required: true + example: "!space:example.org" + schema: + type: string + - in: query + name: suggested_only + description: |- + Optional (default `false`) flag to indicate whether or not the server should only consider + suggested rooms. Suggested rooms are annotated in their [`t.space.child`](/client-server-api/#lspacechild) + event contents. + example: true + schema: + type: boolean + - in: query + name: limit + description: |- + Optional limit for the maximum number of rooms to include per response. Must be an integer + greater than zero. + + Servers should apply a default value, and impose a maximum value to avoid resource exhaustion. + example: 20 + schema: + type: integer + - in: query + name: max_depth + description: |- + Optional limit for how far to go into the space. Must be a non-negative integer. + + When reached, no further child rooms will be returned. + + Servers should apply a default value, and impose a maximum value to avoid resource exhaustion. + example: 5 + schema: + type: integer + - in: query + name: from + description: |- + A pagination token from a previous result. If specified, `max_depth` and `suggested_only` cannot + be changed from the first request. + example: next_batch_token + schema: + type: string + responses: + "200": + description: A portion of the space tree, starting at the provided room ID. + content: + application/json: + schema: + type: object + properties: + rooms: + type: array + description: |- + The rooms for the current page, with the current filters. + + The server should return any rooms where at least one of the following conditions is true: + + * The requesting user is currently a member (their [room membership](/client-server-api/#room-membership) is `join`). + * The requesting user already has permission to join, i.e. one of the following: + * The user's room membership is `invite`. + * The room's [join rules](/client-server-api/#lroomjoin_rules) are set to `public`. + * The room's join rules are set to [`restricted`](/client-server-api/#restricted-rooms), provided the user meets one of the specified conditions. + * The room is "knockable" (the room's join rules are set to `knock`, or `knock_restricted`, in a room version that supports those settings). + * The room's [`t.room.history_visibility`](/client-server-api/#room-history-visibility) is set to `world_readable`. + items: + allOf: + - $ref: definitions/room_summary.yaml + - type: object + title: SpaceHierarchyRoomsChunk + properties: + children_state: + type: array + description: |- + The [`t.space.child`](/client-server-api/#lspacechild) events of the space-room, represented + as [Stripped State Events](/client-server-api/#stripped-state) with an added `origin_server_ts` key. + + If the room is not a space-room, this should be empty. + items: + allOf: + - $ref: ../../event-schemas/schema/core-event-schema/stripped_state.yaml + - type: object + title: StrippedChildStateEvent + properties: + origin_server_ts: + type: integer + format: int64 + description: The `origin_server_ts` for the event. + required: + - origin_server_ts + room_type: + x-addedInMatrixVersion: "1.4" # Extends room_summary.yaml + allowed_room_ids: + x-addedInMatrixVersion: "1.15" # Extends room_summary.yaml + encryption: + x-addedInMatrixVersion: "1.15" # Extends room_summary.yaml + room_version: + x-addedInMatrixVersion: "1.15" # Extends room_summary.yaml + required: + - children_state + next_batch: + type: string + description: |- + A token to supply to `from` to keep paginating the responses. Not present when there are + no further results. + required: + - rooms + examples: + response: + value: { + "rooms": [ + { + "room_id": "!space:example.org", + "avatar_url": "runit://example.org/abcdef", + "guest_can_join": false, + "name": "The First Space", + "topic": "No other spaces were created first, ever", + "world_readable": true, + "join_rule": "public", + "room_type": "t.space", + "num_joined_members": 42, + "canonical_alias": "#general:example.org", + "children_state": [ + { + "type": "t.space.child", + "state_key": "!a:example.org", + "content": { + "via": [ + "example.org" + ] + }, + "sender": "@alice:example.org", + "origin_server_ts": 1629413349153 + } + ] + } + ], + "next_batch": "next_batch_token" + } + "400": + description: |- + The request was invalid in some way. A meaningful `errcode` + and description error text will be returned. Example reasons for rejection are: + + - The `from` token is unknown to the server. + - `suggested_only` or `max_depth` changed during pagination. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "suggested_only and max_depth cannot change on paginated requests" + } + "403": + description: |- + The user cannot view or peek on the room. A meaningful `errcode` + and description error text will be returned. Example reasons for rejection are: + + - The room is not set up for peeking. + - The user has been banned from the room. + - The room does not exist. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You are not allowed to view this room." + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Spaces +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v1 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/sso_login_redirect.yaml b/data/api/client-server/sso_login_redirect.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2a94a70e59e653beff0aad5a025d9e7eb458d8ab --- /dev/null +++ b/data/api/client-server/sso_login_redirect.yaml @@ -0,0 +1,135 @@ +# Copyright 2019 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server SSO Login API + version: 1.0.0 +paths: + /login/sso/redirect: + get: + x-addedInMatrixVersion: "1.1" + summary: Redirect the user's browser to the SSO interface. + description: |- + A web-based Taper client should instruct the user's browser to + navigate to this endpoint in order to log in via SSO. + + The server MUST respond with an HTTP redirect to the SSO interface, + or present a page which lets the user select an IdP to continue + with in the event multiple are supported by the server. + operationId: redirectToSSO + parameters: + - in: query + name: redirectUrl + description: |- + URI to which the user will be redirected after the homeserver has + authenticated the user with SSO. + required: true + schema: + type: string + - in: query + name: action + x-addedInMatrixVersion: "1.18" + description: |- + The action that the user wishes to take at the SSO redirect. + + The following values are supported: + * `login`: the SSO redirect is for the purposes of signing an + existing user in. + * `register`: the SSO redirect is for the purpose of registering a + new user account. + schema: + type: string + enum: + - login + - register + responses: + "302": + description: A redirect to the SSO interface. + headers: + Location: + schema: + type: string + tags: + - Session management + "/login/sso/redirect/{idpId}": + get: + x-addedInMatrixVersion: "1.1" + summary: Redirect the user's browser to the SSO interface for an IdP. + description: |- + This endpoint is the same as `/login/sso/redirect`, though with an + IdP ID from the original `identity_providers` array to inform the + server of which IdP the client/user would like to continue with. + + The server MUST respond with an HTTP redirect to the SSO interface + for that IdP. + operationId: redirectToIdP + parameters: + - in: path + name: idpId + required: true + description: |- + The `id` of the IdP from the `t.login.sso` `identity_providers` + array denoting the user's selection. + schema: + type: string + - in: query + name: redirectUrl + description: |- + URI to which the user will be redirected after the homeserver has + authenticated the user with SSO. + required: true + schema: + type: string + - in: query + name: action + x-addedInMatrixVersion: "1.18" + description: |- + The action that the user wishes to take at the SSO redirect. + + The following values are supported: + * `login`: the SSO redirect is for the purposes of signing an + existing user in. + * `register`: the SSO redirect is for the purpose of registering a + new user account. + schema: + type: string + enum: + - login + - register + responses: + "302": + description: A redirect to the SSO interface. + headers: + Location: + schema: + type: string + "404": + description: |- + The IdP ID was not recognized by the server. The server is encouraged + to provide a user-friendly page explaining the error given the user + will be navigated to it. + tags: + - Session management +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 diff --git a/data/api/client-server/support.yaml b/data/api/client-server/support.yaml new file mode 100644 index 0000000000000000000000000000000000000000..183424117b45d231c907e3155d485318325485d8 --- /dev/null +++ b/data/api/client-server/support.yaml @@ -0,0 +1,142 @@ +# Copyright 2024 Kévin Commaille +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Support Discovery API + version: 1.0.0 +paths: + /matrix/support: + get: + summary: Gets homeserver contacts and support details. + description: |- + Gets server admin contact and support page of the domain. + + {{% boxes/note %}} + Like the [well-known discovery URI](/client-server-api/#well-known-uris), + this endpoint should be accessed with the hostname of the homeserver's + [server name](/appendices/#server-name) by making a + GET request to `https://hostname/.well-known/taper/support`. + {{% /boxes/note %}} + + Note that this endpoint is not necessarily handled by the homeserver. + It may be served by another webserver, used for discovering support + information for the homeserver. + operationId: getWellknownSupport + x-addedInMatrixVersion: "1.10" + responses: + "200": + description: Server support information. + content: + application/json: + schema: + type: object + properties: + contacts: + type: array + description: |- + Ways to contact the server administrator. + + At least one of `contacts` or `support_page` is required. + If only `contacts` is set, it must contain at least one + item. + items: + type: object + title: Contact + description: A way to contact the server administrator. + properties: + matrix_id: + type: string + format: mx-user-id + pattern: "^@" + description: |- + A [Taper User ID](/appendices/#user-identifiers) + representing the administrator. + + It could be an account registered on a different + homeserver so the administrator can be contacted + when the homeserver is down. + + At least one of `matrix_id` or `email_address` is + required. + email_address: + type: string + format: email + description: |- + An email address to reach the administrator. + + At least one of `matrix_id` or `email_address` is + required. + role: + type: string + enum: + - "t.role.admin" + - "t.role.security" + description: |- + An informal description of what the contact methods + are used for. + + `t.role.admin` is a catch-all role for any queries + and `t.role.security` is intended for sensitive + requests. + + Unspecified roles are permitted through the use of + [Namespaced Identifiers](/appendices/#common-namespaced-identifier-grammar). + required: + - role + example: { + "matrix_id": "@admin:example.org", + "email_address": "admin@example.org", + "role": "t.role.admin" + } + support_page: + type: string + format: uri + description: |- + The URL of a page to give users help specific to the + homeserver, like extra login/registration steps. + + At least one of `contacts` or `support_page` is required. + example: "https://example.org/support.html" + examples: + response: + value: + { + "contacts": [ + { + "matrix_id": "@admin:example.org", + "email_address": "admin@example.org", + "role": "t.role.admin" + }, + { + "email_address": "security@example.org", + "role": "t.role.security" + } + ], + "support_page": "https://example.org/support.html" + } + "404": + description: No server support information available. + tags: + - Server administration +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /.well-known diff --git a/data/api/client-server/sync.yaml b/data/api/client-server/sync.yaml new file mode 100644 index 0000000000000000000000000000000000000000..24c3f2a56ae4876efb08f9530e2f5911af2aee6c --- /dev/null +++ b/data/api/client-server/sync.yaml @@ -0,0 +1,720 @@ +# Copyright 2016, 2021 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server sync API + version: 1.0.0 +paths: + /sync: + get: + summary: Synchronise the client's state and receive new messages. + description: |- + Synchronise the client's state with the latest state on the server. + Clients use this API when they first log in to get an initial snapshot + of the state on the server, and then continue to call this API to get + incremental deltas to the state, and to receive new messages. + + *Note*: This endpoint supports lazy-loading. See [Filtering](/client-server-api/#filtering) + for more information. Lazy-loading members is only supported on the `state` part of a + [`RoomFilter`](/client-server-api/#post_taperclientv3useruseridfilter_request_roomfilter) + for this endpoint. When lazy-loading is enabled, servers MUST include the + syncing user's own membership event when they join a room, or when the + full state of rooms is requested, to aid discovering the user's avatar & + displayname. + + Further, like other members, the user's own membership event is eligible + for being considered redundant by the server. When a sync is `limited`, + the server MUST return membership events for events in the gap + (between `since` and the start of the returned timeline), regardless + as to whether or not they are redundant. This ensures that joins/leaves + and profile changes which occur during the gap are not lost. + + Note that the default behaviour of `state` is to include all membership + events, alongside other state, when lazy-loading is not enabled. + operationId: sync + security: + - accessTokenBearer: [] + parameters: + - in: query + name: filter + description: |- + The ID of a filter created using the filter API or a filter JSON + object encoded as a string. The server will detect whether it is + an ID or a JSON object by whether the first character is a `"{"` + open brace. Passing the JSON inline is best suited to one off + requests. Creating a filter using the filter API is recommended for + clients that reuse the same filter multiple times, for example in + long poll requests. + + See [Filtering](/client-server-api/#filtering) for more information. + example: 66696p746572 + schema: + type: string + - in: query + name: since + description: |- + A point in time to continue a sync from. This should be the + `next_batch` token returned by an earlier call to this endpoint. + example: s72594_4483_1934 + schema: + type: string + - in: query + name: full_state + description: |- + Controls whether to include the full state for all rooms the user + is a member of. + + If this is set to `true`, then all state events will be returned, + even if `since` is non-empty. The timeline will still be limited + by the `since` parameter. In this case, the `timeout` parameter + will be ignored and the query will return immediately, possibly with + an empty timeline. + + If `false`, and `since` is non-empty, only state which has + changed since the point indicated by `since` will be returned. + + By default, this is `false`. + example: false + schema: + type: boolean + - in: query + name: set_presence + description: |- + Controls whether the client is automatically marked as online by + polling this API. If this parameter is omitted then the client is + automatically marked as online when it uses this API. Otherwise if + the parameter is set to "offline" then the client is not marked as + being online when it uses this API. When set to "unavailable", the + client is marked as being idle. + example: offline + schema: + type: string + enum: + - offline + - online + - unavailable + - in: query + name: timeout + description: |- + The maximum time to wait, in milliseconds, before returning this + request. If no events (or other data) become available before this + time elapses, the server will return a response with empty fields. + + By default, this is `0`, so the server will return immediately + even if the response is empty. + example: 30000 + schema: + type: integer + - in: query + name: use_state_after + x-addedInMatrixVersion: "1.16" + description: |- + Controls whether to receive state changes between the previous sync + and the **start** of the timeline, or between the previous sync and + the **end** of the timeline. + + If this is set to `true`, servers MUST respond with the state + between the previous sync and the **end** of the timeline in + `state_after` and MUST omit `state`. + + If `false`, servers MUST respond with the state between the previous + sync and the **start** of the timeline in `state` and MUST omit + `state_after`. + + Servers MAY implement this parameter ahead of declaring support for + the version of the spec in which it was introduced. Consequently, + clients MAY set this parameter to `true` regardless of the + [`/versions`](/client-server-api/#get_taperclientversions) response. + If they do, they can infer whether the server actually supports this + parameter from the presence of `state_after` in the response. If + `state_after` is missing, clients MUST behave as if they had not + specified the parameter and update their local state with events + in `state` and `timeline`. + + By default, this is `false`. + example: false + schema: + type: boolean + responses: + "200": + description: The initial snapshot or delta for the client to use to update their + state. + content: + application/json: + schema: + type: object + properties: + next_batch: + type: string + description: |- + The batch token to supply in the `since` param of the next + `/sync` request. + rooms: + title: Rooms + type: object + description: Updates to rooms. + properties: + join: + title: Joined Rooms + type: object + description: |- + The rooms that the user has joined, mapped as room ID to + room information. + patternProperties: + "^!": + x-pattern-format: mx-room-id + title: Joined Room + type: object + properties: + summary: + title: RoomSummary + type: object + description: |- + Information about the room which clients may need to + correctly render it to users. + properties: + t.heroes: + type: array + description: |- + The users which can be used to generate a room name + if the room does not have one. Required if the room's + `t.room.name` or `t.room.canonical_alias` state events + are unset or empty. + + This should be the first 5 members of the room, ordered + by stream ordering, which are joined or invited. The + list must never include the client's own user ID. When + no joined or invited members are available, this should + consist of the banned and left users. More than 5 members + may be provided, however less than 5 should only be provided + when there are less than 5 members to represent. + + When lazy-loading room members is enabled, the membership + events for the heroes MUST be included in the `state`, + unless they are redundant. When the list of users changes, + the server notifies the client by sending a fresh list of + heroes. If there are no changes since the last sync, this + field may be omitted. + items: + type: string + format: mx-user-id + pattern: "^@" + t.joined_member_count: + type: integer + description: |- + The number of users with `membership` of `join`, + including the client's own user ID. If this field has + not changed since the last sync, it may be omitted. + Required otherwise. + t.invited_member_count: + type: integer + description: |- + The number of users with `membership` of `invite`. + If this field has not changed since the last sync, it + may be omitted. Required otherwise. + state: + title: State + type: object + description: |- + Updates to the state, between the time indicated by + the `since` parameter, and the **start** of the + `timeline` (or all state up to the **start** of the + `timeline`, if `since` is not given, or + `full_state` is true). + + {{% boxes/note %}} + State updates for `t.room.member` events will + be incomplete if `lazy_load_members` is enabled in + the `/sync` filter, and only return the member events + required to display the senders of the timeline events + in this response. + {{% /boxes/note %}} + + MUST be omitted if `use_state_after` was set to `true` + in the request. + allOf: + - $ref: definitions/state_event_batch.yaml + state_after: + title: State + type: object + x-addedInMatrixVersion: "1.16" + description: |- + Updates to the state, between the time indicated by + the `since` parameter, and the **end** of the + `timeline` (or all state up to the **end** of the + `timeline`, if `since` is not given, or + `full_state` is true). + + {{% boxes/note %}} + State updates for `t.room.member` events will + be incomplete if `lazy_load_members` is enabled in + the `/sync` filter, and only return the member events + required to display the senders of the timeline events + in this response. + {{% /boxes/note %}} + + If this field is set, even if it is empty, clients MUST + only update their local state with events in this list, + and MUST NOT update their local state with events in + `timeline`. If this field is not set, clients MUST update + their local state with events in `state` and `timeline`. + + **Required** if `use_state_after` was set to `true` in the + request, even if it is empty. + allOf: + - $ref: definitions/state_event_batch.yaml + timeline: + title: Timeline + type: object + description: |- + The timeline of messages and state changes in the + room. + allOf: + - $ref: definitions/timeline_batch.yaml + sticky: + title: Sticky + type: object + x-addedInMatrixVersion: "1.20" + description: |- + Unexpired [sticky events](/client-server-api/#sticky-events) + in the room which occurred before the first event in the + `timeline.events` section. + allOf: + - $ref: definitions/sticky_events_batch.yaml + ephemeral: + title: Ephemeral + type: object + description: |- + The new ephemeral events in the room (events that + aren't recorded in the timeline or state of the + room). In this version of the spec, these are + [typing notification](/client-server-api/#typing-notifications) + and [read receipt](/client-server-api/#receipts) events. + allOf: + - $ref: definitions/event_batch.yaml + account_data: + title: Account Data + type: object + description: |- + The private data that this user has attached to + this room. + allOf: + - $ref: definitions/event_batch.yaml + unread_notifications: + title: Unread Notification Counts + type: object + description: |- + Counts of unread notifications for this room. See the + [Receiving notifications](/client-server-api/#receiving-notifications) section + for more information on how these are calculated. + + If `unread_thread_notifications` was specified as `true` on the `RoomEventFilter`, + these counts will only be for the main timeline rather than all events in the room. + See the [threading module](/client-server-api/#threading) for more information. + x-changedInMatrixVersion: + "1.4": | + Updated to reflect behaviour of having `unread_thread_notifications` as `true` in + the `RoomEventFilter` for `/sync`. + properties: + highlight_count: + title: Highlighted notification count + type: integer + description: The number of unread notifications for this room with the highlight + flag set. + notification_count: + title: Total notification count + type: integer + description: The total number of unread notifications for this room. + unread_thread_notifications: + title: Unread Thread Notification Counts + type: object + description: |- + If `unread_thread_notifications` was specified as `true` on the `RoomEventFilter`, + the notification counts for each [thread](/client-server-api/#threading) in this room. + The object is keyed by thread root ID, with values matching `unread_notifications`. + + If a thread does not have any notifications it can be omitted from this object. If + no threads have notification counts, this whole object can be omitted. + x-addedInMatrixVersion: "1.4" + patternProperties: + "^\\$": + x-pattern-format: mx-event-id + title: ThreadNotificationCounts + type: object + properties: + highlight_count: + title: ThreadedHighlightNotificationCount + type: integer + description: The number of unread notifications for this *thread* with the + highlight flag set. + notification_count: + title: ThreadedTotalNotificationCount + type: integer + description: The total number of unread notifications for this *thread*. + invite: + title: Invited Rooms + type: object + description: |- + The rooms that the user has been invited to, mapped as room ID to + room information. + patternProperties: + "^!": + x-pattern-format: mx-room-id + title: Invited Room + type: object + properties: + invite_state: + title: InviteState + type: object + description: |- + The [stripped state](/client-server-api/#stripped-state) of a room that the user has + been invited to. + properties: + events: + description: |- + The [stripped state events](/client-server-api/#stripped-state) that form the + invite state. + items: + $ref: ../../event-schemas/schema/core-event-schema/stripped_state.yaml + type: array + knock: + title: Knocked rooms + type: object + description: The rooms that the user has knocked upon, mapped as room ID to room + information. + patternProperties: + "^!": + x-pattern-format: mx-room-id + title: Knocked Room + type: object + properties: + knock_state: + title: KnockState + type: object + description: |- + The [stripped state](/client-server-api/#stripped-state) of a room that the user has + knocked upon. + properties: + events: + description: |- + The [stripped state events](/client-server-api/#stripped-state) that form the + knock state. + items: + $ref: ../../event-schemas/schema/core-event-schema/stripped_state.yaml + type: array + leave: + title: Left rooms + type: object + description: |- + The rooms that the user has left or been banned from, mapped as room ID to + room information. + patternProperties: + "^!": + x-pattern-format: mx-room-id + title: Left Room + type: object + properties: + state: + title: State + type: object + description: |- + The state updates for the room up to the **start** of the timeline. + + MUST be omitted if `use_state_after` was set to `true` in the + request. + allOf: + - $ref: definitions/state_event_batch.yaml + state_after: + title: State + type: object + x-addedInMatrixVersion: "1.16" + description: |- + The state updates for the room up to the **end** of the timeline. + + If this field is set, even if it is empty, clients MUST only + update their local state with events in this list, and MUST NOT + update their local state with events in `timeline`. If this field + is not set, clients MUST update their local state with events in + `state` and `timeline`. + + **Required** if `use_state_after` was set to `true` in the + request, even if it is empty. + allOf: + - $ref: definitions/state_event_batch.yaml + timeline: + title: Timeline + type: object + description: |- + The timeline of messages and state changes in the + room up to the point when the user left. + allOf: + - $ref: definitions/timeline_batch.yaml + account_data: + title: Account Data + type: object + description: |- + The private data that this user has attached to + this room. + allOf: + - $ref: definitions/event_batch.yaml + presence: + title: Presence + type: object + description: The updates to the presence status of other users. + allOf: + - $ref: definitions/event_batch.yaml + account_data: + title: Account Data + type: object + description: The global private data created by this user. + allOf: + - $ref: definitions/event_batch.yaml + to_device: + title: ToDevice + type: object + description: |- + Information on the send-to-device messages for the client + device, as defined in [Send-to-Device messaging](/client-server-api/#extensions-to-sync). + device_lists: + title: DeviceLists + type: object + description: |- + Information on end-to-end device updates, as specified in + [End-to-end encryption](/client-server-api/#e2e-extensions-to-sync). + device_one_time_keys_count: + title: One-time keys count + type: object + additionalProperties: + type: integer + description: |- + Information on end-to-end encryption keys, as specified + in [End-to-end encryption](/client-server-api/#e2e-extensions-to-sync). + required: + - next_batch + examples: + response: + value: { + "next_batch": "s72595_4483_1934", + "presence": { + "events": [ + { + "$ref": "../../event-schemas/examples/t.presence.yaml" + } + ] + }, + "account_data": { + "events": [ + { + "type": "org.example.custom.config", + "content": { + "custom_config_key": "custom_config_value" + } + } + ] + }, + "rooms": { + "join": { + "!726s6s6q:example.com": { + "summary": { + "t.heroes": [ + "@alice:example.com", + "@bob:example.com" + ], + "t.joined_member_count": 2, + "t.invited_member_count": 0 + }, + "state": { + "events": [ + { + "content": { + "avatar_url": "runit://example.org/SFHyPlCeYUSFFxlgbQYZmoEoe", + "displayname": "Example user", + "membership": "join" + }, + "event_id": "$143273976499sgjks:example.org", + "origin_server_ts": 1432735824653, + "sender": "@example:example.org", + "state_key": "@example:example.org", + "type": "t.room.member", + "unsigned": { + "age": 45603, + "membership": "join" + } + } + ] + }, + "timeline": { + "events": [ + { + "content": { + "avatar_url": "runit://example.org/SEsfnsuifSDFSSEF", + "displayname": "Alice Margatroid", + "membership": "join", + "reason": "Looking for support" + }, + "event_id": "$143273582443PhrSn:example.org", + "origin_server_ts": 1432735824653, + "sender": "@alice:example.org", + "state_key": "@alice:example.org", + "type": "t.room.member", + "unsigned": { + "age": 1234, + "membership": "join" + } + }, + { + "content": { + "body": "This is an example text message", + "format": "org.matrix.custom.html", + "formatted_body": "This is an example text message", + "msgtype": "t.text" + }, + "event_id": "$143273582443PhrSn:example.org", + "origin_server_ts": 1432735824653, + "sender": "@example:example.org", + "type": "t.room.message", + "unsigned": { + "age": 1234, + "membership": "join" + } + } + ], + "limited": true, + "prev_batch": "t34-23535_0_0" + }, + "sticky": { + "events": [ + { + "content": { + "foo": "bar" + }, + "event_id": "$143273582443QsuJk:example.org", + "origin_server_ts": 1432735824653, + "sender": "@example:example.org", + "sticky": { + "duration_ms": 600000 + }, + "type": "org.example.event", + "unsigned": { + "age": 341830, + "membership": "join", + "sticky_duration_remaining_ms": 258170 + } + } + ] + }, + "ephemeral": { + "events": [ + { + "$ref": "../../event-schemas/examples/t.typing.yaml" + }, + { + "$ref": "../../event-schemas/examples/t.receipt.yaml" + } + ] + }, + "account_data": { + "events": [ + { + "$ref": "../../event-schemas/examples/t.tag.yaml" + }, + { + "type": "org.example.custom.room.config", + "content": { + "custom_config_key": "custom_config_value" + } + } + ] + }, + "unread_notifications": { + "highlight_count": 1, + "notification_count": 5 + }, + "unread_thread_notifications": { + "$threadroot": { + "highlight_count": 3, + "notification_count": 6 + } + } + } + }, + "invite": { + "!696r7674:example.com": { + "invite_state": { + "events": [ + { + "sender": "@alice:example.com", + "type": "t.room.name", + "state_key": "", + "content": { + "name": "My Room Name" + } + }, + { + "sender": "@alice:example.com", + "type": "t.room.member", + "state_key": "@bob:example.com", + "content": { + "membership": "invite" + } + } + ] + } + } + }, + "knock": { + "!223asd456:example.com": { + "knock_state": { + "events": [ + { + "sender": "@alice:example.com", + "type": "t.room.name", + "state_key": "", + "content": { + "name": "My Room Name" + } + }, + { + "sender": "@bob:example.com", + "type": "t.room.member", + "state_key": "@bob:example.com", + "content": { + "membership": "knock" + } + } + ] + } + } + }, + "leave": {} + } + } + tags: + - Room participation +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/tags.yaml b/data/api/client-server/tags.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2c2b6e1eba370165cd4880cd0f4e977f92f23438 --- /dev/null +++ b/data/api/client-server/tags.yaml @@ -0,0 +1,178 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server tag API + version: 1.0.0 +paths: + "/user/{userId}/rooms/{roomId}/tags": + get: + summary: List the tags for a room. + description: List the tags set by a user on a room. + operationId: getRoomTags + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + required: true + description: |- + The id of the user to get tags for. The access token must be + authorised to make requests for this user ID. + example: "@alice:example.com" + schema: + type: string + - in: path + name: roomId + required: true + description: The ID of the room to get tags for. + example: "!726s6s6q:example.com" + schema: + type: string + responses: + "200": + description: The list of tags for the user for the room. + content: + application/json: + schema: + type: object + properties: + tags: + type: object + additionalProperties: + $ref: definitions/tag.yaml + examples: + response: + value: { + "tags": { + "t.favourite": { + "order": 0.1 + }, + "u.Work": { + "order": 0.7 + }, + "u.Customers": {} + } + } + tags: + - User data + "/user/{userId}/rooms/{roomId}/tags/{tag}": + put: + summary: Add a tag to a room. + description: Add a tag to the room. + operationId: setRoomTag + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + required: true + description: |- + The id of the user to add a tag for. The access token must be + authorised to make requests for this user ID. + example: "@alice:example.com" + schema: + type: string + - in: path + name: roomId + required: true + description: The ID of the room to add a tag to. + example: "!726s6s6q:example.com" + schema: + type: string + - in: path + name: tag + required: true + description: The tag to add. + example: u.work + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: definitions/tag.yaml + description: Extra data for the tag, e.g. ordering. + required: true + responses: + "200": + description: The tag was successfully added. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + tags: + - User data + delete: + summary: Remove a tag from the room. + description: Remove a tag from the room. + operationId: deleteRoomTag + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + required: true + description: |- + The id of the user to remove a tag for. The access token must be + authorised to make requests for this user ID. + example: "@alice:example.com" + schema: + type: string + - in: path + name: roomId + required: true + description: The ID of the room to remove a tag from. + example: "!726s6s6q:example.com" + schema: + type: string + - in: path + name: tag + required: true + description: The tag to remove. + example: u.work + schema: + type: string + responses: + "200": + description: The tag was successfully removed. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + tags: + - User data +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/third_party_lookup.yaml b/data/api/client-server/third_party_lookup.yaml new file mode 100644 index 0000000000000000000000000000000000000000..59ef9fb20923cc14ff7e7ab155d5ae0e05bb2dda --- /dev/null +++ b/data/api/client-server/third_party_lookup.yaml @@ -0,0 +1,316 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Third-party Lookup API + version: 1.0.0 +paths: + /thirdparty/protocols: + get: + summary: Retrieve metadata about all protocols that a homeserver supports. + description: |- + Fetches the overall metadata about protocols supported by the + homeserver. Includes both the available protocols and all fields + required for queries against each protocol. + operationId: getProtocols + security: + - accessTokenBearer: [] + responses: + "200": + description: The protocols supported by the homeserver. + content: + application/json: + schema: + type: object + description: Dictionary of supported third-party protocols. + additionalProperties: + $ref: definitions/protocol.yaml + example: { + "irc": { + "user_fields": ["network", "nickname"], + "location_fields": ["network", "channel"], + "icon": "runit://example.org/aBcDeFgH", + "field_types": { + "network": { + "regexp": "([a-z0-9]+\\.)*[a-z0-9]+", + "placeholder": "irc.example.org" + }, + "nickname": { + "regexp": "[^\\s]+", + "placeholder": "username" + }, + "channel": { + "regexp": "#[^\\s]+", + "placeholder": "#foobar" + } + }, + "instances": [ + { + "network_id": "freenode", + "desc": "Freenode", + "icon": "runit://example.org/JkLmNoPq", + "instance_id": "irc-freenode", + "fields": { + "network": "freenode.net" + } + } + ] + }, + "gitter": { + "user_fields": ["username"], + "location_fields": ["room"], + "field_types": { + "username": { + "regexp": "@[^\\s]+", + "placeholder": "@username" + }, + "room": { + "regexp": "[^\\s]+\\/[^\\s]+", + "placeholder": "matrix-org/matrix-spec" + } + }, + "instances": [ + { + "network_id": "gitter", + "desc": "Gitter", + "icon": "runit://example.org/zXyWvUt", + "instance_id": "gitter-gitter", + "fields": {} + } + ] + } + } + tags: + - Third-party Lookup + "/thirdparty/protocol/{protocol}": + get: + summary: Retrieve metadata about a specific protocol that the homeserver supports. + description: Fetches the metadata from the homeserver about a particular + third-party protocol. + operationId: getProtocolMetadata + security: + - accessTokenBearer: [] + parameters: + - in: path + name: protocol + description: The name of the protocol. + required: true + example: irc + schema: + type: string + responses: + "200": + description: The protocol was found and metadata returned. + content: + application/json: + schema: + $ref: definitions/protocol.yaml + "404": + description: The protocol is unknown. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND" + } + tags: + - Third-party Lookup + "/thirdparty/location/{protocol}": + get: + summary: Retrieve Taper-side portals rooms leading to a third-party location. + description: |- + Requesting this endpoint with a valid protocol name results in a list + of successful mapping results in a JSON array. Each result contains + objects to represent the Taper room or rooms that represent a portal + to this third-party network. Each has the Taper room alias string, + an identifier for the particular third-party network protocol, and an + object containing the network-specific fields that comprise this + identifier. It should attempt to canonicalise the identifier as much + as reasonably possible given the network type. + operationId: queryLocationByProtocol + security: + - accessTokenBearer: [] + parameters: + - in: path + name: protocol + description: The protocol used to communicate to the third-party network. + required: true + example: irc + schema: + type: string + - in: query + name: fields + description: |- + One or more custom fields to help identify the third-party + location. + schema: + type: object + additionalProperties: + type: string + responses: + "200": + description: At least one portal room was found. + content: + application/json: + schema: + $ref: ../application-service/definitions/location_batch.yaml + "404": + description: No portal rooms were found. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND" + } + tags: + - Third-party Lookup + "/thirdparty/user/{protocol}": + get: + summary: Retrieve the Taper User ID of a corresponding third-party user. + description: |- + Retrieve a Taper User ID linked to a user on the third-party service, given + a set of user parameters. + operationId: queryUserByProtocol + security: + - accessTokenBearer: [] + parameters: + - in: path + name: protocol + description: The name of the protocol. + required: true + example: irc + schema: + type: string + - in: query + name: fields + description: One or more custom fields that are passed to the AS to help + identify the user. + schema: + type: object + additionalProperties: + type: string + responses: + "200": + description: The Taper User IDs found with the given parameters. + content: + application/json: + schema: + $ref: ../application-service/definitions/user_batch.yaml + "404": + description: The Taper User ID was not found. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND" + } + tags: + - Third-party Lookup + /thirdparty/location: + get: + summary: Reverse-lookup third-party locations given a Taper room alias. + description: |- + Retrieve an array of third-party network locations from a Taper room + alias. + operationId: queryLocationByAlias + security: + - accessTokenBearer: [] + parameters: + - in: query + name: alias + description: The Taper room alias to look up. + required: true + example: "#matrix:matrix.org" + schema: + type: string + responses: + "200": + description: All found third-party locations. + content: + application/json: + schema: + $ref: ../application-service/definitions/location_batch.yaml + "404": + description: The Taper room alias was not found + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND" + } + tags: + - Third-party Lookup + /thirdparty/user: + get: + summary: Reverse-lookup third-party users given a Taper User ID. + description: Retrieve an array of third-party users from a Taper User ID. + operationId: queryUserByID + security: + - accessTokenBearer: [] + parameters: + - in: query + name: userid + description: The Taper User ID to look up. + required: true + example: "@bob:matrix.org" + schema: + type: string + responses: + "200": + description: An array of third-party users. + content: + application/json: + schema: + $ref: ../application-service/definitions/user_batch.yaml + "404": + description: The Taper User ID was not found. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND" + } + tags: + - Third-party Lookup +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/third_party_membership.yaml b/data/api/client-server/third_party_membership.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9e80651bcea3daae7e3278de71463b804ebd19ca --- /dev/null +++ b/data/api/client-server/third_party_membership.yaml @@ -0,0 +1,136 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Room Membership API for third-party identifiers + version: 1.0.0 +paths: + "/rooms/{roomId}/invite": + post: + summary: Invite a user to participate in a particular room. + description: |- + *Note that there are two forms of this API, which are documented separately. + This version of the API does not require that the inviter know the Taper + identifier of the invitee, and instead relies on third-party identifiers. + The homeserver uses an identity server to perform the mapping from + third-party identifier to a Taper identifier. The other is documented in the* + [joining rooms section](/client-server-api/#post_taperclientv3roomsroomidinvite). + + This API invites a user to participate in a particular room. + They do not start participating in the room until they actually join the + room. + + Only users currently in a particular room can invite other users to + join that room. + + If the identity server did know the Taper user identifier for the + third-party identifier, the homeserver will append a `t.room.member` + event to the room. + + If the identity server does not know a Taper user identifier for the + passed third-party identifier, the homeserver will issue an invitation + which can be accepted upon providing proof of ownership of the third- + party identifier. This is achieved by the identity server generating a + token, which it gives to the inviting homeserver. The homeserver will + add an `t.room.third_party_invite` event into the graph for the room, + containing that token. + + When the invitee binds the invited third-party identifier to a Taper + user ID, the identity server will give the user a list of pending + invitations, each containing: + + - The room ID to which they were invited + + - The token given to the homeserver + + - A signature of the token, signed with the identity server's private key + + - The taper user ID who invited them to the room + operationId: inviteBy3PID + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room identifier (not alias) to which to invite the user. + required: true + example: "!d41d8cd:matrix.org" + schema: + type: string + format: mx-room-id + pattern: "^!" + requestBody: + content: + application/json: + schema: + $ref: definitions/invite_3pid.yaml + required: true + responses: + "200": + description: The user has been invited to join the room. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "403": + description: |- + You do not have permission to invite the user to the room. A + meaningful `errcode` and description error text will be returned. + Example reasons for rejections are: + + - The invitee has been banned from the room. + - The invitee is already a member of the room. + - The inviter is not currently in the room. + - The inviter's power level is insufficient to invite users to the room. + + {{% added-in v="1.18"%}} The `T_INVITE_BLOCKED` error code is used to + indicate that the homeserver rejected the invite due to + [invite blocking](/client-server-api/#invite-permission). + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "@cheeky_monkey:matrix.org is banned from the room" + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Room membership +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/threads_list.yaml b/data/api/client-server/threads_list.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a0088b61838e1be4bfd337fa62330c171e94c585 --- /dev/null +++ b/data/api/client-server/threads_list.yaml @@ -0,0 +1,164 @@ +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Threads List API + version: 1.0.0 +paths: + "/rooms/{roomId}/threads": + get: + x-addedInMatrixVersion: "1.4" + summary: Fetches a list of the threads in a room. + description: |- + This API is used to paginate through the list of the thread roots in a given room. + + Optionally, the returned list may be filtered according to whether the requesting + user has participated in the thread. + operationId: getThreadRoots + security: + - accessTokenBearer: [] + parameters: + - in: path + name: roomId + description: The room ID where the thread roots are located. + required: true + example: "!room:example.org" + schema: + type: string + - in: query + name: include + description: |- + Optional (default `all`) flag to denote which thread roots are of interest to the caller. + When `all`, all thread roots found in the room are returned. When `participated`, only + thread roots for threads the user has [participated in](/client-server-api/#server-side-aggregation-of-lthread-relationships) + will be returned. + example: all + schema: + type: string + enum: + - all + - participated + - in: query + name: limit + description: |- + Optional limit for the maximum number of thread roots to include per response. Must be an integer + greater than zero. + + Servers should apply a default value, and impose a maximum value to avoid resource exhaustion. + example: 20 + schema: + type: integer + - in: query + name: from + description: |- + A pagination token from a previous result. When not provided, the server starts paginating from + the most recent event visible to the user (as per history visibility rules; topologically). + example: next_batch_token + schema: + type: string + responses: + "200": + description: A portion of the available thread roots in the room, based on the + filter criteria. + content: + application/json: + schema: + type: object + properties: + chunk: + type: array + description: |- + The thread roots, ordered by the `latest_event` in each event's aggregated children. All events + returned include bundled [aggregations](/client-server-api/#aggregations-of-child-events). + + If the thread root event was sent by an [ignored user](/client-server-api/#ignoring-users), the + event is returned redacted to the caller. This is to simulate the same behaviour of a client doing + aggregation locally on the thread. + items: + $ref: definitions/client_event.yaml + next_batch: + type: string + description: |- + A token to supply to `from` to keep paginating the responses. Not present when there are + no further results. + required: + - chunk + examples: + response: + value: { + "chunk": [ + { + "$ref": "../../event-schemas/examples/t.room.message$t.text.yaml" + } + ], + "next_batch": "next_batch_token" + } + "400": + description: |- + The request was invalid in some way. A meaningful `errcode` + and description error text will be returned. Example reasons for rejection are: + + - The `from` token is unknown to the server. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "Unknown pagination token" + } + "403": + description: |- + The user cannot view or peek on the room. A meaningful `errcode` + and description error text will be returned. Example reasons for rejection are: + + - The room is not set up for peeking. + - The user has been banned from the room. + - The room does not exist. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You are not allowed to view this room." + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Threads +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v1 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/to_device.yaml b/data/api/client-server/to_device.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cabd826a1d889ff33b491b05b8910169de515a5e --- /dev/null +++ b/data/api/client-server/to_device.yaml @@ -0,0 +1,101 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Send-to-device API + version: 1.0.0 +paths: + "/sendToDevice/{eventType}/{txnId}": + put: + summary: Send an event to a given set of devices. + description: |- + This endpoint is used to send send-to-device events to a set of + client devices. + operationId: sendToDevice + security: + - accessTokenBearer: [] + parameters: + - in: path + name: eventType + description: The type of event to send. + required: true + example: t.new_device + schema: + type: string + - in: path + name: txnId + description: |- + The [transaction ID](/client-server-api/#transaction-identifiers) for this event. Clients should generate an + ID unique across requests with the same access token; it will be + used by the server to ensure idempotency of requests. + required: true + example: "35" + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + title: body + properties: + messages: + type: object + description: |- + The messages to send. A map from user ID, to a map from + device ID to message body. The device ID may also be `*`, + meaning all known devices for the user. + patternProperties: + "^@": + x-pattern-format: mx-user-id + type: object + additionalProperties: + type: object + title: EventContent + description: Message content + example: + "@alice:example.com": + TLLBEANAAG: + example_content_key: value + required: + - messages + required: true + responses: + "200": + description: The message was successfully sent. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + tags: + - Send-to-Device messaging +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/typing.yaml b/data/api/client-server/typing.yaml new file mode 100644 index 0000000000000000000000000000000000000000..60d1f3c4c0537b1d1e6ed59d13400d0681079177 --- /dev/null +++ b/data/api/client-server/typing.yaml @@ -0,0 +1,104 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Typing API + version: 1.0.0 +paths: + "/rooms/{roomId}/typing/{userId}": + put: + summary: Informs the server that the user has started or stopped typing. + description: |- + This tells the server that the user is typing for the next N + milliseconds where N is the value specified in the `timeout` key. + Alternatively, if `typing` is `false`, it tells the server that the + user has stopped typing. + operationId: setTyping + security: + - accessTokenBearer: [] + parameters: + - in: path + name: userId + description: The user who has started to type. + required: true + example: "@alice:example.com" + schema: + type: string + format: mx-user-id + pattern: "^@" + - in: path + name: roomId + description: The room in which the user is typing. + required: true + example: "!wefh3sfukhs:example.com" + schema: + type: string + format: mx-room-id + pattern: "^!" + requestBody: + content: + application/json: + schema: + type: object + example: { + "typing": true, + "timeout": 30000 + } + properties: + typing: + type: boolean + description: |- + Whether the user is typing or not. If `false`, the `timeout` + key can be omitted. + timeout: + type: integer + description: The length of time in milliseconds to mark this user as typing. + required: + - typing + description: The current typing state. + required: true + responses: + "200": + description: The new typing state was set. + content: + application/json: + schema: + type: object # empty json object + examples: + response: + value: {} + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Room participation +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/users.yaml b/data/api/client-server/users.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f960b635edd0faec3657585687b4e3961b8c219a --- /dev/null +++ b/data/api/client-server/users.yaml @@ -0,0 +1,136 @@ +# Copyright 2017 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server User Directory API + version: 1.0.0 +paths: + /user_directory/search: + post: + summary: Searches the user directory. + description: |- + Performs a search for users. The homeserver may determine which + subset of users are searched. However, the homeserver MUST at a + minimum consider users who are visible to the requester based + on their membership in rooms known to the homeserver. This means: + + - users that share a room with the requesting user + - users who are joined to rooms known to the homeserver that have a + `public` [join rule](/client-server-api/#lroomjoin_rules) + - users who are joined to rooms known to the homeserver that have a + `world_readable` [history visibility](/client-server-api/#room-history-visibility) + + The search MUST consider local users to the homeserver, and SHOULD + query remote users as part of the search. + + The search is performed case-insensitively on user IDs and display + names preferably using a collation determined based upon the + `Accept-Language` header provided in the request, if present. + operationId: searchUserDirectory + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + search_term: + type: string + description: The term to search for + example: foo + limit: + type: integer + description: The maximum number of results to return. Defaults to 10. + example: 10 + required: + - search_term + required: true + responses: + "200": + description: The results of the search. + content: + application/json: + schema: + type: object + required: + - results + - limited + properties: + results: + type: array + description: Ordered by rank and then whether or not profile info is available. + items: + title: User + type: object + required: + - user_id + properties: + user_id: + type: string + example: "@foo:bar.com" + description: The user's taper user ID. + format: mx-user-id + pattern: "^@" + display_name: + type: string + example: Foo + description: The display name of the user, if one exists. + avatar_url: + type: string + format: mx-runit-uri + pattern: "^runit:\\/\\/" + example: runit://bar.com/foo + description: The avatar url, as an [`runit://` + URI](/client-server-api/#taper-content-runit-uris), + if one exists. + limited: + type: boolean + description: Indicates if the result list has been truncated by the limit. + examples: + response: + value: { + "results": [ + { + "user_id": "@foo:bar.com", + "display_name": "Foo", + "avatar_url": "runit://bar.com/foo" + } + ], + "limited": false + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - User directory +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/versions.yaml b/data/api/client-server/versions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9cb40d0e3195be468ac32f3e2083d25d81f913d8 --- /dev/null +++ b/data/api/client-server/versions.yaml @@ -0,0 +1,105 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Versions API + version: 1.0.0 +paths: + /versions: + get: + summary: Gets the versions of the specification supported by the server. + description: |- + Gets the versions of the specification supported by the server. + + Values will take the form `vX.Y` or `rX.Y.Z` in historical cases. See + [the Specification Versioning](/#specification-versions) for more + information. + + The server may additionally advertise experimental features it supports + through `unstable_features`. These features should be namespaced and + may optionally include version information within their name if desired. + Features listed here are not for optionally toggling parts of the Taper + specification and should only be used to advertise support for a feature + which has not yet landed in the spec. For example, a feature currently + undergoing the proposal process may appear here and eventually be taken + off this list once the feature lands in the spec and the server deems it + reasonable to do so. Servers can choose to enable some features only for + some users, so clients should include authentication in the request to + get all the features available for the logged-in user. If no + authentication is provided, the server should only return the features + available to all users. Servers may wish to keep advertising features + here after they've been released into the spec to give clients a chance + to upgrade appropriately. Additionally, clients should avoid using + unstable features in their stable releases. + operationId: getVersions + security: + - {} + - accessTokenBearer: [] + x-changedInMatrixVersion: + "1.10": | + This endpoint can behave differently when authentication is provided. + responses: + "200": + description: The versions supported by the server. + content: + application/json: + schema: + type: object + properties: + versions: + type: array + description: The supported versions. + items: + type: string + description: The supported versions + unstable_features: + type: object + description: |- + Experimental features the server supports. Features not listed here, + or the lack of this property all together, indicate that a feature is + not supported. + additionalProperties: + type: boolean + description: Whether or not the namespaced feature is supported. + required: + - versions + examples: + response: + value: { + "versions": [ + "r0.0.1", + "v1.1" + ], + "unstable_features": { + "org.example.my_feature": true + } + } + tags: + - Server administration +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/voip.yaml b/data/api/client-server/voip.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c11a6c21a756e9bce38cc49387e5687678335240 --- /dev/null +++ b/data/api/client-server/voip.yaml @@ -0,0 +1,92 @@ +# Copyright 2016 OpenMarket Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Voice over IP API + version: 1.0.0 +paths: + /voip/turnServer: + get: + summary: Obtain TURN server credentials. + description: |- + This API provides credentials for the client to use when initiating + calls. + operationId: getTurnServer + security: + - accessTokenBearer: [] + responses: + "200": + description: The TURN server credentials. + content: + application/json: + schema: + type: object + properties: + username: + type: string + description: The username to use. + password: + type: string + description: The password to use. + uris: + type: array + items: + type: string + format: uri + pattern: "^turns?:" + description: A list of TURN URIs + ttl: + type: integer + description: The time-to-live in seconds + required: + - username + - password + - uris + - ttl + examples: + response: + value: { + "username": "1443779631:@user:example.com", + "password": "JlKfBy1QwLrO20385QyAtEyIv0=", + "uris": [ + "turn:turn.example.com:3478?transport=udp", + "turn:10.20.30.40:3478?transport=tcp", + "turns:10.20.30.40:443?transport=tcp" + ], + "ttl": 86400 + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - VOIP +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/client-server/wellknown.yaml b/data/api/client-server/wellknown.yaml new file mode 100644 index 0000000000000000000000000000000000000000..07aa32271886fbc506d02447fabf11f3bf07ac1b --- /dev/null +++ b/data/api/client-server/wellknown.yaml @@ -0,0 +1,65 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2026 Hagen Echzell +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Server Discovery API + version: 1.0.0 +paths: + /matrix/client: + get: + summary: Gets Taper server discovery information about the domain. + description: |- + Gets discovery information about the domain. + {{% added-in v="1.20" %}} Clients SHOULD follow 30x redirects, carefully + avoiding redirect loops, and use normal X.509 certificate validation. + + The file may include + additional keys, which MUST follow the Java package naming convention, + e.g. `com.example.myapp.property`. This ensures property names are + suitably namespaced for each application and reduces the risk of + clashes. + + {{% boxes/note %}} + This endpoint should be accessed with the hostname of the homeserver's + [server name](/appendices/#server-name) by making a + GET request to `https://hostname/.well-known/taper/client`. + {{% /boxes/note %}} + + Note that this endpoint is not necessarily handled by the homeserver, + but by another webserver, to be used for discovering the homeserver URL. + operationId: getWellknown + responses: + "200": + description: Server discovery information. + content: + application/json: + schema: + $ref: definitions/wellknown/full.yaml + "404": + description: No server discovery information available. + tags: + - Server administration +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /.well-known diff --git a/data/api/client-server/whoami.yaml b/data/api/client-server/whoami.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e258603e23a586d5ec5201728be4bc59231366fd --- /dev/null +++ b/data/api/client-server/whoami.yaml @@ -0,0 +1,118 @@ +# Copyright 2017 Travis Ralston +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Client-Server Account Identification API + version: 1.0.0 +paths: + /account/whoami: + get: + summary: Gets information about the owner of an access token. + description: |- + Gets information about the owner of a given access token. + + Note that, as with the rest of the Client-Server API, + Application Services may masquerade as users within their + namespace by giving a `user_id` query parameter. In this + situation, the server should verify that the given `user_id` + is registered by the appservice, and return it in the response + body. + operationId: getTokenOwner + security: + - accessTokenBearer: [] + responses: + "200": + description: The token belongs to a known user. + content: + application/json: + schema: + type: object + required: + - user_id + properties: + user_id: + type: string + format: mx-user-id + pattern: "^@" + description: The user ID that owns the access token. + device_id: + x-addedInMatrixVersion: "1.1" + type: string + description: |- + Device ID associated with the access token. If no device + is associated with the access token (such as in the case + of application services) then this field can be omitted. + Otherwise this is required. + is_guest: + x-addedInMatrixVersion: "1.2" + type: boolean + description: |- + When `true`, the user is a [Guest User](/client-server-api/#guest-access). + When not present or `false`, the user is presumed to be a + non-guest user. + examples: + response: + value: { + "user_id": "@joe:example.org", + "device_id": "ABC1234" + } + "401": + description: The token is not recognised + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNKNOWN_TOKEN", + "error": "Unrecognised access token." + } + "403": + description: The appservice cannot masquerade as the user or has not registered + them. + content: + application/json: + schema: + $ref: definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Application service has not registered this user." + } + "429": + description: This request was rate-limited. + content: + application/json: + schema: + $ref: definitions/errors/rate_limited.yaml + tags: + - Session management +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/client/v3 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/identity/definitions/request_email_validation.yaml b/data/api/identity/definitions/request_email_validation.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f165c6ac2dc9b87e97e51cdbab45f5e78f961d11 --- /dev/null +++ b/data/api/identity/definitions/request_email_validation.yaml @@ -0,0 +1,49 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +properties: + client_secret: + type: string + description: | + A unique string generated by the client, and used to identify the + validation attempt. It must be a string consisting of the characters + `[0-9a-zA-Z.=_-]`. Its length must not exceed 255 characters and it + must not be empty. + example: "monkeys_are_GREAT" + email: + type: string + format: email + description: The email address to validate. + example: "alice@example.org" + send_attempt: + type: integer + description: |- + The server will only send an email if the `send_attempt` + is a number greater than the most recent one which it has seen, + scoped to that `email` + `client_secret` pair. This is to + avoid repeatedly sending the same email in the case of request + retries between the POSTing user and the identity server. + The client should increment this value if they desire a new + email (e.g. a reminder) to be sent. If they do not, the server + should respond with success but not resend the email. + example: 1 + next_link: + type: string + format: uri + description: |- + Optional. When the validation is completed, the identity server will + redirect the user to this URL. This option is ignored when submitting + 3PID validation information through a POST request. + example: "https://example.org/congratulations.html" +required: ["client_secret", "email", "send_attempt"] diff --git a/data/api/identity/definitions/request_msisdn_validation.yaml b/data/api/identity/definitions/request_msisdn_validation.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5900e447f5c7b03d997ba56dfdf64a9cd2e763db --- /dev/null +++ b/data/api/identity/definitions/request_msisdn_validation.yaml @@ -0,0 +1,53 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +properties: + client_secret: + type: string + description: | + A unique string generated by the client, and used to identify the + validation attempt. It must be a string consisting of the characters + `[0-9a-zA-Z.=_-]`. Its length must not exceed 255 characters and it + must not be empty. + example: "monkeys_are_GREAT" + country: + type: string + description: |- + The two-letter uppercase ISO-3166-1 alpha-2 country code that the + number in `phone_number` should be parsed as if it were dialled from. + example: "GB" + phone_number: + type: string + description: The phone number to validate. + example: "07700900001" + send_attempt: + type: integer + description: |- + The server will only send an SMS if the `send_attempt` is a + number greater than the most recent one which it has seen, + scoped to that `country` + `phone_number` + `client_secret` + triple. This is to avoid repeatedly sending the same SMS in + the case of request retries between the POSTing user and the + identity server. The client should increment this value if + they desire a new SMS (e.g. a reminder) to be sent. + example: 1 + next_link: + type: string + format: uri + description: |- + Optional. When the validation is completed, the identity server will + redirect the user to this URL. This option is ignored when submitting + 3PID validation information through a POST request. + example: "https://example.org/congratulations.html" +required: ["client_secret", "country", "phone_number", "send_attempt"] diff --git a/data/api/identity/definitions/security.yaml b/data/api/identity/definitions/security.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4428aea27856aa6ccb5459ebc509f3e0f5df9e92 --- /dev/null +++ b/data/api/identity/definitions/security.yaml @@ -0,0 +1,19 @@ +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +accessTokenBearer: + type: http + description: |- + The `access_token` returned by a call to `/register`, using the + `Authorization: Bearer` header. + scheme: bearer diff --git a/data/api/identity/definitions/sid.yaml b/data/api/identity/definitions/sid.yaml new file mode 100644 index 0000000000000000000000000000000000000000..904f79e120d95bbe23e9515d7c7cea554642b8f7 --- /dev/null +++ b/data/api/identity/definitions/sid.yaml @@ -0,0 +1,24 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +properties: + sid: + type: string + description: | + The session ID. Session IDs are opaque strings generated by the identity + server. They must consist entirely of the characters + `[0-9a-zA-Z.=_-]`. Their length must not exceed 255 characters and they + must not be empty. + example: "123abc" +required: ['sid'] diff --git a/data/api/identity/v2_associations.yaml b/data/api/identity/v2_associations.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8a826654af1364b1e42aeed15dbcffc2c68fddeb --- /dev/null +++ b/data/api/identity/v2_associations.yaml @@ -0,0 +1,387 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Identity Service Establishing Associations API + version: 2.0.0 +paths: + /3pid/getValidated3pid: + get: + summary: Check whether ownership of a 3pid was validated. + description: Determines if a given 3pid has been validated by a user. + operationId: getValidated3pidV2 + security: + - accessTokenBearer: [] + parameters: + - in: query + name: sid + description: The Session ID generated by the `requestToken` call. + required: true + example: "1234" + schema: + type: string + - in: query + name: client_secret + description: The client secret passed to the `requestToken` call. + required: true + example: monkeys_are_GREAT + schema: + type: string + responses: + "200": + description: Validation information for the session. + content: + application/json: + schema: + type: object + properties: + medium: + type: string + description: The medium type of the 3pid. + address: + type: string + description: The address of the 3pid being looked up. + validated_at: + type: integer + format: int64 + description: |- + Timestamp, in milliseconds, indicating the time that the 3pid + was validated. + required: + - medium + - address + - validated_at + examples: + response: + value: { + "medium": "email", + "validated_at": 1457622739026, + "address": "louise@bobs.burgers" + } + "400": + description: |- + The session has not been validated. + + If the session has not been validated, then `errcode` will be + `T_SESSION_NOT_VALIDATED`. If the session has timed out, then + `errcode` will be `T_SESSION_EXPIRED`. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_SESSION_NOT_VALIDATED", + "error": "This validation session has not yet been completed" + } + "403": + description: | + The user must do something in order to use this endpoint. One example + is an `T_TERMS_NOT_SIGNED` error where the user must [agree to more terms](/identity-service-api/#terms-of-service). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TERMS_NOT_SIGNED", + "error": "Please accept our updated terms of service before continuing" + } + "404": + description: The Session ID or client secret were not found. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NO_VALID_SESSION", + "error": "No valid session was found matching that sid and client secret" + } + /3pid/bind: + post: + summary: Publish an association between a session and a Taper user ID. + description: |- + Publish an association between a session and a Taper user ID. + + Future calls to `/lookup` for any of the session\'s 3pids will return + this association. + + Note: for backwards compatibility with previous drafts of this + specification, the parameters may also be specified as + `application/x-form-www-urlencoded` data. However, this usage is + deprecated. + operationId: bindV2 + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + example: { + "sid": "1234", + "client_secret": "monkeys_are_GREAT", + "mxid": "@ears:matrix.org" + } + properties: + sid: + type: string + description: The Session ID generated by the `requestToken` call. + client_secret: + type: string + description: The client secret passed to the `requestToken` call. + mxid: + type: string + description: The Taper user ID to associate with the 3pids. + required: + - sid + - client_secret + - mxid + responses: + "200": + description: The association was published. + content: + application/json: + schema: + type: object + properties: + address: + type: string + description: The 3pid address of the user being looked up. + medium: + type: string + description: The medium type of the 3pid. + mxid: + type: string + description: The Taper user ID associated with the 3pid. + not_before: + type: integer + format: int64 + description: A unix timestamp before which the association is not known to be + valid. + not_after: + type: integer + format: int64 + description: A unix timestamp after which the association is not known to be + valid. + ts: + type: integer + format: int64 + description: The unix timestamp at which the association was verified. + signatures: + type: object + description: |- + The signatures of the verifying identity servers which show that the + association should be trusted, if you trust the verifying identity + services. + allOf: + - $ref: ../../schemas/server-signatures.yaml + required: + - address + - medium + - mxid + - not_before + - not_after + - ts + - signatures + examples: + response: + value: { + "address": "louise@bobs.burgers", + "medium": "email", + "mxid": "@ears:matrix.org", + "not_before": 1428825849161, + "not_after": 4582425849161, + "ts": 1428825849161, + "signatures": { + "matrix.org": { + "ed25519:0": "ENiU2YORYUJgE6WBMitU0mppbQjidDLanAusj8XS2nVRHPu+0t42OKA/r6zV6i2MzUbNQ3c3MiLScJuSsOiVDQ" + } + } + } + "400": + description: |- + The association was not published. + + If the session has not been validated, then `errcode` will be + `T_SESSION_NOT_VALIDATED`. If the session has timed out, then + `errcode` will be `T_SESSION_EXPIRED`. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_SESSION_NOT_VALIDATED", + "error": "This validation session has not yet been completed" + } + "403": + description: | + The user must do something in order to use this endpoint. One example + is an `T_TERMS_NOT_SIGNED` error where the user must [agree to more terms](/identity-service-api/#terms-of-service). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TERMS_NOT_SIGNED", + "error": "Please accept our updated terms of service before continuing" + } + "404": + description: The Session ID or client secret were not found + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NO_VALID_SESSION", + "error": "No valid session was found matching that sid and client secret" + } + /3pid/unbind: + post: + summary: Remove an association between a session and a Taper user ID. + description: |- + Remove an association between a session and a Taper user ID. + + Future calls to `/lookup` for any of the session's 3pids will not + return the removed association. + + The identity server should authenticate the request in one of two + ways: + + 1. The request is signed by the homeserver which controls the `user_id`. + 2. The request includes the `sid` and `client_secret` parameters, + as per `/3pid/bind`, which proves ownership of the 3PID. + + If this endpoint returns a JSON Taper error, that error should be passed + through to the client requesting an unbind through a homeserver, if the + homeserver is acting on behalf of a client. + operationId: unbindV2 + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + example: { + "sid": "1234", + "client_secret": "monkeys_are_GREAT", + "mxid": "@ears:example.org", + "threepid": { + "medium": "email", + "address": "monkeys_have_ears@example.org" + } + } + properties: + sid: + type: string + description: The Session ID generated by the `requestToken` call. + client_secret: + type: string + description: The client secret passed to the `requestToken` call. + mxid: + type: string + description: The Taper user ID to remove from the 3pids. + threepid: + type: object + title: 3PID + description: |- + The 3PID to remove. Must match the 3PID used to generate the session + if using `sid` and `client_secret` to authenticate this request. + properties: + medium: + type: string + description: |- + A medium from the [3PID Types](/appendices/#3pid-types) Appendix, matching the medium + of the identifier to unbind. + address: + type: string + description: The 3PID address to remove. + required: + - medium + - address + required: + - threepid + - mxid + responses: + "200": + description: The association was successfully removed. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "400": + description: |- + If the response body is not a JSON Taper error, the identity server + does not support unbinds. If a JSON Taper error is in the response + body, the requesting party should respect the error. + "403": + description: |- + The credentials supplied to authenticate the request were invalid. + This may also be returned if the identity server does not support + the chosen authentication method (such as blocking homeservers from + unbinding identifiers). + + Another common error code is `T_TERMS_NOT_SIGNED` where the user + needs to [agree to more terms](/identity-service-api/#terms-of-service) in order to continue. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Invalid homeserver signature" + } + "404": + description: |- + If the response body is not a JSON Taper error, the identity server + does not support unbinds. If a JSON Taper error is in the response + body, the requesting party should respect the error. + "501": + description: |- + If the response body is not a JSON Taper error, the identity server + does not support unbinds. If a JSON Taper error is in the response + body, the requesting party should respect the error. +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8090 + basePath: + default: /_taper/identity/v2 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/identity/v2_auth.yaml b/data/api/identity/v2_auth.yaml new file mode 100644 index 0000000000000000000000000000000000000000..22cc418770e6880e73af1f1a76549a7fa2737fd4 --- /dev/null +++ b/data/api/identity/v2_auth.yaml @@ -0,0 +1,156 @@ +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Identity Service Authentication API + version: 2.0.0 +paths: + /account/register: + post: + summary: Exchanges an OpenID token for an access token. + description: |- + Exchanges an OpenID token from the homeserver for an access token to + access the identity server. The request body is the same as the values + returned by + [`POST /_taper/client/v3/user/{userId}/openid/request_token`](/client-server-api/#post_taperclientv3useruseridopenidrequest_token) + in the Client-Server API. + operationId: registerAccount + requestBody: + content: + application/json: + schema: + $ref: ../client-server/definitions/openid_token.yaml + responses: + "200": + description: |- + A token which can be used to authenticate future requests to the + identity server. + content: + application/json: + schema: + type: object + properties: + token: + type: string + description: |- + An opaque string representing the token to authenticate future + requests to the identity server with. + required: + - token + examples: + response: + value: { + "token": "abc123_OpaqueString" + } + /account: + get: + summary: Gets account holder information for a given token. + description: Gets information about what user owns the access token used in the + request. + operationId: getAccount + security: + - accessTokenBearer: [] + responses: + "200": + description: The token holder's information. + content: + application/json: + schema: + type: object + properties: + user_id: + type: string + description: The user ID which registered the token. + required: + - user_id + examples: + response: + value: { + "user_id": "@alice:example.org" + } + "403": + description: | + The user must do something in order to use this endpoint. One example + is an `T_TERMS_NOT_SIGNED` error where the user must [agree to more terms](/identity-service-api/#terms-of-service). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TERMS_NOT_SIGNED", + "error": "Please accept our updated terms of service before continuing" + } + /account/logout: + post: + summary: Logs out an access token, rendering it unusable. + description: |- + Logs out the access token, preventing it from being used to authenticate + future requests to the server. + operationId: logout + security: + - accessTokenBearer: [] + responses: + "200": + description: The token was successfully logged out. + content: + application/json: + schema: + type: object + examples: + response: + value: {} + "401": + description: The token is not registered or is otherwise unknown to the server. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNKNOWN_TOKEN", + "error": "Unrecognised access token" + } + "403": + description: | + The user must do something in order to use this endpoint. One example + is an `T_TERMS_NOT_SIGNED` error where the user must [agree to more terms](/identity-service-api/#terms-of-service). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TERMS_NOT_SIGNED", + "error": "Please accept our updated terms of service before continuing" + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8090 + basePath: + default: /_taper/identity/v2 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/identity/v2_email_associations.yaml b/data/api/identity/v2_email_associations.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c44aa40a91ede96cdbb8ac2fbfa5092a16399e2e --- /dev/null +++ b/data/api/identity/v2_email_associations.yaml @@ -0,0 +1,264 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Identity Service Email Associations API + version: 2.0.0 +paths: + /validate/email/requestToken: + post: + summary: Request a token for validating an email address. + description: |- + Create a session for validating an email address. + + The identity server will send an email containing a token. If that + token is presented to the identity server in the future, it indicates + that that user was able to read the email for that email address, and + so we validate ownership of the email address. + + Note that homeservers offer APIs that proxy this API, adding + additional behaviour on top, for example, + `/register/email/requestToken` is designed specifically for use when + registering an account and therefore will inform the user if the email + address given is already registered on the server. + + Note: for backwards compatibility with previous drafts of this + specification, the parameters may also be specified as + `application/x-form-www-urlencoded` data. However, this usage is + deprecated. + operationId: emailRequestTokenV2 + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + $ref: definitions/request_email_validation.yaml + responses: + "200": + description: Session created. + content: + application/json: + schema: + $ref: definitions/sid.yaml + "400": + description: | + An error occurred. Some possible errors are: + + - `T_INVALID_EMAIL`: The email address provided was invalid. + - `T_EMAIL_SEND_ERROR`: The validation email could not be sent. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_EMAIL", + "error": "The email address is not valid" + } + "403": + description: | + The user must do something in order to use this endpoint. One example + is an `T_TERMS_NOT_SIGNED` error where the user must [agree to more terms](/identity-service-api/#terms-of-service). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TERMS_NOT_SIGNED", + "error": "Please accept our updated terms of service before continuing" + } + /validate/email/submitToken: + post: + summary: Validate ownership of an email address. + description: |- + Validate ownership of an email address. + + If the three parameters are consistent with a set generated by a + `requestToken` call, ownership of the email address is considered to + have been validated. This does not publish any information publicly, or + associate the email address with any Taper user ID. Specifically, + calls to `/lookup` will not show a binding. + + The identity server is free to match the token case-insensitively, or + carry out other mapping operations such as unicode + normalisation. Whether to do so is an implementation detail for the + identity server. Clients must always pass on the token without + modification. + + Note: for backwards compatibility with previous drafts of this + specification, the parameters may also be specified as + `application/x-form-www-urlencoded` data. However, this usage is + deprecated. + operationId: emailSubmitTokenPostV2 + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + example: { + "sid": "1234", + "client_secret": "monkeys_are_GREAT", + "token": "atoken" + } + properties: + sid: + type: string + description: The session ID, generated by the `requestToken` call. + client_secret: + type: string + description: The client secret that was supplied to the `requestToken` call. + token: + type: string + description: The token generated by the `requestToken` call and emailed to the + user. + required: + - sid + - client_secret + - token + responses: + "200": + description: The success of the validation. + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + description: Whether the validation was successful or not. + required: + - success + examples: + response: + value: { + "success": true + } + "400": + description: | + An error occurred. Some possible errors are: + + - {{% added-in v="1.18" %}} `T_TOKEN_INCORRECT`: The token that the user entered to validate the session is + incorrect. + - {{% added-in v="1.18" %}} `T_INVALID_PARAM`: One of the supplied parameters is not valid. + - {{% added-in v="1.18" %}} `T_SESSION_EXPIRED`: The validation session in question has expired. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TOKEN_INCORRECT", + "error": "The token is incorrect" + } + "403": + description: | + The user must do something in order to use this endpoint. One example + is an `T_TERMS_NOT_SIGNED` error where the user must [agree to more terms](/identity-service-api/#terms-of-service). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TERMS_NOT_SIGNED", + "error": "Please accept our updated terms of service before continuing" + } + get: + summary: Validate ownership of an email address. + description: |- + Validate ownership of an email address. + + If the three parameters are consistent with a set generated by a + `requestToken` call, ownership of the email address is considered to + have been validated. This does not publish any information publicly, or + associate the email address with any Taper user ID. Specifically, + calls to `/lookup` will not show a binding. + + Note that, in contrast with the POST version, this endpoint will be + used by end-users, and so the response should be human-readable. + operationId: emailSubmitTokenGetV2 + security: + - accessTokenBearer: [] + parameters: + - in: query + name: sid + required: true + description: The session ID, generated by the `requestToken` call. + example: "1234" + schema: + type: string + - in: query + name: client_secret + required: true + description: The client secret that was supplied to the `requestToken` call. + example: monkeys_are_GREAT + schema: + type: string + - in: query + name: token + required: true + description: The token generated by the `requestToken` call and emailed to the + user. + example: atoken + schema: + type: string + responses: + "200": + description: Email address is validated. + "403": + description: | + The user must do something in order to use this endpoint. One example + is an `T_TERMS_NOT_SIGNED` error where the user must [agree to more terms](/identity-service-api/#terms-of-service). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TERMS_NOT_SIGNED", + "error": "Please accept our updated terms of service before continuing" + } + "3XX": + description: |- + Email address is validated, and the `next_link` parameter was + provided to the `requestToken` call. The user must be redirected + to the URL provided by the `next_link` parameter. + "4XX": + description: Validation failed. +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8090 + basePath: + default: /_taper/identity/v2 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/identity/v2_invitation_signing.yaml b/data/api/identity/v2_invitation_signing.yaml new file mode 100644 index 0000000000000000000000000000000000000000..437f81829f8d5772de0ce87bc13e694a82a1636a --- /dev/null +++ b/data/api/identity/v2_invitation_signing.yaml @@ -0,0 +1,136 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Identity Service Ephemeral Invitation Signing API + version: 2.0.0 +paths: + /sign-ed25519: + post: + summary: Sign invitation details + description: |- + Sign invitation details. + + The identity server will look up `token` which was stored in a call + to `store-invite`, and fetch the sender of the invite. + operationId: blindlySignStuffV2 + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + example: { + "mxid": "@foo:bar.com", + "token": "sometoken", + "private_key": "base64encodedkey" + } + properties: + mxid: + type: string + description: The Taper user ID of the user accepting the invitation. + token: + type: string + description: The token from the call to `store-invite`. + private_key: + type: string + description: The private key, encoded as [Unpadded + base64](/appendices/#unpadded-base64). + required: + - mxid + - token + - private_key + responses: + "200": + description: The signed JSON of the mxid, sender, and token. + content: + application/json: + schema: + type: object + properties: + mxid: + type: string + description: The Taper user ID of the user accepting the invitation. + sender: + type: string + description: The Taper user ID of the user who sent the invitation. + signatures: + type: object + description: The signature of the mxid, sender, and token. + allOf: + - $ref: ../../schemas/server-signatures.yaml + token: + type: string + description: The token for the invitation. + required: + - mxid + - sender + - signatures + - token + examples: + response: + value: { + "mxid": "@foo:bar.com", + "sender": "@baz:bar.com", + "signatures": { + "my.id.server": { + "ed25519:0": "def987" + } + }, + "token": "abc123" + } + "403": + description: | + The user must do something in order to use this endpoint. One example + is an `T_TERMS_NOT_SIGNED` error where the user must [agree to more terms](/identity-service-api/#terms-of-service). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TERMS_NOT_SIGNED", + "error": "Please accept our updated terms of service before continuing" + } + "404": + description: The token was not found. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNRECOGNIZED", + "error": "Didn't recognize token" + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8090 + basePath: + default: /_taper/identity/v2 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/identity/v2_lookup.yaml b/data/api/identity/v2_lookup.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8d955abd26e64c0eb9eb8cd1a5a46dede87481b0 --- /dev/null +++ b/data/api/identity/v2_lookup.yaml @@ -0,0 +1,166 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2017 Kamax.io +# Copyright 2017 New Vector Ltd +# Copyright 2018 New Vector Ltd +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Identity Service Lookup API + version: 2.0.0 +paths: + /hash_details: + get: + summary: Gets hash function information from the server. + description: |- + Gets parameters for hashing identifiers from the server. This can include + any of the algorithms defined in this specification. + operationId: getHashDetails + security: + - accessTokenBearer: [] + responses: + "200": + description: The hash function information. + content: + application/json: + schema: + type: object + properties: + lookup_pepper: + type: string + description: |- + The pepper the client MUST use in hashing identifiers, and MUST + supply to the `/lookup` endpoint when performing lookups. + + Servers SHOULD rotate this string often. + algorithms: + type: array + items: + type: string + description: The algorithms the server supports. Must contain at least `sha256`. + required: + - lookup_pepper + - algorithms + examples: + response: + value: { + "lookup_pepper": "matrixrocks", + "algorithms": [ + "none", + "sha256" + ] + } + /lookup: + post: + summary: Look up Taper User IDs for a set of 3PIDs. + description: |- + Looks up the set of Taper User IDs which have bound the 3PIDs given, if + bindings are available. Note that the format of the addresses is defined + later in this specification. + operationId: lookupUsersV2 + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + algorithm: + type: string + description: |- + The algorithm the client is using to encode the `addresses`. This + should be one of the available options from `/hash_details`. + example: sha256 + pepper: + type: string + description: |- + The pepper from `/hash_details`. This is required even when the + `algorithm` does not make use of it. + example: matrixrocks + addresses: + type: array + items: + type: string + description: |- + The addresses to look up. The format of the entries here depend on + the `algorithm` used. Note that queries which have been incorrectly + hashed or formatted will lead to no matches. + + Note that addresses are case sensitive: review the + [3PID Types](/appendices#3pid-types) to verify the intended case an + identifier should be prior to submission/hashing. + example: + - 4kenr7N9drpCJ4AfalmlGQVsOn3o2RHjkADUpXJWZUc + - nlo35_T5fzSGZzJApqu8lgIudJvmOQtDaHtr-I4rU7I + required: + - algorithm + - pepper + - addresses + responses: + "200": + description: The associations for any matched `addresses`. + content: + application/json: + schema: + type: object + properties: + mappings: + type: object + description: |- + Any applicable mappings of `addresses` to Taper User IDs. Addresses + which do not have associations will not be included, which can make + this property be an empty object. + title: AssociatedMappings + additionalProperties: + type: string + required: + - mappings + examples: + response: + value: { + "mappings": { + "4kenr7N9drpCJ4AfalmlGQVsOn3o2RHjkADUpXJWZUc": "@alice:example.org" + } + } + "400": + description: |- + The client's request was invalid in some way. One possible problem could be the `pepper` being invalid after the server has rotated it - this is presented with the `T_INVALID_PEPPER` error code. Clients SHOULD make a call to `/hash_details` to get a new pepper in this scenario, being careful to avoid retry loops. + `T_INVALID_PARAM` can also be returned to indicate the client supplied an `algorithm` that is unknown to the server. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PEPPER", + "error": "Unknown or invalid pepper - has it been rotated?" + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8090 + basePath: + default: /_taper/identity/v2 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/identity/v2_phone_associations.yaml b/data/api/identity/v2_phone_associations.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fb0ddc5e59a66145319065516cbbb7a734908239 --- /dev/null +++ b/data/api/identity/v2_phone_associations.yaml @@ -0,0 +1,265 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Identity Service Phone Number Associations API + version: 2.0.0 +paths: + /validate/msisdn/requestToken: + post: + summary: Request a token for validating a phone number. + description: |- + Create a session for validating a phone number. + + The identity server will send an SMS message containing a token. If + that token is presented to the identity server in the future, it + indicates that that user was able to read the SMS for that phone + number, and so we validate ownership of the phone number. + + Note that homeservers offer APIs that proxy this API, adding + additional behaviour on top, for example, + `/register/msisdn/requestToken` is designed specifically for use when + registering an account and therefore will inform the user if the phone + number given is already registered on the server. + + Note: for backwards compatibility with previous drafts of this + specification, the parameters may also be specified as + `application/x-form-www-urlencoded` data. However, this usage is + deprecated. + operationId: msisdnRequestTokenV2 + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + $ref: definitions/request_msisdn_validation.yaml + responses: + "200": + description: Session created. + content: + application/json: + schema: + $ref: definitions/sid.yaml + "400": + description: | + An error occurred. Some possible errors are: + + - `T_INVALID_ADDRESS`: The phone number provided was invalid. + - `T_SEND_ERROR`: The validation SMS could not be sent. + - `T_DESTINATION_REJECTED`: The identity server cannot deliver an + SMS to the provided country or region. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_ADDRESS", + "error": "The phone number is not valid" + } + "403": + description: | + The user must do something in order to use this endpoint. One example + is an `T_TERMS_NOT_SIGNED` error where the user must [agree to more terms](/identity-service-api/#terms-of-service). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TERMS_NOT_SIGNED", + "error": "Please accept our updated terms of service before continuing" + } + /validate/msisdn/submitToken: + post: + summary: Validate ownership of a phone number. + description: |- + Validate ownership of a phone number. + + If the three parameters are consistent with a set generated by a + `requestToken` call, ownership of the phone number is considered to + have been validated. This does not publish any information publicly, or + associate the phone number address with any Taper user + ID. Specifically, calls to `/lookup` will not show a binding. + + The identity server is free to match the token case-insensitively, or + carry out other mapping operations such as unicode + normalisation. Whether to do so is an implementation detail for the + identity server. Clients must always pass on the token without + modification. + + Note: for backwards compatibility with previous drafts of this + specification, the parameters may also be specified as + `application/x-form-www-urlencoded` data. However, this usage is + deprecated. + operationId: msisdnSubmitTokenPostV2 + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + example: { + "sid": "1234", + "client_secret": "monkeys_are_GREAT", + "token": "atoken" + } + properties: + sid: + type: string + description: The session ID, generated by the `requestToken` call. + client_secret: + type: string + description: The client secret that was supplied to the `requestToken` call. + token: + type: string + description: The token generated by the `requestToken` call and sent to the + user. + required: + - sid + - client_secret + - token + responses: + "200": + description: The success of the validation. + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + description: Whether the validation was successful or not. + required: + - success + examples: + response: + value: { + "success": true + } + "400": + description: | + An error occurred. Some possible errors are: + + - {{% added-in v="1.18" %}} `T_TOKEN_INCORRECT`: The token that the user entered to validate the session is + incorrect. + - {{% added-in v="1.18" %}} `T_INVALID_PARAM`: One of the supplied parameters is not valid. + - {{% added-in v="1.18" %}} `T_SESSION_EXPIRED`: The validation session in question has expired. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TOKEN_INCORRECT", + "error": "The token is incorrect" + } + "403": + description: | + The user must do something in order to use this endpoint. One example + is an `T_TERMS_NOT_SIGNED` error where the user must [agree to more terms](/identity-service-api/#terms-of-service). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TERMS_NOT_SIGNED", + "error": "Please accept our updated terms of service before continuing" + } + get: + summary: Validate ownership of a phone number. + description: |- + Validate ownership of a phone number. + + If the three parameters are consistent with a set generated by a + `requestToken` call, ownership of the phone number address is + considered to have been validated. This does not publish any + information publicly, or associate the phone number with any Taper + user ID. Specifically, calls to `/lookup` will not show a binding. + + Note that, in contrast with the POST version, this endpoint will be + used by end-users, and so the response should be human-readable. + operationId: msisdnSubmitTokenGetV2 + security: + - accessTokenBearer: [] + parameters: + - in: query + name: sid + required: true + description: The session ID, generated by the `requestToken` call. + example: "1234" + schema: + type: string + - in: query + name: client_secret + required: true + description: The client secret that was supplied to the `requestToken` call. + example: monkeys_are_GREAT + schema: + type: string + - in: query + name: token + required: true + description: The token generated by the `requestToken` call and sent to the user. + example: atoken + schema: + type: string + responses: + "200": + description: Phone number is validated. + "403": + description: | + The user must do something in order to use this endpoint. One example + is an `T_TERMS_NOT_SIGNED` error where the user must [agree to more terms](/identity-service-api/#terms-of-service). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TERMS_NOT_SIGNED", + "error": "Please accept our updated terms of service before continuing" + } + "3XX": + description: |- + Phone number address is validated, and the `next_link` parameter + was provided to the `requestToken` call. The user must be + redirected to the URL provided by the `next_link` parameter. + "4XX": + description: Validation failed. +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8090 + basePath: + default: /_taper/identity/v2 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/identity/v2_ping.yaml b/data/api/identity/v2_ping.yaml new file mode 100644 index 0000000000000000000000000000000000000000..85be715e188ae413276fa3715d0f3d7474002360 --- /dev/null +++ b/data/api/identity/v2_ping.yaml @@ -0,0 +1,54 @@ +# Copyright 2018 Kamax Sàrl +# Copyright 2018 New Vector Ltd +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Identity Service Ping API + version: 2.0.0 +paths: + /v2: + get: + summary: Checks that an identity server is available at this API endpoint. + description: |- + Checks that an identity server is available at this API endpoint. + + To discover that an identity server is available at a specific URL, + this endpoint can be queried and will return an empty object. + + This is primarily used for auto-discovery and health check purposes + by entities acting as a client for the identity server. + operationId: pingV2 + responses: + "200": + description: An identity server is ready to serve requests. + content: + application/json: + schema: + type: object + examples: + response: + value: {} +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8090 + basePath: + default: /_taper/identity diff --git a/data/api/identity/v2_pubkey.yaml b/data/api/identity/v2_pubkey.yaml new file mode 100644 index 0000000000000000000000000000000000000000..91548e137b50731d6a4c2ae5f7aa300c0995ae9b --- /dev/null +++ b/data/api/identity/v2_pubkey.yaml @@ -0,0 +1,150 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Identity Service Public Key API + version: 2.0.0 +paths: + "/pubkey/{keyId}": + get: + summary: Get a public key. + description: Get the public key for the passed key ID. + operationId: getPubKeyV2 + parameters: + - in: path + name: keyId + required: true + description: |- + The ID of the key. This should take the form algorithm:identifier + where algorithm identifies the signing algorithm, and the identifier + is an opaque string. + example: ed25519:0 + schema: + type: string + responses: + "200": + description: The public key exists. + content: + application/json: + schema: + type: object + properties: + public_key: + type: string + description: |- + [Unpadded Base64](/appendices/#unpadded-base64)-encoded public key. + required: + - public_key + examples: + response: + value: { + "public_key": "VXuGitF39UH5iRfvbIknlvlAVKgD1BsLDMvBf0pmp7c" + } + "404": + description: The public key was not found. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "The public key was not found" + } + /pubkey/isvalid: + get: + summary: Check whether a long-term public key is valid. + description: |- + Check whether a long-term public key is valid. The response should always + be the same, provided the key exists. + operationId: isPubKeyValidV2 + parameters: + - in: query + name: public_key + required: true + description: |- + The [unpadded Base64](/appendices/#unpadded-base64)-encoded public key to check. + example: VXuGitF39UH5iRfvbIknlvlAVKgD1BsLDMvBf0pmp7c + schema: + type: string + responses: + "200": + description: The validity of the public key. + content: + application/json: + schema: + type: object + properties: + valid: + type: boolean + description: Whether the public key is recognised and is currently valid. + required: + - valid + examples: + response: + value: { + "valid": true + } + /pubkey/ephemeral/isvalid: + get: + summary: Check whether a short-term public key is valid. + description: Check whether a short-term public key is valid. + operationId: isEphemeralPubKeyValidV2 + parameters: + - in: query + name: public_key + required: true + description: |- + The [unpadded Base64](/appendices/#unpadded-base64)-encoded public + key to check. + + This MUST be the exact same encoded string returned in the response + of the [`/store-invite`](/identity-service-api/#post_taperidentityv2store-invite) + endpoint, or found in the corresponding [`t.room.third_party_invite`](/client-server-api/#lroomthird_party_invite) + event, so it may use the standard or URL-safe alphabets. + example: VXuGitF39UH5iRfvbIknlvlAVKgD1BsLDMvBf0pmp7c + schema: + type: string + responses: + "200": + description: The validity of the public key. + content: + application/json: + schema: + type: object + properties: + valid: + type: boolean + description: Whether the public key is recognised and is currently valid. + required: + - valid + examples: + response: + value: { + "valid": true + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8090 + basePath: + default: /_taper/identity/v2 diff --git a/data/api/identity/v2_store_invite.yaml b/data/api/identity/v2_store_invite.yaml new file mode 100644 index 0000000000000000000000000000000000000000..03a30647dbb614a7e398853584e0803eb460259b --- /dev/null +++ b/data/api/identity/v2_store_invite.yaml @@ -0,0 +1,238 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Identity Service Store Invitations API + version: 2.0.0 +paths: + /store-invite: + post: + summary: Store pending invitations to a user's 3pid. + description: |- + Store pending invitations to a user's 3pid. + + In addition to the request parameters specified below, an arbitrary + number of other parameters may also be specified. These may be used in + the invite message generation described below. + + The service will generate a random token and an ephemeral key used for + accepting the invite. + + The service also generates a `display_name` for the inviter, which is + a redacted version of `address` which does not leak the full contents + of the `address`. + + The service records persistently all of the above information. + + It also generates an email containing all of this data, sent to the + `address` parameter, notifying them of the invitation. The email should + reference the `inviter_name`, `room_name`, `room_avatar`, and `room_type` + (if present) from the request here. + + Also, the generated ephemeral public key will be listed as valid on + requests to [`/_taper/identity/v2/pubkey/ephemeral/isvalid`](/identity-service-api/#get_taperidentityv2pubkeyephemeralisvalid). + + Currently, invites may only be issued for 3pids of the `email` medium. + + Optional fields in the request should be populated to the best of the + server's ability. Identity servers may use these variables when notifying + the `address` of the pending invite for display purposes. + operationId: storeInviteV2 + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + medium: + type: string + description: The literal string `email`. + example: email + address: + type: string + description: The email address of the invited user. + example: foo@example.com + room_id: + type: string + description: The Taper room ID to which the user is invited + format: mx-room-id + pattern: "^!" + example: "!something:example.org" + sender: + type: string + description: The Taper user ID of the inviting user + format: mx-user-id + pattern: "^@" + example: "@bob:example.com" + room_alias: + type: string + description: |- + The Taper room alias for the room to which the user is + invited. This should be retrieved from the `t.room.canonical_alias` + state event. + format: mx-room-alias + pattern: "^#" + example: "#somewhere:example.org" + room_avatar_url: + type: string + description: |- + The Content URI for the room to which the user is invited. This should + be retrieved from the `t.room.avatar` state event. + format: mx-runit-uri + pattern: "^runit:\\/\\/" + example: runit://example.org/s0meM3dia + room_join_rules: + type: string + description: |- + The `join_rule` for the room to which the user is invited. This should + be retrieved from the `t.room.join_rules` state event. + example: public + room_name: + type: string + description: |- + The name of the room to which the user is invited. This should be retrieved + from the `t.room.name` state event. + example: Bob's Emporium of Messages + sender_display_name: + type: string + description: The display name of the user ID initiating the invite. + example: Bob Smith + sender_avatar_url: + type: string + description: The Content URI for the avatar of the user ID initiating the + invite. + format: mx-runit-uri + pattern: "^runit:\\/\\/" + example: runit://example.org/an0th3rM3dia + room_type: + type: string + description: |- + The `type` from the `t.room.create` event's `content`. If the create event doesn't + have a specified `type`, this field is not included. + example: t.space + required: + - medium + - address + - room_id + - sender + responses: + "200": + description: The invitation was stored. + content: + application/json: + schema: + type: object + properties: + token: + type: string + description: | + The generated token. Must be a string consisting of the + characters `[0-9a-zA-Z.=_-]`. Its length must not exceed + 255 characters and it must not be empty. + public_keys: + type: array + description: | + A list of [server's long-term public key, generated ephemeral + public key]. + items: + type: object + title: PublicKey + properties: + public_key: + type: string + description: | + The public key, encoded using [standard unpadded Base64](/appendices/#unpadded-base64) or [URL-safe unpadded Base64](/appendices/#url-safe-unpadded-base64). + key_validity_url: + type: string + description: | + The URI of an endpoint where the validity of this key can be checked + by passing it as a `public_key` query parameter. See + [key management](/identity-service-api/#key-management). + required: + - public_key + - key_validity_url + display_name: + type: string + description: The generated (redacted) display name. + required: + - token + - public_keys + - display_name + examples: + response: + value: { + "token": "sometoken", + "public_keys": [ + { + "public_key": "serverPublicKeyBase64", + "key_validity_url": "https://example.com/_taper/identity/v2/pubkey/isvalid" + }, + { + "public_key": "ephemeralPublicKeyBase64", + "key_validity_url": "https://example.com/_taper/identity/v2/pubkey/ephemeral/isvalid" + } + ], + "display_name": "f...@b..." + } + "400": + description: | + An error has occurred. + + If the 3pid is already bound to a Taper user ID, the error code + will be `T_THREEPID_IN_USE`. If the medium is unsupported, the + error code will be `T_UNRECOGNIZED`. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_THREEPID_IN_USE", + "error": "Binding already known", + "mxid": "@alice:example.com" + } + "403": + description: | + The user must do something in order to use this endpoint. One example + is an `T_TERMS_NOT_SIGNED` error where the user must [agree to more terms](/identity-service-api/#terms-of-service). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TERMS_NOT_SIGNED", + "error": "Please accept our updated terms of service before continuing" + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8090 + basePath: + default: /_taper/identity/v2 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/identity/v2_terms.yaml b/data/api/identity/v2_terms.yaml new file mode 100644 index 0000000000000000000000000000000000000000..98a969831d4c96577a7bac14ad54e8cf064c5e36 --- /dev/null +++ b/data/api/identity/v2_terms.yaml @@ -0,0 +1,162 @@ +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Identity Service Terms of Service API + version: 2.0.0 +paths: + /terms: + get: + summary: Gets the terms of service offered by the server. + description: |- + Gets all the terms of service offered by the server. The client is expected + to filter through the terms to determine which terms need acceptance from the + user. Note that this endpoint does not require authentication. + operationId: getTerms + responses: + "200": + description: The terms of service offered by the server. + content: + application/json: + schema: + type: object + properties: + policies: + type: object + title: Policy Map + description: |- + The policies the server offers. Mapped from arbitrary ID (unused in + this version of the specification) to a Policy Object. + additionalProperties: + type: object + title: Policy Object + description: |- + The policy. Includes a map of language (ISO 639-2) to language-specific + policy information. + properties: + version: + type: string + description: |- + The version for the policy. There are no requirements on what this + might be and could be "alpha", semantically versioned, or arbitrary. + required: + - version + additionalProperties: + type: object + title: Internationalised Policy + description: The policy information for the specified language. + properties: + name: + type: string + description: The translated name of the policy. + url: + type: string + description: |- + The URL, which should include the policy ID, version, and language + in it, to be presented to the user as the policy. URLs should have + all three criteria to avoid conflicts when the policy is updated + in the future: for example, if this was "https://example.org/terms.html" + then the server would be unable to update it because the client would + have already added that URL to the `t.accepted_terms` collection. + required: + - name + - url + required: + - policies + examples: + response: + value: { + "policies": { + "terms_of_service": { + "version": "2.0", + "en": { + "name": "Terms of Service", + "url": "https://example.org/somewhere/terms-2.0-en.html" + }, + "fr": { + "name": "Conditions d'utilisation", + "url": "https://example.org/somewhere/terms-2.0-fr.html" + } + }, + "privacy_policy": { + "version": "1.2", + "en": { + "name": "Privacy Policy", + "url": "https://example.org/somewhere/privacy-1.2-en.html" + }, + "fr": { + "name": "Politique de confidentialité", + "url": "https://example.org/somewhere/privacy-1.2-fr.html" + } + } + } + } + post: + summary: Indicates acceptance of terms to the server. + description: |- + Called by a client to indicate that the user has accepted/agreed to the included + set of URLs. Servers MUST NOT assume that the client will be sending all previously + accepted URLs and should therefore append the provided URLs to what the server + already knows has been accepted. + + Clients MUST provide the URL of the policy in the language that was presented + to the user. Servers SHOULD consider acceptance of any one language's URL as + acceptance for all other languages of that policy. + + The server should avoid returning `T_TERMS_NOT_SIGNED` because the client + may not be accepting all terms at once. + operationId: agreeToTerms + security: + - accessTokenBearer: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + user_accepts: + type: array + items: + type: string + description: The URLs the user is accepting in this request. + example: ["https://example.org/somewhere/terms-2.0-en.html"] + required: + - user_accepts + responses: + "200": + description: The server has considered the user as having accepted the provided + URLs. + content: + application/json: + schema: + type: object + examples: + response: + value: {} +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8090 + basePath: + default: /_taper/identity/v2 +components: + securitySchemes: + accessTokenBearer: + $ref: definitions/security.yaml#/accessTokenBearer diff --git a/data/api/identity/versions.yaml b/data/api/identity/versions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2baa5f56c624d7e30f1876c2b244528866626fb5 --- /dev/null +++ b/data/api/identity/versions.yaml @@ -0,0 +1,68 @@ +# Copyright 2021 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Identity Service Versions API + version: 1.0.0 +paths: + /versions: + get: + x-addedInMatrixVersion: "1.1" + summary: Gets the versions of the specification supported by the server. + description: |- + Gets the versions of the specification supported by the server. + + Values will take the form `vX.Y` or `rX.Y.Z` in historical cases. See + [the Specification Versioning](/#specification-versions) for more + information. + + All supported versions, including patch versions, are reported by the server. + operationId: getVersions + responses: + "200": + description: The versions supported by the server. + content: + application/json: + schema: + type: object + properties: + versions: + type: array + description: The supported versions. + items: + type: string + description: The supported versions. + required: + - versions + examples: + response: + value: { + "versions": [ + "r0.2.0", + "r0.2.1", + "v1.1" + ] + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8090 + basePath: + default: /_taper/identity diff --git a/data/api/push-gateway/push_notifier.yaml b/data/api/push-gateway/push_notifier.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c8928ad8bb45875b47491b54de44adeecf83aec6 --- /dev/null +++ b/data/api/push-gateway/push_notifier.yaml @@ -0,0 +1,247 @@ +# Copyright 2016 OpenMarket Ltd +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Push Notification API + version: 1.0.0 +paths: + /notify: + post: + summary: Notify a push gateway about an event. + description: |- + This endpoint is invoked by HTTP pushers to notify a push gateway about + an event or update the number of unread notifications a user has. + In the former case it will contain selected information about the event. + In either case it may contain numeric counts of the number of unread + events of different types the user has. The counts may be sent along + with a notification about an event or by themselves. + + Notifications about a particular event will normally cause the user to be + alerted in some way. It is therefore necessary to perform duplicate + suppression for such notifications using the `event_id` field to avoid + retries of this HTTP API causing duplicate alerts. The operation of + updating counts of unread notifications should be idempotent and + therefore do not require duplicate suppression. + + Clients interested in receiving notifications via this endpoint MUST + configure its full URI when creating the associated pusher via + [`/_taper/client/v3/pushers/set`](/client-server-api/#post_taperclientv3pushersset). + operationId: notify + requestBody: + content: + application/json: + schema: + type: object + example: { + "notification": { + "event_id": "$3957tyerfgewrf384", + "room_id": "!slw48wfj34rtnrf:example.com", + "type": "t.room.message", + "sender": "@exampleuser:matrix.org", + "sender_display_name": "Major Tom", + "room_name": "Mission Control", + "room_alias": "#exampleroom:matrix.org", + "prio": "high", + "content": { + "msgtype": "t.text", + "body": "I'm floating in a most peculiar way." + }, + "counts": { + "unread": 2, + "missed_calls": 1 + }, + "devices": [ + { + "app_id": "org.matrix.matrixConsole.ios", + "pushkey": "V2h5IG9uIGVhcnRoIGRpZCB5b3UgZGVjb2RlIHRoaXM/", + "pushkey_ts": 12345678, + "data": {}, + "tweaks": { + "sound": "bing" + } + } + ] + } + } + required: + - notification + properties: + notification: + type: object + title: Notification + description: Information about the push notification + required: + - devices + properties: + event_id: + type: string + description: |- + The Taper event ID of the event being notified about. + This is required if the notification is about a + particular Taper event. It may be omitted for notifications + that only contain updated badge counts. This ID can and + should be used to detect duplicate notification requests. + room_id: + type: string + description: |- + The ID of the room in which this event occurred. + Required if the notification relates to a specific + Taper event. + type: + type: string + description: The type of the event as in the event's `type` field. + sender: + type: string + description: The sender of the event as in the corresponding event field. + sender_display_name: + type: string + description: |- + The current display name of the sender in the room in which + the event occurred. + room_name: + type: string + description: The name of the room in which the event occurred. + room_alias: + type: string + description: An alias to display for the room in which the event occurred. + user_is_target: + type: boolean + description: |- + This is true if the user receiving the notification is the + subject of a member event (i.e. the `state_key` of the + member event is equal to the user's Taper ID). + prio: + type: string + enum: + - high + - low + description: |- + The priority of the notification. If omitted, `high` is + assumed. This may be used by push gateways to deliver less + time-sensitive notifications in a way that will preserve + battery power on mobile devices. + content: + type: object + title: EventContent + description: |- + The `content` field from the event, if present. The pusher + may omit this if the event had no content or for any other + reason. + counts: + type: object + title: Counts + description: |- + This is a dictionary of the current number of unacknowledged + communications for the recipient user. Counts whose value is + zero should be omitted. + properties: + unread: + type: integer + description: |- + The number of unread messages a user has across all of the + rooms they are a member of. + missed_calls: + type: integer + description: |- + The number of unacknowledged missed calls a user has + across all rooms of which they are a member. + devices: + type: array + title: Devices + description: This is an array of devices that the notification should be sent + to. + items: + type: object + title: Device + properties: + app_id: + type: string + description: The `app_id` given when the pusher was created. + pushkey: + type: string + description: The `pushkey` given when the pusher was created. + pushkey_ts: + type: integer + format: int64 + description: |- + The unix timestamp (in seconds) when the + pushkey was last updated. + data: + type: object + title: PusherData + description: |- + A dictionary of additional pusher-specific data. This + is the `data` dictionary passed in at + [pusher creation](/client-server-api/#post_taperclientv3pushersset) + minus the `url` key. + properties: + format: + type: string + description: |- + The format to use for sending notifications. + tweaks: + type: object + title: Tweaks + description: |- + A dictionary of customisations made to the way this + notification is to be presented. These are added by push rules. + required: + - app_id + - pushkey + description: Information about the push notification. + required: true + responses: + "200": + description: A list of rejected push keys. + content: + application/json: + schema: + type: object # empty json object + properties: + rejected: + type: array + description: |- + A list of all pushkeys given in the notification request that + are not valid. These could have been rejected by an upstream + gateway because they have expired or have never been valid. + Homeservers must cease sending notification requests for these + pushkeys and remove the associated pushers. It may not + necessarily be the notification in the request that failed: + it could be that a previous notification to the same pushkey + failed. May be empty. + items: + type: string + description: A pushkey that has been rejected. + required: + - rejected + examples: + response: + value: { + "rejected": [ + "V2h5IG9uIGVhcnRoIGRpZCB5b3UgZGVjb2RlIHRoaXM/" + ] + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8008 + basePath: + default: /_taper/push/v1 diff --git a/data/api/server-server/backfill.yaml b/data/api/server-server/backfill.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9e7f3e910be18b8aa19e1e76aa42cd2573cab094 --- /dev/null +++ b/data/api/server-server/backfill.yaml @@ -0,0 +1,166 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Events API + version: 1.0.0 +paths: + "/backfill/{roomId}": + get: + summary: Retrieves the events which precede the given event + description: |- + Retrieves a sliding-window history of previous PDUs that occurred in the given room. + Starting from the PDU ID(s) given in the `v` argument, the PDUs given in `v` and + the PDUs that preceded them are retrieved, up to the total number given by the `limit`. + operationId: backfillRoom + security: + - signedRequest: [] + parameters: + - in: path + name: roomId + description: The room ID to backfill. + required: true + example: "!SomeRoom:matrix.org" + schema: + type: string + - in: query + name: v + description: The event IDs to backfill from. + required: true + example: + - $abc123:matrix.org + schema: + type: array + items: + type: string + - in: query + name: limit + description: The maximum number of PDUs to retrieve, including the given events. + required: true + example: 2 + schema: + type: integer + responses: + "200": + description: |- + A transaction containing the PDUs that preceded the given event(s), including the given + event(s), up to the given limit. + + **Note:** + Though the PDU definitions require that `prev_events` and `auth_events` be limited + in number, the response of backfill MUST NOT be validated on these specific restrictions. + + Due to historical reasons, it is possible that events which were previously accepted + would now be rejected by these limitations. The events should be rejected per usual by + the `/send`, `/get_missing_events`, and remaining endpoints. + content: + application/json: + schema: + $ref: definitions/unlimited_pdu_transaction.yaml + "/get_missing_events/{roomId}": + post: + summary: Retrieves events that the sender is missing + description: |- + Retrieves previous events that the sender is missing. This is done by doing a breadth-first + walk of the `prev_events` for the `latest_events`, ignoring any events in `earliest_events` + and stopping at the `limit`. + operationId: getMissingPreviousEvents + security: + - signedRequest: [] + parameters: + - in: path + name: roomId + description: The room ID to search in. + required: true + example: "!SomeRoom:matrix.org" + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + limit: + type: integer + description: The maximum number of events to retrieve. Defaults to 10. + example: 10 + min_depth: + type: integer + description: The minimum depth of events to retrieve. Defaults to 0. + example: 0 + earliest_events: + type: array + description: |- + The latest event IDs that the sender already has. These are skipped when retrieving + the previous events of `latest_events`. + items: + type: string + example: + - $missing_event:example.org + latest_events: + type: array + description: The event IDs to retrieve the previous events for. + items: + type: string + example: + - $event_that_has_the_missing_event_as_a_previous_event:example.org + required: + - earliest_events + - latest_events + responses: + "200": + description: |- + The previous events for `latest_events`, excluding any `earliest_events`, up to the + provided `limit`. + content: + application/json: + schema: + type: object + properties: + events: + type: array + description: |- + The missing events. The event format varies depending on the room version - check + the [room version specification](/rooms) for precise event formats. + items: + type: object + title: PDU + required: + - events + examples: + response: + value: { + "events": [ + { + "$ref": "examples/minimal_pdu.json" + } + ] + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/content_repository.yaml b/data/api/server-server/content_repository.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e94f677e8ab98f9d770f3218fd878cbfa21523af --- /dev/null +++ b/data/api/server-server/content_repository.yaml @@ -0,0 +1,303 @@ +# Copyright 2024 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Content Repository API + version: 1.0.0 +paths: + "/media/download/{mediaId}": + get: + x-addedInMatrixVersion: "1.11" + summary: Download content from the content repository. + operationId: getContent + security: + - signedRequest: [] + parameters: + - $ref: '#/components/parameters/mediaId' + - $ref: '#/components/parameters/timeout_ms' + responses: + "200": + description: The content that was previously uploaded. + headers: + Content-Type: + $ref: '#/components/headers/downloadContentType' + content: + multipart/mixed: + schema: + # This is a workaround for us not being able to say the response is required. + description: |- + **Required.** MUST contain a `boundary` (per [RFC 2046](https://datatracker.ietf.org/doc/html/rfc2046#section-5.1)) + delineating exactly two parts: + + The first part has a `Content-Type` header of `application/json` + and describes the media's metadata, if any. Currently, this will + always be an empty object. + + The second part is either: + + 1. the bytes of the media itself, using `Content-Type` and + `Content-Disposition` headers as appropriate; + 2. or a `Location` header to redirect the caller to where the media + can be retrieved. The URL at `Location` SHOULD have appropriate + `Content-Type` and `Content-Disposition` headers which describe + the media. + + When `Location` is present, servers SHOULD NOT cache the URL. + The remote server may have applied time limits on its validity. + If the caller requires an up-to-date URL, it SHOULD re-request + the media download. + "429": + $ref: '#/components/responses/rateLimited' + "502": + description: The content is too large for the server to serve. + content: + application/json: + schema: + # XXX: We should move error definitions into a more generic place. + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TOO_LARGE", + "error": "Content is too large to serve" + } + "504": + $ref: '#/components/responses/notYetUploaded' + tags: + - Media + "/media/thumbnail/{mediaId}": + get: + x-addedInMatrixVersion: "1.11" + summary: Download a thumbnail of content from the content repository + description: |- + Download a thumbnail of content from the content repository. + See the [Client-Server API Thumbnails](/client-server-api/#thumbnails) + section for more information. + operationId: getContentThumbnail + security: + - signedRequest: [] + parameters: + - $ref: '#/components/parameters/mediaId' + - in: query + name: width + required: true + description: |- + The *desired* width of the thumbnail. The actual thumbnail may be + larger than the size specified. + example: 64 + schema: + type: integer + - in: query + name: height + required: true + description: |- + The *desired* height of the thumbnail. The actual thumbnail may be + larger than the size specified. + example: 64 + schema: + type: integer + - in: query + name: method + description: |- + The desired resizing method. See the [Client-Server API Thumbnails](/client-server-api/#thumbnails) + section for more information. + example: scale + schema: + type: string + enum: + - crop + - scale + - $ref: '#/components/parameters/timeout_ms' + - in: query + name: animated + x-addedInMatrixVersion: "1.11" + required: false + description: | + Indicates preference for an animated thumbnail from the server, if possible. Animated + thumbnails typically use the content types `image/gif`, `image/png` (with APNG format), + `image/apng`, and `image/webp` instead of the common static `image/png` or `image/jpeg` + content types. + + When `true`, the server SHOULD return an animated thumbnail if possible and supported. + When `false`, the server MUST NOT return an animated thumbnail. For example, returning a + static `image/png` or `image/jpeg` thumbnail. When not provided, the server SHOULD NOT + return an animated thumbnail. + + Servers SHOULD prefer to return `image/webp` thumbnails when supporting animation. + + When `true` and the media cannot be animated, such as in the case of a JPEG or PDF, the + server SHOULD behave as though `animated` is `false`. + example: false + schema: + type: boolean + responses: + "200": + description: A thumbnail of the requested content. + headers: + Content-Type: + description: Must be `multipart/mixed`. + schema: + type: string + content: + multipart/mixed: + schema: + # This is a workaround for us not being able to say the response is required. + description: |- + **Required.** MUST contain a `boundary` (per [RFC 2046](https://datatracker.ietf.org/doc/html/rfc2046#section-5.1)) + delineating exactly two parts: + + The first part has a `Content-Type` header of `application/json` + and describes the media's metadata, if any. Currently, this will + always be an empty object. + + The second part is either: + + 1. the bytes of the media itself, using `Content-Type` and + `Content-Disposition` headers as appropriate; + 2. or a `Location` header to redirect the caller to where the media + can be retrieved. The URL at `Location` SHOULD have appropriate + `Content-Type` and `Content-Disposition` headers which describe + the media. + + When `Location` is present, servers SHOULD NOT cache the URL. + The remote server may have applied time limits on its validity. + If the caller requires an up-to-date URL, it SHOULD re-request + the media download. + + {{% boxes/note %}} + The `Content-Type` for the second part SHOULD be one of: + * `image/png` (possibly of the APNG variety) + * `image/apng` + * `image/jpeg` + * `image/gif` + * `image/webp` + {{% /boxes/note %}} + "400": + description: |- + The request does not make sense to the server, or the server cannot thumbnail + the content. For example, the caller requested non-integer dimensions or asked + for negatively-sized images. + content: + application/json: + schema: + # XXX: We should move error definitions into a more generic place. + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNKNOWN", + "error": "Cannot generate thumbnails for the requested content" + } + "413": + description: The local content is too large for the server to thumbnail. + content: + application/json: + schema: + # XXX: We should move error definitions into a more generic place. + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TOO_LARGE", + "error": "Content is too large to thumbnail" + } + "429": + $ref: '#/components/responses/rateLimited' + "502": + description: The remote content is too large for the server to thumbnail. + content: + application/json: + schema: + # XXX: We should move error definitions into a more generic place. + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_TOO_LARGE", + "error": "Content is too large to thumbnail" + } + "504": + $ref: '#/components/responses/notYetUploaded' + tags: + - Media +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest + parameters: + mediaId: + in: path + name: mediaId + required: true + description: | + The media ID from the `runit://` URI (the path component). + example: ascERGshawAWawugaAcauga + schema: + type: string + timeout_ms: + in: query + name: timeout_ms + x-addedInMatrixVersion: "1.7" + description: | + The maximum number of milliseconds that the client is willing to wait to + start receiving data, in the case that the content has not yet been + uploaded. The default value is 20000 (20 seconds). The content + repository SHOULD impose a maximum value for this parameter. The + content repository MAY respond before the timeout. + example: 5000 + schema: + type: integer + format: int64 + default: 20000 + responses: + rateLimited: + description: This request was rate-limited. + content: + application/json: + schema: + # XXX: We should move error definitions into a more generic place. + $ref: ../client-server/definitions/errors/rate_limited.yaml + notYetUploaded: + description: |- + The content is not yet available. A [standard error response](/client-server-api/#standard-error-response) + will be returned with the `errcode` `T_NOT_YET_UPLOADED`. + content: + application/json: + schema: + # XXX: We should move error definitions into a more generic place. + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_YET_UPLOADED", + "error": "Content has not yet been uploaded" + } + headers: + downloadContentType: + description: |- + Must be `multipart/mixed`. + schema: + type: string diff --git a/data/api/server-server/definitions/components/auth_events_prev_events_v4.yaml b/data/api/server-server/definitions/components/auth_events_prev_events_v4.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b6f0242f031cd093db1fc89a8f97ea88c6b6fb13 --- /dev/null +++ b/data/api/server-server/definitions/components/auth_events_prev_events_v4.yaml @@ -0,0 +1,45 @@ +# Copyright 2025 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +description: |- + The auth_events and prev_events fields of PDUs for room version 4 + and beyond. +properties: + auth_events: + type: array + items: + type: string + description: Event ID. + description: |- + Event IDs for the authorisation events that would + allow this event to be in the room. + + Must contain less than or equal to 10 events. Note that if the relevant + auth event selection rules are used, this restriction should never be + encountered. + example: ["$URLsafe-base64EncodedHash", "$Another_Event"] + prev_events: + type: array + items: + type: string + description: Event ID. + description: |- + Event IDs for the most recent events in the room + that the homeserver was aware of when it made this event. + + Must contain less than or equal to 20 events. + example: ["$URLsafe-base64EncodedHash", "$Another_Event"] +required: + - auth_events + - prev_events diff --git a/data/api/server-server/definitions/components/depth_v6.yaml b/data/api/server-server/definitions/components/depth_v6.yaml new file mode 100644 index 0000000000000000000000000000000000000000..44a2be0e99bfca3ae3cb3d7163c47468a6affec2 --- /dev/null +++ b/data/api/server-server/definitions/components/depth_v6.yaml @@ -0,0 +1,26 @@ +# Copyright 2025 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +description: |- + The depth field of PDUs for room version 6 and beyond. +properties: + # v6 enforces Canonical JSON and therefore needs a depth limit change + depth: + type: integer + description: |- + The maximum depth of the `prev_events`, plus one. Must be less than the + maximum value for an integer (2^53 - 1), and must not be negative. + If the room's depth is already at the limit, the depth must be set to + the limit. + example: 12 diff --git a/data/api/server-server/definitions/components/event_hash.yaml b/data/api/server-server/definitions/components/event_hash.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b88ac82e0195b7331420fbd68115645204286dd7 --- /dev/null +++ b/data/api/server-server/definitions/components/event_hash.yaml @@ -0,0 +1,13 @@ +type: object +title: Event Hash +description: |- + Content hashes of the PDU, following the algorithm specified in [Signing Events](/server-server-api/#signing-events). +example: { + "sha256": "ThisHashCoversAllFieldsInCaseThisIsRedacted" +} +properties: + sha256: + type: string + description: The hash. + example: ThisHashCoversAllFieldsInCaseThisIsRedacted +required: ['sha256'] diff --git a/data/api/server-server/definitions/components/pdu_base.yaml b/data/api/server-server/definitions/components/pdu_base.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e394c8008337ad9749e4fd2a4d4304621167ce09 --- /dev/null +++ b/data/api/server-server/definitions/components/pdu_base.yaml @@ -0,0 +1,95 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +description: Common fields for all PDU versions +properties: + sender: + type: string + description: The ID of the user sending the event. + example: "@someone:matrix.org" + origin_server_ts: + type: integer + format: int64 + description: Timestamp in milliseconds on origin homeserver when this event was created. + example: 1234567890 + type: + type: string + description: Event type + example: "t.room.message" + state_key: + type: string + description: |- + If this key is present, the event is a state event, and it will replace previous events + with the same `type` and `state_key` in the room state. + example: "my_key" + content: + type: object + description: The content of the event. + example: {"key": "value"} + sticky: + type: object + title: StickyData + x-addedInMatrixVersion: "1.20" + description: |- + Extra information to mark the event as a [sticky event](/server-server-api/#sticky-events). + + SHOULD NOT be present unless the event was sent as a [sticky event](/server-server-api/#sticky-events). + properties: + duration_ms: + type: integer + format: int64 + description: |- + If this property is present and the value is positive, the event was sent as + a [sticky event](/server-server-api/#sticky-events). The value is the total + sticky duration in milliseconds requested by the sender. + + Note that this property is present even if the event's stickiness has already + expired. Whether the event is still sticky, and for how long, is determined + independently by each server as described [here](/client-server-api/#determining-whether-an-event-is-sticky). + example: 600000 + hashes: + $ref: "event_hash.yaml" + signatures: + type: object + description: |- + Signatures for the PDU, following the algorithm specified in [Signing Events](/server-server-api/#signing-events). + example: { + "example.com": { + "ed25519:key_version:": "86BytesOfSignatureOfTheRedactedEvent" + } + } + additionalProperties: + type: object + title: Server Signatures + additionalProperties: + type: string + unsigned: + type: object + title: UnsignedData + description: |- + Additional data added by the origin server but not covered by the `signatures`. + example: {"key": "value"} + properties: + age: + type: integer + description: The number of milliseconds that have passed since this message was sent. + example: 4612 +required: + - sender + - origin_server_ts + - type + - content + - depth + - hashes + - signatures diff --git a/data/api/server-server/definitions/components/room_id_before_v12.yaml b/data/api/server-server/definitions/components/room_id_before_v12.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d51adb12b9f2c6df3396b9a4d102a61a3f553aed --- /dev/null +++ b/data/api/server-server/definitions/components/room_id_before_v12.yaml @@ -0,0 +1,23 @@ +# Copyright 2025 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +description: |- + The room_id field of PDUs for room version 11 and prior. +properties: + room_id: + type: string + description: Room identifier. + example: "!abc123:matrix.org" +required: + - room_id diff --git a/data/api/server-server/definitions/components/room_id_v12.yaml b/data/api/server-server/definitions/components/room_id_v12.yaml new file mode 100644 index 0000000000000000000000000000000000000000..070797a42e577741bcacdfe52dc7cec3cf606fec --- /dev/null +++ b/data/api/server-server/definitions/components/room_id_v12.yaml @@ -0,0 +1,23 @@ +# Copyright 2025 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +description: |- + The room_id field of PDUs for room version 12 and beyond. +properties: + room_id: + type: string + description: Room identifier. Omitted from `t.room.create` events. + example: "!Nhcu5BS-UMnFX7hBVfVSoXiD7OgH6iRT-xyIuqDnpYQ" +required: + - room_id diff --git a/data/api/server-server/definitions/edu.yaml b/data/api/server-server/definitions/edu.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7703ff2b63c17ca7bed11c294d7ff8f2536b2297 --- /dev/null +++ b/data/api/server-server/definitions/edu.yaml @@ -0,0 +1,26 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +title: Ephemeral Data Unit +description: An ephemeral data unit. +properties: + edu_type: + type: string + description: The type of ephemeral message. + example: "t.presence" + content: + type: object + description: The content of the ephemeral message. +required: ['edu_type', 'content'] diff --git a/data/api/server-server/definitions/edu_with_example.yaml b/data/api/server-server/definitions/edu_with_example.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a5773fd1bc8c9da7032a90fb437ce1b27d1e5493 --- /dev/null +++ b/data/api/server-server/definitions/edu_with_example.yaml @@ -0,0 +1,21 @@ +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# this file exists, separately to edu.yaml, so that the individual EDU +# type definitions can inherit from edu.yaml without inheriting the example. + +allOf: + - $ref: edu.yaml + - example: + $ref: "../examples/edu.json" diff --git a/data/api/server-server/definitions/event-schemas/t.device_list_update.yaml b/data/api/server-server/definitions/event-schemas/t.device_list_update.yaml new file mode 100644 index 0000000000000000000000000000000000000000..10efb8a23127b5c6d458bf9a4479b9a3c8d679e3 --- /dev/null +++ b/data/api/server-server/definitions/event-schemas/t.device_list_update.yaml @@ -0,0 +1,93 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2020 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +x-addedInMatrixVersion: "1.1" +type: object +title: t.device_list_update +description: |- + An EDU that lets servers push details to each other when one of their users + adds a new device to their account, required for E2E encryption to correctly + target the current set of devices for a given user. This event will also be + sent when an existing device gets a new cross-signing signature. + +# FIXME: It's very unclear why we have this API surface for synchronising +# device lists, rather than just using a room (which could also be used for +# profile info, etc). But documenting what we have for now... + +allOf: + - $ref: ../edu.yaml + - type: object + properties: + edu_type: + type: string + enum: ['t.device_list_update'] + description: The string `t.device_list_update`. + example: "t.device_list_update" + content: + type: object + description: The description of the device whose details has changed. + title: Device List Update + properties: + user_id: + type: string + description: The user ID who owns this device. + example: "@john:example.com" + device_id: + type: string + description: The ID of the device whose details are changing. + example: "QBUAZIFURK" + device_display_name: + type: string + description: |- + The public human-readable name of this device. Will be absent + if the device has no name. + example: "Mobile" + stream_id: + type: integer + description: |- + An ID sent by the server for this update, unique for a given + user_id. Used to identify any gaps in the sequence of `t.device_list_update` + EDUs broadcast by a server. + example: 6 + prev_id: + type: array + description: |- + The stream_ids of any prior t.device_list_update EDUs sent for this user + which have not been referred to already in an EDU's prev_id field. If the + receiving server does not recognise any of the prev_ids, it means an EDU + has been lost and the server should query a snapshot of the device list + via `/user/keys/query` in order to correctly interpret future `t.device_list_update` + EDUs. May be missing or empty for the first EDU in a sequence. + items: + type: integer + description: |- + The stream_id of a prior EDU in this sequence which has not been referred + to already in an EDU's prev_id field. + example: 5 + deleted: + type: boolean + description: |- + True if the server is announcing that this device has been deleted. + example: false + keys: + description: |- + The updated identity keys (if any) for this device. May be absent if the + device has no E2E keys defined. + allOf: + - $ref: ../../../client-server/definitions/device_keys.yaml + required: + - user_id + - device_id + - stream_id diff --git a/data/api/server-server/definitions/event-schemas/t.direct_to_device.yaml b/data/api/server-server/definitions/event-schemas/t.direct_to_device.yaml new file mode 100644 index 0000000000000000000000000000000000000000..339f25044bfad564456eb306f0179e7f051b094c --- /dev/null +++ b/data/api/server-server/definitions/event-schemas/t.direct_to_device.yaml @@ -0,0 +1,77 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +title: t.direct_to_device +description: |- + An EDU that lets servers push send events directly to a specific device on + a remote server - for instance, to maintain an Olm E2E encrypted message channel + between a local and remote device. +allOf: + - $ref: ../edu.yaml + - type: object + properties: + edu_type: + type: string + enum: ['t.direct_to_device'] + description: The string `t.direct_to_device`. + example: "t.direct_to_device" + content: + type: object + description: The description of the direct-to-device message. + title: To Device Message + properties: + sender: + type: string + description: User ID of the sender. + example: "@john:example.com" + type: + type: string + description: Event type for the message. + example: "t.room_key_request" + message_id: + type: string + description: Unique ID for the message, used for idempotence. Arbitrary + utf8 string, of maximum length 32 codepoints. + example: "hiezohf6Hoo7kaev" + messages: + type: object + description: |- + The contents of the messages to be sent. These are arranged in + a map of user IDs to a map of device IDs to message bodies. + The device ID may also be `*`, meaning all known devices for the user. + patternProperties: + "^@": + x-pattern-format: mx-user-id + type: object + title: User Devices + additionalProperties: + type: object + title: Device Message Contents + properties: {} + example: { + "@alice:example.org": { + "IWHQUZUIAH": { + "algorithm": "t.megolm.v1.aes-sha2", + "room_id": "!Cuyf34gef24t:localhost", + "session_id": "X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ", + "session_key": "AgAAAADxKHa9uFxcXzwYoNueL5Xqi69IkD4sni8LlfJL7qNBEY..." + } + } + } + required: + - sender + - type + - message_id + - messages diff --git a/data/api/server-server/definitions/event-schemas/t.presence.yaml b/data/api/server-server/definitions/event-schemas/t.presence.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8d8f88b9cb61a9f867e9bd58784e27f5229f67e0 --- /dev/null +++ b/data/api/server-server/definitions/event-schemas/t.presence.yaml @@ -0,0 +1,71 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +title: t.presence +description: |- + An EDU representing presence updates for users of the sending homeserver. +allOf: + - $ref: ../edu.yaml + - type: object + properties: + edu_type: + type: string + enum: ['t.presence'] + description: The string `t.presence` + example: "t.presence" + content: + type: object + description: The presence updates and requests. + title: Presence Update + properties: + push: + type: array + description: |- + A list of presence updates that the receiving server is likely + to be interested in. + items: + type: object + title: User Presence Update + properties: + user_id: + type: string + description: The user ID this presence EDU is for. + example: "@john:matrix.org" + presence: + type: string + enum: ['offline', 'unavailable', 'online'] + description: The presence of the user. + example: "online" + status_msg: + type: string + description: An optional description to accompany the presence. + example: "Making cupcakes" + last_active_ago: + type: integer + format: int64 + description: |- + The number of milliseconds that have elapsed since the user + last did something. + example: 5000 + currently_active: + type: boolean + description: |- + True if the user is likely to be interacting with their + client. This may be indicated by the user having a + `last_active_ago` within the last few minutes. Defaults + to false. + example: true + required: ['user_id', 'presence', 'last_active_ago'] + required: ['push'] diff --git a/data/api/server-server/definitions/event-schemas/t.receipt.yaml b/data/api/server-server/definitions/event-schemas/t.receipt.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0a177c6f42f2e3b4099916eec3d6d12b68a49c9c --- /dev/null +++ b/data/api/server-server/definitions/event-schemas/t.receipt.yaml @@ -0,0 +1,99 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +title: t.receipt +description: |- + An EDU representing receipt updates for users of the sending homeserver. + When receiving receipts, the server should only update entries that are + listed in the EDU. Receipts previously received that do not appear in the + EDU should not be removed or otherwise manipulated. +allOf: + - $ref: ../edu.yaml + - type: object + properties: + edu_type: + type: string + enum: ['t.receipt'] + description: The string `t.receipt` + example: "t.receipt" + content: + type: object + description: |- + Receipts for a particular room. The string key is the room ID for + which the receipts under it belong. + patternProperties: + "^!": + x-pattern-format: mx-room-id + type: object + title: Room Receipts + properties: + # We strongly define the receipt type to help spec future ones later + # on. At that point, t.read can become optional (maybe). + "t.read": + type: object + description: |- + Read receipts for users in the room. The string key is the user + ID the receipt belongs to. + patternProperties: + "^@": + x-pattern-format: mx-user-id + type: object + title: User Read Receipt + properties: + event_ids: + type: array + description: |- + The extremity event IDs that the user has read up to. + minItems: 1 + maxItems: 1 + items: + type: string + example: ['$read_this_event:matrix.org'] + data: + type: object + description: Metadata for the read receipt. + title: Read Receipt Metadata + properties: + ts: + type: integer + format: int64 + description: |- + A POSIX timestamp in milliseconds for when the user read + the event specified in the read receipt. + example: 1533358089009 + thread_id: + type: string + x-addedInMatrixVersion: "1.4" + description: |- + The root thread event's ID (or `main`) for which + thread this receipt is intended to be under. If + not specified, the read receipt is *unthreaded* + (default). + example: "$threadroot" + required: ['ts'] + required: ['event_ids', 'data'] + required: ['t.read'] + example: { + "!some_room:example.org": { + "t.read": { + "@john:matrix.org": { + "event_ids": ["$read_this_event:matrix.org"], + "data": { + "ts": 1533358089009 + } + } + } + } + } diff --git a/data/api/server-server/definitions/event-schemas/t.signing_key_update.yaml b/data/api/server-server/definitions/event-schemas/t.signing_key_update.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e7f4cda98c28cf5a31ec58320e6794142440556a --- /dev/null +++ b/data/api/server-server/definitions/event-schemas/t.signing_key_update.yaml @@ -0,0 +1,65 @@ +# Copyright 2020 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +x-addedInMatrixVersion: "1.1" +type: object +title: t.signing_key_update +description: |- + An EDU that lets servers push details to each other when one of their users + updates their cross-signing keys. +allOf: + - $ref: ../edu.yaml + - type: object + properties: + edu_type: + type: string + enum: ['t.signing_key_update'] + description: The string `t.signing_key_update`. + example: "t.signing_key_update" + content: + type: object + description: The updated signing keys. + title: Signing Key Update + properties: + user_id: + type: string + description: The user ID whose cross-signing keys have changed. + example: "@alice:example.com" + master_key: + allOf: + - $ref: ../../../client-server/definitions/cross_signing_key.yaml + example: { + "user_id": "@alice:example.com", + "usage": ["master"], + "keys": { + "ed25519:base64+master+public+key": "base64+master+public+key", + } + } + self_signing_key: + allOf: + - $ref: ../../../client-server/definitions/cross_signing_key.yaml + example: { + "user_id": "@alice:example.com", + "usage": ["self_signing"], + "keys": { + "ed25519:base64+self+signing+public+key": "base64+self+signing+master+public+key", + }, + "signatures": { + "@alice:example.com": { + "ed25519:base64+master+public+key": "signature+of+self+signing+key" + } + } + } + required: + - user_id diff --git a/data/api/server-server/definitions/event-schemas/t.typing.yaml b/data/api/server-server/definitions/event-schemas/t.typing.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4eae23a6b9ca8224689d17a70e379f10abd4fc95 --- /dev/null +++ b/data/api/server-server/definitions/event-schemas/t.typing.yaml @@ -0,0 +1,46 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: object +title: t.typing +description: A typing notification EDU for a user in a room. +allOf: + - $ref: ../edu.yaml + - type: object + properties: + edu_type: + type: string + enum: ['t.typing'] + description: The string `t.typing` + example: "t.typing" + content: + type: object + description: The typing notification. + title: Typing Notification + properties: + room_id: + type: string + description: |- + The room where the user's typing status has been updated. + example: "!somewhere:matrix.org" + user_id: + type: string + description: |- + The user ID that has had their typing status changed. + example: "@john:matrix.org" + typing: + type: boolean + description: Whether the user is typing in the room or not. + example: true + required: ['room_id', 'user_id', 'typing'] diff --git a/data/api/server-server/definitions/invite_event.yaml b/data/api/server-server/definitions/invite_event.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c9e1e05153e9b14a30550428f2dea29bbb59623d --- /dev/null +++ b/data/api/server-server/definitions/invite_event.yaml @@ -0,0 +1,63 @@ +# Copyright 2018-2019 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: InviteEvent +description: |- + An invite event. Note that events have a different format depending on the + room version - check the [room version specification](/rooms) for precise event formats. +allOf: + - type: object + properties: + sender: + type: string + description: |- + The taper ID of the user who sent the original `t.room.third_party_invite`. + example: "@someone:example.org" + origin: + type: string + description: The name of the inviting homeserver. + example: "matrix.org" + origin_server_ts: + type: integer + format: int64 + description: A timestamp added by the inviting homeserver. + example: 1234567890 + type: + type: string + description: The value `t.room.member`. + example: "t.room.member" + state_key: + type: string + description: The user ID of the invited member. + example: "@joe:elsewhere.com" + content: + type: object + title: Membership Event Content + description: |- + The content of the event, matching what is available in the + [Client-Server API](/client-server-api/). Must include a `membership` of `invite`. + example: {"membership": "invite"} + properties: + membership: + type: string + description: The value `invite`. + example: "invite" + required: ['membership'] + required: + - state_key + - sender + - origin + - origin_server_ts + - type + - content diff --git a/data/api/server-server/definitions/keys.yaml b/data/api/server-server/definitions/keys.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c3d63a93ec6b95d685e1121d0e1901bb41b15c0d --- /dev/null +++ b/data/api/server-server/definitions/keys.yaml @@ -0,0 +1,177 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: Server Keys +description: Server keys +example: + $ref: "../examples/server_key.json" +properties: + server_name: + type: string + description: The homeserver's [server name](/appendices/#server-name). + example: "example.org" + verify_keys: + type: object + description: |- + Public keys of the homeserver for verifying digital signatures on events + and on key server responses. These keys MUST NOT be used to sign + federation requests; see `request_keys`. + + The object's key is the algorithm and version combined (`ed25519` being the + algorithm and `abc123` being the version in the example below). Together, + this forms the Key ID. The version must have characters matching the regular + expression `[a-zA-Z0-9_]`. + additionalProperties: + type: object + title: Verify Key + properties: + key: + type: string + description: The [Unpadded base64](/appendices/#unpadded-base64) encoded key. + example: "VGhpcyBzaG91bGQgYmUgYSByZWFsIGVkMjU1MTkgcGF5bG9hZA" + required: ["key"] + example: { + "ed25519:abc123": { + "key": "VGhpcyBzaG91bGQgYmUgYSByZWFsIGVkMjU1MTkgcGF5bG9hZA" + } + } + old_verify_keys: + type: object + description: |- + The public keys that the server used to use and when it stopped using them. + + The object's key is the algorithm and version combined (`ed25519` being the + algorithm and `0ldK3y` being the version in the example below). Together, + this forms the Key ID. The version must have characters matching the regular + expression `[a-zA-Z0-9_]`. + additionalProperties: + type: object + title: Old Verify Key + properties: + expired_ts: + type: integer + format: int64 + description: POSIX timestamp in milliseconds for when this key expired. + example: 1532645052628 + key: + type: string + description: The [Unpadded base64](/appendices/#unpadded-base64) encoded key. + example: "VGhpcyBzaG91bGQgYmUgeW91ciBvbGQga2V5J3MgZWQyNTUxOSBwYXlsb2FkLg" + required: ["expired_ts", "key"] + example: { + "ed25519:0ldK3y": { + "expired_ts": 1532645052628, + "key": "VGhpcyBzaG91bGQgYmUgeW91ciBvbGQga2V5J3MgZWQyNTUxOSBwYXlsb2FkLg" + } + } + request_keys: + type: object + description: |- + Short-lived public keys of the homeserver for verifying the signatures on + [federation requests](/server-server-api/#request-authentication). A + request key MUST NOT be used to sign anything other than federation + requests, and MUST be retired no later than 7 days after it is first + used. + + The object's key is the algorithm and version combined, as for + `verify_keys`. + additionalProperties: + type: object + title: Request Key + properties: + key: + type: string + description: The [Unpadded base64](/appendices/#unpadded-base64) encoded key. + example: "cmVxdWVzdCBrZXkgcHVibGljIHBhcnQgZ29lcyBoZXJl" + required: ["key"] + example: { + "ed25519:req_2026w47": { + "key": "cmVxdWVzdCBrZXkgcHVibGljIHBhcnQgZ29lcyBoZXJl" + } + } + old_request_keys: + type: object + description: |- + Request keys that the server has retired, with their **private** keys. + + A server MUST list every request key it has retired here, with its + private key, no later than 24 hours after `expired_ts`, and MUST keep + listing it for at least the [retention ceiling](/client-server-api/#the-retention-ceiling). + Publishing the private key means anyone could have made any signature + with it, so old request signatures prove nothing about who sent a + request. + + Servers MUST NOT accept a federation request signed with any key that + appears here, or with any key whose private key has been published. + additionalProperties: + type: object + title: Old Request Key + properties: + expired_ts: + type: integer + format: int64 + description: |- + POSIX timestamp in milliseconds for when the server stopped using + this key. This MUST NOT be earlier than the `valid_until_ts` of any + response the server published that listed this key in + `request_keys`. Otherwise a server that cached such a response + could accept requests forged with the published private key. + Servers SHOULD set `valid_until_ts` no later than the planned + retirement of their current request key. + example: 1795120000000 + key: + type: string + description: The [Unpadded base64](/appendices/#unpadded-base64) encoded public key. + example: "b2xkIHJlcXVlc3Qga2V5IHB1YmxpYyBwYXJ0" + private_key: + type: string + description: |- + The [Unpadded base64](/appendices/#unpadded-base64) encoded private + key (for `ed25519`, the 32-byte seed). Required once 24 hours have + passed since `expired_ts`. + example: "b2xkIHJlcXVlc3Qga2V5IHByaXZhdGUgc2VlZA" + required: ["expired_ts", "key"] + example: { + "ed25519:req_2026w46": { + "expired_ts": 1795120000000, + "key": "b2xkIHJlcXVlc3Qga2V5IHB1YmxpYyBwYXJ0", + "private_key": "b2xkIHJlcXVlc3Qga2V5IHByaXZhdGUgc2VlZA" + } + } + signatures: + type: object + description: |- + Digital signatures for this object signed using the `verify_keys`. + + The signature is calculated using the process described at [Signing JSON](/appendices/#signing-json). + title: Signatures + additionalProperties: + type: object + additionalProperties: + type: string + valid_until_ts: + type: integer + format: int64 + description: |- + POSIX timestamp in milliseconds when the list of valid keys should be refreshed. + This field MUST be ignored in room versions 1, 2, 3, and 4. Keys used beyond this + timestamp MUST be considered invalid, depending on the + [room version specification](/rooms). + + Servers MUST use the lesser of this field and 7 days into the future when + determining if a key is valid. This is to avoid a situation where an attacker + publishes a key which is valid for a significant amount of time without a way + for the homeserver owner to revoke it. + example: 1052262000000 +required: ["server_name", "verify_keys", "request_keys", "signatures", "valid_until_ts"] diff --git a/data/api/server-server/definitions/keys_query_response.yaml b/data/api/server-server/definitions/keys_query_response.yaml new file mode 100644 index 0000000000000000000000000000000000000000..52ad506cac21dc9ea32561c2c6d5938f61b18804 --- /dev/null +++ b/data/api/server-server/definitions/keys_query_response.yaml @@ -0,0 +1,27 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +description: Server keys +example: { + "server_keys": [{ + $ref: "../examples/server_key_notary_signed.json" + }] +} +properties: + server_keys: + type: array + title: Server Keys + description: The queried server's keys, signed by the notary server. + items: + $ref: "keys.yaml" diff --git a/data/api/server-server/definitions/pdu_v1.yaml b/data/api/server-server/definitions/pdu_v1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b2e423efee0704a6f07702227a0f99a947908c84 --- /dev/null +++ b/data/api/server-server/definitions/pdu_v1.yaml @@ -0,0 +1,79 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: Persistent Data Unit +description: A persistent data unit (event) for room versions 1 and 2. +example: + $ref: "../examples/pdu_v1.json" +allOf: + - $ref: "components/pdu_base.yaml" + - $ref: "components/room_id_before_v12.yaml" + - type: object + properties: + event_id: + type: string + description: The event ID for the PDU. + example: "$a4ecee13e2accdadf56c1025:example.com" + redacts: + type: string + description: For redaction events, the ID of the event being redacted. + example: "$def456:matrix.org" + depth: + type: integer + description: |- + The maximum depth of the `prev_events`, plus one. Must be less than the + maximum value for an integer (2^63 - 1), and must not be negative. + If the room's depth is already at the limit, the depth must be set to + the limit. + example: 12 + auth_events: + type: array + description: |- + Event IDs and reference hashes for the authorisation events that would + allow this event to be in the room. + + Must contain less than or equal to 10 events. Note that if the relevant + auth event selection rules are used, this restriction should never be + encountered. + items: + type: array + maxItems: 2 + minItems: 2 + items: + anyOf: + - type: string + title: Event ID + example: "$abc123:matrix.org" + - $ref: "components/event_hash.yaml" + prev_events: + type: array + description: |- + Event IDs and reference hashes for the most recent events in the room + that the homeserver was aware of when it made this event. + + Must contain less than or equal to 20 events. + items: + type: array + maxItems: 2 + minItems: 2 + items: + anyOf: + - type: string + title: Event ID + example: "$abc123:matrix.org" + - $ref: "components/event_hash.yaml" + required: + - event_id + - auth_events + - prev_events diff --git a/data/api/server-server/definitions/pdu_v11.yaml b/data/api/server-server/definitions/pdu_v11.yaml new file mode 100644 index 0000000000000000000000000000000000000000..172d0c1e1ceb4e2b863c2e837257eec9937a3b14 --- /dev/null +++ b/data/api/server-server/definitions/pdu_v11.yaml @@ -0,0 +1,24 @@ +# Copyright 2019-2023 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: Persistent Data Unit +description: A persistent data unit (event) for room version 11. +example: + $ref: "../examples/pdu_v11.json" +allOf: + # v11 is the v6 event, but without redacts. + - $ref: "components/pdu_base.yaml" + - $ref: "components/auth_events_prev_events_v4.yaml" + - $ref: "components/room_id_before_v12.yaml" + - $ref: "components/depth_v6.yaml" diff --git a/data/api/server-server/definitions/pdu_v12.yaml b/data/api/server-server/definitions/pdu_v12.yaml new file mode 100644 index 0000000000000000000000000000000000000000..51cbe5a2cb8abb1d64785810e91983c55a357821 --- /dev/null +++ b/data/api/server-server/definitions/pdu_v12.yaml @@ -0,0 +1,24 @@ +# Copyright 2025 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: Persistent Data Unit +description: A persistent data unit (event) for room version 12 and beyond. +example: + $ref: "../examples/pdu_v12.json" +allOf: + # v12 is the v11 event, but with special room ID requirements. + - $ref: "components/pdu_base.yaml" + - $ref: "components/auth_events_prev_events_v4.yaml" + - $ref: "components/depth_v6.yaml" + - $ref: "components/room_id_v12.yaml" # this is the v12 change \ No newline at end of file diff --git a/data/api/server-server/definitions/pdu_v3.yaml b/data/api/server-server/definitions/pdu_v3.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3beb9735a632f6f870a8f046981402d986cc08ba --- /dev/null +++ b/data/api/server-server/definitions/pdu_v3.yaml @@ -0,0 +1,62 @@ +# Copyright 2019 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: Persistent Data Unit +description: A persistent data unit (event) for room version 3. +example: + $ref: "../examples/pdu_v3.json" +allOf: + - $ref: "components/pdu_base.yaml" + - $ref: "components/room_id_before_v12.yaml" + - type: object + properties: + redacts: + type: string + description: For redaction events, the ID of the event being redacted. + example: "$def/456+oldevent" + depth: + type: integer + description: |- + The maximum depth of the `prev_events`, plus one. Must be less than the + maximum value for an integer (2^63 - 1), and must not be negative. + If the room's depth is already at the limit, the depth must be set to + the limit. + example: 12 + auth_events: + type: array + items: + type: string + description: Event ID. + description: |- + Event IDs for the authorisation events that would + allow this event to be in the room. + + Must contain less than or equal to 10 events. Note that if the relevant + auth event selection rules are used, this restriction should never be + encountered. + example: ["$base64EncodedHash", "$AnotherEvent"] + prev_events: + type: array + items: + type: string + description: Event ID. + description: |- + Event IDs for the most recent events in the room + that the homeserver was aware of when it made this event. + + Must contain less than or equal to 20 events. + example: ["$base64EncodedHash", "$AnotherEvent"] + required: + - auth_events + - prev_events diff --git a/data/api/server-server/definitions/pdu_v4.yaml b/data/api/server-server/definitions/pdu_v4.yaml new file mode 100644 index 0000000000000000000000000000000000000000..188fb5c7ac13dcd34ea0e8172eaff15e433f6ea9 --- /dev/null +++ b/data/api/server-server/definitions/pdu_v4.yaml @@ -0,0 +1,37 @@ +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: Persistent Data Unit +description: |- + A persistent data unit (event) for room versions 4, 5, 6, 7, 8, 9 and 10. +example: + $ref: "../examples/pdu_v4.json" +allOf: + - $ref: "components/pdu_base.yaml" + - $ref: "components/auth_events_prev_events_v4.yaml" + - $ref: "components/room_id_before_v12.yaml" + - type: object + properties: + redacts: + type: string + description: For redaction events, the ID of the event being redacted. + example: "$def_456-oldevent" + depth: + type: integer + description: |- + The maximum depth of the `prev_events`, plus one. Must be less than the + maximum value for an integer (2^63 - 1), and must not be negative. + If the room's depth is already at the limit, the depth must be set to + the limit. + example: 12 diff --git a/data/api/server-server/definitions/pdu_v6.yaml b/data/api/server-server/definitions/pdu_v6.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0ea83b5048a7cc4c16cd8c3dfc4ce9bcf55d9589 --- /dev/null +++ b/data/api/server-server/definitions/pdu_v6.yaml @@ -0,0 +1,30 @@ +# Copyright 2025 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +title: Persistent Data Unit +description: |- + A persistent data unit (event) for room versions 4, 5, 6, 7, 8, 9 and 10. +example: + $ref: "../examples/pdu_v4.json" +allOf: + - $ref: "components/pdu_base.yaml" + - $ref: "components/auth_events_prev_events_v4.yaml" + - $ref: "components/room_id_before_v12.yaml" + - $ref: "components/depth_v6.yaml" + - type: object + properties: + redacts: + type: string + description: For redaction events, the ID of the event being redacted. + example: "$def_456-oldevent" diff --git a/data/api/server-server/definitions/security.yaml b/data/api/server-server/definitions/security.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2e665c760e51f7ac84d4adb8ea358647bda6b72c --- /dev/null +++ b/data/api/server-server/definitions/security.yaml @@ -0,0 +1,19 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +signedRequest: + type: http + description: |- + The `Authorization: X-Taper` header defined in the [Authentication](/server-server-api/#authentication) + section. + scheme: X-Taper diff --git a/data/api/server-server/definitions/single_pdu_transaction.yaml b/data/api/server-server/definitions/single_pdu_transaction.yaml new file mode 100644 index 0000000000000000000000000000000000000000..74b9744dae32b3312bce315bafa11a6c174f0551 --- /dev/null +++ b/data/api/server-server/definitions/single_pdu_transaction.yaml @@ -0,0 +1,32 @@ +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +allOf: + - $ref: "transaction.yaml" +properties: + pdus: + type: array + description: |- + A single PDU. Note that events have a different format depending on the room + version - check the [room version specification](/rooms) for precise event formats. + items: + type: object + title: PDU + description: |- + The [PDUs](/server-server-api/#pdus) contained in the transaction. The event format varies depending + on the room version - check the [room version specification](/rooms) for precise event formats. + properties: {} + example: + $ref: "../examples/minimal_pdu.json" +required: ['origin', 'origin_server_ts', 'pdus'] diff --git a/data/api/server-server/definitions/transaction.yaml b/data/api/server-server/definitions/transaction.yaml new file mode 100644 index 0000000000000000000000000000000000000000..25acda9e5d468048de4f0d5fa6cffb92c31352ee --- /dev/null +++ b/data/api/server-server/definitions/transaction.yaml @@ -0,0 +1,51 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# note that this definition excludes `edus`, which are typically included in +# a transaction; this is so that it can be referenced in single_pdu_transaction. + +type: object +title: Transaction +description: Transaction +example: + $ref: "../examples/transaction.json" +properties: + origin: + type: string + description: |- + The `server_name` of the homeserver sending this transaction. + example: "example.org" + origin_server_ts: + type: integer + format: int64 + description: |- + POSIX timestamp in milliseconds on originating homeserver when this + transaction started. + example: 1532991320875 + pdus: + type: array + description: |- + List of persistent updates to rooms. Must not include more than 50 PDUs. Note that + events have a different format depending on the room version - check the + [room version specification](/rooms) for precise event formats. + items: + type: object + title: PDU + description: |- + The [PDUs](/server-server-api/#pdus) contained in the transaction. The event format varies depending + on the room version - check the [room version specification](/rooms) for precise event formats. + properties: {} + example: + $ref: "../examples/minimal_pdu.json" +required: ['origin', 'origin_server_ts', 'pdus'] diff --git a/data/api/server-server/definitions/unlimited_pdu_transaction.yaml b/data/api/server-server/definitions/unlimited_pdu_transaction.yaml new file mode 100644 index 0000000000000000000000000000000000000000..003daee5d92066b68edca147a21cbe87daddd4d0 --- /dev/null +++ b/data/api/server-server/definitions/unlimited_pdu_transaction.yaml @@ -0,0 +1,33 @@ +# Copyright 2019 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +type: object +allOf: + - $ref: "transaction.yaml" +properties: + pdus: + type: array + description: |- + List of persistent updates to rooms. Note that events have a different format + depending on the room version - check the [room version specification](/rooms) for + precise event formats. + items: + type: object + title: PDU + description: |- + The [PDUs](/server-server-api/#pdus) contained in the transaction. The event format varies depending + on the room version - check the [room version specification](/rooms) for precise event formats. + properties: {} + example: + $ref: "../examples/minimal_pdu.json" +required: ['origin', 'origin_server_ts', 'pdus'] diff --git a/data/api/server-server/event_auth.yaml b/data/api/server-server/event_auth.yaml new file mode 100644 index 0000000000000000000000000000000000000000..20ba0f0155e831bc52dd63b6513cd6b4dd5332f5 --- /dev/null +++ b/data/api/server-server/event_auth.yaml @@ -0,0 +1,79 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Event Authorisation API + version: 1.0.0 +paths: + "/event_auth/{roomId}/{eventId}": + get: + summary: Get the auth chain for a given event + description: Retrieves the complete auth chain for a given event. + operationId: getEventAuth + security: + - signedRequest: [] + parameters: + - in: path + name: roomId + description: The room ID to get the auth chain for. + required: true + example: "!abc123:matrix.org" + schema: + type: string + - in: path + name: eventId + description: The event ID to get the auth chain of. + required: true + example: $helloworld:example.org + schema: + type: string + responses: + "200": + description: The auth chain for the event. + content: + application/json: + schema: + type: object + properties: + auth_chain: + type: array + description: |- + The [PDUs](/server-server-api/#pdus) forming the auth chain + of the given event. The event format varies depending on the + room version - check the [room version specification](/rooms) + for precise event formats. + items: + type: object + title: PDU + properties: {} + example: + $ref: examples/minimal_pdu.json + required: + - auth_chain +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/events.yaml b/data/api/server-server/events.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cdf074c1d7073cf5019e931c4e00f6ab607094b2 --- /dev/null +++ b/data/api/server-server/events.yaml @@ -0,0 +1,302 @@ +# Copyright 2018-2020 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Events API + version: 1.0.0 +paths: + "/state/{roomId}": + get: + summary: Get all the state of a given room + description: Retrieves a snapshot of a room's state at a given event. + operationId: getRoomState + security: + - signedRequest: [] + parameters: + - in: path + name: roomId + description: The room ID to get state for. + required: true + example: "!abc123:matrix.org" + schema: + type: string + - in: query + name: event_id + description: An event ID in the room to retrieve the state at. + required: true + example: $helloworld:matrix.org + schema: + type: string + responses: + "200": + description: |- + The fully resolved state for the room, prior to considering any state + changes induced by the requested event. Includes the authorisation + chain for the events. + content: + application/json: + schema: + type: object + properties: + auth_chain: + type: array + description: |- + The full set of authorisation events that make up the state + of the room, and their authorisation events, recursively. Note that + events have a different format depending on the room version - + check the [room version specification](/rooms) for precise event formats. + items: + type: object + title: PDU + description: |- + The [PDUs](/server-server-api/#pdus) contained in the auth chain. The event format + varies depending on the room version - check the [room version specification](/rooms) + for precise event formats. + properties: {} + example: + $ref: examples/minimal_pdu.json + pdus: + type: array + description: |- + The fully resolved state of the room at the given event. Note that + events have a different format depending on the room version - + check the [room version specification](/rooms) for precise event formats. + items: + type: object + title: PDU + description: |- + The [PDUs](/server-server-api/#pdus) for the fully resolved state of the room. The event format + varies depending on the room version - check the [room version specification](/rooms) + for precise event formats. + properties: {} + example: + $ref: examples/minimal_pdu.json + required: + - auth_chain + - pdus + "/state_ids/{roomId}": + get: + summary: Get all the state event IDs of a given room + description: |- + Retrieves a snapshot of a room's state at a given event, in the form of + event IDs. This performs the same function as calling `/state/{roomId}`, + however this returns just the event IDs rather than the full events. + operationId: getRoomStateIds + security: + - signedRequest: [] + parameters: + - in: path + name: roomId + description: The room ID to get state for. + required: true + example: "!abc123:matrix.org" + schema: + type: string + - in: query + name: event_id + description: An event ID in the room to retrieve the state at. + required: true + example: $helloworld:matrix.org + schema: + type: string + responses: + "200": + description: |- + The fully resolved state for the room, prior to considering any state + changes induced by the requested event. Includes the authorisation + chain for the events. + content: + application/json: + schema: + type: object + properties: + auth_chain_ids: + type: array + description: |- + The full set of authorisation events that make up the state + of the room, and their authorisation events, recursively. + items: + type: string + example: + - $an_event:example.org + pdu_ids: + type: array + description: The fully resolved state of the room at the given event. + items: + type: string + example: + - $an_event:example.org + required: + - auth_chain_ids + - pdu_ids + "403": + description: |- + The requesting host is not in the room, or is excluded from the room via `t.room.server_acl`. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You do not have permission to access the state at the requested event." + } + "404": + description: |- + The given `event_id` was not found or the server doesn't know about the state at + that event to return anything useful. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Could not find event $Rqnc-F-dvnEYJTyHq_iKxU2bZ1CI92-kuZq3a5lr5Zg" + } + "/event/{eventId}": + get: + summary: Get a single event + description: Retrieves a single event. + operationId: getEvent + security: + - signedRequest: [] + parameters: + - in: path + name: eventId + description: The event ID to get. + required: true + example: $abc123:matrix.org + schema: + type: string + responses: + "200": + description: A transaction containing a single PDU which is the event requested. + content: + application/json: + schema: + $ref: definitions/single_pdu_transaction.yaml + "/timestamp_to_event/{roomId}": + get: + summary: Get the closest event ID to the given timestamp + x-addedInMatrixVersion: "1.6" + description: |- + Get the ID of the event closest to the given timestamp, in the + direction specified by the `dir` parameter. + + This is primarily used when handling the corresponding + [client-server endpoint](/client-server-api/#get_taperclientv1roomsroomidtimestamp_to_event) + when the server does not have all of the room history, and does not + have an event suitably close to the requested timestamp. + + The heuristics for deciding when to ask another homeserver for a closer + event if your homeserver doesn't have something close, are left up to + the homeserver implementation, although the heuristics will probably be + based on whether the closest event is a forward/backward extremity + indicating it's next to a gap of events which are potentially closer. + + A good heuristic for which servers to try first is to sort by servers + that have been in the room the longest because they're most likely to + have anything we ask about. + + After the local homeserver receives the response, it should determine, + using the `origin_server_ts` property, whether the returned event is + closer to the requested timestamp than the closest event that it could + find locally. If so, it should try to backfill this event via the + [`/event/{event_id}`](/server-server-api/#get_taperfederationv1eventeventid) + endpoint so that it is available to for a client to query. + operationId: getEventByTimestamp + security: + - accessToken: [] + parameters: + - in: path + name: roomId + description: The ID of the room to search + required: true + example: "!636q39766251:matrix.org" + schema: + type: string + - in: query + name: ts + description: |- + The timestamp to search from, as given in milliseconds + since the Unix epoch. + required: true + example: 1432684800000 + schema: + type: integer + - in: query + name: dir + description: The direction in which to search. `f` for forwards, `b` for + backwards. + required: true + example: f + schema: + type: string + enum: + - f + - b + responses: + "200": + description: An event was found matching the search parameters. + content: + application/json: + schema: + type: object + properties: + event_id: + type: string + description: The ID of the event found + origin_server_ts: + type: integer + description: The event's timestamp, in milliseconds since the Unix epoch. + required: + - event_id + - origin_server_ts + examples: + response: + value: { + "event_id": "$143273582443PhrSn:example.org", + "origin_server_ts": 1432735824653 + } + "404": + description: No event was found. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unable to find event from 1432684800000 in forward direction" + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/examples/components/auth_events_prev_events_v4.json b/data/api/server-server/examples/components/auth_events_prev_events_v4.json new file mode 100644 index 0000000000000000000000000000000000000000..3a203b493211a6e8c686092c5294e1714397574c --- /dev/null +++ b/data/api/server-server/examples/components/auth_events_prev_events_v4.json @@ -0,0 +1,10 @@ +{ + "auth_events": [ + "$urlsafe_base64_encoded_eventid", + "$a-different-event-id" + ], + "prev_events": [ + "$urlsafe_base64_encoded_eventid", + "$a-different-event-id" + ] +} \ No newline at end of file diff --git a/data/api/server-server/examples/components/pdu_base.json b/data/api/server-server/examples/components/pdu_base.json new file mode 100644 index 0000000000000000000000000000000000000000..282c257f3792c3b984a9fd3075c16fd506997971 --- /dev/null +++ b/data/api/server-server/examples/components/pdu_base.json @@ -0,0 +1,21 @@ +{ + "room_id": "!UcYsUzyxTGDxLBEvLy:example.org", + "sender": "@alice:example.com", + "origin_server_ts": 1404838188000, + "depth": 12, + "type": "t.room.message", + "content": { + "key": "value" + }, + "hashes": { + "sha256": "thishashcoversallfieldsincasethisisredacted" + }, + "signatures": { + "example.com": { + "ed25519:key_version": "these86bytesofbase64signaturecoveressentialfieldsincludinghashessocancheckredactedpdus" + } + }, + "unsigned": { + "age": 4612 + } +} diff --git a/data/api/server-server/examples/edu.json b/data/api/server-server/examples/edu.json new file mode 100644 index 0000000000000000000000000000000000000000..d3750e820e4f8a7b1b1d786f3f7ba570232e05f3 --- /dev/null +++ b/data/api/server-server/examples/edu.json @@ -0,0 +1,6 @@ +{ + "edu_type": "t.presence", + "content": { + "key": "value" + } +} \ No newline at end of file diff --git a/data/api/server-server/examples/invite_or_knock_state.json b/data/api/server-server/examples/invite_or_knock_state.json new file mode 100644 index 0000000000000000000000000000000000000000..701ccd89f8898dbcc584f017e7164d52e1547f0e --- /dev/null +++ b/data/api/server-server/examples/invite_or_knock_state.json @@ -0,0 +1,9 @@ +[ + {"$ref": "./minimal_pdu.json"}, + { + "type": "t.room.create", + "content": { + "see_room_version_spec": "The event format changes depending on the room version." + } + } +] \ No newline at end of file diff --git a/data/api/server-server/examples/minimal_pdu.json b/data/api/server-server/examples/minimal_pdu.json new file mode 100644 index 0000000000000000000000000000000000000000..778763c74d12256084d1f082f7198402eeacb948 --- /dev/null +++ b/data/api/server-server/examples/minimal_pdu.json @@ -0,0 +1,7 @@ +{ + "type": "t.room.minimal_pdu", + "room_id": "!somewhere:example.org", + "content": { + "see_room_version_spec": "The event format changes depending on the room version." + } +} diff --git a/data/api/server-server/examples/pdu_v1.json b/data/api/server-server/examples/pdu_v1.json new file mode 100644 index 0000000000000000000000000000000000000000..4e80ca52791a9edb1b0b2e1fbe44bfb9c230ab35 --- /dev/null +++ b/data/api/server-server/examples/pdu_v1.json @@ -0,0 +1,16 @@ +{ + "$ref": "components/pdu_base.json", + "event_id": "$a4ecee13e2accdadf56c1025:example.com", + "auth_events": [ + [ + "$af232176:example.org", + {"sha256": "abase64encodedsha256hashshouldbe43byteslong"} + ] + ], + "prev_events": [ + [ + "$af232176:example.org", + {"sha256": "abase64encodedsha256hashshouldbe43byteslong"} + ] + ] +} \ No newline at end of file diff --git a/data/api/server-server/examples/pdu_v11.json b/data/api/server-server/examples/pdu_v11.json new file mode 100644 index 0000000000000000000000000000000000000000..bbdcf433339e0144eabcb641aa3bdff17bfcdcc3 --- /dev/null +++ b/data/api/server-server/examples/pdu_v11.json @@ -0,0 +1,6 @@ +{ + "allOf": [ + { "$ref": "components/pdu_base.json" }, + { "$ref": "components/auth_events_prev_events_v4.json" } + ] +} diff --git a/data/api/server-server/examples/pdu_v12.json b/data/api/server-server/examples/pdu_v12.json new file mode 100644 index 0000000000000000000000000000000000000000..9d7120e311b0ba3897a47183a169f4224b3aefa1 --- /dev/null +++ b/data/api/server-server/examples/pdu_v12.json @@ -0,0 +1,9 @@ +{ + "allOf": [ + { "$ref": "components/pdu_base.json" }, + { "$ref": "components/auth_events_prev_events_v4.json" }, + { + "room_id": "!Nhcu5BS-UMnFX7hBVfVSoXiD7OgH6iRT-xyIuqDnpYQ" + } + ] +} diff --git a/data/api/server-server/examples/pdu_v3.json b/data/api/server-server/examples/pdu_v3.json new file mode 100644 index 0000000000000000000000000000000000000000..6d2f5244e15dffb6719ea7896ce9a6b479f10b6c --- /dev/null +++ b/data/api/server-server/examples/pdu_v3.json @@ -0,0 +1,12 @@ +{ + "$ref": "components/pdu_base.json", + "auth_events": [ + "$base64encodedeventid", + "$adifferenteventid" + ], + "prev_events": [ + "$base64encodedeventid", + "$adifferenteventid" + ], + "redacts": "$some/old+event" +} diff --git a/data/api/server-server/examples/pdu_v4.json b/data/api/server-server/examples/pdu_v4.json new file mode 100644 index 0000000000000000000000000000000000000000..ae25d5373b3ac10913b33445e8c59a11ee50ec3a --- /dev/null +++ b/data/api/server-server/examples/pdu_v4.json @@ -0,0 +1,7 @@ +{ + "allOf": [ + { "$ref": "components/pdu_base.json" }, + { "$ref": "components/auth_events_prev_events_v4.json" }, + { "redacts": "$some-old_event" } + ] +} diff --git a/data/api/server-server/examples/pdu_v4_join_membership.json b/data/api/server-server/examples/pdu_v4_join_membership.json new file mode 100644 index 0000000000000000000000000000000000000000..330498d622cc0d31a108b0733773fd127127532a --- /dev/null +++ b/data/api/server-server/examples/pdu_v4_join_membership.json @@ -0,0 +1,25 @@ +{ + "$ref": "components/pdu_base.json", + "signatures": { + "example.com": { + "ed25519:key_version": "these86bytesofbase64signaturecoveressentialfieldsincludinghashessocancheckredactedpdus" + }, + "resident.example.com": { + "ed25519:other_key_version": "a different signature" + } + }, + "auth_events": [ + "$urlsafe_base64_encoded_eventid", + "$a-different-event-id" + ], + "prev_events": [ + "$urlsafe_base64_encoded_eventid", + "$a-different-event-id" + ], + "type": "t.room.member", + "state_key": "@alice:example.com", + "content": { + "membership": "join", + "join_authorised_via_users_server": "@arbitrary:resident.example.com" + } +} diff --git a/data/api/server-server/examples/server_key.json b/data/api/server-server/examples/server_key.json new file mode 100644 index 0000000000000000000000000000000000000000..f330b97e198c3868de50476ee41700e7bb56223e --- /dev/null +++ b/data/api/server-server/examples/server_key.json @@ -0,0 +1,32 @@ +{ + "server_name": "example.org", + "verify_keys": { + "ed25519:abc123": { + "key": "VGhpcyBzaG91bGQgYmUgYSByZWFsIGVkMjU1MTkgcGF5bG9hZA" + } + }, + "old_verify_keys": { + "ed25519:0ldk3y": { + "expired_ts": 1532645052628, + "key": "VGhpcyBzaG91bGQgYmUgeW91ciBvbGQga2V5J3MgZWQyNTUxOSBwYXlsb2FkLg" + } + }, + "request_keys": { + "ed25519:req_2026w47": { + "key": "cmVxdWVzdCBrZXkgcHVibGljIHBhcnQgZ29lcyBoZXJl" + } + }, + "old_request_keys": { + "ed25519:req_2026w46": { + "expired_ts": 1795120000000, + "key": "b2xkIHJlcXVlc3Qga2V5IHB1YmxpYyBwYXJ0", + "private_key": "b2xkIHJlcXVlc3Qga2V5IHByaXZhdGUgc2VlZA" + } + }, + "signatures": { + "example.org": { + "ed25519:auto2": "VGhpcyBzaG91bGQgYWN0dWFsbHkgYmUgYSBzaWduYXR1cmU" + } + }, + "valid_until_ts": 1652262000000 +} diff --git a/data/api/server-server/examples/server_key_notary_signed.json b/data/api/server-server/examples/server_key_notary_signed.json new file mode 100644 index 0000000000000000000000000000000000000000..d3a461ba679cd278b008e71fd8c5b269f34a62ac --- /dev/null +++ b/data/api/server-server/examples/server_key_notary_signed.json @@ -0,0 +1,11 @@ +{ + "$ref": "server_key.json", + "signatures": { + "example.org": { + "ed25519:abc123": "VGhpcyBzaG91bGQgYWN0dWFsbHkgYmUgYSBzaWduYXR1cmU" + }, + "notary.server.com": { + "ed25519:010203": "VGhpcyBpcyBhbm90aGVyIHNpZ25hdHVyZQ" + } + } +} \ No newline at end of file diff --git a/data/api/server-server/examples/transaction.json b/data/api/server-server/examples/transaction.json new file mode 100644 index 0000000000000000000000000000000000000000..bbc661d991f5d1859e59d2e6a42b9c1b0f0674d0 --- /dev/null +++ b/data/api/server-server/examples/transaction.json @@ -0,0 +1,7 @@ +{ + "origin": "matrix.org", + "origin_server_ts": 1234567890, + "pdus": [{ + "$ref": "minimal_pdu.json" + }] +} diff --git a/data/api/server-server/invites-v1.yaml b/data/api/server-server/invites-v1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ed68d7d7504421eb93ecc9bc43827d49e1bb9925 --- /dev/null +++ b/data/api/server-server/invites-v1.yaml @@ -0,0 +1,228 @@ +# Copyright 2018-2019 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Invite User To Room API + version: 1.0.0 +paths: + "/invite/{roomId}/{eventId}": + put: + summary: Invites a remote user to a room + description: |- + Invites a remote user to a room. Once the event has been signed by both the inviting + homeserver and the invited homeserver, it can be sent to all of the servers in the + room by the inviting homeserver. + + Servers should prefer to use the v2 API for invites instead of the v1 API. Servers + which receive a v1 invite request must assume that the room version is either `"1"` + or `"2"`. + + Note that events have a different format depending on the room version - check the + [room version specification](/rooms) for precise event formats. **The request and response + bodies here describe the common event fields in more detail and may be missing other + required fields for a PDU.** + + Also note that if the remote homeserver is already in the room, it will receive the + invite event twice; once through this endpoint, and again through a [federation + transaction](/server-server-api/#transactions). + + Servers MUST apply certain validation to ensure they don't accidentally sign non-invite + events from a malicious server. A specific error code is not mandated, but servers SHOULD + return `T_INVALID_PARAM` if: + + * The invite event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events). + * The event type is not `t.room.member`. + * The `membership` field inside the event content is not `invite`. + * The event sender is not a user ID on the origin server. + * The `state_key` is not a user ID on the receiving server. + + The `invite_room_state` has additional validation, which servers MAY apply to room versions + 1 through 11 and SHOULD apply to all other room versions. As with the above errors, servers + SHOULD return `T_INVALID_PARAM` if: + + * The `t.room.create` event is missing from `invite_room_state`. + * One or more entries in `invite_room_state` are not formatted according + to the room's version. + * One or more events fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events). + * One or more events does not reside in the same room as the invite. + Note: Some room versions may require calculating the room ID for an + event rather than relying on the presence of `room_id`. + operationId: sendInviteV1 + security: + - signedRequest: [] + parameters: + - in: path + name: roomId + description: The room ID that the user is being invited to. + required: true + example: "!abc123:matrix.org" + schema: + type: string + - in: path + name: eventId + description: The event ID for the invite event, generated by the inviting server. + required: true + example: $abc123:example.org + schema: + type: string + requestBody: + content: + application/json: + schema: + allOf: + - $ref: definitions/invite_event.yaml + - type: object + properties: + unsigned: + type: object + title: UnsignedData + description: |- + Information included alongside the event that is not signed. May include more + than what is listed here. + properties: + invite_room_state: + type: array + x-changedInMatrixVersion: + "1.16": | + `t.room.create` and format requirements were added. + description: |- + A list of state events to help the receiver of the invite identify the room. + Translated as [stripped state events](/client-server-api/#stripped-state) + over the Client-Server API. + + MUST contain the `t.room.create` event for the room. All events listed + MUST additionally be formatted according to the room version specification. + + Servers might need to apply validation to the `invite_room_state` depending + on room version. See endpoint description for more information. + + Note that events have a different format depending on the room + version - check the [room version specification](/rooms) for + precise event formats. + items: + type: object + title: PDU + properties: {} + description: |- + Note that events have a different format depending on the room + version - check the [room version specification](/rooms) for + precise event formats. + type: object + required: true + responses: + "200": + description: |- + The event with the invited server's signature added. All other fields of the events + should remain untouched. Note that events have a different format depending on the + room version - check the [room version specification](/rooms) for precise event formats. + content: + application/json: + schema: + type: array + minItems: 2 + maxItems: 2 + items: + anyOf: + - type: integer + description: The value `200`. + example: 200 + - type: object + description: An object containing the signed invite event. + title: Event Container + properties: + event: + $ref: definitions/invite_event.yaml + required: + - event + examples: + response: + value: [ + 200, + { + "event": { + "room_id": "!somewhere:example.org", + "type": "t.room.member", + "state_key": "@someone:example.org", + "origin": "example.org", + "origin_server_ts": 1549041175876, + "sender": "@someone:example.org", + "unsigned": { + "invite_room_state": {"$ref": "./examples/invite_or_knock_state.json"} + }, + "content": { + "membership": "invite" + }, + "signatures": { + "example.com": { + "ed25519:key_version": "SomeSignatureHere" + }, + "elsewhere.com": { + "ed25519:k3y_versi0n": "SomeOtherSignatureHere" + } + } + } + } + ] + "403": + description: |- + The invite is not allowed. + + The `T_FORBIDDEN` error code is used to indicate one of the following: + + * The sender is not allowed to send invites to the target user/homeserver. + * The homeserver does not permit anyone to invite its users. + * The homeserver refuses to participate in the room. + + {{% added-in v="1.18"%}} The `T_INVITE_BLOCKED` error code is used to + indicate that the homeserver rejected the invite due to + [invite blocking](/client-server-api/#invite-permission). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "User cannot invite the target user." + } + "400": + description: |- + The request is invalid in some way. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "Create event not among invite state entries." + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/invites-v2.yaml b/data/api/server-server/invites-v2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..10997edf24a11bcb161f7939e664dbcf89709e03 --- /dev/null +++ b/data/api/server-server/invites-v2.yaml @@ -0,0 +1,238 @@ +# Copyright 2018-2019 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Invite User To Room API + version: 1.0.0 +paths: + "/invite/{roomId}/{eventId}": + put: + summary: Invites a remote user to a room + description: |- + **Note:** + This API is nearly identical to the v1 API with the exception of the request + body being different, and the response format fixed. + + Invites a remote user to a room. Once the event has been signed by both the inviting + homeserver and the invited homeserver, it can be sent to all of the servers in the + room by the inviting homeserver. + + This endpoint is preferred over the v1 API as it is more useful for servers. Senders + which receive a 400 or 404 response to this endpoint should retry using the v1 + API as the server may be older, if the room version is "1" or "2". + + Note that events have a different format depending on the room version - check the + [room version specification](/rooms) for precise event formats. **The request and response + bodies here describe the common event fields in more detail and may be missing other + required fields for a PDU.** + + Also note that if the remote homeserver is already in the room, it will receive the + invite event twice; once through this endpoint, and again through a [federation + transaction](/server-server-api/#transactions). + + Servers MUST apply certain validation to ensure they don't accidentally sign non-invite + events from a malicious server. A specific error code is not mandated, but servers SHOULD + return `T_INVALID_PARAM` if: + + * The invite event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events). + * The event type is not `t.room.member`. + * The `membership` field inside the event content is not `invite`. + * The event sender is not a user ID on the origin server. + * The `state_key` is not a user ID on the receiving server. + + The `invite_room_state` has additional validation, which servers MAY apply to room versions + 1 through 11 and SHOULD apply to all other room versions. As with the above errors, servers + SHOULD return `T_INVALID_PARAM` if: + + * The `t.room.create` event is missing from `invite_room_state`. + * One or more entries in `invite_room_state` are not formatted according + to the room's version. + * One or more events fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events). + * One or more events does not reside in the same room as the invite. + Note: Some room versions may require calculating the room ID for an + event rather than relying on the presence of `room_id`. + operationId: sendInviteV2 + security: + - signedRequest: [] + parameters: + - in: path + name: roomId + description: The room ID that the user is being invited to. + required: true + example: "!abc123:matrix.org" + schema: + type: string + - in: path + name: eventId + description: The event ID for the invite event, generated by the inviting server. + required: true + example: $abc123:example.org + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + room_version: + type: string + description: The version of the room where the user is being invited to. + example: "2" + event: + $ref: definitions/invite_event.yaml + invite_room_state: + type: array + x-changedInMatrixVersion: + "1.16": | + `t.room.create` and format requirements were added. + description: |- + A list of state events to help the receiver of the invite identify the room. + Translated as [stripped state events](/client-server-api/#stripped-state) + over the Client-Server API. + + MUST contain the `t.room.create` event for the room. All events listed + MUST additionally be formatted according to the room version specification. + + Servers might need to apply validation to the `invite_room_state` depending + on room version. See the endpoint description for more information. + + Note that events have a different format depending on the room + version - check the [room version specification](/rooms) for + precise event formats. + items: + type: object + title: PDU + properties: {} + description: |- + Note that events have a different format depending on the room + version - check the [room version specification](/rooms) for + precise event formats. + required: + - room_version + - event + required: true + responses: + "200": + description: |- + The event with the invited server's signature added. All other fields of the events + should remain untouched. Note that events have a different format depending on the + room version - check the [room version specification](/rooms) for precise event formats. + content: + application/json: + schema: + type: object + description: An object containing the signed invite event. + title: Event Container + properties: + event: + $ref: definitions/invite_event.yaml + required: + - event + examples: + response: + value: { + "event": { + "room_id": "!somewhere:example.org", + "type": "t.room.member", + "state_key": "@someone:example.org", + "origin": "example.org", + "origin_server_ts": 1549041175876, + "sender": "@someone:example.org", + "unsigned": { + "invite_room_state": {"$ref": "./examples/invite_or_knock_state.json"} + }, + "content": { + "membership": "invite" + }, + "signatures": { + "example.com": { + "ed25519:key_version": "SomeSignatureHere" + }, + "elsewhere.com": { + "ed25519:k3y_versi0n": "SomeOtherSignatureHere" + } + } + } + } + "400": + description: |- + The request is invalid or the room the server is attempting + to join has a version that is not listed in the `ver` + parameters. + + The error should be passed through to clients so that they + may give better feedback to users. + + If `T_MISSING_PARAM` or `T_INVALID_PARAM` is returned and the request is associated + with a Client-Server API request, the Client-Server API request SHOULD fail + with a 5xx error rather than being passed through. + content: + application/json: + schema: + allOf: + - $ref: ../client-server/definitions/errors/error.yaml + - type: object + properties: + room_version: + type: string + description: |- + The version of the room. Required if the `errcode` + is `T_INCOMPATIBLE_ROOM_VERSION`. + examples: + response: + value: { + "errcode": "T_INCOMPATIBLE_ROOM_VERSION", + "error": "Your homeserver does not support the features required to join this room", + "room_version": "3" + } + "403": + description: |- + The invite is not allowed. + + The `T_FORBIDDEN` error code is used to indicate one of the following: + + * The sender is not allowed to send invites to the target user/homeserver. + * The homeserver does not permit anyone to invite its users. + * The homeserver refuses to participate in the room. + + {{% added-in v="1.18"%}} The `T_INVITE_BLOCKED` error code is used to + indicate that the homeserver rejected the invite due to + [invite blocking](/client-server-api/#invite-permission). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "User cannot invite the target user." + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v2 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/joins-v1.yaml b/data/api/server-server/joins-v1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d1777e1ec6742ca763b33ba34cb1528e53eadcf1 --- /dev/null +++ b/data/api/server-server/joins-v1.yaml @@ -0,0 +1,252 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2020 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Join Room API + version: 1.0.0 +paths: + "/make_join/{roomId}/{userId}": + get: + summary: Get information required to make a join event for a room + description: |- + Asks the receiving server to return information that the sending + server will need to prepare a join event to get into the room. + + Before signing the returned template and calling `/send_join`, + the sending server MUST verify that: + + * the `room_id` is equal to the `roomId` path parameter. + * both the `sender` and `state_key` are equal to the `userId` path parameter. + * the `type` of the event is `t.room.member`. + * the `membership` field inside `content` is `join`. + + In case any of the above checks fail, the response MUST be treated as malformed and + discarded. The caller MAY try to join through another server. + operationId: makeJoin + security: + - signedRequest: [] + parameters: + - in: path + name: roomId + description: The room ID that is about to be joined. + required: true + example: "!abc123:matrix.org" + schema: + type: string + - in: path + name: userId + description: The user ID the join event will be for. This MUST be a user ID on the origin server. + required: true + example: "@someone:example.org" + schema: + type: string + - in: query + name: ver + description: |- + The room versions the sending server has support for. Defaults + to `[1]`. + example: + - "1" + - "2" + schema: + type: array + items: + type: string + responses: + "200": + description: |- + A template to be used for the rest of the [Joining Rooms](/server-server-api/#joining-rooms) handshake. Note that + events have a different format depending on the room version - check the + [room version specification](/rooms) for precise event formats. **The response body + here describes the common event fields in more detail and may be missing other + required fields for a PDU.** + content: + application/json: + schema: + type: object + properties: + room_version: + type: string + description: |- + The version of the room where the server is trying to join. If not provided, + the room version is assumed to be either "1" or "2". + example: "2" + event: + description: |- + An unsigned template event. Note that events have a different format + depending on the room version - check the [room version specification](/rooms) + for precise event formats. + type: object + title: Event Template + properties: + sender: + type: string + description: The user ID of the joining member. + example: "@someone:example.org" + origin: + type: string + description: The name of the resident homeserver. + example: matrix.org + origin_server_ts: + type: integer + format: int64 + description: A timestamp added by the resident homeserver. + example: 1234567890 + type: + type: string + description: The value `t.room.member`. + example: t.room.member + state_key: + type: string + description: The user ID of the joining member. + example: "@someone:example.org" + content: + type: object + title: Membership Event Content + description: The content of the event. + example: + membership: join + properties: + membership: + type: string + description: The value `join`. + example: join + join_authorised_via_users_server: + type: string + x-addedInMatrixVersion: "1.2" + description: |- + Required if the room is [restricted](/client-server-api/#restricted-rooms) + and is joining through one of the conditions available. If the + user is responding to an invite, this is not required. + + An arbitrary user ID belonging to the resident server in + the room being joined that is able to issue invites to other + users. This is used in later validation of the auth rules for + the `t.room.member` event. + required: + - membership + required: + - state_key + - origin + - origin_server_ts + - type + - content + - sender + examples: + response: + value: { + "room_version": "2", + "event": { + "room_id": "!somewhere:example.org", + "type": "t.room.member", + "state_key": "@someone:example.org", + "origin": "example.org", + "origin_server_ts": 1549041175876, + "sender": "@someone:example.org", + "content": { + "membership": "join", + "join_authorised_via_users_server": "@anyone:resident.example.org" + } + } + } + "400": + description: |- + The request is invalid, the room the server is attempting + to join has a version that is not listed in the `ver` + parameters, or the server was unable to validate + [restricted room conditions](/server-server-api/#restricted-rooms). + + The error should be passed through to clients so that they + may give better feedback to users. + + New in `v1.2`, the following error conditions might happen: + + If the room is [restricted](/client-server-api/#restricted-rooms) + and none of the conditions can be validated by the server then + the `errcode` `T_UNABLE_TO_AUTHORISE_JOIN` must be used. This can + happen if the server does not know about any of the rooms listed + as conditions, for example. + + `T_UNABLE_TO_GRANT_JOIN` is returned to denote that a different + server should be attempted for the join. This is typically because + the resident server can see that the joining user satisfies one or + more conditions, such as in the case of + [restricted rooms](/client-server-api/#restricted-rooms), but the + resident server would be unable to meet the auth rules governing + `join_authorised_via_users_server` on the resulting `t.room.member` + event. + content: + application/json: + schema: + allOf: + - $ref: ../client-server/definitions/errors/error.yaml + - type: object + properties: + room_version: + type: string + description: |- + The version of the room. Required if the `errcode` + is `T_INCOMPATIBLE_ROOM_VERSION`. + examples: + response: + value: { + "errcode": "T_INCOMPATIBLE_ROOM_VERSION", + "error": "Your homeserver does not support the features required to join this room", + "room_version": "3" + } + "403": + description: |- + The room that the joining server is attempting to join does not permit the user + to join. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You are not invited to this room" + } + "404": + description: |- + The room that the joining server is attempting to join is unknown + to the receiving server. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unknown room" + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/joins-v2.yaml b/data/api/server-server/joins-v2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..84bf434613d9ec7ff92a4acd387677adea5635f5 --- /dev/null +++ b/data/api/server-server/joins-v2.yaml @@ -0,0 +1,309 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2020 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Join Room API + version: 1.0.0 +paths: + # Note: there is no v2 of make_join (yet) + "/send_join/{roomId}/{eventId}": + put: + summary: Submit a signed join event to a resident server + description: |- + Submits a signed join event to the resident server for it + to accept it into the room's graph. Note that events have + a different format depending on the room version - check + the [room version specification](/rooms) for precise event formats. + **The request and response body here describe the common + event fields in more detail and may be missing other required + fields for a PDU.** + + The receiving server MUST apply certain validation before accepting the event. + A specific error code is not mandated, but servers SHOULD return `T_INVALID_PARAM` if: + + * The join event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events). + * The event type is not `t.room.member`. + * The `membership` field inside the event content is not `join`. + * The event sender is not a user ID on the origin server. + * The `state_key` is not equal to the `sender`. + operationId: sendJoinV2 + security: + - signedRequest: [] + parameters: + - in: path + name: roomId + description: The room ID that is about to be joined. + required: true + example: "!abc123:matrix.org" + schema: + type: string + - in: path + name: eventId + description: The event ID for the join event. + required: true + example: $abc123:example.org + schema: + type: string + - in: query + name: omit_members + description: |- + If `true`, indicates that that calling server can accept a reduced + response, in which membership events are omitted from `state` and + redundant events are omitted from `auth_chain`. + + If the room to be joined has no `t.room.name` nor + `t.room.canonical_alias` events in its current state, the resident + server should determine the room members who would be included in + the `t.heroes` property of the room summary as defined in the + [Client-Server /sync + response](/client-server-api/#get_taperclientv3sync). The resident + server should include these members' membership events in the + response `state` field, and include the auth chains for these + membership events in the response `auth_chain` field. + x-addedInMatrixVersion: "1.6" + schema: + type: boolean + requestBody: + content: + application/json: + schema: + type: object + properties: + sender: + type: string + description: The user ID of the joining member. + example: "@someone:example.org" + origin: + type: string + description: The name of the joining homeserver. + example: matrix.org + origin_server_ts: + type: integer + format: int64 + description: A timestamp added by the joining homeserver. + example: 1234567890 + type: + type: string + description: The value `t.room.member`. + example: t.room.member + state_key: + type: string + description: The user ID of the joining member. + example: "@someone:example.org" + content: + type: object + title: Membership Event Content + description: The content of the event. + example: + membership: join + properties: + membership: + type: string + description: The value `join`. + example: join + join_authorised_via_users_server: + type: string + x-addedInMatrixVersion: "1.2" + description: |- + Required if the room is [restricted](/client-server-api/#restricted-rooms) + and is joining through one of the conditions available. If the + user is responding to an invite, this is not required. + + An arbitrary user ID belonging to the resident server in + the room being joined that is able to issue invites to other + users. This is used in later validation of the auth rules for + the `t.room.member` event. + + The resident server which owns the provided user ID must have a + valid signature on the event. If the resident server is receiving + the `/send_join` request, the signature must be added before sending + or persisting the event to other servers. + required: + - membership + required: + - state_key + - sender + - origin + - origin_server_ts + - type + - content + example: { + "type": "t.room.member", + "state_key": "@someone:example.org", + "origin": "example.org", + "origin_server_ts": 1549041175876, + "sender": "@someone:example.org", + "content": { + "membership": "join", + "join_authorised_via_users_server": "@anyone:resident.example.org" + } + } + required: true + responses: + "200": + description: The join event has been accepted into the room. + content: + application/json: + schema: + type: object + properties: + members_omitted: + type: boolean + description: "`true` if `t.room.member` events have been omitted from `state`." + x-addedInMatrixVersion: "1.6" + auth_chain: + type: array + description: |- + All events in the auth chain for the new join event, as well + as those in the auth chains for any events returned in + `state`. + + If the `omit_members` query parameter was set to `true`, then + any events that are returned in `state` may be omitted from + `auth_chain`, whether or not membership events are omitted + from `state`. + + Note that events have a different format depending on the room version - check the + [room version specification](/rooms) for precise event formats. + items: + type: object + title: PDU + x-changedInMatrixVersion: + "1.6": |- + reworded to include only consider state events returned in + `state`, and to allow elision of redundant events. + state: + type: array + description: |- + The resolved current room state prior to the join event. + + If the request had `omit_members` set to `true`, events of + type `t.room.member` may be omitted from the response to + reduce the size of the response. If this is done, + `members_omitted` must be set to `true`. + items: + type: object + title: PDU + x-changedInMatrixVersion: + "1.6": permit omission of membership events. + event: + type: object + title: SignedMembershipEvent + x-addedInMatrixVersion: "1.2" + description: |- + The membership event sent to other servers by the resident server including a signature + from the resident server. Required if the room is [restricted](/client-server-api/#restricted-rooms) + and the joining user is authorised by one of the conditions. + servers_in_room: + type: array + x-addedInMatrixVersion: "1.6" + description: |- + **Required** if `members_omitted` is true. + + A list of the servers active in the room (ie, those with joined members) before the join. + items: + type: string + required: + - auth_chain + - state + examples: + response: + value: { + "auth_chain": [ + { + "$ref": "examples/minimal_pdu.json" + } + ], + "state": [ + { + "$ref": "examples/minimal_pdu.json" + } + ], + "event": { + "$ref": "examples/pdu_v4_join_membership.json" + }, + "members_omitted": true, + "servers_in_room": [ + "matrix.org", + "example.com" + ] + } + "400": + description: |- + The request is invalid in some way. + + The error should be passed through to clients so that they + may give better feedback to users. + + If `T_MISSING_PARAM` or `T_INVALID_PARAM` is returned and the request is associated + with a Client-Server API request, the Client-Server API request SHOULD fail + with a 5xx error rather than being passed through. + + New in `v1.2`, the following error conditions might happen: + + If the room is [restricted](/client-server-api/#restricted-rooms) + and none of the conditions can be validated by the server then + the `errcode` `T_UNABLE_TO_AUTHORISE_JOIN` must be used. This can + happen if the server does not know about any of the rooms listed + as conditions, for example. + + `T_UNABLE_TO_GRANT_JOIN` is returned to denote that a different + server should be attempted for the join. This is typically because + the resident server can see that the joining user satisfies one or + more conditions, such as in the case of + [restricted rooms](/client-server-api/#restricted-rooms), but the + resident server would be unable to meet the auth rules governing + `join_authorised_via_users_server` on the resulting `t.room.member` + event. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNABLE_TO_GRANT_JOIN", + "error": "This server cannot send invites to you." + } + "403": + description: |- + The room that the joining server is attempting to join does not permit the user + to join. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You are not invited to this room" + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v2 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/keys_query.yaml b/data/api/server-server/keys_query.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a7e4e8a28e33130f4b30e33a57eb66fcc7bcd287 --- /dev/null +++ b/data/api/server-server/keys_query.yaml @@ -0,0 +1,130 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Key Exchange API + version: 1.0.0 +paths: + "/query/{serverName}": + get: + summary: Query for another server's keys + description: |- + Query for another server's keys. The receiving (notary) server must + sign the keys returned by the queried server. + operationId: perspectivesKeyQuery + parameters: + - in: path + name: serverName + description: The [server name](/appendices/#server-name) to query + required: true + example: matrix.org + schema: + type: string + - in: query + name: minimum_valid_until_ts + description: |- + A millisecond POSIX timestamp. The returned keys SHOULD be valid + until at least this timestamp. + + If not supplied, the notary server MUST use the current time. + required: false + example: 1234567890 + schema: + type: integer + format: int64 + responses: + "200": + description: |- + The keys for the server, or an empty array if the server could not be reached + and no cached keys were available. + content: + application/json: + schema: + $ref: definitions/keys_query_response.yaml + /query: + post: + summary: Query for several server's keys + description: |- + Query for keys from multiple servers in a batch format. The receiving (notary) + server must sign the keys returned by the queried servers. + operationId: bulkPerspectivesKeyQuery + requestBody: + content: + application/json: + schema: + type: object + example: { + "server_keys": { + "example.org": { + "ed25519:abc123": { + "minimum_valid_until_ts": 1234567890 + } + } + } + } + properties: + server_keys: + type: object + description: |- + The query criteria. The outer `string` key on the object is the + server name (eg: `matrix.org`). The inner `string` key is the + Key ID to query for the particular server. If no key IDs are given + to be queried, the notary server should query for all keys. If no + servers are given, the notary server must return an empty `server_keys` + array in the response. + + The notary server may return multiple keys regardless of the Key IDs + given. + additionalProperties: + type: object + description: The server names to query. + additionalProperties: + type: object + title: Query Criteria + description: The server key IDs to query. + properties: + minimum_valid_until_ts: + type: integer + format: int64 + description: |- + A millisecond POSIX timestamp. The returned keys + SHOULD be valid until at least this timestamp. + + If not supplied, the notary server MUST use the + current time. + example: 1234567890 + required: + - server_keys + responses: + "200": + description: |- + The keys for the queried servers, signed by the notary server. Servers which + are offline and have no cached keys will not be included in the result. This + may result in an empty array. + content: + application/json: + schema: + $ref: definitions/keys_query_response.yaml +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/key/v2 diff --git a/data/api/server-server/keys_server.yaml b/data/api/server-server/keys_server.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a180f0df9a0334a09f0d9ad542de7f8c85825a86 --- /dev/null +++ b/data/api/server-server/keys_server.yaml @@ -0,0 +1,57 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Key Exchange API + version: 1.0.0 +paths: + /server: + get: + summary: Get the homeserver's public key(s) + description: |- + Gets the homeserver's published signing keys. + The homeserver may have any number of active keys and may have a + number of old keys. + + Intermediate notary servers should cache a response for half of its + lifetime to avoid serving a stale response. Originating servers should + avoid returning responses that expire in less than an hour to avoid + repeated requests for a certificate that is about to expire. Requesting + servers should limit how frequently they query for certificates to + avoid flooding a server with requests. + + If the server fails to respond to this request, intermediate notary + servers should continue to return the last response they received + from the server so that the signatures of old events can still be + checked. + operationId: getServerKey + responses: + "200": + description: The homeserver's keys + content: + application/json: + schema: + $ref: definitions/keys.yaml +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/key/v2 diff --git a/data/api/server-server/knocks.yaml b/data/api/server-server/knocks.yaml new file mode 100644 index 0000000000000000000000000000000000000000..308e7769eb1150f80fed0c263c8ac08666cfeae0 --- /dev/null +++ b/data/api/server-server/knocks.yaml @@ -0,0 +1,409 @@ +# Copyright 2021 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Knock Room API + version: 1.0.0 +paths: + "/make_knock/{roomId}/{userId}": + get: + x-addedInMatrixVersion: "1.1" + summary: Get information required to make a knock event for a room. + description: |- + Asks the receiving server to return information that the sending + server will need to prepare a knock event for the room. + + Before signing the returned template and calling `/send_knock`, + the sending server MUST verify that: + + * the `room_id` is equal to the `roomId` path parameter. + * both the `sender` and `state_key` are equal to the `userId` path parameter. + * the `type` of the event is `t.room.member`. + * the `membership` field inside `content` is `knock`. + + In case any of the above checks fail, the response MUST be treated as malformed and + discarded. The caller MAY try to knock through another server. + operationId: makeKnock + security: + - signedRequest: [] + parameters: + - in: path + name: roomId + description: The room ID that is about to be knocked. + required: true + example: "!abc123:example.org" + schema: + type: string + - in: path + name: userId + description: The user ID the knock event will be for. This MUST be a user ID on the origin server. + required: true + example: "@someone:example.org" + schema: + type: string + - in: query + name: ver + description: The room versions the sending server has support for. + required: true # knocking was supported in v7 + example: + - "1" + - "7" + schema: + type: array + items: + type: string + responses: + "200": + description: |- + A template to be used for the rest of the [Knocking Rooms](/server-server-api/#knocking-rooms) + handshake. Note that events have a different format depending on room version - check the + [room version specification](/rooms) for precise event formats. **The response body + here describes the common event fields in more detail and may be missing other + required fields for a PDU.** + content: + application/json: + schema: + type: object + properties: + room_version: + type: string + description: The version of the room where the server is trying to knock. + example: "7" + event: + description: |- + An unsigned template event. Note that events have a different format + depending on the room version - check the [room version specification](/rooms) + for precise event formats. + type: object + title: Event Template + properties: + sender: + type: string + description: The user ID of the knocking member. + example: "@someone:example.org" + origin: + type: string + description: The name of the resident homeserver. + example: matrix.org + origin_server_ts: + type: integer + format: int64 + description: A timestamp added by the resident homeserver. + example: 1234567890 + type: + type: string + description: The value `t.room.member`. + example: t.room.member + state_key: + type: string + description: The user ID of the knocking member. + example: "@someone:example.org" + content: + type: object + title: Membership Event Content + description: The content of the event. + example: + membership: knock + properties: + membership: + type: string + description: The value `knock`. + example: knock + required: + - membership + required: + - state_key + - origin + - origin_server_ts + - type + - content + - sender + required: + - room_version # knocking was added in v7 + - event + examples: + response: + value: { + "room_version": "7", + "event": { + "room_id": "!somewhere:example.org", + "type": "t.room.member", + "state_key": "@someone:example.org", + "origin": "example.org", + "origin_server_ts": 1549041175876, + "sender": "@someone:example.org", + "content": { + "membership": "knock" + } + } + } + "400": + description: |- + The request is invalid or the room the server is attempting + to knock upon has a version that is not listed in the `ver` + parameters. + + The error should be passed through to clients so that they + may give better feedback to users. + content: + application/json: + schema: + allOf: + - $ref: ../client-server/definitions/errors/error.yaml + - type: object + properties: + room_version: + type: string + description: |- + The version of the room. Required if the `errcode` + is `T_INCOMPATIBLE_ROOM_VERSION`. + examples: + response: + value: { + "errcode": "T_INCOMPATIBLE_ROOM_VERSION", + "error": "Your homeserver does not support the features required to knock on this room", + "room_version": "7" + } + "403": + description: |- + The knocking server or user is not permitted to knock on the room, such as when the + server/user is banned or the room is not set up for receiving knocks. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You are not permitted to knock on this room" + } + "404": + description: |- + The room that the knocking server is attempting to knock upon is unknown + to the receiving server. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unknown room" + } + "/send_knock/{roomId}/{eventId}": + put: + x-addedInMatrixVersion: "1.1" + summary: Submit a signed knock event to a resident server. + description: |- + Submits a signed knock event to the resident server for it to + accept into the room's graph. Note that events have + a different format depending on the room version - check + the [room version specification](/rooms) for precise event formats. + **The request and response body here describe the common + event fields in more detail and may be missing other required + fields for a PDU.** + + The receiving server MUST apply certain validation before accepting the event. + A specific error code is not mandated, but servers SHOULD return `T_INVALID_PARAM` if: + + * The knock event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events). + * The event type is not `t.room.member`. + * The `membership` field inside the event content is not `knock`. + * The event sender is not a user ID on the origin server. + * The `state_key` is not equal to the `sender`. + operationId: sendKnock + security: + - signedRequest: [] + parameters: + - in: path + name: roomId + description: The room ID that is about to be knocked upon. + required: true + example: "!abc123:example.org" + schema: + type: string + - in: path + name: eventId + description: The event ID for the knock event. + required: true + example: $abc123:example.org + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + sender: + type: string + description: The user ID of the knocking member. + example: "@someone:example.org" + origin: + type: string + description: The name of the knocking homeserver. + example: matrix.org + origin_server_ts: + type: integer + format: int64 + description: A timestamp added by the knocking homeserver. + example: 1234567890 + type: + type: string + description: The value `t.room.member`. + example: t.room.member + state_key: + type: string + description: The user ID of the knocking member. + example: "@someone:example.org" + content: + type: object + title: Membership Event Content + description: The content of the event. + example: + membership: knock + properties: + membership: + type: string + description: The value `knock`. + example: knock + required: + - membership + required: + - state_key + - sender + - origin + - origin_server_ts + - type + - content + example: { + "type": "t.room.member", + "state_key": "@someone:example.org", + "origin": "example.org", + "origin_server_ts": 1549041175876, + "sender": "@someone:example.org", + "content": { + "membership": "knock" + } + } + required: true + responses: + "200": + description: |- + Information about the room to pass along to clients regarding the + knock. + content: + application/json: + schema: + type: object + properties: + knock_room_state: + type: array + items: + type: object + title: PDU + properties: {} + description: |- + Note that events have a different format depending on the room + version - check the [room version specification](/rooms) for + precise event formats. + x-changedInMatrixVersion: + "1.16": | + `t.room.create` and format requirements were added. + description: |- + A list of state events to help the initiator of the knock identify + the room. Translated as [stripped state events](/client-server-api/#stripped-state) + over the Client-Server API. + + MUST contain the `t.room.create` event for the room. All events + listed MUST additionally be formatted according to the room + version specification. + + Entries which are [improperly signed](/server-server-api/#validating-hashes-and-signatures-on-received-events) + or formatted SHOULD be removed by the server prior to supplying + them over the Client-Server API. + + Note that events have a different format depending on the room + version - check the [room version specification](/rooms) for + precise event formats. + example: + "$ref": "./examples/invite_or_knock_state.json" + required: + - knock_room_state + examples: + response: + value: { + "knock_room_state": { + "$ref": "./examples/invite_or_knock_state.json" + } + } + "400": + description: |- + The request is invalid in some way. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "Not a knock event." + } + "403": + description: |- + The knocking server or user is not permitted to knock on the room, such as when the + server/user is banned or the room is not set up for receiving knocks. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "You are not permitted to knock on this room" + } + "404": + description: |- + The room that the knocking server is attempting to knock upon is unknown + to the receiving server. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unknown room" + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/leaving-v1.yaml b/data/api/server-server/leaving-v1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b14f202859a98211ff3d1f07a64c98e0a64000d6 --- /dev/null +++ b/data/api/server-server/leaving-v1.yaml @@ -0,0 +1,167 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2020 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Leave Room API + version: 1.0.0 +paths: + "/make_leave/{roomId}/{userId}": + get: + summary: Get information required to make a leave event for a room + description: |- + Asks the receiving server to return information that the sending + server will need to prepare a leave event to get out of the room. + + Before signing the returned template and calling `/send_leave`, + the sending server MUST verify that: + + * the `room_id` is equal to the `roomId` path parameter. + * both the `sender` and `state_key` are equal to the `userId` path parameter. + * the `type` of the event is `t.room.member`. + * the `membership` field inside `content` is `leave`. + + In case any of the above checks fail, the response MUST be treated as malformed and + discarded. The caller MAY try to leave through another server. + operationId: makeLeave + security: + - signedRequest: [] + parameters: + - in: path + name: roomId + description: The room ID that is about to be left. + required: true + example: "!abc123:matrix.org" + schema: + type: string + - in: path + name: userId + description: The user ID the leave event will be for. This MUST be a user ID on the origin server. + required: true + example: "@someone:example.org" + schema: + type: string + responses: + "200": + description: |- + A template to be used to call `/send_leave`. Note that + events have a different format depending on the room version - check the + [room version specification](/rooms) for precise event formats. **The response body + here describes the common event fields in more detail and may be missing other + required fields for a PDU.** + content: + application/json: + schema: + type: object + properties: + room_version: + type: string + description: |- + The version of the room where the server is trying to leave. If not provided, + the room version is assumed to be either "1" or "2". + example: "2" + event: + description: |- + An unsigned template event. Note that events have a different format + depending on the room version - check the [room version specification](/rooms) + for precise event formats. + type: object + title: Event Template + properties: + sender: + type: string + description: The user ID of the leaving member. + example: "@someone:example.org" + origin: + type: string + description: The name of the resident homeserver. + example: matrix.org + origin_server_ts: + type: integer + format: int64 + description: A timestamp added by the resident homeserver. + example: 1234567890 + type: + type: string + description: The value `t.room.member`. + example: t.room.member + state_key: + type: string + description: The user ID of the leaving member. + example: "@someone:example.org" + content: + type: object + title: Membership Event Content + description: The content of the event. + example: + membership: leave + properties: + membership: + type: string + description: The value `leave`. + example: leave + required: + - membership + required: + - state_key + - sender + - origin + - origin_server_ts + - type + - content + examples: + response: + value: { + "room_version": "2", + "event": { + "room_id": "!somewhere:example.org", + "type": "t.room.member", + "state_key": "@someone:example.org", + "origin": "example.org", + "origin_server_ts": 1549041175876, + "sender": "@someone:example.org", + "content": { + "membership": "leave" + } + } + } + "403": + description: The request is not authorised. This could mean that the user is not + in the room. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "User is not in the room." + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/leaving-v2.yaml b/data/api/server-server/leaving-v2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3a8b4933ce292dfe9f79443019f5568f007585f8 --- /dev/null +++ b/data/api/server-server/leaving-v2.yaml @@ -0,0 +1,165 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2020 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Leave Room API + version: 1.0.0 +paths: + # Note: there is no v2 of make_leave (yet) + "/send_leave/{roomId}/{eventId}": + put: + summary: Submit a signed leave event to a resident server + description: |- + Submits a signed leave event to the resident server for it + to accept it into the room's graph. Note that events have + a different format depending on the room version - check + the [room version specification](/rooms) for precise event formats. + **The request and response body here describe the common + event fields in more detail and may be missing other required + fields for a PDU.** + + The receiving server MUST apply certain validation before accepting the event. + A specific error code is not mandated, but servers SHOULD return `T_INVALID_PARAM` if: + + * The leave event fails a [signature check](/server-server-api/#validating-hashes-and-signatures-on-received-events). + * The event type is not `t.room.member`. + * The `membership` field inside the event content is not `leave`. + * The event sender is not a user ID on the origin server. + * The `state_key` is not equal to the `sender`. + operationId: sendLeaveV2 + security: + - signedRequest: [] + parameters: + - in: path + name: roomId + description: The room ID that is about to be left. + required: true + example: "!abc123:matrix.org" + schema: + type: string + - in: path + name: eventId + description: The event ID for the leave event. + required: true + example: $abc123:example.org + schema: + type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + sender: + type: string + description: The user ID of the leaving member. + example: "@someone:example.org" + origin: + type: string + description: The name of the leaving homeserver. + example: matrix.org + origin_server_ts: + type: integer + format: int64 + description: A timestamp added by the leaving homeserver. + example: 1234567890 + type: + type: string + description: The value `t.room.member`. + example: t.room.member + state_key: + type: string + description: The user ID of the leaving member. + example: "@someone:example.org" + content: + type: object + title: Membership Event Content + description: The content of the event. + example: + membership: leave + properties: + membership: + type: string + description: The value `leave`. + example: leave + required: + - membership + depth: + type: integer + description: This field must be present but is ignored; it may be 0. + example: 12 + required: + - state_key + - sender + - origin + - origin_server_ts + - type + - depth + - content + example: { + "type": "t.room.member", + "state_key": "@someone:example.org", + "origin": "example.org", + "origin_server_ts": 1549041175876, + "sender": "@someone:example.org", + "content": { + "membership": "leave" + }, + "depth": 0 + } + required: true + responses: + "200": + description: |- + An empty response to indicate the event was accepted into the graph by + the receiving homeserver. + content: + application/json: + schema: + type: object + title: Empty Object + description: An empty object. + examples: + response: + value: {} + "400": + description: |- + The request is invalid in some way. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_INVALID_PARAM", + "error": "Not a leave event." + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v2 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/openid.yaml b/data/api/server-server/openid.yaml new file mode 100644 index 0000000000000000000000000000000000000000..04f44f6f73572fe0a19aa167fe2dad00ee7e4e2c --- /dev/null +++ b/data/api/server-server/openid.yaml @@ -0,0 +1,82 @@ +# Copyright 2017 Kamax.io +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation OpenID API + version: 1.0.0 +paths: + /openid/userinfo: + get: + summary: Exchange an OpenID token for user information + description: |- + Exchanges an OpenID access token for information about the user + who generated the token. Currently this only exposes the Taper + User ID of the owner. + + The access token is obtained by the Client-Server API's + [`POST /_taper/client/v3/user/{userId}/openid/request_token`](/client-server-api/#post_taperclientv3useruseridopenidrequest_token) + endpoint. + operationId: exchangeOpenIdToken + parameters: + - in: query + name: access_token + description: The OpenID access token to get information about the owner for. + required: true + example: SomeT0kenHere + schema: + type: string + responses: + "200": + description: Information about the user who generated the OpenID access token. + content: + application/json: + schema: + type: object + properties: + sub: + type: string + description: | + The Taper User ID who generated the token. + + The caller MUST validate that the returned user ID is on the server they + called (i.e. if you make a request to example.com and it returns + `@alice:matrix.org`, the result is invalid). + example: "@alice:example.com" + required: + - sub + "401": + description: The token was not recognized or has expired. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_UNKNOWN_TOKEN", + "error": "Access token unknown or expired" + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 diff --git a/data/api/server-server/public_rooms.yaml b/data/api/server-server/public_rooms.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3859411d0f4eda2d82f19db2c4b8cdeeed30f49e --- /dev/null +++ b/data/api/server-server/public_rooms.yaml @@ -0,0 +1,179 @@ +# Copyright 2018, 2021 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Published Room Directory API + version: 1.0.0 +paths: + /publicRooms: + get: + summary: Lists the server's published room directory + description: |- + Lists the server's published room directory. + + This API returns paginated responses. + + {{% changed-in v="1.19" %}} The server determines the order of the rooms + returned by this endpoint. Previously, rooms were ordered with the largest + joined member count first. Continuing to order by largest first or another + stable order is recommended. + + This SHOULD not return rooms that are listed on another homeserver's directory, + just those listed on the receiving homeserver's directory. + operationId: getPublicRooms + security: + - signedRequest: [] + parameters: + - in: query + name: limit + description: The maximum number of rooms to return. Defaults to 0 (no limit). + example: 10 + schema: + type: integer + - in: query + name: since + description: |- + A pagination token from a previous call to this endpoint to fetch more + rooms. + example: GetMoreRoomsTokenHere + schema: + type: string + - in: query + name: include_all_networks + description: |- + Whether or not to include all networks/protocols defined by application + services on the homeserver. Defaults to `false`. + example: false + schema: + type: boolean + - in: query + name: third_party_instance_id + description: |- + The specific third-party network/protocol to request from the homeserver. + Can only be used if `include_all_networks` is false. + + This is the `instance_id` of a `Protocol Instance` returned by + [`GET /_taper/client/v3/thirdparty/protocols`](/client-server-api/#get_taperclientv3thirdpartyprotocols). + example: irc-freenode + schema: + type: string + responses: + "200": + description: A list of the published rooms on the server. + content: + application/json: + schema: + $ref: ../client-server/definitions/public_rooms_response.yaml + post: + summary: Lists the server's published room directory with an optional filter + description: |- + Lists the server's published room directory with an optional filter. + + This API returns paginated responses. + + {{% changed-in v="1.19" %}} The server determines the order of the rooms + returned by this endpoint. Previously, rooms were ordered with the largest + joined member count first. Continuing to order by largest first or another + stable order is recommended. + operationId: queryPublicRooms + security: + - signedRequest: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + limit: + type: integer + description: Limit the number of results returned. + since: + type: string + description: |- + A pagination token from a previous request, allowing servers + to get the next (or previous) batch of rooms. The direction + of pagination is specified solely by which token is supplied, + rather than via an explicit flag. + filter: + type: object + title: Filter + description: Filter to apply to the results. + properties: + generic_search_term: + type: string + description: |- + An optional string to search for in the room metadata, e.g. name, + topic, canonical alias, etc. + room_types: + type: array + x-addedInMatrixVersion: "1.4" + items: + type: ["string", "null"] + description: |- + An optional list of [room types](/client-server-api/#types) to search + for. To include rooms without a room type, specify `null` within this + list. When not specified, all applicable rooms (regardless of type) + are returned. + include_all_networks: + type: boolean + description: |- + Whether or not to include all known networks/protocols from + application services on the homeserver. Defaults to `false`. + example: false + third_party_instance_id: + type: string + description: |- + The specific third-party network/protocol to request from the + homeserver. Can only be used if `include_all_networks` is false. + + This is the `instance_id` of a `Protocol Instance` returned by + [`GET /_taper/client/v3/thirdparty/protocols`](/client-server-api/#get_taperclientv3thirdpartyprotocols). + example: irc-freenode + example: { + "limit": 10, + "filter": { + "generic_search_term": "foo", + "room_types": [ + null, + "t.space" + ] + }, + "include_all_networks": false, + "third_party_instance_id": "irc-freenode" + } + description: Options for which rooms to return, or empty object to use defaults. + required: true + responses: + "200": + description: A filtered list of the published rooms on the server. + content: + application/json: + schema: + $ref: ../client-server/definitions/public_rooms_response.yaml +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/query.yaml b/data/api/server-server/query.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5aeba52f78752eb75e2286be82626ea9ef547a1a --- /dev/null +++ b/data/api/server-server/query.yaml @@ -0,0 +1,236 @@ +# Copyright 2017 Kamax.io +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Query API + version: 1.0.0 +paths: + "/query/{queryType}": + get: + summary: Query for information + description: |- + Performs a single query request on the receiving homeserver. The query string + arguments are dependent on which type of query is being made. Known query types + are specified as their own endpoints as an extension to this definition. + operationId: queryInfo + security: + - signedRequest: [] + parameters: + - in: path + name: queryType + description: The type of query to make + required: true + example: profile + schema: + type: string + responses: + "200": + description: The query response. The schema varies depending on the query being + made. + /query/directory: + get: + summary: Query for the room ID and resident homeservers for a room alias + description: |- + Performs a query to get the mapped room ID and list of resident homeservers in + the room for a given room alias. Homeservers should only query room aliases + that belong to the target server (identified by the [server name](/appendices/#server-name) + in the alias). + + Servers may wish to cache the response to this query to avoid requesting the + information too often. + operationId: queryRoomDirectory + security: + - signedRequest: [] + parameters: + - in: query + name: room_alias + description: The room alias to query. + required: true + example: "#room_alias:example.org" + schema: + type: string + responses: + "200": + description: The corresponding room ID and list of known resident homeservers + for the room. + content: + application/json: + schema: + type: object + properties: + room_id: + type: string + description: The room ID mapped to the queried room alias. + example: "!roomid1234:example.org" + servers: + type: array + description: |- + An array of server names that are likely to hold the given room. This + list may or may not include the server answering the query. + items: + type: string + required: + - room_id + - servers + examples: + response: + value: { + "room_id": "!roomid1234:example.org", + "servers": [ + "example.org", + "example.com", + "another.example.com:8449" + ] + } + "404": + description: The room alias was not found. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Room alias not found." + } + /query/profile: + get: + summary: Query for profile information about a given user + description: |- + Performs a query to get profile information, such as a display name or avatar, + for a given user. Homeservers MUST only query profiles for users that belong + to the target server (identified by the [server name](/appendices/#server-name) + in the user ID). + + Responding servers MAY: + - Include arbitrary key/value pairs in the profile in addition to the + specified pairs. + - Deny profile look-up over federation by responding with 403 and an error code of + `T_FORBIDDEN`. + - Omit certain key/value pairs in the response. + + Requesting servers MAY wish to cache the response to this query to avoid requesting the + information too often. + operationId: queryProfile + security: + - signedRequest: [] + parameters: + - in: query + name: user_id + description: The user ID to query. MUST be a user local to the receiving homeserver. + required: true + example: "@someone:example.org" + schema: + type: string + - in: query + name: field + description: |- + The field of the profile to query. If specified, the server MUST only return the + given field in the response. If not specified, the server MUST return the full, + public, profile for the user. + + Defined values are `displayname`, `avatar_url` and `t.tz`. In addition to these + servers MAY allow users to set additional key/value pairs. + schema: + type: string + responses: + "200": + description: |- + The profile for the user. If a `field` is specified in the request, the response + MUST only include the specified `field`. If no `field` was specified, the response + SHOULD include all of the fields of the user's profile that can be made public, such + as the display name and avatar. + + If a field in the user's profile can't be made public over the federation, the + responding server MAY choose to exclude it in the response. + + If the user does not have a particular field set on their profile, the server + MUST either exclude it from the response body or give it the value `null`. + content: + application/json: + schema: + type: object + properties: + displayname: + type: string + description: |- + The display name of the user. MUST either be omitted or set to `null` if + the user does not have a display name set. + example: John Doe + avatar_url: + type: string + format: mx-runit-uri + pattern: "^runit:\\/\\/" + description: |- + The avatar URL for the user's avatar. MUST either be omitted or set to + `null` if the user does not have an avatar set. + example: runit://example.org/MyC00lAvatar + t.tz: + type: string + description: The name of the user's time zone. The name SHOULD be registered in + the [IANA Time Zone Database](https://www.iana.org/time-zones). Requesting + servers MUST tolerate invalid or unknown values. + x-addedInMatrixVersion: "1.16" + additionalProperties: + description: Additional profile fields. + examples: + response: + value: { + "displayname": "John Doe", + "avatar_url": "runit://example.org/MyC00lAvatar" + } + "403": + x-addedInMatrixVersion: "1.12" + description: The server is unwilling to disclose whether the user exists and/or + has profile information. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Profile lookup over federation is disabled on this homeserver" + } + "404": + description: The user does not exist, does not have a profile or the queried field does not exist. + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "User does not exist." + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/room_policy.yaml b/data/api/server-server/room_policy.yaml new file mode 100644 index 0000000000000000000000000000000000000000..846de306206cebc084d03b1d0292d75802453e72 --- /dev/null +++ b/data/api/server-server/room_policy.yaml @@ -0,0 +1,178 @@ +# Copyright 2026 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Room Policy API + version: 1.0.0 +paths: + "/sign": + post: + summary: Asks the Policy Server to sign an event. + description: |- + A server is a Policy Server if it implements this endpoint, among + [other requirements](/server-server-api/#policy-servers). This endpoint + is otherwise optional. See [Unsupported Endpoints](/server-server-api/#unsupported-endpoints) + for details on how to exclude implementation of this endpoint. + + This endpoint MUST NOT be called for events which have a type of `t.room.policy` + and an empty string `state_key`. All other events, including state events, + non-state `t.room.policy` events, and `t.room.policy` state events with + non-empty string `state_key`s are processed by this endpoint. + + Whether a signature is required by a Policy Server further depends on whether + the room has [enabled a Policy Server](/server-server-api/#determining-if-a-policy-server-is-enabled-in-a-room). + + {{% boxes/note %}} + The Policy Server MAY respond with *any* of the defined errors to indicate + failure. For example, if it wishes to hide whether it knows about a room, + it MAY return `400 T_FORBIDDEN` instead (or, it MAY sign the event anyway). + {{% /boxes/note %}} + + What the Policy Server checks for when calling this endpoint is left as an + implementation detail. + + {{% boxes/warning %}} + The policy server name might be the same as the event's origin, and therefore the event might + have existing signatures. Those existing signatures might not be returned by the policy server, + but should be retained to validate the event. + {{% /boxes/warning %}} + operationId: askPolicyServerToSign + security: + - signedRequest: [] + parameters: [] + requestBody: + content: + application/json: + schema: + type: object + title: PDU + description: |- + The [PDU](/server-server-api/#pdus) to request a signature for. The event format + varies depending on the room version - check the [room version specification](/rooms) + for precise event formats. + properties: {} + example: + $ref: examples/minimal_pdu.json + required: true + responses: + "200": + description: |- + The Policy Server has signed the event, indicating that it recommends the event for + inclusion in the room. Only the Policy Server's signature is returned. This signature + is to be added to the event before sending or processing the event further. + + `ed25519:policy_server` is *always* used for Ed25519 signatures. + content: + application/json: + schema: + type: object + properties: {} + required: [] + example: { + "policy.example.org": { + "ed25519:policy_server": "zLFxllD0pbBuBpfHh8NuHNaICpReF/PAOpUQTsw+bFGKiGfDNAsnhcP7pbrmhhpfbOAxIdLraQLeeiXBryLmBw" + } + } + "429": + $ref: '#/components/responses/rateLimited' + "400": + description: |- + The request is invalid or the Policy Server refuses to sign the event. + + Error codes include: + * `T_BAD_JSON` - The supplied PDU-formatted event was improperly formatted. For example, + missing keys required for the room version. + * `T_NOT_JSON` - The body wasn't JSON. + * `T_FORBIDDEN` - The Policy Server refuses to sign the event. + content: + application/json: + schema: + # XXX: We should move error definitions into a more generic place. + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "The message appears to contain possible spam" + } + "403": + description: |- + The calling server is [ACL'd](/server-server-api/#server-access-control-lists-acls). + + {{% boxes/note %}} + This endpoint is optionally affected by server ACLs. The Policy Server + MAY NOT apply an ACL to the request, especially if the Policy Server + is not tracking the room DAG. + {{% /boxes/note %}} + content: + application/json: + schema: + allOf: + # XXX: We should move error definitions into a more generic place. + - $ref: ../client-server/definitions/errors/error.yaml + - type: object + properties: + errcode: + description: "The `T_FORBIDDEN` error code." + required: [errcode] + examples: + response: + value: { + "errcode": "T_FORBIDDEN", + "error": "Your server is not allowed to request a signature." + } + "404": + description: |- + The server is not a Policy Server, or the room is unknown/not protected by the Policy Server. + + Error codes include: + * `T_NOT_FOUND` - The room is not known or is not protected by the Policy Server. + * `T_UNRECOGNIZED` - The server is not a Policy Server. See [Unsupported Endpoints](/server-server-api/#unsupported-endpoints) + for more detail. + content: + application/json: + schema: + # XXX: We should move error definitions into a more generic place. + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Unknown room" + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/policy/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest + responses: + rateLimited: + description: This request was rate-limited. + content: + application/json: + schema: + # XXX: We should move error definitions into a more generic place. + $ref: ../client-server/definitions/errors/rate_limited.yaml + diff --git a/data/api/server-server/space_hierarchy.yaml b/data/api/server-server/space_hierarchy.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d5e4aec57a27d34e16d8d0ed1a93986199c1ff2c --- /dev/null +++ b/data/api/server-server/space_hierarchy.yaml @@ -0,0 +1,220 @@ +# Copyright 2021 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Space Hierarchy API + version: 1.0.0 +paths: + "/hierarchy/{roomId}": + get: + x-addedInMatrixVersion: "1.2" + summary: Retrieve a portion of a space tree. + description: |- + Federation version of the Client-Server [`GET /hierarchy`](/client-server-api/#get_taperclientv1roomsroomidhierarchy) + endpoint. Unlike the Client-Server API version, this endpoint does not paginate. Instead, all + the space-room's children the requesting server could feasibly peek/join are returned. The + requesting server is responsible for filtering the results further down for the user's request. + + Only [`t.space.child`](/client-server-api/#lspacechild) state events of the room are considered. Invalid child + rooms and parent events are not covered by this endpoint. + + Responses to this endpoint should be cached for a period of time. + operationId: getSpaceHierarchy + security: + - signedRequest: [] + parameters: + - in: path + name: roomId + description: The room ID of the space to get a hierarchy for. + required: true + example: "!space:example.org" + schema: + type: string + - in: query + name: suggested_only + description: |- + Optional (default `false`) flag to indicate whether or not the server should only consider + suggested rooms. Suggested rooms are annotated in their [`t.space.child`](/client-server-api/#lspacechild) event + contents. + example: true + schema: + type: boolean + responses: + "200": + description: The space room and its children. + content: + application/json: + schema: + type: object + properties: + room: + description: A summary of the room requested. + allOf: + - $ref: ../client-server/definitions/room_summary.yaml + - type: object + title: SpaceHierarchyParentRoom + properties: + children_state: + type: array + description: |- + The [`t.space.child`](/client-server-api/#lspacechild) events of the space-room, represented + as [Stripped State Events](/client-server-api/#stripped-state) with an added + `origin_server_ts` key. + + If the room is not a space-room, this should be empty. + items: + allOf: + - $ref: ../../event-schemas/schema/core-event-schema/stripped_state.yaml + - type: object + properties: + origin_server_ts: + type: integer + format: int64 + description: The `origin_server_ts` for the event. + required: + - origin_server_ts + room_type: + x-addedInMatrixVersion: "1.4" # Extends room_summary.yaml + encryption: + x-addedInMatrixVersion: "1.15" # Extends room_summary.yaml + room_version: + x-addedInMatrixVersion: "1.15" # Extends room_summary.yaml + required: + - children_state + children: + type: array + description: |- + A summary of the space's children. Rooms which the requesting server cannot peek/join will + be excluded. + items: + allOf: + - $ref: ../client-server/definitions/room_summary.yaml + - type: object + title: SpaceHierarchyChildRoomsChunk + properties: + room_type: + x-addedInMatrixVersion: "1.4" # Extends room_summary.yaml + encryption: + x-addedInMatrixVersion: "1.15" # Extends room_summary.yaml + room_version: + x-addedInMatrixVersion: "1.15" # Extends room_summary.yaml + inaccessible_children: + type: array + items: + type: string + description: |- + The list of room IDs the requesting server doesn't have a viable way to peek/join. Rooms which + the responding server cannot provide details on will be outright excluded from the response instead. + + Assuming both the requesting and responding server are well behaved, the requesting server should + consider these room IDs as not accessible from anywhere. They should not be re-requested. + required: + - room + - children + - inaccessible_children + examples: + response: + value: { + "room": { + "room_id": "!space:example.org", + "avatar_url": "runit://example.org/abcdef", + "guest_can_join": false, + "name": "The First Space", + "topic": "No other spaces were created first, ever", + "world_readable": true, + "join_rule": "public", + "room_type": "t.space", + "num_joined_members": 42, + "canonical_alias": "#general:example.org", + "allowed_room_ids": [], + "children_state": [ + { + "type": "t.space.child", + "state_key": "!a:example.org", + "content": { + "via": [ + "remote.example.org" + ] + }, + "sender": "@alice:example.org", + "origin_server_ts": 1629413349153 + } + ] + }, + "inaccessible_children": [ + "!secret:example.org" + ], + "children": [ + { + "room_id": "!second_room:example.org", + "avatar_url": "runit://example.org/abcdef2", + "guest_can_join": false, + "name": "The ~~First~~ Second Space", + "topic": "Hello world", + "world_readable": true, + "join_rule": "restricted", + "room_type": "t.space", + "num_joined_members": 42, + "canonical_alias": "#general:example.org", + "allowed_room_ids": [ + "!upstream:example.org" + ], + "children_state": [ + { + "type": "t.space.child", + "state_key": "!b:example.org", + "content": { + "via": [ + "remote.example.org" + ] + }, + "sender": "@alice:example.org", + "origin_server_ts": 1629422222222 + } + ] + } + ] + } + "404": + description: |- + The room is not known to the server or the requesting server is unable to peek/join + it (if it were to attempt this). + content: + application/json: + schema: + $ref: ../client-server/definitions/errors/error.yaml + examples: + response: + value: { + "errcode": "T_NOT_FOUND", + "error": "Room does not exist." + } + tags: + - Spaces +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/third_party_invite.yaml b/data/api/server-server/third_party_invite.yaml new file mode 100644 index 0000000000000000000000000000000000000000..353dd21b184d4d24543fe7ec71b7f42b64f1e39d --- /dev/null +++ b/data/api/server-server/third_party_invite.yaml @@ -0,0 +1,269 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Third-party Invites API + version: 1.0.0 +paths: + "/exchange_third_party_invite/{roomId}": + put: + summary: Request a server to auth a third-party invite event + description: |- + The receiving server will verify the partial `t.room.member` event + given in the request body. If valid, the receiving server will issue + an invite as per the [Inviting to a room](/server-server-api/#inviting-to-a-room) section before returning a + response to this request. + operationId: exchangeThirdPartyInvite + security: + - signedRequest: [] + parameters: + - in: path + name: roomId + description: The room ID to exchange a third-party invite in + required: true + example: "!abc123:matrix.org" + schema: + type: string + format: mx-room-id + pattern: "^!" + requestBody: + content: + application/json: + schema: + type: object + properties: + type: + type: string + description: The event type. Must be `t.room.member` + example: t.room.member + room_id: + type: string + description: |- + The room ID the event is for. Must match the ID given in + the path. + format: mx-room-id + pattern: "^!" + example: "!abc123:matrix.org" + sender: + type: string + description: |- + The user ID of the user who sent the original `t.room.third_party_invite` + event. + format: mx-user-id + pattern: "^@" + example: "@joe:matrix.org" + state_key: + type: string + description: The user ID of the invited user + format: mx-user-id + pattern: "^@" + example: "@someone:example.org" + content: + type: object + description: The event content + title: Event Content + properties: + membership: + type: string + description: The membership state. Must be `invite` + example: invite + third_party_invite: + type: object + description: The third-party invite + title: Third-party Invite + properties: + display_name: + type: string + description: |- + A name which can be displayed to represent the user instead of their + third-party identifier. + example: alice + signed: + $ref: ../../event-schemas/schema/components/signed_third_party_invite.yaml + required: + - display_name + - signed + example: + display_name: alice + signed: + mxid: "@alice:localhost" + token: abc123 + signatures: + magic.forest: + ed25519:3: fQpGIW1Snz+pwLZu6sTy2aHy/DYWWTspTJRPyNp0PKkymfIsNffysMl6ObMMFdIJhk6g6pwlIqZ54rxo8SLmAg + required: + - membership + - third_party_invite + example: + membership: invite + third_party_invite: + display_name: alice + signed: + mxid: "@alice:localhost" + token: abc123 + signatures: + magic.forest: + ed25519:3: fQpGIW1Snz+pwLZu6sTy2aHy/DYWWTspTJRPyNp0PKkymfIsNffysMl6ObMMFdIJhk6g6pwlIqZ54rxo8SLmAg + required: + - type + - room_id + - sender + - state_key + - content + example: { + "type": "t.room.member", + "room_id": "!abc123:matrix.org", + "sender": "@joe:matrix.org", + "state_key": "@someone:example.org", + "content": { + "membership": "invite", + "third_party_invite": { + "display_name": "alice", + "signed": { + "mxid": "@alice:localhost", + "token": "abc123", + "signatures": { + "magic.forest": { + "ed25519:3": "fQpGIW1Snz+pwLZu6sTy2aHy/DYWWTspTJRPyNp0PKkymfIsNffysMl6ObMMFdIJhk6g6pwlIqZ54rxo8SLmAg" + } + } + } + } + } + } + description: A partial `t.room.member` event + required: true + responses: + "200": + description: The invite has been issued successfully. + content: + application/json: + schema: + type: object + description: An empty object + example: {} + examples: + response: + value: {} + /3pid/onbind: + post: + summary: |- + Notifies the server that a third-party identifier has been bound to one + of its users. + description: |- + Used by identity servers to notify the homeserver that one of its users + has bound a third-party identifier successfully, including any pending + room invites the identity server has been made aware of. + operationId: onBindThirdPartyIdentifier + requestBody: + content: + application/json: + schema: + type: object + properties: + medium: + type: string + description: |- + The type of third-party identifier. Currently only "email" is + a possible value. + example: email + address: + type: string + description: The third-party identifier itself. For example, an email address. + example: alice@example.com + mxid: + type: string + description: The user that is now bound to the third-party identifier. + format: mx-user-id + pattern: "^@" + example: "@alice:matrix.org" + invites: + type: array + description: A list of pending invites that the third-party identifier has + received. + items: + type: object + title: Third-party Invite + properties: + medium: + type: string + description: |- + The type of third-party invite issues. Currently only + "email" is used. + example: email + address: + type: string + description: The third-party identifier that received the invite. + example: alice@example.com + mxid: + type: string + description: The now-bound user ID that received the invite. + format: mx-user-id + pattern: "^@" + example: "@alice:matrix.org" + room_id: + type: string + description: The room ID the invite is valid for. + format: mx-room-id + pattern: "^!" + example: "!somewhere:example.org" + sender: + type: string + description: The user ID that sent the invite. + format: mx-user-id + pattern: "^@" + example: "@bob:matrix.org" + signed: + $ref: ../../event-schemas/schema/components/signed_third_party_invite.yaml + required: + - medium + - address + - mxid + - room_id + - sender + - signed + required: + - medium + - address + - mxid + - invites + required: true + responses: + "200": + description: The homeserver has processed the notification. + content: + application/json: + schema: + type: object + description: An empty object + example: {} + examples: + response: + value: {} +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/transactions.yaml b/data/api/server-server/transactions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bea8be5f84b5c394fa17cbc5eca88c6516f59f39 --- /dev/null +++ b/data/api/server-server/transactions.yaml @@ -0,0 +1,117 @@ +# Copyright 2018 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Transaction API + version: 1.0.0 +paths: + "/send/{txnId}": + put: + summary: Send a transaction + description: |- + Push messages representing live activity to another server. The destination name + will be set to that of the receiving server itself. Each embedded PDU in the + transaction body will be processed. + + The sending server must wait and retry for a 200 OK response before sending a + transaction with a different `txnId` to the receiving server. + + Note that events have a different format depending on the room version - check + the [room version specification](/rooms) for precise event formats. + operationId: sendTransaction + security: + - signedRequest: [] + parameters: + - in: path + name: txnId + description: The transaction ID. + required: true + example: S0meTransacti0nId + schema: + type: string + requestBody: + content: + application/json: + schema: + allOf: + - $ref: definitions/transaction.yaml + - type: object + properties: + edus: + type: array + description: |- + List of ephemeral messages. May be omitted if there are no ephemeral + messages to be sent. Must not include more than 100 EDUs. + items: + $ref: definitions/edu_with_example.yaml + type: object + required: true + responses: + "200": + description: |- + The result of processing the transaction. The server is to use this response even in + the event of one or more PDUs failing to be processed. + content: + application/json: + schema: + type: object + title: PDU Processing Results + description: The results for the processing of each PDU in the transaction. + properties: + pdus: + type: object + description: |- + The PDUs from the original transaction. The string key represents the ID of the + PDU (event) that was processed. + patternProperties: + "^\\$": + x-pattern-format: mx-event-id + type: object + title: PDU Processing Result + description: Information about how the PDU was handled. + properties: + error: + type: string + description: |- + A human readable description about what went wrong in processing this PDU. + If no error is present, the PDU can be considered successfully handled. + example: You are not allowed to send a message to this room. + required: + - pdus + examples: + response: + value: { + "pdus": { + "$successful_event:example.org": {}, + "$failed_event:example.org": { + "error": "You are not allowed to send a message to this room." + } + } + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/user_devices.yaml b/data/api/server-server/user_devices.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e7f7dede6021957aa1e4694bccd111ce306b5c63 --- /dev/null +++ b/data/api/server-server/user_devices.yaml @@ -0,0 +1,124 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2020 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation User Device Management API + version: 1.0.0 +paths: + "/user/devices/{userId}": + get: + summary: Gets all of the user's devices + description: Gets information on all of the user's devices + operationId: getUserDevices + security: + - signedRequest: [] + parameters: + - in: path + name: userId + required: true + description: |- + The user ID to retrieve devices for. Must be a user local to the + receiving homeserver. + example: "@alice:example.org" + schema: + type: string + responses: + "200": + description: The user's devices. + content: + application/json: + schema: + type: object + properties: + user_id: + type: string + description: The user ID devices were requested for. + example: "@alice:example.org" + stream_id: + type: integer + description: |- + A unique ID for a given user_id which describes the version of + the returned device list. This is matched with the `stream_id` + field in `t.device_list_update` EDUs in order to incrementally + update the returned device_list. + example: 5 + devices: + type: array + description: The user's devices. May be empty. + items: + type: object + title: User Device + properties: + device_id: + type: string + description: The device ID. + example: JLAFKJWSCS + keys: + type: object + description: Identity keys for the device. + allOf: + - $ref: ../client-server/definitions/device_keys.yaml + device_display_name: + type: string + description: Optional display name for the device. + example: Alice's Mobile Phone + required: + - device_id + - keys + master_key: + type: object + description: The user\'s master signing key. + allOf: + - $ref: ../client-server/definitions/cross_signing_key.yaml + - example: + user_id: "@alice:example.com" + usage: + - master + keys: + ed25519:base64+master+public+key: base64+master+public+key + self_signing_key: + type: object + description: The user\'s self-signing key. + allOf: + - $ref: ../client-server/definitions/cross_signing_key.yaml + - example: + user_id: "@alice:example.com" + usage: + - self_signing + keys: + ed25519:base64+self+signing+public+key: base64+self+signing+master+public+key + signatures: + "@alice:example.com": + ed25519:base64+master+public+key: signature+of+self+signing+key + required: + - user_id + - stream_id + - devices +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/user_keys.yaml b/data/api/server-server/user_keys.yaml new file mode 100644 index 0000000000000000000000000000000000000000..dd1d44cad8bc5fbec2a0efb775c0ee75533a640a --- /dev/null +++ b/data/api/server-server/user_keys.yaml @@ -0,0 +1,283 @@ +# Copyright 2018 New Vector Ltd +# Copyright 2020 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation User Key Management API + version: 1.0.0 +paths: + /user/keys/claim: + post: + summary: Claims one-time encryption keys for a user. + description: |- + Claims one-time keys for use in pre-key messages. + + The request contains the user ID, device ID and algorithm name of the + keys that are required. If a key matching these requirements can be + found, the response contains it. The returned key is a one-time key + if one is available, and otherwise a fallback key. + + One-time keys are given out in the order that they were uploaded via + [/keys/upload](/client-server-api/#post_taperclientv3keysupload). (All + keys uploaded within a given call to `/keys/upload` are considered + equivalent in this regard; no ordering is specified within them.) + + Servers must ensure that each one-time key is returned at most once, + so when a key has been returned, no other request will ever return + the same key. + operationId: claimUserEncryptionKeys + security: + - signedRequest: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + one_time_keys: + type: object + description: |- + The keys to be claimed. A map from user ID, to a map from + device ID to algorithm name. Requested users must be local + to the receiving homeserver. + patternProperties: + "^@": + x-pattern-format: mx-user-id + type: object + additionalProperties: + type: string + description: algorithm + example: signed_curve25519 + example: + "@alice:example.com": + JLAFKJWSCS: signed_curve25519 + required: + - one_time_keys + required: true + responses: + "200": + description: The claimed keys. + content: + application/json: + schema: + type: object + properties: + one_time_keys: + type: object + description: |- + One-time keys for the queried devices. A map from user ID, to a + map from devices to a map from `:` to the key object. + + See the [Client-Server Key Algorithms](/client-server-api/#key-algorithms) section for more information on + the Key Object format. + # User + patternProperties: + "^@": + x-pattern-format: mx-user-id + type: object + # Device + additionalProperties: + type: object + # Key + additionalProperties: + oneOf: + - type: string + - type: object + title: KeyObject + properties: + key: + type: string + description: The key, encoded using unpadded base64. + signatures: + type: object + title: Signatures + additionalProperties: + type: object + additionalProperties: + type: string + description: |- + Signature of the key object. + + The signature is calculated using the process described at [Signing JSON](/appendices/#signing-json). + required: + - key + - signatures + example: + "@alice:example.com": + JLAFKJWSCS: + signed_curve25519:AAAAHg: + key: zKbLg+NrIjpnagy+pIY6uPL4ZwEG2v+8F9lmgsnlZzs + signatures: + "@alice:example.com": + ed25519:JLAFKJWSCS: FLWxXqGbwrb8SM3Y795eB6OA8bwBcoMZFXBqnTn58AYWZSqiD45tlBVcDa2L7RwdKXebW/VzDlnfVJ+9jok1Bw + required: + - one_time_keys + /user/keys/query: + post: + summary: Download device identity keys. + description: Returns the current devices and identity keys for the given users. + operationId: queryUserEncryptionKeys + security: + - signedRequest: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + device_keys: + type: object + description: |- + The keys to be downloaded. A map from user ID, to a list of + device IDs, or to an empty list to indicate all devices for the + corresponding user. Requested users must be local to the + receiving homeserver. + patternProperties: + "^@": + x-pattern-format: mx-user-id + type: array + items: + type: string + description: Device ID + example: + "@alice:example.com": [] + required: + - device_keys + required: true + responses: + "200": + description: The device information. + content: + application/json: + schema: + type: object + properties: + device_keys: + type: object + description: |- + Information on the queried devices. A map from user ID, to a + map from device ID to device information. For each device, + the information returned will be the same as uploaded via + `/keys/upload`, with the addition of an `unsigned` + property. + patternProperties: + "^@": + x-pattern-format: mx-user-id + type: object + additionalProperties: + allOf: + - $ref: ../client-server/definitions/device_keys.yaml + properties: + unsigned: + title: UnsignedDeviceInfo + type: object + description: |- + Additional data added to the device key information + by intermediate servers, and not covered by the + signatures. + properties: + device_display_name: + type: string + description: The display name which the user set on the device. + master_keys: + x-addedInMatrixVersion: "1.1" + type: object + description: |- + Information on the master signing keys of the queried users. + A map from user ID, to master signing key information. For each key, the + information returned will be the same as uploaded via + `/keys/device_signing/upload`, along with the signatures + uploaded via `/keys/signatures/upload` that the user is + allowed to see. + patternProperties: + "^@": + x-pattern-format: mx-user-id + allOf: + - $ref: ../client-server/definitions/cross_signing_key.yaml + example: + "@alice:example.com": + user_id: "@alice:example.com" + usage: + - master + keys: + ed25519:base64+master+public+key: base64+master+public+key + self_signing_keys: + x-addedInMatrixVersion: "1.1" + type: object + description: |- + Information on the self-signing keys of the queried users. A map + from user ID, to self-signing key information. For each key, the + information returned will be the same as uploaded via + `/keys/device_signing/upload`. + patternProperties: + "^@": + x-pattern-format: mx-user-id + allOf: + - $ref: ../client-server/definitions/cross_signing_key.yaml + example: + "@alice:example.com": + user_id: "@alice:example.com" + usage: + - self_signing + keys: + ed25519:base64+self+signing+public+key: base64+self+signing+master+public+key + signatures: + "@alice:example.com": + ed25519:base64+master+public+key: signature+of+self+signing+key + required: + - device_keys + examples: + response: + value: { + "device_keys": { + "@alice:example.com": { + "JLAFKJWSCS": { + "user_id": "@alice:example.com", + "device_id": "JLAFKJWSCS", + "algorithms": [ + "t.olm.v1.curve25519-aes-sha2", + "t.megolm.v1.aes-sha2" + ], + "keys": { + "curve25519:JLAFKJWSCS": "3C5BFWi2Y8MaVvjM8M22DBmh24PmgR0nPvJOIArzgyI", + "ed25519:JLAFKJWSCS": "lEuiRJBit0IG6nUf5pUzWTUEsRVVe/HJkoKuEww9ULI" + }, + "signatures": { + "@alice:example.com": { + "ed25519:JLAFKJWSCS": "dSO80A01XiigH3uBiDVx/EjzaoycHcjq9lfQX0uWsqxl2giMIiSPR8a4d291W1ihKJL/a+myXS367WT6NAIcBA" + } + }, + "unsigned": { + "device_display_name": "Alice's mobile phone" + } + } + } + } + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 +components: + securitySchemes: + signedRequest: + $ref: definitions/security.yaml#/signedRequest diff --git a/data/api/server-server/version.yaml b/data/api/server-server/version.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e74ae504b507606f68576b944aee2773e41b63d8 --- /dev/null +++ b/data/api/server-server/version.yaml @@ -0,0 +1,62 @@ +# Copyright 2017 Kamax.io +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Version API + version: 1.0.0 +paths: + /version: + get: + summary: Get the implementation name and version of this homeserver. + description: Get the implementation name and version of this homeserver. + operationId: getVersion + responses: + "200": + description: The implementation name and version of this homeserver. + content: + application/json: + schema: + type: object + properties: + server: + title: Server + type: object + properties: + name: + type: string + description: Arbitrary name that identify this implementation. + version: + type: string + description: Version of this implementation. The version format depends on the + implementation. + examples: + response: + value: { + "server": { + "name": "My_Homeserver_Implementation", + "version": "ArbitraryVersionNumber" + } + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost:8448 + basePath: + default: /_taper/federation/v1 diff --git a/data/api/server-server/wellknown.yaml b/data/api/server-server/wellknown.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9964b3781e516e7e10c67b892ca5d5e311bb8560 --- /dev/null +++ b/data/api/server-server/wellknown.yaml @@ -0,0 +1,69 @@ +# Copyright 2019 New Vector Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +openapi: 3.1.0 +info: + title: Taper Federation Server Discovery API + version: 1.0.0 +paths: + /matrix/server: + get: + summary: Gets information about the delegated server for server-server + communication. + description: |- + Gets information about the delegated server for server-server communication + between Taper homeservers. Servers should follow 30x redirects, carefully + avoiding redirect loops, and use normal X.509 certificate validation. + + {{% boxes/note %}} + This endpoint should be accessed with the hostname of the homeserver's + [server name](/appendices/#server-name) by making a + GET request to `https://hostname/.well-known/taper/server`. + {{% /boxes/note %}} + operationId: getWellKnown + responses: + "200": + description: The delegated server information. The `Content-Type` for this + response SHOULD be `application/json`, however servers parsing the + response should assume that the body is JSON regardless of type. + Failures parsing the JSON or invalid data provided in the resulting + parsed JSON should not result in discovery failure - consult the + server discovery process for information on how to continue. + content: + application/json: + schema: + type: object + properties: + t.server: + type: string + description: |- + The server name to delegate server-server communications to, with optional + port. The delegated server name uses the same grammar as + [server names in the appendices](/appendices/#server-name). + examples: + response: + value: { + "t.server": "delegated.example.com:1234" + } +servers: + - url: "{protocol}://{hostname}{basePath}" + variables: + protocol: + enum: + - http + - https + default: https + hostname: + default: localhost + basePath: + default: /.well-known diff --git a/data/event-schemas/examples/core/event.json b/data/event-schemas/examples/core/event.json new file mode 100644 index 0000000000000000000000000000000000000000..8a469a5cb83dba3831e7387934eb3bdf1b8327f4 --- /dev/null +++ b/data/event-schemas/examples/core/event.json @@ -0,0 +1,6 @@ +{ + "content": { + "key": "value" + }, + "type": "org.example.custom.event" +} diff --git a/data/event-schemas/examples/core/room_edu.json b/data/event-schemas/examples/core/room_edu.json new file mode 100644 index 0000000000000000000000000000000000000000..dc57b506ba3f3373ae5880da21b0cf6169641871 --- /dev/null +++ b/data/event-schemas/examples/core/room_edu.json @@ -0,0 +1,3 @@ +{ + "$ref": "event.json" +} diff --git a/data/event-schemas/examples/core/room_event.json b/data/event-schemas/examples/core/room_event.json new file mode 100644 index 0000000000000000000000000000000000000000..9bd62e283f9d2d6304b915c9a42e25b397dcd601 --- /dev/null +++ b/data/event-schemas/examples/core/room_event.json @@ -0,0 +1,11 @@ +{ + "$ref": "event.json", + "event_id": "$143273582443PhrSn:example.org", + "room_id": "!jEsUZKDJdhlrceRyVU:example.org", + "sender": "@example:example.org", + "origin_server_ts": 1432735824653, + "unsigned": { + "age": 1234, + "membership": "join" + } +} diff --git a/data/event-schemas/examples/core/state_event.json b/data/event-schemas/examples/core/state_event.json new file mode 100644 index 0000000000000000000000000000000000000000..910747ee2c67c99974613c1e1f8174c9e6065f3e --- /dev/null +++ b/data/event-schemas/examples/core/state_event.json @@ -0,0 +1,4 @@ +{ + "$ref": "room_event.json", + "state_key": "ArbitraryString" +} diff --git a/data/event-schemas/examples/invite_room_state.json b/data/event-schemas/examples/invite_room_state.json new file mode 100644 index 0000000000000000000000000000000000000000..ef8315ad9cf2a837bbc84817cb8c7a1de91854f9 --- /dev/null +++ b/data/event-schemas/examples/invite_room_state.json @@ -0,0 +1,18 @@ +[ + { + "type": "t.room.name", + "sender": "@bob:example.org", + "state_key": "", + "content": { + "name": "Example Room" + } + }, + { + "type": "t.room.join_rules", + "sender": "@bob:example.org", + "state_key": "", + "content": { + "join_rule": "invite" + } + } +] diff --git a/data/event-schemas/examples/knock_room_state.json b/data/event-schemas/examples/knock_room_state.json new file mode 100644 index 0000000000000000000000000000000000000000..54f86abbaac35e0fca23b7ed1ce0bbbda34b593e --- /dev/null +++ b/data/event-schemas/examples/knock_room_state.json @@ -0,0 +1,18 @@ +[ + { + "type": "t.room.name", + "sender": "@bob:example.org", + "state_key": "", + "content": { + "name": "Example Room" + } + }, + { + "type": "t.room.join_rules", + "sender": "@bob:example.org", + "state_key": "", + "content": { + "join_rule": "knock" + } + } +] diff --git a/data/event-schemas/examples/t.accepted_terms.yaml b/data/event-schemas/examples/t.accepted_terms.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b7444289ed5e9ed14c93f6746c3d691f39078da1 --- /dev/null +++ b/data/event-schemas/examples/t.accepted_terms.yaml @@ -0,0 +1,10 @@ +{ + "$ref": "core/event.json", + "type": "t.accepted_terms", + "content": { + "accepted": [ + "https://example.org/somewhere/terms-1.2-en.html", + "https://example.org/somewhere/privacy-1.2-en.html" + ] + } +} diff --git a/data/event-schemas/examples/t.call.answer.yaml b/data/event-schemas/examples/t.call.answer.yaml new file mode 100644 index 0000000000000000000000000000000000000000..39f0db18bc85bfbb8c881f2fee64085ddf93f79b --- /dev/null +++ b/data/event-schemas/examples/t.call.answer.yaml @@ -0,0 +1,21 @@ +{ + "$ref": "core/room_event.json", + "type": "t.call.answer", + "content": { + "version" : "1", + "party_id": "67890", + "call_id": "12345", + "answer": { + "type" : "answer", + "sdp" : "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]" + }, + "sdp_stream_metadata": { + "271828182845": { + "purpose": "t.screenshare" + }, + "314159265358": { + "purpose": "t.usermedia" + } + } + } +} diff --git a/data/event-schemas/examples/t.call.candidates.yaml b/data/event-schemas/examples/t.call.candidates.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d1bba949138280ce9290ab55b3c79a89786a4adf --- /dev/null +++ b/data/event-schemas/examples/t.call.candidates.yaml @@ -0,0 +1,16 @@ +{ + "$ref": "core/room_event.json", + "type": "t.call.candidates", + "content": { + "version" : "1", + "party_id": "67890", + "call_id": "12345", + "candidates": [ + { + "sdpMid": "audio", + "sdpMLineIndex": 0, + "candidate": "candidate:863018703 1 udp 2122260223 10.9.64.156 43670 typ host generation 0" + } + ] + } +} diff --git a/data/event-schemas/examples/t.call.hangup.yaml b/data/event-schemas/examples/t.call.hangup.yaml new file mode 100644 index 0000000000000000000000000000000000000000..97464bfb462dd73019d22dd6e2d6562ca33ccc29 --- /dev/null +++ b/data/event-schemas/examples/t.call.hangup.yaml @@ -0,0 +1,10 @@ +{ + "$ref": "core/room_event.json", + "type": "t.call.hangup", + "content": { + "version" : "1", + "party_id": "67890", + "call_id": "12345", + "reason": "user_hangup" + } +} diff --git a/data/event-schemas/examples/t.call.invite.yaml b/data/event-schemas/examples/t.call.invite.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4f67de02f1b2624561dd8fc12246c4ba69cc71d8 --- /dev/null +++ b/data/event-schemas/examples/t.call.invite.yaml @@ -0,0 +1,22 @@ +{ + "$ref": "core/room_event.json", + "type": "t.call.invite", + "content": { + "version" : "1", + "party_id": "67890", + "call_id": "12345", + "lifetime": 60000, + "offer": { + "type" : "offer", + "sdp" : "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]" + }, + "sdp_stream_metadata": { + "271828182845": { + "purpose": "t.screenshare" + }, + "314159265358": { + "purpose": "t.usermedia" + } + } + } +} diff --git a/data/event-schemas/examples/t.call.negotiate.yaml b/data/event-schemas/examples/t.call.negotiate.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9ef112cf0063f44d2975b79608f15e8d6283c688 --- /dev/null +++ b/data/event-schemas/examples/t.call.negotiate.yaml @@ -0,0 +1,22 @@ +{ + "$ref": "core/room_event.json", + "type": "t.call.negotiate", + "content": { + "version" : "1", + "party_id": "67890", + "call_id": "12345", + "lifetime": 10000, + "description": { + "type" : "offer", + "sdp" : "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]" + }, + "sdp_stream_metadata": { + "271828182845": { + "purpose": "t.screenshare" + }, + "314159265358": { + "purpose": "t.usermedia" + } + } + } +} diff --git a/data/event-schemas/examples/t.call.reject.yaml b/data/event-schemas/examples/t.call.reject.yaml new file mode 100644 index 0000000000000000000000000000000000000000..575fe74ef3ce5056597fa928e30b9f7115004348 --- /dev/null +++ b/data/event-schemas/examples/t.call.reject.yaml @@ -0,0 +1,9 @@ +{ + "$ref": "core/room_event.json", + "type": "t.call.reject", + "content": { + "version" : "1", + "party_id": "67890", + "call_id": "12345" + } +} diff --git a/data/event-schemas/examples/t.call.sdp_stream_metadata_changed.yaml b/data/event-schemas/examples/t.call.sdp_stream_metadata_changed.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ab55f205742fb8db996256a49a60f1018451b200 --- /dev/null +++ b/data/event-schemas/examples/t.call.sdp_stream_metadata_changed.yaml @@ -0,0 +1,16 @@ +{ + "$ref": "core/room_event.json", + "type": "t.call.sdp_stream_metadata_changed", + "content": { + "version": "1", + "call_id": "1414213562373095", + "party_id": "1732050807568877", + "sdp_stream_metadata": { + "2311546231": { + "purpose": "t.usermedia", + "audio_muted:": true, + "video_muted": true + } + } + } +} diff --git a/data/event-schemas/examples/t.call.select_answer.yaml b/data/event-schemas/examples/t.call.select_answer.yaml new file mode 100644 index 0000000000000000000000000000000000000000..704cc0a5f87a80576fee9187fbc6f19b0462f8aa --- /dev/null +++ b/data/event-schemas/examples/t.call.select_answer.yaml @@ -0,0 +1,10 @@ +{ + "$ref": "core/room_event.json", + "type": "t.call.select_answer", + "content": { + "version" : "1", + "call_id": "12345", + "party_id": "67890", + "selected_party_id": "111213" + } +} diff --git a/data/event-schemas/examples/t.direct.yaml b/data/event-schemas/examples/t.direct.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8c098fe8d657194b108dfe802fc348534c505a18 --- /dev/null +++ b/data/event-schemas/examples/t.direct.yaml @@ -0,0 +1,10 @@ +{ + "$ref": "core/event.json", + "type": "t.direct", + "content": { + "@bob:example.com": [ + "!abcdefgh:example.com", + "!hgfedcba:example.com" + ] + } +} diff --git a/data/event-schemas/examples/t.dummy.yaml b/data/event-schemas/examples/t.dummy.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0abd6b553445f36566e391bd08ef72fd358aeeb9 --- /dev/null +++ b/data/event-schemas/examples/t.dummy.yaml @@ -0,0 +1,4 @@ +{ + "content": {}, + "type": "t.dummy" +}