Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openfin-adapter

Package Overview
Dependencies
Maintainers
1
Versions
970
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openfin-adapter

Allows the use of the OpenFin API from node.js. Please note the launch and connect methods are specific to a node environment.

  • 30.74.17
  • alpha-v30
  • npm
  • Socket score

Version published
Weekly downloads
2.7K
decreased by-34.18%
Maintainers
1
Weekly downloads
 
Created
Source

OpenFin Node.js adapter

Allows the use of the OpenFin API from node.js. Please note the launch and connect methods are specific to a node environment.

Requirements

  • Node.js LTS ^6.9

Install as dependency

$ npm install -S openfin-adapter

Usage

Using the fin api from an Applications context

init.js

import { fin } from 'openfin-adapter/src/mock';

(() => {
  if (fin.me.isView) {
      fin.me.getCurrentWindow();
      // returns => Promise<OpenFin.Window> only when in a View's context.
  }

  if(fin.me.isFrame) {
      fin.me.getInfo();
      // returns => Promise<OpenFin.FrameInfo> only when in a Frame's context.
  }

  if (fin.me.isWindow) {
      fin.me.getCurrentViews();
      // returns => Promise<OpenFin.View[]> only when in a Window's context.
  }
})();

Using the fin api in node

Connecting to an already running runtime

connect.js

import { connect } from 'openfin-adapter';

export async function connectFromNode() {
    try {
        const { fin }  = await connect({
            address: "ws://localhost:9696",
            uuid: "my-uuid-123"
        });
        const version = await fin.System.getVersion();
        console.log("Connected to OpenFin runtime version:", version);

        const platform = await fin.Platform.startFromManifest('https://openfin.github.io/golden-prototype/public.json');
        console.log('Platform is running, wrapped platform: ', platform);

        return fin;

    } catch(e) {
        throw new Error(`Error: \n${e}`);
    }
}

init.js

import { connectFromNode } from './connect.js'

(async () => {
    try {
        const fin = await connectFromNode();
        console.log(`You are connected to node with this fin instance: \n${fin}`);
    } catch(e) {
        throw new Error(`Error connecting to  from node: \n${e}`);
    }
})();


Launching a runtime from node

launchFromNode.js

import { launch } from 'openfin-adapter';

export async function launchFromNode() {
    try {
        const { fin }  = await launch({
            uuid: "my-uuid-123",
            runtime: {
                version: 'stable'
            }
        });
        const version = await fin.System.getVersion();
        console.log("Connected to OpenFin runtime version:", version);

        const platform = await fin.Platform.startFromManifest('https://openfin.github.io/golden-prototype/public.json');
        console.log('Platform is running, wrapped platform: ', platform);

        return fin;

    } catch(e) {
        throw new Error(`Error: \n${e}`);
    }
}

init.js

import { launchFromNode } from './launchFromNode.js'

(async () => {
    try {
        const fin = await launchFromNode();
        console.log(`You successfully connected from node with to a runtime with this fin instance: \n${fin}`);
    } catch(e) {
        throw new Error(`Error connecting to  from node: \n${e}`);
    }
})();

License

The code in this repository 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 just email us at support@openfin.co with questions.

Copyright 2020-2021 OpenFin

https://openfin.co/developer-agreement/

https://openfin.co/licensing/

FAQs

Package last updated on 17 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc