npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

futoin-executor

v2.3.7

Published

FutoIn Service base with strict API definition for Node and Browser

Downloads

207

Readme

NPM Version NPM Downloads Build Status stable

NPM

Stability: 3 - Stable

About

Documentation --> FutoIn Guide

FutoIn Executor is a peer which processes a request - handles a FutoIn interface method as described in FTN3: FutoIn Interface Definition. It is not necessary a server - e.g. client may handle callback request from server.

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.

Executor class is the core which encapsulate pure FutoIn Executor logic. It can be extended to platform-specific implementation (e.g. Browser or Node)

The primary communication channel is WebSockets and HTTP as secondary. Large raw data upload and download is also supported through HTTP(S) only.

Executor - neutral Executor concept logic NodeExecutor - available only if used in Node.js

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

Features

  • Microservice implementation with zero boilerplates
  • Easy scaling from single monolithic process to cluster per microservice
  • Universal in-process, WebSockets and HTTP request handling
  • REST-like HTTP integration (mapping of path components and parameters to message structure)
  • Raw data for request and response (with HTTP fallback)
  • Callback requests for bi-directional channels like (WebSockets, in-process)
  • Advanced fair resource usage / DoS protection limits based on client source address
    • message limit control
    • max concurrent requests with queuing limits
    • max requests per period with queuing limits
    • optional limit aggregation per network address prefix
    • advanced efficient limit config selection using futoin-ipset
  • API specification enforcement (defined in human-friendly FTN3 format)
    • works even for in-process calls and covers JS type safety issues
    • checks parameters with optional default value substitution
    • checks result
    • checks advanced message lengths as per FTN3 v1.8
    • checks exception types to avoid exposure of internal information
    • strict semver-like interface versioning - implicit backward compatibility support
    • transport security, authentication and authorization are integrated as well
    • optional HMAC signing
  • High performance and low memory usage

FutoIn reference implementation

Reference implementation of:

FTN6: FutoIn Executor Concept
Version: 1.7

FTN3: FutoIn Interface Definition
Version: 1.9

FTN5: FutoIn HTTP integration
Version: 1.3

FTN4: FutoIn Interface - Ping-Pong
Version: 1.0 (service)

Author: Andrey Galkin

Installation for Node.js

Command line:

$ npm install futoin-executor --save

or

$ yarn add futoin-executor

Hint: checkout FutoIn CID for all tools setup.

All public classes can be accessed through module:

var Executor = require('futoin-executor').Executor;

or included modular way, e.g.:

var Executor = require('futoin-executor/Executor');

Browser installation

Pre-built ES5 CJS modules are available under es5/. These modules can be used with webpack without transpiler - default "browser" entry point points to ES5 version.

Webpack dists are also available under dist/ folder, but their usage should be limited to sites without build process.

Warning: check AsyncSteps and AsyncEvent polyfill for older browsers.

The following globals are 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

The best examples are live projects:

Please note that the examples here expect interface definition files listed below. All sources are available under examples/ folder.

Server implementation example


var AdvancedCCM = require( 'futoin-invoker/AdvancedCCM' );
var NodeExecutor = require( 'futoin-executor/NodeExecutor' );
var async_steps = require( 'futoin-asyncsteps' );

// Initialize CCM
var ccm = new AdvancedCCM( { specDirs : __dirname } );

// Initialize Node.js Executor implementation
var executor = new NodeExecutor(
    ccm,
    {
        specDirs : __dirname,
        httpAddr : 'localhost',
        httpPort : 3000,
        httpPath : '/api/'
    }
);
executor.on( 'notExpected', function( err, error_info ){
    console.log( 'Server: ' + err + ': ' + error_info );
} );

// Normally, you would want to define one in separate module
var service_impl = {
    getProgress : function( as, reqinfo )
    {
        var p = reqinfo.params();
        
        if ( reqinfo.params().resource === 'MyResource' )
        {
            as.success( { progress : 75 } )
        }
        else
        {
            as.error( 'InvalidResource' );
        }
    },

    subscribeProgress : function( as, reqinfo )
    {
        var p = reqinfo.params();
        
        if ( reqinfo.params().resource !== 'MyResource' )
        {
            as.error( 'InvalidResource' );
        }

        var channel = reqinfo.channel();
        channel.register( as, 'org.example.receiver:1.0' );
        
        as.add( function( as )
        {
            var iface = channel.iface( 'org.example.receiver:1.0' );
            reqinfo.result().ok = true;

            // Stupid simple scheduling of events to be sent
            //---
            var add_progress = function( progress, delay )
            {
                setTimeout( function(){
                    async_steps().add( function( as ){
                        iface.progressEvent( as, 'MyResource', progress );
                    } )
                    .execute();
                }, delay );
            };
            
            for ( var i = 0; i <= 10; ++i )
            {
                add_progress( i * 10, i * 100 );
            }
            //---
        } );
    }
};

