Class EmbeddingClient

    Hierarchy

    • EmbeddingClient

    Configuration

    Communication

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

      See EmbeddingMessages.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 extends "error" | "loaded" | "click" | "unloaded" | "navigated" | "heightChange" | "connectionStatusChange"

      Parameters

      Returns EmbeddingClient

    • 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);
      }
      });

      Parameters

      Returns EmbeddingClient

    Navigation

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

      It does the following:

      1. Calls provided config.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 config.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 EmbeddingClient

    • 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 EmbeddingClient

    Helper

    • 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

    • 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

    • 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

    Other

    currentWorkatoUrl: string = null

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