Class EmbeddingClient

Hierarchy

  • EmbeddingClient

Index

Properties

Accessors

Configuration Methods

Communication Methods

Navigation Methods

Helper Methods

Properties

currentWorkatoUrl

currentWorkatoUrl: string = null

Current Workato URL, loaded into the embedding iframe e.g. /recipes/1?status=succeeded#jobs. Is null until first EmbeddingLoadedMessage is received. Also becomes null after EmbeddingUnloadedMessage is received.

Accessors

loaded

  • get loaded(): boolean

Configuration Methods

configure

Communication Methods

off

  • Allows to unsubscribe handler from processing Workato messages.

    Parameters

    Returns this

on

  • Allows to subscribe to messages of specific type, emitted by embedded Workato app.

    See EmbeddingWorkatoMessage for the complete list of emitted messages.

    Example:

    Workato.on('navigated', payload => {
      console.log(`Workato navigated to ${payload.url}`);
    
      if (payload.replaced) {
        console.log('And URL was replaced in browser history');
      }
    });

    Type parameters

    • TMessageType: EmbeddingWorkatoMessage["type"]

    Parameters

    • messageType: TMessageType

      Value of the type property of EmbeddingWorkatoMessage (e.g. navigated).

    • handler: MessageHandler<EmbeddingSourceMessageOfType<TMessageType>["payload"]>

      Will be called with message's payload as the first parameter.

    Returns this

  • Allows to subscribe to all messages, emitted by Workato.

    Example:

    Workato.on('*', message => {
      console.log(`Received a "${message.type}" message.');
    
      if (message.payload) {
        console.log('Message payload:', message.payload);
      }
    });
    category

    Communication

    Parameters

    Returns this

send

Navigation Methods

disableNavigationHandling

  • disableNavigationHandling(): this

handleNavigation

  • Helper method that allows to synchronize current Workato URL with current vendor's URL.

    It does the following:

    1. Calls provided NavigationConfig.onWorkatoNavigation callback every time after embedded Workato app is navigated to another page (Workato URL changes). It's also called right after initialization of Workato app.

      If this handler is omitted or event.preventVendorUrlChange is not called, current browser's URL will be updated to corresponding embedding URL using History API.

    2. Calls provided NavigationConfig.onVendorNavigation callback every time user clicks on embedding links in the vendor's webapp or clicks browser's back/forward buttons.

      If this handler is omitted or event.preventWorkatoUrlChange is not called, navigateTo method will be called with the corresponding Workato URL.

      Also if this handler is omitted or event.preventVendorUrlChange is not called, current browser's URL will be updated to corresponding embedding URL using History API.

    These handlers can be used, for example, to highlight currently active embedding link in the vendor's webapp or to properly embed Workato into an existing SPA app with it's own routing solution.

    Parameters

    Returns this

navigateTo

  • navigateTo(url: string): this
  • Navigates Workato webapp in the embedding iframe to the provided URL.

    Note that navigation to all non-Workato URLs (e.g. https://foobar.com) with be ignored.

    Parameters

    • url: string

    Returns this

Helper Methods

constructEmbeddingUrl

  • constructEmbeddingUrl(workatoUrl: string): string
  • Constructs embedding URL out of Workato URL.

    Example:

    Workato.configure({embeddingUrlPrefix: '/integration'});
    Workato.constructEmbeddingUrl('/') // => '/integration/'
    Workato.constructEmbeddingUrl('/recipes') // => '/integration/recipes'
    Workato.constructEmbeddingUrl('/recipes/1?a=1#hash') // => '/integration/recipes/1?a=1#hash'

    Parameters

    • workatoUrl: string

    Returns string

extractWorkatoUrl

  • extractWorkatoUrl(vendorUrl: string): string | null
  • Extracts Workato URL from vendor URL.

    Returns null if vendor URL is not embedding URL.

    Example:

    Workato.configure({embeddingUrlPrefix: '/integration'});
    Workato.extractWorkatoUrl('/integration') // => '/'
    Workato.extractWorkatoUrl('/integration/bar?a=1#hash') // => '/bar?a=1#hash'
    Workato.extractWorkatoUrl('https://vendor.com/integration/bar?a=1#hash') // => '/bar?a=1#hash'
    Workato.extractWorkatoUrl('/blah') // => null
    Workato.extractWorkatoUrl('https://google.com/foo/bar?a=1#hash') // => null

    Parameters

    • vendorUrl: string

      Vendor URL. May or may not contain an origin.

    Returns string | null

generateIFrameUrl

  • generateIFrameUrl(token: string, workatoUrl?: string): string
  • Generates a URL that can be used as a value for embedding iframe's src attribute.

    Parameters

    • token: string

      JWT token for authorization. See more information here: https://docs.workato.com/oem/jwt-direct-linking

    • Optional workatoUrl: string

      Specifies Workato URL that will be initially opened in the iframe. If omitted, Workato URL will be extracted from the current browser's URL and if it's not an embedding URL, an error will be thrown.

    Returns string