x&&a("overflow"),m==t){for(c=r,f=j;p=f<=i?E:f>=i+P?P:f-i,!(c= 0x80 (not a basic code point)","invalid-input":"Invalid input"},Z=j-E,T=Math.floor,_=String.fromCharCode;if(O={version:"1.4.1",ucs2:{decode:h,encode:f},decode:m,encode:y,toASCII:b,toUnicode:v},"object"==i(r(3))&&r(3))void 0!==(o=function(){return O}.call(t,r,t,e))&&(e.exports=o);else if(g&&S)if(e.exports==g)S.exports=O;else for(A in O)O.hasOwnProperty(A)&&(g[A]=O[A]);else s.punycode=O}(void 0)}).call(t,r(13)(e),r(12))},function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,r,i){t=t||"&",r=r||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var u=1e3;i&&"number"==typeof i.maxKeys&&(u=i.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var h=0;h=0?(f=m.substr(0,y),p=m.substr(y+1)):(f=m,p=""),l=decodeURIComponent(f),d=decodeURIComponent(p),n(s,l)?o(s[l])?s[l].push(d):s[l]=[s[l],d]:s[l]=d}return s};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,r){"use strict";function n(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n2&&void 0!==arguments[2]?arguments[2]:void 0;if("string"!=typeof t)return n;for(var r=t.split("."),o=e,i=0;i1&&void 0!==arguments[1]?arguments[1]:1e4,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};o(this,t);var u=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return u.worker=e,u.sockets=e.scServer.clients,u.endpoints.slaveRpc={},u.config={},u.internalRequestsTimeoutMs=n,u.worker.on("masterMessage",function(e,t){p.isValid(e,p.MasterConfigRequestSchema)?(u.config=Object.assign({},u.config,e.config),e.registeredEvents&&u.registerEventEndpoints(e.registeredEvents.reduce(function(e,t){return Object.assign(e,r({},t,function(e){u.worker.sendToMaster({data:e,procedure:t,type:p.EventRequestSchema.id})}))},{})),s(null,u),s=function(){}):console.error('Received invalid master message payload of type "'+e.type+'"')}),u}return s(t,e),u(t,[{key:"sendToMaster",value:function(e,t,n){var r={type:p.InterProcessRPCRequestSchema.id,procedure:e,data:t};n?this.worker.sendToMaster(r,function(e,t){return e?n(e):n(null,t.data)}):this.worker.sendToMaster(r)}},{key:"processWAMPRequest",value:function(e,t){d.validate(e,p.RPCRequestSchema).valid&&(this.endpoints.slaveRpc[e.procedure]&&"function"==typeof this.endpoints.slaveRpc[e.procedure]?t?this.endpoints.slaveRpc[e.procedure](e,function(e,n){t(e,{type:p.RPCResponseSchema.id,data:n})}):this.endpoints.slaveRpc[e.procedure](e):(e.type=p.MasterRPCRequestSchema.id,this.worker.sendToMaster(e,t)))}},{key:"reassignRPCSlaveEndpoints",value:function(e){this.endpoints.slaveRpc=e}},{key:"registerRPCSlaveEndpoints",value:function(e){this.endpoints.slaveRpc=Object.assign(this.endpoints.slaveRpc,e)}}]),t}(a);e.exports=f}])});
--------------------------------------------------------------------------------
/dist/WAMPClient.bundle.min.js:
--------------------------------------------------------------------------------
1 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("wampSocketCluster",[],t):"object"==typeof exports?exports.wampSocketCluster=t():e.wampSocketCluster=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=16)}([function(e,t,r){"use strict";function n(e,t){return t+": "+e.toString()+"\n"}function o(e,t,r,n){"object"===(void 0===r?"undefined":c(r))?t[n]=s(e[n],r):-1===e.indexOf(r)&&t.push(r)}function i(e,t,r){t[r]=e[r]}function a(e,t,r,n){"object"===c(t[n])&&t[n]&&e[n]?r[n]=s(e[n],t[n]):r[n]=t[n]}function s(e,t){var r=Array.isArray(t),n=r&&[]||{};return r?(e=e||[],n=n.concat(e),t.forEach(o.bind(null,e,n))):(e&&"object"===(void 0===e?"undefined":c(e))&&Object.keys(e).forEach(i.bind(null,e,n)),Object.keys(t).forEach(a.bind(null,e,t,n))),n}function u(e){return"/"+encodeURIComponent(e).replace(/~/g,"%7E")}var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h=r(2),f=t.ValidationError=function(e,t,r,n,o,i){n&&(this.property=n),e&&(this.message=e),r&&(r.id?this.schema=r.id:this.schema=r),t&&(this.instance=t),this.name=o,this.argument=i,this.stack=this.toString()};f.prototype.toString=function(){return this.property+" "+this.message};var l=t.ValidatorResult=function(e,t,r,n){this.instance=e,this.schema=t,this.propertyPath=n.propertyPath,this.errors=[],this.throwError=r&&r.throwError,this.disableFormat=r&&!0===r.disableFormat};l.prototype.addError=function(e){var t;if("string"==typeof e)t=new f(e,this.instance,this.schema,this.propertyPath);else{if(!e)throw new Error("Missing error detail");if(!e.message)throw new Error("Missing error message");if(!e.name)throw new Error("Missing validator type");t=new f(e.message,this.instance,this.schema,this.propertyPath,e.name,e.argument)}if(this.throwError)throw t;return this.errors.push(t),t},l.prototype.importErrors=function(e){"string"==typeof e||e&&e.validatorType?this.addError(e):e&&e.errors&&Array.prototype.push.apply(this.errors,e.errors)},l.prototype.toString=function(e){return this.errors.map(n).join("")},Object.defineProperty(l.prototype,"valid",{get:function(){return!this.errors.length}});var m=t.SchemaError=function e(t,r){this.message=t,this.schema=r,Error.call(this,t),Error.captureStackTrace(this,e)};m.prototype=Object.create(Error.prototype,{constructor:{value:m,enumerable:!1},name:{value:"SchemaError",enumerable:!1}});var p=t.SchemaContext=function(e,t,r,n,o){this.schema=e,this.options=t,this.propertyPath=r,this.base=n,this.schemas=o};p.prototype.resolve=function(e){return h.resolve(this.base,e)},p.prototype.makeChild=function(e,t){var r=void 0===t?this.propertyPath:this.propertyPath+y(t),n=h.resolve(this.base,e.id||""),o=new p(e,this.options,r,n,Object.create(this.schemas));return e.id&&!o.schemas[n]&&(o.schemas[n]=e),o};var d=t.FORMAT_REGEXPS={"date-time":/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])[tT ](2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])(\.\d+)?([zZ]|[+-]([0-5][0-9]):(60|[0-5][0-9]))$/,date:/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-(3[01]|0[1-9]|[12][0-9])$/,time:/^(2[0-4]|[01][0-9]):([0-5][0-9]):(60|[0-5][0-9])$/,email:/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/,"ip-address":/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,ipv6:/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,uri:/^[a-zA-Z][a-zA-Z0-9+-.]*:[^\s]*$/,color:/^(#?([0-9A-Fa-f]{3}){1,2}\b|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\)))$/,hostname:/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,"host-name":/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/,alpha:/^[a-zA-Z]+$/,alphanumeric:/^[a-zA-Z0-9]+$/,"utc-millisec":function(e){return"string"==typeof e&&parseFloat(e)===parseInt(e,10)&&!isNaN(e)},regex:function(e){var t=!0;try{new RegExp(e)}catch(e){t=!1}return t},style:/\s*(.+?):\s*([^;]+);?/g,phone:/^\+(?:[0-9] ?){6,14}[0-9]$/};d.regexp=d.regex,d.pattern=d.regex,d.ipv4=d["ip-address"],t.isFormat=function(e,t,r){if("string"==typeof e&&void 0!==d[t]){if(d[t]instanceof RegExp)return d[t].test(e);if("function"==typeof d[t])return d[t](e)}else if(r&&r.customFormats&&"function"==typeof r.customFormats[t])return r.customFormats[t](e);return!0};var y=t.makeSuffix=function(e){return e=e.toString(),e.match(/[.\s\[\]]/)||e.match(/^[\d]/)?e.match(/^\d+$/)?"["+e+"]":"["+JSON.stringify(e)+"]":"."+e};t.deepCompareStrict=function e(t,r){if((void 0===t?"undefined":c(t))!==(void 0===r?"undefined":c(r)))return!1;if(t instanceof Array)return r instanceof Array&&(t.length===r.length&&t.every(function(n,o){return e(t[o],r[o])}));if("object"===(void 0===t?"undefined":c(t))){if(!t||!r)return t===r;var n=Object.keys(t),o=Object.keys(r);return n.length===o.length&&n.every(function(n){return e(t[n],r[n])})}return t===r},e.exports.deepMerge=s,t.objectGetPath=function(e,t){for(var r,n=t.split("/").slice(1);"string"==typeof(r=n.shift());){var o=decodeURIComponent(r.replace(/~0/,"~").replace(/~1/g,"/"));if(!(o in e))return;e=e[o]}return e},t.encodePath=function(e){return e.map(u).join("")}},function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o,i=r(4).Validator,a=new i,s={id:"/RPCResponse",type:"object",properties:{type:{type:"string"},data:{}},required:["type","data"]},u={id:"/RPCRequest",type:"object",properties:{type:{type:"string"},procedure:{type:"string"},data:{}},required:["type","procedure"]},c={id:"/EventRequestSchema",type:"object",properties:{type:{type:"string"},procedure:{type:"string"},data:{}},required:["type","procedure"]},h={id:"/MasterRPCRequest",type:"object",properties:{type:{type:"string"},procedure:{type:"string"},data:{}},required:["type","procedure"]},f={id:"/InterProcessRPCRequestSchema",type:"object",properties:{type:{type:"string"},procedure:{type:"string"},data:{}},required:["type","procedure"]},l={id:"/MasterConfigRequestSchema",type:"object",properties:{type:{type:"string"},registeredEvents:{type:"array"},config:{type:"object"}},required:["type","registeredEvents","config"]},m=n({},s.id,u.id),p=(o={},n(o,u.id,s.id),n(o,h.id,s.id),o),d=function(e,t){return a.validate(e,t).valid&&e.type===t.id};e.exports={EventRequestSchema:c,RPCRequestSchema:u,RPCResponseSchema:s,InterProcessRPCRequestSchema:f,MasterRPCRequestSchema:h,MasterConfigRequestSchema:l,resToReqMap:m,reqToResMap:p,isValid:d}},function(e,t,r){"use strict";function n(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function o(e,t,r){if(e&&h.isObject(e)&&e instanceof n)return e;var o=new n;return o.parse(e,t,r),o}function i(e){return h.isString(e)&&(e=o(e)),e instanceof n?e.format():n.prototype.format.call(e)}function a(e,t){return o(e,!1,!0).resolve(t)}function s(e,t){return e?o(e,!1,!0).resolveObject(t):t}var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=r(7),h=r(11);t.parse=o,t.resolve=a,t.resolveObject=s,t.format=i,t.Url=n;var f=/^([a-z0-9.+-]+:)/i,l=/:[0-9]*$/,m=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,p=["<",">",'"',"`"," ","\r","\n","\t"],d=["{","}","|","\\","^","`"].concat(p),y=["'"].concat(d),v=["%","/","?",";","#"].concat(y),b=["/","?","#"],g=/^[+a-z0-9A-Z_-]{0,63}$/,S=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,w={javascript:!0,"javascript:":!0},A={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},O=r(10);n.prototype.parse=function(e,t,r){if(!h.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+(void 0===e?"undefined":u(e)));var n=e.indexOf("?"),o=-1!==n&&n127?z+="x":z+=k[Z];if(!z.match(g)){var N=F.slice(0,P),U=F.slice(P+1),T=k.match(S);T&&(N.push(T[1]),U.unshift(T[2])),U.length&&(s="/"+U.join(".")+s),this.hostname=N.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),I||(this.hostname=c.toASCII(this.hostname));var L=this.port?":"+this.port:"",V=this.hostname||"";this.host=V+L,this.href+=this.host,I&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==s[0]&&(s="/"+s))}if(!w[d])for(var P=0,$=y.length;P<$;P++){var J=y[P];if(-1!==s.indexOf(J)){var B=encodeURIComponent(J);B===J&&(B=escape(J)),s=s.split(J).join(B)}}var _=s.indexOf("#");-1!==_&&(this.hash=s.substr(_),s=s.slice(0,_));var G=s.indexOf("?");if(-1!==G?(this.search=s.substr(G),this.query=s.substr(G+1),t&&(this.query=O.parse(this.query)),s=s.slice(0,G)):t&&(this.search="",this.query={}),s&&(this.pathname=s),x[d]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var L=this.pathname||"",D=this.search||"";this.path=L+D}return this.href=this.format(),this},n.prototype.format=function(){var e=this.auth||"";e&&(e=encodeURIComponent(e),e=e.replace(/%3A/i,":"),e+="@");var t=this.protocol||"",r=this.pathname||"",n=this.hash||"",o=!1,i="";this.host?o=e+this.host:this.hostname&&(o=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&h.isObject(this.query)&&Object.keys(this.query).length&&(i=O.stringify(this.query));var a=this.search||i&&"?"+i||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||x[t])&&!1!==o?(o="//"+(o||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):o||(o=""),n&&"#"!==n.charAt(0)&&(n="#"+n),a&&"?"!==a.charAt(0)&&(a="?"+a),r=r.replace(/[?#]/g,function(e){return encodeURIComponent(e)}),a=a.replace("#","%23"),t+o+r+a+n},n.prototype.resolve=function(e){return this.resolveObject(o(e,!1,!0)).format()},n.prototype.resolveObject=function(e){if(h.isString(e)){var t=new n;t.parse(e,!1,!0),e=t}for(var r=new n,o=Object.keys(this),i=0;i0)&&r.host.split("@");j&&(r.auth=j.shift(),r.host=r.hostname=j.shift())}return r.search=e.search,r.query=e.query,h.isNull(r.pathname)&&h.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!w.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var E=w.slice(-1)[0],P=(r.host||e.host||w.length>1)&&("."===E||".."===E)||""===E,R=0,q=w.length;q>=0;q--)E=w[q],"."===E?w.splice(q,1):".."===E?(w.splice(q,1),R++):R&&(w.splice(q,1),R--);if(!g&&!S)for(;R--;R)w.unshift("..");!g||""===w[0]||w[0]&&"/"===w[0].charAt(0)||w.unshift(""),P&&"/"!==w.join("/").substr(-1)&&w.push("");var C=""===w[0]||w[0]&&"/"===w[0].charAt(0);if(O){r.hostname=r.host=C?"":w.length?w.shift():"";var j=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@");j&&(r.auth=j.shift(),r.host=r.hostname=j.shift())}return g=g||r.host&&w.length,g&&!C&&w.unshift(""),w.length?r.pathname=w.join("/"):(r.pathname=null,r.path=null),h.isNull(r.pathname)&&h.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var e=this.host,t=l.exec(e);t&&(t=t[0],":"!==t&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t){(function(t){e.exports=t}).call(t,{})},function(e,t,r){"use strict";var n=e.exports.Validator=r(6);e.exports.ValidatorResult=r(0).ValidatorResult,e.exports.ValidationError=r(0).ValidationError,e.exports.SchemaError=r(0).SchemaError,e.exports.validate=function(e,t,r){return(new n).validate(e,t,r)}},function(e,t,r){"use strict";function n(e,t,r,n,o){var i=this.validateSchema(e,o,t,r);return!i.valid&&n instanceof Function&&n(i),i.valid}function o(e,t,r,n,o,i){if(!t.properties||void 0===t.properties[o])if(!1===t.additionalProperties)i.addError({name:"additionalProperties",argument:o,message:"additionalProperty "+JSON.stringify(o)+" exists in instance when not allowed"});else{var a=t.additionalProperties||{},s=this.validateSchema(e[o],a,r,n.makeChild(a,o));s.instance!==i.instance[o]&&(i.instance[o]=s.instance),i.importErrors(s)}}function i(e,t,r){var n,o=r.length;for(n=t+1,o;n"||e+""});o.addError({name:"type",argument:a,message:"is not of a type(s) "+a})}return o},f.anyOf=function(e,t,r,o){if(void 0===e)return null;var i=new u(e,t,r,o),a=new u(e,t,r,o);if(!Array.isArray(t.anyOf))throw new c("anyOf must be an array");if(!t.anyOf.some(n.bind(this,e,r,o,function(e){a.importErrors(e)}))){var s=t.anyOf.map(function(e,t){return e.id&&"<"+e.id+">"||e.title&&JSON.stringify(e.title)||e.$ref&&"<"+e.$ref+">"||"[subschema "+t+"]"});r.nestedErrors&&i.importErrors(a),i.addError({name:"anyOf",argument:s,message:"is not any of "+s.join(",")})}return i},f.allOf=function(e,t,r,n){if(void 0===e)return null;if(!Array.isArray(t.allOf))throw new c("allOf must be an array");var o=new u(e,t,r,n),i=this;return t.allOf.forEach(function(t,a){var s=i.validateSchema(e,t,r,n);if(!s.valid){var u=t.id&&"<"+t.id+">"||t.title&&JSON.stringify(t.title)||t.$ref&&"<"+t.$ref+">"||"[subschema "+a+"]";o.addError({name:"allOf",argument:{id:u,length:s.errors.length,valid:s},message:"does not match allOf schema "+u+" with "+s.errors.length+" error[s]:"}),o.importErrors(s)}}),o},f.oneOf=function(e,t,r,o){if(void 0===e)return null;if(!Array.isArray(t.oneOf))throw new c("oneOf must be an array");var i=new u(e,t,r,o),a=new u(e,t,r,o),s=t.oneOf.filter(n.bind(this,e,r,o,function(e){a.importErrors(e)})).length,h=t.oneOf.map(function(e,t){return e.id&&"<"+e.id+">"||e.title&&JSON.stringify(e.title)||e.$ref&&"<"+e.$ref+">"||"[subschema "+t+"]"});return 1!==s&&(r.nestedErrors&&i.importErrors(a),i.addError({name:"oneOf",argument:h,message:"is not exactly one from "+h.join(",")})),i},f.properties=function(e,t,r,n){if(void 0!==e&&e instanceof Object){var o=new u(e,t,r,n),i=t.properties||{};for(var a in i){var s=(e||void 0)&&e[a],c=this.validateSchema(s,i[a],r,n.makeChild(i[a],a));c.instance!==o.instance[a]&&(o.instance[a]=c.instance),o.importErrors(c)}return o}},f.patternProperties=function(e,t,r,n){if(void 0!==e&&this.types.object(e)){var i=new u(e,t,r,n),a=t.patternProperties||{};for(var s in e){var c=!0;for(var h in a){if(new RegExp(h).test(s)){c=!1;var f=this.validateSchema(e[s],a[h],r,n.makeChild(a[h],s));f.instance!==i.instance[s]&&(i.instance[s]=f.instance),i.importErrors(f)}}c&&o.call(this,e,t,r,n,s,i)}return i}},f.additionalProperties=function(e,t,r,n){if(void 0!==e&&this.types.object(e)){if(t.patternProperties)return null;var i=new u(e,t,r,n);for(var a in e)o.call(this,e,t,r,n,a,i);return i}},f.minProperties=function(e,t,r,n){if(!e||"object"!==(void 0===e?"undefined":a(e)))return null;var o=new u(e,t,r,n);return Object.keys(e).length>=t.minProperties||o.addError({name:"minProperties",argument:t.minProperties,message:"does not meet minimum property length of "+t.minProperties}),o},f.maxProperties=function(e,t,r,n){if(!e||"object"!==(void 0===e?"undefined":a(e)))return null;var o=new u(e,t,r,n);return Object.keys(e).length<=t.maxProperties||o.addError({name:"maxProperties",argument:t.maxProperties,message:"does not meet maximum property length of "+t.maxProperties}),o},f.items=function(e,t,r,n){if(!Array.isArray(e))return null;var o=this,i=new u(e,t,r,n);return void 0!==e&&t.items?(e.every(function(e,a){var s=Array.isArray(t.items)?t.items[a]||t.additionalItems:t.items;if(void 0===s)return!0;if(!1===s)return i.addError({name:"items",message:"additionalItems not permitted"}),!1;var u=o.validateSchema(e,s,r,n.makeChild(s,a));return u.instance!==i.instance[a]&&(i.instance[a]=u.instance),i.importErrors(u),!0}),i):i},f.minimum=function(e,t,r,n){if("number"!=typeof e)return null;var o=new u(e,t,r,n),i=!0;return i=t.exclusiveMinimum&&!0===t.exclusiveMinimum?e>t.minimum:e>=t.minimum,i||o.addError({name:"minimum",argument:t.minimum,message:"must have a minimum value of "+t.minimum}),o},f.maximum=function(e,t,r,n){if("number"!=typeof e)return null;var o,i=new u(e,t,r,n);return o=t.exclusiveMaximum&&!0===t.exclusiveMaximum?e=t.minLength||o.addError({name:"minLength",argument:t.minLength,message:"does not meet minimum length of "+t.minLength}),o},f.maxLength=function(e,t,r,n){if("string"!=typeof e)return null;var o=new u(e,t,r,n);return e.length<=t.maxLength||o.addError({name:"maxLength",argument:t.maxLength,message:"does not meet maximum length of "+t.maxLength}),o},f.minItems=function(e,t,r,n){if(!Array.isArray(e))return null;var o=new u(e,t,r,n);return e.length>=t.minItems||o.addError({name:"minItems",argument:t.minItems,message:"does not meet minimum length of "+t.minItems}),o},f.maxItems=function(e,t,r,n){if(!Array.isArray(e))return null;var o=new u(e,t,r,n);return e.length<=t.maxItems||o.addError({name:"maxItems",argument:t.maxItems,message:"does not meet maximum length of "+t.maxItems}),o},f.uniqueItems=function(e,t,r,n){function o(e,t,r){for(var n=t+1;n"||a;i.addError({name:"not",argument:s,message:"is of prohibited type "+s})}}),i):null},e.exports=h},function(e,t,r){"use strict";function n(e){var t="string"==typeof e?e:e.$ref;return"string"==typeof t&&t}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(2),a=r(5),s=r(0),u=s.ValidatorResult,c=s.SchemaError,h=s.SchemaContext,f=function e(){this.customFormats=Object.create(e.prototype.customFormats),this.schemas={},this.unresolvedRefs=[],this.types=Object.create(l),this.attributes=Object.create(a.validators)};f.prototype.customFormats={},f.prototype.schemas=null,f.prototype.types=null,f.prototype.attributes=null,f.prototype.unresolvedRefs=null,f.prototype.addSchema=function(e,t){if(!e)return null;var r=t||e.id;return this.addSubSchema(r,e),r&&(this.schemas[r]=e),this.schemas[r]},f.prototype.addSubSchema=function(e,t){if(t&&"object"==(void 0===t?"undefined":o(t))){if(t.$ref){var r=i.resolve(e,t.$ref);return void(void 0===this.schemas[r]&&(this.schemas[r]=null,this.unresolvedRefs.push(r)))}var n=t.id&&i.resolve(e,t.id),a=n||e;if(n){if(this.schemas[n]){if(!s.deepCompareStrict(this.schemas[n],t))throw new Error("Schema <"+t+"> already exists with different definition");return this.schemas[n]}this.schemas[n]=t;var u=n.replace(/^([^#]*)#$/,"$1");this.schemas[u]=t}return this.addSubSchemaArray(a,t.items instanceof Array?t.items:[t.items]),this.addSubSchemaArray(a,t.extends instanceof Array?t.extends:[t.extends]),this.addSubSchema(a,t.additionalItems),this.addSubSchemaObject(a,t.properties),this.addSubSchema(a,t.additionalProperties),this.addSubSchemaObject(a,t.definitions),this.addSubSchemaObject(a,t.patternProperties),this.addSubSchemaObject(a,t.dependencies),this.addSubSchemaArray(a,t.disallow),this.addSubSchemaArray(a,t.allOf),this.addSubSchemaArray(a,t.anyOf),this.addSubSchemaArray(a,t.oneOf),this.addSubSchema(a,t.not),this.schemas[n]}},f.prototype.addSubSchemaArray=function(e,t){if(t instanceof Array)for(var r=0;r",e);var u=s.objectGetPath(r.schemas[a],o.substr(1));if(void 0===u)throw new c("no such schema "+o+" located in <"+a+">",e);return{subschema:u,switchSchema:t}},f.prototype.testType=function(e,t,r,n,i){if("function"==typeof this.types[i])return this.types[i].call(this,e);if(i&&"object"==(void 0===i?"undefined":o(i))){var a=this.validateSchema(e,i,r,n);return void 0===a||!(a&&a.errors.length)}return!0};var l=f.prototype.types={};l.string=function(e){return"string"==typeof e},l.number=function(e){return"number"==typeof e&&isFinite(e)},l.integer=function(e){return"number"==typeof e&&e%1==0},l.boolean=function(e){return"boolean"==typeof e},l.array=function(e){return e instanceof Array},l.null=function(e){return null===e},l.date=function(e){return e instanceof Date},l.any=function(e){return!0},l.object=function(e){return e&&"object"===(void 0===e?"undefined":o(e))&&!(e instanceof Array)&&!(e instanceof Date)},e.exports=f},function(e,t,r){"use strict";(function(e,n){var o,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(a){function s(e){throw new RangeError(Z[e])}function u(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function c(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),e=e.replace(z,"."),n+u(e.split("."),t).join(".")}function h(e){for(var t,r,n=[],o=0,i=e.length;o=55296&&t<=56319&&o65535&&(e-=65536,t+=U(e>>>10&1023|55296),e=56320|1023&e),t+=U(e)}).join("")}function l(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:j}function m(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function p(e,t,r){var n=0;for(e=r?N(e/q):e>>1,e+=N(e/t);e>M*P>>1;n+=j)e=N(e/M);return N(n+(M+1)*e/(e+R))}function d(e){var t,r,n,o,i,a,u,c,h,m,d=[],y=e.length,v=0,b=I,g=C;for(r=e.lastIndexOf(F),r<0&&(r=0),n=0;n=128&&s("not-basic"),d.push(e.charCodeAt(n));for(o=r>0?r+1:0;o=y&&s("invalid-input"),c=l(e.charCodeAt(o++)),(c>=j||c>N((O-v)/a))&&s("overflow"),v+=c*a,h=u<=g?E:u>=g+P?P:u-g,!(cN(O/m)&&s("overflow"),a*=m;t=d.length+1,g=p(v-i,t,0==i),N(v/t)>O-b&&s("overflow"),b+=N(v/t),v%=t,d.splice(v++,0,b)}return f(d)}function y(e){var t,r,n,o,i,a,u,c,f,l,d,y,v,b,g,S=[];for(e=h(e),y=e.length,t=I,r=0,i=C,a=0;a=t&&dN((O-r)/v)&&s("overflow"),r+=(u-t)*v,t=u,a=0;aO&&s("overflow"),d==t){for(c=r,f=j;l=f<=i?E:f>=i+P?P:f-i,!(c= 0x80 (not a basic code point)","invalid-input":"Invalid input"},M=j-E,N=Math.floor,U=String.fromCharCode;if(A={version:"1.4.1",ucs2:{decode:h,encode:f},decode:d,encode:y,toASCII:b,toUnicode:v},"object"==i(r(3))&&r(3))void 0!==(o=function(){return A}.call(t,r,t,e))&&(e.exports=o);else if(g&&S)if(e.exports==g)S.exports=A;else for(x in A)A.hasOwnProperty(x)&&(g[x]=A[x]);else a.punycode=A}(void 0)}).call(t,r(13)(e),r(12))},function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,r,i){t=t||"&",r=r||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var u=1e3;i&&"number"==typeof i.maxKeys&&(u=i.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var h=0;h=0?(f=d.substr(0,y),l=d.substr(y+1)):(f=d,l=""),m=decodeURIComponent(f),p=decodeURIComponent(l),n(a,m)?o(a[m])?a[m].push(p):a[m]=[a[m],p]:a[m]=p}return a};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,r){"use strict";function n(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n2&&void 0!==arguments[2]?arguments[2]:void 0;if("string"!=typeof t)return r;for(var n=t.split("."),o=e,i=0;i2&&void 0!==arguments[2]?arguments[2]:void 0;if("string"!=typeof t)return r;for(var n=t.split("."),o=e,i=0;i",'"',"`"," ","\r","\n","\t"],d=["{","}","|","\\","^","`"].concat(m),y=["'"].concat(d),v=["%","/","?",";","#"].concat(y),b=["/","?","#"],g=/^[+a-z0-9A-Z_-]{0,63}$/,S=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,w={javascript:!0,"javascript:":!0},A={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},O=r(10);n.prototype.parse=function(e,t,r){if(!h.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+(void 0===e?"undefined":u(e)));var n=e.indexOf("?"),o=-1!==n&&n127?z+="x":z+=$[M];if(!z.match(g)){var N=F.slice(0,P),U=F.slice(P+1),T=$.match(S);T&&(N.push(T[1]),U.unshift(T[2])),U.length&&(a="/"+U.join(".")+a),this.hostname=N.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),I||(this.hostname=c.toASCII(this.hostname));var L=this.port?":"+this.port:"",V=this.hostname||"";this.host=V+L,this.href+=this.host,I&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!w[d])for(var P=0,k=y.length;P0)&&r.host.split("@");j&&(r.auth=j.shift(),r.host=r.hostname=j.shift())}return r.search=e.search,r.query=e.query,h.isNull(r.pathname)&&h.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!w.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var E=w.slice(-1)[0],P=(r.host||e.host||w.length>1)&&("."===E||".."===E)||""===E,R=0,q=w.length;q>=0;q--)E=w[q],"."===E?w.splice(q,1):".."===E?(w.splice(q,1),R++):R&&(w.splice(q,1),R--);if(!g&&!S)for(;R--;R)w.unshift("..");!g||""===w[0]||w[0]&&"/"===w[0].charAt(0)||w.unshift(""),P&&"/"!==w.join("/").substr(-1)&&w.push("");var C=""===w[0]||w[0]&&"/"===w[0].charAt(0);if(O){r.hostname=r.host=C?"":w.length?w.shift():"";var j=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@");j&&(r.auth=j.shift(),r.host=r.hostname=j.shift())}return g=g||r.host&&w.length,g&&!C&&w.unshift(""),w.length?r.pathname=w.join("/"):(r.pathname=null,r.path=null),h.isNull(r.pathname)&&h.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var e=this.host,t=p.exec(e);t&&(t=t[0],":"!==t&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t){(function(t){e.exports=t}).call(t,{})},function(e,t,r){"use strict";var n=e.exports.Validator=r(6);e.exports.ValidatorResult=r(0).ValidatorResult,e.exports.ValidationError=r(0).ValidationError,e.exports.SchemaError=r(0).SchemaError,e.exports.validate=function(e,t,r){return(new n).validate(e,t,r)}},function(e,t,r){"use strict";function n(e,t,r,n,o){var i=this.validateSchema(e,o,t,r);return!i.valid&&n instanceof Function&&n(i),i.valid}function o(e,t,r,n,o,i){if(!t.properties||void 0===t.properties[o])if(!1===t.additionalProperties)i.addError({name:"additionalProperties",argument:o,message:"additionalProperty "+JSON.stringify(o)+" exists in instance when not allowed"});else{var s=t.additionalProperties||{},a=this.validateSchema(e[o],s,r,n.makeChild(s,o));a.instance!==i.instance[o]&&(i.instance[o]=a.instance),i.importErrors(a)}}function i(e,t,r){var n,o=r.length;for(n=t+1,o;n"||e+""});o.addError({name:"type",argument:s,message:"is not of a type(s) "+s})}return o},f.anyOf=function(e,t,r,o){if(void 0===e)return null;var i=new u(e,t,r,o),s=new u(e,t,r,o);if(!Array.isArray(t.anyOf))throw new c("anyOf must be an array");if(!t.anyOf.some(n.bind(this,e,r,o,function(e){s.importErrors(e)}))){var a=t.anyOf.map(function(e,t){return e.id&&"<"+e.id+">"||e.title&&JSON.stringify(e.title)||e.$ref&&"<"+e.$ref+">"||"[subschema "+t+"]"});r.nestedErrors&&i.importErrors(s),i.addError({name:"anyOf",argument:a,message:"is not any of "+a.join(",")})}return i},f.allOf=function(e,t,r,n){if(void 0===e)return null;if(!Array.isArray(t.allOf))throw new c("allOf must be an array");var o=new u(e,t,r,n),i=this;return t.allOf.forEach(function(t,s){var a=i.validateSchema(e,t,r,n);if(!a.valid){var u=t.id&&"<"+t.id+">"||t.title&&JSON.stringify(t.title)||t.$ref&&"<"+t.$ref+">"||"[subschema "+s+"]";o.addError({name:"allOf",argument:{id:u,length:a.errors.length,valid:a},message:"does not match allOf schema "+u+" with "+a.errors.length+" error[s]:"}),o.importErrors(a)}}),o},f.oneOf=function(e,t,r,o){if(void 0===e)return null;if(!Array.isArray(t.oneOf))throw new c("oneOf must be an array");var i=new u(e,t,r,o),s=new u(e,t,r,o),a=t.oneOf.filter(n.bind(this,e,r,o,function(e){s.importErrors(e)})).length,h=t.oneOf.map(function(e,t){return e.id&&"<"+e.id+">"||e.title&&JSON.stringify(e.title)||e.$ref&&"<"+e.$ref+">"||"[subschema "+t+"]"});return 1!==a&&(r.nestedErrors&&i.importErrors(s),i.addError({name:"oneOf",argument:h,message:"is not exactly one from "+h.join(",")})),i},f.properties=function(e,t,r,n){if(void 0!==e&&e instanceof Object){var o=new u(e,t,r,n),i=t.properties||{};for(var s in i){var a=(e||void 0)&&e[s],c=this.validateSchema(a,i[s],r,n.makeChild(i[s],s));c.instance!==o.instance[s]&&(o.instance[s]=c.instance),o.importErrors(c)}return o}},f.patternProperties=function(e,t,r,n){if(void 0!==e&&this.types.object(e)){var i=new u(e,t,r,n),s=t.patternProperties||{};for(var a in e){var c=!0;for(var h in s){if(new RegExp(h).test(a)){c=!1;var f=this.validateSchema(e[a],s[h],r,n.makeChild(s[h],a));f.instance!==i.instance[a]&&(i.instance[a]=f.instance),i.importErrors(f)}}c&&o.call(this,e,t,r,n,a,i)}return i}},f.additionalProperties=function(e,t,r,n){if(void 0!==e&&this.types.object(e)){if(t.patternProperties)return null;var i=new u(e,t,r,n);for(var s in e)o.call(this,e,t,r,n,s,i);return i}},f.minProperties=function(e,t,r,n){if(!e||"object"!==(void 0===e?"undefined":s(e)))return null;var o=new u(e,t,r,n);return Object.keys(e).length>=t.minProperties||o.addError({name:"minProperties",argument:t.minProperties,message:"does not meet minimum property length of "+t.minProperties}),o},f.maxProperties=function(e,t,r,n){if(!e||"object"!==(void 0===e?"undefined":s(e)))return null;var o=new u(e,t,r,n);return Object.keys(e).length<=t.maxProperties||o.addError({name:"maxProperties",argument:t.maxProperties,message:"does not meet maximum property length of "+t.maxProperties}),o},f.items=function(e,t,r,n){if(!Array.isArray(e))return null;var o=this,i=new u(e,t,r,n);return void 0!==e&&t.items?(e.every(function(e,s){var a=Array.isArray(t.items)?t.items[s]||t.additionalItems:t.items;if(void 0===a)return!0;if(!1===a)return i.addError({name:"items",message:"additionalItems not permitted"}),!1;var u=o.validateSchema(e,a,r,n.makeChild(a,s));return u.instance!==i.instance[s]&&(i.instance[s]=u.instance),i.importErrors(u),!0}),i):i},f.minimum=function(e,t,r,n){if("number"!=typeof e)return null;var o=new u(e,t,r,n),i=!0;return i=t.exclusiveMinimum&&!0===t.exclusiveMinimum?e>t.minimum:e>=t.minimum,i||o.addError({name:"minimum",argument:t.minimum,message:"must have a minimum value of "+t.minimum}),o},f.maximum=function(e,t,r,n){if("number"!=typeof e)return null;var o,i=new u(e,t,r,n);return o=t.exclusiveMaximum&&!0===t.exclusiveMaximum?e=t.minLength||o.addError({name:"minLength",argument:t.minLength,message:"does not meet minimum length of "+t.minLength}),o},f.maxLength=function(e,t,r,n){if("string"!=typeof e)return null;var o=new u(e,t,r,n);return e.length<=t.maxLength||o.addError({name:"maxLength",argument:t.maxLength,message:"does not meet maximum length of "+t.maxLength}),o},f.minItems=function(e,t,r,n){if(!Array.isArray(e))return null;var o=new u(e,t,r,n);return e.length>=t.minItems||o.addError({name:"minItems",argument:t.minItems,message:"does not meet minimum length of "+t.minItems}),o},f.maxItems=function(e,t,r,n){if(!Array.isArray(e))return null;var o=new u(e,t,r,n);return e.length<=t.maxItems||o.addError({name:"maxItems",argument:t.maxItems,message:"does not meet maximum length of "+t.maxItems}),o},f.uniqueItems=function(e,t,r,n){function o(e,t,r){for(var n=t+1;n"||s;i.addError({name:"not",argument:a,message:"is of prohibited type "+a})}}),i):null},e.exports=h},function(e,t,r){"use strict";function n(e){var t="string"==typeof e?e:e.$ref;return"string"==typeof t&&t}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(2),s=r(5),a=r(0),u=a.ValidatorResult,c=a.SchemaError,h=a.SchemaContext,f=function e(){this.customFormats=Object.create(e.prototype.customFormats),this.schemas={},this.unresolvedRefs=[],this.types=Object.create(p),this.attributes=Object.create(s.validators)};f.prototype.customFormats={},f.prototype.schemas=null,f.prototype.types=null,f.prototype.attributes=null,f.prototype.unresolvedRefs=null,f.prototype.addSchema=function(e,t){if(!e)return null;var r=t||e.id;return this.addSubSchema(r,e),r&&(this.schemas[r]=e),this.schemas[r]},f.prototype.addSubSchema=function(e,t){if(t&&"object"==(void 0===t?"undefined":o(t))){if(t.$ref){var r=i.resolve(e,t.$ref);return void(void 0===this.schemas[r]&&(this.schemas[r]=null,this.unresolvedRefs.push(r)))}var n=t.id&&i.resolve(e,t.id),s=n||e;if(n){if(this.schemas[n]){if(!a.deepCompareStrict(this.schemas[n],t))throw new Error("Schema <"+t+"> already exists with different definition");return this.schemas[n]}this.schemas[n]=t;var u=n.replace(/^([^#]*)#$/,"$1");this.schemas[u]=t}return this.addSubSchemaArray(s,t.items instanceof Array?t.items:[t.items]),this.addSubSchemaArray(s,t.extends instanceof Array?t.extends:[t.extends]),this.addSubSchema(s,t.additionalItems),this.addSubSchemaObject(s,t.properties),this.addSubSchema(s,t.additionalProperties),this.addSubSchemaObject(s,t.definitions),this.addSubSchemaObject(s,t.patternProperties),this.addSubSchemaObject(s,t.dependencies),this.addSubSchemaArray(s,t.disallow),this.addSubSchemaArray(s,t.allOf),this.addSubSchemaArray(s,t.anyOf),this.addSubSchemaArray(s,t.oneOf),this.addSubSchema(s,t.not),this.schemas[n]}},f.prototype.addSubSchemaArray=function(e,t){if(t instanceof Array)for(var r=0;r",e);var u=a.objectGetPath(r.schemas[s],o.substr(1));if(void 0===u)throw new c("no such schema "+o+" located in <"+s+">",e);return{subschema:u,switchSchema:t}},f.prototype.testType=function(e,t,r,n,i){if("function"==typeof this.types[i])return this.types[i].call(this,e);if(i&&"object"==(void 0===i?"undefined":o(i))){var s=this.validateSchema(e,i,r,n);return void 0===s||!(s&&s.errors.length)}return!0};var p=f.prototype.types={};p.string=function(e){return"string"==typeof e},p.number=function(e){return"number"==typeof e&&isFinite(e)},p.integer=function(e){return"number"==typeof e&&e%1==0},p.boolean=function(e){return"boolean"==typeof e},p.array=function(e){return e instanceof Array},p.null=function(e){return null===e},p.date=function(e){return e instanceof Date},p.any=function(e){return!0},p.object=function(e){return e&&"object"===(void 0===e?"undefined":o(e))&&!(e instanceof Array)&&!(e instanceof Date)},e.exports=f},function(e,t,r){"use strict";(function(e,n){var o,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(s){function a(e){throw new RangeError(M[e])}function u(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function c(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),e=e.replace(z,"."),n+u(e.split("."),t).join(".")}function h(e){for(var t,r,n=[],o=0,i=e.length;o=55296&&t<=56319&&o65535&&(e-=65536,t+=U(e>>>10&1023|55296),e=56320|1023&e),t+=U(e)}).join("")}function p(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:j}function l(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function m(e,t,r){var n=0;for(e=r?N(e/q):e>>1,e+=N(e/t);e>Z*P>>1;n+=j)e=N(e/Z);return N(n+(Z+1)*e/(e+R))}function d(e){var t,r,n,o,i,s,u,c,h,l,d=[],y=e.length,v=0,b=I,g=C;for(r=e.lastIndexOf(F),r<0&&(r=0),n=0;n=128&&a("not-basic"),d.push(e.charCodeAt(n));for(o=r>0?r+1:0;o=y&&a("invalid-input"),c=p(e.charCodeAt(o++)),(c>=j||c>N((O-v)/s))&&a("overflow"),v+=c*s,h=u<=g?E:u>=g+P?P:u-g,!(cN(O/l)&&a("overflow"),s*=l;t=d.length+1,g=m(v-i,t,0==i),N(v/t)>O-b&&a("overflow"),b+=N(v/t),v%=t,d.splice(v++,0,b)}return f(d)}function y(e){var t,r,n,o,i,s,u,c,f,p,d,y,v,b,g,S=[];for(e=h(e),y=e.length,t=I,r=0,i=C,s=0;s=t&&dN((O-r)/v)&&a("overflow"),r+=(u-t)*v,t=u,s=0;sO&&a("overflow"),d==t){for(c=r,f=j;p=f<=i?E:f>=i+P?P:f-i,!(c= 0x80 (not a basic code point)","invalid-input":"Invalid input"},Z=j-E,N=Math.floor,U=String.fromCharCode;if(A={version:"1.4.1",ucs2:{decode:h,encode:f},decode:d,encode:y,toASCII:b,toUnicode:v},"object"==i(r(3))&&r(3))void 0!==(o=function(){return A}.call(t,r,t,e))&&(e.exports=o);else if(g&&S)if(e.exports==g)S.exports=A;else for(x in A)A.hasOwnProperty(x)&&(g[x]=A[x]);else s.punycode=A}(void 0)}).call(t,r(13)(e),r(12))},function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,r,i){t=t||"&",r=r||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var u=1e3;i&&"number"==typeof i.maxKeys&&(u=i.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var h=0;h=0?(f=d.substr(0,y),p=d.substr(y+1)):(f=d,p=""),l=decodeURIComponent(f),m=decodeURIComponent(p),n(s,l)?o(s[l])?s[l].push(m):s[l]=[s[l],m]:s[l]=m}return s};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,r){"use strict";function n(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n {
16 | this.socket = scClient.connect(options);
17 |
18 | wampClient.upgradeToWAMP(this.socket);
19 |
20 | this.socket.on('error', (err) => {
21 | throw new Error(`Socket error - ${err}`);
22 | });
23 |
24 | this.socket.on('connect', () => {
25 | console.info('socket client connected');
26 | });
27 |
28 | return this.socket;
29 | };
30 |
31 | Client.prototype.callRPCInInterval = () => {
32 | const interval = setInterval(() => {
33 | const randNumber = Math.floor(Math.random() * 5);
34 | this.socket.call('multiplyByTwo', randNumber)
35 | .then(result => console.info(`RPC result: ${randNumber} * 2 = ${result}`))
36 | .catch(err => console.warn('RPC multiply by two error', err));
37 |
38 | this.socket.emit('multiplyByThree', randNumber);
39 | }, 1000);
40 |
41 | this.socket.on('disconnect', () => {
42 | console.warn('socket client disconnected');
43 | clearInterval(interval);
44 | });
45 | };
46 |
47 | module.exports = Client;
48 |
--------------------------------------------------------------------------------
/example/index.js:
--------------------------------------------------------------------------------
1 | require('./server').getInstance();
2 |
3 | const Client = require('./client');
4 |
5 | setTimeout(() => {
6 | const c = new Client();
7 | c.connect();
8 | c.callRPCInInterval();
9 | }, 1000);
10 |
--------------------------------------------------------------------------------
/example/server.js:
--------------------------------------------------------------------------------
1 | const SocketCluster = require('socketcluster');
2 |
3 | const serverScenarioName = 'serverWorker';
4 |
5 | const options = {
6 | workers: 1,
7 | port: 8000,
8 | wsEngine: 'uws',
9 | appName: 'wampSocketCluster',
10 | workerController: `${__dirname}/${serverScenarioName}`,
11 | };
12 |
13 | const SOCKET_CLUSTER_KEY = Symbol.for('App.SocketClusterServer');
14 | const globalSymbols = Object.getOwnPropertySymbols(global);
15 | const hasSocketCluster = (globalSymbols.indexOf(SOCKET_CLUSTER_KEY) > -1);
16 |
17 | if (!hasSocketCluster) {
18 | global[SOCKET_CLUSTER_KEY] = {
19 | socketCluster: new SocketCluster(options),
20 | };
21 | }
22 |
23 | const socketClusterSingleton = {
24 | getInstance: () => global[SOCKET_CLUSTER_KEY],
25 | };
26 |
27 | module.exports = socketClusterSingleton;
28 |
--------------------------------------------------------------------------------
/example/serverWorker.js:
--------------------------------------------------------------------------------
1 | let counter = 0;
2 |
3 | /**
4 | * All examples every third time will be:
5 | * - returining valid result
6 | * - returning example error
7 | * - not replying at all causing timeouts
8 | */
9 | const rpcEndpoints = {
10 | multiplyByTwo: (num, cb) => {
11 | counter += 1;
12 | const randomError = counter % 2 === 0 ? null : 'random occurring error';
13 | if (counter % 3) {
14 | console.info('For every 3rd call the response is randomly not being returned');
15 | } else {
16 | cb(randomError, num * 2);
17 | }
18 | },
19 | };
20 |
21 | const eventEndpoints = {
22 | multiplyByThree: (num, cb) => {
23 | counter += 1;
24 | const randomError = counter % 2 === 0 ? null : 'random occurring error';
25 | if (counter % 3) {
26 | console.info('For every 3rd call the response is randomly not being returned');
27 | } else {
28 | cb(randomError, num * 3);
29 | }
30 | },
31 | };
32 |
33 | const SCWorker = require('socketcluster/scworker');
34 | const WAMPServer = require('../WAMPServer');
35 |
36 | class Worker extends SCWorker {
37 | run() {
38 | const scServer = this.scServer;
39 |
40 | const wampServer = new WAMPServer();
41 | wampServer.registerRPCEndpoints(rpcEndpoints);
42 | wampServer.registerEventEndpoints(eventEndpoints);
43 |
44 | scServer.on('connection', (socket) => {
45 | wampServer.upgradeToWAMP(socket);
46 | });
47 | }
48 | }
49 | module.exports = new Worker();
50 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | const SlaveWAMPServer = require('./SlaveWAMPServer');
2 | const MasterWAMPServer = require('./MasterWAMPServer');
3 | const WAMPServer = require('./WAMPServer');
4 | const WAMPClient = require('./WAMPClient');
5 |
6 | module.exports = {
7 | SlaveWAMPServer,
8 | MasterWAMPServer,
9 | WAMPClient,
10 | WAMPServer,
11 | };
12 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "wamp-socket-cluster",
3 | "version": "2.0.0-beta.4",
4 | "description": "",
5 | "main": "dist/index.js",
6 | "scripts": {
7 | "test": "mocha $(find . -name '*.spec.js' ! -ipath '*node_modules*')",
8 | "build": "npm run build:src && npm run build:bundle",
9 | "build:src": "webpack --optimize-minimize",
10 | "build:bundle": "BUNDLE=true webpack --optimize-minimize",
11 | "eslint": "eslint .",
12 | "eslint:fix": "npm run eslint -- --fix"
13 | },
14 | "author": "Lisk Foundation , lightcurve GmbH ",
15 | "license": "GPLv3",
16 | "dependencies": {
17 | "jsonschema": "=1.1.1"
18 | },
19 | "devDependencies": {
20 | "babel-core": "=6.24.0",
21 | "babel-loader": "=6.4.1",
22 | "babel-preset-env": "=1.2.2",
23 | "chai": "=4.1.1",
24 | "dirty-chai": "=2.0.1",
25 | "eslint": "=4.3.0",
26 | "eslint-config-airbnb-base": "=11.3.1",
27 | "eslint-config-lisk-base": "=0.1.0",
28 | "eslint-plugin-import": "=2.7.0",
29 | "mocha": "=3.2.0",
30 | "sinon": "=2.1.0",
31 | "socketcluster": "=9.1.10",
32 | "socketcluster-client": "=9.0.2",
33 | "webpack": "=2.3.2",
34 | "webpack-node-externals": "=1.5.4"
35 | },
36 | "pre-commit": "build"
37 | }
38 |
--------------------------------------------------------------------------------
/schemas.js:
--------------------------------------------------------------------------------
1 | const Validator = require('jsonschema').Validator;
2 |
3 | const v = new Validator();
4 |
5 | const RPCResponseSchema = {
6 | id: '/RPCResponse',
7 | type: 'object',
8 | properties: {
9 | type: { type: 'string' },
10 | data: {},
11 | },
12 | required: ['type', 'data'],
13 | };
14 |
15 | const RPCRequestSchema = {
16 | id: '/RPCRequest',
17 | type: 'object',
18 | properties: {
19 | type: { type: 'string' },
20 | procedure: { type: 'string' },
21 | data: {},
22 | },
23 | required: ['type', 'procedure'],
24 | };
25 |
26 | const EventRequestSchema = {
27 | id: '/EventRequestSchema',
28 | type: 'object',
29 | properties: {
30 | type: { type: 'string' },
31 | procedure: { type: 'string' },
32 | data: {},
33 | },
34 | required: ['type', 'procedure'],
35 | };
36 |
37 | const MasterRPCRequestSchema = {
38 | id: '/MasterRPCRequest',
39 | type: 'object',
40 | properties: {
41 | type: { type: 'string' },
42 | procedure: { type: 'string' },
43 | data: {},
44 | },
45 | required: ['type', 'procedure'],
46 | };
47 |
48 | const InterProcessRPCRequestSchema = {
49 | id: '/InterProcessRPCRequestSchema',
50 | type: 'object',
51 | properties: {
52 | type: { type: 'string' },
53 | procedure: { type: 'string' },
54 | data: {},
55 | },
56 | required: ['type', 'procedure'],
57 | };
58 |
59 | const MasterConfigRequestSchema = {
60 | id: '/MasterConfigRequestSchema',
61 | type: 'object',
62 | properties: {
63 | type: { type: 'string' },
64 | registeredEvents: { type: 'array' },
65 | config: { type: 'object' },
66 | },
67 | required: ['type', 'registeredEvents', 'config'],
68 | };
69 |
70 |
71 | const resToReqMap = {
72 | [RPCResponseSchema.id]: RPCRequestSchema.id,
73 | };
74 |
75 | const reqToResMap = {
76 | [RPCRequestSchema.id]: RPCResponseSchema.id,
77 | [MasterRPCRequestSchema.id]: RPCResponseSchema.id,
78 | };
79 |
80 | const isValid = (obj, schema) => v.validate(obj, schema).valid && obj.type === schema.id;
81 |
82 | module.exports = {
83 | EventRequestSchema,
84 | RPCRequestSchema,
85 | RPCResponseSchema,
86 | InterProcessRPCRequestSchema,
87 | MasterRPCRequestSchema,
88 | MasterConfigRequestSchema,
89 | resToReqMap,
90 | reqToResMap,
91 | isValid,
92 | };
93 |
--------------------------------------------------------------------------------
/testSetup.spec.js:
--------------------------------------------------------------------------------
1 | /* eslint-env node, mocha */
2 |
3 | const chai = require('chai');
4 | const dirtyChai = require('dirty-chai');
5 |
6 | chai.use(dirtyChai);
7 | module.exports = { expect: chai.expect };
8 |
--------------------------------------------------------------------------------
/utils.js:
--------------------------------------------------------------------------------
1 | const utils = {
2 | get: (obj, deepKeyString, defaultValue = undefined) => {
3 | if (typeof deepKeyString !== 'string') {
4 | return defaultValue;
5 | }
6 | const deepKeyArray = deepKeyString.split('.');
7 | let currentResult = obj;
8 |
9 | for (let i = 0; i < deepKeyArray.length; i += 1) {
10 | currentResult = currentResult[deepKeyArray[i]];
11 | if (currentResult === undefined) {
12 | return defaultValue;
13 | }
14 | }
15 | return currentResult;
16 | },
17 | };
18 |
19 | module.exports = utils;
20 |
--------------------------------------------------------------------------------
/utils.spec.js:
--------------------------------------------------------------------------------
1 | /* eslint-env node, mocha */
2 | const { expect } = require('./testSetup.spec');
3 |
4 | const utils = require('./utils');
5 |
6 | describe('utils', () => {
7 | describe('get', () => {
8 | let validPath;
9 | let validObject;
10 | let validDefaultValue;
11 |
12 | let getResult;
13 |
14 | before(() => {
15 | validPath = '';
16 | validObject = {};
17 | validDefaultValue = undefined;
18 | });
19 |
20 | beforeEach(() => {
21 | getResult = utils.get(validObject, validPath, validDefaultValue);
22 | });
23 |
24 | describe('when path is not a string', () => {
25 | describe('when path is an object', () => {
26 | before(() => {
27 | validPath = {};
28 | });
29 |
30 | it('should return undefined', () => {
31 | expect(getResult).to.be.undefined();
32 | });
33 | });
34 |
35 | describe('when path is an array', () => {
36 | before(() => {
37 | validPath = [];
38 | });
39 |
40 | it('should return undefined', () => {
41 | expect(getResult).to.be.undefined();
42 | });
43 | });
44 |
45 | describe('when path is a number', () => {
46 | before(() => {
47 | const validNumber = 1;
48 | validPath = validNumber;
49 | });
50 |
51 | it('should return undefined', () => {
52 | expect(getResult).to.be.undefined();
53 | });
54 | });
55 |
56 | describe('when path is null', () => {
57 | before(() => {
58 | validPath = null;
59 | });
60 |
61 | it('should return undefined', () => {
62 | expect(getResult).to.be.undefined();
63 | });
64 | });
65 |
66 | describe('when path is undefined', () => {
67 | before(() => {
68 | validPath = undefined;
69 | });
70 |
71 | it('should return undefined', () => {
72 | expect(getResult).to.be.undefined();
73 | });
74 | });
75 | });
76 |
77 | describe('when path is a string', () => {
78 | describe('and is empty', () => {
79 | before(() => {
80 | validPath = '';
81 | });
82 |
83 | it('should return undefined', () => {
84 | expect(getResult).to.be.undefined();
85 | });
86 | });
87 |
88 | describe('when accessing nested object', () => {
89 | before(() => {
90 | validObject = {
91 | a: {
92 | b: {
93 | c: {
94 | d: 'abcd',
95 | },
96 | },
97 | },
98 | };
99 | });
100 |
101 | describe('when accessing property does not exist', () => {
102 | before(() => {
103 | validPath = 'A.B.C.D';
104 | });
105 |
106 | it('should return undefined', () => {
107 | expect(getResult).to.be.undefined();
108 | });
109 |
110 | describe('when defaultValue = false', () => {
111 | before(() => {
112 | validDefaultValue = false;
113 | });
114 |
115 | it('should return undefined', () => {
116 | expect(getResult).to.be.false();
117 | });
118 | });
119 | });
120 |
121 | describe('when accessing property exists', () => {
122 | describe('and points to the middle-path value', () => {
123 | before(() => {
124 | validPath = 'a.b';
125 | });
126 |
127 | it('should return {c: {d: "abcd"}}}', () => {
128 | expect(getResult).to.eql({
129 | c: {
130 | d: 'abcd',
131 | },
132 | });
133 | });
134 | });
135 |
136 | describe('and points to the final value', () => {
137 | before(() => {
138 | validPath = 'a.b.c.d';
139 | });
140 |
141 | it('should return "abcd"', () => {
142 | expect(getResult).to.equal('abcd');
143 | });
144 | });
145 | });
146 | });
147 | });
148 | });
149 | });
150 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const webpackNodeExternals = require('webpack-node-externals');
3 |
4 | const config = {
5 | entry: {
6 | MasterWAMPServer: './MasterWAMPServer.js',
7 | SlaveWAMPServer: './SlaveWAMPServer.js',
8 | WAMPClient: './WAMPClient.js',
9 | WAMPServer: './WAMPServer.js',
10 | },
11 | module: {
12 | rules: [
13 | {
14 | test: /\.js$/,
15 | loader: 'babel-loader',
16 | },
17 | ],
18 | },
19 | output: {
20 | path: path.join(__dirname, './dist'),
21 | filename: '[name].bundle.js',
22 | library: 'wampSocketCluster',
23 | libraryTarget: 'umd',
24 | umdNamedDefine: true,
25 | },
26 | };
27 |
28 | if (process.env.BUNDLE) {
29 | config.output.filename = '[name].bundle.min.js';
30 | } else {
31 | config.externals = [webpackNodeExternals()];
32 | config.output.filename = '[name].src.min.js';
33 | }
34 |
35 | module.exports = config;
36 |
--------------------------------------------------------------------------------