// Register Service implementation
async_steps()
.add(
    function( as )
    {
        executor.register( as, 'org.example.service:1.0', service_impl );
    },
    function( as, err )
    {
        console.log( err + ': ' + as.state.error_info );
        console.log( as.state.last_exception.stack );
    }
)
.execute();

Polling client implementation example

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

var ccm = new AdvancedCCM( { specDirs : [ __dirname ] } );

async_steps()
// Do it once for program's entire life time
.add(
    function( as )
    {
        // Register interface and endpoint
        ccm.register( as, 'myservice',
                      'org.example.service:1.0',
                      'http://localhost:3000/api/' );
    },
    function( as, err )
    {
        console.log( err + ': ' + as.state.error_info );
        console.log( as.state.last_exception.stack );
    }
)
// Regular service call
.add(
    function( as )
    {
        var myservice = ccm.iface( 'myservice' );
        
        // equal to myservice.call( as, 'getProgress', { progress: 'MyResource' } );
        myservice.getProgress( as, 'MyResource' );
        
        as.add( function( as, res ){
            // Use result
            console.log( 'Progress: ' + res.progress );
        } );
    },
    function( as, err )
    {
        // Handle error
        console.log( err + ': ' + as.state.error_info );
    }
)
.execute();

Event receiving client implementation example

var async_steps = require( 'futoin-asyncsteps' );
var AdvancedCCM = require( 'futoin-invoker/AdvancedCCM' );
var Executor = require( 'futoin-executor/Executor' );

var opts = { specDirs : __dirname };
var ccm = new AdvancedCCM( opts );
var client_executor = new Executor( ccm, opts );

async_steps()
// Do it once for program's entire life time
.add(
    function( as )
    {
        // Register interface and endpoint
        ccm.register(
                as,
                'myservice',
                'org.example.service:1.0',
                'ws://localhost:3000/api/',
                null,
                {
                    executor : client_executor
                }
        );

        // Register client-side Executor Service
        client_executor.register(
                as,
                'org.example.receiver:1.0',
                {
                    progressEvent: function( as, reqinfo )
                    {
                        var progress = reqinfo.params().progress;
                        console.log( 'Progress: ' + progress );

                        if ( progress >= 100 )
                        {
                            ccm.close();
                        }
                    }
                }
        );
        
        // Subscribe for events
        as.add( function( as )
        {
            // Note: it is a sub-step as we need to wait for 
            // registration to complete
            var myservice = ccm.iface( 'myservice' );
            
            // equal to myservice.call( as, 'subscribeProgress',
            // { progress: 'MyResource' } );
            myservice.subscribeProgress( as, 'MyResource' );
        } );
    },
    function( as, err )
    {
        console.log( err + ': ' + as.state.error_info );
        console.log( as.state.last_exception.stack );
    }
)
.execute();

Example output of execution

Starting Example Server
Starting Example Client
Progress: 75
Starting Example Client with Callback
Progress: 0
Progress: 10
Progress: 20
Progress: 30
Progress: 40
Progress: 50
Progress: 60
Progress: 70
Progress: 80
Progress: 90
Progress: 100

FutoIn iface definitions

Please see FTN3: FutoIn Interface Definition v1.x for all advanced features.

org.example.types-1.0-iface.json

This one is only used to share Type definitions. It does not participate in inheritance

{
    "iface" : "org.example.types",
    "version" : "1.0",
    "ftn3rev" : "1.1",
    "types" : {
        "Percent" : {
            "type" : "integer",
            "min" : 0,
            "max" : 100
        }
    },
    "desc" : "Shared interface to define common types"
}

org.example.service-1.0-iface.json

Actual Server-side Service definition

