Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widgets, the spec #2764

Draft
wants to merge 46 commits into
base: old_master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b71f892
Start a template for a widgets spec
turt2live Aug 28, 2020
fb13f49
Specify what the different widget kinds are
turt2live Aug 28, 2020
bf646d0
Add a section on rendering
turt2live Aug 31, 2020
826ce02
Start specifying widget types
turt2live Aug 31, 2020
03d64bd
Specify Jitsi widgets
turt2live Aug 31, 2020
65a290a
Specify TradingView widgets
turt2live Aug 31, 2020
d2bfe5d
Clarify that widgets are an optional feature
turt2live Aug 31, 2020
71cb98a
Fix understanding of what a "client" is in the context of widgets
turt2live Aug 31, 2020
ee14c27
Specify Spotify widgets
turt2live Sep 1, 2020
fa7334f
Specify Video (YouTube) widgets
turt2live Sep 1, 2020
ea57956
Specify Google Docs widgets
turt2live Sep 1, 2020
2ce44f6
Specify Google Calendar widgets
turt2live Sep 1, 2020
4cfd97f
Specify Etherpad widgets
turt2live Sep 1, 2020
afa3817
Specify Grafana widgets
turt2live Sep 1, 2020
09261b3
Specify Stickerpicker widgets
turt2live Sep 1, 2020
927f4c0
Specify Custom (default) widgets
turt2live Sep 1, 2020
fa3e85f
Add a note about widget wrappers
turt2live Sep 1, 2020
8c237c4
Mention that invalid `data` means the widget is custom
turt2live Sep 1, 2020
db96e6c
Fix API Standards heading
turt2live Sep 1, 2020
6552523
Record the remaining security considerations so far
turt2live Sep 1, 2020
2c08043
Move custom widgets up to indicate their importance
turt2live Sep 1, 2020
7a6e09b
Early specification for the Widget API
turt2live Sep 1, 2020
2479ee5
Move widget data examples into their schema definitions
turt2live Sep 1, 2020
229a2ab
Clean up descriptions for API responses
turt2live Sep 1, 2020
ac74770
Specify the startup sequence for the widget API
turt2live Sep 1, 2020
b6d7ce5
Specify widget screenshots
turt2live Sep 1, 2020
700336f
Clarify the iframe onLoad diagram for widgets
turt2live Sep 1, 2020
84d304c
Specify the capabilities action
turt2live Sep 2, 2020
db08e54
Specify versioning for the widget API
turt2live Sep 2, 2020
c1c4f12
Add visibility to the API
turt2live Sep 2, 2020
8aadcd3
Specify the content_loaded action
turt2live Sep 2, 2020
26b0a3a
Specify stickers
turt2live Sep 2, 2020
5d469eb
Use the request schema as a base for the response schema
turt2live Sep 2, 2020
fe53635
Specify always on screen (MSC1354)
turt2live Sep 2, 2020
b853bfa
Leave a note about how this spec tries to support auto-genned code
turt2live Sep 2, 2020
84c627b
Remove simple widgets which serve no purpose
turt2live Sep 3, 2020
e2c45ce
Add a security aspect to the widget API
turt2live Sep 3, 2020
5be2635
[swagger parsing] Support freeform objects
turt2live Sep 3, 2020
63a7f7b
Move name property for sticker action up a level
turt2live Sep 4, 2020
c9d72d3
Move description up too
turt2live Sep 4, 2020
87f6144
Specify MSC1960
turt2live Sep 23, 2020
538864d
Fix sticky action examples
turt2live Sep 23, 2020
cdd48e2
Merge branch 'master' into travis/widgets
turt2live Nov 23, 2020
4b6bf32
Specify avatar_url per MSC2765
turt2live Nov 23, 2020
d5927ec
Specify matrix_widget_id template variable per MSC2774
turt2live Nov 23, 2020
b910b89
Apply suggestions from code review
turt2live Nov 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions api/widgets/definitions/api_error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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: WidgetApiErrorResponse
description: |-
Schema definition for an error response in the Widget API. This is a regular ``WidgetApiResponse``
object with the ``response`` specified as follows.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be updated to say error and omit the response object in the WidgetApiErrorResponse.

allOf:
- $ref: "./api_response.yaml"
properties:
response:
type: object
title: WidgetErrorResponseData
description: |-
The response data.
properties:
error:
type: object
title: WidgetApiError
description: |-
Information about the error that happened.
properties:
message:
type: string
description: |-
Human-readable string for the cause of the error.
example: "Failed to process request: Server returned 500 error"
required: ['message']
required: ['error']
55 changes: 55 additions & 0 deletions api/widgets/definitions/api_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 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: WidgetApiRequest
description: |-
Schema definition for a widget request object over the Widget API.
properties:
api:
type: string
enum: [fromWidget, toWidget]
description: |-
The API for which the request is to be sent over.
example: "fromWidget"
requestId:
type: string
description: |-
An opaque string which uniquely identifies the request in the context of the session.
example: "generated-id-1234"
Comment on lines +20 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it that the widget API uses camelCase in some prominent places like this? Could that still be changed, with some backwards-compatibility hacks? Matrix otherwise pretty consistently uses snake_case.

