Iframe widget protocol
An iframe widget embeds a page that can talk to FINOS Workspace through window.postMessage. Every message is an object with a type field. The messages are defined in frontend/src/types/iframeProtocol.ts and handled in frontend/src/components/Widgets/Helpers/useIframeProtocol.tsx. Talk to FINOS Workspace from an iframe page explains the order of the messages and which of them FINOS Workspace accepts.
Messages from the page
workspace-connect
The page announces the widgets that it supplies and the parameters that it understands
workspace-connectThe page announces the widgets that it supplies and the parameters that it understands
Properties
type"workspace-connect"requiredwidgetsobject[]requiredThe widgets that the page can supply
5 nested properties
widgetIdstringrequiredThe id that the page gives the widget
namestringrequiredThe name that the Agent and the dashboard show
descriptionstringWhat the widget shows
categorystringThe group that the catalog lists the widget under
dataType"table" | "markdown"requiredThe kind of data that the widget answers with
paramsobject[]The parameters that the page understands
9 nested properties
paramNamestringrequiredThe name of the parameter
labelstringThe label of the control
type"text" | "number" | "date" | "boolean"requiredThe kind of control
descriptionstringHelp shown on hover
valuestringThe default value, as a string
optionsobject[]The choices of a dropdown
2 nested properties
labelstringrequiredThe name that the choice shows
valuestringrequiredThe value of the choice
minnumberThe lowest value of a number
maxnumberThe highest value of a number
stepnumberThe step of a number
workspace-data
The page answers a `workspace-request`
workspace-dataThe page answers a workspace-request
Properties
type"workspace-data"requiredwidgetIdstringrequiredThe id of the widget that the data belongs to
dataType"table" | "markdown"requiredThe kind of data:
tableormarkdowndatamap<string, any>[] | stringrequiredFor
table, an array of row objects. Formarkdown, a stringcolumnsstring[]The names of the columns of a table
workspace-error
The page cannot answer a `workspace-request`, and the request fails with the message
workspace-errorThe page cannot answer a workspace-request, and the request fails with the message
Properties
type"workspace-error"requiredwidgetIdstringrequiredThe id of the widget that cannot answer
errorstringrequiredThe message that the request fails with
workspace:widget-params:update or workspace:params:update
The page changes parameter values.
workspace:widget-params:update or workspace:params:updateThe page changes parameter values. A message that has both params and paramName applies both
Properties
type"workspace:widget-params:update" | "workspace:params:update"requiredparamsmap<string, string | number | boolean | null | (string | number | boolean | null)[]>The new values, by parameter name
paramNamestringThe name of one parameter, together with
valuevaluestring | number | boolean | null | (string | number | boolean | null)[]The new value of the parameter that
paramNamenames
FINOS Workspace validates each message against its schema. A message that does not match is ignored, and a warning appears in the browser console that names the problem.
Messages from FINOS Workspace
workspace-request
FINOS Workspace asks the page for the data of one widget, and the page should answer with `workspace-data` or `workspace-error`
workspace-requestFINOS Workspace asks the page for the data of one widget, and the page should answer with workspace-data or workspace-error
Properties
type"workspace-request"requiredwidgetIdstring | nullrequiredThe id of the widget whose data the page should send
workspace-params-update
A parameter value changed, so the page should update what it shows.
workspace-params-updateA parameter value changed, so the page should update what it shows. FINOS Workspace also sends the message after the handshake, when the user changes a control, when a parameter that the widget shares in a group changes, and when the site's theme changes
Properties
type"workspace-params-update"requiredparamsmap<string, string>requiredEvery current parameter value, including
theme, which islightordark
workspace-auth
The signed-in user's email address, in the header `X-Workspace-User`, which the page can attach to its own requests.
workspace-authThe signed-in user's email address, in the header X-Workspace-User, which the page can attach to its own requests. FINOS Workspace sends it once after each workspace-connect, only when the deployment turns on AUTHENTICATION_SEND_USER_EMAIL_AS_HEADER, and only to a window whose origin equals the origin of the iframe's address
Properties
type"workspace-auth"requiredheadersmap<string, string>requiredThe headers that FINOS Workspace passes to the page, by header name. The only one is
X-Workspace-User, the signed-in user's email address
Parameter values
FINOS Workspace turns every value of a parameter update into a string:
| Value in the message | Text that FINOS Workspace stores |
|---|---|
| a string | a |
| a number | 1.5 |
| a boolean | true |
| null | an empty string |
| no value | an empty string |
| a list | a,2,false |
| a list with a null | a,b |
Limits
- FINOS Workspace gives up on a
workspace-requestafter10000milliseconds and fails the request with a time-out. - A message qualifies as coming from the widget's iframe when it comes from a frame that is nested at most
8levels deep inside it.