{
    "iface" : "org.example.service",
    "version" : "1.0",
    "ftn3rev" : "1.1",
    "imports" : [
        "org.example.types:1.0"
    ],
    "funcs" : {
        "getProgress" : {
            "params" : {
                "resource" : {
                    "type" : "string"
                }
            },
            "result" : {
                "progress" : {
                    "type" : "Percent"
                }
            },
            "throws" : [
                "InvalidResource"
            ]
        },
        "subscribeProgress" : {
            "params" : {
                "resource" : {
                    "type" : "string"
                }
            },
            "result" : {
                "ok" : {
                    "type" : "boolean"
                }
            },
            "throws" : [
                "InvalidResource"
            ]
        }
    },
    "requires" : [
        "AllowAnonymous"
    ],
    "desc" : "Service-side Service"
}

org.example.receiver-1.0-iface.json

Client-side Service for bi-directional transport channels, like WebSockets.

{
    "iface" : "org.example.receiver",
    "version" : "1.0",
    "ftn3rev" : "1.1",
    "imports" : [
        "org.example.types:1.0"
    ],
    "funcs" : {
        "progressEvent" : {
            "params" : {
                "resource" : {
                    "type" : "string"
                },
                "progress" : {
                    "type" : "Percent"
                }
            },
            "desc" : "Progress receiving event callback"
        }
    },
    "requires" : [
        "AllowAnonymous"
    ],
    "desc" : "Client-side Service"
}

API documentation

The concept is described in FutoIn specification: FTN6: Interface Executor Concept v1.x

Modules

Classes

Members

Constants

futoin-executor

BasicAuthFace

BasicAuth is not official spec - it is a temporary solution until FTN8 Security Concept is finalized

Kind: global class

BasicAuthFace.register(as, ccm, endpoint, [credentials], [options])

BasicAuth interface registration helper

Kind: static method of BasicAuthFace

| Param | Type | Default | Description | | --- | --- | --- | --- | | as | AsyncSteps | | step interface | | ccm | AdvancedCCM | | CCM instance | | endpoint | string | | endpoint URL | | [credentials] | * | | see CCM register() | | [options] | object | {} | registration options | | [options.version] | string | "1.0" | iface version |

BasicAuthService

BasicService is not official spec - it is a temporary solution until FTN8 Security Concept is finalized

Kind: global class

basicAuthService.addUser(user, secret, details, [system_user])

Register users statically right after registration

Kind: instance method of BasicAuthService

| Param | Type | Description | | --- | --- | --- | | user | string | user name | | secret | string | user secret (either password or raw key for HMAC) | | details | object | user details the way as defined in FTN8 | | [system_user] | boolean | is system user |

basicAuthService._getUser(as, user)

Get by name. Override, if needed.

Kind: instance method of BasicAuthService
Note: as result: {object} user object or null (through as)

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | steps interface | | user | string | user name |

basicAuthService._getUserByID(as, local_id)

Get by ID. Override, if needed.

Kind: instance method of BasicAuthService
Note: as result: {object} user object or null (through as)

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | steps interfaces | | local_id | number | local ID |

basicAuthService.addUser(user, secret, details, [system_user])

Register users statically right after registration

Kind: instance method of BasicAuthService

| Param | Type | Default | Description | | --- | --- | --- | --- | | user | string | | user name | | secret | string | | user secret (either password or raw key for HMAC) | | details | object | | user details the way as defined in FTN8 | | [system_user] | boolean | false | is system user |

BasicAuthService.register(as, executor) ⇒ BasicAuthService

BasicAuthService registration helper

Kind: static method of BasicAuthService
Returns: BasicAuthService - reference to implementation instance (to register users)

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | steps interface | | executor | Executor | executor instance |

BrowserExecutorOptions ⇐ ExecutorOptions

Kind: global class
Extends: ExecutorOptions

new BrowserExecutorOptions()

Pseudo-class for BrowserExecutor options documentation

BrowserExecutorOptions.clientTimeoutMS

Client timeout MS

Kind: static property of BrowserExecutorOptions
Default: 600

BrowserExecutorOptions.allowedOrigins

List of allowed page origins for incoming connections. It is MANDATORY for security reasons.

Example:

  • 'http://localhost:8000'
  • 'http://example.com'

Kind: static property of BrowserExecutorOptions
Default: []

BrowserExecutor

Browser Executor with HTML5 Web Messaging as incoming transport.

It allows communication across open pages (frames/tabs/windows) inside client browser.

Kind: global class

new BrowserExecutor(ccm, opts)

| Param | Type | Description | | --- | --- | --- | | ccm | AdvancedCCM | CCM ref | | opts | BrowserExecutorOptions | executor options |

ChannelContext