action:
type: string
description: |-
The action to send to the other party. Custom actions can be sent using the Java package
naming convention as a namespace.
example: "com.example.say_hello"
widgetId:
type: string
description: |-
The widget's ID.
example: "20200827_WidgetExample"
data:
type: object
description: |-
The request data.
additionalProperties: true
example: {
"request-param": "value"
}
required:
- api
- requestId
- action
- widgetId
- data
51 changes: 51 additions & 0 deletions api/widgets/definitions/api_response.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 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: WidgetApiResponse
description: |-
Schema definition for a widget response object over the Widget API.

.. Note::
This is intentionally designed to allow API users to copy the request object
verbatim and simply append their ``response``.

allOf:
- $ref: "./api_request.yaml"
properties:
response:
type: object
description: |-
The response data.
additionalProperties: true
example: {
"response-param": "value"
}
# We define other properties from the api_request.yaml schema to override their descriptions
# for context purposes
api:
type: string
enum: [fromWidget, toWidget]
description: The API the request was sent over.
example: "fromWidget"
requestId:
type: string
description: The request ID supplied in the original request.
example: "generated-id-1234"
action:
type: string
description: The action which was invoked.
example: "com.example.say_hello"
required:
- response
32 changes: 32 additions & 0 deletions api/widgets/definitions/capabilities_action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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: CapabilitiesActionBase
properties:
api:
type: string
enum: ["toWidget"]
description: "" # The enum will result in this being "Must be $0"
example: "toWidget"
action:
type: string
enum: ["capabilities"]
description: "" # The enum will result in this being "Must be $0"
example: "capabilities"
data:
type: object
description: |-
An empty data object (no request parameters).
example: {}
22 changes: 22 additions & 0 deletions api/widgets/definitions/capabilities_action_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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: CapabilitiesActionRequest
description: |-
Schema definition for a ``toWidget`` API request with action of ``capabilities``.
allOf:
- $ref: "./api_request.yaml"
- $ref: "./capabilities_action.yaml"
properties: {}
37 changes: 37 additions & 0 deletions api/widgets/definitions/capabilities_action_response.yaml
Original file line number Diff line number Diff line change
@@ -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: CapabilitiesActionResponse
description: |-
Schema definition for a response to a ``CapabilitiesActionRequest``.
allOf:
- $ref: "./api_response.yaml"
- $ref: "./capabilities_action_request.yaml"
properties:
response:
type: object
description: |-
The response data.
title: CapabilitiesActionResponseData
properties:
capabilities:
type: array
items:
type: string
description: |-
The list of requested capabilities. An empty array indicates that no capabilities are
requested.
example: ["m.capabilitity.screenshot", "m.sticker"]
required: ['capabilities']
32 changes: 32 additions & 0 deletions api/widgets/definitions/content_loaded_action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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: ContentLoadedActionBase
properties:
api:
type: string
enum: ["fromWidget"]
description: "" # The enum will result in this being "Must be $0"
example: "fromWidget"
action:
type: string
enum: ["content_loaded"]
description: "" # The enum will result in this being "Must be $0"
example: "content_loaded"
data:
type: object
description: |-
An empty data object (no request parameters).
example: {}
22 changes: 22 additions & 0 deletions api/widgets/definitions/content_loaded_action_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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: ContentLoadedActionRequest
description: |-
Schema definition for a ``fromWidget`` API request with action of ``content_loaded``.
allOf:
- $ref: "./api_request.yaml"
- $ref: "./content_loaded_action.yaml"
properties: {}
27 changes: 27 additions & 0 deletions api/widgets/definitions/content_loaded_action_response.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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: ContentLoadedActionResponse
description: |-
Schema definition for a response to a ``ContentLoadedActionRequest``.
allOf:
- $ref: "./api_response.yaml"
- $ref: "./content_loaded_action_request.yaml"
properties:
response:
type: object
description: |-
An empty response body to acknowledge the request.
example: {}
31 changes: 31 additions & 0 deletions api/widgets/definitions/custom_data.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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: CustomWidgetData
description: |-
Definition for a widget's ``data`` when using a ``type`` of ``m.custom`` or using an
unknown/unsupported ``type``. Currently no requirements are specified.
properties:
url:
type: string
description: |-
The URL for the embedded content. Required only if the widget's URL does not match
the embedded content, before templating ocurrs.

Clients should note that not all widgets which get interpretted as custom widgets
will have this property, though all widgets are required to have a higher level ``url``
which can be used to display them. As such, requirements for this field being present
SHOULD only be enforced upon widgets with an explicit ``type`` of ``m.custom``.
example: "https://matrix.org"
33 changes: 33 additions & 0 deletions api/widgets/definitions/get_openid_action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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: GetOpenIDCredentialsActionBase
properties:
api:
type: string
enum: ["fromWidget"]
description: "" # The enum will result in this being "Must be $0"
example: "fromWidget"
action:
type: string
enum: ["get_openid"]
description: "" # The enum will result in this being "Must be $0"
example: "get_openid"
data:
type: object
title: GetOpenIDCredentialsRequestData
description: |-
An empty request body.
example: {}
Loading