Skip to main content

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

The page announces the widgets that it supplies and the parameters that it understands

objectno other properties

Properties

  • type"workspace-connect"required
  • widgetsobject[]required

    The widgets that the page can supply

    5 nested properties
    • widgetIdstringrequired

      The id that the page gives the widget

    • namestringrequired

      The name that the Agent and the dashboard show

    • descriptionstring

      What the widget shows

    • categorystring

      The group that the catalog lists the widget under

    • dataType"table" | "markdown"required

      The kind of data that the widget answers with

  • paramsobject[]

    The parameters that the page understands

    9 nested properties
    • paramNamestringrequired

      The name of the parameter

    • labelstring

      The label of the control

    • type"text" | "number" | "date" | "boolean"required

      The kind of control

    • descriptionstring

      Help shown on hover

    • valuestring

      The default value, as a string

    • optionsobject[]

      The choices of a dropdown

      2 nested properties
      • labelstringrequired

        The name that the choice shows

      • valuestringrequired

        The value of the choice

    • minnumber

      The lowest value of a number

    • maxnumber

      The highest value of a number

    • stepnumber

      The step of a number

workspace-data​

The page answers a `workspace-request`

The page answers a workspace-request

objectno other properties

Properties

  • type"workspace-data"required
  • widgetIdstringrequired

    The id of the widget that the data belongs to

  • dataType"table" | "markdown"required

    The kind of data: table or markdown

  • datamap<string, any>[] | stringrequired

    For table, an array of row objects. For markdown, a string

  • columnsstring[]

    The names of the columns of a table

workspace-error​

The page cannot answer a `workspace-request`, and the request fails with the message

The page cannot answer a workspace-request, and the request fails with the message

objectno other properties

Properties

  • type"workspace-error"required
  • widgetIdstringrequired

    The id of the widget that cannot answer

  • errorstringrequired

    The message that the request fails with

workspace:widget-params:update or workspace:params:update​

The page changes parameter values.

The page changes parameter values. A message that has both params and paramName applies both

objectno other properties

Properties

  • type"workspace:widget-params:update" | "workspace:params:update"required
  • paramsmap<string, string | number | boolean | null | (string | number | boolean | null)[]>

    The new values, by parameter name

  • paramNamestring

    The name of one parameter, together with value

  • valuestring | number | boolean | null | (string | number | boolean | null)[]

    The new value of the parameter that paramName names

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`

FINOS Workspace asks the page for the data of one widget, and the page should answer with workspace-data or workspace-error

objectno other properties

Properties

  • type"workspace-request"required
  • widgetIdstring | nullrequired

    The 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.

A 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

objectno other properties

Properties

  • type"workspace-params-update"required
  • paramsmap<string, string>required

    Every current parameter value, including theme, which is light or dark

workspace-auth​

The signed-in user's email address, in the header `X-Workspace-User`, which the page can attach to its own requests.

The 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

objectno other properties

Properties

  • type"workspace-auth"required
  • headersmap<string, string>required

    The 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 messageText that FINOS Workspace stores
a stringa
a number1.5
a booleantrue
nullan empty string
no valuean empty string
a lista,2,false
a list with a nulla,b

Limits​

  • FINOS Workspace gives up on a workspace-request after 10000 milliseconds 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 8 levels deep inside it.