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 - npm Package Compare versions

Comparing version 0.5.3 to 0.5.4

lib/cacheface.js

2

bower.json
{
"name": "futoin-invoker",
"version": "0.5.3",
"version": "0.5.4",
"main": "dist/futoin-invoker.js",

@@ -5,0 +5,0 @@ "moduleType": [

@@ -1,1 +0,1 @@

!function(a){"function"==typeof define&&define.amd?define(["futoin-asyncsteps","lodash"],a):"object"==typeof exports?module.exports=a(require("futoin-asyncsteps"),require("lodash")):this.FutoInInvoker=a($as,_)}(function(a,b){function c(a){var b=c.cache[a];if(!b){var d={};b=c.cache[a]={id:a,exports:d},c.modules[a].call(d,b,d)}return b.exports}var d,e=this;return c.cache=[],c.modules=[function(a,b){"use strict";function d(a){a=a||{};var b=a.specDirs||[];b instanceof Array||(b=[b]),a.specDirs=b,h.SimpleCCMImpl.call(this,a)}var e=c(7),f=c(3),g=f.FutoInError,h=c(6);b=a.exports=function(b){return new a.exports.AdvancedCCMImpl(b)};var i=h.SimpleCCMImpl.prototype;d.prototype={onRegister:function(a,b){e.loadIface(a,b,b.options.specDirs),b.options.prodMode||e.checkConsistency(a,b)},checkParams:function(a,b,c){var d,f=b.info,h=b.name;"SecureChannel"in f.constraints&&!f.secure_channel&&a.error(g.SecurityError,"Requires secure channel"),"AllowAnonymous"in f.constraints||f.creds||a.error(g.SecurityError,"Requires authenticated user"),h in f.funcs||a.error(g.InvokerError,"Unknown interface function");var i=f.funcs[h];b.upload_data&&!i.rawupload&&a.error(g.InvokerError,"Raw upload is not allowed"),!Object.keys(i.params).length&&Object.keys(c).length&&a.error(g.InvokerError,"No params are defined");for(d in c)i.params.hasOwnProperty(d)||a.error(g.InvokerError,"Unknown parameter "+d),e.checkParameterType(a,f,h,d,c[d]);for(d in i.params)c.hasOwnProperty(d)||i.params[d].hasOwnProperty("default")||a.error(g.InvokerError,"Missing parameter "+d)},createMessage:function(a,b,c){b.info.options.prodMode||this.checkParams(a,b,c);var d=b.info,e={f:d.iface+":"+d.version+":"+b.name,p:c};null!==d.creds&&("master"===d.creds||(e.sec=d.creds)),b.expect_response=d.funcs[b.name].expect_result,a.success(e)},onMessageResponse:function(a,b,c){var d=b.info,f=b.name,h=d.funcs[f];if("e"in c){var i=c.e;i in h["throws"]||i in e.standard_errors?a.error(i,c.edesc):a.error(g.InternalError,"Not expected exception from Executor")}h.rawresult&&a.error(g.InternalError,"Raw result is expected"),"master"===d.creds;var j=h.result,k=Object.keys(j).length;for(var l in c.r)j.hasOwnProperty(l)&&(e.checkResultType(a,d,f,l,c.r[l]),--k);k>0&&a.error(g.InternalError,"Missing result variables"),a.success(c.r)},onDataResponse:function(a,b,c){b.info.funcs[b.name].rawresult?a.success(c):a.error(g.InternalError,"Raw result is not expected")},getComms:i.getComms,performCommon:i.performCommon,perfomHTTP:i.perfomHTTP,perfomWebSocket:i.perfomWebSocket,perfomUNIX:i.perfomUNIX,perfomBrowser:i.perfomBrowser},b.AdvancedCCMImpl=d},function(a){!function(b){"use strict";var d=b.FutoIn||{};if("undefined"==typeof d.Invoker){var e=c(4),f=e.SimpleCCM;b.SimpleCCM=f;var g=e.AdvancedCCM;b.AdvancedCCM=g,d.Invoker=e,b.FutoInInvoker=e,b.FutoIn=d,a&&(a.exports=e)}}(window)},function(a,b){"use strict";var d=c(11),e=c(3),f=e.FutoInError,g=WebSocket;b.HTTPComms=function(){},b.HTTPComms.prototype={perform:function(a,b,c){var d=this;a.add(function(a){d._perform(a,b,c)})},_perform:function(a,b,c){var d,e=b.options.messageSniffer,g=new XMLHttpRequest,h=b.endpoint,i=b.upload_data;if(i||""===i){d="application/octet-stream","/"!==h.charAt(h.length-1)&&(h+="/"),h+=c.f.replace(/:/g,"/")+"/","sec"in c&&(h+=c.sec+"/");var j=[];for(var k in c.p)j.push(encodeURIComponent(k)+"="+encodeURIComponent(c.p[k]));h+="?"+j.join("&"),e(b.info,c,!1)}else d="application/futoin+json",i=JSON.stringify(c),e(b.info,i,!1);b.expect_response&&(b.download_stream&&(g.responseType=b.download_stream),g.onreadystatechange=function(){if(this.readyState===this.DONE){var c=b.download_stream?this.response:this.responseText;if(c){var d=this.getResponseHeader("content-type");"application/futoin+json"===d?e(b.info,c,!0):e(b.info,"%DATA%",!0),a.success(c,d)}else try{a.error(f.CommError,"Low error")}catch(g){}}},a.setCancel(function(){g.abort()})),g.open("POST",h,!0),g.setRequestHeader("Content-Type",d),g.send(i),b.expect_response||a.success()}},b.WSComms=function(){this.rid=1,this.reqas={},this.evt=new d},b.WSComms.prototype={_waiting_open:!1,init:function(a,b){var c=b.options,d=new g(b.endpoint);this.ws=d,this._waiting_open=!0;var e=this.reqas,h=c.executor||null,i=b.info,j=this,k=c.messageSniffer;this.sniffer=k;var l=function(a){var b=h.packPayloadJSON(a);k(i,b,!1),d.send(b)},m=function(a){c.disconnectSniffer(i),d.close(),delete j.ws;for(var b in e)try{e[b].error(f.CommError,a.wasClean?"Cleanup":"Error")}catch(g){}delete j.reqas,j.reqas={},j._waiting_open=!1};d.onclose=m,d.onerror=m,d.onopen=function(a){j._waiting_open=!1,j.evt.emit("open")},d.onmessage=function(a){k(i,a.data,!0);var b;try{b=JSON.parse(a.data)}catch(c){return}if("rid"in b){var d=b.rid;d in e?(e[d].success(b,"application/futoin+json"),delete e[d]):"S"===d.charAt(0)&&h&&h.onEndpointRequest(i,b,l)}}},perform:function(a,b,c){var d=this;"ws"in this||d.init(a,b),this._waiting_open&&a.add(function(a){if(d._waiting_open){var b=function(){a.success()};d.evt.once("open",b),a.setCancel(function(){d.evt.removeListener("open",b)})}}),a.add(function(a){d._perform(a,b,c)})},_perform:function(a,b,c){var d=this.reqas,e="C"+this.rid++;b.expect_response&&(d[e]=a,a.setCancel(function(){delete d[e]})),c.rid=e;var f=JSON.stringify(c);this.sniffer(b.info,f,!1),this.ws.send(f)}},g||(b.WSComms=b.HTTPComms),b.BrowserComms=function(){this.rid=1,this.reqas={}},b.BrowserComms.prototype={init:function(a,b){var c=b.options;this.opts=c;var d,e=b.endpoint.split("://",2)[1],g=window;if("parent"===e)e=g.parent;else if(e in g&&"postMessage"in g[e])e=g[e];else{var h=document;d=h.getElementById(e),d?e=d.contentWindow:a.error(f.CommError,"Unknown target: "+e)}e===g&&a.error(f.CommError,"Target matches current window"),this.target=e;var i=this.reqas,j=c.executor||null,k=b.info,l=c.targetOrigin,m=c.messageSniffer;this.sniffer=m;var n=function(a){m(l,a,!1),e.postMessage(a,l||"*")},o=function(a){if(m(k,a.data,!0),!a.source||a.source===e){if(l){if(a.origin!==l)return console.log("Error: peer origin mismatch "),console.log("Error >origin: "+a.origin),void console.log("Error >required: "+l)}else;var b=a.data;if("object"!=typeof b)return void console.log("Not object response: "+b);if("rid"in b){var c=b.rid;if(!("f"in b)&&c in i)i[c].success(b,"application/futoin+json"),delete i[c];else{if(!("f"in b&&"S"===c.charAt(0)&&j))return;j.onEndpointRequest(k,b,n)}a.stopPropagation&&a.stopPropagation()}}};g.addEventListener("message",o,!1)},perform:function(a,b,c){(b.upload_data||b.download_stream)&&a.error(f.CommError,"Raw Data is not supported by Web Messaging yet"),"target"in this||this.init(a,b);var d=this;a.add(function(a){var e=d.reqas,f="C"+d.rid++;b.expect_response&&(e[f]=a,a.setCancel(function(a){delete e[f]})),c.rid=f,d.sniffer(b.info,c,!1),d.target.postMessage(c,d.opts.targetOrigin||"*")})}}},function(a,b){"use strict";var d=c(9);b.AsyncSteps=d,b.FutoInError=d.FutoInError,b.Options={OPT_CALL_TIMEOUT_MS:"callTimeoutMS",OPT_PROD_MODE:"prodMode",OPT_COMM_CONFIG_CB:"commConfigCallback",OPT_MSG_SNIFFER:"messageSniffer",OPT_DISCONNECT_SNIFFER:"disconnectSniffer",OPT_SPEC_DIRS:"specDirs",OPT_EXECUTOR:"executor",OPT_TARGET_ORIGIN:"targetOrigin",OPT_RETRY_COUNT:"retryCount",SAFE_PAYLOAD_LIMIT:65536},b._ifacever_pattern=/^(([a-z][a-z0-9]*)(\.[a-z][a-z0-9]*)*):(([0-9]+)\.([0-9]+))$/},function(a,b){"use strict";function d(a){this._iface_info={},this._iface_impl={},this._impl=j(a)}function e(a){this._iface_info={},this._iface_impl={},this._impl=k(a)}var f=c(3),g=f.FutoInError,h=c(5),i=c(10),j=c(6),k=c(0),l=c(7),m={SVC_RESOLVER:"#resolver",SVC_AUTH:"#auth",SVC_DEFENSE:"#defense",SVC_ACL:"#acl",SVC_LOG:"#log",SVC_CACHE_:"#cache."};i.extend(m,f.Options),i.extend(d,m);var n={_secure_replace:/^secure\+/,_secure_test:/^(https|wss|unix):\/\//,_native_iface_builder:function(a,b){return h(a,b)}};i.extend(n,m),n.register=function(a,b,c,d,e,h){var j=null===b;!j&&b in this._iface_info&&a.error(g.InvokerError,"Already registered");var k=c.match(f._ifacever_pattern);null===k&&a.error(g.InvokerError,"Invalid ifacever");var l,m=k[1],n=k[4],o=k[5],p=k[6],q=!1,r=null,s=!1;if(j)l="callback",s=!0;else if("string"==typeof d)switch(this._secure_replace.test(d)?(q=!0,d=d.replace(this._secure_replace,"")):this._secure_test.test(d)&&(q=!0),r=this._native_iface_builder,l=d.split(":")[0]){case"http":case"https":break;case"ws":case"wss":case"unix":s=!0;break;case"browser":h&&h.targetOrigin&&(q=!0),s=!0;break;default:a.error(g.InvokerError,"Unknown endpoint schema")}else q=!0,r=d,d=null,l=null,s=!0;h=h||{},i.defaults(h,this._impl.options);var t={iface:m,version:n,mjrver:o,mnrver:p,endpoint:d,endpoint_scheme:l,creds:e||null,secure_channel:q,impl:r,regname:b,inherits:null,funcs:null,constraints:null,options:h,_invoker_use:!0,_user_info:null};b&&(this._iface_info[b]=t);var u=this;a.add(function(a){u._impl.onRegister(a,t),a.add(function(a){"SecureChannel"in t.constraints&&!q&&a.error(g.SecurityError,"SecureChannel is required"),"BiDirectChannel"in t.constraints&&!s&&a.error(g.InvokerError,"BiDirectChannel is required"),j&&a.success(t,u._native_iface_builder(u._impl,t))})},function(a,c){b&&delete u._iface_info[b]})},n.iface=function(a){var b=this._iface_info[a];if(!b)throw new Error(g.InvokerError);var c=b.regname,d=this._iface_impl[c];return d||(d=b.impl(this._impl,b),this._iface_impl[c]=d),d},n.unRegister=function(a){var b=this._iface_info[a];if(!b)throw new Error(g.InvokerError);var c=b.regname;if(c===a){if(delete this._iface_info[c],delete this._iface_impl[c],b.aliases)for(var d=b.aliases,e=0;e<d.length;++e)delete this._iface_info[d[e]]}else delete this._iface_info[a],b.aliases.splice(b.aliases.indexOf(a),0)},n.defense=function(){return this.iface(this.SVC_DEFENSE)},n.log=function(){return this.iface(this.SVC_LOG)},n.cache=function(a){return this.iface(this.SVC_CACHE_+(a||"default"))},n.assertIface=function(a,b){var c=this._iface_info[a];if(!c)throw new Error(g.InvokerError);var d=b.match(f._ifacever_pattern);if(null===d)throw new Error(g.InvokerError);var e=d[1],h=d[5],i=d[6];if(c.iface!==e||c.mjrver!==h||c.mnrver<i)throw new Error(g.InvokerError)},n.alias=function(a,b){var c=this._iface_info[a];if(!c||this._iface_info[b])throw new Error(g.InvokerError);this._iface_info[b]=c,c.aliases?c.aliases.push(b):c.aliases=[b]},d.prototype=n,i.extend(e,m);var o={};i.extend(o,n),o.initFromCache=function(a,b){a.error(g.NotImplemented,"Caching is not supported yet")},o.cacheInit=function(a){},e.prototype=o,b.SimpleCCM=d,b.AdvancedCCM=e,b.FutoInError=g,b.NativeIface=h.NativeIface,b.InterfaceInfo=h.InterfaceInfo,b.SpecTools=l,b.SpecTools._ifacever_pattern=f._ifacever_pattern},function(a,b){"use strict";function d(a){this._raw_info=a}function e(a,b){this._ccmimpl=a,this._raw_info=b,this._iface_info=null,this._comms={};for(var c in this._raw_info.funcs){var d=this._raw_info.funcs[c];d.rawupload||c in this||(this[c]=this._member_call_generate(c,d))}}var f=c(4),g=c(10);b=a.exports=function(b,c){return new a.exports.NativeIface(b,c)},d.prototype={name:function(){return this._raw_info.iface},version:function(){return this._raw_info.version},inherits:function(){return this._raw_info.inherits},funcs:function(){return this._raw_info.funcs},constraints:function(){return this._raw_info.constraints}},b.InterfaceInfo=d,e.prototype={call:function(a,b,c,d,e,g){c=c||{};var h=this._raw_info,i={ccmimpl:this._ccmimpl,name:b,info:h,upload_data:d,download_stream:e,rsp_content_type:null,native_iface:this,options:h.options,endpoint:h.endpoint,expect_response:!0},j=this._ccmimpl;a.add(function(a){j.createMessage(a,i,c)}),a.add(function(a,c){"number"!=typeof g&&(g=i.info.options.callTimeoutMS),g>0&&a.setTimeout(g);var d=h.endpoint_scheme;if("http"===d||"https"===d)j.perfomHTTP(a,i,c);else if("ws"===d||"wss"===d){var e,k=i.download_stream||i.info.funcs&&(e=i.info.funcs[b])&&e.rawresult;i.upload_data||k?(i.endpoint=i.endpoint.replace("ws","http"),i.rawresult=k,j.perfomHTTP(a,i,c)):j.perfomWebSocket(a,i,c)}else i.upload_data?a.error(f.FutoInError.InvokerError,"Upload data is allowed only for HTTP/WS endpoints"):i.download_stream?a.error(f.FutoInError.InvokerError,"Download stream is allowed only for HTTP/WS endpoints"):"browser"===d?j.perfomBrowser(a,i,c):"unix"===d?j.perfomUNIX(a,i,c):"callback"===d?i.endpoint(a,i,c):a.error(f.FutoInError.InvokerError,"Unknown endpoint scheme");a.add(function(a,b,c){if(i.expect_response)if(i.download_stream)a.success(!0);else if("application/futoin+json"===c){if("string"==typeof b)try{b=JSON.parse(b)}catch(d){a.error(f.FutoInError.CommError,"JSON:"+d.message)}j.onMessageResponse(a,i,b)}else j.onDataResponse(a,i,b);else a.success()})})},_member_call_intercept:function(a,b,c,d){var e=c.params,h=Object.keys(e);d.length>h.length?a.error(f.FutoInError.InvokerError,"Unknown parameters"):d.length<c.min_args?a.error(f.FutoInError.InvokerError,"Missing parameters"):d.length<h.length&&(h=h.splice(0,d.length));var i=g.object(h,d);this.call(a,b,i)},_member_call_generate:function(a,b){return function(c){this._member_call_intercept(c,a,b,Array.prototype.slice.call(arguments,1))}},ifaceInfo:function(){return this._iface_info||(this._iface_info=new d(this._raw_info)),this._iface_info},burst:function(){throw new Error(f.FutoInError.InvokerError,"Not Implemented")},bindDerivedKey:function(){throw new Error(f.FutoInError.InvokerError,"Not Implemented")}},b.NativeIface=e},function(a,b){"use strict";function d(a){a=a||{},i.defaults(a,k),this.options=a,this.comms={}}var e,f=c(3),g=f.FutoInError,h=c(8),i=c(10);if(h){var j=require;e=j("./node_comms")}else e=c(2);b=a.exports=function(b){return new a.exports.SimpleCCMImpl(b)};var k={callTimeoutMS:3e4,prodMode:!1,commConfigCallback:null,retryCount:1,messageSniffer:function(){},disconnectSniffer:function(){}};d.prototype={onRegister:function(a,b){b.funcs={},b.inherits=[],b.constraints={}},createMessage:function(a,b,c){var d=b.info,e={f:d.iface+":"+d.version+":"+b.name,p:c,forcersp:!0};null!==d.creds&&"master"!==d.creds&&(e.sec=d.creds),a.success(e)},onMessageResponse:function(a,b,c){"e"in c?a.error(c.e,c.edesc):a.success(c.r)},onDataResponse:function(a,b,c){a.success(c)},getComms:function(a,b,c,d){var e,f,h=b.options,i=this.options;h.executor!==i.executor||h.messageSniffer!==i.messageSniffer||h.disconnectSniffer!==i.disconnectSniffer||h.commConfigCallback!==i.commConfigCallback?(e=b.native_iface._comms,f=b.info.endpoint_scheme):(e=this.comms,f=b.endpoint+"##"+(b.credentials||"")+"##"+(d||""));var j=e[f];return j||(c||a.error(g.InvokerError,"Not implemented "+b.info.endpoint_scheme+" scheme"),j=new c,e[f]=j),j},performCommon:function(a,b,c,d){var e,f;a.repeat(b.options.retryCount+1,function(a){a.add(function(a){d.perform(a,b,c),a.add(function(a,b,c){e=b,f=c,a["break"]()})},function(a,b){b===g.CommError&&a["continue"]()})}).add(function(a){a.success(e,f)})},perfomHTTP:function(a,b,c){var d=this.getComms(a,b,e.HTTPComms);this.performCommon(a,b,c,d)},perfomWebSocket:function(a,b,c){var d=this.getComms(a,b,e.WSComms);this.performCommon(a,b,c,d)},perfomUNIX:function(a,b,c){a.error(g.InvokerError,"Not implemented unix:// scheme")},perfomBrowser:function(a,b,c){var d=this.getComms(a,b,e.BrowserComms,b.options.targetOrigin);d.perform(a,b,c)}},b.SimpleCCMImpl=d},function(a){"use strict";var b,d,e=c(3),f=e.FutoInError,g=c(8),h=c(10);if(g){var i=require;b=i("fs"),d=i("request")}var j={standard_errors:{UnknownInterface:!0,NotSupportedVersion:!0,NotImplemented:!0,Unauthorized:!0,InternalError:!0,InvalidRequest:!0,DefenseRejected:!0,PleaseReauth:!0,SecurityError:!0},_ver_pattern:/^([0-9]+)\.([0-9]+)$/,loadIface:function(a,c,e){var h=null;a.forEach(e,function(a,e,f){var i=c.iface+"-"+c.version+"-iface.json";a.add(function(a){if("string"==typeof f&&g){var c=f+"/"+i,e=function(b){if(a){try{return f=JSON.parse(b),f._just_loaded=!0,void a.success()}catch(c){}try{a["continue"]()}catch(c){}}};"http"===c.substr(0,4)?d(c,function(a,b,c){e(c)}):b.readFile(c,{encoding:"utf8"},function(a,b){e(b)}),a.setCancel(function(b){a=null})}}).add(function(a){if("string"==typeof f&&!g){var b=f+"/"+i,c=new XMLHttpRequest;c.onreadystatechange=function(){if(this.readyState===this.DONE){var b=this.responseText;if(b)try{return f=JSON.parse(b),f._just_loaded=!0,void a.success()}catch(c){}try{a["continue"]()}catch(d){}}},c.open("GET",b,!0),c.send(),a.setCancel(function(a){c.abort()})}}).add(function(a){"object"==typeof f&&f.iface===c.iface&&f.version===c.version&&(h=f,a["break"]())})}).add(function(a){null===h&&a.error(f.InternalError,"Failed to load valid spec for "+c.iface+":"+c.version),j.parseIface(a,c,e,h)})},parseIface:function(a,b,c,d){if(d._just_loaded?(b.funcs=d.funcs||{},b.types=d.types||{}):(b.funcs=h.cloneDeep(d.funcs||{}),b.types=h.cloneDeep(d.types||{})),j._parseFuncs(a,b),j._parseTypes(a,b),"requires"in d){var g=d.requires;Array.isArray(g)||a.error(f.InternalError,'"requires" is not array'),b.constraints=h.object(g,g)}else b.constraints={};if(j._checkFTN3Rev(a,b,d),b.inherits=[],"inherit"in d){var i=d.inherit.match(e._ifacever_pattern);null===i&&a.error(f.InvokerError,"Invalid inherit ifacever: "+d.inherit);var k={};k.iface=i[1],k.version=i[4],j.loadIface(a,k,c),a.add(function(a){j._parseImportInherit(a,b,c,d,k),b.inherits.push(d.inherit),b.inherits=b.inherits.concat(k.inherits)})}"imports"in d?(b.imports=d.imports.slice(),a.forEach(d.imports,function(a,g,h){var i=h.match(e._ifacever_pattern);null===i&&a.error(f.InvokerError,"Invalid import ifacever: "+h);var k={};k.iface=i[1],k.version=i[4],j.loadIface(a,k,c),a.add(function(a){j._parseImportInherit(a,b,c,d,k),b.imports=b.imports.concat(k.imports)})})):b.imports=[]},_checkFTN3Rev:function(a,b,c){var d=c.ftn3rev||"1.0",e=d.match(j._ver_pattern);null===e&&a.error(f.InternalError,"Invalid ftn3rev field");var g=parseInt(e[1]),h=parseInt(e[2]);1===g?(1>h&&(c.imports||c.types||"BiDirectChannel"in b.constraints)&&a.error(f.InternalError,"Missing ftn3rev field when FTN3 v1.1 features are used"),!b._invoker_use&&h>1&&a.error(f.InternalError,"Not supported FTN3 revision for Executor")):a.error(f.InternalError,"Not supported FTN3 revision")},_parseFuncs:function(a,b){var c,d;for(var e in b.funcs){if(c=b.funcs[e],c.min_args=0,"params"in c){var g=c.params;"object"!=typeof g&&a.error(f.InternalError,"Invalid params object");for(d in g){var i=g[d];"object"!=typeof i&&a.error(f.InternalError,"Invalid param object"),"type"in i||a.error(f.InternalError,"Missing type for params"),"default"in i||(c.min_args+=1)}}else c.params={};if(c.expect_result=!1,"result"in c){var j=c.result;"object"!=typeof j&&a.error(f.InternalError,"Invalid result object");for(var k in j){var l=j[k];"object"!=typeof l&&a.error(f.InternalError,"Invalid resultvar object"),"type"in l||a.error(f.InternalError,"Missing type for result"),c.expect_result=!0}}else c.result={};if("rawupload"in c||(c.rawupload=!1),"rawresult"in c||(c.rawresult=!1),c.rawresult&&(c.expect_result=!0),"throws"in c){c.expect_result||a.error(f.InternalError,'"throws" without result');var m=c["throws"];Array.isArray(m)||a.error(f.InternalError,'"throws" is not array'),c["throws"]=h.object(m,m)}else c["throws"]={}}},_parseTypes:function(a,b){var c;for(var d in b.types)if(c=b.types[d],"type"in c||a.error(f.InternalError,'Missing "type" for custom type'),"map"===c.type){if(!("fields"in c)){c.fields={};continue}for(var e in c.fields)"type"in c.fields[e]||a.error(f.InternalError,'Missing "type" for custom type field')}},_parseImportInherit:function(a,b,c,d,e){var g,i;for(var j in e.types)j in b.types?a.error(f.InternalError,"Iface type redifintion: "+j):b.types[j]=e.types[j];for(var k in e.funcs){var l=e.funcs[k];if(k in b.funcs){var m=l.params,n=b.funcs[k].params,o=Object.keys(m),p=Object.keys(n);for(p.length<o.length&&a.error(f.InternalError,"Invalid param count for '"+k+"'"),g=0;g<o.length;++g)i=o[g],i!==p[g]&&a.error(f.InternalError,"Invalid param order for '"+k+"/"+i+"'"),m[i].type!==n[i].type&&a.error(f.InternalError,"Param type mismatch '"+k+"/"+i+"'");for(;g<p.length;++g)i=p[g],i in m||"default"in n[i]||null===n[i]||a.error(f.InternalError,"Missing default for '"+k+"/"+i+"'");l.rawresult!==b.funcs[k].rawresult&&a.error(f.InternalError,"'rawresult' flag mismatch for '"+k+"'"),l.rawupload&&!b.funcs[k].rawupload&&a.error(f.InternalError,"'rawupload' flag is missing for '"+k+"'")}else b.funcs[k]=l}h.difference(Object.keys(e.constraints),d.requires).length&&a.error(f.InternalError,"Missing constraints from inherited")},checkConsistency:function(a,b){},checkType:function(a,b,c,d){if(null===c)return!1;switch(b){case"any":return!0;case"boolean":case"string":case"number":return typeof c===b;case"map":return"object"==typeof c&&!(c instanceof Array);case"integer":return"number"==typeof c&&(0|c)===c;case"array":return c instanceof Array;default:if(!("types"in a&&b in a.types))return!1}if(b in a.types){var e=a.types[b];d=d||{};var g=e.type;if(g in d)throw console&&console.log("[ERROR] Custom type recursion: "+e),new Error(f.InternalError);if(d[b]=!0,!this.checkType(a,g,c,d))return!1;switch(g){case"integer":case"number":return"min"in e&&c<e.min?!1:"max"in e&&c>e.max?!1:!0;case"string":if("regex"in e){var h;return"_comp_regex"in a?h=a._comp_regex:(h={},a._comp_regex=h),b in h||(h[b]=new RegExp(e.regex)),null!==c.match(h[b])}return!0;case"array":var i=c.length;if("minlen"in e&&i<e.minlen)return!1;if("maxlen"in e&&i>e.maxlen)return!1;if("elemtype"in e)for(var j=e.elemtype,k=0;i>k;++k)if(!this.checkType(a,j,c[k],[]))return!1;return!0;case"map":var l=e.fields;for(var m in l){var n=l[m];if(!(m in c)||null===c[m])return n.optional?(c[m]=null,!0):!1;if(!this.checkType(a,n.type,c[m],[]))return!1}return!0}}return!1},checkParameterType:function(a,b,c,d,e){j.checkType(b,b.funcs[c].params[d].type,e)||a.error(f.InvalidRequest,"Type mismatch for parameter: "+d)},checkResultType:function(a,b,c,d,e){j.checkType(b,b.funcs[c].result[d].type,e)||a.error(f.InvalidRequest,"Type mismatch for result: "+d)},checkFutoInType:function(a,b,c,d){j.checkType({},b,d)||a.error(f.InvalidRequest,"Type mismatch for parameter: "+c)}};a.exports=j},function(a){a.exports=!1;try{a.exports="[object process]"===Object.prototype.toString.call(e.process)}catch(b){}},function(b){b.exports=a},function(a){a.exports=b},function(a){(function(){"use strict";function b(){}function c(a,b){for(var c=a.length;c--;)if(a[c].listener===b)return c;return-1}function e(a){return function(){return this[a].apply(this,arguments)}}var f=b.prototype,g=this,h=g.EventEmitter;f.getListeners=function(a){var b,c,d=this._getEvents();if(a instanceof RegExp){b={};for(c in d)d.hasOwnProperty(c)&&a.test(c)&&(b[c]=d[c])}else b=d[a]||(d[a]=[]);return b},f.flattenListeners=function(a){var b,c=[];for(b=0;b<a.length;b+=1)c.push(a[b].listener);return c},f.getListenersAsObject=function(a){var b,c=this.getListeners(a);return c instanceof Array&&(b={},b[a]=c),b||c},f.addListener=function(a,b){var d,e=this.getListenersAsObject(a),f="object"==typeof b;for(d in e)e.hasOwnProperty(d)&&-1===c(e[d],b)&&e[d].push(f?b:{listener:b,once:!1});return this},f.on=e("addListener"),f.addOnceListener=function(a,b){return this.addListener(a,{listener:b,once:!0})},f.once=e("addOnceListener"),f.defineEvent=function(a){return this.getListeners(a),this},f.defineEvents=function(a){for(var b=0;b<a.length;b+=1)this.defineEvent(a[b]);return this},f.removeListener=function(a,b){var d,e,f=this.getListenersAsObject(a);for(e in f)f.hasOwnProperty(e)&&(d=c(f[e],b),-1!==d&&f[e].splice(d,1));return this},f.off=e("removeListener"),f.addListeners=function(a,b){return this.manipulateListeners(!1,a,b)},f.removeListeners=function(a,b){return this.manipulateListeners(!0,a,b)},f.manipulateListeners=function(a,b,c){var d,e,f=a?this.removeListener:this.addListener,g=a?this.removeListeners:this.addListeners;if("object"!=typeof b||b instanceof RegExp)for(d=c.length;d--;)f.call(this,b,c[d]);else for(d in b)b.hasOwnProperty(d)&&(e=b[d])&&("function"==typeof e?f.call(this,d,e):g.call(this,d,e));return this},f.removeEvent=function(a){var b,c=typeof a,d=this._getEvents();if("string"===c)delete d[a];else if(a instanceof RegExp)for(b in d)d.hasOwnProperty(b)&&a.test(b)&&delete d[b];else delete this._events;return this},f.removeAllListeners=e("removeEvent"),f.emitEvent=function(a,b){var c,d,e,f,g=this.getListenersAsObject(a);for(e in g)if(g.hasOwnProperty(e))for(d=g[e].length;d--;)c=g[e][d],c.once===!0&&this.removeListener(a,c.listener),f=c.listener.apply(this,b||[]),f===this._getOnceReturnValue()&&this.removeListener(a,c.listener);return this},f.trigger=e("emitEvent"),f.emit=function(a){var b=Array.prototype.slice.call(arguments,1);return this.emitEvent(a,b)},f.setOnceReturnValue=function(a){return this._onceReturnValue=a,this},f._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},f._getEvents=function(){return this._events||(this._events={})},b.noConflict=function(){return g.EventEmitter=h,b},"function"==typeof d&&d.amd?d(function(){return b}):"object"==typeof a&&a.exports?a.exports=b:g.EventEmitter=b}).call(this)}],c(1)});
!function(a){"function"==typeof define&&define.amd?define(["futoin-asyncsteps","lodash"],a):"object"==typeof exports?module.exports=a(require("futoin-asyncsteps"),require("lodash")):this.FutoInInvoker=a($as,_)}(function(a,b){function c(a){var b=c.cache[a];if(!b){var d={};b=c.cache[a]={id:a,exports:d},c.modules[a].call(d,b,d)}return b.exports}var d=this;return c.cache=[],c.modules=[function(a,b){"use strict";function d(a){a=a||{};var b=a.specDirs||[];b instanceof Array||(b=[b]),a.specDirs=b,h.SimpleCCMImpl.call(this,a)}var e=c(7),f=c(3),g=f.FutoInError,h=c(6);b=a.exports=function(b){return new a.exports.AdvancedCCMImpl(b)};var i=h.SimpleCCMImpl.prototype;d.prototype={onRegister:function(a,b){e.loadIface(a,b,b.options.specDirs),b.options.prodMode||e.checkConsistency(a,b)},checkParams:function(a,b,c){var d,f=b.info,h=b.name;"SecureChannel"in f.constraints&&!f.secure_channel&&a.error(g.SecurityError,"Requires secure channel"),"AllowAnonymous"in f.constraints||f.creds||a.error(g.SecurityError,"Requires authenticated user"),h in f.funcs||a.error(g.InvokerError,"Unknown interface function: "+h);var i=f.funcs[h];b.upload_data&&!i.rawupload&&a.error(g.InvokerError,"Raw upload is not allowed"),!Object.keys(i.params).length&&Object.keys(c).length&&a.error(g.InvokerError,"No params are defined");for(d in c)i.params.hasOwnProperty(d)||a.error(g.InvokerError,"Unknown parameter: "+d),e.checkParameterType(a,f,h,d,c[d]);for(d in i.params)c.hasOwnProperty(d)||i.params[d].hasOwnProperty("default")||a.error(g.InvokerError,"Missing parameter "+d)},createMessage:function(a,b,c){b.info.options.prodMode||this.checkParams(a,b,c);var d=b.info,e={f:d.iface+":"+d.version+":"+b.name,p:c};null!==d.creds&&("master"===d.creds||(e.sec=d.creds)),b.expect_response=d.funcs[b.name].expect_result,a.success(e)},onMessageResponse:function(a,b,c){var d=b.info,f=b.name,h=d.funcs[f];if("e"in c){var i=c.e;i in h["throws"]||i in e.standard_errors?a.error(i,c.edesc):a.error(g.InternalError,"Not expected exception from Executor")}h.rawresult&&a.error(g.InternalError,"Raw result is expected"),"master"===d.creds;var j=h.result,k=Object.keys(j).length;for(var l in c.r)j.hasOwnProperty(l)&&(e.checkResultType(a,d,f,l,c.r[l]),--k);k>0&&a.error(g.InternalError,"Missing result variables"),a.success(c.r)},onDataResponse:function(a,b,c){b.info.funcs[b.name].rawresult?a.success(c):a.error(g.InternalError,"Raw result is not expected")},getComms:i.getComms,performCommon:i.performCommon,perfomHTTP:i.perfomHTTP,perfomWebSocket:i.perfomWebSocket,perfomUNIX:i.perfomUNIX,perfomBrowser:i.perfomBrowser},b.AdvancedCCMImpl=d},function(a){!function(b){"use strict";var d=b.FutoIn||{};if("undefined"==typeof d.Invoker){var e=c(4),f=e.SimpleCCM;b.SimpleCCM=f;var g=e.AdvancedCCM;b.AdvancedCCM=g,d.Invoker=e,b.FutoInInvoker=e,b.FutoIn=d,a&&(a.exports=e)}}(window)},function(a,b){"use strict";var d=c(9),e=c(3),f=e.FutoInError,g=WebSocket;b.HTTPComms=function(){},b.HTTPComms.prototype={close:function(){},perform:function(a,b,c){var d=this;a.add(function(a){d._perform(a,b,c)})},_perform:function(a,b,c){var d,e=b.options.messageSniffer,g=new XMLHttpRequest,h=b.endpoint,i=b.upload_data;if(i||""===i){d="application/octet-stream","/"!==h.charAt(h.length-1)&&(h+="/"),h+=c.f.replace(/:/g,"/")+"/","sec"in c&&(h+=c.sec+"/");var j=[];for(var k in c.p)j.push(encodeURIComponent(k)+"="+encodeURIComponent(c.p[k]));h+="?"+j.join("&"),e(b.info,c,!1)}else d="application/futoin+json",i=JSON.stringify(c),e(b.info,i,!1);b.expect_response&&(b.download_stream&&(g.responseType=b.download_stream),g.onreadystatechange=function(){if(this.readyState===this.DONE){var c=b.download_stream?this.response:this.responseText;if(c){var d=this.getResponseHeader("content-type");"application/futoin+json"===d?e(b.info,c,!0):e(b.info,"%DATA%",!0),a.success(c,d)}else try{a.error(f.CommError,"Low error")}catch(g){}}},a.setCancel(function(){g.abort()})),g.open("POST",h,!0),g.setRequestHeader("Content-Type",d),g.send(i),b.expect_response||a.success()}},b.WSComms=function(){this.rid=1,this.reqas={},this.evt=d()},b.WSComms.prototype={_waiting_open:!1,init:function(a,b){var c=b.options,d=new g(b.endpoint);this.ws=d,this._waiting_open=!0;var e=this.reqas,h=c.executor||null,i=b.info,j=this,k=c.messageSniffer;this.sniffer=k;var l=function(a){var b=h.packPayloadJSON(a);k(i,b,!1),d.send(b)},m=function(a){c.disconnectSniffer(i),d.close(),delete j.ws;for(var g in e)try{e[g].error(f.CommError,a.wasClean?"Cleanup":"Error")}catch(h){}delete j.reqas,j.reqas={},j._waiting_open=!1,b.native_iface.emit("disconnect")};d.onclose=m,d.onerror=m,d.onopen=function(a){j._waiting_open=!1,j.evt.emit("open"),b.native_iface.emit("connect")},d.onmessage=function(a){k(i,a.data,!0);var b;try{b=JSON.parse(a.data)}catch(c){return}if("rid"in b){var d=b.rid;d in e?(e[d].success(b,"application/futoin+json"),delete e[d]):"S"===d.charAt(0)&&h&&h.onEndpointRequest(i,b,l)}}},close:function(){this.ws&&this.ws.close()},perform:function(a,b,c){var d=this;"ws"in this||d.init(a,b),this._waiting_open&&a.add(function(a){if(d._waiting_open){var b=function(){a.success()};d.evt.once("open",b),a.setCancel(function(){d.evt.off("open",b)})}}),a.add(function(a){d._perform(a,b,c)})},_perform:function(a,b,c){"ws"in this||a.error(f.CommError,"Disconnect while in progress");var d=this.reqas,e="C"+this.rid++;b.expect_response&&(d[e]=a,a.setCancel(function(){delete d[e]})),c.rid=e;var g=JSON.stringify(c);this.sniffer(b.info,g,!1),this.ws.send(g)}},g||(b.WSComms=b.HTTPComms),b.BrowserComms=function(){this.rid=1,this.reqas={}},b.BrowserComms.prototype={init:function(a,b){var c=b.options;this.opts=c;var d,e=b.endpoint.split("://",2)[1],g=window;if("parent"===e)e=g.parent;else if(e in g&&"postMessage"in g[e])e=g[e];else{var h=document;d=h.getElementById(e),d?e=d.contentWindow:a.error(f.CommError,"Unknown target: "+e)}e===g&&a.error(f.CommError,"Target matches current window"),this.target=e;var i=this.reqas,j=c.executor||null,k=b.info,l=c.targetOrigin,m=c.messageSniffer;this.sniffer=m;var n=function(a){m(l,a,!1),e.postMessage(a,l||"*")},o=function(a){if(m(k,a.data,!0),!a.source||a.source===e){if(l){if(a.origin!==l)return console.log("Error: peer origin mismatch "),console.log("Error >origin: "+a.origin),void console.log("Error >required: "+l)}else;var b=a.data;if("object"!=typeof b)return void console.log("Not object response: "+b);if("rid"in b){var c=b.rid;if(!("f"in b)&&c in i)i[c].success(b,"application/futoin+json"),delete i[c];else{if(!("f"in b&&"S"===c.charAt(0)&&j))return;j.onEndpointRequest(k,b,n)}a.stopPropagation&&a.stopPropagation()}}};g.addEventListener("message",o,!1),b.native_iface.emit("connect")},close:function(){this.target&&(this.target=null)},perform:function(a,b,c){(b.upload_data||b.download_stream)&&a.error(f.CommError,"Raw Data is not supported by Web Messaging yet"),this.target||this.init(a,b);var d=this;a.add(function(a){var e=d.reqas,f="C"+d.rid++;b.expect_response&&(e[f]=a,a.setCancel(function(a){delete e[f]})),c.rid=f,d.sniffer(b.info,c,!1),d.target.postMessage(c,d.opts.targetOrigin||"*")})}}},function(a,b){"use strict";var d=c(24);b.AsyncSteps=d,b.FutoInError=d.FutoInError,b.Options={OPT_CALL_TIMEOUT_MS:"callTimeoutMS",OPT_PROD_MODE:"prodMode",OPT_COMM_CONFIG_CB:"commConfigCallback",OPT_MSG_SNIFFER:"messageSniffer",OPT_DISCONNECT_SNIFFER:"disconnectSniffer",OPT_SPEC_DIRS:"specDirs",OPT_EXECUTOR:"executor",OPT_TARGET_ORIGIN:"targetOrigin",OPT_RETRY_COUNT:"retryCount",SAFE_PAYLOAD_LIMIT:65536,SVC_RESOLVER:"#resolver",SVC_AUTH:"#auth",SVC_DEFENSE:"#defense",SVC_ACL:"#acl",SVC_LOG:"#log",SVC_CACHE_:"#cache."},b._ifacever_pattern=/^(([a-z][a-z0-9]*)(\.[a-z][a-z0-9]*)*):(([0-9]+)\.([0-9]+))$/},function(a,b){"use strict";function d(a){m(this),this._iface_info={},this._iface_impl={},this._impl=j(a),i.extend(this,o)}function e(a){m(this),this._iface_info={},this._iface_impl={},this._impl=k(a),i.extend(this,p)}var f=c(3),g=f.FutoInError,h=c(5),i=c(25),j=c(6),k=c(0),l=c(7),m=c(9),n=f.Options;i.extend(d,n);var o={_secure_replace:/^secure\+/,_secure_test:/^(https|wss|unix):\/\//,_native_iface_builder:function(a,b){return h(a,b)}};i.extend(o,n),o.register=function(a,b,c,d,e,h){var j=null===b;!j&&b in this._iface_info&&a.error(g.InvokerError,"Already registered");var k=c.match(f._ifacever_pattern);null===k&&a.error(g.InvokerError,"Invalid ifacever");var l,m=k[1],n=k[4],o=k[5],p=k[6],q=!1,r=null,s=!1;if(j)l="callback",s=!0;else if("string"==typeof d)switch(this._secure_replace.test(d)?(q=!0,d=d.replace(this._secure_replace,"")):this._secure_test.test(d)&&(q=!0),r=this._native_iface_builder,l=d.split(":")[0]){case"http":case"https":break;case"ws":case"wss":case"unix":s=!0;break;case"browser":h&&h.targetOrigin&&(q=!0),s=!0;break;default:a.error(g.InvokerError,"Unknown endpoint schema")}else q=!0,r=d,d=null,l=null,s=!0;h=h||{},i.defaults(h,this._impl.options);var t={iface:m,version:n,mjrver:o,mnrver:p,endpoint:d,endpoint_scheme:l,creds:e||null,secure_channel:q,impl:r,regname:b,inherits:null,funcs:null,constraints:null,options:h,_invoker_use:!0,_user_info:null};b&&(this._iface_info[b]=t);var u=this;a.add(function(a){u._impl.onRegister(a,t),a.add(function(a){"SecureChannel"in t.constraints&&!q&&a.error(g.SecurityError,"SecureChannel is required"),"BiDirectChannel"in t.constraints&&!s&&a.error(g.InvokerError,"BiDirectChannel is required"),j&&a.success(t,u._native_iface_builder(u._impl,t)),u.emit("register",b,c,t)})},function(a,c){b&&delete u._iface_info[b]})},o.iface=function(a){var b=this._iface_info[a];if(!b)throw new Error(g.InvokerError);var c=b.regname,d=this._iface_impl[c];if(!d){var e=b.options.nativeImpl;d=e?new e(this._impl,b):b.impl(this._impl,b),this._iface_impl[c]=d}return d},o.unRegister=function(a){var b=this._iface_info[a];if(!b)throw new Error(g.InvokerError);var c=b.regname;if(c===a){delete this._iface_info[c];var d=this._iface_impl[c];if(d&&(d._close(),delete this._iface_impl[c]),b.aliases)for(var e=b.aliases,f=0;f<e.length;++f)delete this._iface_info[e[f]]}else delete this._iface_info[a],b.aliases.splice(b.aliases.indexOf(a),0);this.emit("unregister",a,b)},o.defense=function(){return this.iface(this.SVC_DEFENSE)},o.log=function(){return this.iface(this.SVC_LOG)},o.cache=function(a){return this.iface(this.SVC_CACHE_+(a||"default"))},o.assertIface=function(a,b){var c=this._iface_info[a];if(!c)throw new Error(g.InvokerError);var d=b.match(f._ifacever_pattern);if(null===d)throw new Error(g.InvokerError);var e=d[1],h=d[5],i=d[6];if(c.iface!==e||c.mjrver!==h||c.mnrver<i)throw new Error(g.InvokerError)},o.alias=function(a,b){var c=this._iface_info[a];if(!c||this._iface_info[b])throw new Error(g.InvokerError);this._iface_info[b]=c,c.aliases?c.aliases.push(b):c.aliases=[b],this.emit("register",b,c.iface+":"+c.version,c)},o.close=function(){var a=this._iface_impl;for(var b in a)a[b]._close();var c=this._impl.comms;for(var d in c)c[d].close();this.emit("close")},i.extend(e,n);var p={};i.extend(p,o),p.initFromCache=function(a,b){a.error(g.NotImplemented,"Caching is not supported yet")},p.cacheInit=function(a){},b.SimpleCCM=d,b.AdvancedCCM=e,b.FutoInError=g,b.NativeIface=h.NativeIface,b.InterfaceInfo=h.InterfaceInfo,b.SpecTools=l,b.SpecTools._ifacever_pattern=f._ifacever_pattern},function(a,b){"use strict";function d(a){this._raw_info=a}function e(a,b){this._ccmimpl=a,this._raw_info=b,this._iface_info=null,this._comms={},h.extend(this,k),i(this);for(var c in this._raw_info.funcs){var d=this._raw_info.funcs[c];d.rawupload||c in this||(this[c]=this._member_call_generate(c,d))}}var f=c(3),g=f.FutoInError,h=c(25),i=c(9),j=c(24);b=a.exports=function(b,c){return new a.exports.NativeIface(b,c)},d.prototype={name:function(){return this._raw_info.iface},version:function(){return this._raw_info.version},inherits:function(){return this._raw_info.inherits},funcs:function(){return this._raw_info.funcs},constraints:function(){return this._raw_info.constraints}},b.InterfaceInfo=d;var k={call:function(a,b,c,d,e,f){c=c||{};var h=this._raw_info,i={ccmimpl:this._ccmimpl,name:b,info:h,upload_data:d,download_stream:e,rsp_content_type:null,native_iface:this,options:h.options,endpoint:h.endpoint,expect_response:!0},k=this._ccmimpl;a.add(function(a){k.createMessage(a,i,c)}),a.add(function(a,c){var d;i.expect_response?(d=a,"number"!=typeof f&&(f=i.info.options.callTimeoutMS),f>0&&d.setTimeout(f)):d=j();var e=h.endpoint_scheme;if("http"===e||"https"===e)k.perfomHTTP(d,i,c);else if("ws"===e||"wss"===e){var l,m=i.download_stream||i.info.funcs&&(l=i.info.funcs[b])&&l.rawresult;i.upload_data||m?(i.endpoint=i.endpoint.replace("ws","http"),i.rawresult=m,k.perfomHTTP(d,i,c)):k.perfomWebSocket(d,i,c)}else i.upload_data?d.error(g.InvokerError,"Upload data is allowed only for HTTP/WS endpoints"):i.download_stream?d.error(g.InvokerError,"Download stream is allowed only for HTTP/WS endpoints"):"browser"===e?k.perfomBrowser(d,i,c):"unix"===e?k.perfomUNIX(d,i,c):"callback"===e?i.endpoint(d,i,c):d.error(g.InvokerError,"Unknown endpoint scheme");d!==a?(d.execute(),a.success()):d.add(function(a,b,c){if(i.download_stream)a.success(!0);else if("application/futoin+json"===c){if("string"==typeof b)try{b=JSON.parse(b)}catch(d){a.error(g.CommError,"JSON:"+d.message)}k.onMessageResponse(a,i,b)}else k.onDataResponse(a,i,b)})})},_member_call_intercept:function(a,b,c,d){var e=c.params,f=Object.keys(e);d.length>f.length?a.error(g.InvokerError,"Unknown parameters"):d.length<c.min_args?a.error(g.InvokerError,"Missing parameters"):d.length<f.length&&(f=f.splice(0,d.length));var i=h.object(f,d);this.call(a,b,i)},_member_call_generate:function(a,b){return function(c){this._member_call_intercept(c,a,b,Array.prototype.slice.call(arguments,1))}},ifaceInfo:function(){return this._iface_info||(this._iface_info=new d(this._raw_info)),this._iface_info},bindDerivedKey:function(a){throw new Error(g.InvokerError,"Not Implemented")},_close:function(){var a=this._comms;for(var b in a)a[b].close();this.emit("close")}};b.NativeIface=e},function(a,b){"use strict";function d(a){a=a||{},i.defaults(a,k),this.options=a,this.comms={}}var e,f=c(3),g=f.FutoInError,h=c(8),i=c(25);if(h){var j=require;e=j("./node_comms")}else e=c(2);b=a.exports=function(b){return new a.exports.SimpleCCMImpl(b)};var k={callTimeoutMS:3e4,prodMode:!1,commConfigCallback:null,retryCount:1,messageSniffer:function(){},disconnectSniffer:function(){}};d.prototype={onRegister:function(a,b){b.funcs={},b.inherits=[],b.constraints={}},createMessage:function(a,b,c){var d=b.info,e={f:d.iface+":"+d.version+":"+b.name,p:c,forcersp:!0};null!==d.creds&&"master"!==d.creds&&(e.sec=d.creds),a.success(e)},onMessageResponse:function(a,b,c){"e"in c?a.error(c.e,c.edesc):a.success(c.r)},onDataResponse:function(a,b,c){a.success(c)},getComms:function(a,b,c,d){var e,f,h=b.options,i=this.options;h.executor!==i.executor||h.messageSniffer!==i.messageSniffer||h.disconnectSniffer!==i.disconnectSniffer||h.commConfigCallback!==i.commConfigCallback?(e=b.native_iface._comms,f=b.info.endpoint_scheme):(e=this.comms,f=b.endpoint+"##"+(b.credentials||"")+"##"+(d||""));var j=e[f];return j||(c||a.error(g.InvokerError,"Not implemented "+b.info.endpoint_scheme+" scheme"),j=new c,e[f]=j),j},performCommon:function(a,b,c,d){var e,f;a.repeat(b.options.retryCount+1,function(a){a.add(function(a){d.perform(a,b,c),a.add(function(a,b,c){e=b,f=c,a["break"]()})},function(a,d){d===g.CommError&&(b.native_iface.emit("commError",a.state.error_info,c),a["continue"]())})}).add(function(a){a.success(e,f)})},perfomHTTP:function(a,b,c){var d=this.getComms(a,b,e.HTTPComms);this.performCommon(a,b,c,d)},perfomWebSocket:function(a,b,c){var d=this.getComms(a,b,e.WSComms);this.performCommon(a,b,c,d)},perfomUNIX:function(a,b,c){a.error(g.InvokerError,"Not implemented unix:// scheme")},perfomBrowser:function(a,b,c){var d=this.getComms(a,b,e.BrowserComms,b.options.targetOrigin);d.perform(a,b,c)}},b.SimpleCCMImpl=d},function(a){"use strict";var b,d,e=c(3),f=e.FutoInError,g=c(8),h=c(25);if(g){var i=require;b=i("fs"),d=i("request")}var j={standard_errors:{UnknownInterface:!0,NotSupportedVersion:!0,NotImplemented:!0,Unauthorized:!0,InternalError:!0,InvalidRequest:!0,DefenseRejected:!0,PleaseReauth:!0,SecurityError:!0},_ver_pattern:/^([0-9]+)\.([0-9]+)$/,loadIface:function(a,c,e){var h=null;a.forEach(e,function(a,e,f){var i=c.iface+"-"+c.version+"-iface.json";a.add(function(a){if("string"==typeof f&&g){var c=f+"/"+i,e=function(b){if(a){try{return f=JSON.parse(b),f._just_loaded=!0,void a.success()}catch(c){}try{a["continue"]()}catch(c){}}};"http"===c.substr(0,4)?d(c,function(a,b,c){e(c)}):b.readFile(c,{encoding:"utf8"},function(a,b){e(b)}),a.setCancel(function(b){a=null})}}).add(function(a){if("string"==typeof f&&!g){var b=f+"/"+i,c=new XMLHttpRequest;c.onreadystatechange=function(){if(this.readyState===this.DONE){var b=this.responseText;if(b)try{return f=JSON.parse(b),f._just_loaded=!0,void a.success()}catch(c){}try{a["continue"]()}catch(d){}}},c.open("GET",b,!0),c.send(),a.setCancel(function(a){c.abort()})}}).add(function(a){"object"==typeof f&&f.iface===c.iface&&f.version===c.version&&(h=f,a["break"]())})}).add(function(a){null===h&&a.error(f.InternalError,"Failed to load valid spec for "+c.iface+":"+c.version),j.parseIface(a,c,e,h)})},parseIface:function(a,b,c,d){if(d._just_loaded?(b.funcs=d.funcs||{},b.types=d.types||{}):(b.funcs=h.cloneDeep(d.funcs||{}),b.types=h.cloneDeep(d.types||{})),j._parseFuncs(a,b),j._parseTypes(a,b),"requires"in d){var g=d.requires;Array.isArray(g)||a.error(f.InternalError,'"requires" is not array'),b.constraints=h.object(g,g)}else b.constraints={};if(j._checkFTN3Rev(a,b,d),b.inherits=[],"inherit"in d){var i=d.inherit.match(e._ifacever_pattern);null===i&&a.error(f.InvokerError,"Invalid inherit ifacever: "+d.inherit);var k={};k.iface=i[1],k.version=i[4],j.loadIface(a,k,c),a.add(function(a){j._parseImportInherit(a,b,c,d,k),b.inherits.push(d.inherit),b.inherits=b.inherits.concat(k.inherits)})}"imports"in d?(b.imports=d.imports.slice(),a.forEach(d.imports,function(a,g,h){var i=h.match(e._ifacever_pattern);null===i&&a.error(f.InvokerError,"Invalid import ifacever: "+h);var k={};k.iface=i[1],k.version=i[4],j.loadIface(a,k,c),a.add(function(a){j._parseImportInherit(a,b,c,d,k),b.imports=b.imports.concat(k.imports)})})):b.imports=[]},_checkFTN3Rev:function(a,b,c){var d=c.ftn3rev||"1.0",e=d.match(j._ver_pattern);null===e&&a.error(f.InternalError,"Invalid ftn3rev field");var g=parseInt(e[1]),h=parseInt(e[2]);1===g?(1>h&&(c.imports||c.types||"BiDirectChannel"in b.constraints)&&a.error(f.InternalError,"Missing ftn3rev field when FTN3 v1.1 features are used"),!b._invoker_use&&h>1&&a.error(f.InternalError,"Not supported FTN3 revision for Executor")):a.error(f.InternalError,"Not supported FTN3 revision")},_parseFuncs:function(a,b){var c,d;for(var e in b.funcs){if(c=b.funcs[e],c.min_args=0,"params"in c){var g=c.params;"object"!=typeof g&&a.error(f.InternalError,"Invalid params object");for(d in g){var i=g[d];"object"!=typeof i&&a.error(f.InternalError,"Invalid param object"),"type"in i||a.error(f.InternalError,"Missing type for params"),"default"in i||(c.min_args+=1)}}else c.params={};if(c.expect_result=!1,"result"in c){var j=c.result;"object"!=typeof j&&a.error(f.InternalError,"Invalid result object");for(var k in j){var l=j[k];"object"!=typeof l&&a.error(f.InternalError,"Invalid resultvar object"),"type"in l||a.error(f.InternalError,"Missing type for result"),c.expect_result=!0}}else c.result={};if("rawupload"in c||(c.rawupload=!1),"rawresult"in c||(c.rawresult=!1),c.rawresult&&(c.expect_result=!0),"throws"in c){c.expect_result||a.error(f.InternalError,'"throws" without result');var m=c["throws"];Array.isArray(m)||a.error(f.InternalError,'"throws" is not array'),c["throws"]=h.object(m,m)}else c["throws"]={}}},_parseTypes:function(a,b){var c;for(var d in b.types)if(c=b.types[d],"type"in c||a.error(f.InternalError,'Missing "type" for custom type'),"map"===c.type){if(!("fields"in c)){c.fields={};continue}for(var e in c.fields)"type"in c.fields[e]||a.error(f.InternalError,'Missing "type" for custom type field')}},_parseImportInherit:function(a,b,c,d,e){var g,i;for(var j in e.types)j in b.types?a.error(f.InternalError,"Iface type redifintion: "+j):b.types[j]=e.types[j];for(var k in e.funcs){var l=e.funcs[k];if(k in b.funcs){var m=l.params,n=b.funcs[k].params,o=Object.keys(m),p=Object.keys(n);for(p.length<o.length&&a.error(f.InternalError,"Invalid param count for '"+k+"'"),g=0;g<o.length;++g)i=o[g],i!==p[g]&&a.error(f.InternalError,"Invalid param order for '"+k+"/"+i+"'"),m[i].type!==n[i].type&&a.error(f.InternalError,"Param type mismatch '"+k+"/"+i+"'");for(;g<p.length;++g)i=p[g],i in m||"default"in n[i]||null===n[i]||a.error(f.InternalError,"Missing default for '"+k+"/"+i+"'");l.rawresult!==b.funcs[k].rawresult&&a.error(f.InternalError,"'rawresult' flag mismatch for '"+k+"'"),l.rawupload&&!b.funcs[k].rawupload&&a.error(f.InternalError,"'rawupload' flag is missing for '"+k+"'")}else b.funcs[k]=l}h.difference(Object.keys(e.constraints),d.requires).length&&a.error(f.InternalError,"Missing constraints from inherited")},checkConsistency:function(a,b){},checkType:function(a,b,c,d){if(null===c)return!1;switch(b){case"any":return!0;case"boolean":case"string":case"number":return typeof c===b;case"map":return"object"==typeof c&&!(c instanceof Array);case"integer":return"number"==typeof c&&(0|c)===c;case"array":return c instanceof Array;default:if(!("types"in a&&b in a.types))return!1}if(b in a.types){var e=a.types[b];d=d||{};var g=e.type;if(g in d)throw console&&console.log("[ERROR] Custom type recursion: "+e),new Error(f.InternalError);if(d[b]=!0,!this.checkType(a,g,c,d))return!1;switch(g){case"integer":case"number":return"min"in e&&c<e.min?!1:"max"in e&&c>e.max?!1:!0;case"string":if("regex"in e){var h;return"_comp_regex"in a?h=a._comp_regex:(h={},a._comp_regex=h),b in h||(h[b]=new RegExp(e.regex)),null!==c.match(h[b])}return!0;case"array":var i=c.length;if("minlen"in e&&i<e.minlen)return!1;if("maxlen"in e&&i>e.maxlen)return!1;if("elemtype"in e)for(var j=e.elemtype,k=0;i>k;++k)if(!this.checkType(a,j,c[k],[]))return!1;return!0;case"map":var l=e.fields;for(var m in l){var n=l[m];if(!(m in c)||null===c[m])return n.optional?(c[m]=null,!0):!1;if(!this.checkType(a,n.type,c[m],[]))return!1}return!0}}return!1},checkParameterType:function(a,b,c,d,e){j.checkType(b,b.funcs[c].params[d].type,e)||a.error(f.InvalidRequest,"Type mismatch for parameter: "+d)},checkResultType:function(a,b,c,d,e){j.checkType(b,b.funcs[c].result[d].type,e)||a.error(f.InvalidRequest,"Type mismatch for result: "+d)},checkFutoInType:function(a,b,c,d){j.checkType({},b,d)||a.error(f.InvalidRequest,"Type mismatch for parameter: "+c)}};a.exports=j},function(a){a.exports=!1;try{a.exports="[object process]"===Object.prototype.toString.call(d.process)}catch(b){}},function(a,b){"use strict";var d,e,f,g,h,i,j,k=c(10),l=c(19),m=Function.prototype.apply,n=Function.prototype.call,o=Object.create,p=Object.defineProperty,q=Object.defineProperties,r=Object.prototype.hasOwnProperty,s={configurable:!0,enumerable:!1,writable:!0};d=function(a,b){var c;return l(b),r.call(this,"__ee__")?c=this.__ee__:(c=s.value=o(null),p(this,"__ee__",s),s.value=null),c[a]?"object"==typeof c[a]?c[a].push(b):c[a]=[c[a],b]:c[a]=b,this},e=function(a,b){var c,e;return l(b),e=this,d.call(this,a,c=function(){f.call(e,a,c),m.call(b,this,arguments)}),c.__eeOnceListener__=b,this},f=function(a,b){var c,d,e,f;if(l(b),!r.call(this,"__ee__"))return this;if(c=this.__ee__,!c[a])return this;if(d=c[a],"object"==typeof d)for(f=0;e=d[f];++f)(e===b||e.__eeOnceListener__===b)&&(2===d.length?c[a]=d[f?0:1]:d.splice(f,1));else(d===b||d.__eeOnceListener__===b)&&delete c[a];return this},g=function(a){var b,c,d,e,f;if(r.call(this,"__ee__")&&(e=this.__ee__[a]))if("object"==typeof e){for(c=arguments.length,f=new Array(c-1),b=1;c>b;++b)f[b-1]=arguments[b];for(e=e.slice(),b=0;d=e[b];++b)m.call(d,this,f)}else switch(arguments.length){case 1:n.call(e,this);break;case 2:n.call(e,this,arguments[1]);break;case 3:n.call(e,this,arguments[1],arguments[2]);break;default:for(c=arguments.length,f=new Array(c-1),b=1;c>b;++b)f[b-1]=arguments[b];m.call(e,this,f)}},h={on:d,once:e,off:f,emit:g},i={on:k(d),once:k(e),off:k(f),emit:k(g)},j=q({},i),a.exports=b=function(a){return null==a?o(j):q(Object(a),i)},b.methods=h},function(a){"use strict";var b,d=c(11),e=c(18),f=c(14),g=c(21);b=a.exports=function(a,b){var c,f,h,i,j;return arguments.length<2||"string"!=typeof a?(i=b,b=a,a=null):i=arguments[2],null==a?(c=h=!0,f=!1):(c=g.call(a,"c"),f=g.call(a,"e"),h=g.call(a,"w")),j={value:b,configurable:c,enumerable:f,writable:h},i?d(e(i),j):j},b.gs=function(a,b,c){var h,i,j,k;return"string"!=typeof a?(j=c,c=b,b=a,a=null):j=arguments[3],null==b?b=void 0:f(b)?null==c?c=void 0:f(c)||(j=c,c=void 0):(j=b,b=c=void 0),null==a?(h=!0,i=!1):(h=g.call(a,"c"),i=g.call(a,"e")),k={get:b,set:c,configurable:h,enumerable:i},j?d(e(j),k):k}},function(a){"use strict";a.exports=c(12)()?Object.assign:c(13)},function(a){"use strict";a.exports=function(){var a,b=Object.assign;return"function"!=typeof b?!1:(a={foo:"raz"},b(a,{bar:"dwa"},{trzy:"trzy"}),a.foo+a.bar+a.trzy==="razdwatrzy")}},function(a){"use strict";var b=c(15),d=c(20),e=Math.max;a.exports=function(a,c){var f,g,h,i=e(arguments.length,2);for(a=Object(d(a)),h=function(b){try{a[b]=c[b]}catch(d){f||(f=d)}},g=1;i>g;++g)c=arguments[g],b(c).forEach(h);if(void 0!==f)throw f;return a}},function(a){"use strict";a.exports=function(a){return"function"==typeof a}},function(a){"use strict";a.exports=c(16)()?Object.keys:c(17)},function(a){"use strict";a.exports=function(){try{return Object.keys("primitive"),!0}catch(a){return!1}}},function(a){"use strict";var b=Object.keys;a.exports=function(a){return b(null==a?a:Object(a))}},function(a){"use strict";var b,d=c(11),e=Array.prototype.forEach,f=Object.create,g=Object.getPrototypeOf;b=function(a,c){var e=g(a);return d(e?b(e,c):c,a)},a.exports=function(){var a=f(null);return e.call(arguments,function(c){null!=c&&b(Object(c),a)}),a}},function(a){"use strict";a.exports=function(a){if("function"!=typeof a)throw new TypeError(a+" is not a function");return a}},function(a){"use strict";a.exports=function(a){if(null==a)throw new TypeError("Cannot use null or undefined");return a}},function(a){"use strict";a.exports=c(22)()?String.prototype.contains:c(23)},function(a){"use strict";var b="razdwatrzy";a.exports=function(){return"function"!=typeof b.contains?!1:b.contains("dwa")===!0&&b.contains("foo")===!1}},function(a){"use strict";var b=String.prototype.indexOf;a.exports=function(a){return b.call(this,a,arguments[1])>-1}},function(b){b.exports=a},function(a){a.exports=b}],c(1)});

@@ -70,6 +70,6 @@ "use strict";

{
as.error( FutoInError.InvokerError, "Unknown interface function" );
as.error( FutoInError.InvokerError, "Unknown interface function: " + name );
}
var finfo = info.funcs[name];
var finfo = info.funcs[ name ];

@@ -93,6 +93,6 @@ if ( ctx.upload_data &&

{
as.error( FutoInError.InvokerError, "Unknown parameter " + k );
as.error( FutoInError.InvokerError, "Unknown parameter: " + k );
}
spectools.checkParameterType( as, info, name, k, params[k] );
spectools.checkParameterType( as, info, name, k, params[ k ] );
}

@@ -104,3 +104,3 @@

if ( !params.hasOwnProperty( k ) &&
!finfo.params[k].hasOwnProperty( "default" ) )
!finfo.params[ k ].hasOwnProperty( "default" ) )
{

@@ -185,3 +185,3 @@ as.error( FutoInError.InvokerError, "Missing parameter " + k );

{
spectools.checkResultType( as, info, name, k, rsp.r[k] );
spectools.checkResultType( as, info, name, k, rsp.r[ k ] );
--rescount;

@@ -202,3 +202,3 @@ }

{
if ( ctx.info.funcs[ctx.name].rawresult )
if ( ctx.info.funcs[ ctx.name ].rawresult )
{

@@ -205,0 +205,0 @@ as.success( rsp );

"use strict";
var EventEmitter = require( 'wolfy87-eventemitter' );
var ee = require( 'event-emitter' );

@@ -19,2 +19,5 @@ var common = require( './common' );

{
close : function()
{},
perform : function( as, ctx, req )

@@ -66,3 +69,3 @@ {

{
params.push( encodeURIComponent( k ) + "=" + encodeURIComponent( req.p[k] ) );
params.push( encodeURIComponent( k ) + "=" + encodeURIComponent( req.p[ k ] ) );
}

@@ -153,3 +156,3 @@

this.reqas = {};
this.evt = new EventEmitter();
this.evt = ee();
};

@@ -203,2 +206,3 @@

_this._waiting_open = false;
ctx.native_iface.emit( 'disconnect' );
};

@@ -214,2 +218,3 @@

_this.evt.emit( 'open' );
ctx.native_iface.emit( 'connect' );
};

@@ -255,2 +260,10 @@

close : function()
{
if ( this.ws )
{
this.ws.close();
}
},
perform : function( as, ctx, req )

@@ -283,3 +296,3 @@ {

{
_this.evt.removeListener( 'open', on_open );
_this.evt.off( 'open', on_open );
} );

@@ -300,2 +313,7 @@ } );

{
if ( !( 'ws' in this ) )
{
as.error( FutoInError.CommError, 'Disconnect while in progress' );
}
var reqas = this.reqas;

@@ -307,3 +325,3 @@

{
reqas[rid] = as;
reqas[ rid ] = as;

@@ -313,3 +331,3 @@ as.setCancel(

{
delete reqas[rid];
delete reqas[ rid ];
}

@@ -353,3 +371,3 @@ );

// --
var target = ctx.endpoint.split( '://', 2 )[1];
var target = ctx.endpoint.split( '://', 2 )[ 1 ];
var browser_window = window; // jshint ignore:line

@@ -363,3 +381,3 @@ var iframe;

else if ( ( target in browser_window ) &&
( 'postMessage' in browser_window[target] ) )
( 'postMessage' in browser_window[ target ] ) )
{

@@ -470,4 +488,13 @@ target = browser_window[ target ];

browser_window.addEventListener( "message", on_message, false );
ctx.native_iface.emit( 'connect' );
},
close : function()
{
if ( this.target )
{
this.target = null;
}
},
perform : function( as, ctx, req )

@@ -481,3 +508,3 @@ {

if ( !( 'target' in this ) )
if ( !this.target )
{

@@ -497,3 +524,3 @@ this.init( as, ctx );

{
reqas[rid] = as;
reqas[ rid ] = as;

@@ -504,3 +531,3 @@ as.setCancel(

void as;
delete reqas[rid];
delete reqas[ rid ];
}

@@ -507,0 +534,0 @@ );

@@ -83,2 +83,44 @@ "use strict";

SAFE_PAYLOAD_LIMIT : 65536,
/**
* Runtime iface resolution v1.x
* @alias SimpleCCM.SVC_RESOLVER
* @const
*/
SVC_RESOLVER : '#resolver',
/**
* AuthService v1.x
* @alias SimpleCCM.SVC_AUTH
* @const
*/
SVC_AUTH : '#auth',
/**
* Defense system v1.x
* @alias SimpleCCM.SVC_DEFENSE
* @const
*/
SVC_DEFENSE : '#defense',
/**
* Access Control system v1.x
* @alias SimpleCCM.SVC_ACL
* @const
*/
SVC_ACL : '#acl',
/**
* Audit Logging v1.x
* @alias SimpleCCM.SVC_LOG
* @const
*/
SVC_LOG : '#log',
/**
* cache v1.x iface name prefix
* @alias SimpleCCM.SVC_CACHE_
* @const
*/
SVC_CACHE_ : "#cache.",
};

@@ -85,0 +127,0 @@

@@ -14,2 +14,3 @@ "use strict";

var spectools = require( './spectools' );
var ee = require( 'event-emitter' );

@@ -20,20 +21,4 @@ /**

*/
var SimpleCCMPublic =
{
/** Runtime iface resolution v1.x */
SVC_RESOLVER : '#resolver',
/** AuthService v1.x */
SVC_AUTH : '#auth',
/** Defense system v1.x */
SVC_DEFENSE : '#defense',
/** Access Control system v1.x */
SVC_ACL : '#acl',
/** Audit Logging v1.x */
SVC_LOG : '#log',
/** cache v1.x iface name prefix */
SVC_CACHE_ : "#cache.",
};
var SimpleCCMPublic = common.Options;
_.extend( SimpleCCMPublic, common.Options );
/**

@@ -48,5 +33,7 @@ * Simple CCM - Reference Implementation

{
ee( this );
this._iface_info = {};
this._iface_impl = {};
this._impl = simple_ccm( options );
_.extend( this, SimpleCCMProto );
}

@@ -81,3 +68,4 @@

* @param {string} ifacever - interface identifier and its version separated by colon
* @param {string} endpoint - URI or any other resource identifier of iface implementing peer, accepted by CCM implementation
* @param {string} endpoint - URI or any other resource identifier of function( ccmimpl, info )
* returning iface implementing peer, accepted by CCM implementation
* @param {string=} credentials - optional, authentication credentials:

@@ -108,6 +96,6 @@ * @param {object=} options - NOT STANDARD feature, fine tune global CCM options per endpoint

var iface = m[1];
var mjrmnr = m[4];
var mjr = m[5];
var mnr = m[6];
var iface = m[ 1 ];
var mjrmnr = m[ 4 ];
var mjr = m[ 5 ];
var mnr = m[ 6 ];

@@ -140,3 +128,3 @@ var secure_channel = false;

// ---
endpoint_scheme = endpoint.split( ':' )[0];
endpoint_scheme = endpoint.split( ':' )[ 0 ];

@@ -233,2 +221,4 @@ switch ( endpoint_scheme )

}
_this.emit( 'register', name, ifacever, info );
} );

@@ -268,3 +258,13 @@ },

{
impl = info.impl( this._impl, info );
var NativeImpl = info.options.nativeImpl;
if ( NativeImpl )
{
impl = new NativeImpl( this._impl, info );
}
else
{
impl = info.impl( this._impl, info );
}
this._iface_impl[ regname ] = impl;

@@ -294,4 +294,10 @@ }

delete this._iface_info[ regname ];
delete this._iface_impl[ regname ];
var impl = this._iface_impl[ regname ];
if ( impl )
{
impl._close();
delete this._iface_impl[ regname ];
}
if ( info.aliases )

@@ -312,2 +318,4 @@ {

}
this.emit( 'unregister', name, info );
};

@@ -363,5 +371,5 @@

var iface = m[1];
var mjr = m[5];
var mnr = m[6];
var iface = m[ 1 ];
var mjr = m[ 5 ];
var mnr = m[ 6 ];

@@ -401,5 +409,29 @@ if ( ( info.iface !== iface ) ||

}
this.emit( 'register', alias, info.iface + ':' + info.version, info );
};
SimpleCCM.prototype = SimpleCCMProto;
/**
* Shutdown CCM (close all active comms)
*/
SimpleCCMProto.close = function()
{
var impls = this._iface_impl;
for ( var n in impls )
{
impls[ n ]._close();
}
// ---
var comms = this._impl.comms;
for ( var k in comms )
{
comms[ k ].close();
}
// ---
this.emit( 'close' );
};
/* --- */

@@ -415,5 +447,7 @@

{
ee( this );
this._iface_info = {};
this._iface_impl = {};
this._impl = advanced_ccm( options );
_.extend( this, AdvancedCCMProto );
}

@@ -453,4 +487,2 @@

};
AdvancedCCM.prototype = AdvancedCCMProto;
/* --- */

@@ -457,0 +489,0 @@

"use strict";
var invoker = require( './invoker' );
var common = require( './common' );
var futoin_error = common.FutoInError;
var _ = require( 'lodash' );
var ee = require( 'event-emitter' );
var async_steps = require( 'futoin-asyncsteps' );

@@ -81,2 +84,5 @@ exports = module.exports = function( ccmimpl, info )

_.extend( this, NativeIfaceProto );
ee( this );
for ( var fn in this._raw_info.funcs )

@@ -97,7 +103,7 @@ {

this[fn] = this._member_call_generate( fn, finfo );
this[ fn ] = this._member_call_generate( fn, finfo );
}
}
NativeIface.prototype =
var NativeIfaceProto =
{

@@ -113,2 +119,3 @@ /**

* @param {int=} timeout - if provided, overrides the default. <=0 - disables timeout
* @alias NativeIface#call
*/

@@ -147,12 +154,23 @@ call : function( as, name, params, upload_data, download_stream, timeout )

as.add(
function( as, req )
function( orig_as, req )
{
if ( typeof timeout !== 'number' )
var as;
if ( ctx.expect_response )
{
timeout = ctx.info.options.callTimeoutMS;
as = orig_as;
if ( typeof timeout !== 'number' )
{
timeout = ctx.info.options.callTimeoutMS;
}
if ( timeout > 0 )
{
as.setTimeout( timeout );
}
}
if ( timeout > 0 )
else
{
as.setTimeout( timeout );
as = async_steps();
}

@@ -190,3 +208,3 @@

as.error(
invoker.FutoInError.InvokerError,
futoin_error.InvokerError,
'Upload data is allowed only for HTTP/WS endpoints' );

@@ -197,3 +215,3 @@ }

as.error(
invoker.FutoInError.InvokerError,
futoin_error.InvokerError,
'Download stream is allowed only for HTTP/WS endpoints' );

@@ -215,38 +233,42 @@ }

{
as.error( invoker.FutoInError.InvokerError, 'Unknown endpoint scheme' );
as.error( futoin_error.InvokerError, 'Unknown endpoint scheme' );
}
as.add(
function( as, rsp, content_type )
{
if ( !ctx.expect_response )
if ( as !== orig_as )
{
as.execute();
orig_as.success();
}
else
{
as.add(
function( as, rsp, content_type )
{
as.success();
}
else if ( ctx.download_stream )
{
as.success( true );
}
else if ( content_type === 'application/futoin+json' )
{
if ( typeof rsp === 'string' )
if ( ctx.download_stream )
{
try
as.success( true );
}
else if ( content_type === 'application/futoin+json' )
{
if ( typeof rsp === 'string' )
{
rsp = JSON.parse( rsp );
try
{
rsp = JSON.parse( rsp );
}
catch ( e )
{
as.error( futoin_error.CommError, "JSON:" + e.message );
}
}
catch ( e )
{
as.error( invoker.FutoInError.CommError, "JSON:" + e.message );
}
ccmimpl.onMessageResponse( as, ctx, rsp );
}
ccmimpl.onMessageResponse( as, ctx, rsp );
else
{
ccmimpl.onDataResponse( as, ctx, rsp );
}
}
else
{
ccmimpl.onDataResponse( as, ctx, rsp );
}
}
);
);
}
}

@@ -266,7 +288,7 @@ );

{
as.error( invoker.FutoInError.InvokerError, "Unknown parameters" );
as.error( futoin_error.InvokerError, "Unknown parameters" );
}
else if ( args.length < finfo.min_args )
{
as.error( invoker.FutoInError.InvokerError, "Missing parameters" );
as.error( futoin_error.InvokerError, "Missing parameters" );
}

@@ -301,2 +323,3 @@ else if ( args.length < keys.length )

* @returns {object}
* @alias NativeIface#call
*/

@@ -314,16 +337,25 @@ ifaceInfo : function()

/**
* Returns extended API interface as defined in [FTN10 Burst Calls][]
* @returns {object}
* Results with DerivedKeyAccessor through as.success()
* @alias NativeIface#bindDerivedKey
*/
burst : function()
bindDerivedKey : function( as )
{
throw new Error( invoker.FutoInError.InvokerError, "Not Implemented" );
void as;
throw new Error( futoin_error.InvokerError, "Not Implemented" );
},
/**
* Results with DerivedKeyAccessor through as.success()
* Shutdow interface
* @private
*/
bindDerivedKey : function( /*as*/ )
_close : function()
{
throw new Error( invoker.FutoInError.InvokerError, "Not Implemented" );
var comms = this._comms;
for ( var k in comms )
{
comms[ k ].close();
}
this.emit( 'close' );
}

@@ -330,0 +362,0 @@ };

@@ -114,2 +114,5 @@ "use strict";

close : function()
{},
perform : function( as, ctx, req )

@@ -143,15 +146,15 @@ {

{
httpopts.headers['content-type'] = 'application/octet-stream';
httpopts.headers[ 'content-type' ] = 'application/octet-stream';
if ( typeof rawreq === "string" )
{
httpopts.headers['content-length'] = Buffer.byteLength( rawreq, 'utf8' );
httpopts.headers[ 'content-length' ] = Buffer.byteLength( rawreq, 'utf8' );
}
else if ( rawreq instanceof Buffer )
{
httpopts.headers['content-length'] = rawreq.length;
httpopts.headers[ 'content-length' ] = rawreq.length;
}
else if ( 'lengthInBytes' in rawreq )
{
httpopts.headers['content-length'] = rawreq.lengthInBytes;
httpopts.headers[ 'content-length' ] = rawreq.lengthInBytes;
}

@@ -186,3 +189,3 @@ else

rawreq = JSON.stringify( req );
httpopts.headers['content-type'] = 'application/futoin+json';
httpopts.headers[ 'content-type' ] = 'application/futoin+json';
var byte_length = Buffer.byteLength( rawreq, 'utf8' );

@@ -195,3 +198,3 @@

httpopts.headers['content-length'] = byte_length;
httpopts.headers[ 'content-length' ] = byte_length;

@@ -242,3 +245,3 @@ sniffer( ctx.info, rawreq, false );

sniffer( ctx.info, '%DATA%', true );
as.success( true, rsp.headers['content-type'] );
as.success( true, rsp.headers[ 'content-type' ] );
};

@@ -285,3 +288,3 @@

var rawmsg = Buffer.concat( jsonrsp ).toString( 'utf8' );
var content_type = rsp.headers['content-type'];
var content_type = rsp.headers[ 'content-type' ];

@@ -400,2 +403,3 @@ if ( content_type === 'application/futoin+json' )

_this._waiting_open = false;
ctx.native_iface.emit( 'disconnect' );
};

@@ -409,2 +413,3 @@

_this._waiting_open = false;
ctx.native_iface.emit( 'connect' );
} );

@@ -449,2 +454,10 @@

close : function()
{
if ( this.ws )
{
this.ws.close();
}
},
perform : function( as, ctx, req )

@@ -493,2 +506,7 @@ {

{
if ( !( 'ws' in this ) )
{
as.error( FutoInError.CommError, 'Disconnect while in progress' );
}
var reqas = this.reqas;

@@ -502,3 +520,3 @@

{
reqas[rid] = as;
reqas[ rid ] = as;

@@ -508,3 +526,3 @@ as.setCancel(

{
delete reqas[rid];
delete reqas[ rid ];
}

@@ -511,0 +529,0 @@ );

@@ -112,3 +112,3 @@ "use strict";

var c = comms[key];
var c = comms[ key ];

@@ -125,3 +125,3 @@ if ( !c )

c = new CommImpl();
comms[key] = c;
comms[ key ] = c;
}

@@ -154,2 +154,3 @@

{
ctx.native_iface.emit( 'commError', as.state.error_info, req );
as.continue();

@@ -156,0 +157,0 @@ }

@@ -263,4 +263,4 @@ "use strict";

var sup_info = {};
sup_info.iface = m[1];
sup_info.version = m[4];
sup_info.iface = m[ 1 ];
sup_info.version = m[ 4 ];
spectools.loadIface( as, sup_info, specdirs );

@@ -293,4 +293,4 @@

var imp_info = {};
imp_info.iface = m[1];
imp_info.version = m[4];
imp_info.iface = m[ 1 ];
imp_info.version = m[ 4 ];
spectools.loadIface( as, imp_info, specdirs );

@@ -324,4 +324,4 @@

var mjr = parseInt( rv[1] );
var mnr = parseInt( rv[2] );
var mjr = parseInt( rv[ 1 ] );
var mnr = parseInt( rv[ 2 ] );

@@ -371,3 +371,3 @@ // Check for version-specific features

{
finfo = info.funcs[f];
finfo = info.funcs[ f ];
finfo.min_args = 0;

@@ -422,3 +422,3 @@

{
var rinfo = fresult[rn];
var rinfo = fresult[ rn ];

@@ -507,3 +507,3 @@ if ( typeof rinfo !== 'object' )

{
if ( !( 'type' in tinfo.fields[f] ) )
if ( !( 'type' in tinfo.fields[ f ] ) )
{

@@ -542,3 +542,3 @@ as.error( FutoInError.InternalError, 'Missing "type" for custom type field' );

{
info.funcs[f] = fdef;
info.funcs[ f ] = fdef;
continue;

@@ -548,3 +548,3 @@ }

var sup_params = fdef.params;
var params = info.funcs[f].params;
var params = info.funcs[ f ].params;

@@ -569,3 +569,3 @@ var sup_params_keys = Object.keys( sup_params );

if ( sup_params[pn].type !== params[pn].type )
if ( sup_params[ pn ].type !== params[ pn ].type )
{

@@ -582,4 +582,4 @@ as.error( FutoInError.InternalError, "Param type mismatch '" + f + "/" + pn + "'" );

if ( !( pn in sup_params ) &&
!( 'default' in params[pn] ||
params[pn] === null ) )
!( 'default' in params[ pn ] ||
params[ pn ] === null ) )
{

@@ -590,3 +590,3 @@ as.error( FutoInError.InternalError, "Missing default for '" + f + "/" + pn + "'" );

if ( fdef.rawresult !== info.funcs[f].rawresult )
if ( fdef.rawresult !== info.funcs[ f ].rawresult )
{

@@ -597,3 +597,3 @@ as.error( FutoInError.InternalError, "'rawresult' flag mismatch for '" + f + "'" );

if ( fdef.rawupload &&
!info.funcs[f].rawupload )
!info.funcs[ f ].rawupload )
{

@@ -762,3 +762,3 @@ as.error( FutoInError.InternalError, "'rawupload' flag is missing for '" + f + "'" );

// Note, new type stack
if ( !this.checkType( info, elemtype, val[i], [] ) )
if ( !this.checkType( info, elemtype, val[ i ], [] ) )
{

@@ -780,7 +780,7 @@ return false;

if ( !( f in val ) ||
( val[f] === null ) )
( val[ f ] === null ) )
{
if ( field_def.optional )
{
val[f] = null;
val[ f ] = null;
return true;

@@ -816,3 +816,3 @@ }

{
if ( !spectools.checkType( info, info.funcs[funcname].params[varname].type, value ) )
if ( !spectools.checkType( info, info.funcs[ funcname ].params[ varname ].type, value ) )
{

@@ -833,3 +833,3 @@ as.error( FutoInError.InvalidRequest, "Type mismatch for parameter: " + varname );

{
if ( !spectools.checkType( info, info.funcs[funcname].result[varname].type, value ) )
if ( !spectools.checkType( info, info.funcs[ funcname ].result[ varname ].type, value ) )
{

@@ -836,0 +836,0 @@ as.error( FutoInError.InvalidRequest, "Type mismatch for result: " + varname );

{
"name": "futoin-invoker",
"version": "0.5.3",
"version": "0.5.4",
"description": "FutoIn Invoker - Reference Implementation. Transparently and efficiently invoke remote or local service methods with strict API definition",

@@ -40,2 +40,3 @@ "main": "lib/invoker.js",

"detect-node": "^2.0.3",
"event-emitter": "^0.3.1",
"faye-websocket": "^0.9.2",

@@ -42,0 +43,0 @@ "futoin-asyncsteps": "^1.5.1",

@@ -23,6 +23,13 @@

Version: 1.1
FTN9: FutoIn Interface - AuditLog
Version: 1.0 (client)
FTN14: FutoIn Cache
Version: 1.0 (client)
Spec FTN7: [FTN7: Interface Invoker Concept v1.x](http://specs.futoin.org/final/preview/ftn7_iface_invoker_concept-1.html)
Spec FTN3: [FTN3: FutoIn Interface Definition v1.x](http://specs.futoin.org/final/preview/ftn3_iface_definition.html)
* Spec FTN7: [FTN7: Interface Invoker Concept v1.x](http://specs.futoin.org/final/preview/ftn7_iface_invoker_concept-1.html)
* Spec FTN3: [FTN3: FutoIn Interface Definition v1.x](http://specs.futoin.org/final/preview/ftn3_iface_definition.html)
* Spec FTN9: [FTN9: FutoIn Interface - AuditLog v1.x](http://specs.futoin.org/final/preview/ftn9_if_auditlog.html)
* Spec FTN14: [FTN14: FutoIn Cache v1.x](http://specs.futoin.org/final/preview/ftn14_cache.html)

@@ -121,2 +128,23 @@ [Web Site](http://futoin.org/)

* [class: CacheFace](#CacheFace)
* [new CacheFace()](#new_CacheFace)
* [CacheFace.ifacespec](#CacheFace.ifacespec)
* [CacheFace.register()](#CacheFace.register)
* [cacheFace.getOrSet(as, key_prefix, callable, params, ttl)](#CacheFace#getOrSet)
* [class: LogFace](#LogFace)
* [new LogFace()](#new_LogFace)
* [LogFace.ifacespec](#LogFace.ifacespec)
* [LogFace.register()](#LogFace.register)
* [logFace.msg(lvl, txt)](#LogFace#msg)
* [logFace.msg(lvl, txt, data)](#LogFace#msg)
* [logFace.debug(txt)](#LogFace#debug)
* [logFace.info(txt)](#LogFace#info)
* [logFace.warn(txt)](#LogFace#warn)
* [logFace.error(txt)](#LogFace#error)
* [logFace.security(txt)](#LogFace#security)
* [const: LogFace.LVL_DEBUG](#LogFace.LVL_DEBUG)
* [const: LogFace.LVL_INFO](#LogFace.LVL_INFO)
* [const: LogFace.LVL_WARN](#LogFace.LVL_WARN)
* [const: LogFace.LVL_ERROR](#LogFace.LVL_ERROR)
* [const: LogFace.LVL_SECURITY](#LogFace.LVL_SECURITY)
* [class: InterfaceInfo](#InterfaceInfo)

@@ -132,4 +160,3 @@ * [new InterfaceInfo()](#new_InterfaceInfo)

* [nativeIface.call(as, name, params, upload_data, [download_stream], [timeout])](#NativeIface#call)
* [nativeIface.ifaceInfo()](#NativeIface#ifaceInfo)
* [nativeIface.burst()](#NativeIface#burst)
* [nativeIface.call()](#NativeIface#call)
* [nativeIface.bindDerivedKey()](#NativeIface#bindDerivedKey)

@@ -156,2 +183,8 @@ * [class: spectools](#spectools)

* [const: SimpleCCM.SAFE_PAYLOAD_LIMIT](#SimpleCCM.SAFE_PAYLOAD_LIMIT)
* [const: SimpleCCM.SVC_RESOLVER](#SimpleCCM.SVC_RESOLVER)
* [const: SimpleCCM.SVC_AUTH](#SimpleCCM.SVC_AUTH)
* [const: SimpleCCM.SVC_DEFENSE](#SimpleCCM.SVC_DEFENSE)
* [const: SimpleCCM.SVC_ACL](#SimpleCCM.SVC_ACL)
* [const: SimpleCCM.SVC_LOG](#SimpleCCM.SVC_LOG)
* [const: SimpleCCM.SVC_CACHE_](#SimpleCCM.SVC_CACHE_)
* [AdvancedCCM](#AdvancedCCM)

@@ -237,2 +270,156 @@ * [const: AdvancedCCM.OPT_SPEC_DIRS](#AdvancedCCM.OPT_SPEC_DIRS)

<a name="CacheFace"></a>
#class: CacheFace
**Members**
* [class: CacheFace](#CacheFace)
* [new CacheFace()](#new_CacheFace)
* [CacheFace.ifacespec](#CacheFace.ifacespec)
* [CacheFace.register()](#CacheFace.register)
* [cacheFace.getOrSet(as, key_prefix, callable, params, ttl)](#CacheFace#getOrSet)
<a name="new_CacheFace"></a>
##new CacheFace()
Cache Native interface
Register with CacheFace.register()
<a name="CacheFace.ifacespec"></a>
##CacheFace.ifacespec
Embedded spec for FutoIn CacheFace
<a name="CacheFace.register"></a>
##CacheFace.register()
AuditLog Native interface registration helper
<a name="CacheFace#getOrSet"></a>
##cacheFace.getOrSet(as, key_prefix, callable, params, ttl)
Get or Set cached value
NOTE: the actual cache key is formed with concatenation of *key_prefix* and join
of *params* values
**Params**
- as `AsyncSteps`
- key_prefix `string` - unique key prefix
- callable `function` - func( as, params.. ) - a callable
which is called to generated value on cache miss
- params `Array` - parameters to be passed to *callable*
- ttl `integer` - time to live to use, if value is set on cache miss
<a name="LogFace"></a>
#class: LogFace
**Members**
* [class: LogFace](#LogFace)
* [new LogFace()](#new_LogFace)
* [LogFace.ifacespec](#LogFace.ifacespec)
* [LogFace.register()](#LogFace.register)
* [logFace.msg(lvl, txt)](#LogFace#msg)
* [logFace.msg(lvl, txt, data)](#LogFace#msg)
* [logFace.debug(txt)](#LogFace#debug)
* [logFace.info(txt)](#LogFace#info)
* [logFace.warn(txt)](#LogFace#warn)
* [logFace.error(txt)](#LogFace#error)
* [logFace.security(txt)](#LogFace#security)
* [const: LogFace.LVL_DEBUG](#LogFace.LVL_DEBUG)
* [const: LogFace.LVL_INFO](#LogFace.LVL_INFO)
* [const: LogFace.LVL_WARN](#LogFace.LVL_WARN)
* [const: LogFace.LVL_ERROR](#LogFace.LVL_ERROR)
* [const: LogFace.LVL_SECURITY](#LogFace.LVL_SECURITY)
<a name="new_LogFace"></a>
##new LogFace()
AuditLog Native interface
Register with LogFace.register()
<a name="LogFace.ifacespec"></a>
##LogFace.ifacespec
Embedded spec for FutoIn LogFace
<a name="LogFace.register"></a>
##LogFace.register()
AuditLog Native interface registration helper
<a name="LogFace#msg"></a>
##logFace.msg(lvl, txt)
Log message
**Params**
- lvl `string` - debug|info|warn|error|security
- txt `string` - message to log
<a name="LogFace#msg"></a>
##logFace.msg(lvl, txt, data)
Log message
**Params**
- lvl `string` - debug|info|warn|error|security
- txt `string` - message to log
- data `string` - raw data
<a name="LogFace#debug"></a>
##logFace.debug(txt)
Log message in debug level
**Params**
- txt `string` - message to log
<a name="LogFace#info"></a>
##logFace.info(txt)
Log message in info level
**Params**
- txt `string` - message to log
<a name="LogFace#warn"></a>
##logFace.warn(txt)
Log message in warn level
**Params**
- txt `string` - message to log
<a name="LogFace#error"></a>
##logFace.error(txt)
Log message in error level
**Params**
- txt `string` - message to log
<a name="LogFace#security"></a>
##logFace.security(txt)
Log message in security level
**Params**
- txt `string` - message to log
<a name="LogFace.LVL_DEBUG"></a>
##const: LogFace.LVL_DEBUG
Debug log level
<a name="LogFace.LVL_INFO"></a>
##const: LogFace.LVL_INFO
Info log level
<a name="LogFace.LVL_WARN"></a>
##const: LogFace.LVL_WARN
Warn log level
<a name="LogFace.LVL_ERROR"></a>
##const: LogFace.LVL_ERROR
Error log level
<a name="LogFace.LVL_SECURITY"></a>
##const: LogFace.LVL_SECURITY
Security log level
<a name="InterfaceInfo"></a>

@@ -286,4 +473,3 @@ #class: InterfaceInfo

* [nativeIface.call(as, name, params, upload_data, [download_stream], [timeout])](#NativeIface#call)
* [nativeIface.ifaceInfo()](#NativeIface#ifaceInfo)
* [nativeIface.burst()](#NativeIface#burst)
* [nativeIface.call()](#NativeIface#call)
* [nativeIface.bindDerivedKey()](#NativeIface#bindDerivedKey)

@@ -309,12 +495,7 @@

<a name="NativeIface#ifaceInfo"></a>
##nativeIface.ifaceInfo()
<a name="NativeIface#call"></a>
##nativeIface.call()
Get interface info
**Returns**: `object`
<a name="NativeIface#burst"></a>
##nativeIface.burst()
Returns extended API interface as defined in [FTN10 Burst Calls][]
**Returns**: `object`
<a name="NativeIface#bindDerivedKey"></a>

@@ -321,0 +502,0 @@ ##nativeIface.bindDerivedKey()

var fail_next = false;
var log_count = 0;
var cached_value;

@@ -10,4 +12,54 @@ function processServerRequest( freq, data )

{
return { e : 'InvalidReuquest' };
return { e : 'InvalidRequest' };
}
else if ( func[0] === 'futoin.log' &&
func[1] === '1.0' )
{
if ( freq.p.txt === 'sync' )
{
if ( freq.p.lvl !== 'debug' )
{
return null;
}
}
else if ( freq.p.txt.toLowerCase() !== freq.p.lvl + 'msg' )
{
return null;
}
else if ( func[2] === 'hexdump' &&
freq.p.data !== new Buffer( 'HEXDATA' ).toString( 'base64' ) )
{
return null;
}
++log_count;
return '';
}
else if ( func[0] === 'futoin.cache' &&
func[1] === '1.0' )
{
if ( freq.p.key !== 'mykey1_2' ||
( func[2] === 'set' && freq.p.ttl !== 10 ) )
{
return { e : 'InvalidRequest', edesc: JSON.stringify( freq ) };
}
switch ( func[2] )
{
case 'set':
cached_value = freq.p.value;
return { value: cached_value };
case 'get':
if ( cached_value )
{
return { value: cached_value };
}
else
{
return { e: 'CacheMiss' };
}
}
}
else if ( func[0] !== 'fileface.a' )

@@ -82,2 +134,5 @@ {

return { pong : freq.p.ping };
case "getLogCount":
return { count: log_count };
}

@@ -84,0 +139,0 @@

@@ -90,2 +90,9 @@ {

]
},
"getLogCount" : {
"result" : {
"count" : {
"type" : "integer"
}
}
}

@@ -92,0 +99,0 @@ },

var _ = require( 'lodash' );
var assert;
var async_steps = require( 'futoin-asyncsteps' );
var logface = require( '../lib/logface' );
var cacheface = require( '../lib/cacheface' );
var invoker;

@@ -71,2 +73,6 @@ var as;

try {
as.state.reg_fired = false;
ccm.once( 'register', function(){
as.state.reg_fired = true;
});
ccm.register( as , 'myiface', 'iface.a:1.1', 'http://localhost:23456' );

@@ -81,3 +87,6 @@ } catch ( e ) {

)
.add( function(as){ done(); })
.add( function(as){
as.state.reg_fired.should.be.true;
done();
})
.execute();

@@ -96,2 +105,7 @@ }

as.state.reg_fired = false;
ccm.once('unregister', function()
{
as.state.reg_fired = true;
});
ccm.unRegister( 'myiface' );

@@ -103,5 +117,2 @@ ccm.assertIface( 'otherface', 'iface.b:1.2' );

}, 'InvokerError' );
as.success();
done();
} catch ( e ){

@@ -116,4 +127,9 @@ console.dir( e.stack );

}
);
as.execute();
)
.add( function( as )
{
as.state.reg_fired.should.be.true;
done();
} )
.execute();
});

@@ -633,3 +649,3 @@

err.should.equal( "InvokerError" );
as.state.error_info.should.equal( "Unknown interface function" );
as.state.error_info.should.equal( "Unknown interface function: unknownFunc" );
}

@@ -719,3 +735,3 @@ else

err.should.equal( "InvokerError" );
as.state.error_info.should.equal( "Unknown parameter b" );
as.state.error_info.should.equal( "Unknown parameter: b" );

@@ -773,2 +789,24 @@ as.success();

}
).add(
function( as )
{
as.state.close_called = false;
as.state.iface_close_called = false;
ccm.once( 'close', function(){
as.state.close_called = true;
});
iface.once( 'close', function(){
as.state.iface_close_called = true;
});
ccm.close();
}
).add(
function( as )
{
as.state.close_called.should.be.true;
as.state.iface_close_called.should.be.true;
}
);

@@ -849,3 +887,4 @@ },

{
as.state.done( new Error( err + ": " + as.state.error_info + "("+as.state.step+")" ) );
console.log( err + ": " + as.state.error_info + "("+as.state.step+")" );
as.state.done( as.state.last_exception );
}

@@ -1303,1 +1342,140 @@ ).add( function( as ){

});
//============================================================================
describe( 'LogFace', function()
{
before(function( done ){
as = async_steps();
var opts = {};
opts[ invoker.AdvancedCCM.OPT_SPEC_DIRS ] = thisDir + '/specs';
ccm = new invoker.AdvancedCCM( opts );
as
.add(
function( as ) {
logface.register( as, ccm, 'secure+ws://localhost:23456/ftn' );
ccm.register( as , 'myiface', 'fileface.a:1.1', 'secure+ws://localhost:23456/ftn' );
as.add( function( as ){
createTestHttpServer( function(){ done(); } );
} );
},
function( as, err )
{
console.log( as.state.error_info );
done( as.state.last_exception );
}
)
.execute();
});
after(function( done ){
closeTestHttpServer( done );
});
it( 'should call futoin.log through native interface', function( done )
{
as
.add(
function( as ){
ccm.log().debug( 'DEBUGMSG' );
ccm.log().info( 'INFOMSG' );
ccm.log().warn( 'WARNMSG' );
ccm.log().error( 'ERRORMSG' );
ccm.log().security( 'SECURITYMSG' );
ccm.log().hexdump( 'debug', 'DEBUGMSG', 'HEXDATA' );
ccm.log().call( as, 'msg', { txt: 'sync', lvl : 'debug', ts : '12345678901234.123' } );
as.add( function( as )
{
ccm.iface( 'myiface' ).getLogCount( as );
} );
as.add( function( as, res )
{
res.count.should.equal( 7 );
} );
},
function( as, err )
{
console.log( as.state.error_info );
done( as.state.last_exception );
}
)
.add( function( as, res )
{
done();
} )
.execute();
});
} );
//============================================================================
describe( 'CacheFace', function()
{
before(function( done ){
as = async_steps();
var opts = {};
opts[ invoker.AdvancedCCM.OPT_SPEC_DIRS ] = thisDir + '/specs';
ccm = new invoker.AdvancedCCM( opts );
as
.add(
function( as ) {
cacheface.register( as, ccm, 'my', 'secure+ws://localhost:23456/ftn', 'login:pass' );
ccm.register( as , 'myiface', 'fileface.a:1.1', 'secure+ws://localhost:23456/ftn' );
as.add( function( as ){
createTestHttpServer( function(){ done(); } );
} );
},
function( as, err )
{
console.log( as.state.error_info );
done( as.state.last_exception );
}
)
.execute();
});
after(function( done ){
closeTestHttpServer( done );
});
it( 'should call futoin.cache through native interface', function( done )
{
as
.add(
function( as ){
var cface = ccm.cache( 'my' );
var call_count = 0;
var cb = function( as, a, b )
{
call_count += 1;
as.add( function( as ){
as.success( a + b );
});
};
cface.getOrSet( as, 'mykey', cb, [1,2], 10 );
as.add( function( as, value ){
value.should.equal( 3 );
call_count.should.equal( 1 );
});
},
function( as, err )
{
console.log( as.state.error_info );
done( as.state.last_exception );
}
)
.add( function( as, res )
{
done();
} )
.execute();
});
} );

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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