# Remote Adapter

This package contains APIs for proxying API messages between OpenFin applications running on different machines.

The APIs provided require WebRTC [peer connections](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection). This package does not provide WebRTC peer connections for you, establishing those is up to you.

Useful resources:

-   [Getting started with peer connections](https://webrtc.org/getting-started/peer-connections)

## Installation

With npm:

```bash
$ npm i -S @openfin/remote-adapter
```

With yarn:

```bash
$ yarn add @openfin/remote-adapter
```

## Usage

Initialize a connection from a "host" OpenFin application.

```typescript
import { init } from '@openfin/remote-adapter';

const rtcPeer = createWebRTCPeer(); // we don't provide this function it is the user's responsibility to create a RTCPeerConnection

await init({ fin: window.fin, rtc: rtcPeer });
```

Connect to the "host" application from a "remote" application.

```typescript
import { connect } from '@openfin/remote-adapter';
import { fdc3FromFin } from '@openfin/fdc3-api';

const rtcPeer = createWebRTCPeer(); // we don't provide this function it is the user's responsibility to create a RTCPeerConnection

const fin = await connect({ rtc: rtcPeer });

// Connect to the host application as an interop client.
fin.me.interop = fin.Interop.connectSync('<HOST_APP_UUID>', {});

// Get an instance of fdc3 from using the fdc3-api package (https://www.npmjs.com/package/@openfin/fdc3-api).
const fdc3 = await fdc3FromFin(fin);
```

## License

Copyright 2020-2023 OpenFin

The code in this package is distributed under the Apache License, Version 2.0.

However, if you run this code, it may call on the OpenFin RVM or OpenFin Runtime, which are covered by OpenFin's Developer, Community, and Enterprise licenses. You can learn more about OpenFin licensing at the links listed below or email us at support@openfin.co with questions.

-   [Developer agreement](https://openfin.co/developer-agreement/)
