You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Backend.js 92KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. !function(e,t){for(var s in t)e[s]=t[s]}(exports,function(e){var t={};function s(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,s),n.l=!0,n.exports}return s.m=e,s.c=t,s.d=function(e,t,r){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(s.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)s.d(r,n,function(t){return e[t]}.bind(null,n));return r},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=10)}([function(e,t){e.exports=require("util")},function(e,t,s){"use strict";
  2. /*!
  3. * assert.js - assertions for javascript
  4. * Copyright (c) 2018, Christopher Jeffrey (MIT License).
  5. * https://github.com/chjj/bsert
  6. */class r extends Error{constructor(e){"string"==typeof e&&(e={message:e}),null!==e&&"object"==typeof e||(e={});let t=null,s="fail",r=Boolean(e.generatedMessage);var n;if(null!=e.message&&(t="string"==typeof(n=e.message)?n:b(n)?d(n):p(n)),"string"==typeof e.operator&&(s=e.operator),null==t){if("fail"===s)t="Assertion failed.";else{t=`${p(e.actual)} ${s} ${p(e.expected)}`}r=!0}super(t);let i=this.constructor;"function"==typeof e.stackStartFunction?i=e.stackStartFunction:"function"==typeof e.stackStartFn&&(i=e.stackStartFn),this.type="AssertionError",this.name="AssertionError [ERR_ASSERTION]",this.code="ERR_ASSERTION",this.generatedMessage=r,this.actual=e.actual,this.expected=e.expected,this.operator=s,Error.captureStackTrace&&Error.captureStackTrace(this,i)}}function n(e,t){if(!e){let s=!1;if(0===arguments.length)t="No value argument passed to `assert()`.",s=!0;else if(null==t)t="Assertion failed.",s=!0;else if(b(t))throw t;throw new r({message:t,actual:e,expected:!0,operator:"==",generatedMessage:s,stackStartFn:n})}}function i(e,t,s){if(!Object.is(e,t)){if(b(s))throw s;throw new r({message:s,actual:e,expected:t,operator:"strictEqual",stackStartFn:i})}}function o(e,t,s){if(Object.is(e,t)){if(b(s))throw s;throw new r({message:s,actual:e,expected:t,operator:"notStrictEqual",stackStartFn:o})}}function a(e,t,s){"string"==typeof t&&(s=t,t=void 0);let n=!1,i=null;l("function"==typeof e,"func","function");try{e()}catch(e){n=!0,i=e}if(n){if(_(i,t,s,a)){let e=!1;throw null==s&&(s="Got unwanted exception.",e=!0),new r({message:s,actual:i,expected:t,operator:"doesNotThrow",generatedMessage:e,stackStartFn:a})}throw i}}async function h(e,t,s){"string"==typeof t&&(s=t,t=void 0);let n=!1,i=null;"function"!=typeof e&&l(S(e),"func","promise");try{S(e)?await e:await e()}catch(e){n=!0,i=e}if(!n){let e=!1;throw null==s&&(s="Missing expected rejection.",e=!0),new r({message:s,actual:void 0,expected:t,operator:"rejects",generatedMessage:e,stackStartFn:h})}if(!_(i,t,s,h))throw i}async function c(e,t,s){"string"==typeof t&&(s=t,t=void 0);let n=!1,i=null;"function"!=typeof e&&l(S(e),"func","promise");try{S(e)?await e:await e()}catch(e){n=!0,i=e}if(n){if(_(i,t,s,c)){let e=!1;throw null==s&&(s="Got unwanted rejection.",e=!0),new r({message:s,actual:void 0,expected:t,operator:"doesNotReject",generatedMessage:e,stackStartFn:c})}throw i}}function u(e,t,s){if(!g(e,t,!1)){if(b(s))throw s;throw new r({message:s,actual:e,expected:t,operator:"deepStrictEqual",stackStartFn:u})}}function f(e,t,s){if(g(e,t,!0)){if(b(s))throw s;throw new r({message:s,actual:e,expected:t,operator:"notDeepStrictEqual",stackStartFn:f})}}function l(e,t,s){if(!e){let e;e=null==t?"Invalid type for parameter.":null==s?`Invalid type for "${t}".`:`"${t}" must be a(n) ${s}.`;const r=new TypeError(e);throw Error.captureStackTrace&&Error.captureStackTrace(r,l),r}}function p(e){switch(typeof e){case"undefined":return"undefined";case"object":return null===e?"null":`[${function(e){const t=function(e){return m(e).slice(8,-1)}(e);if(null==e)return t;if("Object"!==t&&"Error"!==t)return t;let s,r;try{s=e.constructor}catch(e){}if(null==s)return t;try{r=s.name}catch(e){return t}return"string"!=typeof r||0===r.length?t:r}(e)}]`;case"boolean":case"number":return`${e}`;case"string":return e.length>80&&(e=`${e.substring(0,77)}...`),JSON.stringify(e);case"symbol":return d(e);case"function":return`[${function(e){let t;try{t=e.name}catch(e){}return"string"!=typeof t||0===t.length?"Function":`Function: ${t}`}(e)}]`;case"bigint":return`${e}n`;default:return`[${typeof e}]`}}function d(e){try{return String(e)}catch(e){return"Object"}}function _(e,t,s,n){if(null==t)return!0;if(k(t))return t.test(e);if("function"!=typeof t){if(n===a||n===c)throw new TypeError('"expected" must not be an object.');if("object"!=typeof t)throw new TypeError('"expected" must be an object.');let i=!1;if(null==s){s=`Missing expected ${n===h?"rejection":"exception"}.`,i=!0}if(null==e||"object"!=typeof e)throw new r({actual:e,expected:t,message:s,operator:n.name,generatedMessage:i,stackStartFn:n});const o=Object.keys(t);if(b(t)&&o.push("name","message"),0===o.length)throw new TypeError('"expected" may not be an empty object.');for(const a of o){const o=t[a],h=e[a];if(("string"!=typeof h||!k(o)||!o.test(h))&&!(a in e&&g(h,o,!1)))throw new r({actual:e,expected:t,message:s,operator:n.name,generatedMessage:i,stackStartFn:n})}return!0}return void 0!==t.prototype&&e instanceof t||!Error.isPrototypeOf(t)&&!0===t.call({},e)}function g(e,t,s){try{return y(e,t,null)}catch(e){return s}}function y(e,t,s){if(Object.is(e,t))return!0;if(!w(e)||!w(t))return!1;if(m(e)!==m(t))return!1;if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(E(e)&&E(t))return e.equals(t);if(e instanceof Date)return Object.is(e.getTime(),t.getTime());if(k(e))return e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase;if(b(e)&&e.message!==t.message)return!1;if(function(e){return e instanceof ArrayBuffer}(e)&&(e=new Uint8Array(e),t=new Uint8Array(t)),function(e){return ArrayBuffer.isView(e)}(e)&&!E(e)){if(E(t))return!1;const s=new Uint8Array(e.buffer),r=new Uint8Array(t.buffer);if(s.length!==r.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!==r[e])return!1;return!0}if(function(e){return e instanceof Set}(e)){if(e.size!==t.size)return!1;return new Set([...e,...t]).size===e.size}if(s){const r=s.a.get(e);if(null!=r){const e=s.b.get(t);if(null!=e)return r===e}s.p+=1}else s={a:new Map,b:new Map,p:0};s.a.set(e,s.p),s.b.set(t,s.p);const r=function(e,t,s){if(r=e,r instanceof Map){if(e.size!==t.size)return!1;const r=new Set([...e.keys(),...t.keys()]);if(r.size!==e.size)return!1;for(const n of r)if(!y(e.get(n),t.get(n),s))return!1;return!0}var r;if(function(e){return Array.isArray(e)}(e)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!y(e[r],t[r],s))return!1;return!0}const n=v(e),i=v(t);if(n.length!==i.length)return!1;const o=new Set([...n,...i]);if(o.size!==n.length)return!1;for(const r of o)if(!y(e[r],t[r],s))return!1;return!0}(e,t,s);return s.a.delete(e),s.b.delete(t),r}function v(e){const t=Object.keys(e);if(!Object.getOwnPropertySymbols)return t;if(!Object.getOwnPropertyDescriptor)return t;const s=Object.getOwnPropertySymbols(e);for(const r of s){const s=Object.getOwnPropertyDescriptor(e,r);s&&s.enumerable&&t.push(r)}return t}function m(e){if(void 0===e)return"[object Undefined]";if(null===e)return"[object Null]";try{return Object.prototype.toString.call(e)}catch(e){return"[object Object]"}}function E(e){return w(e)&&"function"==typeof e.writeUInt32LE&&"function"==typeof e.equals}function b(e){return e instanceof Error}function w(e){return e&&"object"==typeof e}function S(e){return e instanceof Promise}function k(e){return e instanceof RegExp}function O(e){if("string"!=typeof e)return!1;switch(e){case"ascii":case"binary":case"base64":case"hex":case"latin1":case"ucs2":case"utf8":case"utf16le":return!0}return!1}function x(e,t,s){if("string"==typeof t){if(!E(e))return null;const{constructor:r}=e;if(!r||"function"!=typeof r.from)return null;if(!O(s))return null;if("hex"===s&&1&t.length)return null;const n=r.from(t,s);return"hex"===s&&n.length!==t.length>>>1?null:n}return t}n.AssertionError=r,n.assert=n,n.strict=n,n.ok=n,n.equal=i,n.notEqual=o,n.strictEqual=i,n.notStrictEqual=o,n.fail=function e(t){let s=!1;if(b(t))throw t;throw null==t&&(t="Assertion failed.",s=!0),new r({message:t,actual:!1,expected:!0,operator:"fail",generatedMessage:s,stackStartFn:e})},n.throws=function e(t,s,n){"string"==typeof s&&(n=s,s=void 0);let i=!1,o=null;l("function"==typeof t,"func","function");try{t()}catch(e){i=!0,o=e}if(!i){let t=!1;throw null==n&&(n="Missing expected exception.",t=!0),new r({message:n,actual:void 0,expected:s,operator:"throws",generatedMessage:t,stackStartFn:e})}if(!_(o,s,n,e))throw o},n.doesNotThrow=a,n.rejects=h,n.doesNotReject=c,n.ifError=function e(t){if(null!=t){let s="ifError got unwanted exception: ";throw"object"==typeof t&&"string"==typeof t.message?0===t.message.length&&t.constructor?s+=t.constructor.name:s+=t.message:s+=p(t),new r({message:s,actual:t,expected:null,operator:"ifError",generatedMessage:!0,stackStartFn:e})}},n.deepEqual=u,n.notDeepEqual=f,n.deepStrictEqual=u,n.notDeepStrictEqual=f,n.bufferEqual=function e(t,s,n,i){if(O(n)||(i=n,n=null),null==n&&(n="hex"),s=x(t,s,n),l(E(t),"actual","buffer"),l(E(s),"expected","buffer"),t!==s&&!t.equals(s)){if(b(i))throw i;throw new r({message:i,actual:t.toString(n),expected:s.toString(n),operator:"bufferEqual",stackStartFn:e})}},n.notBufferEqual=function e(t,s,n,i){if(O(n)||(i=n,n=null),null==n&&(n="hex"),s=x(t,s,n),l(E(t),"actual","buffer"),l(E(s),"expected","buffer"),t===s||t.equals(s)){if(b(i))throw i;throw new r({message:i,actual:t.toString(n),expected:s.toString(n),operator:"notBufferEqual",stackStartFn:e})}},n.enforce=l,n.range=function e(t,s){if(!t){const t=new RangeError(null!=s?`"${s}" is out of range.`:"Parameter is out of range.");throw Error.captureStackTrace&&Error.captureStackTrace(t,e),t}},e.exports=n},function(e,t){e.exports=require("events")},function(e,t){e.exports=require("stream")},function(e,t){e.exports=require("crypto")},function(e,t){e.exports=require("url")},function(e,t,s){"use strict";e.exports=s(13)},function(e,t,s){"use strict";const r=s(1),n={CONNECT:0,DISCONNECT:1,EVENT:2,ACK:3,ERROR:4,BINARY_EVENT:5,BINARY_ACK:6};class i{constructor(e){this.type=e||0,this.attachments=0,this.nsp="/",this.id=-1,this.data="",this.buffers=[]}setData(e){r(void 0!==e),r("number"!=typeof e),r("function"!=typeof e);const[t,s]=function(e){const t=[],s=function e(t,s,r,n){if(null===s||"object"!=typeof s)return s;if(Buffer.isBuffer(s)){const e=n.get(s);if(null!=e)return e;const t={_placeholder:!0,num:r.length};return n.set(s,t),r.push(s),t}if(n.has(s))throw new TypeError("Converting circular structure to JSON.");if(Array.isArray(s)){const t=[];n.set(s,null);for(let i=0;i<s.length;i++)t.push(e(i,s[i],r,n));return n.delete(s),t}const i=Object.create(null);const o="function"==typeof s.toJSON?s.toJSON(t):s;n.set(s,null);for(const t of Object.keys(o))i[t]=e(t,o[t],r,n);n.delete(s);return i}("",e,t,new Map);return[JSON.stringify(s),t]}(e);if(this.data=t,this.buffers=s,this.attachments=s.length,this.attachments>0)switch(this.type){case n.EVENT:this.type=n.BINARY_EVENT;break;case n.ACK:this.type=n.BINARY_ACK}return this}getData(){return 0===this.data.length?null:(e=this.data,t=this.buffers,JSON.parse(e,(e,s)=>(function(e){return null!==e&&"object"==typeof e&&!0===e._placeholder&&e.num>>>0===e.num})(s)&&s.num<t.length?t[s.num]:s));var e,t}toString(){let e=this.type.toString(10);switch(this.type){case n.BINARY_EVENT:case n.BINARY_ACK:e+=this.attachments.toString(10)+"-"}return"/"!==this.nsp&&(e+=this.nsp+","),-1!==this.id&&(e+=this.id.toString(10)),e+=this.data}static fromString(e){r("string"==typeof e),r(e.length>0);let t=0,s=0,i=0,a="/",h=-1,c="";switch([t,s]=function(e,t){const s=e.charCodeAt(t)-48;return s<0||s>9?-1:[t+1,s]}(e,t),r(-1!==s),r(s<=n.BINARY_ACK),s){case n.BINARY_EVENT:case n.BINARY_ACK:[t,i]=o(e,t),r(-1!==i),r(t<e.length),r("-"===e[t]),t+=1}t<e.length&&"/"===e[t]&&([t,a]=function(e,t,s){let n=t;for(;n<e.length&&e[n]!==s;n++);return r(n<e.length),[n+1,e.substring(t,n)]}(e,t,",")),[t,h]=o(e,t),t<e.length&&(c=e.substring(t));const u=new this;return u.type=s,u.attachments=i,u.nsp=a,u.id=h,u.data=c,u}}function o(e,t){let s=0,n=0;for(;t<e.length;t++){const i=e.charCodeAt(t)-48;if(i<0||i>9)break;n*=10,n+=i,r((s+=1)<=10)}return r(n<=4294967295),0===s&&(n=-1),[t,n]}i.types=n,e.exports=i},function(e,t,s){"use strict";const r=s(1),n=s(2),i=s(6).Client,o=s(7),a=s(9),h=s(19),c=s(20),u=s(21),f=s(22);class l{constructor(e,t,s){this.resolve=e,this.reject=t,this.time=s}}function p(e){return null!==e&&"number"!=typeof e&&"string"!=typeof e?null:e}function d(e){return"string"!=typeof e?"No message.":e}function _(e){return"string"!=typeof e?null:e}function g(e,t,s){if(!e){const e=new TypeError(`'${t}' must be a(n) ${s}.`);throw Error.captureStackTrace&&Error.captureStackTrace(e,g),e}}e.exports=class extends n{constructor(){super(),this.server=null,this.ws=null,this.protocol="",this.url="ws://127.0.0.1:80/socket.io/?transport=websocket",this.ssl=!1,this.host="127.0.0.1",this.port=80,this.inbound=!1,this.handshake=!1,this.opened=!1,this.connected=!1,this.challenge=!1,this.destroyed=!1,this.reconnection=!0,this.time=0,this.sequence=0,this.pingInterval=25e3,this.pingTimeout=6e4,this.lastPing=0,this.parser=new c,this.binary=!1,this.packet=null,this.timer=null,this.jobs=new Map,this.hooks=new Map,this.channels=new Set,this.events=new n,this.buffer=[],this.admin=!1,this.auth=!1}accept(e,t,s,n){r(!this.ws,"Cannot accept twice."),r(e),r(t),r(s),r(s.remoteAddress),r(null!=s.remotePort),r(n);let i="ws",o=s.remoteAddress,a=s.remotePort;return s.encrypted&&(i="wss"),-1!==o.indexOf(":")&&(o=`[${o}]`),a||(a=0),this.server=e,this.binary=-1===t.url.indexOf("b64=1"),this.url=`${i}://${o}:${a}/socket.io/?transport=websocket`,this.ssl="wss"===i,this.host=s.remoteAddress,this.port=s.remotePort,this.inbound=!0,this.ws=n,this.init(),this}connect(e,t,s,n){r(!this.ws,"Cannot connect twice."),"string"==typeof e&&(n=t,[e,t,s]=h.parseURL(e));let o="ws";s&&(o="wss"),t||(t="127.0.0.1"),r("string"==typeof t),r((65535&e)===e,"Must pass a port."),r(!s||"boolean"==typeof s),r(!n||Array.isArray(n));let a=t;-1!==t.indexOf(":")&&"["!==t[0]&&(a=`[${t}]`);const c=`${o}://${a}:${e}/socket.io/?transport=websocket`;return this.binary=!0,this.url=c,this.ssl=s,this.host=t,this.port=e,this.inbound=!1,this.ws=new i(c,n),this.init(),this}init(){this.protocol=this.ws.protocol,this.time=Date.now(),this.observe(),this.parser.on("error",e=>{this.emit("error",e)}),this.parser.on("frame",async e=>{try{await this.handleFrame(e)}catch(e){this.emit("error",e)}}),this.start()}observe(){const e=this.ws;r(e),e.binaryType="arraybuffer",e.onopen=async()=>{await this.onOpen()},e.onmessage=async e=>{await this.onMessage(e)},e.onerror=async e=>{await this.onError(e)},e.onclose=async e=>{await this.onClose(e)}}async onOpen(){this.destroyed||this.inbound&&(r(!this.opened),r(!this.connected),r(!this.handshake),this.opened=!0,this.handshake=!0,await this.emitAsync("open"),this.sendHandshake(),this.connected=!0,await this.emitAsync("connect"),this.sendConnect())}async emitAsync(e,...t){const s=this.listeners(e);for(const e of s)try{await e(...t)}catch(e){this.emit("error",e)}}async onMessage(e){if(this.destroyed)return;let t;try{t=await function(e){return new Promise((t,s)=>{if("string"!=typeof e)if(e&&"object"==typeof e)if(Buffer.isBuffer(e))t(e);else if(e instanceof ArrayBuffer){const s=Buffer.from(e);t(s)}else if(e.buffer instanceof ArrayBuffer){const s=Buffer.from(e.buffer,e.byteOffset,e.byteLength);t(s)}else{if("undefined"!=typeof Blob&&Blob&&e instanceof Blob){const s=new FileReader;return s.onloadend=()=>{const e=Buffer.from(s.result);t(e)},void s.readAsArrayBuffer(e)}s(new Error("Bad data object."))}else s(new Error("Bad data object."));else t(e)})}(e.data)}catch(e){return void this.emit("error",e)}"string"!=typeof t?this.parser.feedBinary(t):this.parser.feedString(t)}async onError(e){this.destroyed||(this.emit("error",new Error(e.message)),this.inbound?this.destroy():this.close())}async onClose(e){if(this.destroyed)return;if(1e3===e.code||1001===e.code)return this.connected||this.emit("error",new Error("Could not connect.")),this.inbound?void this.destroy():void this.close();const t=u[e.code]||"UNKNOWN_CODE",s=e.reason||"Unknown reason",r=new Error(`Websocket Closed: ${s} (code=${t}).`);r.reason=e.reason||"",r.code=e.code||0,this.emit("error",r),this.inbound?this.destroy():this.reconnection?this.close():this.destroy()}close(){if(!this.destroyed){this.time=Date.now(),this.packet=null,this.handshake=!1,this.connected=!1,this.challenge=!1,this.sequence=0,this.lastPing=0;for(const[e,t]of this.jobs)this.jobs.delete(e),t.reject(new Error("Job timed out."));r(this.ws),this.ws.onopen=()=>{},this.ws.onmessage=()=>{},this.ws.onerror=()=>{},this.ws.onclose=()=>{},this.ws.close(),this.emitAsync("disconnect")}}error(e){this.destroyed||this.emit("error",new Error(e))}destroy(){this.destroyed||(this.close(),this.stop(),this.opened=!1,this.destroyed=!0,this.buffer.length=0,this.emitAsync("close"),this.removeAllListeners(),this.on("error",()=>{}))}send(e){this.destroyed||(r(this.ws),e.binary&&this.binary?this.ws.send(e.toRaw()):this.ws.send(e.toString()))}reconnect(){r(!this.inbound),this.close(),this.ws=new i(this.url),this.time=Date.now(),this.observe()}start(){r(this.ws),r(null==this.timer),this.timer=setInterval(()=>this.stall(),5e3)}stop(){null!=this.timer&&(clearInterval(this.timer),this.timer=null)}stall(){const e=Date.now();if(r(this.ws),!this.connected)return e-this.time>1e4?this.inbound||!this.reconnection?(this.error("Timed out waiting for connection."),void this.destroy()):(this.error("Timed out waiting for connection. Reconnecting..."),void this.reconnect()):void 0;for(const[t,s]of this.jobs)e-s.time>6e5&&(this.jobs.delete(t),s.reject(new Error("Job timed out.")));return this.inbound||this.challenge?!this.inbound&&e-this.lastPing>this.pingTimeout?(this.error("Connection is stalling (ping)."),this.inbound?void this.destroy():void this.close()):void 0:(this.challenge=!0,this.lastPing=e,void this.sendPing())}async handleFrame(e){if(!this.destroyed)switch(e.type){case a.types.OPEN:return this.handleOpen(e);case a.types.CLOSE:return this.handleClose(e);case a.types.PING:return this.handlePing(e);case a.types.PONG:return this.handlePong(e);case a.types.MESSAGE:return this.handleMessage(e);case a.types.UPGRADE:return this.handleUpgrade(e);case a.types.NOOP:return this.handleNoop(e);default:throw new Error("Unknown frame.")}}async handleOpen(e){if(this.inbound)throw new Error("Inbound socket sent an open frame.");if(e.binary)throw new Error("Received a binary open frame.");if(this.handshake)throw new Error("Duplicate open frame.");const t=JSON.parse(e.data);g(t&&"object"==typeof t,"open","object");const{pingInterval:s,pingTimeout:r}=t;g(s>>>0===s,"interval","uint32"),g(r>>>0===r,"timeout","uint32"),this.pingInterval=s,this.pingTimeout=r,this.handshake=!0,this.opened||(this.opened=!0,await this.emitAsync("open"))}async handleClose(e){if(this.inbound)throw new Error("Inbound socket sent a close frame.");this.close()}async handlePing(){if(!this.inbound)throw new Error("Outbound socket sent a ping frame.");this.sendPong()}async handlePong(){if(this.inbound)throw new Error("Inbound socket sent a pong frame.");if(!this.challenge)return this.error("Remote node sent bad pong."),void this.destroy();this.challenge=!1}async handleMessage(e){if(this.packet){const t=this.packet;if(!e.binary)throw new Error("Received non-binary frame as attachment.");return t.buffers.push(e.data),t.buffers.length===t.attachments?(this.packet=null,this.handlePacket(t)):void 0}if(e.binary)throw new Error("Received binary frame as a message.");const t=o.fromString(e.data);if(!(t.attachments>0))return this.handlePacket(t);this.packet=t}async handleUpgrade(e){if(!this.inbound)throw new Error("Outbound socket sent an upgrade frame.");throw new Error("Cannot upgrade from websocket.")}async handleNoop(e){}sendFrame(e,t,s){this.send(new a(e,t,s))}sendOpen(e){this.sendFrame(a.types.OPEN,e,!1)}sendClose(e){this.sendFrame(a.types.CLOSE,e,!1)}sendPing(e){this.sendFrame(a.types.PING,e,!1)}sendPong(e){this.sendFrame(a.types.PONG,e,!1)}sendMessage(e){this.sendFrame(a.types.MESSAGE,e,!1)}sendBinary(e){this.sendFrame(a.types.MESSAGE,e,!0)}sendHandshake(){const e=JSON.stringify({sid:"00000000000000000000",upgrades:[],pingInterval:this.pingInterval,pingTimeout:this.pingTimeout});this.sendOpen(e)}async handlePacket(e){if(!this.destroyed)switch(e.type){case o.types.CONNECT:return this.handleConnect();case o.types.DISCONNECT:return this.handleDisconnect();case o.types.EVENT:case o.types.BINARY_EVENT:{const t=e.getData();return g(Array.isArray(t),"args","array"),g(t.length>0,"args","array"),g("string"==typeof t[0],"event","string"),-1!==e.id?this.handleCall(e.id,t):this.handleEvent(t)}case o.types.ACK:case o.types.BINARY_ACK:{g(-1!==e.id,"id","uint32");const t=e.getData();g(null==t||Array.isArray(t),"args","array");let s=null,r=null;return t&&t.length>0&&(s=t[0]),t&&t.length>1&&(r=t[1]),null==r&&(r=null),s?(g("object"==typeof s,"error","object"),this.handleError(e.id,s)):this.handleAck(e.id,r)}case o.types.ERROR:{const t=e.getData();return g(t&&"object"==typeof t,"error","object"),this.handleError(-1,t)}default:throw new Error("Unknown packet.")}}async handleConnect(){if(this.inbound)throw new Error("Inbound socket sent connect packet.");this.connected=!0,await this.emitAsync("connect");for(const e of this.buffer)this.sendPacket(e);this.buffer.length=0}async handleDisconnect(){this.close()}async handleEvent(e){try{const t=e[0];if(f.hasOwnProperty(t))throw new Error(`Cannot emit blacklisted event: ${t}.`);this.events.emit(...e)}catch(e){this.emit("error",e),this.sendError(-1,e)}}async handleCall(e,t){let s;try{const e=t.shift();if(f.hasOwnProperty(e))throw new Error(`Cannot emit blacklisted event: ${e}.`);const r=this.hooks.get(e);if(!r)throw new Error(`Call not found: ${e}.`);s=await r(...t)}catch(t){return this.emit("error",t),void this.sendError(e,t)}null==s&&(s=null),this.sendAck(e,s)}async handleAck(e,t){const s=this.jobs.get(e);if(!s)throw new Error(`Job not found for ${e}.`);this.jobs.delete(e),s.resolve(t)}async handleError(e,t){const s=d(t.message),r=_(t.name),n=_(t.type),i=p(t.code);if(-1===e){const e=new Error(s);return e.name=r,e.type=n,e.code=i,void this.emit("error",e)}const o=this.jobs.get(e);if(!o)throw new Error(`Job not found for ${e}.`);this.jobs.delete(e);const a=new Error(s);a.name=r,a.type=n,a.code=i,o.reject(a)}sendPacket(e){this.sendMessage(e.toString());for(const t of e.buffers)this.sendBinary(t)}sendConnect(){this.sendPacket(new o(o.types.CONNECT))}sendDisconnect(){this.sendPacket(new o(o.types.DISCONNECT))}sendEvent(e){const t=new o;t.type=o.types.EVENT,t.setData(e),this.connected?this.sendPacket(t):this.buffer.push(t)}sendCall(e,t){const s=new o;s.type=o.types.EVENT,s.id=e,s.setData(t),this.connected?this.sendPacket(s):this.buffer.push(s)}sendAck(e,t){const s=new o;s.type=o.types.ACK,s.id=e,s.setData([null,t]),this.sendPacket(s)}sendError(e,t){const s=d(t.message),r=_(t.name),n=_(t.type),i=p(t.code);if(-1===e){const e=new o;return e.type=o.types.ERROR,e.setData({message:s,name:r,type:n,code:i}),void this.sendPacket(e)}const a=new o;a.type=o.types.ACK,a.id=e,a.setData([{message:s,name:r,type:n,code:i}]),this.sendPacket(a)}bind(e,t){g("string"==typeof e,"event","string"),g("function"==typeof t,"handler","function"),r(!f.hasOwnProperty(e),"Blacklisted event."),this.events.on(e,t)}unbind(e,t){g("string"==typeof e,"event","string"),g("function"==typeof t,"handler","function"),r(!f.hasOwnProperty(e),"Blacklisted event."),this.events.removeListener(e,t)}fire(...e){g(e.length>0,"event","string"),g("string"==typeof e[0],"event","string"),this.sendEvent(e)}hook(e,t){g("string"==typeof e,"event","string"),g("function"==typeof t,"handler","function"),r(!this.hooks.has(e),"Hook already bound."),r(!f.hasOwnProperty(e),"Blacklisted event."),this.hooks.set(e,t)}unhook(e){g("string"==typeof e,"event","string"),r(!f.hasOwnProperty(e),"Blacklisted event."),this.hooks.delete(e)}call(...e){g(e.length>0,"event","string"),g("string"==typeof e[0],"event","string");const t=this.sequence;return this.sequence+=1,this.sequence>>>=0,r(!this.jobs.has(t),"ID collision."),this.sendCall(t,e),new Promise((e,s)=>{this.jobs.set(t,new l(e,s,Date.now()))})}channel(e){return this.channels.has(e)}join(e){return!!this.server&&this.server.join(this,e)}leave(e){return!!this.server&&this.server.leave(this,e)}static accept(e,t,s,r){return(new this).accept(e,t,s,r)}static connect(e,t,s,r){return(new this).connect(e,t,s,r)}}},function(e,t,s){"use strict";const r=s(1),n=Buffer.alloc(0),i={OPEN:0,CLOSE:1,PING:2,PONG:3,MESSAGE:4,UPGRADE:5,NOOP:6};class o{constructor(e,t,s){r("number"==typeof e),r(e>>>0===e),r(e<=i.NOOP),r("boolean"==typeof s),s?(null==t&&(t=n),r(Buffer.isBuffer(t))):(null==t&&(t=""),r("string"==typeof t)),this.type=e,this.data=t,this.binary=s}toString(){let e="";return this.binary?(e+="b",e+=this.type.toString(10),e+=this.data.toString("base64")):(e+=this.type.toString(10),e+=this.data),e}static fromString(e){r("string"==typeof e);let t,s=e.charCodeAt(0),n=!1;return 98===s?(r(e.length>1),s=e.charCodeAt(1),t=Buffer.from(e.substring(2),"base64"),n=!0):t=e.substring(1),r((s-=48)>=0&&s<=9),r(s<=i.NOOP),new this(s,t,n)}size(){let e=1;return this.binary?e+=this.data.length:e+=Buffer.byteLength(this.data,"utf8"),e}toRaw(){const e=Buffer.allocUnsafe(this.size());return e[0]=this.type,this.binary?this.data.copy(e,1):this.data.length>0&&e.write(this.data,1,"utf8"),e}static fromRaw(e){r(Buffer.isBuffer(e)),r(e.length>0);const t=e[0];return r(t<=i.NOOP),new this(t,e.slice(1),!0)}}o.types=i,o.table=["open","close","ping","pong","message","upgrade","noop"],e.exports=o},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=s(11),n=s(12),i=s(23);t.Server=class{constructor(e,t=[],s={errorHandler:e=>t=>{e.destroy(),console.error(t)},closeHandler:e=>()=>{console.log("Socket closing")},connectionHandler:e=>{console.log("New websocket connection in port "+e.port)},visibility:"127.0.0.1"}){this.port=e,this.exporters=t,this.conf=s,this.ws=r.createServer(),this.io=n.createServer(),this.startWebsocket()}startWebsocket(){try{this.io.attach(this.ws),this.io.on("socket",e=>{e.on("error",this.conf.errorHandler(e)),e.on("close",this.conf.closeHandler(e)),"127.0.0.1"===this.conf.visibility?this.initRPCs(e):this.initPublicRPCs(e)}),this.ws.listen(this.port,this.conf.visibility)}catch(e){this.errorHandler(void 0)("Unable to connect to socket")}}initRPCs(e){e.hook("info",()=>t);const t=[...this.exporters.flatMap(t=>i.rpcHooker(e,t))]}initPublicRPCs(e){e.hook("info",()=>t);const t=[...this.exporters.flatMap(t=>i.rpcHooker(e,t))]}}},function(e,t){e.exports=require("http")},function(e,t,s){"use strict";const r=s(6),n=s(18),i=s(8);t.WebSocket=r,t.Server=n,t.server=()=>new n,t.createServer=n.createServer.bind(n),t.attach=n.attach.bind(n),t.Socket=i,t.socket=()=>new i,t.connect=i.connect.bind(i)},function(e,t,s){(function(e,r,n){
  7. /*!
  8. * faye-websocket@0.11.1 - Standards-compliant WebSocket server and client
  9. * Copyright (c) 2019, James Coglan (MIT)
  10. * https://github.com/faye/faye-websocket-node
  11. *
  12. * License for websocket-driver@0.7.0:
  13. *
  14. * # The MIT License
  15. *
  16. * Copyright (c) 2010-2017 James Coglan
  17. *
  18. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19. * of this software and associated documentation files (the 'Software'), to deal
  20. * in the Software without restriction, including without limitation the rights
  21. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22. * copies of the Software, and to permit persons to whom the Software is
  23. * furnished to do so, subject to the following conditions:
  24. *
  25. * The above copyright notice and this permission notice shall be included in
  26. * all copies or substantial portions of the Software.
  27. *
  28. * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  29. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  30. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  31. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  32. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  33. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  34. * SOFTWARE.
  35. *
  36. * License for http-parser-js@0.5.0:
  37. *
  38. * Copyright (c) 2015 Tim Caswell (https://github.com/creationix) and other
  39. * contributors. All rights reserved.
  40. *
  41. * Permission is hereby granted, free of charge, to any person obtaining a copy
  42. * of this software and associated documentation files (the "Software"), to deal
  43. * in the Software without restriction, including without limitation the rights
  44. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  45. * copies of the Software, and to permit persons to whom the Software is
  46. * furnished to do so, subject to the following conditions:
  47. *
  48. * The above copyright notice and this permission notice shall be included in
  49. * all copies or substantial portions of the Software.
  50. *
  51. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  52. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  53. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  54. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  55. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  56. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  57. * SOFTWARE.
  58. *
  59. * Some files from the tests folder are from joyent/node and mscedex/io.js, a
  60. * fork of nodejs/io.js:
  61. *
  62. * - tests/iojs/test-http-parser-durability.js
  63. *
  64. * This file is from
  65. * https://github.com/mscdex/io.js/blob/js-http-parser/test/pummel/test-http-parser-durability.js
  66. * with modifications by Jan Schär (jscissr).
  67. *
  68. * """ Copyright io.js contributors. All rights reserved.
  69. *
  70. * Permission is hereby granted, free of charge, to any person obtaining a copy
  71. * of this software and associated documentation files (the "Software"), to deal
  72. * in the Software without restriction, including without limitation the rights
  73. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  74. * copies of the Software, and to permit persons to whom the Software is
  75. * furnished to do so, subject to the following conditions:
  76. *
  77. * The above copyright notice and this permission notice shall be included in
  78. * all copies or substantial portions of the Software.
  79. *
  80. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  81. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  82. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  83. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  84. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  85. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  86. * SOFTWARE. """
  87. *
  88. * - tests/fixtures/* tests/parallel/* tests/testpy/* tests/common.js
  89. * tests/test.py tests/utils.py
  90. *
  91. * These files are from https://github.com/nodejs/node with changes by Jan Schär
  92. * (jscissr).
  93. *
  94. * Node.js is licensed for use as follows:
  95. *
  96. * """ Copyright Node.js contributors. All rights reserved.
  97. *
  98. * Permission is hereby granted, free of charge, to any person obtaining a copy
  99. * of this software and associated documentation files (the "Software"), to deal
  100. * in the Software without restriction, including without limitation the rights
  101. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  102. * copies of the Software, and to permit persons to whom the Software is
  103. * furnished to do so, subject to the following conditions:
  104. *
  105. * The above copyright notice and this permission notice shall be included in
  106. * all copies or substantial portions of the Software.
  107. *
  108. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  109. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  110. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  111. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  112. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  113. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  114. * SOFTWARE. """
  115. *
  116. * This license applies to parts of Node.js originating from the
  117. * https://github.com/joyent/node repository:
  118. *
  119. * """ Copyright Joyent, Inc. and other Node contributors. All rights reserved.
  120. * Permission is hereby granted, free of charge, to any person obtaining a copy
  121. * of this software and associated documentation files (the "Software"), to deal
  122. * in the Software without restriction, including without limitation the rights
  123. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  124. * copies of the Software, and to permit persons to whom the Software is
  125. * furnished to do so, subject to the following conditions:
  126. *
  127. * The above copyright notice and this permission notice shall be included in
  128. * all copies or substantial portions of the Software.
  129. *
  130. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  131. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  132. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  133. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  134. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  135. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  136. * SOFTWARE. """
  137. *
  138. * License for websocket-extensions@0.1.3:
  139. *
  140. * # The MIT License
  141. *
  142. * Copyright (c) 2014-2017 James Coglan
  143. *
  144. * Permission is hereby granted, free of charge, to any person obtaining a copy
  145. * of this software and associated documentation files (the 'Software'), to deal
  146. * in the Software without restriction, including without limitation the rights
  147. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  148. * copies of the Software, and to permit persons to whom the Software is
  149. * furnished to do so, subject to the following conditions:
  150. *
  151. * The above copyright notice and this permission notice shall be included in
  152. * all copies or substantial portions of the Software.
  153. *
  154. * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  155. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  156. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  157. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  158. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  159. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  160. * SOFTWARE.
  161. */
  162. var i=[["faye-websocket","/lib/faye/websocket.js",function(e,t,r,n,i){var o=s(0),h=a(1),c=a(23),u=function(e,t,s,r,n){n=n||{},this._stream=t,this._driver=h.http(e,{maxLength:n.maxLength,protocols:r});var i=this;if(this._stream&&this._stream.writable){if(!this._stream.readable)return this._stream.end();var o=function(){i._stream.removeListener("data",o)};this._stream.on("data",o),c.call(this,n),process.nextTick((function(){i._driver.start(),i._driver.io.write(s)}))}};o.inherits(u,c),u.isWebSocket=function(e){return h.isWebSocket(e)},u.validateOptions=function(e,t){h.validateOptions(e,t)},u.WebSocket=u,u.Client=a(26),u.EventSource=a(27),t.exports=u}],["websocket-driver","/lib/websocket/driver.js",function(e,t,s,r,n){"use strict";var i=a(2),o=a(6),h=a(20),c={client:function(e,t){return void 0===(t=t||{}).masking&&(t.masking=!0),new o(e,t)},server:function(e){return void 0===(e=e||{}).requireMasking&&(e.requireMasking=!0),new h(e)},http:function(){return h.http.apply(h,arguments)},isSecureRequest:function(e){return h.isSecureRequest(e)},isWebSocket:function(e){if("GET"!==e.method)return!1;var t=e.headers.connection||"",s=e.headers.upgrade||"";return"GET"===e.method&&t.toLowerCase().split(/ *, */).indexOf("upgrade")>=0&&"websocket"===s.toLowerCase()},validateOptions:function(e,t){i.validateOptions(e,t)}};t.exports=c}],["websocket-driver","/lib/websocket/driver/base.js",function(e,t,r,n,i){"use strict";var o=s(2).EventEmitter,h=s(0),c=a(3),u=a(4),f=a(5),l=function(e,t,s){o.call(this),l.validateOptions(s||{},["maxLength","masking","requireMasking","protocols"]),this._request=e,this._reader=new f,this._options=s||{},this._maxLength=this._options.maxLength||this.MAX_LENGTH,this._headers=new u,this.__queue=[],this.readyState=0,this.url=t,this.io=new c.IO(this),this.messages=new c.Messages(this),this._bindEventListeners()};h.inherits(l,o),l.validateOptions=function(e,t){for(var s in e)if(t.indexOf(s)<0)throw new Error("Unrecognized option: "+s)};var p={MAX_LENGTH:67108863,STATES:["connecting","open","closing","closed"],_bindEventListeners:function(){var e=this;this.messages.on("error",(function(){})),this.on("message",(function(t){var s=e.messages;s.readable&&s.emit("data",t.data)})),this.on("error",(function(t){var s=e.messages;s.readable&&s.emit("error",t)})),this.on("close",(function(){var t=e.messages;t.readable&&(t.readable=t.writable=!1,t.emit("end"))}))},getState:function(){return this.STATES[this.readyState]||null},addExtension:function(e){return!1},setHeader:function(e,t){return!(this.readyState>0)&&(this._headers.set(e,t),!0)},start:function(){if(0!==this.readyState)return!1;var e=this._handshakeResponse();return!!e&&(this._write(e),-1!==this._stage&&this._open(),!0)},text:function(e){return this.frame(e)},binary:function(e){return!1},ping:function(){return!1},pong:function(){return!1},close:function(e,t){return 1===this.readyState&&(this.readyState=3,this.emit("close",new l.CloseEvent(null,null)),!0)},_open:function(){this.readyState=1,this.__queue.forEach((function(e){this.frame.apply(this,e)}),this),this.__queue=[],this.emit("open",new l.OpenEvent)},_queue:function(e){return this.__queue.push(e),!0},_write:function(e){var t=this.io;t.readable&&t.emit("data",e)}};for(var d in p)l.prototype[d]=p[d];l.ConnectEvent=function(){},l.OpenEvent=function(){},l.CloseEvent=function(e,t){this.code=e,this.reason=t},l.MessageEvent=function(e){this.data=e},l.PingEvent=function(e){this.data=e},l.PongEvent=function(e){this.data=e},t.exports=l}],["websocket-driver","/lib/websocket/streams.js",function(e,t,r,n,i){"use strict";var o=s(3).Stream,a=s(0),h=function(e){this.readable=this.writable=!0,this._paused=!1,this._driver=e};a.inherits(h,o),h.prototype.pause=function(){this._paused=!0,this._driver.messages._paused=!0},h.prototype.resume=function(){this._paused=!1,this.emit("drain");var e=this._driver.messages;e._paused=!1,e.emit("drain")},h.prototype.write=function(e){return!!this.writable&&(this._driver.parse(e),!this._paused)},h.prototype.end=function(e){if(this.writable){void 0!==e&&this.write(e),this.writable=!1;var t=this._driver.messages;t.readable&&(t.readable=t.writable=!1,t.emit("end"))}},h.prototype.destroy=function(){this.end()};var c=function(e){this.readable=this.writable=!0,this._paused=!1,this._driver=e};a.inherits(c,o),c.prototype.pause=function(){this._driver.io._paused=!0},c.prototype.resume=function(){this._driver.io._paused=!1,this._driver.io.emit("drain")},c.prototype.write=function(e){return!!this.writable&&("string"==typeof e?this._driver.text(e):this._driver.binary(e),!this._paused)},c.prototype.end=function(e){void 0!==e&&this.write(e)},c.prototype.destroy=function(){},e.IO=h,e.Messages=c}],["websocket-driver","/lib/websocket/driver/headers.js",function(e,t,s,r,n){"use strict";var i=function(){this.clear()};i.prototype.ALLOWED_DUPLICATES=["set-cookie","set-cookie2","warning","www-authenticate"],i.prototype.clear=function(){this._sent={},this._lines=[]},i.prototype.set=function(e,t){if(void 0!==t){e=this._strip(e),t=this._strip(t);var s=e.toLowerCase();(!this._sent.hasOwnProperty(s)||this.ALLOWED_DUPLICATES.indexOf(s)>=0)&&(this._sent[s]=!0,this._lines.push(e+": "+t+"\r\n"))}},i.prototype.toString=function(){return this._lines.join("")},i.prototype._strip=function(e){return e.toString().replace(/^ */,"").replace(/ *$/,"")},t.exports=i}],["websocket-driver","/lib/websocket/driver/stream_reader.js",function(e,t,s,r,n){"use strict";var i=function(){this._queue=[],this._queueSize=0,this._offset=0};i.prototype.put=function(e){e&&0!==e.length&&(e.copy||(e=new Buffer(e)),this._queue.push(e),this._queueSize+=e.length)},i.prototype.read=function(e){if(e>this._queueSize)return null;if(0===e)return new Buffer(0);this._queueSize-=e;var t,s,r=this._queue,n=e,i=r[0];if(i.length>=e)return i.length===e?r.shift():(s=i.slice(0,e),r[0]=i.slice(e),s);for(var o=0,a=r.length;o<a&&!(n<r[o].length);o++)n-=r[o].length;return t=r.splice(0,o),n>0&&r.length>0&&(t.push(r[0].slice(0,n)),r[0]=r[0].slice(n)),this._concat(t,e)},i.prototype.eachByte=function(e,t){for(var s,r,n;this._queue.length>0;){for(r=(s=this._queue[0]).length;this._offset<r;)n=this._offset,this._offset+=1,e.call(t,s[n]);this._offset=0,this._queue.shift()}},i.prototype._concat=function(e,t){if(Buffer.concat)return Buffer.concat(e,t);for(var s=new Buffer(t),r=0,n=0,i=e.length;n<i;n++)e[n].copy(s,r),r+=e[n].length;return s},t.exports=i}],["websocket-driver","/lib/websocket/driver/client.js",function(e,t,r,n,i){"use strict";var o=s(4),h=s(5),c=s(0),u=a(7),f=a(2),l=a(9),p=a(19),d=function(e,t){this.version="hybi-13",l.call(this,null,e,t),this.readyState=-1,this._key=d.generateKey(),this._accept=l.generateAccept(this._key),this._http=new u("response");var s=h.parse(this.url),r=s.auth&&new Buffer(s.auth,"utf8").toString("base64");if(this.VALID_PROTOCOLS.indexOf(s.protocol)<0)throw new Error(this.url+" is not a valid WebSocket URL");this._pathname=(s.pathname||"/")+(s.search||""),this._headers.set("Host",s.host),this._headers.set("Upgrade","websocket"),this._headers.set("Connection","Upgrade"),this._headers.set("Sec-WebSocket-Key",this._key),this._headers.set("Sec-WebSocket-Version","13"),this._protocols.length>0&&this._headers.set("Sec-WebSocket-Protocol",this._protocols.join(", ")),r&&this._headers.set("Authorization","Basic "+r)};c.inherits(d,l),d.generateKey=function(){return o.randomBytes(16).toString("base64")};var _={VALID_PROTOCOLS:["ws:","wss:"],proxy:function(e,t){return new p(this,e,t)},start:function(){return-1===this.readyState&&(this._write(this._handshakeRequest()),this.readyState=0,!0)},parse:function(e){if(3!==this.readyState){if(this.readyState>0)return l.prototype.parse.call(this,e);this._http.parse(e),this._http.isComplete()&&(this._validateHandshake(),3!==this.readyState&&(this._open(),this.parse(this._http.body)))}},_handshakeRequest:function(){var e=this._extensions.generateOffer();e&&this._headers.set("Sec-WebSocket-Extensions",e);var t=["GET "+this._pathname+" HTTP/1.1",this._headers.toString(),""];return new Buffer(t.join("\r\n"),"utf8")},_failHandshake:function(e){e="Error during WebSocket handshake: "+e,this.readyState=3,this.emit("error",new Error(e)),this.emit("close",new f.CloseEvent(this.ERRORS.protocol_error,e))},_validateHandshake:function(){if(this.statusCode=this._http.statusCode,this.headers=this._http.headers,this._http.error)return this._failHandshake(this._http.error.message);if(101!==this._http.statusCode)return this._failHandshake("Unexpected response code: "+this._http.statusCode);var e=this._http.headers,t=e.upgrade||"",s=e.connection||"",r=e["sec-websocket-accept"]||"",n=e["sec-websocket-protocol"]||"";if(""===t)return this._failHandshake("'Upgrade' header is missing");if("websocket"!==t.toLowerCase())return this._failHandshake("'Upgrade' header value is not 'WebSocket'");if(""===s)return this._failHandshake("'Connection' header is missing");if("upgrade"!==s.toLowerCase())return this._failHandshake("'Connection' header value is not 'Upgrade'");if(r!==this._accept)return this._failHandshake("Sec-WebSocket-Accept mismatch");if(this.protocol=null,""!==n){if(this._protocols.indexOf(n)<0)return this._failHandshake("Sec-WebSocket-Protocol mismatch");this.protocol=n}try{this._extensions.activate(this.headers["sec-websocket-extensions"])}catch(e){return this._failHandshake(e.message)}}};for(var g in _)d.prototype[g]=_[g];t.exports=d}],["websocket-driver","/lib/websocket/http_parser.js",function(e,t,s,r,n){"use strict";var i=a(8).HTTPParser,o=process.version.match(/[0-9]+/g).map((function(e){return parseInt(e,10)})),h={request:i.REQUEST||"request",response:i.RESPONSE||"response"},c=function(e){this._type=e,this._parser=new i(h[e]),this._complete=!1,this.headers={};var t=null,s=this;this._parser.onHeaderField=function(e,s,r){t=e.toString("utf8",s,s+r).toLowerCase()},this._parser.onHeaderValue=function(e,r,n){var i=e.toString("utf8",r,r+n);s.headers.hasOwnProperty(t)?s.headers[t]+=", "+i:s.headers[t]=i},this._parser.onHeadersComplete=this._parser[i.kOnHeadersComplete]=function(e,t,r,n,i,o){var a=arguments[0];if("object"==typeof a&&(n=a.method,i=a.url,o=a.statusCode,r=a.headers),s.method="number"==typeof n?c.METHODS[n]:n,s.statusCode=o,s.url=i,r){for(var h,u,f=0,l=r.length;f<l;f+=2)h=r[f].toLowerCase(),u=r[f+1],s.headers.hasOwnProperty(h)?s.headers[h]+=", "+u:s.headers[h]=u;s._complete=!0}}};c.METHODS={0:"DELETE",1:"GET",2:"HEAD",3:"POST",4:"PUT",5:"CONNECT",6:"OPTIONS",7:"TRACE",8:"COPY",9:"LOCK",10:"MKCOL",11:"MOVE",12:"PROPFIND",13:"PROPPATCH",14:"SEARCH",15:"UNLOCK",16:"BIND",17:"REBIND",18:"UNBIND",19:"ACL",20:"REPORT",21:"MKACTIVITY",22:"CHECKOUT",23:"MERGE",24:"M-SEARCH",25:"NOTIFY",26:"SUBSCRIBE",27:"UNSUBSCRIBE",28:"PATCH",29:"PURGE",30:"MKCALENDAR",31:"LINK",32:"UNLINK"},0===o[0]&&12===o[1]&&(c.METHODS[16]="REPORT",c.METHODS[17]="MKACTIVITY",c.METHODS[18]="CHECKOUT",c.METHODS[19]="MERGE",c.METHODS[20]="M-SEARCH",c.METHODS[21]="NOTIFY",c.METHODS[22]="SUBSCRIBE",c.METHODS[23]="UNSUBSCRIBE",c.METHODS[24]="PATCH",c.METHODS[25]="PURGE"),c.prototype.isComplete=function(){return this._complete},c.prototype.parse=function(e){var t=this._parser.execute(e,0,e.length);if("number"!=typeof t)return this.error=t,void(this._complete=!0);0===o[0]&&o[1]<6&&(t+=1),this._complete&&(this.body=t<e.length?e.slice(t):new Buffer(0))},t.exports=c}],["http-parser-js","/http-parser.js",function(e,t,r,n,i){var o=s(15);function a(e){o.ok(e===a.REQUEST||e===a.RESPONSE),this.type=e,this.state=e+"_LINE",this.info={headers:[],upgrade:!1},this.trailers=[],this.line="",this.isChunked=!1,this.connection="",this.headerSize=0,this.body_bytes=null,this.isUserCall=!1,this.hadError=!1}e.HTTPParser=a,a.encoding="ascii",a.maxHeaderSize=81920,a.REQUEST="REQUEST",a.RESPONSE="RESPONSE";var h=a.kOnHeaders=0,c=a.kOnHeadersComplete=1,u=a.kOnBody=2,f=a.kOnMessageComplete=3;a.prototype[h]=a.prototype[c]=a.prototype[u]=a.prototype[f]=function(){};var l=!0;Object.defineProperty(a,"kOnExecute",{get:function(){return l=!1,4}});var p=e.methods=a.methods=["DELETE","GET","HEAD","POST","PUT","CONNECT","OPTIONS","TRACE","COPY","LOCK","MKCOL","MOVE","PROPFIND","PROPPATCH","SEARCH","UNLOCK","BIND","REBIND","UNBIND","ACL","REPORT","MKACTIVITY","CHECKOUT","MERGE","M-SEARCH","NOTIFY","SUBSCRIBE","UNSUBSCRIBE","PATCH","PURGE","MKCALENDAR","LINK","UNLINK"],d=p.indexOf("CONNECT");a.prototype.reinitialize=a,a.prototype.close=a.prototype.pause=a.prototype.resume=a.prototype.free=function(){},a.prototype._compatMode0_11=!1,a.prototype.getAsyncId=function(){return 0};var _={REQUEST_LINE:!0,RESPONSE_LINE:!0,HEADER:!0};a.prototype.execute=function(e,t,s){if(!(this instanceof a))throw new TypeError("not a HTTPParser");t=t||0,s="number"==typeof s?s:e.length,this.chunk=e,this.offset=t;var r=this.end=t+s;try{for(;this.offset<r&&!this[this.state](););}catch(e){if(this.isUserCall)throw e;return this.hadError=!0,e}return this.chunk=null,s=this.offset-t,_[this.state]&&(this.headerSize+=s,this.headerSize>a.maxHeaderSize)?new Error("max header size exceeded"):s};var g={REQUEST_LINE:!0,RESPONSE_LINE:!0,BODY_RAW:!0};a.prototype.finish=function(){if(!this.hadError)return g[this.state]?void("BODY_RAW"===this.state&&this.userCall()(this[f]())):new Error("invalid state for EOF")},a.prototype.consume=a.prototype.unconsume=a.prototype.getCurrentBuffer=function(){},a.prototype.userCall=function(){this.isUserCall=!0;var e=this;return function(t){return e.isUserCall=!1,t}},a.prototype.nextRequest=function(){this.userCall()(this[f]()),this.reinitialize(this.type)},a.prototype.consumeLine=function(){for(var e=this.end,t=this.chunk,s=this.offset;s<e;s++)if(10===t[s]){var r=this.line+t.toString(a.encoding,this.offset,s);return"\r"===r.charAt(r.length-1)&&(r=r.substr(0,r.length-1)),this.line="",this.offset=s+1,r}this.line+=t.toString(a.encoding,this.offset,this.end),this.offset=this.end};var y=/^([^: \t]+):[ \t]*((?:.*[^ \t])|)/,v=/^[ \t]+(.*[^ \t])/;a.prototype.parseHeader=function(e,t){if(-1!==e.indexOf("\r"))throw b("HPE_LF_EXPECTED");var s=y.exec(e),r=s&&s[1];if(r)t.push(r),t.push(s[2]);else{var n=v.exec(e);n&&t.length&&(t[t.length-1]&&(t[t.length-1]+=" "),t[t.length-1]+=n[1])}};var m=/^([A-Z-]+) ([^ ]+) HTTP\/(\d)\.(\d)$/;a.prototype.REQUEST_LINE=function(){var e=this.consumeLine();if(e){var t=m.exec(e);if(null===t)throw b("HPE_INVALID_CONSTANT");if(this.info.method=this._compatMode0_11?t[1]:p.indexOf(t[1]),-1===this.info.method)throw new Error("invalid request method");this.info.url=t[2],this.info.versionMajor=+t[3],this.info.versionMinor=+t[4],this.body_bytes=0,this.state="HEADER"}};var E=/^HTTP\/(\d)\.(\d) (\d{3}) ?(.*)$/;function b(e){var t=new Error("Parse Error");return t.code=e,t}a.prototype.RESPONSE_LINE=function(){var e=this.consumeLine();if(e){var t=E.exec(e);if(null===t)throw b("HPE_INVALID_CONSTANT");this.info.versionMajor=+t[1],this.info.versionMinor=+t[2];var s=this.info.statusCode=+t[3];this.info.statusMessage=t[4],1!=(s/100|0)&&204!==s&&304!==s||(this.body_bytes=0),this.state="HEADER"}},a.prototype.shouldKeepAlive=function(){if(this.info.versionMajor>0&&this.info.versionMinor>0){if(-1!==this.connection.indexOf("close"))return!1}else if(-1===this.connection.indexOf("keep-alive"))return!1;return!(null===this.body_bytes&&!this.isChunked)},a.prototype.HEADER=function(){var e=this.consumeLine();if(void 0!==e){var t=this.info;if(e)this.parseHeader(e,t.headers);else{for(var s,r,n=t.headers,i=!1,o=!1,h=0;h<n.length;h+=2)switch(n[h].toLowerCase()){case"transfer-encoding":this.isChunked="chunked"===n[h+1].toLowerCase();break;case"content-length":if(s=+n[h+1],i){if(s!==this.body_bytes)throw b("HPE_UNEXPECTED_CONTENT_LENGTH")}else i=!0,this.body_bytes=s;break;case"connection":this.connection+=n[h+1].toLowerCase();break;case"upgrade":o=!0}if(this.isChunked&&i&&(i=!1,this.body_bytes=null),o&&-1!=this.connection.indexOf("upgrade")?t.upgrade=this.type===a.REQUEST||101===t.statusCode:t.upgrade=t.method===d,t.shouldKeepAlive=this.shouldKeepAlive(),2===(r=l?this.userCall()(this[c](t)):this.userCall()(this[c](t.versionMajor,t.versionMinor,t.headers,t.method,t.url,t.statusCode,t.statusMessage,t.upgrade,t.shouldKeepAlive))))return this.nextRequest(),!0;if(this.isChunked&&!r)this.state="BODY_CHUNKHEAD";else{if(r||0===this.body_bytes)return this.nextRequest(),t.upgrade;null===this.body_bytes?this.state="BODY_RAW":this.state="BODY_SIZED"}}}},a.prototype.BODY_CHUNKHEAD=function(){var e=this.consumeLine();void 0!==e&&(this.body_bytes=parseInt(e,16),this.body_bytes?this.state="BODY_CHUNK":this.state="BODY_CHUNKTRAILERS")},a.prototype.BODY_CHUNK=function(){var e=Math.min(this.end-this.offset,this.body_bytes);this.userCall()(this[u](this.chunk,this.offset,e)),this.offset+=e,this.body_bytes-=e,this.body_bytes||(this.state="BODY_CHUNKEMPTYLINE")},a.prototype.BODY_CHUNKEMPTYLINE=function(){var e=this.consumeLine();void 0!==e&&(o.equal(e,""),this.state="BODY_CHUNKHEAD")},a.prototype.BODY_CHUNKTRAILERS=function(){var e=this.consumeLine();void 0!==e&&(e?this.parseHeader(e,this.trailers):(this.trailers.length&&this.userCall()(this[h](this.trailers,"")),this.nextRequest()))},a.prototype.BODY_RAW=function(){var e=this.end-this.offset;this.userCall()(this[u](this.chunk,this.offset,e)),this.offset=this.end},a.prototype.BODY_SIZED=function(){var e=Math.min(this.end-this.offset,this.body_bytes);this.userCall()(this[u](this.chunk,this.offset,e)),this.offset+=e,this.body_bytes-=e,this.body_bytes||this.nextRequest()},["Headers","HeadersComplete","Body","MessageComplete"].forEach((function(e){var t=a["kOn"+e];Object.defineProperty(a.prototype,"on"+e,{get:function(){return this[t]},set:function(e){return this._compatMode0_11=!0,d="CONNECT",this[t]=e}})}))}],["websocket-driver","/lib/websocket/driver/hybi.js",function(e,t,r,n,i){"use strict";var o=s(4),h=s(0),c=a(10),u=a(2),f=a(17),l=a(18),p=function(e,t,s){if(u.apply(this,arguments),this._extensions=new c,this._stage=0,this._masking=this._options.masking,this._protocols=this._options.protocols||[],this._requireMasking=this._options.requireMasking,this._pingCallbacks={},"string"==typeof this._protocols&&(this._protocols=this._protocols.split(/ *, */)),this._request){var r=this._request.headers["sec-websocket-key"],n=this._request.headers["sec-websocket-protocol"],i=this._request.headers["sec-websocket-version"],o=this._protocols;this._headers.set("Upgrade","websocket"),this._headers.set("Connection","Upgrade"),this._headers.set("Sec-WebSocket-Accept",p.generateAccept(r)),void 0!==n&&("string"==typeof n&&(n=n.split(/ *, */)),this.protocol=n.filter((function(e){return o.indexOf(e)>=0}))[0],this.protocol&&this._headers.set("Sec-WebSocket-Protocol",this.protocol)),this.version="hybi-"+i}};h.inherits(p,u),p.mask=function(e,t,s){if(!t||0===t.length)return e;s=s||0;for(var r=0,n=e.length-s;r<n;r++)e[s+r]=e[s+r]^t[r%4];return e},p.generateAccept=function(e){var t=o.createHash("sha1");return t.update(e+p.GUID),t.digest("base64")},p.GUID="258EAFA5-E914-47DA-95CA-C5AB0DC85B11";var d={FIN:128,MASK:128,RSV1:64,RSV2:32,RSV3:16,OPCODE:15,LENGTH:127,OPCODES:{continuation:0,text:1,binary:2,close:8,ping:9,pong:10},OPCODE_CODES:[0,1,2,8,9,10],MESSAGE_OPCODES:[0,1,2],OPENING_OPCODES:[1,2],ERRORS:{normal_closure:1e3,going_away:1001,protocol_error:1002,unacceptable:1003,encoding_error:1007,policy_violation:1008,too_large:1009,extension_error:1010,unexpected_condition:1011},ERROR_CODES:[1e3,1001,1002,1003,1007,1008,1009,1010,1011],DEFAULT_ERROR_CODE:1e3,MIN_RESERVED_ERROR:3e3,MAX_RESERVED_ERROR:4999,UTF8_MATCH:/^([\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})*$/,addExtension:function(e){return this._extensions.add(e),!0},parse:function(e){this._reader.put(e);for(var t=!0;t;)switch(this._stage){case 0:(t=this._reader.read(1))&&this._parseOpcode(t[0]);break;case 1:(t=this._reader.read(1))&&this._parseLength(t[0]);break;case 2:(t=this._reader.read(this._frame.lengthBytes))&&this._parseExtendedLength(t);break;case 3:(t=this._reader.read(4))&&(this._stage=4,this._frame.maskingKey=t);break;case 4:(t=this._reader.read(this._frame.length))&&(this._stage=0,this._emitFrame(t));break;default:t=null}},text:function(e){return!(this.readyState>1)&&this.frame(e,"text")},binary:function(e){return!(this.readyState>1)&&this.frame(e,"binary")},ping:function(e,t){return!(this.readyState>1)&&(e=e||"",t&&(this._pingCallbacks[e]=t),this.frame(e,"ping"))},pong:function(e){return!(this.readyState>1)&&(e=e||"",this.frame(e,"pong"))},close:function(e,t){return e=e||"",t=t||this.ERRORS.normal_closure,this.readyState<=0?(this.readyState=3,this.emit("close",new u.CloseEvent(t,e)),!0):1===this.readyState&&(this.readyState=2,this._extensions.close((function(){this.frame(e,"close",t)}),this),!0)},frame:function(e,t,s){if(this.readyState<=0)return this._queue([e,t,s]);if(this.readyState>2)return!1;e instanceof Array&&(e=new Buffer(e)),"number"==typeof e&&(e=e.toString());var r,n,i=new l,a="string"==typeof e;i.rsv1=i.rsv2=i.rsv3=!1,i.opcode=this.OPCODES[t||(a?"text":"binary")],r=a?new Buffer(e,"utf8"):e,s&&(n=r,(r=new Buffer(2+n.length)).writeUInt16BE(s,0),n.copy(r,2)),i.data=r;var h=function(e){var t=new f;t.final=!0,t.rsv1=e.rsv1,t.rsv2=e.rsv2,t.rsv3=e.rsv3,t.opcode=e.opcode,t.masked=!!this._masking,t.length=e.data.length,t.payload=e.data,t.masked&&(t.maskingKey=o.randomBytes(4)),this._sendFrame(t)};return this.MESSAGE_OPCODES.indexOf(i.opcode)>=0?this._extensions.processOutgoingMessage(i,(function(e,t){if(e)return this._fail("extension_error",e.message);h.call(this,t)}),this):h.call(this,i),!0},_sendFrame:function(e){var t=e.length,s=t<=125?2:t<=65535?4:10,r=s+(e.masked?4:0),n=new Buffer(r+t),i=e.masked?this.MASK:0;n[0]=(e.final?this.FIN:0)|(e.rsv1?this.RSV1:0)|(e.rsv2?this.RSV2:0)|(e.rsv3?this.RSV3:0)|e.opcode,t<=125?n[1]=i|t:t<=65535?(n[1]=126|i,n.writeUInt16BE(t,2)):(n[1]=127|i,n.writeUInt32BE(Math.floor(t/4294967296),2),n.writeUInt32BE(t%4294967296,6)),e.payload.copy(n,r),e.masked&&(e.maskingKey.copy(n,s),p.mask(n,e.maskingKey,r)),this._write(n)},_handshakeResponse:function(){try{var e=this._extensions.generateResponse(this._request.headers["sec-websocket-extensions"])}catch(e){return this._fail("protocol_error",e.message)}e&&this._headers.set("Sec-WebSocket-Extensions",e);var t=["HTTP/1.1 101 Switching Protocols",this._headers.toString(),""];return new Buffer(t.join("\r\n"),"utf8")},_shutdown:function(e,t,s){delete this._frame,delete this._message,this._stage=5;var r=1===this.readyState;this.readyState=2,this._extensions.close((function(){r&&this.frame(t,"close",e),this.readyState=3,s&&this.emit("error",new Error(t)),this.emit("close",new u.CloseEvent(e,t))}),this)},_fail:function(e,t){this.readyState>1||this._shutdown(this.ERRORS[e],t,!0)},_parseOpcode:function(e){var t=[this.RSV1,this.RSV2,this.RSV3].map((function(t){return(e&t)===t})),s=this._frame=new f;return s.final=(e&this.FIN)===this.FIN,s.rsv1=t[0],s.rsv2=t[1],s.rsv3=t[2],s.opcode=e&this.OPCODE,this._stage=1,this._extensions.validFrameRsv(s)?this.OPCODE_CODES.indexOf(s.opcode)<0?this._fail("protocol_error","Unrecognized frame opcode: "+s.opcode):this.MESSAGE_OPCODES.indexOf(s.opcode)<0&&!s.final?this._fail("protocol_error","Received fragmented control frame: opcode = "+s.opcode):this._message&&this.OPENING_OPCODES.indexOf(s.opcode)>=0?this._fail("protocol_error","Received new data frame but previous continuous frame is unfinished"):void 0:this._fail("protocol_error","One or more reserved bits are on: reserved1 = "+(s.rsv1?1:0)+", reserved2 = "+(s.rsv2?1:0)+", reserved3 = "+(s.rsv3?1:0))},_parseLength:function(e){var t=this._frame;if(t.masked=(e&this.MASK)===this.MASK,t.length=e&this.LENGTH,t.length>=0&&t.length<=125){if(this._stage=t.masked?3:4,!this._checkFrameLength())return}else this._stage=2,t.lengthBytes=126===t.length?2:8;if(this._requireMasking&&!t.masked)return this._fail("unacceptable","Received unmasked frame but masking is required")},_parseExtendedLength:function(e){var t=this._frame;if(t.length=this._readUInt(e),this._stage=t.masked?3:4,this.MESSAGE_OPCODES.indexOf(t.opcode)<0&&t.length>125)return this._fail("protocol_error","Received control frame having too long payload: "+t.length);this._checkFrameLength()},_checkFrameLength:function(){return!((this._message?this._message.length:0)+this._frame.length>this._maxLength)||(this._fail("too_large","WebSocket frame length too large"),!1)},_emitFrame:function(e){var t,s,r,n,i,o=this._frame,a=o.payload=p.mask(e,o.maskingKey),h=o.opcode;if(delete this._frame,h===this.OPCODES.continuation){if(!this._message)return this._fail("protocol_error","Received unexpected continuation frame");this._message.pushFrame(o)}if(h!==this.OPCODES.text&&h!==this.OPCODES.binary||(this._message=new l,this._message.pushFrame(o)),o.final&&this.MESSAGE_OPCODES.indexOf(h)>=0)return this._emitMessage(this._message);h===this.OPCODES.close&&(s=a.length>=2?a.readUInt16BE(0):null,r=a.length>2?this._encode(a.slice(2)):null,0!==a.length&&!(null!==s&&s>=this.MIN_RESERVED_ERROR&&s<=this.MAX_RESERVED_ERROR)&&this.ERROR_CODES.indexOf(s)<0&&(s=this.ERRORS.protocol_error),(a.length>125||a.length>2&&!r)&&(s=this.ERRORS.protocol_error),this._shutdown(s||this.DEFAULT_ERROR_CODE,r||"")),h===this.OPCODES.ping&&(this.frame(a,"pong"),this.emit("ping",new u.PingEvent(a.toString()))),h===this.OPCODES.pong&&(i=(n=this._pingCallbacks)[t=this._encode(a)],delete n[t],i&&i(),this.emit("pong",new u.PongEvent(a.toString())))},_emitMessage:function(e){(e=this._message).read(),delete this._message,this._extensions.processIncomingMessage(e,(function(e,t){if(e)return this._fail("extension_error",e.message);var s=t.data;if(t.opcode===this.OPCODES.text&&(s=this._encode(s)),null===s)return this._fail("encoding_error","Could not decode a text frame as UTF-8");this.emit("message",new u.MessageEvent(s))}),this)},_encode:function(e){try{var t=e.toString("binary",0,e.length);if(!this.UTF8_MATCH.test(t))return null}catch(e){}return e.toString("utf8",0,e.length)},_readUInt:function(e){return 2===e.length?e.readUInt16BE(0):4294967296*e.readUInt32BE(0)+e.readUInt32BE(4)}};for(var _ in d)p.prototype[_]=d[_];t.exports=p}],["websocket-extensions","/lib/websocket_extensions.js",function(e,t,s,r,n){"use strict";var i=a(11),o=a(12),h=function(){this._rsv1=this._rsv2=this._rsv3=null,this._byName={},this._inOrder=[],this._sessions=[],this._index={}};h.MESSAGE_OPCODES=[1,2];var c={add:function(e){if("string"!=typeof e.name)throw new TypeError("extension.name must be a string");if("permessage"!==e.type)throw new TypeError('extension.type must be "permessage"');if("boolean"!=typeof e.rsv1)throw new TypeError("extension.rsv1 must be true or false");if("boolean"!=typeof e.rsv2)throw new TypeError("extension.rsv2 must be true or false");if("boolean"!=typeof e.rsv3)throw new TypeError("extension.rsv3 must be true or false");if(this._byName.hasOwnProperty(e.name))throw new TypeError('An extension with name "'+e.name+'" is already registered');this._byName[e.name]=e,this._inOrder.push(e)},generateOffer:function(){var e=[],t=[],s={};return this._inOrder.forEach((function(r){var n=r.createClientSession();if(n){var o=[r,n];e.push(o),s[r.name]=o;var a=n.generateOffer();(a=a?[].concat(a):[]).forEach((function(e){t.push(i.serializeParams(r.name,e))}),this)}}),this),this._sessions=e,this._index=s,t.length>0?t.join(", "):null},activate:function(e){var t=i.parseHeader(e),s=[];t.eachOffer((function(e,t){var r=this._index[e];if(!r)throw new Error('Server sent an extension response for unknown extension "'+e+'"');var n=r[0],o=r[1],a=this._reserved(n);if(a)throw new Error("Server sent two extension responses that use the RSV"+a[0]+' bit: "'+a[1]+'" and "'+n.name+'"');if(!0!==o.activate(t))throw new Error("Server sent unacceptable extension parameters: "+i.serializeParams(e,t));this._reserve(n),s.push(r)}),this),this._sessions=s,this._pipeline=new o(s)},generateResponse:function(e){var t=[],s=[],r=i.parseHeader(e);return this._inOrder.forEach((function(e){var n=r.byName(e.name);if(0!==n.length&&!this._reserved(e)){var o=e.createServerSession(n);o&&(this._reserve(e),t.push([e,o]),s.push(i.serializeParams(e.name,o.generateResponse())))}}),this),this._sessions=t,this._pipeline=new o(t),s.length>0?s.join(", "):null},validFrameRsv:function(e){var t,s={rsv1:!1,rsv2:!1,rsv3:!1};if(h.MESSAGE_OPCODES.indexOf(e.opcode)>=0)for(var r=0,n=this._sessions.length;r<n;r++)t=this._sessions[r][0],s.rsv1=s.rsv1||t.rsv1,s.rsv2=s.rsv2||t.rsv2,s.rsv3=s.rsv3||t.rsv3;return(s.rsv1||!e.rsv1)&&(s.rsv2||!e.rsv2)&&(s.rsv3||!e.rsv3)},processIncomingMessage:function(e,t,s){this._pipeline.processIncomingMessage(e,t,s)},processOutgoingMessage:function(e,t,s){this._pipeline.processOutgoingMessage(e,t,s)},close:function(e,t){if(!this._pipeline)return e.call(t);this._pipeline.close(e,t)},_reserve:function(e){this._rsv1=this._rsv1||e.rsv1&&e.name,this._rsv2=this._rsv2||e.rsv2&&e.name,this._rsv3=this._rsv3||e.rsv3&&e.name},_reserved:function(e){return this._rsv1&&e.rsv1?[1,this._rsv1]:this._rsv2&&e.rsv2?[2,this._rsv2]:!(!this._rsv3||!e.rsv3)&&[3,this._rsv3]}};for(var u in c)h.prototype[u]=c[u];t.exports=h}],["websocket-extensions","/lib/parser.js",function(e,t,s,r,n){"use strict";var i=/([!#\$%&'\*\+\-\.\^_`\|~0-9A-Za-z]+)/,o=/([^!#\$%&'\*\+\-\.\^_`\|~0-9A-Za-z])/g,a=new RegExp(i.source+"(?:=(?:"+i.source+"|"+/"((?:\\[\x00-\x7f]|[^\x00-\x08\x0a-\x1f\x7f"])*)"/.source+"))?"),h=new RegExp(i.source+"(?: *; *"+a.source+")*","g"),c=new RegExp("^"+h.source+"(?: *, *"+h.source+")*$"),u=/^-?(0|[1-9][0-9]*)(\.[0-9]+)?$/,f=Object.prototype.hasOwnProperty,l={parseHeader:function(e){var t=new p;if(""===e||void 0===e)return t;if(!c.test(e))throw new SyntaxError("Invalid Sec-WebSocket-Extensions header: "+e);return e.match(h).forEach((function(e){var s=e.match(new RegExp(a.source,"g")),r=s.shift(),n={};s.forEach((function(e){var t,s=e.match(a),r=s[1];t=void 0!==s[2]?s[2]:void 0===s[3]||s[3].replace(/\\/g,""),u.test(t)&&(t=parseFloat(t)),f.call(n,r)?(n[r]=[].concat(n[r]),n[r].push(t)):n[r]=t}),this),t.push(r,n)}),this),t},serializeParams:function(e,t){var s=[],r=function(e,t){t instanceof Array?t.forEach((function(t){r(e,t)})):!0===t?s.push(e):"number"==typeof t?s.push(e+"="+t):o.test(t)?s.push(e+'="'+t.replace(/"/g,'\\"')+'"'):s.push(e+"="+t)};for(var n in t)r(n,t[n]);return[e].concat(s).join("; ")}},p=function(){this._byName={},this._inOrder=[]};p.prototype.push=function(e,t){f.call(this._byName,e)||(this._byName[e]=[]),this._byName[e].push(t),this._inOrder.push({name:e,params:t})},p.prototype.eachOffer=function(e,t){for(var s=this._inOrder,r=0,n=s.length;r<n;r++)e.call(t,s[r].name,s[r].params)},p.prototype.byName=function(e){return this._byName[e]||[]},p.prototype.toArray=function(){return this._inOrder.slice()},t.exports=l}],["websocket-extensions","/lib/pipeline/index.js",function(e,t,s,r,n){"use strict";var i=a(13),o=a(16),h=function(e){this._cells=e.map((function(e){return new i(e)})),this._stopped={incoming:!1,outgoing:!1}};h.prototype.processIncomingMessage=function(e,t,s){this._stopped.incoming||this._loop("incoming",this._cells.length-1,-1,-1,e,t,s)},h.prototype.processOutgoingMessage=function(e,t,s){this._stopped.outgoing||this._loop("outgoing",0,this._cells.length,1,e,t,s)},h.prototype.close=function(e,t){this._stopped={incoming:!0,outgoing:!0};var s=this._cells.map((function(e){return e.close()}));e&&o.all(s).then((function(){e.call(t)}))},h.prototype._loop=function(e,t,s,r,n,i,o){for(var a=this._cells,h=a.length,c=this;h--;)a[h].pending(e);var u=function(t,n,h){if(t===s)return i.call(o,n,h);a[t][e](n,h,(function(s,n){s&&(c._stopped[e]=!0),u(t+r,s,n)}))};u(t,null,n)},t.exports=h}],["websocket-extensions","/lib/pipeline/cell.js",function(e,t,s,r,n){"use strict";var i=a(14),o=a(16),h=function(e){this._ext=e[0],this._session=e[1],this._functors={incoming:new i(this._session,"processIncomingMessage"),outgoing:new i(this._session,"processOutgoingMessage")}};h.prototype.pending=function(e){var t=this._functors[e];t._stopped||(t.pending+=1)},h.prototype.incoming=function(e,t,s,r){this._exec("incoming",e,t,s,r)},h.prototype.outgoing=function(e,t,s,r){this._exec("outgoing",e,t,s,r)},h.prototype.close=function(){return this._closed=this._closed||new o,this._doClose(),this._closed},h.prototype._exec=function(e,t,s,r,n){this._functors[e].call(t,s,(function(e,t){e&&(e.message=this._ext.name+": "+e.message),r.call(n,e,t),this._doClose()}),this)},h.prototype._doClose=function(){var e=this._functors.incoming,t=this._functors.outgoing;this._closed&&e.pending+t.pending===0&&(this._session&&this._session.close(),this._session=null,this._closed.done())},t.exports=h}],["websocket-extensions","/lib/pipeline/functor.js",function(e,t,s,r,n){"use strict";var i=a(15),o=function(e,t){this._session=e,this._method=t,this._queue=new i(o.QUEUE_SIZE),this._stopped=!1,this.pending=0};o.QUEUE_SIZE=8,o.prototype.call=function(e,t,s,r){if(!this._stopped){var n={error:e,message:t,callback:s,context:r,done:!1},i=!1,o=this;if(this._queue.push(n),n.error)return n.done=!0,this._stop(),this._flushQueue();var a=function(e,t){i^(i=!0)&&(e?(o._stop(),n.error=e,n.message=null):n.message=t,n.done=!0,o._flushQueue())};try{this._session[this._method](t,a)}catch(e){a(e)}}},o.prototype._stop=function(){this.pending=this._queue.length,this._stopped=!0},o.prototype._flushQueue=function(){for(var e,t=this._queue;t.length>0&&t.peek().done;)(e=t.shift()).error?(this.pending=0,t.clear()):this.pending-=1,e.callback.call(e.context,e.error,e.message)},t.exports=o}],["websocket-extensions","/lib/pipeline/ring_buffer.js",function(e,t,s,r,n){"use strict";var i=function(e){this._bufferSize=e,this.clear()};i.prototype.clear=function(){this._buffer=new Array(this._bufferSize),this._ringOffset=0,this._ringSize=this._bufferSize,this._head=0,this._tail=0,this.length=0},i.prototype.push=function(e){var t=!1,s=!1;this._ringSize<this._bufferSize?t=0===this._tail:this._ringOffset===this._ringSize&&(t=!0,s=0===this._tail),t&&(this._tail=this._bufferSize,this._buffer=this._buffer.concat(new Array(this._bufferSize)),this._bufferSize=this._buffer.length,s&&(this._ringSize=this._bufferSize)),this._buffer[this._tail]=e,this.length+=1,this._tail<this._ringSize&&(this._ringOffset+=1),this._tail=(this._tail+1)%this._bufferSize},i.prototype.peek=function(){if(0!==this.length)return this._buffer[this._head]},i.prototype.shift=function(){if(0!==this.length){var e=this._buffer[this._head];return this._buffer[this._head]=void 0,this.length-=1,this._ringOffset-=1,0===this._ringOffset&&this.length>0?(this._head=this._ringSize,this._ringOffset=this.length,this._ringSize=this._bufferSize):this._head=(this._head+1)%this._ringSize,e}},t.exports=i}],["websocket-extensions","/lib/pipeline/pledge.js",function(e,t,s,r,n){"use strict";var i=a(15),o=function(){this._complete=!1,this._callbacks=new i(o.QUEUE_SIZE)};o.QUEUE_SIZE=4,o.all=function(e){var t=new o,s=e.length,r=s;for(0===s&&t.done();r--;)e[r].then((function(){0===(s-=1)&&t.done()}));return t},o.prototype.then=function(e){this._complete?e():this._callbacks.push(e)},o.prototype.done=function(){this._complete=!0;for(var e,t=this._callbacks;e=t.shift();)e()},t.exports=o}],["websocket-driver","/lib/websocket/driver/hybi/frame.js",function(e,t,s,r,n){"use strict";var i=function(){},o={final:!1,rsv1:!1,rsv2:!1,rsv3:!1,opcode:null,masked:!1,maskingKey:null,lengthBytes:1,length:0,payload:null};for(var a in o)i.prototype[a]=o[a];t.exports=i}],["websocket-driver","/lib/websocket/driver/hybi/message.js",function(e,t,s,r,n){"use strict";var i=function(){this.rsv1=!1,this.rsv2=!1,this.rsv3=!1,this.opcode=null,this.length=0,this._chunks=[]},o={read:function(){if(this.data)return this.data;this.data=new Buffer(this.length);for(var e=0,t=0,s=this._chunks.length;t<s;t++)this._chunks[t].copy(this.data,e),e+=this._chunks[t].length;return this.data},pushFrame:function(e){this.rsv1=this.rsv1||e.rsv1,this.rsv2=this.rsv2||e.rsv2,this.rsv3=this.rsv3||e.rsv3,null===this.opcode&&(this.opcode=e.opcode),this._chunks.push(e.payload),this.length+=e.length}};for(var a in o)i.prototype[a]=o[a];t.exports=i}],["websocket-driver","/lib/websocket/driver/proxy.js",function(e,t,r,n,i){"use strict";var o=s(3).Stream,h=s(5),c=s(0),u=a(2),f=a(4),l=a(7),p={"ws:":80,"wss:":443},d=function(e,t,s){this._client=e,this._http=new l("response"),this._origin="object"==typeof e.url?e.url:h.parse(e.url),this._url="object"==typeof t?t:h.parse(t),this._options=s||{},this._state=0,this.readable=this.writable=!0,this._paused=!1,this._headers=new f,this._headers.set("Host",this._origin.host),this._headers.set("Connection","keep-alive"),this._headers.set("Proxy-Connection","keep-alive");var r=this._url.auth&&new Buffer(this._url.auth,"utf8").toString("base64");r&&this._headers.set("Proxy-Authorization","Basic "+r)};c.inherits(d,o);var _={setHeader:function(e,t){return 0===this._state&&(this._headers.set(e,t),!0)},start:function(){if(0!==this._state)return!1;this._state=1;var e=this._origin,t=e.port||p[e.protocol],s=["CONNECT "+e.hostname+":"+t+" HTTP/1.1",this._headers.toString(),""];return this.emit("data",new Buffer(s.join("\r\n"),"utf8")),!0},pause:function(){this._paused=!0},resume:function(){this._paused=!1,this.emit("drain")},write:function(e){if(!this.writable)return!1;if(this._http.parse(e),!this._http.isComplete())return!this._paused;if(this.statusCode=this._http.statusCode,this.headers=this._http.headers,200===this.statusCode)this.emit("connect",new u.ConnectEvent);else{var t="Can't establish a connection to the server at "+this._origin.href;this.emit("error",new Error(t))}return this.end(),!this._paused},end:function(e){this.writable&&(void 0!==e&&this.write(e),this.readable=this.writable=!1,this.emit("close"),this.emit("end"))},destroy:function(){this.end()}};for(var g in _)d.prototype[g]=_[g];t.exports=d}],["websocket-driver","/lib/websocket/driver/server.js",function(e,t,r,n,i){"use strict";var o=s(0),h=a(7),c=a(2),u=a(21),f=a(22),l=a(9),p=function(e){c.call(this,null,null,e),this._http=new h("request")};o.inherits(p,c);var d={EVENTS:["open","message","error","close"],_bindEventListeners:function(){this.messages.on("error",(function(){})),this.on("error",(function(){}))},parse:function(e){if(this._delegate)return this._delegate.parse(e);if(this._http.parse(e),this._http.isComplete()){this.method=this._http.method,this.url=this._http.url,this.headers=this._http.headers,this.body=this._http.body;var t=this;this._delegate=p.http(this,this._options),this._delegate.messages=this.messages,this._delegate.io=this.io,this._open(),this.EVENTS.forEach((function(e){this._delegate.on(e,(function(s){t.emit(e,s)}))}),this),this.protocol=this._delegate.protocol,this.version=this._delegate.version,this.parse(this._http.body),this.emit("connect",new c.ConnectEvent)}},_open:function(){this.__queue.forEach((function(e){this._delegate[e[0]].apply(this._delegate,e[1])}),this),this.__queue=[]}};for(var _ in["addExtension","setHeader","start","frame","text","binary","ping","close"].forEach((function(e){d[e]=function(){return this._delegate?this._delegate[e].apply(this._delegate,arguments):(this.__queue.push([e,arguments]),!0)}})),d)p.prototype[_]=d[_];p.isSecureRequest=function(e){if(e.connection&&void 0!==e.connection.authorized)return!0;if(e.socket&&e.socket.secure)return!0;var t=e.headers;return!!t&&("on"===t.https||("on"===t["x-forwarded-ssl"]||("https"===t["x-forwarded-scheme"]||"https"===t["x-forwarded-proto"])))},p.determineUrl=function(e){return(this.isSecureRequest(e)?"wss:":"ws:")+"//"+e.headers.host+e.url},p.http=function(e,t){void 0===(t=t||{}).requireMasking&&(t.requireMasking=!0);var s=e.headers,r=this.determineUrl(e);return s["sec-websocket-version"]?new l(e,r,t):s["sec-websocket-key1"]?new f(e,r,t):new u(e,r,t)},t.exports=p}],["websocket-driver","/lib/websocket/driver/draft75.js",function(e,t,r,n,i){"use strict";var o=a(2),h=function(e,t,s){o.apply(this,arguments),this._stage=0,this.version="hixie-75",this._headers.set("Upgrade","WebSocket"),this._headers.set("Connection","Upgrade"),this._headers.set("WebSocket-Origin",this._request.headers.origin),this._headers.set("WebSocket-Location",this.url)};s(0).inherits(h,o);var c={close:function(){return 3!==this.readyState&&(this.readyState=3,this.emit("close",new o.CloseEvent(null,null)),!0)},parse:function(e){this.readyState>1||(this._reader.put(e),this._reader.eachByte((function(e){var t;switch(this._stage){case-1:this._body.push(e),this._sendHandshakeBody();break;case 0:this._parseLeadingByte(e);break;case 1:if(this._length=(127&e)+128*this._length,this._closing&&0===this._length)return this.close();128!=(128&e)&&(0===this._length?this._stage=0:(this._skipped=0,this._stage=2));break;case 2:if(255===e)this._stage=0,t=new Buffer(this._buffer).toString("utf8",0,this._buffer.length),this.emit("message",new o.MessageEvent(t));else if(this._length)this._skipped+=1,this._skipped===this._length&&(this._stage=0);else if(this._buffer.push(e),this._buffer.length>this._maxLength)return this.close()}}),this))},frame:function(e){if(0===this.readyState)return this._queue([e]);if(this.readyState>1)return!1;"string"!=typeof e&&(e=e.toString());var t=new Buffer(e,"utf8"),s=new Buffer(t.length+2);return s[0]=0,s[t.length+1]=255,t.copy(s,1),this._write(s),!0},_handshakeResponse:function(){var e=["HTTP/1.1 101 Web Socket Protocol Handshake",this._headers.toString(),""];return new Buffer(e.join("\r\n"),"utf8")},_parseLeadingByte:function(e){128==(128&e)?(this._length=0,this._stage=1):(delete this._length,delete this._skipped,this._buffer=[],this._stage=2)}};for(var u in c)h.prototype[u]=c[u];t.exports=h}],["websocket-driver","/lib/websocket/driver/draft76.js",function(e,t,r,n,i){"use strict";var o=a(2),h=a(21),c=s(4),u=s(0),f=function(e){return parseInt(e.match(/[0-9]/g).join(""),10)},l=function(e){return e.match(/ /g).length},p=function(e,t,s){h.apply(this,arguments),this._stage=-1,this._body=[],this.version="hixie-76",this._headers.clear(),this._headers.set("Upgrade","WebSocket"),this._headers.set("Connection","Upgrade"),this._headers.set("Sec-WebSocket-Origin",this._request.headers.origin),this._headers.set("Sec-WebSocket-Location",this.url)};u.inherits(p,h);var d={BODY_SIZE:8,start:function(){return!!h.prototype.start.call(this)&&(this._started=!0,this._sendHandshakeBody(),!0)},close:function(){return 3!==this.readyState&&(this._write(new Buffer([255,0])),this.readyState=3,this.emit("close",new o.CloseEvent(null,null)),!0)},_handshakeResponse:function(){var e=(o=this._request.headers)["sec-websocket-key1"],t=f(e),s=l(e),r=o["sec-websocket-key2"],n=f(r),i=l(r);if(t%s!=0||n%i!=0)return this.emit("error",new Error("Client sent invalid Sec-WebSocket-Key headers")),this.close(),null;this._keyValues=[t/s,n/i];var o=["HTTP/1.1 101 WebSocket Protocol Handshake",this._headers.toString(),""];return new Buffer(o.join("\r\n"),"binary")},_handshakeSignature:function(){if(this._body.length<this.BODY_SIZE)return null;var e=c.createHash("md5"),t=new Buffer(8+this.BODY_SIZE);return t.writeUInt32BE(this._keyValues[0],0),t.writeUInt32BE(this._keyValues[1],4),new Buffer(this._body).copy(t,8,0,this.BODY_SIZE),e.update(t),new Buffer(e.digest("binary"),"binary")},_sendHandshakeBody:function(){if(this._started){var e=this._handshakeSignature();e&&(this._write(e),this._stage=0,this._open(),this._body.length>this.BODY_SIZE&&this.parse(this._body.slice(this.BODY_SIZE)))}},_parseLeadingByte:function(e){if(255!==e)return h.prototype._parseLeadingByte.call(this,e);this._closing=!0,this._length=0,this._stage=1}};for(var _ in d)p.prototype[_]=d[_];t.exports=p}],["faye-websocket","/lib/faye/websocket/api.js",function(e,t,r,n,i){var o=s(3).Stream,h=s(0),c=a(1),u=a(24),f=a(25),l=function(e){e=e||{},c.validateOptions(e,["headers","extensions","maxLength","ping","proxy","tls","ca"]),this.readable=this.writable=!0;var t=e.headers;if(t)for(var s in t)this._driver.setHeader(s,t[s]);var r=e.extensions;r&&[].concat(r).forEach(this._driver.addExtension,this._driver),this._ping=e.ping,this._pingId=0,this.readyState=l.CONNECTING,this.bufferedAmount=0,this.protocol="",this.url=this._driver.url,this.version=this._driver.version;var n=this;this._driver.on("open",(function(e){n._open()})),this._driver.on("message",(function(e){n._receiveMessage(e.data)})),this._driver.on("close",(function(e){n._beginClose(e.reason,e.code)})),this._driver.on("error",(function(e){n._emitError(e.message)})),this.on("error",(function(){})),this._driver.messages.on("drain",(function(){n.emit("drain")})),this._ping&&(this._pingTimer=setInterval((function(){n._pingId+=1,n.ping(n._pingId.toString())}),1e3*this._ping)),this._configureStream(),this._proxy||(this._stream.pipe(this._driver.io),this._driver.io.pipe(this._stream))};h.inherits(l,o),l.CONNECTING=0,l.OPEN=1,l.CLOSING=2,l.CLOSED=3,l.CLOSE_TIMEOUT=3e4;var p={write:function(e){return this.send(e)},end:function(e){void 0!==e&&this.send(e),this.close()},pause:function(){return this._driver.messages.pause()},resume:function(){return this._driver.messages.resume()},send:function(e){return!(this.readyState>l.OPEN)&&(e instanceof Buffer||(e=String(e)),this._driver.messages.write(e))},ping:function(e,t){return!(this.readyState>l.OPEN)&&this._driver.ping(e,t)},close:function(e,t){if(void 0===e&&(e=1e3),void 0===t&&(t=""),1e3!==e&&(e<3e3||e>4999))throw new Error("Failed to execute 'close' on WebSocket: The code must be either 1000, or between 3000 and 4999. "+e+" is neither.");this.readyState!==l.CLOSED&&(this.readyState=l.CLOSING);var s=this;this._closeTimer=setTimeout((function(){s._beginClose("",1006)}),l.CLOSE_TIMEOUT),this._driver.close(t,e)},_configureStream:function(){var e=this;this._stream.setTimeout(0),this._stream.setNoDelay(!0),["close","end"].forEach((function(t){this._stream.on(t,(function(){e._finalizeClose()}))}),this),this._stream.on("error",(function(t){e._emitError("Network error: "+e.url+": "+t.message),e._finalizeClose()}))},_open:function(){if(this.readyState===l.CONNECTING){this.readyState=l.OPEN,this.protocol=this._driver.protocol||"";var e=new f("open");e.initEvent("open",!1,!1),this.dispatchEvent(e)}},_receiveMessage:function(e){if(this.readyState>l.OPEN)return!1;this.readable&&this.emit("data",e);var t=new f("message",{data:e});t.initEvent("message",!1,!1),this.dispatchEvent(t)},_emitError:function(e){if(!(this.readyState>=l.CLOSING)){var t=new f("error",{message:e});t.initEvent("error",!1,!1),this.dispatchEvent(t)}},_beginClose:function(e,t){this.readyState!==l.CLOSED&&(this.readyState=l.CLOSING,this._closeParams=[e,t],this._stream&&(this._stream.destroy(),this._stream.readable||this._finalizeClose()))},_finalizeClose:function(){if(this._closeTimer&&clearTimeout(this._closeTimer),this.readyState!==l.CLOSED){this.readyState=l.CLOSED,this._pingTimer&&clearInterval(this._pingTimer),this._stream&&this._stream.end(),this.readable&&this.emit("end"),this.readable=this.writable=!1;var e=this._closeParams?this._closeParams[0]:"",t=this._closeParams?this._closeParams[1]:1006,s=new f("close",{code:t,reason:e});s.initEvent("close",!1,!1),this.dispatchEvent(s)}}};for(var d in p)l.prototype[d]=p[d];for(var _ in u)l.prototype[_]=u[_];t.exports=l}],["faye-websocket","/lib/faye/websocket/api/event_target.js",function(e,t,s,r,n){var i=a(25),o={onopen:null,onmessage:null,onerror:null,onclose:null,addEventListener:function(e,t,s){this.on(e,t)},removeEventListener:function(e,t,s){this.removeListener(e,t)},dispatchEvent:function(e){e.target=e.currentTarget=this,e.eventPhase=i.AT_TARGET,this["on"+e.type]&&this["on"+e.type](e),this.emit(e.type,e)}};t.exports=o}],["faye-websocket","/lib/faye/websocket/api/event.js",function(e,t,s,r,n){var i=function(e,t){for(var s in this.type=e,t)this[s]=t[s]};i.prototype.initEvent=function(e,t,s){this.type=e,this.bubbles=t,this.cancelable=s},i.prototype.stopPropagation=function(){},i.prototype.preventDefault=function(){},i.CAPTURING_PHASE=1,i.AT_TARGET=2,i.BUBBLING_PHASE=3,t.exports=i}],["faye-websocket","/lib/faye/websocket/client.js",function(e,t,r,n,i){var o=s(0),h=s(16),c=s(17),u=s(5),f=a(1),l=a(23),p=(a(25),{"http:":80,"https:":443,"ws:":80,"wss:":443}),d=["https:","wss:"],_=function(e,t,s){s=s||{},this.url=e,this._driver=f.client(this.url,{maxLength:s.maxLength,protocols:t}),["open","error"].forEach((function(e){this._driver.on(e,(function(){v.headers=v._driver.headers,v.statusCode=v._driver.statusCode}))}),this);var r=s.proxy||{},n=u.parse(r.origin||this.url),i=n.port||p[n.protocol],o=d.indexOf(n.protocol)>=0,a=function(){v._onConnect()},_=s.net||{},g=s.tls||{},y=r.origin?r.tls||{}:g,v=this;_.host=y.host=n.hostname,_.port=y.port=i,g.ca=g.ca||s.ca,y.servername=y.servername||n.hostname,this._stream=o?c.connect(y,a):h.connect(_,a),r.origin&&this._configureProxy(r,g),l.call(this,s)};o.inherits(_,l),_.prototype._onConnect=function(){(this._proxy||this._driver).start()},_.prototype._configureProxy=function(e,t){var s,r=u.parse(this.url),n=d.indexOf(r.protocol)>=0,i=this;if(this._proxy=this._driver.proxy(e.origin),e.headers)for(s in e.headers)this._proxy.setHeader(s,e.headers[s]);this._proxy.pipe(this._stream,{end:!1}),this._stream.pipe(this._proxy),this._proxy.on("connect",(function(){if(n){var e={socket:i._stream,servername:r.hostname};for(s in t)e[s]=t[s];i._stream=c.connect(e),i._configureStream()}i._driver.io.pipe(i._stream),i._stream.pipe(i._driver.io),i._driver.start()})),this._proxy.on("error",(function(e){i._driver.emit("error",e)}))},t.exports=_}],["faye-websocket","/lib/faye/eventsource.js",function(e,t,r,n,i){var o=s(3).Stream,h=s(0),c=a(1),u=a(4),f=a(23),l=a(24),p=a(25),d=function(e,t,s){this.writable=!0,s=s||{},this._stream=t.socket,this._ping=s.ping||this.DEFAULT_PING,this._retry=s.retry||this.DEFAULT_RETRY;var r=c.isSecureRequest(e)?"https:":"http:";this.url=r+"//"+e.headers.host+e.url,this.lastEventId=e.headers["last-event-id"]||"",this.readyState=f.CONNECTING;var n=new u,i=this;if(s.headers)for(var o in s.headers)n.set(o,s.headers[o]);if(this._stream&&this._stream.writable){process.nextTick((function(){i._open()})),this._stream.setTimeout(0),this._stream.setNoDelay(!0);var a="HTTP/1.1 200 OK\r\nContent-Type: text/event-stream\r\nCache-Control: no-cache, no-store\r\nConnection: close\r\n"+n.toString()+"\r\nretry: "+Math.floor(1e3*this._retry)+"\r\n\r\n";this._write(a),this._stream.on("drain",(function(){i.emit("drain")})),this._ping&&(this._pingTimer=setInterval((function(){i.ping()}),1e3*this._ping)),["error","end"].forEach((function(e){i._stream.on(e,(function(){i.close()}))}))}};h.inherits(d,o),d.isEventSource=function(e){return"GET"===e.method&&(e.headers.accept||"").split(/\s*,\s*/).indexOf("text/event-stream")>=0};var _={DEFAULT_PING:10,DEFAULT_RETRY:5,_write:function(e){if(!this.writable)return!1;try{return this._stream.write(e,"utf8")}catch(e){return!1}},_open:function(){if(this.readyState===f.CONNECTING){this.readyState=f.OPEN;var e=new p("open");e.initEvent("open",!1,!1),this.dispatchEvent(e)}},write:function(e){return this.send(e)},end:function(e){void 0!==e&&this.write(e),this.close()},send:function(e,t){if(this.readyState>f.OPEN)return!1;e=String(e).replace(/(\r\n|\r|\n)/g,"$1data: ");var s="";return(t=t||{}).event&&(s+="event: "+t.event+"\r\n"),t.id&&(s+="id: "+t.id+"\r\n"),s+="data: "+e+"\r\n\r\n",this._write(s)},ping:function(){return this._write(":\r\n\r\n")},close:function(){if(this.readyState>f.OPEN)return!1;this.readyState=f.CLOSED,this.writable=!1,this._pingTimer&&clearInterval(this._pingTimer),this._stream&&this._stream.end();var e=new p("close");return e.initEvent("close",!1,!1),this.dispatchEvent(e),!0}};for(var g in _)d.prototype[g]=_[g];for(var y in l)d.prototype[y]=l[y];t.exports=d}]],o=[];function a(s){if(s>>>0!==s||s>i.length)return function(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}(s);for(;o.length<=s;)o.push(null);var a=o[s];if(a)return a.exports;var h=i[s],c=h[0],u=h[1],f=h[2],l=t,p=e;0!==s&&(p={id:"/"+c+u,exports:l={},parent:e.parent,filename:e.filename,loaded:!1,children:e.children,paths:e.paths}),o[s]=p;try{f.call(l,l,p,r,n,void 0)}catch(e){throw o[s]=null,e}return i[s]=null,0!==s&&(p.loaded=!0),p.exports}a(0)}).call(this,s(14)(e),"/index.js","/")},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){e.exports=require("assert")},function(e,t){e.exports=require("net")},function(e,t){e.exports=require("tls")},function(e,t,s){"use strict";const r=s(1),n=s(2),i=s(7),o=s(6),a=s(8);e.exports=class extends n{constructor(e={}){super(),r(!e.protocols||Array.isArray(e.protocols)),this.protocols=e.protocols||void 0,this.sockets=new Set,this.channels=new Map,this.mounts=[],this.mounted=!1}handleSocket(e){this.add(e),e.on("close",()=>{this.remove(e)}),this.emit("socket",e);for(const t of this.mounts)t.emit("socket",e)}mount(e){r(!e.mounted),e.mounted=!0,e.sockets=this.sockets,e.channels=this.channels,this.mounts.push(e)}async open(){}async close(){if(!this.mounted)for(const e of this.sockets)e.destroy()}attach(e){const t=(e,t,s)=>{if(!t.remoteAddress)return void t.destroy();if(!o.isWebSocket(e))return void t.destroy();const r=new o(e,t,s,this.protocols),n=a.accept(this,e,t,r);this.handleSocket(n)};return e.on("upgrade",(e,s,r)=>{try{t(e,s,r)}catch(e){this.emit("error",e)}}),this}add(e){this.sockets.add(e)}remove(e){for(const t of e.channels)this.leave(e,t);r(this.sockets.delete(e))}join(e,t){if(e.channels.has(t))return!1;return this.channels.has(t)||this.channels.set(t,new Set),this.channels.get(t).add(e),e.channels.add(t),!0}leave(e,t){if(!e.channels.has(t))return!1;const s=this.channels.get(t);return r(s),r(s.delete(e)),0===s.size&&this.channels.delete(t),e.channels.delete(t),!0}channel(e){const t=this.channels.get(e);return t?(r(t.size>0),t):null}event(e){r(e.length>0,"Event must be present."),r("string"==typeof e[0],"Event must be a string.");const t=new i;return t.type=i.types.EVENT,t.setData(e),t}to(e,...t){const s=this.channels.get(e);if(!s)return;r(s.size>0);const n=this.event(t);for(const e of s)e.sendPacket(n)}all(...e){const t=this.event(e);for(const e of this.sockets)e.sendPacket(t)}static attach(e,t){return new this(t).attach(e)}static createServer(e){return new this(e)}}},function(e,t,s){"use strict";const r=s(1),n=s(5);t.parseURL=function(e){-1===e.indexOf("://")&&(e=`ws://${e}`);const t=n.parse(e);if("http:"!==t.protocol&&"https:"!==t.protocol&&"ws:"!==t.protocol&&"wss:"!==t.protocol)throw new Error("Invalid protocol for websocket URL.");if(!t.hostname)throw new Error("Malformed URL.");const s=t.hostname;let i=80,o=!1;return"https:"!==t.protocol&&"wss:"!==t.protocol||(i=443,o=!0),t.port&&(i=parseInt(t.port,10),r((65535&i)===i),r(0!==i)),[i,s,o]}},function(e,t,s){"use strict";
  163. /*!
  164. * parser.js - packet parser
  165. * Copyright (c) 2017, Christopher Jeffrey (MIT License).
  166. * https://github.com/chjj
  167. */const r=s(1),n=s(2),i=s(9),o=1e8;e.exports=class extends n{constructor(){super()}error(e){this.emit("error",new Error(e))}feedBinary(e){if(r(Buffer.isBuffer(e)),e.length>o)return void this.error("Frame too large.");let t;try{t=i.fromRaw(e)}catch(e){return void this.emit("error",e)}this.emit("frame",t)}feedString(e){if(r("string"==typeof e),Buffer.byteLength(e,"utf8")>o)return void this.error("Frame too large.");let t;try{t=i.fromString(e)}catch(e){return void this.emit("error",e)}this.emit("frame",t)}}},function(e,t,s){"use strict";e.exports={1e3:"NORMAL_CLOSURE",1001:"GOING_AWAY",1002:"PROTOCOL_ERROR",1003:"UNSUPPORTED_DATA",1004:"RESERVED",1005:"NO_STATUS_RECVD",1006:"ABNORMAL_CLOSURE",1007:"INVALID_FRAME_PAYLOAD_DATA",1008:"POLICY_VIOLATION",1009:"MESSAGE_TOO_BIG",1010:"MISSING_EXTENSION",1011:"INTERNAL_ERROR",1012:"SERVICE_RESTART",1013:"TRY_AGAIN_LATER",1014:"BAD_GATEWAY",1015:"TLS_HANDSHAKE"}},function(e,t,s){"use strict";e.exports={connect:!0,connect_error:!0,connect_timeout:!0,connecting:!0,disconnect:!0,error:!0,reconnect:!0,reconnect_attempt:!0,reconnect_failed:!0,reconnect_error:!0,reconnecting:!0,ping:!0,pong:!0}},function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const uuid=__webpack_require__(24);function rpcHooker(e,t,s=!0){const r=t.name,n=[...t.publicRPCs(),...t.localRPCs()],i=s?"-"+uuid().substr(0,4):"";return n.map(e=>exports.rpcToRpcinfo(e,r)).map(t=>{const s=t;switch(s.uniqueName=t.name+i,t.type){case"Hook":e.hook(s.uniqueName,t.generator(e));break;case"Unhook":e.hook(s.uniqueName,t.unhook);break;case"Call":e.hook(s.uniqueName,t.call)}return e.on("close",()=>e.unhook(t.name)),s})}exports.rpcToRpcinfo=(e,t)=>{switch(e.type){case"Call":return{owner:t,argNames:extractArgs(e.call),type:e.type,name:e.name,call:e.call};case"Unhook":return{owner:t,argNames:extractArgs(e.unhook),type:e.type,name:e.name,unhook:e.unhook};case"Hook":const s=hookGenerator(e);return{owner:t,argNames:extractArgs(s(void 0)),type:e.type,name:e.name,unhook:e.unhook,generator:s}}},exports.rpcHooker=rpcHooker;const hookGenerator=rpc=>{const argsArr=extractArgs(rpc.clbk);argsArr.pop();const args=argsArr.join(",");return eval("(socket) => async ("+args+") => { \n const res = await rpc.clbk("+args+(0!==args.length?",":"")+" (x) => {\n socket.call(res.uid, x)\n })\n if(res.result == 'Success'){\n socket.on('close', async () => {\n const unhookRes = await rpc.unhook(res.uid)\n console.log(\"Specific close handler for\", rpc.name, res.uid, unhookRes)\n })\n\n }\n return res\n }")},extractArgs=e=>{let t=String(e),s=t.substr(0,t.indexOf(")"));return(s=s.substr(t.indexOf("(")+1)).split(",")}},function(e,t,s){var r=s(25),n=s(26);e.exports=function(e,t,s){var i=t&&s||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||r)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var a=0;a<16;++a)t[i+a]=o[a];return t||n(o)}},function(e,t,s){var r=s(4);e.exports=function(){return r.randomBytes(16)}},function(e,t){for(var s=[],r=0;r<256;++r)s[r]=(r+256).toString(16).substr(1);e.exports=function(e,t){var r=t||0,n=s;return[n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]]].join("")}}]));