Channel Context normally accessible through RequestInfo object.

Kind: global class

new ChannelContext(executor)

| Param | Type | Description | | --- | --- | --- | | executor | Executor | reference to associated executor |

channelContext.type() ⇒ string

Get type of channel

Standard values: HTTP, WS, BROWSER, TCP, UDP, UNIX

Kind: instance abstract method of ChannelContext
Returns: string - arbitrary string, see FTN6

channelContext.isStateful() ⇒ Boolean

Check if transport is stateful (e.g. WebSockets)

Kind: instance method of ChannelContext
Returns: Boolean - true, if context object is persistent across requests in the same session

channelContext.onInvokerAbort(callable, [user_data])

Set invoker abort handler.

Kind: instance method of ChannelContext
Note: It should be possible to call multiple times setting multiple callbacks.
Note: The callback is set for lifetime of the channel - do not use it on every request!

| Param | Type | Description | | --- | --- | --- | | callable | function | callback | | [user_data] | any | optional parameter to pass to callable |

channelContext.register(as, ifacever, options)

Register Invoker interface on bi-directional channels to make calls from Server to Client.

Kind: instance method of ChannelContext
See: AdvancedCCM.register

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | steps interface | | ifacever | string | standard iface:version notation | | options | object | standard Invoker options |

channelContext.iface(ifacever) ⇒ NativeIface

Get previously registered interface on bi-directional channel.

NOTE: unlike CCM, there is no point for local alias name as Invoker can have only a single ClientExecutor which can have only a single instance implementing specified iface:version.

Kind: instance method of ChannelContext
Returns: NativeIface - - native interface
See: AdvancedCCM.iface

| Param | Type | Description | | --- | --- | --- | | ifacever | string | standard iface:version notation |

DerivedKey

Derived Key interface for planned FTN8 Master key management.

A dummy so far.

Kind: global class

new DerivedKey(ccm, base_id, sequence_id)

| Param | Type | Description | | --- | --- | --- | | ccm | AdvancedCCM | reference to CCM | | base_id | integer | master key ID | | sequence_id | integer | sequence number of the derived key |

derivedKey.baseID() ⇒ integer

Get master key ID

Kind: instance method of DerivedKey
Returns: integer - Base ID

derivedKey.sequenceID() ⇒ integer

Get derived key sequence ID

Kind: instance method of DerivedKey
Returns: integer - Sequence ID

derivedKey.encrypt(as, data) ⇒ Buffer

Encrypt data with current derived key. Useful for very senstive information.

Kind: instance method of DerivedKey
Returns: Buffer - encrypted data

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | steps interface | | data | string | Buffer | to encrypt |

derivedKey.decrypt(as, data) ⇒ Buffer

Decrypt data using current derived key

Kind: instance method of DerivedKey
Returns: Buffer - decrypted data

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | steps interface | | data | Buffer | to decrypt |

ExecutorOptions

Kind: global class

new ExecutorOptions()

Pseudo-class for Executor options documentation

ExecutorOptions.specDirs

Search dirs for spec definition or spec instance directly. It can be single value or array of values. Each value is either path/URL (string) or iface spec instance (object).

Kind: static property of ExecutorOptions
Default: []

ExecutorOptions.prodMode

Production mode - disables some checks without compomising security

Kind: static property of ExecutorOptions
Default: false

ExecutorOptions.reqTimeout

Default request processing timeout

Kind: static property of ExecutorOptions
Default: 5000

ExecutorOptions.heavyReqTimeout

Default request processing timeout for functions marked "heavy". See FTN3

Kind: static property of ExecutorOptions
Default: 60000

ExecutorOptions.securityProvider

FTN8 security interface

Kind: static property of ExecutorOptions

ExecutorOptions.messageSniffer()

Message sniffer callback( iface_info, msg, is_incomming ). Useful for audit logging.

Kind: static method of ExecutorOptions
Default: dummy

Executor

An abstract core implementing pure FTN6 Executor logic.

Kind: global class

new Executor(ccm, opts)

| Param | Type | Description | | --- | --- | --- | | ccm | AdvancedCCM | instance of AdvancedCCM | | opts | objects | see ExecutorOptions |

executor.ccm() ⇒ AdvancedCCM

Get reference to associated AdvancedCCM instance

Kind: instance method of Executor
Returns: AdvancedCCM - CCM ref

executor.register(as, ifacever, impl, specdirs)

Register implementation of specific interface

