Merge branch 'master' into rav/clarify_event_signing

This commit is contained in:
Richard van der Hoff 2018-08-30 22:48:56 +01:00 committed by GitHub
commit 0f84c69805
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
84 changed files with 667 additions and 451 deletions

View file

@ -0,0 +1,18 @@
# 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.
homeserverAccessToken:
type: apiKey
description: The ``hs_token`` provided by the application service's registration.
name: access_token
in: query

View file

@ -19,13 +19,15 @@ host: localhost:8008
schemes: schemes:
- https - https
- http - http
basePath: "/" basePath: /_matrix/app/v1
consumes: consumes:
- application/json - application/json
produces: produces:
- application/json - application/json
securityDefinitions:
$ref: definitions/security.yaml
paths: paths:
"/_matrix/app/unstable/thirdparty/protocol/{protocol}": "/thirdparty/protocol/{protocol}":
get: get:
summary: Retrieve metadata about a specific protocol that the application service supports. summary: Retrieve metadata about a specific protocol that the application service supports.
description: |- description: |-
@ -33,6 +35,8 @@ paths:
with specific information about the various third party networks that with specific information about the various third party networks that
an application service supports. an application service supports.
operationId: getProtocolMetadata operationId: getProtocolMetadata
security:
- homeserverAccessToken: []
parameters: parameters:
- in: path - in: path
name: protocol name: protocol
@ -72,7 +76,7 @@ paths:
} }
schema: schema:
$ref: ../client-server/definitions/errors/error.yaml $ref: ../client-server/definitions/errors/error.yaml
"/_matrix/app/unstable/thirdparty/user/{protocol}": "/thirdparty/user/{protocol}":
get: get:
summary: Retrieve the Matrix User ID of a corresponding third party user. summary: Retrieve the Matrix User ID of a corresponding third party user.
description: |- description: |-
@ -80,6 +84,8 @@ paths:
User ID linked to a user on the third party network, given a set of User ID linked to a user on the third party network, given a set of
user parameters. user parameters.
operationId: queryUserByProtocol operationId: queryUserByProtocol
security:
- homeserverAccessToken: []
parameters: parameters:
- in: path - in: path
name: protocol name: protocol
@ -125,12 +131,14 @@ paths:
} }
schema: schema:
$ref: ../client-server/definitions/errors/error.yaml $ref: ../client-server/definitions/errors/error.yaml
"/_matrix/app/unstable/thirdparty/location/{protocol}": "/thirdparty/location/{protocol}":
get: get:
summary: Retrieve Matrix-side portal rooms leading to a third party location. summary: Retrieve Matrix-side portal rooms leading to a third party location.
description: |- description: |-
Retrieve a list of Matrix portal rooms that lead to the matched third party location. Retrieve a list of Matrix portal rooms that lead to the matched third party location.
operationId: queryLocationByProtocol operationId: queryLocationByProtocol
security:
- homeserverAccessToken: []
parameters: parameters:
- in: path - in: path
name: protocol name: protocol
@ -176,13 +184,15 @@ paths:
} }
schema: schema:
$ref: ../client-server/definitions/errors/error.yaml $ref: ../client-server/definitions/errors/error.yaml
"/_matrix/app/unstable/thirdparty/location": "/thirdparty/location":
get: get:
summary: Reverse-lookup third party locations given a Matrix room alias. summary: Reverse-lookup third party locations given a Matrix room alias.
description: |- description: |-
Retrieve an array of third party network locations from a Matrix room Retrieve an array of third party network locations from a Matrix room
alias. alias.
operationId: queryLocationByAlias operationId: queryLocationByAlias
security:
- homeserverAccessToken: []
parameters: parameters:
- in: query - in: query
name: alias name: alias
@ -221,12 +231,14 @@ paths:
} }
schema: schema:
$ref: ../client-server/definitions/errors/error.yaml $ref: ../client-server/definitions/errors/error.yaml
"/_matrix/app/unstable/thirdparty/user": "/thirdparty/user":
get: get:
summary: Reverse-lookup third party users given a Matrix User ID. summary: Reverse-lookup third party users given a Matrix User ID.
description: |- description: |-
Retrieve an array of third party users from a Matrix User ID. Retrieve an array of third party users from a Matrix User ID.
operationId: queryUserByID operationId: queryUserByID
security:
- homeserverAccessToken: []
parameters: parameters:
- in: query - in: query
name: userid name: userid

View file

@ -20,11 +20,13 @@ host: localhost:8008
schemes: schemes:
- https - https
- http - http
basePath: "/" basePath: /_matrix/app/v1
consumes: consumes:
- application/json - application/json
produces: produces:
- application/json - application/json
securityDefinitions:
$ref: definitions/security.yaml
paths: paths:
"/rooms/{roomAlias}": "/rooms/{roomAlias}":
get: get:
@ -36,6 +38,8 @@ paths:
homeserver will send this request when it receives a request to join a homeserver will send this request when it receives a request to join a
room alias within the application service's namespace. room alias within the application service's namespace.
operationId: queryRoomByAlias operationId: queryRoomByAlias
security:
- homeserverAccessToken: []
parameters: parameters:
- in: path - in: path
name: roomAlias name: roomAlias

View file

@ -20,11 +20,13 @@ host: localhost:8008
schemes: schemes:
- https - https
- http - http
basePath: "/" basePath: /_matrix/app/v1
consumes: consumes:
- application/json - application/json
produces: produces:
- application/json - application/json
securityDefinitions:
$ref: definitions/security.yaml
paths: paths:
"/users/{userId}": "/users/{userId}":
get: get:
@ -36,6 +38,8 @@ paths:
send this request when it receives an event for an unknown user ID in send this request when it receives an event for an unknown user ID in
the application service's namespace, such as a room invite. the application service's namespace, such as a room invite.
operationId: queryUserById operationId: queryUserById
security:
- homeserverAccessToken: []
parameters: parameters:
- in: path - in: path
name: userId name: userId

View file

@ -20,9 +20,11 @@ host: localhost:8008
schemes: schemes:
- https - https
- http - http
basePath: "/" basePath: /_matrix/app/v1
produces: produces:
- application/json - application/json
securityDefinitions:
$ref: definitions/security.yaml
paths: paths:
"/transactions/{txnId}": "/transactions/{txnId}":
put: put:
@ -35,6 +37,8 @@ paths:
from message events via the presence of a ``state_key``, rather than from message events via the presence of a ``state_key``, rather than
via the event type. via the event type.
operationId: sendTransaction operationId: sendTransaction
security:
- homeserverAccessToken: []
parameters: parameters:
- in: path - in: path
name: txnId name: txnId

View file

@ -87,6 +87,16 @@ paths:
type: string type: string
description: |- description: |-
A unique identifier for the event. A unique identifier for the event.
403:
description: |-
The sender doesn't have permission to send the event into the room.
schema:
$ref: "definitions/errors/error.yaml"
examples:
application/json: {
"errcode": "M_FORBIDDEN",
"error": "You do not have permission to send the event."
}
tags: tags:
- Room participation - Room participation
"/rooms/{roomId}/state/{eventType}": "/rooms/{roomId}/state/{eventType}":
@ -142,5 +152,15 @@ paths:
type: string type: string
description: |- description: |-
A unique identifier for the event. A unique identifier for the event.
403:
description: |-
The sender doesn't have permission to send the event into the room.
schema:
$ref: "definitions/errors/error.yaml"
examples:
application/json: {
"errcode": "M_FORBIDDEN",
"error": "You do not have permission to send the event."
}
tags: tags:
- Room participation - Room participation

View file

@ -77,13 +77,14 @@ paths:
- in: query - in: query
name: set_presence name: set_presence
type: string type: string
enum: ["offline"] enum: ["offline", "online", "unavailable"]
description: |- description: |-
Controls whether the client is automatically marked as online by Controls whether the client is automatically marked as online by
polling this API. If this parameter is omitted then the client is polling this API. If this parameter is omitted then the client is
automatically marked as online when it uses this API. Otherwise if automatically marked as online when it uses this API. Otherwise if
the parameter is set to "offline" then the client is not marked as the parameter is set to "offline" then the client is not marked as
being online when it uses this API. being online when it uses this API. When set to "unavailable", the
client is marked as being idle.
x-example: "offline" x-example: "offline"
- in: query - in: query
name: timeout name: timeout

View file

@ -18,15 +18,17 @@ info:
host: localhost:8090 host: localhost:8090
schemes: schemes:
- https - https
- http
basePath: /_matrix/identity/api/v1 basePath: /_matrix/identity/api/v1
consumes:
- application/json
produces: produces:
- application/json - application/json
paths: paths:
"/3pid/getValidated3pid": "/3pid/getValidated3pid":
get: get:
summary: Check whether ownership of a 3pid was validated. summary: Check whether ownership of a 3pid was validated.
description: A client can check whether ownership of a 3pid was validated description: |-
Determines if a given 3pid has been validated by a user.
operationId: getValidated3pid operationId: getValidated3pid
parameters: parameters:
- in: query - in: query
@ -61,7 +63,9 @@ paths:
description: The address of the 3pid being looked up. description: The address of the 3pid being looked up.
validated_at: validated_at:
type: integer type: integer
description: Timestamp indicating the time that the 3pid was validated. description: |-
Timestamp, in milliseconds, indicating the time that the 3pid
was validated.
required: ['medium', 'address', 'validated_at'] required: ['medium', 'address', 'validated_at']
400: 400:
description: |- description: |-
@ -78,7 +82,7 @@ paths:
schema: schema:
$ref: "../client-server/definitions/errors/error.yaml" $ref: "../client-server/definitions/errors/error.yaml"
404: 404:
description: The Session ID or client secret were not found description: The Session ID or client secret were not found.
examples: examples:
application/json: { application/json: {
"errcode": "M_NO_VALID_SESSION", "errcode": "M_NO_VALID_SESSION",
@ -95,7 +99,7 @@ paths:
Future calls to ``/lookup`` for any of the session\'s 3pids will return Future calls to ``/lookup`` for any of the session\'s 3pids will return
this association. this association.
Note: for backwards compatibility with older versions of this Note: for backwards compatibility with previous drafts of this
specification, the parameters may also be specified as specification, the parameters may also be specified as
``application/x-form-www-urlencoded`` data. However, this usage is ``application/x-form-www-urlencoded`` data. However, this usage is
deprecated. deprecated.
@ -132,7 +136,6 @@ paths:
"not_before": 1428825849161, "not_before": 1428825849161,
"not_after": 4582425849161, "not_after": 4582425849161,
"ts": 1428825849161, "ts": 1428825849161,
"signatures": { "signatures": {
"matrix.org": { "matrix.org": {
"ed25519:0": "ENiU2YORYUJgE6WBMitU0mppbQjidDLanAusj8XS2nVRHPu+0t42OKA/r6zV6i2MzUbNQ3c3MiLScJuSsOiVDQ" "ed25519:0": "ENiU2YORYUJgE6WBMitU0mppbQjidDLanAusj8XS2nVRHPu+0t42OKA/r6zV6i2MzUbNQ3c3MiLScJuSsOiVDQ"
@ -162,7 +165,10 @@ paths:
description: The unix timestamp at which the association was verified. description: The unix timestamp at which the association was verified.
signatures: signatures:
type: object type: object
description: The signatures of the verifying identity services which show that the association should be trusted, if you trust the verifying identity services. description: |-
The signatures of the verifying identity services which show that the
association should be trusted, if you trust the verifying identity
services.
$ref: "../../schemas/server-signatures.yaml" $ref: "../../schemas/server-signatures.yaml"
required: required:
- address - address

View file

@ -18,8 +18,9 @@ info:
host: localhost:8090 host: localhost:8090
schemes: schemes:
- https - https
- http
basePath: /_matrix/identity/api/v1 basePath: /_matrix/identity/api/v1
consumes:
- application/json
produces: produces:
- application/json - application/json
paths: paths:
@ -34,13 +35,13 @@ paths:
that that user was able to read the email for that email address, and that that user was able to read the email for that email address, and
so we validate ownership of the email address. so we validate ownership of the email address.
Note that Home Servers offer APIs that proxy this API, adding Note that homeservers offer APIs that proxy this API, adding
additional behaviour on top, for example, additional behaviour on top, for example,
``/register/email/requestToken`` is designed specifically for use when ``/register/email/requestToken`` is designed specifically for use when
registering an account and therefore will inform the user if the email registering an account and therefore will inform the user if the email
address given is already registered on the server. address given is already registered on the server.
Note: for backwards compatibility with older versions of this Note: for backwards compatibility with previous drafts of this
specification, the parameters may also be specified as specification, the parameters may also be specified as
``application/x-form-www-urlencoded`` data. However, this usage is ``application/x-form-www-urlencoded`` data. However, this usage is
deprecated. deprecated.
@ -58,7 +59,7 @@ paths:
properties: properties:
client_secret: client_secret:
type: string type: string
description: A unique string used to identify the validation attempt description: A unique string used to identify the validation attempt.
email: email:
type: string type: string
description: The email address to validate. description: The email address to validate.
@ -119,7 +120,7 @@ paths:
associate the email address with any Matrix user ID. Specifically, associate the email address with any Matrix user ID. Specifically,
calls to ``/lookup`` will not show a binding. calls to ``/lookup`` will not show a binding.
Note: for backwards compatibility with older versions of this Note: for backwards compatibility with previous drafts of this
specification, the parameters may also be specified as specification, the parameters may also be specified as
``application/x-form-www-urlencoded`` data. However, this usage is ``application/x-form-www-urlencoded`` data. However, this usage is
deprecated. deprecated.

View file

@ -18,8 +18,9 @@ info:
host: localhost:8090 host: localhost:8090
schemes: schemes:
- https - https
- http
basePath: /_matrix/identity/api/v1 basePath: /_matrix/identity/api/v1
consumes:
- application/json
produces: produces:
- application/json - application/json
paths: paths:
@ -29,7 +30,7 @@ paths:
description: |- description: |-
Sign invitation details. Sign invitation details.
The identity server will look up ``token`` which was stored in a call The identity service will look up ``token`` which was stored in a call
to ``store-invite``, and fetch the sender of the invite. to ``store-invite``, and fetch the sender of the invite.
operationId: blindlySignStuff operationId: blindlySignStuff
parameters: parameters:
@ -38,24 +39,24 @@ paths:
schema: schema:
type: object type: object
example: { example: {
"mxid": "@foo:bar.com", "mxid": "@foo:bar.com",
"token": "sometoken", "token": "sometoken",
"private_key": "base64encodedkey" "private_key": "base64encodedkey"
} }
properties: properties:
mxid: mxid:
type: string type: string
description: The Matrix user ID of the user accepting the invitation. description: The Matrix user ID of the user accepting the invitation.
token: token:
type: string type: string
description: Token from the call to ``store-invite`` description: The token from the call to ``store-invite``.
private_key: private_key:
type: string type: string
description: The private key, encoded as `Unpadded base64`_. description: The private key, encoded as `Unpadded base64`_.
required: ["mxid", "token", "private_key"] required: ["mxid", "token", "private_key"]
responses: responses:
200: 200:
description: The signedjson of the mxid, sender, and token. description: The signed JSON of the mxid, sender, and token.
schema: schema:
type: object type: object
properties: properties:
@ -85,7 +86,7 @@ paths:
"token": "abc123" "token": "abc123"
} }
404: 404:
description: Token was not found. description: The token was not found.
examples: examples:
application/json: { application/json: {
"errcode": "M_UNRECOGNIZED", "errcode": "M_UNRECOGNIZED",

View file

@ -1,6 +1,7 @@
# Copyright 2016 OpenMarket Ltd # Copyright 2016 OpenMarket Ltd
# Copyright 2017 Kamax.io # Copyright 2017 Kamax.io
# Copyright 2017 New Vector Ltd # Copyright 2017 New Vector Ltd
# Copyright 2018 New Vector Ltd
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -20,8 +21,9 @@ info:
host: localhost:8090 host: localhost:8090
schemes: schemes:
- https - https
- http
basePath: /_matrix/identity/api/v1 basePath: /_matrix/identity/api/v1
consumes:
- application/json
produces: produces:
- application/json - application/json
paths: paths:
@ -46,7 +48,7 @@ paths:
responses: responses:
200: 200:
description: description:
The association for that 3pid, or the empty object if no association is known. The association for that 3pid, or an empty object if no association is known.
examples: examples:
application/json: { application/json: {
"address": "louise@bobs.burgers", "address": "louise@bobs.burgers",
@ -66,10 +68,10 @@ paths:
properties: properties:
address: address:
type: string type: string
description: The 3pid address of the user being looked up. description: The 3pid address of the user being looked up, matching the address requested.
medium: medium:
type: string type: string
description: The literal string "email". description: A medium from the `3PID Types`_ Appendix, matching the medium requested.
mxid: mxid:
type: string type: string
description: The Matrix user ID associated with the 3pid. description: The Matrix user ID associated with the 3pid.
@ -126,7 +128,9 @@ paths:
#- type: 3PID Address #- type: 3PID Address
- type: string - type: string
- type: string - type: string
description: an array of arrays containing the `3PID Types`_ with the ``medium`` in first position and the ``address`` in second position. description: |-
An array of arrays containing the `3PID Types`_ with the ``medium``
in first position and the ``address`` in second position.
required: required:
- "threepids" - "threepids"
responses: responses:
@ -157,6 +161,9 @@ paths:
- type: string - type: string
- type: string - type: string
- type: string - type: string
description: an array of array containing the `3PID Types`_ with the ``medium`` in first position, the ``address`` in second position and Matrix ID in third position. description: |-
An array of array containing the `3PID Types`_ with the ``medium``
in first position, the ``address`` in second position and Matrix user
ID in third position.
required: required:
- "threepids" - "threepids"

View file

@ -18,8 +18,9 @@ info:
host: localhost:8090 host: localhost:8090
schemes: schemes:
- https - https
- http
basePath: /_matrix/identity/api/v1 basePath: /_matrix/identity/api/v1
consumes:
- application/json
produces: produces:
- application/json - application/json
paths: paths:
@ -34,13 +35,13 @@ paths:
indicates that that user was able to read the SMS for that phone indicates that that user was able to read the SMS for that phone
number, and so we validate ownership of the phone number. number, and so we validate ownership of the phone number.
Note that Home Servers offer APIs that proxy this API, adding Note that homeservers offer APIs that proxy this API, adding
additional behaviour on top, for example, additional behaviour on top, for example,
``/register/msisdn/requestToken`` is designed specifically for use when ``/register/msisdn/requestToken`` is designed specifically for use when
registering an account and therefore will inform the user if the phone registering an account and therefore will inform the user if the phone
number given is already registered on the server. number given is already registered on the server.
Note: for backwards compatibility with older versions of this Note: for backwards compatibility with previous drafts of this
specification, the parameters may also be specified as specification, the parameters may also be specified as
``application/x-form-www-urlencoded`` data. However, this usage is ``application/x-form-www-urlencoded`` data. However, this usage is
deprecated. deprecated.
@ -106,6 +107,8 @@ paths:
- ``M_INVALID_ADDRESS``: The phone number provided was invalid. - ``M_INVALID_ADDRESS``: The phone number provided was invalid.
- ``M_SEND_ERROR``: The validation SMS could not be sent. - ``M_SEND_ERROR``: The validation SMS could not be sent.
- ``M_DESTINATION_REJECTED``: The identity service cannot deliver an
SMS to the provided country or region.
examples: examples:
application/json: { application/json: {
"errcode": "M_INVALID_ADDRESS", "errcode": "M_INVALID_ADDRESS",
@ -125,7 +128,7 @@ paths:
associate the phone number address with any Matrix user associate the phone number address with any Matrix user
ID. Specifically, calls to ``/lookup`` will not show a binding. ID. Specifically, calls to ``/lookup`` will not show a binding.
Note: for backwards compatibility with older versions of this Note: for backwards compatibility with previous drafts of this
specification, the parameters may also be specified as specification, the parameters may also be specified as
``application/x-form-www-urlencoded`` data. However, this usage is ``application/x-form-www-urlencoded`` data. However, this usage is
deprecated. deprecated.

View file

@ -1,4 +1,5 @@
# Copyright 2018 Kamax Sàrl # Copyright 2018 Kamax Sàrl
# Copyright 2018 New Vector Ltd
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -14,7 +15,7 @@
swagger: "2.0" swagger: "2.0"
info: info:
title: "Matrix Client-Identity Versions API" title: "Matrix Identity Service Ping API"
version: "1.0.0" version: "1.0.0"
host: localhost:8090 host: localhost:8090
schemes: schemes:
@ -25,19 +26,19 @@ produces:
paths: paths:
"/api/v1": "/api/v1":
get: get:
summary: Checks that an Identity server is available at this API endpopint. summary: Checks that an Identity Service is available at this API endpoint.
description: |- description: |-
Checks that an Identity server is available at this API endpopint. Checks that an Identity Service is available at this API endpoint.
To discover that an Identity server is available at a specific URL, To discover that an Identity Service is available at a specific URL,
this endpoint can be queried and will return an empty object. this endpoint can be queried and will return an empty object.
This is primarly used for auto-discovery and health check purposes This is primarly used for auto-discovery and health check purposes
by entities acting as a client for the Identity server. by entities acting as a client for the Identity Service.
operationId: ping operationId: ping
responses: responses:
200: 200:
description: An Identity server is ready to serve requests. description: An Identity Service is ready to serve requests.
examples: examples:
application/json: {} application/json: {}
schema: schema:

View file

@ -18,8 +18,9 @@ info:
host: localhost:8090 host: localhost:8090
schemes: schemes:
- https - https
- http
basePath: /_matrix/identity/api/v1 basePath: /_matrix/identity/api/v1
consumes:
- application/json
produces: produces:
- application/json - application/json
paths: paths:
@ -113,8 +114,8 @@ paths:
The validity of the public key. The validity of the public key.
examples: examples:
application/json: { application/json: {
"valid": true "valid": true
} }
schema: schema:
type: object type: object
properties: properties:

View file

@ -18,16 +18,17 @@ info:
host: localhost:8090 host: localhost:8090
schemes: schemes:
- https - https
- http
basePath: /_matrix/identity/api/v1 basePath: /_matrix/identity/api/v1
consumes:
- application/json
produces: produces:
- application/json - application/json
paths: paths:
"/store-invite": "/store-invite":
post: post:
summary: Store pending invitations to a user\'s 3pid. summary: Store pending invitations to a user's 3pid.
description: |- description: |-
Store pending invitations to a user\'s 3pid. Store pending invitations to a user's 3pid.
In addition to the request parameters specified below, an arbitrary In addition to the request parameters specified below, an arbitrary
number of other parameters may also be specified. These may be used in number of other parameters may also be specified. These may be used in
@ -47,6 +48,8 @@ paths:
Also, the generated ephemeral public key will be listed as valid on Also, the generated ephemeral public key will be listed as valid on
requests to ``/_matrix/identity/api/v1/pubkey/ephemeral/isvalid``. requests to ``/_matrix/identity/api/v1/pubkey/ephemeral/isvalid``.
Currently, invites may only be issued for 3pids of the ``email`` medium.
operationId: storeInvite operationId: storeInvite
parameters: parameters:
- in: body - in: body
@ -84,7 +87,7 @@ paths:
description: The generated token. description: The generated token.
public_keys: public_keys:
type: array type: array
description: A list of [server\'s long-term public key, generated ephemeral public key]. description: A list of [server's long-term public key, generated ephemeral public key].
items: items:
type: string type: string
display_name: display_name:
@ -111,7 +114,7 @@ paths:
application/json: { application/json: {
"errcode": "M_THREEPID_IN_USE", "errcode": "M_THREEPID_IN_USE",
"error": "Binding already known", "error": "Binding already known",
"mxid": mxid "mxid": "@alice:example.com"
} }
schema: schema:
$ref: "../client-server/definitions/errors/error.yaml" $ref: "../client-server/definitions/errors/error.yaml"

View file

@ -49,7 +49,8 @@ paths:
responses: responses:
200: 200:
description: |- description: |-
The fully resolved state for the room, including the authorization The fully resolved state for the room, prior to considering any state
changes induced by the requested event. Includes the authorization
chain for the events. chain for the events.
schema: schema:
type: object type: object
@ -96,7 +97,8 @@ paths:
responses: responses:
200: 200:
description: |- description: |-
The fully resolved state for the room, including the authorization The fully resolved state for the room, prior to considering any state
changes induced by the requested event. Includes the authorization
chain for the events. chain for the events.
schema: schema:
type: object type: object

View file

View file

@ -0,0 +1 @@
!.gitignore

View file

@ -0,0 +1,30 @@
[tool.towncrier]
filename = "../application_service.rst"
directory = "newsfragments"
issue_format = "`#{issue} <https://github.com/matrix-org/matrix-doc/issues/{issue}>`_"
title_format = "{version}"
[[tool.towncrier.type]]
directory = "breaking"
name = "Breaking Changes"
showcontent = true
[[tool.towncrier.type]]
directory = "deprecation"
name = "Deprecations"
showcontent = true
[[tool.towncrier.type]]
directory = "new"
name = "New Endpoints"
showcontent = true
[[tool.towncrier.type]]
directory = "feature"
name = "Backwards Compatible Changes"
showcontent = true
[[tool.towncrier.type]]
directory = "clarification"
name = "Spec Clarifications"
showcontent = true

View file

@ -0,0 +1 @@
Update all event examples to be accurate representations of their associated events.

View file

@ -0,0 +1 @@
Document the 403 error for sending state events.

View file

@ -0,0 +1 @@
Add more presence options to the ``set_presence`` parameter of ``/sync``. (Thanks @mujx!)

View file

View file

@ -0,0 +1 @@
!.gitignore

View file

@ -0,0 +1,30 @@
[tool.towncrier]
filename = "../identity_service.rst"
directory = "newsfragments"
issue_format = "`#{issue} <https://github.com/matrix-org/matrix-doc/issues/{issue}>`_"
title_format = "{version}"
[[tool.towncrier.type]]
directory = "breaking"
name = "Breaking Changes"
showcontent = true
[[tool.towncrier.type]]
directory = "deprecation"
name = "Deprecations"
showcontent = true
[[tool.towncrier.type]]
directory = "new"
name = "New Endpoints"
showcontent = true
[[tool.towncrier.type]]
directory = "feature"
name = "Backwards Compatible Changes"
showcontent = true
[[tool.towncrier.type]]
directory = "clarification"
name = "Spec Clarifications"
showcontent = true

View file

View file

@ -0,0 +1 @@
!.gitignore

View file

@ -0,0 +1,30 @@
[tool.towncrier]
filename = "../server_server.rst"
directory = "newsfragments"
issue_format = "`#{issue} <https://github.com/matrix-org/matrix-doc/issues/{issue}>`_"
title_format = "{version}"
[[tool.towncrier.type]]
directory = "breaking"
name = "Breaking Changes"
showcontent = true
[[tool.towncrier.type]]
directory = "deprecation"
name = "Deprecations"
showcontent = true
[[tool.towncrier.type]]
directory = "new"
name = "New Endpoints"
showcontent = true
[[tool.towncrier.type]]
directory = "feature"
name = "Backwards Compatible Changes"
showcontent = true
[[tool.towncrier.type]]
directory = "clarification"
name = "Spec Clarifications"
showcontent = true

View file

@ -44,16 +44,51 @@ except ImportError as e:
raise raise
def load_file(path):
print("Loading reference: %s" % path)
if not path.startswith("file://"):
raise Exception("Bad ref: %s" % (path,))
path = path[len("file://"):]
with open(path, "r") as f:
if path.endswith(".json"):
return json.load(f)
else:
# We have to assume it's YAML because some of the YAML examples
# do not have file extensions.
return yaml.load(f)
def resolve_references(path, schema):
if isinstance(schema, dict):
# do $ref first
if '$ref' in schema:
value = schema['$ref']
path = os.path.abspath(os.path.join(os.path.dirname(path), value))
ref = load_file("file://" + path)
result = resolve_references(path, ref)
del schema['$ref']
else:
result = {}
for key, value in schema.items():
result[key] = resolve_references(path, value)
return result
elif isinstance(schema, list):
return [resolve_references(path, value) for value in schema]
else:
return schema
def check_example_file(examplepath, schemapath): def check_example_file(examplepath, schemapath):
with open(examplepath) as f: with open(examplepath) as f:
example = yaml.load(f) example = resolve_references(examplepath, json.load(f))
with open(schemapath) as f: with open(schemapath) as f:
schema = yaml.load(f) schema = yaml.load(f)
fileurl = "file://" + os.path.abspath(schemapath) fileurl = "file://" + os.path.abspath(schemapath)
schema["id"] = fileurl schema["id"] = fileurl
resolver = jsonschema.RefResolver(schemapath, schema, handlers={"file": load_yaml}) resolver = jsonschema.RefResolver(schemapath, schema, handlers={"file": load_file})
print ("Checking schema for: %r %r" % (examplepath, schemapath)) print ("Checking schema for: %r %r" % (examplepath, schemapath))
try: try:
@ -71,6 +106,10 @@ def check_example_dir(exampledir, schemadir):
if filename.startswith("."): if filename.startswith("."):
# Skip over any vim .swp files. # Skip over any vim .swp files.
continue continue
cwd = os.path.basename(os.path.dirname(os.path.join(root, filename)))
if cwd == "core":
# Skip checking the underlying definitions
continue
examplepath = os.path.join(root, filename) examplepath = os.path.join(root, filename)
schemapath = examplepath.replace(exampledir, schemadir) schemapath = examplepath.replace(exampledir, schemadir)
if schemapath.find("#") >= 0: if schemapath.find("#") >= 0:
@ -85,14 +124,6 @@ def check_example_dir(exampledir, schemadir):
raise ValueError("Error validating examples") raise ValueError("Error validating examples")
def load_yaml(path):
if not path.startswith("file:///"):
raise Exception("Bad ref: %s" % (path,))
path = path[len("file://"):]
with open(path, "r") as f:
return yaml.load(f)
if __name__ == '__main__': if __name__ == '__main__':
try: try:
check_example_dir("examples", "schema") check_example_dir("examples", "schema")

View file

@ -0,0 +1,6 @@
{
"content": {
"key": "value"
},
"type": "org.example.custom.event"
}

View file

@ -0,0 +1,4 @@
{
"$ref": "event.json",
"room_id": "!jEsUZKDJdhlrceRyVU:domain.com"
}

View file

@ -0,0 +1,10 @@
{
"$ref": "event.json",
"event_id": "$143273582443PhrSn:domain.com",
"room_id": "!jEsUZKDJdhlrceRyVU:domain.com",
"sender": "@example:domain.com",
"origin_server_ts": 1432735824653,
"unsigned": {
"age": 1234
}
}

View file

@ -0,0 +1,4 @@
{
"$ref": "room_event.json",
"state_key": "ArbitraryString"
}

View file

@ -1,5 +1,6 @@
{ {
"age": 242352, "$ref": "core/room_event.json",
"type": "m.call.answer",
"content": { "content": {
"version" : 0, "version" : 0,
"call_id": "12345", "call_id": "12345",
@ -8,10 +9,5 @@
"type" : "answer", "type" : "answer",
"sdp" : "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]" "sdp" : "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]"
} }
}, }
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.call.answer",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,5 +1,6 @@
{ {
"age": 242352, "$ref": "core/room_event.json",
"type": "m.call.candidates",
"content": { "content": {
"version" : 0, "version" : 0,
"call_id": "12345", "call_id": "12345",
@ -10,10 +11,5 @@
"candidate": "candidate:863018703 1 udp 2122260223 10.9.64.156 43670 typ host generation 0" "candidate": "candidate:863018703 1 udp 2122260223 10.9.64.156 43670 typ host generation 0"
} }
] ]
}, }
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.call.candidates",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,12 +1,8 @@
{ {
"age": 242352, "$ref": "core/room_event.json",
"type": "m.call.hangup",
"content": { "content": {
"version" : 0, "version" : 0,
"call_id": "12345" "call_id": "12345"
}, }
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.call.hangup",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,5 +1,6 @@
{ {
"age": 242352, "$ref": "core/room_event.json",
"type": "m.call.invite",
"content": { "content": {
"version" : 0, "version" : 0,
"call_id": "12345", "call_id": "12345",
@ -8,10 +9,5 @@
"type" : "offer", "type" : "offer",
"sdp" : "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]" "sdp" : "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]"
} }
}, }
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.call.invite",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,9 +1,10 @@
{ {
"$ref": "core/event.json",
"type": "m.direct", "type": "m.direct",
"content": { "content": {
"@bob:example.com": [ "@bob:example.com": [
"!abcdefgh:example.com", "!abcdefgh:example.com",
"!hgfedcba:example.com" "!hgfedcba:example.com"
] ]
} }
} }

View file

@ -1,4 +1,5 @@
{ {
"$ref": "core/event.json",
"type": "m.ignored_user_list", "type": "m.ignored_user_list",
"content": { "content": {
"ignored_users": { "ignored_users": {

View file

@ -1,10 +1,11 @@
{ {
"$ref": "core/event.json",
"sender": "@example:localhost",
"type": "m.presence",
"content": { "content": {
"avatar_url": "mxc://localhost:wefuiwegh8742w", "avatar_url": "mxc://localhost:wefuiwegh8742w",
"last_active_ago": 2478593, "last_active_ago": 2478593,
"presence": "online", "presence": "online",
"currently_active": false "currently_active": false
}, }
"sender": "@example:localhost",
"type": "m.presence"
} }

View file

@ -1,13 +1,13 @@
{ {
"type": "m.receipt", "$ref": "core/room_edu.json",
"room_id": "!KpjVgQyZpzBwvMBsnT:matrix.org", "type": "m.receipt",
"content": { "content": {
"$1435641916114394fHBLK:matrix.org": { "$1435641916114394fHBLK:matrix.org": {
"m.read": { "m.read": {
"@rikj:jki.re": { "@rikj:jki.re": {
"ts": 1436451550453 "ts": 1436451550453
}
}
} }
}
} }
}
} }

View file

@ -1,12 +1,8 @@
{ {
"age": 242352, "$ref": "core/state_event.json",
"content": { "state_key": "domain.com",
"aliases": ["#somewhere:localhost", "#another:localhost"]
},
"state_key": "localhost",
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.aliases", "type": "m.room.aliases",
"room_id": "!Cuyf34gef24t:localhost", "content": {
"sender": "@example:localhost" "aliases": ["#somewhere:domain.com", "#another:domain.com"]
}
} }

View file

@ -1,5 +1,7 @@
{ {
"age": 242352, "$ref": "core/state_event.json",
"type": "m.room.avatar",
"state_key": "",
"content": { "content": {
"info": { "info": {
"h": 398, "h": 398,
@ -7,12 +9,6 @@
"mimetype": "image/jpeg", "mimetype": "image/jpeg",
"size": 31037 "size": 31037
}, },
"url": "mxc://localhost/JWEIFJgwEIhweiWJE" "url": "mxc://domain.com/JWEIFJgwEIhweiWJE"
}, }
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.avatar",
"state_key": "",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,12 +1,8 @@
{ {
"age": 242352, "$ref": "core/state_event.json",
"type": "m.room.canonical_alias",
"state_key": "",
"content": { "content": {
"alias": "#somewhere:localhost" "alias": "#somewhere:localhost"
}, }
"state_key": "",
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.canonical_alias",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,12 +1,10 @@
{ {
"age": 242352, "$ref": "core/state_event.json",
"content": {
"creator": "@example:localhost"
},
"state_key": "",
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.create", "type": "m.room.create",
"room_id": "!Cuyf34gef24t:localhost", "state_key": "",
"sender": "@example:localhost" "content": {
"creator": "@example:domain.com",
"room_version": "1",
"m.federate": true
}
} }

View file

@ -1,14 +1,11 @@
{ {
"$ref": "core/room_event.json",
"type": "m.room.encrypted",
"content": { "content": {
"algorithm": "m.megolm.v1.aes-sha2", "algorithm": "m.megolm.v1.aes-sha2",
"ciphertext": "AwgAEnACgAkLmt6qF84IK++J7UDH2Za1YVchHyprqTqsg...", "ciphertext": "AwgAEnACgAkLmt6qF84IK++J7UDH2Za1YVchHyprqTqsg...",
"device_id": "RJYKSTBOIE", "device_id": "RJYKSTBOIE",
"sender_key": "IlRMeOPX2e0MurIyfWEucYBRVOEEUMrOHqn/8mLqMjA", "sender_key": "IlRMeOPX2e0MurIyfWEucYBRVOEEUMrOHqn/8mLqMjA",
"session_id": "X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ" "session_id": "X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ"
}, }
"event_id": "$WLGTSEFSEF:localhost",
"room_id": "!Cuyf34gef24t:localhost",
"origin_server_ts": 1476648761524,
"sender": "@example:localhost",
"type": "m.room.encrypted"
} }

View file

@ -1,6 +1,6 @@
{ {
"$ref": "core/room_event.json",
"type": "m.room.encrypted", "type": "m.room.encrypted",
"sender": "@example:localhost",
"content": { "content": {
"algorithm": "m.olm.v1.curve25519-aes-sha2", "algorithm": "m.olm.v1.curve25519-aes-sha2",
"sender_key": "Szl29ksW/L8yZGWAX+8dY1XyFi+i5wm+DRhTGkbMiwU", "sender_key": "Szl29ksW/L8yZGWAX+8dY1XyFi+i5wm+DRhTGkbMiwU",

View file

@ -1,13 +1,10 @@
{ {
"$ref": "core/state_event.json",
"type": "m.room.encryption",
"state_key": "",
"content": { "content": {
"algorithm": "m.megolm.v1.aes-sha2", "algorithm": "m.megolm.v1.aes-sha2",
"rotation_period_ms": 604800000, "rotation_period_ms": 604800000,
"rotation_period_msgs": 100 "rotation_period_msgs": 100
}, }
"event_id": "$WLGTSEFJJKJ:localhost",
"origin_server_ts": 1476648761524,
"sender": "@example:localhost",
"room_id": "!Cuyf34gef24t:localhost",
"state_key": "",
"type": "m.room.encryption"
} }

View file

@ -1,12 +1,8 @@
{ {
"age": 242353, "$ref": "core/state_event.json",
"type": "m.room.guest_access",
"state_key": "",
"content": { "content": {
"guest_access": "can_join" "guest_access": "can_join"
}, }
"state_key": "",
"origin_server_ts": 1431961217938,
"event_id": "$WLGTSEFSEG:localhost",
"type": "m.room.guest_access",
"room_id": "!Cuyf34gef24u:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,12 +1,8 @@
{ {
"age": 242352, "$ref": "core/state_event.json",
"type": "m.room.history_visibility",
"state_key": "",
"content": { "content": {
"history_visibility": "shared" "history_visibility": "shared"
}, }
"state_key": "",
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.history_visibility",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,12 +1,8 @@
{ {
"age": 242352, "$ref": "core/state_event.json",
"type": "m.room.join_rules",
"state_key": "",
"content": { "content": {
"join_rule": "public" "join_rule": "public"
}, }
"state_key": "",
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.join_rules",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,14 +1,10 @@
{ {
"age": 242352, "$ref": "core/state_event.json",
"state_key": "@alice:domain.com",
"type": "m.room.member",
"content": { "content": {
"membership": "join", "membership": "join",
"avatar_url": "mxc://localhost/SEsfnsuifSDFSSEF#auto", "avatar_url": "mxc://domain.com/SEsfnsuifSDFSSEF#auto",
"displayname": "Alice Margatroid" "displayname": "Alice Margatroid"
}, }
"state_key": "@alice:localhost",
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.member",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,11 +1,12 @@
{ {
"age": 242352, "$ref": "m.room.member",
"content": { "content": {
"membership": "invite", "membership": "invite",
"avatar_url": "mxc://localhost/SEsfnsuifSDFSSEF#auto", "avatar_url": "mxc://domain.com/SEsfnsuifSDFSSEF#auto",
"displayname": "Alice Margatroid" "displayname": "Alice Margatroid"
}, },
"unsigned": { "unsigned": {
"age": 1234,
"invite_room_state": [ "invite_room_state": [
{ {
"type": "m.room.name", "type": "m.room.name",
@ -22,11 +23,5 @@
} }
} }
] ]
}, }
"state_key": "@alice:localhost",
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.member",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,13 +1,13 @@
{ {
"age": 242352, "$ref": "m.room.member",
"content": { "content": {
"membership": "invite", "membership": "invite",
"avatar_url": "mxc://localhost/SEsfnsuifSDFSSEF#auto", "avatar_url": "mxc://domain.com/SEsfnsuifSDFSSEF#auto",
"displayname": "Alice Margatroid", "displayname": "Alice Margatroid",
"third_party_invite": { "third_party_invite": {
"display_name": "alice", "display_name": "alice",
"signed": { "signed": {
"mxid": "@alice:localhost", "mxid": "@alice:domain.com",
"signatures": { "signatures": {
"magic.forest": { "magic.forest": {
"ed25519:3": "fQpGIW1Snz+pwLZu6sTy2aHy/DYWWTspTJRPyNp0PKkymfIsNffysMl6ObMMFdIJhk6g6pwlIqZ54rxo8SLmAg" "ed25519:3": "fQpGIW1Snz+pwLZu6sTy2aHy/DYWWTspTJRPyNp0PKkymfIsNffysMl6ObMMFdIJhk6g6pwlIqZ54rxo8SLmAg"
@ -16,11 +16,5 @@
"token": "abc123" "token": "abc123"
} }
} }
}, }
"state_key": "@alice:localhost",
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.member",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,18 +1,14 @@
{ {
"age": 146, "$ref": "core/room_event.json",
"type": "m.room.message",
"content": { "content": {
"body": "Bee Gees - Stayin' Alive", "body": "Bee Gees - Stayin' Alive",
"url": "mxc://localhost/ffed755USFFxlgbQYZGtryd", "url": "mxc://domain.com/ffed755USFFxlgbQYZGtryd",
"info": { "info": {
"duration": 2140786, "duration": 2140786,
"size": 1563685, "size": 1563685,
"mimetype": "audio/mpeg" "mimetype": "audio/mpeg"
}, },
"msgtype": "m.audio" "msgtype": "m.audio"
}, }
"event_id": "$143273582443PhrSn:localhost",
"origin_server_ts": 1432735824653,
"room_id": "!jEsUZKDJdhlrceRyVU:localhost",
"type": "m.room.message",
"sender": "@example:localhost"
} }

View file

@ -1,14 +1,10 @@
{ {
"age": 242352, "$ref": "core/room_event.json",
"type": "m.room.message",
"content": { "content": {
"body": "thinks this is an example emote", "body": "thinks this is an example emote",
"msgtype": "m.emote", "msgtype": "m.emote",
"format": "org.matrix.custom.html", "format": "org.matrix.custom.html",
"formatted_body": "thinks <b>this</b> is an example emote" "formatted_body": "thinks <b>this</b> is an example emote"
}, }
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.message",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,5 +1,6 @@
{ {
"age": 146, "$ref": "core/room_event.json",
"type": "m.room.message",
"content": { "content": {
"body": "something-important.doc", "body": "something-important.doc",
"filename": "something-important.doc", "filename": "something-important.doc",
@ -8,11 +9,6 @@
"size": 46144 "size": 46144
}, },
"msgtype": "m.file", "msgtype": "m.file",
"url": "mxc://localhost/FHyPlCeYUSFFxlgbQYZmoEoe" "url": "mxc://domain.com/FHyPlCeYUSFFxlgbQYZmoEoe"
}, }
"event_id": "$143273582443PhrSn:localhost",
"origin_server_ts": 1432735824653,
"room_id": "!jEsUZKDJdhlrceRyVU:localhost",
"type": "m.room.message",
"sender": "@example:localhost"
} }

View file

@ -1,5 +1,6 @@
{ {
"age": 242352, "$ref": "core/room_event.json",
"type": "m.room.message",
"content": { "content": {
"body": "filename.jpg", "body": "filename.jpg",
"info": { "info": {
@ -8,12 +9,7 @@
"mimetype": "image/jpeg", "mimetype": "image/jpeg",
"size": 31037 "size": 31037
}, },
"url": "mxc://localhost/JWEIFJgwEIhweiWJE", "url": "mxc://domain.com/JWEIFJgwEIhweiWJE",
"msgtype": "m.image" "msgtype": "m.image"
}, }
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.message",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,10 +1,11 @@
{ {
"age": 146, "$ref": "core/room_event.json",
"type": "m.room.message",
"content": { "content": {
"body": "Big Ben, London, UK", "body": "Big Ben, London, UK",
"geo_uri": "geo:51.5008,0.1247", "geo_uri": "geo:51.5008,0.1247",
"info": { "info": {
"thumbnail_url": "mxc://localhost/FHyPlCeYUSFFxlgbQYZmoEoe", "thumbnail_url": "mxc://domain.com/FHyPlCeYUSFFxlgbQYZmoEoe",
"thumbnail_info": { "thumbnail_info": {
"mimetype": "image/jpeg", "mimetype": "image/jpeg",
"size": 46144, "size": 46144,
@ -13,10 +14,5 @@
} }
}, },
"msgtype": "m.location" "msgtype": "m.location"
}, }
"event_id": "$143273582443PhrSn:localhost",
"origin_server_ts": 1432735824653,
"room_id": "!jEsUZKDJdhlrceRyVU:localhost",
"type": "m.room.message",
"sender": "@example:localhost"
} }

View file

@ -1,14 +1,10 @@
{ {
"age": 242352, "$ref": "core/room_event.json",
"type": "m.room.message",
"content": { "content": {
"body": "This is an example notice", "body": "This is an example notice",
"msgtype": "m.notice", "msgtype": "m.notice",
"format": "org.matrix.custom.html", "format": "org.matrix.custom.html",
"formatted_body": "This is an <strong>example</strong> notice" "formatted_body": "This is an <strong>example</strong> notice"
}, }
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.message",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,14 +1,10 @@
{ {
"age": 242352, "$ref": "core/room_event.json",
"type": "m.room.message",
"content": { "content": {
"body": "This is an example text message", "body": "This is an example text message",
"msgtype": "m.text", "msgtype": "m.text",
"format": "org.matrix.custom.html", "format": "org.matrix.custom.html",
"formatted_body": "<b>This is an example text message</b>" "formatted_body": "<b>This is an example text message</b>"
}, }
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.message",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,10 +1,11 @@
{ {
"age": 146, "$ref": "core/room_event.json",
"type": "m.room.message",
"content": { "content": {
"body": "Gangnam Style", "body": "Gangnam Style",
"url": "mxc://localhost/a526eYUSFFxlgbQYZmo442", "url": "mxc://domain.com/a526eYUSFFxlgbQYZmo442",
"info": { "info": {
"thumbnail_url": "mxc://localhost/FHyPlCeYUSFFxlgbQYZmoEoe", "thumbnail_url": "mxc://domain.com/FHyPlCeYUSFFxlgbQYZmoEoe",
"thumbnail_info": { "thumbnail_info": {
"mimetype": "image/jpeg", "mimetype": "image/jpeg",
"size": 46144, "size": 46144,
@ -18,10 +19,5 @@
"mimetype": "video/mp4" "mimetype": "video/mp4"
}, },
"msgtype": "m.video" "msgtype": "m.video"
}, }
"event_id": "$143273582443PhrSn:localhost",
"origin_server_ts": 1432735824653,
"room_id": "!jEsUZKDJdhlrceRyVU:localhost",
"type": "m.room.message",
"sender": "@example:localhost"
} }

View file

@ -1,12 +1,8 @@
{ {
"age": 242352, "$ref": "core/room_event.json",
"type": "m.room.message.feedback",
"content": { "content": {
"type": "delivered", "type": "delivered",
"target_event_id": "$WEIGFHFW:localhost" "target_event_id": "$WEIGFHFW:localhost"
}, }
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.message.feedback",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,12 +1,8 @@
{ {
"age": 242352, "$ref": "core/state_event.json",
"type": "m.room.name",
"state_key": "",
"content": { "content": {
"name": "The room name" "name": "The room name"
}, }
"state_key": "",
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.name",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,12 +1,8 @@
{ {
"age": 242352, "$ref": "core/state_event.json",
"content": {
"pinned": ["$someevent:localhost"]
},
"state_key": "",
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.pinned_events", "type": "m.room.pinned_events",
"room_id": "!Cuyf34gef24t:localhost", "state_key": "",
"sender": "@example:localhost" "content": {
"pinned": ["$someevent:domain.com"]
}
} }

View file

@ -1,5 +1,7 @@
{ {
"age": 242352, "$ref": "core/state_event.json",
"type": "m.room.power_levels",
"state_key": "",
"content": { "content": {
"ban": 50, "ban": 50,
"events": { "events": {
@ -18,11 +20,5 @@
"notifications": { "notifications": {
"room": 20 "room": 20
} }
}, }
"state_key": "",
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.power_levels",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,14 +1,8 @@
{ {
"unsigned": { "$ref": "core/room_event.json",
"age": 242352 "type": "m.room.redaction",
}, "redacts": "$fukweghifu23:localhost",
"content": { "content": {
"reason": "Spamming" "reason": "Spamming"
}, }
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.redaction",
"room_id": "!Cuyf34gef24t:localhost",
"redacts": "$fukweghifu23:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,5 +1,7 @@
{ {
"age": 242352, "$ref": "core/state_event.json",
"type": "m.room.third_party_invite",
"state_key": "pc98",
"content": { "content": {
"display_name": "Alice Margatroid", "display_name": "Alice Margatroid",
"key_validity_url": "https://magic.forest/verifykey", "key_validity_url": "https://magic.forest/verifykey",
@ -8,11 +10,5 @@
"public_key": "def456", "public_key": "def456",
"key_validity_url": "https://magic.forest/verifykey" "key_validity_url": "https://magic.forest/verifykey"
}] }]
}, }
"state_key": "pc98",
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.third_party_invite",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,12 +1,8 @@
{ {
"age": 242352, "$ref": "core/state_event.json",
"type": "m.room.topic",
"state_key": "",
"content": { "content": {
"topic": "A room topic" "topic": "A room topic"
}, }
"state_key": "",
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.room.topic",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,9 +1,10 @@
{ {
"$ref": "core/event.json",
"type": "m.room_key",
"content": { "content": {
"algorithm": "m.megolm.v1.aes-sha2", "algorithm": "m.megolm.v1.aes-sha2",
"room_id": "!Cuyf34gef24t:localhost", "room_id": "!Cuyf34gef24t:localhost",
"session_id": "X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ", "session_id": "X3lUlvLELLYxeTx4yOVu6UDpasGEVO0Jbu+QFnm0cKQ",
"session_key": "AgAAAADxKHa9uFxcXzwYoNueL5Xqi69IkD4sni8LlfJL7qNBEY..." "session_key": "AgAAAADxKHa9uFxcXzwYoNueL5Xqi69IkD4sni8LlfJL7qNBEY..."
}, }
"type": "m.room_key"
} }

View file

@ -1,5 +1,6 @@
{ {
"age": 242352, "$ref": "core/room_event.json",
"type": "m.sticker",
"content": { "content": {
"body": "Landing", "body": "Landing",
"info": { "info": {
@ -16,10 +17,5 @@
"size": 73602 "size": 73602
}, },
"url": "mxc://matrix.org/sHhqkFCvSkFwtmvtETOtKnLP" "url": "mxc://matrix.org/sHhqkFCvSkFwtmvtETOtKnLP"
}, }
"origin_server_ts": 1431961217939,
"event_id": "$WLGTSEFSEF:localhost",
"type": "m.sticker",
"room_id": "!Cuyf34gef24t:localhost",
"sender": "@example:localhost"
} }

View file

@ -1,4 +1,5 @@
{ {
"$ref": "core/event.json",
"type": "m.tag", "type": "m.tag",
"content": { "content": {
"tags": { "tags": {

View file

@ -1,7 +1,7 @@
{ {
"type": "m.typing", "$ref": "core/room_edu.json",
"room_id": "!z0mnsuiwhifuhwwfw:matrix.org", "type": "m.typing",
"content": { "content": {
"user_ids": ["@alice:matrix.org", "@bob:example.com"] "user_ids": ["@alice:matrix.org", "@bob:example.com"]
} }
} }

View file

@ -27,7 +27,7 @@ The remainder of the process is as follows:
1. Add the changes to the matrix-org/matrix.org repository (for historic tracking). 1. Add the changes to the matrix-org/matrix.org repository (for historic tracking).
* This is done by making a PR to the `unstyled_docs/spec` folder for the version and * This is done by making a PR to the `unstyled_docs/spec` folder for the version and
specification you're releasing. specification you're releasing.
* Don't forget to symlink the new release as `latest`. * Don't forget to symlink the new release as `latest`.
1. Perform a release on GitHub to tag the release. 1. Perform a release on GitHub to tag the release.
1. Yell from the mountaintop to the world about the new release. 1. Yell from the mountaintop to the world about the new release.

View file

@ -154,7 +154,7 @@ def get_rst(file_info, title_level, title_styles, spec_dir, adjust_titles):
# string are file paths to RST blobs # string are file paths to RST blobs
if isinstance(file_info, str): if isinstance(file_info, str):
log("%s %s" % (">" * (1 + title_level), file_info)) log("%s %s" % (">" * (1 + title_level), file_info))
with open(os.path.join(spec_dir, file_info), "r") as f: with open(os.path.join(spec_dir, file_info), "r", encoding="utf-8") as f:
rst = None rst = None
if adjust_titles: if adjust_titles:
rst = load_with_adjusted_titles( rst = load_with_adjusted_titles(
@ -186,7 +186,7 @@ def get_rst(file_info, title_level, title_styles, spec_dir, adjust_titles):
def build_spec(target, out_filename): def build_spec(target, out_filename):
log("Building templated file %s" % out_filename) log("Building templated file %s" % out_filename)
with open(out_filename, "wb") as outfile: with open(out_filename, "w", encoding="utf-8") as outfile:
for file_info in target["files"]: for file_info in target["files"]:
section = get_rst( section = get_rst(
file_info=file_info, file_info=file_info,
@ -195,7 +195,7 @@ def build_spec(target, out_filename):
spec_dir=spec_dir, spec_dir=spec_dir,
adjust_titles=True adjust_titles=True
) )
outfile.write(section.encode('UTF-8')) outfile.write(section)
""" """
@ -223,8 +223,8 @@ def fix_relative_titles(target, filename, out_filename):
"^[" + re.escape("".join(title_styles)) + "]{3,}$" "^[" + re.escape("".join(title_styles)) + "]{3,}$"
) )
current_title_style = None current_title_style = None
with open(filename, "r") as infile: with open(filename, "r", encoding="utf-8") as infile:
with open(out_filename, "w") as outfile: with open(out_filename, "w", encoding="utf-8") as outfile:
for line in infile.readlines(): for line in infile.readlines():
if not relative_title_matcher.match(line): if not relative_title_matcher.match(line):
if title_matcher.match(line): if title_matcher.match(line):
@ -263,8 +263,8 @@ def fix_relative_titles(target, filename, out_filename):
def rst2html(i, o, stylesheets): def rst2html(i, o, stylesheets):
log("rst2html %s -> %s" % (i, o)) log("rst2html %s -> %s" % (i, o))
with open(i, "r") as in_file: with open(i, "r", encoding="utf-8") as in_file:
with open(o, "w") as out_file: with open(o, "w", encoding="utf-8") as out_file:
publish_file( publish_file(
source=in_file, source=in_file,
destination=out_file, destination=out_file,
@ -280,16 +280,15 @@ def rst2html(i, o, stylesheets):
def addAnchors(path): def addAnchors(path):
log("add anchors %s" % path) log("add anchors %s" % path)
with open(path, "rb") as f: with open(path, "r", encoding="utf-8") as f:
lines = f.readlines() lines = f.readlines()
replacement = r'<p><a class="anchor" id="\2"></a></p>\n\1' replacement = r'<p><a class="anchor" id="\2"></a></p>\n\1'
with open(path, "wb") as f: with open(path, "w", encoding="utf-8") as f:
for line in lines: for line in lines:
line = line.decode("UTF-8")
line = re.sub(r'(<h\d id="#?(.*?)">)', replacement, line.rstrip()) line = re.sub(r'(<h\d id="#?(.*?)">)', replacement, line.rstrip())
line = re.sub(r'(<div class="section" id="(.*?)">)', replacement, line.rstrip()) line = re.sub(r'(<div class="section" id="(.*?)">)', replacement, line.rstrip())
f.write((line + "\n").encode('UTF-8')) f.write(line + "\n")
def run_through_template(input_files, set_verbose, substitutions): def run_through_template(input_files, set_verbose, substitutions):
@ -518,10 +517,18 @@ if __name__ == '__main__':
"--server_release", "-s", action="store", default="unstable", "--server_release", "-s", action="store", default="unstable",
help="The server-server release tag to generate, e.g. r1.2" help="The server-server release tag to generate, e.g. r1.2"
) )
parser.add_argument(
"--appservice_release", "-a", action="store", default="unstable",
help="The appservice release tag to generate, e.g. r1.2"
)
parser.add_argument( parser.add_argument(
"--push_gateway_release", "-p", action="store", default="unstable", "--push_gateway_release", "-p", action="store", default="unstable",
help="The push gateway release tag to generate, e.g. r1.2" help="The push gateway release tag to generate, e.g. r1.2"
) )
parser.add_argument(
"--identity_release", "-i", action="store", default="unstable",
help="The identity service release tag to generate, e.g. r1.2"
)
parser.add_argument( parser.add_argument(
"--list_targets", action="store_true", "--list_targets", action="store_true",
help="Do not update the specification. Instead print a list of targets.", help="Do not update the specification. Instead print a list of targets.",
@ -540,12 +547,13 @@ if __name__ == '__main__':
substitutions = { substitutions = {
"%CLIENT_RELEASE_LABEL%": args.client_release, "%CLIENT_RELEASE_LABEL%": args.client_release,
# we hardcode a major version of r0. This ends up in the # we hardcode the major versions. This ends up in the example
# example API URLs. When we have released a new major version, # API URLs. When we have released a new major version, we'll
# we'll have to bump it. # have to bump them.
"%CLIENT_MAJOR_VERSION%": "r0", "%CLIENT_MAJOR_VERSION%": "r0",
"%SERVER_RELEASE_LABEL%": args.server_release, "%SERVER_RELEASE_LABEL%": args.server_release,
"%SERVER_MAJOR_VERSION%": extract_major(args.server_release), "%APPSERVICE_RELEASE_LABEL%": args.appservice_release,
"%IDENTITY_RELEASE_LABEL%": args.identity_release,
"%PUSH_GATEWAY_RELEASE_LABEL%": args.push_gateway_release, "%PUSH_GATEWAY_RELEASE_LABEL%": args.push_gateway_release,
} }

View file

@ -8,8 +8,11 @@ cd `dirname $0`/..
mkdir -p assets mkdir -p assets
# generate specification/proposals.rst if [ "$CIRCLECI" != "true" ]
./scripts/proposals.py then
# generate specification/proposals.rst
./scripts/proposals.py
fi
# generate the spec docs # generate the spec docs
./scripts/gendoc.py -d assets/spec ./scripts/gendoc.py -d assets/spec

View file

@ -37,6 +37,18 @@ class MatrixSections(Sections):
changelogs = self.units.get("changelogs") changelogs = self.units.get("changelogs")
return changelogs["push_gateway"] return changelogs["push_gateway"]
def render_identity_service_changelog(self):
changelogs = self.units.get("changelogs")
return changelogs["identity_service"]
def render_server_server_changelog(self):
changelogs = self.units.get("changelogs")
return changelogs["server_server"]
def render_application_service_changelog(self):
changelogs = self.units.get("changelogs")
return changelogs["application_service"]
def _render_events(self, filterFn, sortFn): def _render_events(self, filterFn, sortFn):
template = self.env.get_template("events.tmpl") template = self.env.get_template("events.tmpl")
examples = self.units.get("event_examples") examples = self.units.get("event_examples")

View file

@ -125,7 +125,7 @@ def resolve_references(path, schema):
if '$ref' in schema: if '$ref' in schema:
value = schema['$ref'] value = schema['$ref']
path = os.path.join(os.path.dirname(path), value) path = os.path.join(os.path.dirname(path), value)
with open(path) as f: with open(path, encoding="utf-8") as f:
ref = yaml.load(f, OrderedLoader) ref = yaml.load(f, OrderedLoader)
result = resolve_references(path, ref) result = resolve_references(path, ref)
del schema['$ref'] del schema['$ref']
@ -664,11 +664,11 @@ class MatrixUnits(Units):
continue continue
filepath = os.path.join(path, filename) filepath = os.path.join(path, filename)
logger.info("Reading swagger API: %s" % filepath) logger.info("Reading swagger API: %s" % filepath)
with open(filepath, "r") as f: with open(filepath, "r", encoding="utf-8") as f:
# strip .yaml # strip .yaml
group_name = filename[:-5].replace("-", "_") group_name = filename[:-5].replace("-", "_")
group_name = "%s_%s" % (group_name, suffix) group_name = "%s_%s" % (group_name, suffix)
api = yaml.load(f.read(), OrderedLoader) api = yaml.load(f, OrderedLoader)
api = resolve_references(filepath, api) api = resolve_references(filepath, api)
api["__meta"] = self._load_swagger_meta( api["__meta"] = self._load_swagger_meta(
api, group_name api, group_name
@ -698,11 +698,11 @@ class MatrixUnits(Units):
continue continue
filepath = os.path.join(path, filename) filepath = os.path.join(path, filename)
logger.info("Reading swagger definition: %s" % filepath) logger.info("Reading swagger definition: %s" % filepath)
with open(filepath, "r") as f: with open(filepath, "r", encoding="utf-8") as f:
# strip .yaml # strip .yaml
group_name = re.sub(r"[^a-zA-Z0-9_]", "_", filename[:-5]) group_name = re.sub(r"[^a-zA-Z0-9_]", "_", filename[:-5])
group_name = "%s_%s" % (prefix, group_name) group_name = "%s_%s" % (prefix, group_name)
definition = yaml.load(f.read(), OrderedLoader) definition = yaml.load(f, OrderedLoader)
definition = resolve_references(filepath, definition) definition = resolve_references(filepath, definition)
if 'type' not in definition: if 'type' not in definition:
continue continue
@ -741,7 +741,7 @@ class MatrixUnits(Units):
event_type = filename[:-5] # strip the ".yaml" event_type = filename[:-5] # strip the ".yaml"
logger.info("Reading event schema: %s" % filepath) logger.info("Reading event schema: %s" % filepath)
with open(filepath) as f: with open(filepath, encoding="utf-8") as f:
event_schema = yaml.load(f, OrderedLoader) event_schema = yaml.load(f, OrderedLoader)
schema_info = process_data_type( schema_info = process_data_type(
@ -754,6 +754,8 @@ class MatrixUnits(Units):
def load_apis(self, substitutions): def load_apis(self, substitutions):
cs_ver = substitutions.get("%CLIENT_RELEASE_LABEL%", "unstable") cs_ver = substitutions.get("%CLIENT_RELEASE_LABEL%", "unstable")
fed_ver = substitutions.get("%SERVER_RELEASE_LABEL%", "unstable") fed_ver = substitutions.get("%SERVER_RELEASE_LABEL%", "unstable")
is_ver = substitutions.get("%IDENTITY_RELEASE_LABEL%", "unstable")
as_ver = substitutions.get("%APPSERVICE_RELEASE_LABEL%", "unstable")
push_gw_ver = substitutions.get("%PUSH_GATEWAY_RELEASE_LABEL%", "unstable") push_gw_ver = substitutions.get("%PUSH_GATEWAY_RELEASE_LABEL%", "unstable")
# we abuse the typetable to return this info to the templates # we abuse the typetable to return this info to the templates
@ -767,11 +769,11 @@ class MatrixUnits(Units):
fed_ver, fed_ver,
"Federation between servers", "Federation between servers",
), TypeTableRow( ), TypeTableRow(
"`Application Service API <application_service/unstable.html>`_", "`Application Service API <application_service/"+as_ver+".html>`_",
"unstable", as_ver,
"Privileged server plugins", "Privileged server plugins",
), TypeTableRow( ), TypeTableRow(
"`Identity Service API <identity_service/unstable.html>`_", "`Identity Service API <identity_service/"+is_ver+".html>`_",
"unstable", "unstable",
"Mapping of third party IDs to Matrix IDs", "Mapping of third party IDs to Matrix IDs",
), TypeTableRow( ), TypeTableRow(
@ -792,8 +794,8 @@ class MatrixUnits(Units):
filepath = os.path.join(path, filename) filepath = os.path.join(path, filename)
logger.info("Reading event example: %s" % filepath) logger.info("Reading event example: %s" % filepath)
try: try:
with open(filepath, "r") as f: with open(filepath, "r", encoding="utf-8") as f:
example = json.load(f) example = resolve_references(filepath, json.load(f))
examples[filename] = examples.get(filename, []) examples[filename] = examples.get(filename, [])
examples[filename].append(example) examples[filename].append(example)
if filename != event_name: if filename != event_name:
@ -830,7 +832,7 @@ class MatrixUnits(Units):
def read_event_schema(self, filepath): def read_event_schema(self, filepath):
logger.info("Reading %s" % filepath) logger.info("Reading %s" % filepath)
with open(filepath, "r") as f: with open(filepath, "r", encoding="utf-8") as f:
json_schema = yaml.load(f, OrderedLoader) json_schema = yaml.load(f, OrderedLoader)
schema = { schema = {
@ -942,7 +944,7 @@ class MatrixUnits(Units):
title_part = None title_part = None
changelog_lines = [] changelog_lines = []
with open(path, "r") as f: with open(path, "r", encoding="utf-8") as f:
lines = f.readlines() lines = f.readlines()
prev_line = None prev_line = None
for line in (tc_lines + lines): for line in (tc_lines + lines):

View file

@ -30,22 +30,37 @@ irrespective of the underlying homeserver implementation.
.. contents:: Table of Contents .. contents:: Table of Contents
.. sectnum:: .. sectnum::
Specification version Changelog
--------------------- ---------
.. topic:: Version: unstable
{{application_service_changelog}}
This version of the specification is generated from This version of the specification is generated from
`matrix-doc <https://github.com/matrix-org/matrix-doc>`_ as of Git commit `matrix-doc <https://github.com/matrix-org/matrix-doc>`_ as of Git commit
`{{git_version}} <https://github.com/matrix-org/matrix-doc/tree/{{git_rev}}>`_. `{{git_version}} <https://github.com/matrix-org/matrix-doc/tree/{{git_rev}}>`_.
For the full historical changelog, see
https://github.com/matrix-org/matrix-doc/blob/master/changelogs/application_service.rst
Other versions of this specification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following other versions are also available, in reverse chronological order:
- `HEAD <https://matrix.org/docs/spec/application_service/unstable.html>`_: Includes all changes since the latest versioned release.
Application Services Application Services
-------------------- --------------------
Application services are passive and can only observe events from a given Application services are passive and can only observe events from homeserver.
homeserver (HS). They can inject events into rooms they are participating in. They can inject events into rooms they are participating in.
They cannot prevent events from being sent, nor can they modify the content of They cannot prevent events from being sent, nor can they modify the content of
the event being sent. In order to observe events from a homeserver, the the event being sent. In order to observe events from a homeserver, the
homeserver needs to be configured to pass certain types of traffic to the homeserver needs to be configured to pass certain types of traffic to the
application service. This is achieved by manually configuring the homeserver application service. This is achieved by manually configuring the homeserver
with information about the application service (AS). with information about the application service.
Registration Registration
~~~~~~~~~~~~ ~~~~~~~~~~~~
@ -169,6 +184,34 @@ An example registration file for an IRC-bridging application service is below:
Homeserver -> Application Service API Homeserver -> Application Service API
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Legacy routes
+++++++++++++
Previous drafts of the application service specification had a mix of endpoints
that have been used in the wild for a significant amount of time. The application
service specification now defines a version on all endpoints to be more compatible
with the rest of the Matrix specification and the future.
Homeservers should attempt to use the specified endpoints first when communicating
with application services. However, if the application service receives an http status
code that does not indicate success (ie: 404, 500, 501, etc) then the homeserver
should fall back to the older endpoints for the application service.
The older endpoints have the exact same request body and response format, they
just belong at a different path. The equivalent path for each is as follows:
* ``/_matrix/app/v1/transactions/{txnId}`` becomes ``/transactions/{txnId}``
* ``/_matrix/app/v1/users/{userId}`` becomes ``/users/{userId}``
* ``/_matrix/app/v1/rooms/{roomAlias}`` becomes ``/rooms/{roomAlias}``
* ``/_matrix/app/v1/thirdparty/protocol/{protocol}`` becomes ``/_matrix/app/unstable/thirdparty/protocol/{protocol}``
* ``/_matrix/app/v1/thirdparty/user/{user}`` becomes ``/_matrix/app/unstable/thirdparty/user/{user}``
* ``/_matrix/app/v1/thirdparty/location/{location}`` becomes ``/_matrix/app/unstable/thirdparty/location/{location}``
* ``/_matrix/app/v1/thirdparty/user`` becomes ``/_matrix/app/unstable/thirdparty/user``
* ``/_matrix/app/v1/thirdparty/location`` becomes ``/_matrix/app/unstable/thirdparty/location``
Homeservers should periodically try again for the newer endpoints because the
application service may have been updated.
Pushing events Pushing events
++++++++++++++ ++++++++++++++
@ -179,24 +222,24 @@ events. Each list of events includes a transaction ID, which works as follows:
Typical Typical
HS ---> AS : Homeserver sends events with transaction ID T. HS ---> AS : Homeserver sends events with transaction ID T.
<--- : AS sends back 200 OK. <--- : Application Service sends back 200 OK.
AS ACK Lost AS ACK Lost
HS ---> AS : Homeserver sends events with transaction ID T. HS ---> AS : Homeserver sends events with transaction ID T.
<-/- : AS 200 OK is lost. <-/- : AS 200 OK is lost.
HS ---> AS : Homeserver retries with the same transaction ID of T. HS ---> AS : Homeserver retries with the same transaction ID of T.
<--- : AS sends back 200 OK. If the AS had processed these events <--- : Application Service sends back 200 OK. If the AS had processed these
already, it can NO-OP this request (and it knows if it is the same events already, it can NO-OP this request (and it knows if it is the
events based on the transaction ID). same events based on the transaction ID).
The events sent to the application service should be linearised, as if they were The events sent to the application service should be linearised, as if they were
from the event stream. The homeserver MUST maintain a queue of transactions to from the event stream. The homeserver MUST maintain a queue of transactions to
send to the AS. If the application service cannot be reached, the homeserver send to the application service. If the application service cannot be reached, the
SHOULD backoff exponentially until the application service is reachable again. homeserver SHOULD backoff exponentially until the application service is reachable again.
As application services cannot *modify* the events in any way, these requests can As application services cannot *modify* the events in any way, these requests can
be made without blocking other aspects of the homeserver. Homeservers MUST NOT be made without blocking other aspects of the homeserver. Homeservers MUST NOT
alter (e.g. add more) events they were going to send within that transaction ID alter (e.g. add more) events they were going to send within that transaction ID
on retries, as the AS may have already processed the events. on retries, as the application service may have already processed the events.
{{transactions_as_http_api}} {{transactions_as_http_api}}
@ -337,7 +380,7 @@ users needs API changes in order to:
- Have a 'passwordless' user. - Have a 'passwordless' user.
This involves bypassing the registration flows entirely. This is achieved by This involves bypassing the registration flows entirely. This is achieved by
including the AS token on a ``/register`` request, along with a login type of including the ``as_token`` on a ``/register`` request, along with a login type of
``m.login.application_service`` to set the desired user ID without a password. ``m.login.application_service`` to set the desired user ID without a password.
:: ::
@ -374,13 +417,18 @@ additional parameters on the ``/publicRooms`` client-server endpoint.
{{appservice_room_directory_cs_http_api}} {{appservice_room_directory_cs_http_api}}
Event fields Referencing messages from a third party network
~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. TODO-TravisR: Fix this section to be a general "3rd party networks" section Application services should include an ``external_url`` in the ``content`` of
events it emits to indicate where the message came from. This typically applies
to application services that bridge other networks into Matrix, such as IRC,
where an HTTP URL may be available to reference.
We recommend that any events that originated from a remote network should Clients should provide users with a way to access the ``external_url`` if it
include an ``external_url`` field in their content to provide a way for Matrix is present. Clients should additionally ensure the URL has a scheme of ``https``
clients to link into the 'native' client from which the event originated. or ``http`` before making use of it.
For instance, this could contain the message-ID for emails/nntp posts, or a link
to a blog comment when bridging blog comment traffic in & out of Matrix. The presence of an ``external_url`` on an event does not necessarily mean the
event was sent from an application service. Clients should be wary of the URL
contained within, as it may not be a legitimate reference to the event's source.

View file

@ -1,6 +1,7 @@
.. Copyright 2016 OpenMarket Ltd .. Copyright 2016 OpenMarket Ltd
.. Copyright 2017 Kamax.io .. Copyright 2017 Kamax.io
.. Copyright 2017 New Vector Ltd .. Copyright 2017 New Vector Ltd
.. Copyright 2018 New Vector Ltd
.. ..
.. Licensed under the Apache License, Version 2.0 (the "License"); .. Licensed under the Apache License, Version 2.0 (the "License");
.. you may not use this file except in compliance with the License. .. you may not use this file except in compliance with the License.
@ -28,13 +29,27 @@ practice has only been applied specifically to email addresses and phone numbers
.. contents:: Table of Contents .. contents:: Table of Contents
.. sectnum:: .. sectnum::
Specification version Changelog
--------------------- ---------
.. topic:: Version: %IDENTITY_RELEASE_LABEL%
{{identity_service_changelog}}
This version of the specification is generated from This version of the specification is generated from
`matrix-doc <https://github.com/matrix-org/matrix-doc>`_ as of Git commit `matrix-doc <https://github.com/matrix-org/matrix-doc>`_ as of Git commit
`{{git_version}} <https://github.com/matrix-org/matrix-doc/tree/{{git_rev}}>`_. `{{git_version}} <https://github.com/matrix-org/matrix-doc/tree/{{git_rev}}>`_.
For the full historical changelog, see
https://github.com/matrix-org/matrix-doc/blob/master/changelogs/identity_service.rst
Other versions of this specification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following other versions are also available, in reverse chronological order:
- `HEAD <https://matrix.org/docs/spec/identity_service/unstable.html>`_: Includes all changes since the latest versioned release.
General principles General principles
------------------ ------------------
@ -56,7 +71,7 @@ is left as an exercise for the client.
3PID types are described in `3PID Types`_ Appendix. 3PID types are described in `3PID Types`_ Appendix.
API Standards API standards
------------- -------------
The mandatory baseline for identity service communication in Matrix is exchanging The mandatory baseline for identity service communication in Matrix is exchanging
@ -136,6 +151,22 @@ should allow a 3pid to be mapped to a Matrix user identity, but not in the other
direction (i.e. one should not be able to get all 3pids associated with a Matrix direction (i.e. one should not be able to get all 3pids associated with a Matrix
user ID, or get all 3pids associated with a 3pid). user ID, or get all 3pids associated with a 3pid).
Web browser clients
-------------------
It is realistic to expect that some clients will be written to be run within a web
browser or similar environment. In these cases, the identity service should respond to
pre-flight requests and supply Cross-Origin Resource Sharing (CORS) headers on all
requests.
When a client approaches the server with a pre-flight (OPTIONS) request, the server
should respond with the CORS headers for that route. The recommended CORS headers
to be returned by servers on all requests are::
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
Status check Status check
------------ ------------
@ -146,25 +177,24 @@ Key management
An identity service has some long-term public-private keypairs. These are named An identity service has some long-term public-private keypairs. These are named
in a scheme ``algorithm:identifier``, e.g. ``ed25519:0``. When signing an in a scheme ``algorithm:identifier``, e.g. ``ed25519:0``. When signing an
association, the Matrix standard JSON signing format is used, as specified in association, the standard `Signing JSON`_ algorithm applies.
the server-server API specification under the heading "Signing Events".
In the event of key compromise, the identity service may revoke any of its keys. In the event of key compromise, the identity service may revoke any of its keys.
An HTTP API is offered to get public keys, and check whether a particular key is An HTTP API is offered to get public keys, and check whether a particular key is
valid. valid.
The identity server may also keep track of some short-term public-private The identity service may also keep track of some short-term public-private
keypairs, which may have different usage and lifetime characteristics than the keypairs, which may have different usage and lifetime characteristics than the
service's long-term keys. service's long-term keys.
{{pubkey_is_http_api}} {{pubkey_is_http_api}}
Association Lookup Association lookup
------------------ ------------------
{{lookup_is_http_api}} {{lookup_is_http_api}}
Establishing Associations Establishing associations
------------------------- -------------------------
The flow for creating an association is session-based. The flow for creating an association is session-based.
@ -183,6 +213,12 @@ session, within a 24 hour period since its most recent modification. Any
attempts to perform these actions after the expiry will be rejected, and a new attempts to perform these actions after the expiry will be rejected, and a new
session should be created and used instead. session should be created and used instead.
To start a session, the client makes a request to the appropriate ``/requestToken``
endpoint. The user then receives a validation token which should be provided
to the client. The client then provides the token to the appropriate ``/submitToken``
endpoint, completing the session. At this point, the client should ``/bind`` the
third party identifier or leave it for another entity to bind.
Email associations Email associations
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
@ -198,53 +234,31 @@ General
{{associations_is_http_api}} {{associations_is_http_api}}
Invitation Storage Invitation storage
------------------ ------------------
An identity service can store pending invitations to a user's 3pid, which will An identity service can store pending invitations to a user's 3pid, which will
be retrieved and can be either notified on or look up when the 3pid is be retrieved and can be either notified on or look up when the 3pid is
associated with a Matrix user ID. associated with a Matrix user ID.
At a later point, if the owner of that particular 3pid binds it with a Matrix user ID, the identity server will attempt to make an HTTP POST to the Matrix user's homeserver which looks roughly as below:: At a later point, if the owner of that particular 3pid binds it with a Matrix user
ID, the identity service will attempt to make an HTTP POST to the Matrix user's
POST https://bar.com:8448/_matrix/federation/v1/3pid/onbind homeserver via the `/3pid/onbind`_ endpoint. The request MUST be signed with a
Content-Type: application/json long-term private key for the identity service.
{
"medium": "email",
"address": "foo@bar.baz",
"mxid": "@alice:example.tld",
"invites": [
{
"medium": "email",
"address": "foo@bar.baz",
"mxid": "@alice:example.tld",
"room_id": "!something:example.tld",
"sender": "@bob:example.tld",
"signed": {
"mxid": "@alice:example.tld",
"signatures": {
"vector.im": {
"ed25519:0": "somesignature"
}
},
"token": "sometoken"
}
}
]
}
Where the signature is produced using a long-term private key.
{{store_invite_is_http_api}} {{store_invite_is_http_api}}
Ephemeral invitation signing Ephemeral invitation signing
---------------------------- ----------------------------
To aid clients who may not be able to perform crypto themselves, the identity service offers some crypto functionality to help in accepting invitations. To aid clients who may not be able to perform crypto themselves, the identity
This is less secure than the client doing it itself, but may be useful where this isn't possible. service offers some crypto functionality to help in accepting invitations.
This is less secure than the client doing it itself, but may be useful where
this isn't possible.
{{invitation_signing_is_http_api}} {{invitation_signing_is_http_api}}
.. _`Unpadded Base64`: ../appendices.html#unpadded-base64 .. _`Unpadded Base64`: ../appendices.html#unpadded-base64
.. _`3PID Types`: ../appendices.html#pid-types .. _`3PID Types`: ../appendices.html#pid-types
.. _`Signing JSON`: ../appendices.html#signing-json
.. _`/3pid/onbind`: ../server_server/unstable.html#put-matrix-federation-v1-3pid-onbind

View file

@ -31,7 +31,7 @@ The client recieves the account data as events in the ``account_data`` sections
of a ``/sync``. of a ``/sync``.
These events can also be received in a ``/events`` response or in the These events can also be received in a ``/events`` response or in the
``account_data`` section of a room in ``/initialSync``. ``m.tag`` ``account_data`` section of a room in ``/sync``. ``m.tag``
events appearing in ``/events`` will have a ``room_id`` with the room events appearing in ``/events`` will have a ``room_id`` with the room
the tags are for. the tags are for.

View file

@ -38,11 +38,10 @@ single ``event_id``.
Client behaviour Client behaviour
---------------- ----------------
In ``/initialSync``, receipts are listed in a separate top level ``receipts`` In ``/sync``, receipts are listed under the ``ephemeral`` array of events
key. In ``/sync``, receipts are contained in the ``ephemeral`` block for a for a given room. New receipts that come down the event streams are deltas
room. New receipts that come down the event streams are deltas which update which update existing mappings. Clients should replace older receipt acknowledgements
existing mappings. Clients should replace older receipt acknowledgements based based on ``user_id`` and ``receipt_type`` pairs. For example::
on ``user_id`` and ``receipt_type`` pairs. For example::
Client receives m.receipt: Client receives m.receipt:
user = @alice:example.com user = @alice:example.com

View file

@ -64,13 +64,27 @@ request.
.. contents:: Table of Contents .. contents:: Table of Contents
.. sectnum:: .. sectnum::
Specification version Changelog
--------------------- ---------
.. topic:: Version: %SERVER_RELEASE_LABEL%
{{server_server_changelog}}
This version of the specification is generated from This version of the specification is generated from
`matrix-doc <https://github.com/matrix-org/matrix-doc>`_ as of Git commit `matrix-doc <https://github.com/matrix-org/matrix-doc>`_ as of Git commit
`{{git_version}} <https://github.com/matrix-org/matrix-doc/tree/{{git_rev}}>`_. `{{git_version}} <https://github.com/matrix-org/matrix-doc/tree/{{git_rev}}>`_.
For the full historical changelog, see
https://github.com/matrix-org/matrix-doc/blob/master/changelogs/server_server.rst
Other versions of this specification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following other versions are also available, in reverse chronological order:
- `HEAD <https://matrix.org/docs/spec/server_server/unstable.html>`_: Includes all changes since the latest versioned release.
Server discovery Server discovery
---------------- ----------------
@ -1077,12 +1091,13 @@ Example code
.. |/query/directory| replace:: ``/query/directory`` .. |/query/directory| replace:: ``/query/directory``
.. _/query/directory: #get-matrix-federation-v1-query-directory .. _/query/directory: #get-matrix-federation-v1-query-directory
.. _`Invitation storage`: ../identity_service/unstable.html#invitation-storage .. _`Invitation storage`: ../identity_service/%IDENTITY_RELEASE_LABEL%.html#invitation-storage
.. _`Identity Service API`: ../identity_service/unstable.html .. _`Identity Service API`: ../identity_service/%IDENTITY_RELEASE_LABEL%.html
.. _`Client-Server API`: ../client_server/unstable.html .. _`Client-Server API`: ../client_server/%CLIENT_RELEASE_LABEL%.html
.. _`Inviting to a room`: #inviting-to-a-room .. _`Inviting to a room`: #inviting-to-a-room
.. _`Canonical JSON`: ../appendices.html#canonical-json .. _`Canonical JSON`: ../appendices.html#canonical-json
.. _`Unpadded Base64`: ../appendices.html#unpadded-base64 .. _`Unpadded Base64`: ../appendices.html#unpadded-base64
.. _`Server ACLs`: ../client_server/unstable.html#module-server-acls
.. _`redaction algorithm`: ../client_server/unstable.html#redactions .. _`redaction algorithm`: ../client_server/unstable.html#redactions
.. _`Signing JSON`: ../appendices.html#signing-json .. _`Signing JSON`: ../appendices.html#signing-json
.. _`Checking for a signature`: ../appendices.html#checking-for-a-signature .. _`Checking for a signature`: ../appendices.html#checking-for-a-signature

View file

@ -13,7 +13,7 @@ targets:
application_service: application_service:
files: files:
- application_service_api.rst - application_service_api.rst
version_label: unstable version_label: "%APPSERVICE_RELEASE_LABEL%"
server_server: server_server:
files: files:
- server_server_api.rst - server_server_api.rst