2.3.7 • Published 1 year ago

futoin-executor v2.3.7

Weekly downloads
25
License
Apache-2.0
Repository
github
Last release
1 year ago

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

ParamTypeDefaultDescription
asAsyncStepsstep interface
ccmAdvancedCCMCCM instance
endpointstringendpoint URL
credentials*see CCM register()
optionsobject{}registration options
options.versionstring"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

ParamTypeDescription
userstringuser name
secretstringuser secret (either password or raw key for HMAC)
detailsobjectuser details the way as defined in FTN8
system_userbooleanis 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)

ParamTypeDescription
asAsyncStepssteps interface
userstringuser 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)

ParamTypeDescription
asAsyncStepssteps interfaces
local_idnumberlocal ID

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

Register users statically right after registration

Kind: instance method of BasicAuthService

ParamTypeDefaultDescription
userstringuser name
secretstringuser secret (either password or raw key for HMAC)
detailsobjectuser details the way as defined in FTN8
system_userbooleanfalseis system user

BasicAuthService.register(as, executor) ⇒ BasicAuthService

BasicAuthService registration helper

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

ParamTypeDescription
asAsyncStepssteps interface
executorExecutorexecutor 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:

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)

ParamTypeDescription
ccmAdvancedCCMCCM ref
optsBrowserExecutorOptionsexecutor options

ChannelContext

Channel Context normally accessible through RequestInfo object.

Kind: global class

new ChannelContext(executor)

ParamTypeDescription
executorExecutorreference 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!

ParamTypeDescription
callablefunctioncallback
user_dataanyoptional 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

ParamTypeDescription
asAsyncStepssteps interface
ifaceverstringstandard iface:version notation
optionsobjectstandard 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

ParamTypeDescription
ifaceverstringstandard 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)

ParamTypeDescription
ccmAdvancedCCMreference to CCM
base_idintegermaster key ID
sequence_idintegersequence 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

ParamTypeDescription
asAsyncStepssteps interface
datastring | Bufferto encrypt

derivedKey.decrypt(as, data) ⇒ Buffer

Decrypt data using current derived key

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

ParamTypeDescription
asAsyncStepssteps interface
dataBufferto 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)

ParamTypeDescription
ccmAdvancedCCMinstance of AdvancedCCM
optsobjectssee 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

ParamTypeDescription
asAsyncStepssteps interface
ifaceverstringstandard iface:version notation of interface to be implemented.
implobject | functioneither iface implementation or func( impl, executor )
specdirsobject | arrayNOT 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

ParamTypeDescription
infoobjectraw Invoker interface info
ftnreqobjectFutoIn request object
send_executor_rspfunctioncallback( 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

ParamTypeDescription
asAsyncStepssteps interface
infoobjectraw Invoker interface info
ftnreqobjectFutoIn request object
upload_dataobjectupload stream, if any
download_streamobjectdownload 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

ParamTypeDescription
asAsyncStepssteps 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

ParamTypeDescription
asAsyncStepssteps interface
acdstringaccess control descriptor

executor.initFromCache(as)

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

Kind: instance method of Executor

ParamTypeDescription
asAsyncStepssteps interface

executor.cacheInit(as)

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

Kind: instance method of Executor

ParamTypeDescription
asAsyncStepssteps interface

executor.close(close_cb)

Shutdown Executor and stop whole processing

Kind: instance method of Executor
Emits: close

ParamTypeDefaultDescription
close_cbcallablecallback 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

ParamTypeDescription
coderMessageCodermessage coder instance
msgobjectmessage 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

ParamTypeDefaultDescription
asAsyncStepsAsyncSteps interface
ccmAdvancedCCMCCM instance
secprovSecurityProvideroptional 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)

ParamTypeDescription
ccmAdvancedCCMCCM for internal requests
optsNodeExecutorOptionsexecutor 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

ParamTypeDescription
reqhttp.IncomingMessageincoming HTTP request
rsphttp.ServerResponseresponse object

nodeExecutor.handleWSConnection(upgrade_req, ws)