Kind: instance method of Executor

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | steps interface | | ifacever | string | standard iface:version notation of interface to be implemented. | | impl | object | function | either iface implementation or func( impl, executor ) | | specdirs | object | array | NOT STANDARD. Useful for direct passing of hardcoded spec definition. |

executor.onEndpointRequest(info, ftnreq, send_executor_rsp)

Entry point for Server-originated requests when acting as ClientExecutor

Kind: instance method of Executor
Emits: notExpected, request, response

| Param | Type | Description | | --- | --- | --- | | info | object | raw Invoker interface info | | ftnreq | object | FutoIn request object | | send_executor_rsp | function | callback( ftnrsp ) |

executor.onInternalRequest(as, info, ftnreq, [upload_data], [download_stream])

Entry point for in-program originated requests. Process with maximum efficiency (not yet ;)

Kind: instance method of Executor
Emits: notExpected, request, response
Note: AS result: ftnrsp, content-type

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | steps interface | | info | object | raw Invoker interface info | | ftnreq | object | FutoIn request object | | [upload_data] | object | upload stream, if any | | [download_stream] | object | download stream, if any |

executor.process(as)

Standard entry point used by subclasses. Do full cycle of request processing, including all security checks

NOTE: as.state.reqinfo must point to valid instance of RequestInfo

Kind: instance method of Executor
Emits: notExpected, request, response

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | steps interface |

executor.checkAccess(as, acd)

Shortcut to check access through #acl interface.

NOTE: as.state.reqinfo must point to valid instance of RequestInfo

Kind: instance method of Executor

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | steps interface | | acd | string | access control descriptor |

executor.initFromCache(as)

NOT IMPLEMENTED, DO NOT USE. Just a compliance with the Executor interface from spec.

Kind: instance method of Executor

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | steps interface |

executor.cacheInit(as)

NOT IMPLEMENTED, DO NOT USE. Just a compliance with the Executor interface from spec.

Kind: instance method of Executor

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | steps interface |

executor.close([close_cb])

Shutdown Executor and stop whole processing

Kind: instance method of Executor
Emits: close

| Param | Type | Default | Description | | --- | --- | --- | --- | | [close_cb] | callable | | callback to execute after Executor shutdown |

executor.packPayload(coder, msg) ⇒ string

Not standard. Pack message object into JSON representation. If safe limit of 64K is exceeded then error is raised.

Kind: instance method of Executor
Returns: string - string representation of the message
Emits: notExpected

| Param | Type | Description | | --- | --- | --- | | coder | MessageCoder | message coder instance | | msg | object | message to encode into JSON |

"ready"

May be fired in derived Executors to signal readiness ()

Kind: event emitted by Executor

"request"

Fired when request processing is started. ( reqinfo, rawreq )

Kind: event emitted by Executor

"response"

Fired when request processing is started. ( reqinfo, rawreq )

Kind: event emitted by Executor

"notExpected"

Fired when not expected error occurs ( errmsg, error_info, last_exception, async_stack )

Kind: event emitted by Executor

"close"

Fired when Executor is shutting down. ()

Kind: event emitted by Executor

LegacySecurityProvider

This functionality is provided to provide historical not standard BasicAuth interface. Use of this approach is discouraged.

Kind: global class

new LegacySecurityProvider(as, ccm, secprov)

C-tor

| Param | Type | Default | Description | | --- | --- | --- | --- | | as | AsyncSteps | | AsyncSteps interface | | ccm | AdvancedCCM | | CCM instance | | secprov | SecurityProvider | | optional secprov for chaining |

NodeExecutorOptions ⇐ ExecutorOptions

Kind: global class
Extends: ExecutorOptions

new NodeExecutorOptions()

Pseudo-class for NodeExecutor options documentation

NodeExecutorOptions.httpServer

Provide a pre-configured HTTP server instance or use httpPort [& httpAddr] options

Kind: static property of NodeExecutorOptions
Default:

NodeExecutorOptions.httpAddr

Bind address for internally created HTTP server

Kind: static property of NodeExecutorOptions
Default:

NodeExecutorOptions.httpPort

Bind port for internally created HTTP server

Kind: static property of NodeExecutorOptions
Default:

NodeExecutorOptions.httpPath

Path to server FutoIn request on.

NOTE: if httpServer is provided than all not related requests are silently ignored. Otherwise, immediate error is raised if request path does not match httpPath.

Kind: static property of NodeExecutorOptions
Default: /

