1 Star 0 Fork 7

nirvanaReborn_web/zbus-js

forked from 开放金融技术/zbus-js 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
zbus.min.js 45.24 KB
一键复制 编辑 原始数据 按行查看 历史
rushmore 提交于 2018-12-09 16:45 . fix websocket sub window bug
!function i(a,s,u){function l(t,e){if(!s[t]){if(!a[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(c)return c(t,!0);var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}var o=s[t]={exports:{}};a[t][0].call(o.exports,function(e){return l(a[t][1][e]||e)},o,o.exports,i,a,s,u)}return s[t].exports}for(var c="function"==typeof require&&require,e=0;e<u.length;e++)l(u[e]);return l}({1:[function(e,t,n){"use strict";t.exports=e("./lib/index.js")},{"./lib/index.js":12}],2:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.RpcMethodTemplate=n.RpcStyleTemplate=n.RpcInfoTemplate=n.reply=n.joinPath=n.signMessage=n.signHttpRequest=n.calcSignature=n.uuid=void 0;var y=r(e("jssha")),b=r(e("json-stable-stringify"));function r(e){return e&&e.__esModule?e:{default:e}}String.prototype.format=function(){for(var e=arguments.length,n=Array(e),t=0;t<e;t++)n[t]=arguments[t];return n=n||[],this.replace(/{(\d+)}/g,function(e,t){return void 0!==n[t]?n[t]:e})};n.uuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})};var c=n.calcSignature=function(e,t,n,r){r||(r="url,method,body,h.*");var o={headers:{}};o.headers.apiKey=e,r&&(o.headers.signFields=r);var i=!0,a=!1,s=void 0;try{for(var u,l=r.split(",")[Symbol.iterator]();!(i=(u=l.next()).done);i=!0){var c=u.value;if(c.startsWith("h.")&&n.headers){var f=c.substr(2);if("*"==f)for(var h in n.headers)o.headers[h]=n.headers[h];else o.headers[f]=n.headers[f]}else c in n&&(o[c]=n[c])}}catch(e){a=!0,s=e}finally{try{!i&&l.return&&l.return()}finally{if(a)throw s}}var d=(0,b.default)(o),p=new y.default("SHA-256","TEXT");return p.setHMACKey(t,"TEXT"),p.update(d),p.getHMAC("HEX")},o=n.signHttpRequest=function(e,t,n,r,o,i,a){var s={url:t,headers:{},body:r};for(var u in e&&(s.method=e),n)s.headers[u]=n[u];var l=c(o,i,s,a);n.apiKey=o,a&&(n.signFields=a),n.signature=l};n.signMessage=function(e,t,n){o(n.method,n.url,n.headers,n.body,e,t,n.headers.signFields)},n.joinPath=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=(t=t||[]).join("/");return 1<(r=r.replace(/[//]+/g,"/")).length&&r.endsWith("/")&&(r=r.substr(0,r.length-1)),r},n.reply=function(e,t,n){e.status=t,e.headers["Content-Type"]="text/plain; charset=utf8",e.body=n},n.RpcInfoTemplate='\n<html><head>\n<meta http-equiv="Content-type" content="text/html; charset=utf-8">\n<title>{0} JS</title>\n{1}\n\n<script> \nvar rpc; \nfunction init(){\n\trpc = new RpcClient(null,"{0}"); \n} \n<\/script> \n<script async src="https://unpkg.com/zbus/zbus.min.js" onload="init()"><\/script>\n\n</head>\n\n<div> \n<table class="table">\n<thead>\n<tr class="table-info"> \n <th class="urlPath">URL Path</th>\n <th class="returnType">Return Type</th>\n <th class="methodParams">Method and Params</th> \n</tr>\n<thead>\n<tbody>\n{2}\n</tbody>\n</table> </div> </body></html>\n',n.RpcStyleTemplate="\n<style type=\"text/css\">\nbody {\n font-family: -apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;\n font-size: 1rem;\n font-weight: 400;\n line-height: 1.5;\n color: #292b2c;\n background-color: #fff;\n margin: 0px;\n padding: 0px;\n}\ntable { background-color: transparent; display: table; border-collapse: separate; border-color: grey; }\n.table { width: 100%; max-width: 100%; margin-bottom: 1rem; }\n.table th { height: 30px; }\n.table td, .table th { border-bottom: 1px solid #eceeef; text-align: left; padding-left: 16px;} \nth.urlPath { width: 10%; }\nth.returnType { width: 10%; }\nth.methodParams { width: 80%; } \ntd.returnType { text-align: right; }\nthead { display: table-header-group; vertical-align: middle; border-color: inherit;}\ntbody { display: table-row-group; vertical-align: middle; border-color: inherit;}\ntr { display: table-row; vertical-align: inherit; border-color: inherit; }\n.table-info, .table-info>td, .table-info>th { background-color: #dff0d8; }\n.url { margin: 4px 0; padding-left: 16px;}\n</style>\n",n.RpcMethodTemplate='\n<tr> \n <td class="urlPath"><a href="{0}">{0}</a></td>\n <td class="returnType"></td>\n <td class="methodParams">\n <code><strong><a href="{0}">{1}</a></strong>({2})</code>\n </td> \n</tr>\n'},{"json-stable-stringify":14,jssha:18}],3:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}();Date.prototype.format=function(e){var t={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()};for(var n in/(y+)/.test(e)&&(e=e.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length))),t)new RegExp("("+n+")").test(e)&&(e=e.replace(RegExp.$1,1==RegExp.$1.length?t[n]:("00"+t[n]).substr((""+t[n]).length)));return e};var o=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(this.level=e)||(this.level=t.DEBUG),this.DEBUG=0,this.INFO=1,this.WARN=2,this.ERROR=3}return r(t,[{key:"debug",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._log.apply(this,[this.DEBUG].concat(t))}},{key:"info",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._log.apply(this,[this.INFO].concat(t))}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._log.apply(this,[this.WARN].concat(t))}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._log.apply(this,[this.ERROR].concat(t))}},{key:"log",value:function(e){for(var t=arguments.length,n=Array(1<t?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this._log.apply(this,[e].concat(n))}},{key:"_log",value:function(e){for(var t,n=arguments.length,r=Array(1<n?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];if(!(e<this.level)){r=r||[];var i="UNKNOWN";e==this.DEBUG&&(i="DEBUG"),e==this.INFO&&(i="INFO"),e==this.WARN&&(i="WARN"),e==this.ERROR&&(i="ERROR"),r.splice(0,0,"["+i+"]"),(t=console).log.apply(t,[(new Date).format("yyyy/MM/dd hh:mm:ss.S")].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(this._format(r))))}}},{key:"_format",value:function(e){e=e||[];var t=this._getStackInfo(2);if(t){var n=t.relativePath+":"+t.line;"string"==typeof e[0]?e[0]=n+" "+e[0]:e.unshift(n)}return e}},{key:"_getStackInfo",value:function(e){var t=(new Error).stack.split("\n").slice(3),n=t[e]||t[0],r=/at\s+(.*)\s+\((.*):(\d*):(\d*)\)/gi.exec(n)||/at\s+()(.*):(\d*):(\d*)/gi.exec(n);if(r&&5===r.length)return{method:r[1],relativePath:r[2].replace(/^.*[\\\/]/,""),line:r[3],pos:r[4],file:r[2],stack:t.join("\n")}}}]),t}();n.Logger=o;n.logger=new o(o.INFO)},{}],4:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}();var o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.headers={}}return r(e,[{key:"replace",value:function(e){for(var t in this)delete this[t];for(var t in e)this[t]=e[t]}}]),e}();n.default=o},{}],5:[function(e,t,n){},{}],6:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)};r.MASK_DELETE_ON_EXIT=1,r.MASK_EXCLUSIVE=2,r.MEMORY="memory",r.DISK="disk",r.DB="db",n.default=r},{}],7:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),u=e("./Kit"),i=r(e("./WebsocketClient")),a=r(e("./RpcInvoker"));function r(e){return e&&e.__esModule?e:{default:e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var l=function(){function e(){s(this,e),this.authEnabled=!1,this.apiKey="",this.secretKey="",this.signFields="url,method,body,h.*"}return o(e,[{key:"invoke",value:function(e,t){t&&t(e),e.method||(e.method="POST"),e.headers["Content-Type"]||(e.headers["Content-Type"]="application/json"),this.authEnabled&&(e.headers.signFields=this.signFields,(0,u.signMessage)(this.apiKey,this.secretKey,e));var r,n,o=e.method,i=new XMLHttpRequest,a=new Promise(function(e,t){r=e,n=t});for(var s in i.onload=function(e){var t=i.responseText;if(r){var n=i.getResponseHeader("content-type");if(n||(n=i.getResponseHeader("Content-Type")),n&&n.startsWith("application/json"))try{t=JSON.parse(t)}catch(e){}r(t)}},i.onerror=function(e){n&&n(e)},i.open(o,e.url),e.headers)i.setRequestHeader(s,e.headers[s]);return i.send(JSON.stringify(e.body)),a}}]),e}(),c=function(){function r(e,t){s(this,r),e?(this.wsClient=new i.default(e),this.wsClient.heartbeatMessage={headers:{cmd:"ping"}}):this.ajaxClient=new l,this.urlPrefix=t,this.urlPrefix||(this.urlPrefix=""),this.authEnabled=!1,this.apiKey="",this.secretKey="",this.signFields="url,method,body,h.*",this.defaultInvoker=this.module("");var n=this;return this.proxy=new Proxy(this,{get:function(e,t){return t in e?e[t]:n.module(t)}}),this.proxy}return o(r,[{key:"enableAuth",value:function(e,t){var n=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];this.authEnabled=n,this.apiKey=e,this.secretKey=t}},{key:"module",value:function(e){if(this.authEnabled){var t=this.wsClient;this.ajaxClient&&(t=this.ajaxClient),t.authEnabled=this.authEnabled,t.apiKey=this.apiKey,t.secretKey=this.secretKey,t.signFields=this.signFields}var n=(0,u.joinPath)(this.urlPrefix,e);return new a.default(this,n)}},{key:"invoke",value:function(){for(var e,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return n=n||[],(e=this.defaultInvoker).invoke.apply(e,function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(n))}},{key:"_invoke",value:function(e){return this.wsClient?this._wsInvoke(e):this.ajaxClient.invoke(e)}},{key:"_wsInvoke",value:function(e){var t=this;return(this.wsClient.active()?this.wsClient.invoke(e):this.wsClient.connect().then(function(){return t.wsClient.invoke(e)})).then(function(e){if(200!=e.status)throw e.body;return e.body})}},{key:"close",value:function(){this.wsClient&&(this.wsClient.close(),this.wsClient=null)}}]),r}();n.default=c},{"./Kit":2,"./RpcInvoker":8,"./WebsocketClient":11}],8:[function(e,t,n){"use strict";var r="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};Object.defineProperty(n,"__esModule",{value:!0});var o,i=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),l=e("./Kit"),a=e("./Message"),c=(o=a)&&o.__esModule?o:{default:o};function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":r(t))&&"function"!=typeof t?e:t}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var f=function(){function n(e,t){u(this,n),this.client=e,this.urlPrefix=t}return i(n,[{key:"invoke",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];if((t=t||[]).length<1)throw"Missing request parameter";var r,o=t[0];if("string"==typeof o){for(var i=[],a=t.length,s=1;s<a;s++)i.push(t[s]);(r=new c.default).url=(0,l.joinPath)(this.urlPrefix,o),r.body=i}else o.constructor==c.default?r=o:(r=new c.default).replace(o);return this.client._invoke(r)}},{key:"proxyMethod",value:function(s){var u=this;return function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var r=(t=t||[]).length,o=[],i=0;i<r;i++)o.push(t[i]);var a=new c.default;return a.url=(0,l.joinPath)(u.urlPrefix,s),a.body=o,u.invoke(a)}}}]),n}(),h=function(e){function o(e,t){u(this,o);var n=s(this,(o.__proto__||Object.getPrototypeOf(o)).call(this));n.invoker=new f(e,t);var r=n.invoker;return n.proxy=new Proxy(r,{get:function(e,t){return t in e?e[t]:r.proxyMethod(t)},apply:function(e,t,n){return r.proxyMethod("").apply(void 0,function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(n))}}),s(n,n.proxy)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":r(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(o,Function),o}();n.default=h},{"./Kit":2,"./Message":4}],9:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r,o=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),a=e("./Logger"),h=e("./Kit"),i=e("./Message"),c=(r=i)&&r.__esModule?r:{default:r};function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var u=function(){function t(e){s(this,t),this.processor=e}return o(t,[{key:"index",value:function(){var e=this.processor,t=new c.default;t.status=200,t.headers["content-type"]="text/html; charset=utf8";var n="";for(var r in e.urlPath2Methods){var o=e.urlPath2Methods[r];if(o.docEnabled){var i=o.paramsString,a=(0,h.joinPath)(e.rootUrl,o.urlPath);n+=h.RpcMethodTemplate.format(a,o.method,i)}}return t.body=h.RpcInfoTemplate.format(e.rootUrl,h.RpcStyleTemplate,n),t}}]),t}(),l=function(){function e(){s(this,e),this.urlPath2Methods={},this.rootUrl="/",this.docUrl="/doc",this.docEnabled=!0}return o(e,[{key:"_matchMethod",value:function(e,t){e||(e="");var n=this.module2methods[e];return null==n?null:n[t]}},{key:"_parseParams",value:function(e){var t=e.split("?"),n=t[0].split("/").filter(function(e){return 0<e.length}),r={},o=t.slice(1).join("?").split("&").filter(function(e){return 0<e.length});0<o.length&&n.push(r);var i=!0,a=!1,s=void 0;try{for(var u,l=o[Symbol.iterator]();!(i=(u=l.next()).done);i=!0){var c=u.value.split("=");1<c.length&&(r[c[0]]=c[1])}}catch(e){a=!0,s=e}finally{try{!i&&l.return&&l.return()}finally{if(a)throw s}}return n}},{key:"process",value:function(e,t){var n=e.url;if(n){var r=null,o=null,i=0;for(var a in this.urlPath2Methods)n.startsWith(a)&&a.length>i&&(i=a.length,o=a,r=this.urlPath2Methods[a]);if(null!=r){var s=[];if(e.body)e.body instanceof Array||(e.body=JSON.parse(e.body)),s=e.body;else{var u=n.substr(o.length);s=this._parseParams(u)}var l=r.instance.apply(r.target,s);l instanceof c.default?t.replace(l):(t.status=200,t.headers["content-type"]="application/json; charset=utf8;",t.body=l)}else(0,h.reply)(t,404,"Url="+n+" Not Found")}else(0,h.reply)(t,400,"Missing url in request")}},{key:"_addMethod",value:function(e,t,n,r){e=(0,h.joinPath)(e);var o=t.name;void 0===r&&(r=!0);var i={urlPath:e,method:o,paramsString:"",instance:t,target:n,docEnabled:r};return e in this.urlPath2Methods&&a.logger.warn("Url="+e+", Method="+o+" exists"),this.urlPath2Methods[e]=i}},{key:"mount",value:function(e,t,n,r){if("function"!=typeof t){var o=this._getAllMethods(t),i=!0,a=!1,s=void 0;try{for(var u,l=o[Symbol.iterator]();!(i=(u=l.next()).done);i=!0){var c=t[u.value],f=(0,h.joinPath)(e,c.name);this._addMethod(f,c,t,r).paramsString=this._getFnParamNames(c.toString())}}catch(e){a=!0,s=e}finally{try{!i&&l.return&&l.return()}finally{if(a)throw s}}}else this._addMethod(e,t,n,r)}},{key:"mountDoc",value:function(){if(this.docEnabled){var e=new u(this);this.mount(this.docUrl,e.index,e,!1)}}},{key:"_getFnParamNames",value:function(e){return e.toString().match(/\(.*?\)/)[0].replace(/[()]/gi,"").replace(/\s/gi,"").split(",")}},{key:"_getAllMethods",value:function(e){var t=new Set;for(var n in e){"function"==typeof e[n]&&t.add(n)}for(;(e=Reflect.getPrototypeOf(e))&&e.constructor!=Object;){Reflect.ownKeys(e).forEach(function(e){if("constructor"==e)return!1;t.add(e)})}return t}}]),e}();n.default=l},{"./Kit":2,"./Logger":3,"./Message":4}],10:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),u=e("./Logger"),l=e("./Kit"),o=i(e("./MqClient")),c=i(e("./Message"));function i(e){return e&&e.__esModule?e:{default:e}}var a=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.mqServerAddress=null,this.mq=null,this.mqType="memory",this.mqMask=null,this.channel=null,this.clientCount=1,this.authEnabled=!1,this.apiKey="",this.secretKey="",this.clients=[],this.processor=e}return r(t,[{key:"enableAuth",value:function(e,t){var n=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];this.authEnabled=n,this.apiKey=e,this.secretKey=t}},{key:"start",value:function(){var t=this;if(null==this.mqServerAddress)throw new Error("missing mqServerAddress");if(null==this.mq)throw new Error("missing mq");null==this.channel&&(this.channel=this.mq),this.processor.mountDoc(),this.processor.rootUrl=(0,l.joinPath)("/",this.mq);for(var a=this.processor,e=0;e<this.clientCount;e++){var s=new o.default(this.mqServerAddress);this.authEnabled&&(s.authEnabled=this.authEnabled,s.apiKey=this.apiKey,s.secretKey=this.secretKey),s.onopen=function(){var e={};e.headers={cmd:"create",mq:t.mq,mqType:t.mqType,mqMask:t.mqMask,channel:t.channel},s.invoke(e).then(function(e){u.logger.info(e)}),(e={}).headers={cmd:"sub",mq:t.mq,channel:t.channel},s.invoke(e).then(function(e){u.logger.info(e)})},s.addMqHandler(this.mq,this.channel,function(e){var t=e.headers.id,n=e.headers.source,r=e.url,o=a.rootUrl;r&&r.startsWith(o)&&(r=r.substr(o.length),r=(0,l.joinPath)("/",r),e.url=r);var i=new c.default;try{a.process(e,i)}catch(e){u.logger.error(e),i.headers["content-type"]="text/plain; charset=utf8;",(0,l.reply)(i,500,e)}i.headers.cmd="route",i.headers.target=n,i.headers.id=t,null==i.status&&(i.status=200),s.send(i)}),s.connect(),this.clients.push(s)}}},{key:"close",value:function(){var e=!0,t=!1,n=void 0;try{for(var r,o=this.clients[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){r.value.close()}}catch(e){t=!0,n=e}finally{try{!e&&o.return&&o.return()}finally{if(t)throw n}}this.clients=[]}}]),t}();n.default=a},{"./Kit":2,"./Logger":3,"./Message":4,"./MqClient":5}],11:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.Ticket=void 0;var r,o=function(){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}}(),i=e("isomorphic-ws"),a=(r=i)&&r.__esModule?r:{default:r},s=e("./Logger"),u=e("./Kit");function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var c=n.Ticket=function e(t,n){l(this,e),this.id=(0,u.uuid)(),t.headers||(t.headers={}),t.headers.id=this.id,this.request=t,this.response=null,this.resolve=n},f=function(){function t(e){l(this,t),e.startsWith("ws://")||e.startsWith("wss://")||(e="ws://"+e),this.address=e,this.socket=null,this.heartbeatInterval=3e4,this.ticketTable={},this.connectPromise=null,this.autoReconnect=!0,this.reconnectInterval=3e3,this.authEnabled=!1,this.apiKey="",this.secretKey="",this.signFields="url,method,body,h.*",this.onopen=null,this.onclose=null,this.onerror=null,this.onmessage=null,this.beforeSend=null,this.heartbeator=null,this.heartbeatMessage=null,this.heartbeatInterval=3e4}return o(t,[{key:"enableAuth",value:function(e,t){var n=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];this.authEnabled=n,this.apiKey=e,this.secretKey=t}},{key:"connect",value:function(){if(null!=this.socket&&null!=this.connectPromise)return this.connectPromise;var n,r;s.logger.debug("Trying to connect to "+this.address),this.connectPromise=new Promise(function(e,t){n=e,r=t});try{this.socket=new a.default(this.address)}catch(e){return r(e),this.connectPromise}var o=this;return this.socket.onopen=function(e){s.logger.debug("Connected to "+o.address),n&&n(),o.onopen&&o.onopen(o),null!=o.heartbeatMessage&&(o.heartbeator=setInterval(function(){try{o.send(o.heartbeatMessage)}catch(e){s.logger.warn(e)}},o.heartbeatInterval))},this.socket.onclose=function(e){o.connectPromise=null,clearInterval(o.heartbeat),o.onclose&&o.onclose(),o.autoReconnect&&(o.connectTrying=setTimeout(function(){try{o.connect()}catch(e){}},o.reconnectInterval))},this.socket.onmessage=function(e){var t=JSON.parse(e.data),n=null;t.headers&&(n=t.headers.id);var r=o.ticketTable[n];r?(r.response=t,r.resolve&&(r.resolve(t),delete o.ticketTable[n])):o.onmessage&&o.onmessage(t)},this.socket.onerror=function(e){s.logger.error("Error: "+e)},this.connectPromise}},{key:"close",value:function(){this.connectPromise=null,clearInterval(this.heartbeat),this.connectTrying&&clearTimeout(this.connectTrying),this.socket.onclose=function(){},this.autoReconnect=!1,this.socket.close(),this.socket=null}},{key:"active",value:function(){return this.socket&&this.socket.readyState==a.default.OPEN}},{key:"send",value:function(e,t){t||(t=this.beforeSend),null!=t&&t(e),this.authEnabled&&(e.headers.signFields=this.signFields,(0,u.signMessage)(this.apiKey,this.secretKey,e));var n=JSON.stringify(e);this.socket.send(n)}},{key:"invoke",value:function(e,t){var n=this,r=this,o=new c(e);this.ticketTable[o.id]=o;var i=new Promise(function(e,t){r.active()?(o.resolve=e,o.response&&(o.resolve(o.reponse),delete n.ticketTable[o.id])):t(new Error("socket is not open, invalid"))});return this.send(e,t),i}}]),t}();n.default=f},{"./Kit":2,"./Logger":3,"isomorphic-ws":13}],12:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.calcSignature=n.signHttpRequest=n.signMessage=n.Message=n.RpcServer=n.RpcClient=n.RpcProcessor=n.MqClient=n.WebsocketClient=n.Logger=n.Protocol=void 0;var r=h(e("./Protocol")),o=e("./Logger"),i=h(e("./WebsocketClient")),a=h(e("./MqClient")),s=h(e("./RpcProcessor")),u=h(e("./RpcClient")),l=h(e("./RpcServer")),c=h(e("./Message")),f=e("./Kit");function h(e){return e&&e.__esModule?e:{default:e}}n.Protocol=r.default,n.Logger=o.Logger,n.WebsocketClient=i.default,n.MqClient=a.default,n.RpcProcessor=s.default,n.RpcClient=u.default,n.RpcServer=l.default,n.Message=c.default,n.signMessage=f.signMessage,n.signHttpRequest=f.signHttpRequest,n.calcSignature=f.calcSignature,"undefined"!=typeof window&&(window.Protocol=r.default,window.Logger=o.Logger,window.WebsocketClient=i.default,window.MqClient=a.default,window.RpcProcessor=s.default,window.RpcClient=u.default,window.RpcServer=l.default,window.Message=c.default,window.signMessage=f.signMessage,window.signHttpRequest=f.signHttpRequest,window.calcSignature=f.calcSignature)},{"./Kit":2,"./Logger":3,"./Message":4,"./MqClient":5,"./Protocol":6,"./RpcClient":7,"./RpcProcessor":9,"./RpcServer":10,"./WebsocketClient":11}],13:[function(e,n,t){(function(e){var t=null;"undefined"!=typeof WebSocket?t=WebSocket:"undefined"!=typeof MozWebSocket?t=MozWebSocket:void 0!==e?t=e.WebSocket||e.MozWebSocket:"undefined"!=typeof window?t=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(t=self.WebSocket||self.MozWebSocket),n.exports=t}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],14:[function(e,t,n){var g="undefined"!=typeof JSON?JSON:e("jsonify");t.exports=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var d=t.space||"";"number"==typeof d&&(d=Array(d+1).join(" "));var i,p="boolean"==typeof t.cycles&&t.cycles,y=t.replacer||function(e,t){return t},b=t.cmp&&(i=t.cmp,function(o){return function(e,t){var n={key:e,value:o[e]},r={key:t,value:o[t]};return i(n,r)}}),v=[];return function e(t,n,r,o){var i=d?"\n"+new Array(o+1).join(d):"",a=d?": ":":";if(r&&r.toJSON&&"function"==typeof r.toJSON&&(r=r.toJSON()),void 0!==(r=y.call(t,n,r))){if("object"!=typeof r||null===r)return g.stringify(r);if(w(r)){for(var s=[],u=0;u<r.length;u++){var l=e(r,u,r[u],o+1)||g.stringify(null);s.push(i+d+l)}return"["+s.join(",")+i+"]"}if(-1!==v.indexOf(r)){if(p)return g.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}v.push(r);var c=m(r).sort(b&&b(r));for(s=[],u=0;u<c.length;u++){var f=e(r,n=c[u],r[n],o+1);if(f){var h=g.stringify(n)+a+f;s.push(i+d+h)}}return v.splice(v.indexOf(r),1),"{"+s.join(",")+i+"}"}}({"":e},"",e,0)};var w=Array.isArray||function(e){return"[object Array]"==={}.toString.call(e)},m=Object.keys||function(e){var t=Object.prototype.hasOwnProperty||function(){return!0},n=[];for(var r in e)t.call(e,r)&&n.push(r);return n}},{jsonify:15}],15:[function(e,t,n){n.parse=e("./lib/parse"),n.stringify=e("./lib/stringify")},{"./lib/parse":16,"./lib/stringify":17}],16:[function(e,t,n){var r,o,i,s,a={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},u=function(e){throw{name:"SyntaxError",message:e,at:r,text:i}},l=function(e){return e&&e!==o&&u("Expected '"+e+"' instead of '"+o+"'"),o=i.charAt(r),r+=1,o},c=function(){var e,t="";for("-"===o&&l(t="-");"0"<=o&&o<="9";)t+=o,l();if("."===o)for(t+=".";l()&&"0"<=o&&o<="9";)t+=o;if("e"===o||"E"===o)for(t+=o,l(),"-"!==o&&"+"!==o||(t+=o,l());"0"<=o&&o<="9";)t+=o,l();if(e=+t,isFinite(e))return e;u("Bad number")},f=function(){var e,t,n,r="";if('"'===o)for(;l();){if('"'===o)return l(),r;if("\\"===o)if(l(),"u"===o){for(t=n=0;t<4&&(e=parseInt(l(),16),isFinite(e));t+=1)n=16*n+e;r+=String.fromCharCode(n)}else{if("string"!=typeof a[o])break;r+=a[o]}else r+=o}u("Bad string")},h=function(){for(;o&&o<=" ";)l()};s=function(){switch(h(),o){case"{":return function(){var e,t={};if("{"===o){if(l("{"),h(),"}"===o)return l("}"),t;for(;o;){if(e=f(),h(),l(":"),Object.hasOwnProperty.call(t,e)&&u('Duplicate key "'+e+'"'),t[e]=s(),h(),"}"===o)return l("}"),t;l(","),h()}}u("Bad object")}();case"[":return function(){var e=[];if("["===o){if(l("["),h(),"]"===o)return l("]"),e;for(;o;){if(e.push(s()),h(),"]"===o)return l("]"),e;l(","),h()}}u("Bad array")}();case'"':return f();case"-":return c();default:return"0"<=o&&o<="9"?c():function(){switch(o){case"t":return l("t"),l("r"),l("u"),l("e"),!0;case"f":return l("f"),l("a"),l("l"),l("s"),l("e"),!1;case"n":return l("n"),l("u"),l("l"),l("l"),null}u("Unexpected '"+o+"'")}()}},t.exports=function(e,a){var t;return i=e,r=0,o=" ",t=s(),h(),o&&u("Syntax error"),"function"==typeof a?function e(t,n){var r,o,i=t[n];if(i&&"object"==typeof i)for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(void 0!==(o=e(i,r))?i[r]=o:delete i[r]);return a.call(t,n,i)}({"":t},""):t}},{}],17:[function(e,t,n){var c,f,h,r=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,o={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function d(e){return r.lastIndex=0,r.test(e)?'"'+e.replace(r,function(e){var t=o[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}t.exports=function(e,t,n){var r;if(f=c="","number"==typeof n)for(r=0;r<n;r+=1)f+=" ";else"string"==typeof n&&(f=n);if((h=t)&&"function"!=typeof t&&("object"!=typeof t||"number"!=typeof t.length))throw new Error("JSON.stringify");return function e(t,n){var r,o,i,a,s,u=c,l=n[t];switch(l&&"object"==typeof l&&"function"==typeof l.toJSON&&(l=l.toJSON(t)),"function"==typeof h&&(l=h.call(n,t,l)),typeof l){case"string":return d(l);case"number":return isFinite(l)?String(l):"null";case"boolean":case"null":return String(l);case"object":if(!l)return"null";if(c+=f,s=[],"[object Array]"===Object.prototype.toString.apply(l)){for(a=l.length,r=0;r<a;r+=1)s[r]=e(r,l)||"null";return i=0===s.length?"[]":c?"[\n"+c+s.join(",\n"+c)+"\n"+u+"]":"["+s.join(",")+"]",c=u,i}if(h&&"object"==typeof h)for(a=h.length,r=0;r<a;r+=1)"string"==typeof(o=h[r])&&(i=e(o,l))&&s.push(d(o)+(c?": ":":")+i);else for(o in l)Object.prototype.hasOwnProperty.call(l,o)&&(i=e(o,l))&&s.push(d(o)+(c?": ":":")+i);return i=0===s.length?"{}":c?"{\n"+c+s.join(",\n"+c)+"\n"+u+"}":"{"+s.join(",")+"}",c=u,i}}("",{"":e})}},{}],18:[function(e,i,a){"use strict";!function(e){function t(a,e,t){var o,s,u,l,f,c,h,d,p,y=0,b=[],v=0,g=!1,i=[],w=[],m=!1,k=!1,S=-1;if(o=(t=t||{}).encoding||"UTF8",(p=t.numRounds||1)!==parseInt(p,10)||p<1)throw Error("numRounds must a integer >= 1");if("SHA-1"===a)f=512,c=$,h=V,l=160,d=function(e){return e.slice()};else if(0===a.lastIndexOf("SHA-",0))if(c=function(e,t){return Z(e,t,a)},h=function(e,t,n,r){var o,i;if("SHA-224"===a||"SHA-256"===a)o=15+(t+65>>>9<<4),i=16;else{if("SHA-384"!==a&&"SHA-512"!==a)throw Error("Unexpected error in SHA-2 implementation");o=31+(t+129>>>10<<5),i=32}for(;e.length<=o;)e.push(0);for(e[t>>>5]|=128<<24-t%32,t+=n,e[o]=4294967295&t,e[o-1]=t/4294967296|0,n=e.length,t=0;t<n;t+=i)r=Z(e.slice(t,t+i),r,a);if("SHA-224"===a)e=[r[0],r[1],r[2],r[3],r[4],r[5],r[6]];else if("SHA-256"===a)e=r;else if("SHA-384"===a)e=[r[0].a,r[0].b,r[1].a,r[1].b,r[2].a,r[2].b,r[3].a,r[3].b,r[4].a,r[4].b,r[5].a,r[5].b];else{if("SHA-512"!==a)throw Error("Unexpected error in SHA-2 implementation");e=[r[0].a,r[0].b,r[1].a,r[1].b,r[2].a,r[2].b,r[3].a,r[3].b,r[4].a,r[4].b,r[5].a,r[5].b,r[6].a,r[6].b,r[7].a,r[7].b]}return e},d=function(e){return e.slice()},"SHA-224"===a)f=512,l=224;else if("SHA-256"===a)f=512,l=256;else if("SHA-384"===a)f=1024,l=384;else{if("SHA-512"!==a)throw Error("Chosen SHA variant is not supported");f=1024,l=512}else{if(0!==a.lastIndexOf("SHA3-",0)&&0!==a.lastIndexOf("SHAKE",0))throw Error("Chosen SHA variant is not supported");var A=6;if(c=Q,d=function(e){var t,n=[];for(t=0;t<5;t+=1)n[t]=e[t].slice();return n},S=1,"SHA3-224"===a)f=1152,l=224;else if("SHA3-256"===a)f=1088,l=256;else if("SHA3-384"===a)f=832,l=384;else if("SHA3-512"===a)f=576,l=512;else if("SHAKE128"===a)f=1344,l=-1,A=31,k=!0;else{if("SHAKE256"!==a)throw Error("Chosen SHA variant is not supported");f=1088,l=-1,A=31,k=!0}h=function(e,t,n,r,o){var i,a=A,s=[],u=(n=f)>>>5,l=0,c=t>>>5;for(i=0;i<c&&n<=t;i+=u)r=Q(e.slice(i,i+u),r),t-=n;for(e=e.slice(i),t%=n;e.length<u;)e.push(0);for(e[(i=t>>>3)>>2]^=a<<i%4*8,e[u-1]^=2147483648,r=Q(e,r);32*s.length<o&&(e=r[l%5][l/5|0],s.push(e.b),!(32*s.length>=o));)s.push(e.a),0==64*(l+=1)%n&&Q(null,r);return s}}u=C(e,o,S),s=G(a),this.setHMACKey=function(e,t,n){var r;if(!0===g)throw Error("HMAC key already set");if(!0===m)throw Error("Cannot set HMAC key after calling update");if(!0===k)throw Error("SHAKE is not supported for HMAC");if(e=(t=C(t,o=(n||{}).encoding||"UTF8",S)(e)).binLen,t=t.value,n=(r=f>>>3)/4-1,r<e/8){for(t=h(t,e,0,G(a),l);t.length<=n;)t.push(0);t[n]&=4294967040}else if(e/8<r){for(;t.length<=n;)t.push(0);t[n]&=4294967040}for(e=0;e<=n;e+=1)i[e]=909522486^t[e],w[e]=1549556828^t[e];s=c(i,s),y=f,g=!0},this.update=function(e){var t,n,r,o=0,i=f>>>5;for(e=(t=u(e,b,v)).binLen,n=t.value,t=e>>>5,r=0;r<t;r+=i)o+f<=e&&(s=c(n.slice(r,r+i),s),o+=f);y+=o,b=n.slice(o>>>5),v=e%f,m=!0},this.getHash=function(e,t){var n,r,o,i;if(!0===g)throw Error("Cannot call getHash after setting HMAC key");if(o=H(t),!0===k){if(-1===o.shakeLen)throw Error("shakeLen must be specified in options");l=o.shakeLen}switch(e){case"HEX":n=function(e){return E(e,l,S,o)};break;case"B64":n=function(e){return x(e,l,S,o)};break;case"BYTES":n=function(e){return M(e,l,S)};break;case"ARRAYBUFFER":try{r=new ArrayBuffer(0)}catch(e){throw Error("ARRAYBUFFER not supported by this environment")}n=function(e){return R(e,l,S)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(i=h(b.slice(),v,y,d(s),l),r=1;r<p;r+=1)!0===k&&0!=l%32&&(i[i.length-1]&=16777215>>>24-l%32),i=h(i,l,0,G(a),l);return n(i)},this.getHMAC=function(e,t){var n,r,o,i;if(!1===g)throw Error("Cannot call getHMAC without first setting HMAC key");switch(o=H(t),e){case"HEX":n=function(e){return E(e,l,S,o)};break;case"B64":n=function(e){return x(e,l,S,o)};break;case"BYTES":n=function(e){return M(e,l,S)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(e){throw Error("ARRAYBUFFER not supported by this environment")}n=function(e){return R(e,l,S)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER")}return r=h(b.slice(),v,y,d(s),l),i=c(w,G(a)),n(i=h(r,l,f,i,l))}}function P(e,t){this.a=e,this.b=t}function E(e,t,n,r){var o,i,a,s="";for(t/=8,a=-1===n?3:0,o=0;o<t;o+=1)i=e[o>>>2]>>>8*(a+o%4*n),s+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return r.outputUpper?s.toUpperCase():s}function x(e,t,n,r){var o,i,a,s,u="",l=t/8;for(s=-1===n?3:0,o=0;o<l;o+=3)for(i=o+1<l?e[o+1>>>2]:0,a=o+2<l?e[o+2>>>2]:0,a=(e[o>>>2]>>>8*(s+o%4*n)&255)<<16|(i>>>8*(s+(o+1)%4*n)&255)<<8|a>>>8*(s+(o+2)%4*n)&255,i=0;i<4;i+=1)u+=8*o+6*i<=t?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>6*(3-i)&63):r.b64Pad;return u}function M(e,t,n){var r,o,i,a="";for(t/=8,i=-1===n?3:0,r=0;r<t;r+=1)o=e[r>>>2]>>>8*(i+r%4*n)&255,a+=String.fromCharCode(o);return a}function R(e,t,n){t/=8;var r,o,i,a=new ArrayBuffer(t);for(i=new Uint8Array(a),o=-1===n?3:0,r=0;r<t;r+=1)i[r]=e[r>>>2]>>>8*(o+r%4*n)&255;return a}function H(e){var t={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(e=e||{},t.outputUpper=e.outputUpper||!1,!0===e.hasOwnProperty("b64Pad")&&(t.b64Pad=e.b64Pad),!0===e.hasOwnProperty("shakeLen")){if(0!=e.shakeLen%8)throw Error("shakeLen must be a multiple of 8");t.shakeLen=e.shakeLen}if("boolean"!=typeof t.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw Error("Invalid b64Pad formatting option");return t}function C(e,h,d){switch(h){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":e=function(e,t,n){var r,o,i,a,s,u,l=e.length;if(0!=l%2)throw Error("String of HEX type must be in byte increments");for(t=t||[0],s=(n=n||0)>>>3,u=-1===d?3:0,r=0;r<l;r+=2){if(o=parseInt(e.substr(r,2),16),isNaN(o))throw Error("String of HEX type contains invalid characters");for(i=(a=(r>>>1)+s)>>>2;t.length<=i;)t.push(0);t[i]|=o<<8*(u+a%4*d)}return{value:t,binLen:4*l+n}};break;case"TEXT":e=function(e,t,n){var r,o,i,a,s,u,l,c,f=0;if(t=t||[0],s=(n=n||0)>>>3,"UTF8"===h)for(c=-1===d?3:0,i=0;i<e.length;i+=1)for(o=[],(r=e.charCodeAt(i))<128?o.push(r):r<2048?(o.push(192|r>>>6),o.push(128|63&r)):r<55296||57344<=r?o.push(224|r>>>12,128|r>>>6&63,128|63&r):(i+=1,r=65536+((1023&r)<<10|1023&e.charCodeAt(i)),o.push(240|r>>>18,128|r>>>12&63,128|r>>>6&63,128|63&r)),a=0;a<o.length;a+=1){for(u=(l=f+s)>>>2;t.length<=u;)t.push(0);t[u]|=o[a]<<8*(c+l%4*d),f+=1}else if("UTF16BE"===h||"UTF16LE"===h)for(c=-1===d?2:0,o="UTF16LE"===h&&1!==d||"UTF16LE"!==h&&1===d,i=0;i<e.length;i+=1){for(r=e.charCodeAt(i),!0===o&&(r=(a=255&r)<<8|r>>>8),u=(l=f+s)>>>2;t.length<=u;)t.push(0);t[u]|=r<<8*(c+l%4*d),f+=2}return{value:t,binLen:8*f+n}};break;case"B64":e=function(e,t,n){var r,o,i,a,s,u,l,c,f=0;if(-1===e.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(o=e.indexOf("="),e=e.replace(/\=/g,""),-1!==o&&o<e.length)throw Error("Invalid '=' found in base-64 string");for(t=t||[0],u=(n=n||0)>>>3,c=-1===d?3:0,o=0;o<e.length;o+=4){for(s=e.substr(o,4),i=a=0;i<s.length;i+=1)a|=(r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(s[i]))<<18-6*i;for(i=0;i<s.length-1;i+=1){for(r=(l=f+u)>>>2;t.length<=r;)t.push(0);t[r]|=(a>>>16-8*i&255)<<8*(c+l%4*d),f+=1}}return{value:t,binLen:8*f+n}};break;case"BYTES":e=function(e,t,n){var r,o,i,a,s,u;for(t=t||[0],i=(n=n||0)>>>3,u=-1===d?3:0,o=0;o<e.length;o+=1)r=e.charCodeAt(o),a=(s=o+i)>>>2,t.length<=a&&t.push(0),t[a]|=r<<8*(u+s%4*d);return{value:t,binLen:8*e.length+n}};break;case"ARRAYBUFFER":try{e=new ArrayBuffer(0)}catch(e){throw Error("ARRAYBUFFER not supported by this environment")}e=function(e,t,n){var r,o,i,a,s,u;for(t=t||[0],o=(n=n||0)>>>3,s=-1===d?3:0,u=new Uint8Array(e),r=0;r<e.byteLength;r+=1)i=(a=r+o)>>>2,t.length<=i&&t.push(0),t[i]|=u[r]<<8*(s+a%4*d);return{value:t,binLen:8*e.byteLength+n}};break;default:throw Error("format must be HEX, TEXT, B64, BYTES, or ARRAYBUFFER")}return e}function c(e,t){return e<<t|e>>>32-t}function h(e,t){return 32<t?(t-=32,new P(e.b<<t|e.a>>>32-t,e.a<<t|e.b>>>32-t)):0!==t?new P(e.a<<t|e.b>>>32-t,e.b<<t|e.a>>>32-t):e}function n(e,t){return e>>>t|e<<32-t}function r(e,t){var n=null;n=new P(e.a,e.b);return t<=32?new P(n.a>>>t|n.b<<32-t&4294967295,n.b>>>t|n.a<<32-t&4294967295):new P(n.b>>>t-32|n.a<<64-t&4294967295,n.a>>>t-32|n.b<<64-t&4294967295)}function o(e,t){return t<=32?new P(e.a>>>t,e.b>>>t|e.a<<32-t&4294967295):new P(0,e.a>>>t-32)}function O(e,t,n){return e&t^~e&n}function j(e,t,n){return new P(e.a&t.a^~e.a&n.a,e.b&t.b^~e.b&n.b)}function T(e,t,n){return e&t^e&n^t&n}function _(e,t,n){return new P(e.a&t.a^e.a&n.a^t.a&n.a,e.b&t.b^e.b&n.b^t.b&n.b)}function F(e){return n(e,2)^n(e,13)^n(e,22)}function U(e){var t=r(e,28),n=r(e,34);return e=r(e,39),new P(t.a^n.a^e.a,t.b^n.b^e.b)}function K(e){return n(e,6)^n(e,11)^n(e,25)}function q(e){var t=r(e,14),n=r(e,18);return e=r(e,41),new P(t.a^n.a^e.a,t.b^n.b^e.b)}function I(e){return n(e,7)^n(e,18)^e>>>3}function L(e){var t=r(e,1),n=r(e,8);return e=o(e,7),new P(t.a^n.a^e.a,t.b^n.b^e.b)}function B(e){return n(e,17)^n(e,19)^e>>>10}function N(e){var t=r(e,19),n=r(e,61);return e=o(e,6),new P(t.a^n.a^e.a,t.b^n.b^e.b)}function W(e,t){var n=(65535&e)+(65535&t);return((e>>>16)+(t>>>16)+(n>>>16)&65535)<<16|65535&n}function Y(e,t,n,r){var o=(65535&e)+(65535&t)+(65535&n)+(65535&r);return((e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(o>>>16)&65535)<<16|65535&o}function D(e,t,n,r,o){var i=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&o);return((e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(o>>>16)+(i>>>16)&65535)<<16|65535&i}function X(e,t){var n,r,o;return n=(65535&e.b)+(65535&t.b),o=(65535&(r=(e.b>>>16)+(t.b>>>16)+(n>>>16)))<<16|65535&n,n=(65535&e.a)+(65535&t.a)+(r>>>16),new P((65535&(r=(e.a>>>16)+(t.a>>>16)+(n>>>16)))<<16|65535&n,o)}function J(e,t,n,r){var o,i,a;return o=(65535&e.b)+(65535&t.b)+(65535&n.b)+(65535&r.b),a=(65535&(i=(e.b>>>16)+(t.b>>>16)+(n.b>>>16)+(r.b>>>16)+(o>>>16)))<<16|65535&o,o=(65535&e.a)+(65535&t.a)+(65535&n.a)+(65535&r.a)+(i>>>16),new P((65535&(i=(e.a>>>16)+(t.a>>>16)+(n.a>>>16)+(r.a>>>16)+(o>>>16)))<<16|65535&o,a)}function z(e,t,n,r,o){var i,a,s;return i=(65535&e.b)+(65535&t.b)+(65535&n.b)+(65535&r.b)+(65535&o.b),s=(65535&(a=(e.b>>>16)+(t.b>>>16)+(n.b>>>16)+(r.b>>>16)+(o.b>>>16)+(i>>>16)))<<16|65535&i,i=(65535&e.a)+(65535&t.a)+(65535&n.a)+(65535&r.a)+(65535&o.a)+(a>>>16),new P((65535&(a=(e.a>>>16)+(t.a>>>16)+(n.a>>>16)+(r.a>>>16)+(o.a>>>16)+(i>>>16)))<<16|65535&i,s)}function d(e,t){return new P(e.a^t.a,e.b^t.b)}function G(e){var t,n=[];if("SHA-1"===e)n=[1732584193,4023233417,2562383102,271733878,3285377520];else if(0===e.lastIndexOf("SHA-",0))switch(n=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],t=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],e){case"SHA-224":break;case"SHA-256":n=t;break;case"SHA-384":n=[new P(3418070365,n[0]),new P(1654270250,n[1]),new P(2438529370,n[2]),new P(355462360,n[3]),new P(1731405415,n[4]),new P(41048885895,n[5]),new P(3675008525,n[6]),new P(1203062813,n[7])];break;case"SHA-512":n=[new P(t[0],4089235720),new P(t[1],2227873595),new P(t[2],4271175723),new P(t[3],1595750129),new P(t[4],2917565137),new P(t[5],725511199),new P(t[6],4215389547),new P(t[7],327033209)];break;default:throw Error("Unknown SHA variant")}else{if(0!==e.lastIndexOf("SHA3-",0)&&0!==e.lastIndexOf("SHAKE",0))throw Error("No SHA variants supported");for(e=0;e<5;e+=1)n[e]=[new P(0,0),new P(0,0),new P(0,0),new P(0,0),new P(0,0)]}return n}function $(e,t){var n,r,o,i,a,s,u,l=[];for(n=t[0],r=t[1],o=t[2],i=t[3],a=t[4],u=0;u<80;u+=1)l[u]=u<16?e[u]:c(l[u-3]^l[u-8]^l[u-14]^l[u-16],1),s=u<20?D(c(n,5),r&o^~r&i,a,1518500249,l[u]):u<40?D(c(n,5),r^o^i,a,1859775393,l[u]):u<60?D(c(n,5),T(r,o,i),a,2400959708,l[u]):D(c(n,5),r^o^i,a,3395469782,l[u]),a=i,i=o,o=c(r,30),r=n,n=s;return t[0]=W(n,t[0]),t[1]=W(r,t[1]),t[2]=W(o,t[2]),t[3]=W(i,t[3]),t[4]=W(a,t[4]),t}function V(e,t,n,r){var o;for(o=15+(t+65>>>9<<4);e.length<=o;)e.push(0);for(e[t>>>5]|=128<<24-t%32,t+=n,e[o]=4294967295&t,e[o-1]=t/4294967296|0,t=e.length,o=0;o<t;o+=16)r=$(e.slice(o,o+16),r);return r}function Z(e,t,n){var r,o,i,a,s,u,l,c,f,h,d,p,y,b,v,g,w,m,k,S,A,E,x,M=[];if("SHA-224"===n||"SHA-256"===n)h=64,p=1,E=Number,y=W,b=Y,v=D,g=I,w=B,m=F,k=K,A=T,S=O,x=ee;else{if("SHA-384"!==n&&"SHA-512"!==n)throw Error("Unexpected error in SHA-2 implementation");h=80,p=2,E=P,y=X,b=J,v=z,g=L,w=N,m=U,k=q,A=_,S=j,x=te}for(n=t[0],r=t[1],o=t[2],i=t[3],a=t[4],s=t[5],u=t[6],l=t[7],d=0;d<h;d+=1)d<16?(f=d*p,c=e.length<=f?0:e[f],f=e.length<=f+1?0:e[f+1],M[d]=new E(c,f)):M[d]=b(w(M[d-2]),M[d-7],g(M[d-15]),M[d-16]),c=v(l,k(a),S(a,s,u),x[d],M[d]),f=y(m(n),A(n,r,o)),l=u,u=s,s=a,a=y(i,c),i=o,o=r,r=n,n=y(c,f);return t[0]=y(n,t[0]),t[1]=y(r,t[1]),t[2]=y(o,t[2]),t[3]=y(i,t[3]),t[4]=y(a,t[4]),t[5]=y(s,t[5]),t[6]=y(u,t[6]),t[7]=y(l,t[7]),t}function Q(e,t){var n,r,o,i,a=[],s=[];if(null!==e)for(r=0;r<e.length;r+=2)t[(r>>>1)%5][(r>>>1)/5|0]=d(t[(r>>>1)%5][(r>>>1)/5|0],new P(e[r+1],e[r]));for(n=0;n<24;n+=1){for(i=G("SHA3-"),r=0;r<5;r+=1){o=t[r][0];var u=t[r][1],l=t[r][2],c=t[r][3],f=t[r][4];a[r]=new P(o.a^u.a^l.a^c.a^f.a,o.b^u.b^l.b^c.b^f.b)}for(r=0;r<5;r+=1)s[r]=d(a[(r+4)%5],h(a[(r+1)%5],1));for(r=0;r<5;r+=1)for(o=0;o<5;o+=1)t[r][o]=d(t[r][o],s[r]);for(r=0;r<5;r+=1)for(o=0;o<5;o+=1)i[o][(2*r+3*o)%5]=h(t[r][o],p[r][o]);for(r=0;r<5;r+=1)for(o=0;o<5;o+=1)t[r][o]=d(i[r][o],new P(~i[(r+1)%5][o].a&i[(r+2)%5][o].a,~i[(r+1)%5][o].b&i[(r+2)%5][o].b));t[0][0]=d(t[0][0],y[n])}return t}var ee,te,p,y;te=[new P((ee=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298])[0],3609767458),new P(ee[1],602891725),new P(ee[2],3964484399),new P(ee[3],2173295548),new P(ee[4],4081628472),new P(ee[5],3053834265),new P(ee[6],2937671579),new P(ee[7],3664609560),new P(ee[8],2734883394),new P(ee[9],1164996542),new P(ee[10],1323610764),new P(ee[11],3590304994),new P(ee[12],4068182383),new P(ee[13],991336113),new P(ee[14],633803317),new P(ee[15],3479774868),new P(ee[16],2666613458),new P(ee[17],944711139),new P(ee[18],2341262773),new P(ee[19],2007800933),new P(ee[20],1495990901),new P(ee[21],1856431235),new P(ee[22],3175218132),new P(ee[23],2198950837),new P(ee[24],3999719339),new P(ee[25],766784016),new P(ee[26],2566594879),new P(ee[27],3203337956),new P(ee[28],1034457026),new P(ee[29],2466948901),new P(ee[30],3758326383),new P(ee[31],168717936),new P(ee[32],1188179964),new P(ee[33],1546045734),new P(ee[34],1522805485),new P(ee[35],2643833823),new P(ee[36],2343527390),new P(ee[37],1014477480),new P(ee[38],1206759142),new P(ee[39],344077627),new P(ee[40],1290863460),new P(ee[41],3158454273),new P(ee[42],3505952657),new P(ee[43],106217008),new P(ee[44],3606008344),new P(ee[45],1432725776),new P(ee[46],1467031594),new P(ee[47],851169720),new P(ee[48],3100823752),new P(ee[49],1363258195),new P(ee[50],3750685593),new P(ee[51],3785050280),new P(ee[52],3318307427),new P(ee[53],3812723403),new P(ee[54],2003034995),new P(ee[55],3602036899),new P(ee[56],1575990012),new P(ee[57],1125592928),new P(ee[58],2716904306),new P(ee[59],442776044),new P(ee[60],593698344),new P(ee[61],3733110249),new P(ee[62],2999351573),new P(ee[63],3815920427),new P(3391569614,3928383900),new P(3515267271,566280711),new P(3940187606,3454069534),new P(4118630271,4000239992),new P(116418474,1914138554),new P(174292421,2731055270),new P(289380356,3203993006),new P(460393269,320620315),new P(685471733,587496836),new P(852142971,1086792851),new P(1017036298,365543100),new P(1126000580,2618297676),new P(1288033470,3409855158),new P(1501505948,4234509866),new P(1607167915,987167468),new P(1816402316,1246189591)],y=[new P(0,1),new P(0,32898),new P(2147483648,32906),new P(2147483648,2147516416),new P(0,32907),new P(0,2147483649),new P(2147483648,2147516545),new P(2147483648,32777),new P(0,138),new P(0,136),new P(0,2147516425),new P(0,2147483658),new P(0,2147516555),new P(2147483648,139),new P(2147483648,32905),new P(2147483648,32771),new P(2147483648,32770),new P(2147483648,128),new P(0,32778),new P(2147483648,2147483658),new P(2147483648,2147516545),new P(2147483648,32896),new P(0,2147483649),new P(2147483648,2147516424)],p=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]],"function"==typeof define&&define.amd?define(function(){return t}):void 0!==a?(void 0!==i&&i.exports&&(i.exports=t),a=t):e.jsSHA=t}(this)},{}]},{},[1]);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/nirvana-reborn_web/zbus-js.git
git@gitee.com:nirvana-reborn_web/zbus-js.git
nirvana-reborn_web
zbus-js
zbus-js
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385