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

futoin-invoker

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

futoin-invoker

FutoIn Invoker - Reference Implementation. Transparently and efficiently invoke remote or local service methods with strict API definition for Node and Browser

  • 0.7.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27
increased by28.57%
Maintainers
1
Weekly downloads
 
Created
Source

NPM Version NPM Downloads Build Status

NPM

Stability: 2 - Unstable

WARNING

This project is in active development and is not feature-complete yet, but is already mature enough. The documentation of this specific implementation is not complete either.

FutoIn reference implementation

Reference implementation of:

FTN7: FutoIn Invoker Concept
Version: 1.4

FTN3: FutoIn Interface Definition
Version: 1.2

FTN5: FutoIn HTTP integration
Version: 1.2

FTN9: FutoIn Interface - AuditLog
Version: 1.0 (client)

FTN14: FutoIn Cache
Version: 1.0 (client)

Web Site

About

FutoIn Invoker is a peer which initiates a request - invokes a FutoIn interface method as described in FTN3: FutoIn Interface Definition. It is not necessary a client - e.g. server may initiate request for event delivery to client.

The method can be implemented locally or remotely - it is transparent to invoking code. A similar concept can be found in CORBA and other more heavy request brokers.

Strict FutoIn interface (iface) definition and transport protocol is defined in FTN3 spec mentioned above. As it is based on JSON, both client and server can be implemented in a few minutes almost in any technology. However, Invoker and Executor concept provide significant benefits for efficiency, reliability and error control.

The core of invoker is CCM - Connection and Credentials Manager. It has the following advantages:

  • A single place to configure & hold sensitive data (like credentials)
  • Transparent connection management (no need for special connect/request/response/disconnect logic)
  • Efficient use of communications (keep-alive, persistent WebSockets channels, channel-based instead of message-based security, etc.)
  • Inversion of Control / Dependency Injection - implementations are referenced by static names like "mymodule.some.service" in code. The rest is hidden in CCM configuration.
  • Easy HMAC-based message signature and user authentication
  • Security enforcement

The primary communication channel is WebSockets. Large raw data upload and download is also supported through automatic fallback to HTTP(S).

SimpleCCM - a light version without heavy processing of iface definition (ideal for browser) AdvancedCCM - full featured CCM (extends SimpleCCM)

Communication methods:

  • HTTP/HTTPS - remote calls
  • WS/WSS - WebSockets remote calls with bi-directional sockets
  • HTML5 Web Messaging - same- and cross-origin local calls inside Browser through window.postMessage() API
  • Same Process - optimized for single instance deployment

Note: Invoker and Executor are platform/technology-neutral concepts. The implementation is already available in JS and PHP. Hopefully, others are upcoming

Installation for Node.js

Command line:

$ npm install futoin-invoker --save

All public classes can be accessed through module:

var AdvancedCCM = require('futoin-invoker').AdvancedCCM;

or included modular way, e.g.:

var AdvancedCCM = require('futoin-invoker/AdvancedCCM');

Installation for Browser

$ bower install futoin-invoker --save

Please note that browser build is available under in dist/ folder in sources generated with pure-sjc. It include modular parts of lodash.

Note: there are the following globals available:

  • SimpleCCM - global reference to futoin-invoker.SimpleCCM class
  • AdvancedCCM - global reference to futoin-invoker.AdvancedCCM class
  • futoin.Invoker - global reference to futoin-invoker module

Examples

NOTE: more complex examples should be found in (futoin-executor)[https://github.com/futoin/core-js-ri-executor/]

Call remote function with SimpleCCM

var async_steps = require( 'futoin-asyncsteps' );
var invoker = require( 'futoin-invoker' );

var ccm = new invoker.SimpleCCM();

async_steps()
.add(
    function( as ){
        ccm.register( as, 'localone', 'some.iface:1.0', 'https://localhost/some/path' );
        ccm.register( as, 'localtwo', 'other.iface:1.0', 'https://localhost/some/path' );

        as.add( function( as ){
            var localone = ccm.iface( 'localone' );
            var localtwo = ccm.iface( 'localtwo' );
            
            localone.call( as, 'somefunc', {
                arg1 : 1,
                arg2 : 'abc',
                arg3 : true,
            } );
            
            as.add( function( as, res ){
                console.log( res.result1, res.result2 );
            } );
        } );
    },
    function( as, err )
    {
        console.log( err + ': ' + as.state.error_info );
        console.log( as.state.last_exception.stack );
    }
)
.execute();

Call remote function with AdvancedCCM

var async_steps = require( 'futoin-asyncsteps' );
var invoker = require( 'futoin-invoker' );

var some_iface_v1_0 = {
    "iface" : "some.iface",
    "version" : "1.0",
    "ftn3rev" : "1.1",
    "funcs" : {
        "get" : {
            "params" : {
                "arg1" : {
                    "type" : "integer"
                },
                "arg2" : {
                    "type" : "string"
                },
                "arg3" : {
                    "type" : "boolean"
                }
            },
            "result" : {
                "result1" : {
                    "type" : "number"
                },
                "result2" : {
                    "type" : "any"
                }
            },
            "throws" : [
                "MyError"
            ]
        }
    },
    "requires" : [
        "SecureChannel",
        "AllowAnonymous"
    ]
};

var ccm = new invoker.AdvancedCCM({
    specDirs : [ __dirname + '/specs', some_iface_v1_0 ]
});

async_steps()
.add(
    function( as ){
        ccm.register( as, 'localone', 'some.iface:1.0', 'https://localhost/some/path' );
        ccm.register( as, 'localtwo', 'other.iface:1.0', 'https://localhost/some/path' );

        as.add( function( as ){
            var localone = ccm.iface( 'localone' );
            var localtwo = ccm.iface( 'localtwo' );
            
            localone.call( as, 'somefunc', {
                arg1 : 1,
                arg2 : 'abc',
                arg3 : true,
            } );
            
            as.add( function( as, res ){
                console.log( res.result1, res.result2 );
            } );
        } );
    },
    function( as, err )
    {
        console.log( err + ': ' + as.state.error_info );
        console.log( as.state.last_exception.stack );
    }
)
.execute();

API documentation

The concept is described in FutoIn specification: FTN7: Interface Invoker Concept v1.x

#Index

Modules

Members

#futoin-invoker #SimpleCCM window.SimpleCCM - Browser-only reference to futoin-asyncsteps.SimpleCCM

#AdvancedCCM window.AdvancedCCM - Browser-only reference to futoin-asyncsteps.AdvancedCCM

#Invoker futoin.Invoker - Browser-only reference to futoin-invoker module

#FutoInInvoker window.FutoInInvoker - Browser-only reference to futoin-invoker module

#SimpleCCM window.SimpleCCM - Browser-only reference to futoin-asyncsteps.SimpleCCM

documented by jsdoc-to-markdown.

Keywords

FAQs

Package last updated on 23 Feb 2015

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