NodeExecutorOptions.httpBacklog

Option to configure internally created server backlog

Kind: static property of NodeExecutorOptions
Default:

NodeExecutorOptions.secureChannel

If true, if incoming transport as seen is 'SecureChannel', see FTN3. Useful with reverse proxy and local connections.

Kind: static property of NodeExecutorOptions
Default: false

NodeExecutorOptions.trustProxy

If true, X-Real-IP and X-Forwarded-For will be used as Source Address, if present

Kind: static property of NodeExecutorOptions
Default: false

NodeExecutorOptions.enableLimiter

If true, then request limiter is enabled by default

Kind: static property of NodeExecutorOptions
Default: false

NodeExecutorOptions.cleanupLimitsMS

Interval to run limiter cleanup task for better cache performance and correct reflection of active memory usage.

Kind: static property of NodeExecutorOptions
Default: 60000

NodeExecutorOptions.cleanupConnMS

Interval to run connection cleanup task for WebSockets. If connection is idle for this period then ping is sent. If connection is idle for twice of that period then connection is killed.

Kind: static property of NodeExecutorOptions
Default: 60000

NodeExecutorOptions.limitCacheSize

Auto-detected based posix.getrlimit('nofiles')

Kind: static property of NodeExecutorOptions
Default:

NodeExecutorOptions.limitConf

Startup configuration for NodeExecutor#limitConf(). Please mind it's per v4/v6 scope (prefix length).

Kind: static property of NodeExecutorOptions
Default: {"default":""}

NodeExecutorOptions.addressLimitMap

Startup configuration for NodeExecutor#addressLimitMap()

Kind: static property of NodeExecutorOptions
Default: {}

NodeExecutorOptions.secureObjectPrototype

Controls if SpecTools.secureObjectPrototype() is called upon startup.

Kind: static property of NodeExecutorOptions
Default: true

NodeExecutor

Executor implementation for Node.js/io.js with HTTP and WebSockets transport

Kind: global class

new NodeExecutor(ccm, opts)

| Param | Type | Description | | --- | --- | --- | | ccm | AdvancedCCM | CCM for internal requests | | opts | NodeExecutorOptions | executor options |

nodeExecutor.limitsIPSet ⇒ IPSet

Access address-limit name ipset for efficient dynamic manipulation

Kind: instance property of NodeExecutor
Returns: IPSet - - ref to static address to limit mapping

nodeExecutor.handleHTTPRequest(req, rsp) ⇒ Boolean

Entry point to process HTTP request

Kind: instance method of NodeExecutor
Returns: Boolean - true on success

| Param | Type | Description | | --- | --- | --- | | req | http.IncomingMessage | incoming HTTP request | | rsp | http.ServerResponse | response object |

nodeExecutor.handleWSConnection(upgrade_req, ws)

Entry point to process HTTP upgrade request with WebSocket

Kind: instance method of NodeExecutor

| Param | Type | Description | | --- | --- | --- | | upgrade_req | http.IncomingMessage | original HTTP upgrade request | | ws | WebSocket | WebSockets connection object |

nodeExecutor.limitConf(name, options)

Configure named limits to be used for client's request limiting.

Kind: instance method of NodeExecutor

| Param | Type | Description | | --- | --- | --- | | name | string | name of limit configuration | | options | object | see AsyncSteps Limiter class |

nodeExecutor.addressLimitMap(map)

Configure static address to limit name map

Kind: instance method of NodeExecutor

| Param | Type | Description | | --- | --- | --- | | map | object | limit-name => list of CIDR addresses pairs |

PingService

Implementation of futoin.ping & futoin.anonping interface

Designed to be used as imported part of larger interfaces.

Kind: global class

PingService.register(as, executor) ⇒ PingService

Register futoin.ping interface with Executor

Kind: static method of PingService
Returns: PingService - instance by convention

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | steps interface | | executor | Executor | executor instance |

RequestInfoConst

Kind: global class
See: FTN6 spec

new RequestInfoConst()

Pseudo-class for RequestInfo.info field enumeration

RequestInfoConst.INFO_X509_CN

CN field coming from validated client's x509 certificate, if any

Kind: static property of RequestInfoConst
Default: X509_CN

RequestInfoConst.INFO_PUBKEY

Client provided public key, if any

Kind: static property of RequestInfoConst
Default: PUBKEY

RequestInfoConst.INFO_CLIENT_ADDR

Client address

Kind: static property of RequestInfoConst
Default: CLIENT_ADDR
See: SourceAddress

RequestInfoConst.INFO_SECURE_CHANNEL

Boolean, indicates if transport channel is secure

Kind: static property of RequestInfoConst
Default: SECURE_CHANNEL

RequestInfoConst.INFO_REQUEST_TIME_FLOAT

Implementation define timestamp of request start.

NOTE:it may not be related to absolute time. Please see performance-now NPM module.

Kind: static property of RequestInfoConst
Default: REQUEST_TIME_FLOAT

RequestInfoConst.INFO_SECURITY_LEVEL

Authentication, but not authorization, security level.

Kind: static property of RequestInfoConst
See: RequestInfoConst.SL_*

RequestInfoConst.INFO_USER_INFO

User Info object

Kind: static property of RequestInfoConst
See: UserInfo

RequestInfoConst.INFO_RAW_REQUEST

Raw FutoIn request object

Kind: static property of RequestInfoConst

RequestInfoConst.INFO_RAW_RESPONSE

Raw FutoIn response object

Kind: static property of RequestInfoConst

RequestInfoConst.INFO_DERIVED_KEY

Associated Derived Key

Kind: static property of RequestInfoConst
See: DerivedKey

RequestInfoConst.INFO_HAVE_RAW_UPLOAD

Indicates that input transport provided raw upload stream.

NOTE: service implementation should simply try to open RequestInfo.rawInput()

Kind: static property of RequestInfoConst

RequestInfoConst.INFO_HAVE_RAW_RESULT

Indicates that Executor must provide raw response

NOTE: service implementation should simply try to open RequestInfo.rawOutput()

Kind: static property of RequestInfoConst

RequestInfoConst.INFO_CHANNEL_CONTEXT

Associated transport channel context

Kind: static property of RequestInfoConst
See: ChannelContext

RequestInfoConst.SL_ANONYMOUS

Security Level - Anonymous

Kind: static constant of RequestInfoConst
Default: Anonymous
See: RequestInfoConst.INFO_SECURITY_LEVEL

RequestInfoConst.SL_INFO

Security Level - Info

NOTE: it is level of user authentication, but not authorization. This one is equal to HTTP cookie-based authentication.

Kind: static constant of RequestInfoConst
Default: Info
See: RequestInfoConst.INFO_SECURITY_LEVEL

RequestInfoConst.SL_SAFE_OPS

Security Level - SafeOps

NOTE: it is level of user authentication, but not authorization. This one is equal to HTTP Basic Auth.

Kind: static constant of RequestInfoConst
Default: SafeOps
See: RequestInfoConst.INFO_SECURITY_LEVEL

RequestInfoConst.SL_PRIVILEGED_OPS

Security Level - PrivilegedOps

NOTE: it is level of user authentication, but not authorization. This one equals to multi-factor authentication and signed requests.

Kind: static constant of RequestInfoConst
Default: PrivilegedOps
See: RequestInfoConst.INFO_SECURITY_LEVEL

RequestInfoConst.SL_EXCEPTIONAL_OPS

Security Level - ExceptionalOps

NOTE: it is level of user authentication, but not authorization. This one equals to multi-factor authentication for each action and signed requests.

Kind: static constant of RequestInfoConst
Default: ExceptionalOps
See: RequestInfoConst.INFO_SECURITY_LEVEL

RequestInfoConst.SL_SYSTEM

Security Level - System

NOTE: it is level of user authentication, but not authorization. This one equals to internal system authorization. User never gets such security level.

Kind: static constant of RequestInfoConst
Default: System
See: RequestInfoConst.INFO_SECURITY_LEVEL

RequestInfo

RequestInfo object as defined in FTN6

Kind: global class

new RequestInfo(executor, rawreq)

| Param | Type | Description | | --- | --- | --- | | executor | Executor | _ | | rawreq | object | string | raw request |

requestInfo.params() ⇒ object

Get reference to input params

Kind: instance method of RequestInfo
Returns: object - parameter holder

requestInfo.result(replace) ⇒ object

Get reference to output

Kind: instance method of RequestInfo
Returns: object - result variable holder

| Param | Type | Description | | --- | --- | --- | | replace | * | replace result object |

requestInfo.rawInput() ⇒ object

Get reference to input stream

Kind: instance method of RequestInfo
Returns: object - raw input stream
Throws:

  • RawInputError

requestInfo.rawOutput() ⇒ object