Entry point to process HTTP upgrade request with WebSocket

Kind: instance method of NodeExecutor

ParamTypeDescription
upgrade_reqhttp.IncomingMessageoriginal HTTP upgrade request
wsWebSocketWebSockets connection object

nodeExecutor.limitConf(name, options)

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

Kind: instance method of NodeExecutor

ParamTypeDescription
namestringname of limit configuration
optionsobjectsee AsyncSteps Limiter class

nodeExecutor.addressLimitMap(map)

Configure static address to limit name map

Kind: instance method of NodeExecutor

ParamTypeDescription
mapobjectlimit-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

ParamTypeDescription
asAsyncStepssteps interface
executorExecutorexecutor 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)

ParamTypeDescription
executorExecutor_
rawreqobject | stringraw 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

ParamTypeDescription
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

ParamTypeDescription
time_msfloatset 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

ParamTypeDescription
asAsyncStepsAsyncSteps interface
reqinfoRequestInfoextended request info
reqmsgobjectrequest message as is
secarrayreqmsg.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

ParamTypeDescription
asAsyncStepsAsyncSteps interface
reqinfoRequestInfoextended request info
rspmsgobjectresponse 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

ParamTypeDescription
reqinfoRequestInfoextended request info

securityProvider.checkAccess(as, reqinfo, acd)

Check access through Access Control concept

Kind: instance method of SecurityProvider

ParamTypeDescription
asAsyncStepsAsyncSteps interface
reqinfoRequestInfoextended request info
acdstring | arrayaccess control descriptor

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

A special helper to set authenticated user info

Kind: instance method of SecurityProvider

ParamTypeDefaultDescription
asAsyncStepsAsyncSteps interface
reqinfoRequestInfoextended request info
seclvlstringsecurity level
auth_infoobjectauthentication info
auth_info.local_idinteger | stringLocal User ID
auth_info.global_idstringGlobal User ID
auth_info.detailsobjectuser 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

ParamTypeDescription
asAsyncStepsAsyncSteps interface
reqinfoRequestInfoextended request info

SourceAddress

Source Address representation

Kind: global class

new SourceAddress(type, host, port)

ParamTypeDescription
typestringType of address
hoststringmachine address, if applicable
portinteger | stringport 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)

ParamTypeDescription
ccmAdvancedCCMreference to CCM
local_idintegerlocal unique ID
global_idstringglobal unique ID
detailsobjectuser 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()

ParamTypeDescription
asAsyncStepssteps interface
user_field_identifiersobjectfield 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

2.3.7

1 year ago

2.3.6

3 years ago

2.3.5

3 years ago

2.3.4

4 years ago

2.3.3

4 years ago

2.3.2

4 years ago

2.3.1

5 years ago

2.3.0

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.4

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.10.1

6 years ago

1.10.0

6 years ago

1.9.0

6 years ago

1.8.8

6 years ago

1.8.7

6 years ago

1.8.6

6 years ago

1.8.5

6 years ago

1.8.4

6 years ago

1.8.3

6 years ago

1.8.2

6 years ago

1.8.1

6 years ago

1.8.0

6 years ago

1.7.5

6 years ago

1.7.4

6 years ago

1.7.3

6 years ago

1.7.2

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.2

6 years ago

1.6.1

6 years ago

1.6.0

6 years ago

1.5.8

6 years ago

1.5.7

6 years ago

1.5.6

6 years ago

1.5.5

7 years ago

1.5.4

7 years ago

1.5.3

7 years ago

1.5.2

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.3

7 years ago

1.4.2

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.4

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.9.1

7 years ago

0.9.0

7 years ago

0.8.4

7 years ago

0.8.3

8 years ago

0.8.2

8 years ago

0.8.1

8 years ago

0.8.0

9 years ago

0.7.2

9 years ago

0.7.1

9 years ago

0.7.0

9 years ago

0.6.1

9 years ago

0.6.0

9 years ago

0.5.5

9 years ago

0.5.4

9 years ago

0.5.3

9 years ago

0.5.2

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.0

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago