0.37.17 • Published 18 days ago

@openfin/web-interop v0.37.17

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
-
Last release
18 days ago

@openfin/web-interop

This npm library facilitates the use of OpenFin's channels API across origins within a web browser.

Key Concepts

Web Broker

A hosted iframe that enables cross-origin communication.

Web Client

A connection to the web broker that leverages the fin API.

Client Library Usage

To utilize the client library, you need to be aware of the URL of your web broker.

import { connect } from '@openfin/web-interop';

const brokerUrl = 'http://example.com/web-broker';
const timeout = 30 * 1000; // Default timeout is infinite, short circuit earlier

const fin = await connect({ brokerUrl, timeout });

const channelClient = await fin.InterApplicationBus.Channel.connect('foo');

Supported APIs

  • fin.me.identity - your randomly generated identity
  • fin.InterApplicationBus.Channel.connect
  • fin.InterApplicationBus.Channel.create

The only supported channel strategy is classic

Hosting a Web Broker

In order to use this library, you must connect to a web broker. The web broker behaves like an instance of the OpenFin runtime for channel uniqueness.

The Web Broker requires that a copy of @openfin/web-interop/shared-worker be hosted alongside it within the same origin.

Accepting Connections

To initialize the connection from an embedding browsing context, a shared worker URL must be specified as shown below.

import { init } from '@openfin/web-interop/iframe-broker';

init({
    sharedWorkerUrl: `${location.origin}/shared-worker.js`
});

Rejecting Connections

The web broker runs as an iframe embedded in the client page, so standard web APIs can be used to detect the embedder info if you wish to reject connections.

If you have a 404 or other error pages, this call can also be used to ensure redirected brokers do not hang the client connections.

import { rejectConnections } from '@openfin/web-interop/iframe-broker';

rejectConnections({ reason: 'custom error message' });

Further Reading

0.37.22

18 days ago

0.37.21

19 days ago

0.37.20

20 days ago

0.37.19

30 days ago

0.38.24

1 month ago

0.38.23

1 month ago

0.38.22

1 month ago

0.38.19

1 month ago

0.38.9

2 months ago

0.38.8

2 months ago

0.37.17

2 months ago