Get reference to output stream

Kind: instance method of RequestInfo
Returns: object - raw output stream
Throws:

  • RawOutputError

requestInfo.executor() ⇒ Executor

Get reference to associated Executor instance

Kind: instance method of RequestInfo
Returns: Executor - _

requestInfo.ccm() ⇒ AdvancedCCM

Get reference to associated Executor's CCM instance

Kind: instance method of RequestInfo
Returns: AdvancedCCM - _

requestInfo.channel() ⇒ ChannelContext

Get reference to channel context

Kind: instance method of RequestInfo
Returns: ChannelContext - _

requestInfo.cancelAfter(time_ms)

Set overall request processing timeout in microseconds.

NOTE: repeat calls override previous value

Kind: instance method of RequestInfo

| Param | Type | Description | | --- | --- | --- | | time_ms | float | set automatic request timeout after specified value of microseconds. 0 - disables timeout |

SecurityProvider

Generic security provider interface

Kind: global class

securityProvider.checkAuth(as, reqinfo, reqmsg, sec)

Check request authentication.

Kind: instance method of SecurityProvider

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | AsyncSteps interface | | reqinfo | RequestInfo | extended request info | | reqmsg | object | request message as is | | sec | array | reqmsg.sec field split by ':' |

securityProvider.signAuto(as, reqinfo, rspmsg) ⇒ boolean

Check if response signature is required and perform signing.

Kind: instance method of SecurityProvider
Returns: boolean - true, if signature is set

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | AsyncSteps interface | | reqinfo | RequestInfo | extended request info | | rspmsg | object | response message as is |

securityProvider.isSigned(reqinfo) ⇒ boolean

Check if request is signed as in MessageSignature constraint.

Kind: instance method of SecurityProvider
Returns: boolean - true, if signed

| Param | Type | Description | | --- | --- | --- | | reqinfo | RequestInfo | extended request info |

securityProvider.checkAccess(as, reqinfo, acd)

Check access through Access Control concept

Kind: instance method of SecurityProvider

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | AsyncSteps interface | | reqinfo | RequestInfo | extended request info | | acd | string | array | access control descriptor |

securityProvider._setUser(as, reqinfo, seclvl, auth_info)

A special helper to set authenticated user info

Kind: instance method of SecurityProvider

| Param | Type | Default | Description | | --- | --- | --- | --- | | as | AsyncSteps | | AsyncSteps interface | | reqinfo | RequestInfo | | extended request info | | seclvl | string | | security level | | auth_info | object | | authentication info | | auth_info.local_id | integer | string | | Local User ID | | auth_info.global_id | string | | Global User ID | | [auth_info.details] | object | | user details |

securityProvider._normalizeQueryParams(as, reqinfo)

Normalize parameters passed through HTTP query. It's important to call this before MAC checking.

Kind: instance method of SecurityProvider

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | AsyncSteps interface | | reqinfo | RequestInfo | extended request info |

SourceAddress

Source Address representation

Kind: global class

new SourceAddress(type, [host], port)

| Param | Type | Description | | --- | --- | --- | | type | string | Type of address | | [host] | string | machine address, if applicable | | port | integer | string | port or path, if applicable |

sourceAddress.asString() ⇒ string

Get a stable string representation

Kind: instance method of SourceAddress
Returns: string - string representation

UserInfo

Class representing user information

Kind: global class

new UserInfo(ccm, local_id, global_id, details)

| Param | Type | Description | | --- | --- | --- | | ccm | AdvancedCCM | reference to CCM | | local_id | integer | local unique ID | | global_id | string | global unique ID | | details | object | user info fields, see UserInfoConst |

userInfo.localID() ⇒ integer

Get local unique ID

Kind: instance method of UserInfo
Returns: integer - Local ID

userInfo.globalID() ⇒ string

Get local global ID

Kind: instance method of UserInfo
Returns: string - Global ID

userInfo.details(as, [user_field_identifiers]) ⇒ AsyncSteps

Get user info details

Kind: instance method of UserInfo
Returns: AsyncSteps - for easy chaining. {object} with details through as.success()

| Param | Type | Description | | --- | --- | --- | | as | AsyncSteps | steps interface | | [user_field_identifiers] | object | field list to get |

FutoInExecutor

window.FutoInExecutor - Browser-only reference to futoin-executor

Kind: global variable

Executor

window.futoin.Executor - Browser-only reference to futoin-executor

Kind: global variable