diff --git a/dist/ChabokSDKWorker.js b/dist/ChabokSDKWorker.js index a408cd3..b3a7814 100644 --- a/dist/ChabokSDKWorker.js +++ b/dist/ChabokSDKWorker.js @@ -1,3 +1,3 @@ -/*! chabokpush - 1.0.2 | (c) 2017, 2018 ADP digital | ISC | http://chabokpush.com/ */ +/*! chabokpush - 1.0.3 | (c) 2017, 2018 ADP digital | ISC | http://chabokpush.com/ */ !function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("chabokpush",[],n):"object"==typeof exports?exports.chabokpush=n():t.chabokpush=n()}("undefined"!=typeof self?self:this,function(){return function(t){function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var e={};return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=125)}({125:function(t,n,e){"use strict";self.addEventListener("push",function(t){if(t.data.json()){var n=t.data.json();n.silent||(n.clickUrl&&(n.data=n.data||{},n.data.clickUrl=n.clickUrl),t.waitUntil(self.registration.showNotification(n.title,n)))}}),self.addEventListener("pushsubscriptionchange",function(t){var n=t.oldSubscription.options;t.waitUntil(self.registration.pushManager.subscribe(n).then(function(t){}))}),self.addEventListener("notificationclick",function(t){var n="https://chabokpush.com";t&&t.notification&&t.notification.data&&t.notification.data.clickUrl&&(n=t.notification.data.clickUrl),t.notification.close(),t.waitUntil(self.clients.matchAll({type:"window"}).then(function(t){for(var e=0;e1)for(var n=1;n0&&this._events[t].length>i&&(this._events[t].warned=!0,console.trace),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function n(){this.removeListener(t,n),i||(i=!0,e.apply(this,arguments))}if(!r(e))throw TypeError("listener must be a function");var i=!1;return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var n,i,s,a;if(!r(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],s=n.length,i=-1,n===e||r(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(n)){for(a=s;a-- >0;)if(n[a]===e||n[a].listener&&n[a].listener===e){i=a;break}if(i<0)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],r(n))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){return this._events&&this._events[t]?r(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(r(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e,n){"use strict";function r(t){if(!(this instanceof r))return new r(t);c.call(this,t),l.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",i)}function i(){this.allowHalfOpen||this._writableState.ended||s(o,this)}function o(t){t.end()}var s=n(7),a=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};t.exports=r;var u=n(8);u.inherits=n(3);var c=n(23),l=n(27);u.inherits(r,c);for(var f=a(l.prototype),h=0;h=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|t}function g(t){return+t!=t&&(t=0),o.alloc(+t)}function b(t,e){if(o.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Y(t).length;default:if(r)return H(t).length;e=(""+e).toLowerCase(),r=!0}}function m(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,e>>>=0,n<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return R(this,e,n);case"latin1":case"binary":return C(this,e,n);case"base64":return T(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function y(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function v(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=o.from(e,r)),o.isBuffer(e))return 0===e.length?-1:w(t,e,n,r,i);if("number"==typeof e)return e&=255,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):w(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function w(t,e,n,r,i){function o(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}var s=1,a=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,n/=2}var c;if(i){var l=-1;for(c=n;ca&&(n=a-u),c=n;c>=0;c--){for(var f=!0,h=0;hi&&(r=i):r=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s239?4:o>223?3:o>191?2:1;if(i+a<=n){var u,c,l,f;switch(a){case 1:o<128&&(s=o);break;case 2:u=t[i+1],128==(192&u)&&(f=(31&o)<<6|63&u)>127&&(s=f);break;case 3:u=t[i+1],c=t[i+2],128==(192&u)&&128==(192&c)&&(f=(15&o)<<12|(63&u)<<6|63&c)>2047&&(f<55296||f>57343)&&(s=f);break;case 4:u=t[i+1],c=t[i+2],l=t[i+3],128==(192&u)&&128==(192&c)&&128==(192&l)&&(f=(15&o)<<18|(63&u)<<12|(63&c)<<6|63&l)>65535&&f<1114112&&(s=f)}}null===s?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),i+=a}return O(r)}function O(t){var e=t.length;if(e<=Z)return String.fromCharCode.apply(String,t);for(var n="",r=0;rr)&&(n=r);for(var i="",o=e;on)throw new RangeError("Trying to access beyond buffer length")}function L(t,e,n,r,i,s){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function N(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);i>>8*(r?i:1-i)}function U(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);i>>8*(r?i:3-i)&255}function B(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function D(t,e,n,r,i){return i||B(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),J.write(t,e,n,r,23,4),n+4}function q(t,e,n,r,i){return i||B(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),J.write(t,e,n,r,52,8),n+8}function F(t){if(t=W(t).replace(tt,""),t.length<2)return"";for(;t.length%4!=0;)t+="=";return t}function W(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function K(t){return t<16?"0"+t.toString(16):t.toString(16)}function H(t,e){e=e||1/0;for(var n,r=t.length,i=null,o=[],s=0;s55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function z(t){for(var e=[],n=0;n>8,i=n%256,o.push(i),o.push(r);return o}function Y(t){return X.toByteArray(F(t))}function V(t,e,n,r){for(var i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function $(t){return t!==t}/*! * The buffer module from node.js, for the browser. * @@ -11,5 +11,5 @@ var X=n(81),J=n(82),Q=n(24);e.Buffer=o,e.SlowBuffer=g,e.INSPECT_MAX_BYTES=50,o.T * @author Feross Aboukhadijeh * @license MIT */ -t.exports=function(t){return null!=t&&(n(t)||r(t)||!!t._isBuffer)}},function(t,e,n){"use strict";function r(t){this.defaults=t,this.interceptors={request:new s,response:new s}}var i=n(13),o=n(1),s=n(72),a=n(73);r.prototype.request=function(t){"string"==typeof t&&(t=o.merge({url:arguments[0]},arguments[1])),t=o.merge(i,this.defaults,{method:"get"},t),t.method=t.method.toLowerCase();var e=[a,void 0],n=Promise.resolve(t);for(this.interceptors.request.forEach(function(t){e.unshift(t.fulfilled,t.rejected)}),this.interceptors.response.forEach(function(t){e.push(t.fulfilled,t.rejected)});e.length;)n=n.then(e.shift(),e.shift());return n},o.forEach(["delete","get","head","options"],function(t){r.prototype[t]=function(e,n){return this.request(o.merge(n||{},{method:t,url:e}))}}),o.forEach(["post","put","patch"],function(t){r.prototype[t]=function(e,n,r){return this.request(o.merge(r||{},{method:t,url:e,data:n}))}}),t.exports=r},function(t,e,n){"use strict";var r=n(1);t.exports=function(t,e){r.forEach(t,function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r])})}},function(t,e,n){"use strict";var r=n(19);t.exports=function(t,e,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?e(r("Request failed with status code "+n.status,n.config,null,n.request,n)):t(n)}},function(t,e,n){"use strict";t.exports=function(t,e,n,r,i){return t.config=e,n&&(t.code=n),t.request=r,t.response=i,t}},function(t,e,n){"use strict";function r(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var i=n(1);t.exports=function(t,e,n){if(!e)return t;var o;if(n)o=n(e);else if(i.isURLSearchParams(e))o=e.toString();else{var s=[];i.forEach(e,function(t,e){null!==t&&void 0!==t&&(i.isArray(t)&&(e+="[]"),i.isArray(t)||(t=[t]),i.forEach(t,function(t){i.isDate(t)?t=t.toISOString():i.isObject(t)&&(t=JSON.stringify(t)),s.push(r(e)+"="+r(t))}))}),o=s.join("&")}return o&&(t+=(-1===t.indexOf("?")?"?":"&")+o),t}},function(t,e,n){"use strict";var r=n(1),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];t.exports=function(t){var e,n,o,s={};return t?(r.forEach(t.split("\n"),function(t){if(o=t.indexOf(":"),e=r.trim(t.substr(0,o)).toLowerCase(),n=r.trim(t.substr(o+1)),e){if(s[e]&&i.indexOf(e)>=0)return;s[e]="set-cookie"===e?(s[e]?s[e]:[]).concat([n]):s[e]?s[e]+", "+n:n}}),s):s}},function(t,e,n){"use strict";var r=n(1);t.exports=r.isStandardBrowserEnv()?function(){function t(t){var e=t;return n&&(i.setAttribute("href",e),e=i.href),i.setAttribute("href",e),{href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}var e,n=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");return e=t(window.location.href),function(n){var i=r.isString(n)?t(n):n;return i.protocol===e.protocol&&i.host===e.host}}():function(){return function(){return!0}}()},function(t,e,n){"use strict";function r(){this.message="String contains an invalid character"}function i(t){for(var e,n,i=String(t),s="",a=0,u=o;i.charAt(0|a)||(u="=",a%1);s+=u.charAt(63&e>>8-a%1*8)){if((n=i.charCodeAt(a+=.75))>255)throw new r;e=e<<8|n}return s}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.prototype=new Error,r.prototype.code=5,r.prototype.name="InvalidCharacterError",t.exports=i},function(t,e,n){"use strict";var r=n(1);t.exports=r.isStandardBrowserEnv()?function(){return{write:function(t,e,n,i,o,s){var a=[];a.push(t+"="+encodeURIComponent(e)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(i)&&a.push("path="+i),r.isString(o)&&a.push("domain="+o),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(t,e,n){"use strict";function r(){this.handlers=[]}var i=n(1);r.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},r.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},r.prototype.forEach=function(t){i.forEach(this.handlers,function(e){null!==e&&t(e)})},t.exports=r},function(t,e,n){"use strict";function r(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var i=n(1),o=n(74),s=n(20),a=n(13),u=n(75),c=n(76);t.exports=function(t){return r(t),t.baseURL&&!u(t.url)&&(t.url=c(t.baseURL,t.url)),t.headers=t.headers||{},t.data=o(t.data,t.headers,t.transformRequest),t.headers=i.merge(t.headers.common||{},t.headers[t.method]||{},t.headers||{}),i.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]}),(t.adapter||a.adapter)(t).then(function(e){return r(t),e.data=o(e.data,e.headers,t.transformResponse),e},function(e){return s(e)||(r(t),e&&e.response&&(e.response.data=o(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)})}},function(t,e,n){"use strict";var r=n(1);t.exports=function(t,e,n){return r.forEach(n,function(n){t=n(t,e)}),t}},function(t,e,n){"use strict";t.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}},function(t,e,n){"use strict";t.exports=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}},function(t,e,n){"use strict";function r(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(t){e=t});var n=this;t(function(t){n.reason||(n.reason=new i(t),e(n.reason))})}var i=n(21);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var t;return{token:new r(function(e){t=e}),cancel:t}},t.exports=r},function(t,e,n){"use strict";t.exports=function(t){return function(e){return t.apply(null,e)}}},function(t,e,n){"use strict";(function(e){function r(t){var e;t.auth&&(e=t.auth.match(/^(.+):(.+)$/),e?(t.username=e[1],t.password=e[2]):t.username=t.auth)}function i(t,e){function n(t){return e.servers&&(t._reconnectCount&&t._reconnectCount!==e.servers.length||(t._reconnectCount=0),e.host=e.servers[t._reconnectCount].host,e.port=e.servers[t._reconnectCount].port,e.hostname=e.host,t._reconnectCount++),c[e.protocol](t,e)}if("object"!=typeof t||e||(e=t,t=null),e=e||{},t){var i=a.parse(t,!0);if(null!=i.port&&(i.port=Number(i.port)),e=u(i,e),null===e.protocol)throw new Error("Missing protocol");e.protocol=e.protocol.replace(/:$/,"")}if(r(e),e.query&&"string"==typeof e.query.clientId&&(e.clientId=e.query.clientId),e.cert&&e.key){if(!e.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs"].indexOf(e.protocol))switch(e.protocol){case"mqtt":e.protocol="mqtts";break;case"ws":e.protocol="wss";break;case"wx":e.protocol="wxs";break;default:throw new Error('Unknown protocol for secure connection: "'+e.protocol+'"!')}}if(!c[e.protocol]){var s=-1!==["mqtts","wss"].indexOf(e.protocol);e.protocol=["mqtt","mqtts","ws","wss","wx","wxs"].filter(function(t,e){return(!s||e%2!=0)&&"function"==typeof c[t]})[0]}if(!1===e.clean&&!e.clientId)throw new Error("Missing clientId for unclean clients");return new o(n,e)}var o=n(80),s=n(22),a=n(15),u=n(14),c={};"browser"!==e.title?(c.mqtt=n(34),c.tcp=n(34),c.ssl=n(16),c.tls=n(16),c.mqtts=n(16)):(c.wx=n(35),c.wxs=n(35)),c.ws=n(37),c.wss=n(37),t.exports=i,t.exports.connect=i,t.exports.MqttClient=o,t.exports.Store=s}).call(e,n(0))},function(t,e,n){"use strict";(function(e,r){function i(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function o(t,e,n){t.emit("packetsend",e),!h.writeToStream(e,t.stream)&&n?t.stream.once("drain",n):n&&n()}function s(t,e,n){t.outgoingStore.put(e,function(r){if(r)return n&&n(r);o(t,e,n)})}function a(){}function u(t,e){var n,r=this;if(!(this instanceof u))return new u(t,e);this.options=e||{};for(n in v)void 0===this.options[n]?this.options[n]=v[n]:this.options[n]=e[n];this.options.clientId="string"==typeof this.options.clientId?this.options.clientId:i(),this.streamBuilder=t,this.outgoingStore=this.options.outgoingStore||new l,this.incomingStore=this.options.incomingStore||new l,this.queueQoSZero=void 0===this.options.queueQoSZero||this.options.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this.nextId=Math.floor(65535*Math.random()),this.outgoing={},this.on("connect",function(){if(!this.disconnected){this.connected=!0;var t=null;t=this.outgoingStore.createStream(),t.once("readable",function(){function e(){var n,i=t.read(1);i&&(!r.disconnecting&&!r.reconnectTimer&&r.options.reconnectPeriod>0?(t.read(0),n=r.outgoing[i.messageId],r.outgoing[i.messageId]=function(t,r){n&&n(t,r),e()},r._sendPacket(i)):t.destroy&&t.destroy())}e()}).on("error",this.emit.bind(this,"error"))}}),this.on("close",function(){this.connected=!1,clearTimeout(this.connackTimer)}),this.on("connect",this._setupPingTimer),this.on("connect",function(){function t(){var n=e.shift(),i=null;n&&(i=n.packet,r._sendPacket(i,function(e){n.cb&&n.cb(e),t()}))}var e=this.queue;t()});var o=!0;this.on("connect",function(){!o&&this.options.clean&&Object.keys(this._resubscribeTopics).length>0&&(this.options.resubscribe?(this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics)):this._resubscribeTopics={}),o=!1}),this.on("close",function(){null!==r.pingTimer&&(r.pingTimer.clear(),r.pingTimer=null)}),this.on("close",this._setupReconnect),c.EventEmitter.call(this),this._setupStream()}var c=n(5),l=n(22),f=n(30),h=n(91),p=n(9).Writable,d=n(3),g=n(100),b=n(101),m=n(14),y=e.setImmediate||function(t){r.nextTick(t)},v={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0};d(u,c.EventEmitter),u.prototype._setupStream=function(){function t(){r.nextTick(e)}function e(){var e=l.shift(),n=c;e?i._handlePacket(e,t):(c=null,n())}var n,i=this,s=new p,u=h.parser(this.options),c=null,l=[];this._clearReconnect(),this.stream=this.streamBuilder(this),u.on("packet",function(t){l.push(t)}),s._write=function(t,n,r){c=r,u.parse(t),e()},this.stream.pipe(s),this.stream.on("error",a),f(this.stream,this.emit.bind(this,"close")),n=Object.create(this.options),n.cmd="connect",o(this,n),u.on("error",this.emit.bind(this,"error")),this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){i._cleanUp(!0)},this.options.connectTimeout)},u.prototype._handlePacket=function(t,e){switch(this.emit("packetreceive",t),t.cmd){case"publish":this._handlePublish(t,e);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(t),e();break;case"pubrel":this._handlePubrel(t,e);break;case"connack":this._handleConnack(t),e();break;case"pingresp":this._handlePingresp(t),e()}},u.prototype._checkDisconnecting=function(t){return this.disconnecting&&(t?t(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},u.prototype.publish=function(t,e,n,r){var i;if("function"==typeof n&&(r=n,n=null),n=m({qos:0,retain:!1,dup:!1},n),this._checkDisconnecting(r))return this;switch(i={cmd:"publish",topic:t,payload:e,qos:n.qos,retain:n.retain,messageId:this._nextId(),dup:n.dup},n.qos){case 1:case 2:this.outgoing[i.messageId]=r||a,this._sendPacket(i);break;default:this._sendPacket(i,r)}return this},u.prototype.subscribe=function(){var t,e,n=Array.prototype.slice.call(arguments),r=[],i=n.shift(),o=i.resubscribe,s=n.pop()||a,u=n.pop(),c=this;if(delete i.resubscribe,"string"==typeof i&&(i=[i]),"function"!=typeof s&&(u=s,s=a),null!==(e=b.validateTopics(i)))return y(s,new Error("Invalid topic "+e)),this;if(this._checkDisconnecting(s))return this;if(u=m({qos:0},u),Array.isArray(i)?i.forEach(function(t){(c._resubscribeTopics[t]0&&(c._resubscribeTopics[t.topic]=t.qos,l.push(t.topic))}),c.messageIdToTopic[t.messageId]=l}return this.outgoing[t.messageId]=function(t,e){if(!t)for(var n=e.granted,i=0;i0?this.once("outgoingEmpty",setTimeout.bind(null,r,10)):r(),this)},u.prototype.removeOutgoingMessage=function(t){var e=this.outgoing[t];return delete this.outgoing[t],this.outgoingStore.del({messageId:t},function(){e(new Error("Message removed"))}),this},u.prototype.reconnect=function(t){var e=this,n=function(){t?(e.options.incomingStore=t.incomingStore,e.options.outgoingStore=t.outgoingStore):(e.options.incomingStore=null,e.options.outgoingStore=null),e.incomingStore=e.options.incomingStore||new l,e.outgoingStore=e.options.outgoingStore||new l,e.disconnecting=!1,e.disconnected=!1,e._deferredReconnect=null,e._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=n:n(),this},u.prototype._reconnect=function(){this.emit("reconnect"),this._setupStream()},u.prototype._setupReconnect=function(){var t=this;!t.disconnecting&&!t.reconnectTimer&&t.options.reconnectPeriod>0&&(this.reconnecting||(this.emit("offline"),this.reconnecting=!0),t.reconnectTimer=setInterval(function(){t._reconnect()},t.options.reconnectPeriod))},u.prototype._clearReconnect=function(){this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},u.prototype._cleanUp=function(t,e){e&&this.stream.on("close",e),t?this.stream.destroy():this._sendPacket({cmd:"disconnect"},y.bind(null,this.stream.end.bind(this.stream))),this.disconnecting||(this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(this.pingTimer.clear(),this.pingTimer=null)},u.prototype._sendPacket=function(t,e){if(!this.connected)return void(0===(t.qos||0)&&this.queueQoSZero||"publish"!==t.cmd?this.queue.push({packet:t,cb:e}):t.qos>0?this.outgoingStore.put(t,function(t){if(t)return e&&e(t)}):e&&e(new Error("No connection to broker")));if(this._shiftPingInterval(),"publish"!==t.cmd)return void o(this,t,e);switch(t.qos){case 2:case 1:s(this,t,e);break;case 0:default:o(this,t,e)}},u.prototype._setupPingTimer=function(){var t=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=g(function(){t._checkPing()},1e3*this.options.keepalive))},u.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},u.prototype._checkPing=function(){this.pingResp?(this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):this._cleanUp(!0)},u.prototype._handlePingresp=function(){this.pingResp=!0},u.prototype._handleConnack=function(t){var e=t.returnCode,n=["","Unacceptable protocol version","Identifier rejected","Server unavailable","Bad username or password","Not authorized"];if(clearTimeout(this.connackTimer),0===e)this.reconnecting=!1,this.emit("connect",t);else if(e>0){var r=new Error("Connection refused: "+n[e]);r.code=e,this.emit("error",r)}},u.prototype._handlePublish=function(t,e){var n=t.topic.toString(),r=t.payload,i=t.qos,o=t.messageId,s=this;switch(i){case 2:this.incomingStore.put(t,function(){s._sendPacket({cmd:"pubrec",messageId:o},e)});break;case 1:this.emit("message",n,r,t),this.handleMessage(t,function(t){if(t)return e&&e(t);s._sendPacket({cmd:"puback",messageId:o},e)});break;case 0:this.emit("message",n,r,t),this.handleMessage(t,e)}},u.prototype.handleMessage=function(t,e){e()},u.prototype._handleAck=function(t){var e=t.messageId,n=t.cmd,r=null,i=this.outgoing[e],o=this;if(i){switch(n){case"pubcomp":case"puback":delete this.outgoing[e],this.outgoingStore.del(t,i);break;case"pubrec":r={cmd:"pubrel",qos:2,messageId:e},this._sendPacket(r);break;case"suback":if(delete this.outgoing[e],1===t.granted.length&&0!=(128&t.granted[0])){var s=this.messageIdToTopic[e];s&&s.forEach(function(t){delete o._resubscribeTopics[t]})}i(null,t);break;case"unsuback":delete this.outgoing[e],i(null);break;default:o.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}},u.prototype._handlePubrel=function(t,e){var n=t.messageId,r=this,i={cmd:"pubcomp",messageId:n};r.incomingStore.get(t,function(n,o){n||"pubrel"===o.cmd?r._sendPacket(i,e):(r.emit("message",o.topic,o.payload,o),r.incomingStore.put(t),r.handleMessage(o,function(t){if(t)return e&&e(t);r._sendPacket(i,e)}))})},u.prototype._nextId=function(){var t=this.nextId++;return 65535===t&&(this.nextId=1),t},u.prototype.getLastMessageId=function(){return 1===this.nextId?65535:this.nextId-1},t.exports=u}).call(e,n(2),n(0))},function(t,e,n){"use strict";function r(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function i(t){return 3*t.length/4-r(t)}function o(t){var e,n,i,o,s,a=t.length;o=r(t),s=new f(3*a/4-o),n=o>0?a-4:a;var u=0;for(e=0;e>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=l[t.charCodeAt(e)]<<2|l[t.charCodeAt(e+1)]>>4,s[u++]=255&i):1===o&&(i=l[t.charCodeAt(e)]<<10|l[t.charCodeAt(e+1)]<<4|l[t.charCodeAt(e+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}function s(t){return c[t>>18&63]+c[t>>12&63]+c[t>>6&63]+c[63&t]}function a(t,e,n){for(var r,i=[],o=e;ou?u:s+16383));return 1===r?(e=t[n-1],i+=c[e>>2],i+=c[e<<4&63],i+="=="):2===r&&(e=(t[n-2]<<8)+t[n-1],i+=c[e>>10],i+=c[e>>4&63],i+=c[e<<2&63],i+="="),o.push(i),o.join("")}e.byteLength=i,e.toByteArray=o,e.fromByteArray=u;for(var c=[],l=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,d=h.length;p>1,l=-7,f=n?i-1:0,h=n?-1:1,p=t[e+f];for(f+=h,o=p&(1<<-l)-1,p>>=-l,l+=a;l>0;o=256*o+t[e+f],f+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+t[e+f],f+=h,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var s,a,u,c=8*o-i-1,l=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+f>=1?h/u:h*Math.pow(2,1-f),e*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(e*u-1)*Math.pow(2,i),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;t[n+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;t[n+p]=255&s,p+=d,s/=256,c-=8);t[n+p-d]|=128*g}},function(t,e){},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e,n){t.copy(e,n)}var o=n(4).Buffer;t.exports=function(){function t(){r(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n},t.prototype.concat=function(t){if(0===this.length)return o.alloc(0);if(1===this.length)return this.head.data;for(var e=o.allocUnsafe(t>>>0),n=this.head,r=0;n;)i(n.data,e,r),r+=n.data.length,n=n.next;return e},t}()},function(t,e,n){function r(t,e){this._id=t,this._clearFn=e}var i=Function.prototype.apply;e.setTimeout=function(){return new r(i.call(setTimeout,window,arguments),clearTimeout)},e.setInterval=function(){return new r(i.call(setInterval,window,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(window,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n(86),e.setImmediate=setImmediate,e.clearImmediate=clearImmediate},function(t,e,n){(function(t,e){!function(t,n){"use strict";function r(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n0)&&this[this._states[this._stateCounter]]()&&!this.error;)++this._stateCounter>=this._states.length&&(this._stateCounter=0);return this._list.length},r.prototype._parseHeader=function(){var t=this._list.readUInt8(0);return this.packet.cmd=u.types[t>>u.CMD_SHIFT],this.packet.retain=0!=(t&u.RETAIN_MASK),this.packet.qos=t>>u.QOS_SHIFT&u.QOS_MASK,this.packet.dup=0!=(t&u.DUP_MASK),this._list.consume(1),!0},r.prototype._parseLength=function(){for(var t,e=0,n=1,r=0,i=!0;e<5&&(t=this._list.readUInt8(e++),r+=n*(t&u.LENGTH_MASK),n*=128,0!=(t&u.LENGTH_FIN_MASK));)if(this._list.length<=e){i=!1;break}return i&&(this.packet.length=r,this._list.consume(e)),i},r.prototype._parsePayload=function(){var t=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseMessageId();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":case"disconnect":break;default:this._emitError(new Error("Not supported"))}t=!0}return t},r.prototype._parseConnect=function(){var t,e,n,r,i,o,s={},a=this.packet;if(null===(t=this._parseString()))return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==t&&"MQIsdp"!==t)return this._emitError(new Error("Invalid protocolId"));if(a.protocolId=t,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(a.protocolVersion=this._list.readUInt8(this._pos),3!==a.protocolVersion&&4!==a.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(++this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(s.username=this._list.readUInt8(this._pos)&u.USERNAME_MASK,s.password=this._list.readUInt8(this._pos)&u.PASSWORD_MASK,s.will=this._list.readUInt8(this._pos)&u.WILL_FLAG_MASK,s.will&&(a.will={},a.will.retain=0!=(this._list.readUInt8(this._pos)&u.WILL_RETAIN_MASK),a.will.qos=(this._list.readUInt8(this._pos)&u.WILL_QOS_MASK)>>u.WILL_QOS_SHIFT),a.clean=0!=(this._list.readUInt8(this._pos)&u.CLEAN_SESSION_MASK),this._pos++,a.keepalive=this._parseNum(),-1===a.keepalive)return this._emitError(new Error("Packet too short"));if(null===(e=this._parseString()))return this._emitError(new Error("Packet too short"));if(a.clientId=e,s.will){if(null===(n=this._parseString()))return this._emitError(new Error("Cannot parse will topic"));if(a.will.topic=n,null===(r=this._parseBuffer()))return this._emitError(new Error("Cannot parse will payload"));a.will.payload=r}if(s.username){if(null===(o=this._parseString()))return this._emitError(new Error("Cannot parse username"));a.username=o}if(s.password){if(null===(i=this._parseBuffer()))return this._emitError(new Error("Cannot parse password"));a.password=i}return a},r.prototype._parseConnack=function(){var t=this.packet;return this._list.length<2?null:(t.sessionPresent=!!(this._list.readUInt8(this._pos++)&u.SESSIONPRESENT_MASK),t.returnCode=this._list.readUInt8(this._pos),-1===t.returnCode?this._emitError(new Error("Cannot parse return code")):void 0)},r.prototype._parsePublish=function(){var t=this.packet;if(t.topic=this._parseString(),null===t.topic)return this._emitError(new Error("Cannot parse topic"));t.qos>0&&!this._parseMessageId()||(t.payload=this._list.slice(this._pos,t.length))},r.prototype._parseSubscribe=function(){var t,e,n=this.packet;if(1!==n.qos)return this._emitError(new Error("Wrong subscribe header"));if(n.subscriptions=[],this._parseMessageId())for(;this._posthis._list.length||r>this.packet.length?null:(e=this._list.toString("utf8",this._pos,r),this._pos+=n,e)},r.prototype._parseBuffer=function(){var t,e=this._parseNum(),n=e+this._pos;return-1===e||n>this._list.length||n>this.packet.length?null:(t=this._list.slice(this._pos,n),this._pos+=e,t)},r.prototype._parseNum=function(){if(this._list.length-this._pos<2)return-1;var t=this._list.readUInt16BE(this._pos);return this._pos+=2,t},r.prototype._newPacket=function(){return this.packet&&(this._list.consume(this.packet.length),this.emit("packet",this.packet)),this.packet=new a,!0},r.prototype._emitError=function(t){this.error=t,this.emit("error",t)},t.exports=r},function(t,e,n){(function(e){function r(t){if(!(this instanceof r))return new r(t);if(this._bufs=[],this.length=0,"function"==typeof t){this._callback=t;var e=function(t){this._callback&&(this._callback(t),this._callback=null)}.bind(this);this.on("pipe",function(t){t.on("error",e)}),this.on("unpipe",function(t){t.removeListener("error",e)})}else this.append(t);i.call(this)}var i=n(94);n(95).inherits(r,i),r.prototype._offset=function(t){var e,n=0,r=0;if(0===t)return[0,0];for(;rthis.length)&&(i=this.length),r>=this.length)return t||new e(0);if(i<=0)return t||new e(0);var o,s,a=!!t,u=this._offset(r),c=i-r,l=c,f=a&&n||0,h=u[1];if(0===r&&i==this.length){if(!a)return 1===this._bufs.length?this._bufs[0]:e.concat(this._bufs,this.length);for(s=0;so)){this._bufs[s].copy(t,f,h,h+l);break}this._bufs[s].copy(t,f,h),f+=o,l-=o,h&&(h=0)}return t},r.prototype.shallowSlice=function(t,e){t=t||0,e=e||this.length,t<0&&(t+=this.length),e<0&&(e+=this.length);var n=this._offset(t),i=this._offset(e),o=this._bufs.slice(n[0],i[0]+1);return 0==i[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,i[1]),0!=n[1]&&(o[0]=o[0].slice(n[1])),new r(o)},r.prototype.toString=function(t,e,n){return this.slice(e,n).toString(t)},r.prototype.consume=function(t){for(;this._bufs.length;){if(!(t>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(t),this.length-=t;break}t-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},r.prototype.duplicate=function(){for(var t=0,e=new r;t=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),g(n)?r.showHidden=n:n&&e._extend(r,n),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),u(r,t,r.depth)}function o(t,e){var n=i.styles[e];return n?"["+i.colors[n][0]+"m"+t+"["+i.colors[n][1]+"m":t}function s(t,e){return t}function a(t){var e={};return t.forEach(function(t,n){e[t]=!0}),e}function u(t,n,r){if(t.customInspect&&n&&I(n.inspect)&&n.inspect!==e.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,t);return v(i)||(i=u(t,i,r)),i}var o=c(t,n);if(o)return o;var s=Object.keys(n),g=a(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(n)),x(n)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return l(n);if(0===s.length){if(I(n)){var b=n.name?": "+n.name:"";return t.stylize("[Function"+b+"]","special")}if(S(n))return t.stylize(RegExp.prototype.toString.call(n),"regexp");if(k(n))return t.stylize(Date.prototype.toString.call(n),"date");if(x(n))return l(n)}var m="",y=!1,w=["{","}"];if(d(n)&&(y=!0,w=["[","]"]),I(n)){m=" [Function"+(n.name?": "+n.name:"")+"]"}if(S(n)&&(m=" "+RegExp.prototype.toString.call(n)),k(n)&&(m=" "+Date.prototype.toUTCString.call(n)),x(n)&&(m=" "+l(n)),0===s.length&&(!y||0==n.length))return w[0]+m+w[1];if(r<0)return S(n)?t.stylize(RegExp.prototype.toString.call(n),"regexp"):t.stylize("[Object]","special");t.seen.push(n);var _;return _=y?f(t,n,r,g,s):s.map(function(e){return h(t,n,r,g,e,y)}),t.seen.pop(),p(_,m,w)}function c(t,e){if(_(e))return t.stylize("undefined","undefined");if(v(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}return y(e)?t.stylize(""+e,"number"):g(e)?t.stylize(""+e,"boolean"):b(e)?t.stylize("null","null"):void 0}function l(t){return"["+Error.prototype.toString.call(t)+"]"}function f(t,e,n,r,i){for(var o=[],s=0,a=e.length;s-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n"))):a=t.stylize("[Circular]","special")),_(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function p(t,e,n){var r=0;return t.reduce(function(t,e){return r++,e.indexOf("\n")>=0&&r++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1]:n[0]+e+" "+t.join(", ")+" "+n[1]}function d(t){return Array.isArray(t)}function g(t){return"boolean"==typeof t}function b(t){return null===t}function m(t){return null==t}function y(t){return"number"==typeof t}function v(t){return"string"==typeof t}function w(t){return"symbol"==typeof t}function _(t){return void 0===t}function S(t){return E(t)&&"[object RegExp]"===A(t)}function E(t){return"object"==typeof t&&null!==t}function k(t){return E(t)&&"[object Date]"===A(t)}function x(t){return E(t)&&("[object Error]"===A(t)||t instanceof Error)}function I(t){return"function"==typeof t}function T(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t}function A(t){return Object.prototype.toString.call(t)}function O(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var R=/%[sdj%]/g;e.format=function(t){if(!v(t)){for(var e=[],n=0;n=o)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return t}}),a=r[n];n>8,0,!0),e.writeUInt8(255&t,1,!0),e}function i(){for(var t=0;t0){t=new Array(arguments.length-2);for(var e=0;e1&&(r=n[0]+"@",t=n[1]),t=t.replace(C,"."),r+a(t.split("."),e).join(".")}function c(t){for(var e,n,r=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(t-=65536,e+=L(t>>>10&1023|55296),t=56320|1023&t),e+=L(t)}).join("")}function f(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:_}function h(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function p(t,e,n){var r=0;for(t=n?j(t/x):t>>1,t+=j(t/e);t>M*E>>1;r+=_)t=j(t/M);return j(r+(M+1)*t/(t+k))}function d(t){var e,n,r,i,o,a,u,c,h,d,g=[],b=t.length,m=0,y=T,v=I;for(n=t.lastIndexOf(A),n<0&&(n=0),r=0;r=128&&s("not-basic"),g.push(t.charCodeAt(r));for(i=n>0?n+1:0;i=b&&s("invalid-input"),c=f(t.charCodeAt(i++)),(c>=_||c>j((w-m)/a))&&s("overflow"),m+=c*a,h=u<=v?S:u>=v+E?E:u-v,!(cj(w/d)&&s("overflow"),a*=d;e=g.length+1,v=p(m-o,e,0==o),j(m/e)>w-y&&s("overflow"),y+=j(m/e),m%=e,g.splice(m++,0,y)}return l(g)}function g(t){var e,n,r,i,o,a,u,l,f,d,g,b,m,y,v,k=[];for(t=c(t),b=t.length,e=T,n=0,o=I,a=0;a=e&&gj((w-n)/m)&&s("overflow"),n+=(u-e)*m,e=u,a=0;aw&&s("overflow"),g==e){for(l=n,f=_;d=f<=o?S:f>=o+E?E:f-o,!(l= 0x80 (not a basic code point)","invalid-input":"Invalid input"},M=_-S,j=Math.floor,L=String.fromCharCode;v={version:"1.4.1",ucs2:{decode:c,encode:l},decode:d,encode:g,toASCII:m,toUnicode:b},void 0!==(i=function(){return v}.call(e,n,e,t))&&(t.exports=i)}()}).call(e,n(33)(t),n(2))},function(t,e,n){"use strict";t.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},function(t,e,n){"use strict";e.decode=e.parse=n(105),e.encode=e.stringify=n(106)},function(t,e,n){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,n,o){e=e||"&",n=n||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var l=0;l=0?(f=g.substr(0,b),h=g.substr(b+1)):(f=g,h=""),p=decodeURIComponent(f),d=decodeURIComponent(h),r(s,p)?i(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,n){"use strict";function r(t,e){if(t.map)return t.map(e);for(var n=[],r=0;r64)&&!/\s|\/|\\|\+|\*|#/gi.test(t))},encryptedStorage:function(){var t=this;return{get:function(e){return i.get(e)?JSON.parse(t.decrypt(i.get(e))):{}},set:function(e,n){return n="object"===(void 0===n?"undefined":r(n))?JSON.stringify(n):n,i.set(e,t.encrypt(n)),t}}},decrypt:function(t){return String(t).split("").map(function(t,e){return String.fromCharCode(t.charCodeAt(0)-s.charCodeAt(e%s.length))}).join("")},encrypt:function(t){return String(t).split("").map(function(t,e){return String.fromCharCode(t.charCodeAt(0)+s.charCodeAt(e%s.length))}).join("")},getAppDomain:function(t,e){return e?o.HOST_DEV:-1===o.EXCLUSIVE_APPIDS.indexOf(t)?t.replace("-demo","")+"."+o.HOST:o.HOST},defaultDevice:function(t){var e=t.appId,r=t.userId,i=t.token,s=t.realtime;i=i||"disabled";var u=navigator.connection||navigator.mozConnection||navigator.webkitConnection||{type:null};return i=Object.keys(i).length?JSON.stringify(Object.assign(i,{expirationTime:0})):"notSupported"===i?"---":"disabled",{realtime:s,launchCount:+this.encryptedStorage().get(o.STORAGE_KEY).launchCount,launchTime:Date.now(),appId:e,userId:r,deviceToken:i,deviceType:"web",deviceModel:a.name?a.name.toLowerCase():"NodeJS",osVersion:a.os.version,deviceManufacture:a.os.family,browserVersion:a.version,appVersion:n(115).version,subscriptions:o.DEFAULT_CHANNELS,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,connection:u.type}},toTopicName:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"user",i=void 0,o=void 0;switch(r){case"user":var s=n.split("/");"public"===s[0]?(i=s[0],o=s[1]):(i=e,o=s[0]);break;case"publish":i="*"===e?"public":e,o=n;break;case"event":case"track":i=n,o=e||"+";break;default:throw new Error("Invalid topic type.")}return["app",t,r,i,o].join("/")},fromChabokChannel:function(t){var e=t.split("/"),n=void 0;switch(e.length){case 1:n="public/"+e[0];break;case 2:if("public"!==e[0]&&"private"!==e[0])throw new Error("Invalid channel name format, please read documentations.");n="public"===e[0]?"public/"+e[1]:e[1];break;default:throw new Error("Invalid channel name format, please read documentations.")}return n},toChabokMessage:function(t,e){var n=t.split("/"),r=n[3]+"/"+n[4];try{var i=JSON.parse(e);return i.channel=r,i}catch(t){return e}},toEventMessage:function(t,e){var n=t.split("/"),r=n[1],i=n[3],o=n[4],s={appId:r,eventName:i,deviceId:o,receivedAt:Date.now()};try{return s.data=JSON.parse(e),s.createdAt=s.data.createdAt,s.id=s.data.id,s}catch(t){return e}}};t.exports=u},function(t,e){!function(e,n){var r={version:"2.5.2",areas:{},apis:{},inherit:function(t,e){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n]);return e},stringify:function(t){return void 0===t||"function"==typeof t?t+"":JSON.stringify(t)},parse:function(t){try{return JSON.parse(t)}catch(e){return t}},fn:function(t,e){r.storeAPI[t]=e;for(var n in r.apis)r.apis[n][t]=e},get:function(t,e){return t.getItem(e)},set:function(t,e,n){t.setItem(e,n)},remove:function(t,e){t.removeItem(e)},key:function(t,e){return t.key(e)},length:function(t){return t.length},clear:function(t){t.clear()},Store:function(t,e,n){var i=r.inherit(r.storeAPI,function(t,e,n){return 0===arguments.length?i.getAll():"function"==typeof e?i.transact(t,e,n):void 0!==e?i.set(t,e,n):"string"==typeof t||"number"==typeof t?i.get(t):t?i.setAll(t,e):i.clear()});i._id=t;try{e.setItem("_safariPrivate_","sucks"),i._area=e,e.removeItem("_safariPrivate_")}catch(t){}return i._area||(i._area=r.inherit(r.storageAPI,{items:{},name:"fake"})),i._ns=n||"",r.areas[t]||(r.areas[t]=i._area),r.apis[i._ns+i._id]||(r.apis[i._ns+i._id]=i),i},storeAPI:{area:function(t,e){var n=this[t];return n&&n.area||(n=r.Store(t,e,this._ns),this[t]||(this[t]=n)),n},namespace:function(t,e){if(!t)return this._ns?this._ns.substring(0,this._ns.length-1):"";var n=t,i=this[n];return i&&i.namespace||(i=r.Store(this._id,this._area,this._ns+n+"."),this[n]||(this[n]=i),e||i.area("session",r.areas.session)),i},isFake:function(){return"fake"===this._area.name},toString:function(){return"store"+(this._ns?"."+this.namespace():"")+"["+this._id+"]"},has:function(t){return this._area.has?this._area.has(this._in(t)):!!(this._in(t)in this._area)},size:function(){return this.keys().length},each:function(t,e){for(var n=0,i=r.length(this._area);nr.length(this._area)&&(i--,n--)}return e||this},keys:function(){return this.each(function(t,e){e.push(t)},[])},get:function(t,e){var n=r.get(this._area,this._in(t));return null!==n?r.parse(n):e||n},getAll:function(){return this.each(function(t,e){e[t]=this.get(t)},{})},transact:function(t,e,n){var r=this.get(t,n),i=e(r);return this.set(t,void 0===i?r:i),this},set:function(t,e,n){var i=this.get(t);return null!=i&&!1===n?e:r.set(this._area,this._in(t),r.stringify(e),n)||i},setAll:function(t,e){var n,r;for(var i in t)r=t[i],this.set(i,r,e)!==r&&(n=!0);return n},remove:function(t){var e=this.get(t);return r.remove(this._area,this._in(t)),e},clear:function(){return this._ns?this.each(function(t){r.remove(this._area,this._in(t))},1):r.clear(this._area),this},clearAll:function(){var t=this._area;for(var e in r.areas)r.areas.hasOwnProperty(e)&&(this._area=r.areas[e],this.clear());return this._area=t,this},_in:function(t){return"string"!=typeof t&&(t=r.stringify(t)),this._ns?this._ns+t:t},_out:function(t){return this._ns?t&&0===t.indexOf(this._ns)?t.substring(this._ns.length):void 0:t}},storageAPI:{length:0,has:function(t){return this.items.hasOwnProperty(t)},key:function(t){var e=0;for(var n in this.items)if(this.has(n)&&t===e++)return n},setItem:function(t,e){this.has(t)||this.length++,this.items[t]=e},removeItem:function(t){this.has(t)&&(delete this.items[t],this.length--)},getItem:function(t){return this.has(t)?this.items[t]:null},clear:function(){for(var t in this.items)this.removeItem(t)},toString:function(){return this.length+" items in "+this.name+"Storage"}}},i=r.Store("local",function(){try{return localStorage}catch(t){}}());i.local=i,i._=r,i.area("session",function(){try{return sessionStorage}catch(t){}}()),"function"==typeof n&&void 0!==n.amd?n("store2",[],function(){return i}):void 0!==t&&t.exports?t.exports=i:(e.store&&(r.conflict=e.store),e.store=i)}(this,this.define)},function(t,e,n){(function(t,r){var i;(function(){"use strict";function o(t){return t=String(t),t.charAt(0).toUpperCase()+t.slice(1)}function s(t,e,n){var r={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return e&&n&&/^Win/i.test(t)&&!/^Windows Phone /i.test(t)&&(r=r[/[\d.]+$/.exec(t)])&&(t="Windows "+r),t=String(t),e&&n&&(t=t.replace(RegExp(e,"i"),n)),t=u(t.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}function a(t,e){var n=-1,r=t?t.length:0;if("number"==typeof r&&r>-1&&r<=S)for(;++n3&&"WebKit"||/\bOpera\b/.test(W)&&(/\bOPR\b/.test(t)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(F)&&"WebKit"||!F&&/\bMSIE\b/i.test(t)&&("Mac OS"==z?"Tasman":"Trident")||"WebKit"==F&&/\bPlayStation\b(?! Vita\b)/i.test(W)&&"NetFront")&&(F=[b]),"IE"==W&&(b=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(W+=" Mobile",z="Windows Phone "+(/\+$/.test(b)?b:b+".x"),U.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(W="IE Mobile",z="Windows Phone 8.x",U.unshift("desktop mode"),q||(q=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=W&&"Trident"==F&&(b=/\brv:([\d.]+)/.exec(t))&&(W&&U.push("identifying as "+W+(q?" "+q:"")),W="IE",q=b[1]),D){if(f(r,"global"))if(O&&(b=O.lang.System,N=b.getProperty("os.arch"),z=z||b.getProperty("os.name")+" "+b.getProperty("os.version")),w&&f(r,"system")&&(b=[r.system])[0]){z||(z=b[0].os||null);try{b[1]=r.require("ringo/engine").version,q=b[1].join("."),W="RingoJS"}catch(t){b[0].global.system==r.system&&(W="Narwhal")}}else"object"==typeof r.process&&!r.process.browser&&(b=r.process)?"object"==typeof b.versions?"string"==typeof b.versions.electron?(U.push("Node "+b.versions.node),W="Electron",q=b.versions.electron):"string"==typeof b.versions.nw&&(U.push("Chromium "+q,"Node "+b.versions.node),W="NW.js",q=b.versions.nw):(W="Node.js",N=b.arch,z=b.platform,q=/[\d.]+/.exec(b.version),q=q?q[0]:"unknown"):R&&(W="Rhino");else l(b=r.runtime)==S?(W="Adobe AIR",z=b.flash.system.Capabilities.os):l(b=r.phantom)==A?(W="PhantomJS",q=(b=b.version||null)&&b.major+"."+b.minor+"."+b.patch):"number"==typeof M.documentMode&&(b=/\bTrident\/(\d+)/i.exec(t))?(q=[q,M.documentMode],(b=+b[1]+4)!=q[1]&&(U.push("IE "+q[1]+" mode"),F&&(F[1]=""),q[1]=b),q="IE"==W?String(q[1].toFixed(1)):q[0]):"number"==typeof M.documentMode&&/^(?:Chrome|Firefox)\b/.test(W)&&(U.push("masking as "+W+" "+q),W="IE",q="11.0",F=["Trident"],z="Windows");z=z&&u(z)}if(q&&(b=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(q)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(D&&o.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(B=/b/i.test(b)?"beta":"alpha",q=q.replace(RegExp(b+"\\+?$"),"")+("beta"==B?P:C)+(/\d+\+?/.exec(b)||"")),"Fennec"==W||"Firefox"==W&&/\b(?:Android|Firefox OS)\b/.test(z))W="Firefox Mobile";else if("Maxthon"==W&&q)q=q.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(K))"Xbox 360"==K&&(z=null),"Xbox 360"==K&&/\bIEMobile\b/.test(t)&&U.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(W)&&(!W||K||/Browser|Mobi/.test(W))||"Windows CE"!=z&&!/Mobi/i.test(t))if("IE"==W&&D)try{null===r.external&&U.unshift("platform preview")}catch(t){U.unshift("embedded")}else(/\bBlackBerry\b/.test(K)||/\bBB10\b/.test(t))&&(b=(RegExp(K.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||q)?(b=[b,/BB10/.test(t)],z=(b[1]?(K=null,H="BlackBerry"):"Device Software")+" "+b[0],q=null):this!=c&&"Wii"!=K&&(D&&j||/Opera/.test(W)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==W&&/\bOS X (?:\d+\.){2,}/.test(z)||"IE"==W&&(z&&!/^Win/.test(z)&&q>5.5||/\bWindows XP\b/.test(z)&&q>8||8==q&&!/\bTrident\b/.test(t)))&&!E.test(b=g.call(c,t.replace(E,"")+";"))&&b.name&&(b="ing as "+b.name+((b=b.version)?" "+b:""),E.test(W)?(/\bIE\b/.test(b)&&"Mac OS"==z&&(z=null),b="identify"+b):(b="mask"+b,W=L?u(L.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(b)&&(z=null),D||(q=null)),F=["Presto"],U.push(b));else W+=" Mobile";(b=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(b=[parseFloat(b.replace(/\.(\d)$/,".0$1")),b],"Safari"==W&&"+"==b[1].slice(-1)?(W="WebKit Nightly",B="alpha",q=b[1].slice(0,-1)):q!=b[1]&&q!=(b[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(q=null),b[1]=(/\bChrome\/([\d.]+)/i.exec(t)||0)[1],537.36==b[0]&&537.36==b[2]&&parseFloat(b[1])>=28&&"WebKit"==F&&(F=["Blink"]),D&&(_||b[1])?(F&&(F[1]="like Chrome"),b=b[1]||(b=b[0],b<530?1:b<532?2:b<532.05?3:b<533?4:b<534.03?5:b<534.07?6:b<534.1?7:b<534.13?8:b<534.16?9:b<534.24?10:b<534.3?11:b<535.01?12:b<535.02?"13+":b<535.07?15:b<535.11?16:b<535.19?17:b<536.05?18:b<536.1?19:b<537.01?20:b<537.11?"21+":b<537.13?23:b<537.18?24:b<537.24?25:b<537.36?26:"Blink"!=F?"27":"28")):(F&&(F[1]="like Safari"),b=b[0],b=b<400?1:b<500?2:b<526?3:b<533?4:b<534?"4+":b<535?5:b<537?6:b<538?7:b<601?8:"8"),F&&(F[1]+=" "+(b+="number"==typeof b?".x":/[.+]/.test(b)?"":"+")),"Safari"==W&&(!q||parseInt(q)>45)&&(q=b)),"Opera"==W&&(b=/\bzbov|zvav$/.exec(z))?(W+=" ",U.unshift("desktop mode"),"zvav"==b?(W+="Mini",q=null):W+="Mobile",z=z.replace(RegExp(" *"+b+"$"),"")):"Safari"==W&&/\bChrome\b/.exec(F&&F[1])&&(U.unshift("desktop mode"),W="Chrome Mobile",q=null,/\bOS X\b/.test(z)?(H="Apple",z="iOS 4.3+"):z=null),q&&0==q.indexOf(b=/[\d.]+$/.exec(z))&&t.indexOf("/"+b+"-")>-1&&(z=d(z.replace(b,""))),F&&!/\b(?:Avant|Nook)\b/.test(W)&&(/Browser|Lunascape|Maxthon/.test(W)||"Safari"!=W&&/^iOS/.test(z)&&/\bSafari\b/.test(F[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|Web)/.test(W)&&F[1])&&(b=F[F.length-1])&&U.push(b),U.length&&(U=["("+U.join("; ")+")"]),H&&K&&K.indexOf(H)<0&&U.push("on "+H),K&&U.push((/^on /.test(U[U.length-1])?"":"on ")+K),z&&(b=/ ([\d.+]+)$/.exec(z),v=b&&"/"==z.charAt(z.length-b[0].length-1),z={architecture:32,family:b&&!v?z.replace(b[0],""):z,version:b?b[1]:null,toString:function(){var t=this.version;return this.family+(t&&!v?" "+t:"")+(64==this.architecture?" 64-bit":"")}}),(b=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(N))&&!/\bi686\b/i.test(N)?(z&&(z.architecture=64,z.family=z.family.replace(RegExp(" *"+b),"")),W&&(/\bWOW64\b/i.test(t)||D&&/\w(?:86|32)$/.test(o.cpuClass||o.platform)&&!/\bWin64; x64\b/i.test(t))&&U.unshift("32-bit")):z&&/^OS X/.test(z.family)&&"Chrome"==W&&parseFloat(q)>=39&&(z.architecture=64),t||(t=null);var G={};return G.description=t,G.layout=F&&F[0],G.manufacturer=H,G.name=W,G.prerelease=B,G.product=K,G.ua=t,G.version=W&&q,G.os=z||{architecture:null,family:null,version:null,toString:function(){return"null"}},G.parse=g,G.toString=n,G.version&&U.unshift(q),G.name&&U.unshift(W),z&&W&&(z!=String(z).split(" ")[0]||z!=W.split(" ")[0]&&!K)&&U.push(K?"("+z+")":"on "+z),U.length&&(G.description=U.join(" ")),G}var b={function:!0,object:!0},m=b[typeof window]&&window||this,y=m,v=b[typeof e]&&e,w=b[typeof t]&&t&&!t.nodeType&&t,_=v&&w&&"object"==typeof r&&r;!_||_.global!==_&&_.window!==_&&_.self!==_||(m=_);var S=Math.pow(2,53)-1,E=/\bOpera/,k=this,x=Object.prototype,I=x.hasOwnProperty,T=x.toString,A=g();m.platform=A,void 0!==(i=function(){return A}.call(e,n,e,t))&&(t.exports=i)}).call(this)}).call(e,n(33)(t),n(2))},function(t,e){t.exports={name:"chabokpush",version:"1.0.2",description:"Chabok Javascript client for browsers, React-Native, Web Workers & Node.js",main:"dist/chabokpush.min.js",homepage:"http://chabokpush.com/",scripts:{build:"webpack --env build","demo-build":"webpack --env demo && node ./development.js","dev-build":"webpack --env demo && NODE_ENV=staging node ./development.js",dev:"webpack --progress --colors --watch --env dev",pretest:"webpack --env build",test:"mocha --compilers js:babel-core/register --colors ./test/*.spec.js -r ./test/setup.js","test:watch":"mocha --compilers js:babel-core/register --colors -w ./test/*.spec.js -r ./test/setup.js",release:"./release.sh"},repository:{type:"git",url:"https://github.com/chabokpush/chabok-client-js.git"},author:"ADP digital",license:"ISC",eslintConfig:{env:{browser:!0,node:!0},parserOptions:{ecmaVersion:6,sourceType:"module"},rules:{semi:2}},dependencies:{axios:"^0.17.1","es6-symbol":"^3.1.1","faye-websocket":"^0.11.1",mqtt:"^2.15.0",platform:"^1.3.4",shortid:"^2.2.8",store2:"^2.5.2"},devDependencies:{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.0.3","babel-loader":"^7.1.2","babel-plugin-add-module-exports":"0.2.1","babel-preset-es2015":"6.24.1",chai:"^4.1.2","copy-webpack-plugin":"^4.3.0",eslint:"^4.13.1","eslint-loader":"^1.9.0","html-webpack-plugin":"^2.30.1",mocha:"^4.0.1",webpack:"^3.10.0",yargs:"^10.0.3"}}},function(t,e,n){"use strict";t.exports=n(117)},function(t,e,n){"use strict";function r(e){return a.seed(e),t.exports}function i(e){return f=e,t.exports}function o(t){return void 0!==t&&a.characters(t),a.shuffled()}function s(){return c(f)}var a=n(11),u=(n(39),n(120)),c=n(121),l=n(122),f=n(123)||0;t.exports=s,t.exports.generate=s,t.exports.seed=r,t.exports.worker=i,t.exports.characters=o,t.exports.decode=u,t.exports.isValid=l},function(t,e,n){"use strict";function r(){return(o=(9301*o+49297)%233280)/233280}function i(t){o=t}var o=1;t.exports={nextValue:r,seed:i}},function(t,e,n){"use strict";function r(){if(!i||!i.getRandomValues)return 48&Math.floor(256*Math.random());var t=new Uint8Array(1);return i.getRandomValues(t),48&t[0]}var i="object"==typeof window&&(window.crypto||window.msCrypto);t.exports=r},function(t,e,n){"use strict";function r(t){var e=i.shuffled();return{version:15&e.indexOf(t.substr(0,1)),worker:15&e.indexOf(t.substr(1,1))}}var i=n(11);t.exports=r},function(t,e,n){"use strict";function r(t){var e="",n=Math.floor(.001*(Date.now()-u));return n===o?i++:(i=0,o=n),e+=s(a.lookup,c),e+=s(a.lookup,t),i>0&&(e+=s(a.lookup,i)),e+=s(a.lookup,n)}var i,o,s=n(39),a=n(11),u=1459707606518,c=6;t.exports=r},function(t,e,n){"use strict";function r(t){if(!t||"string"!=typeof t||t.length<6)return!1;for(var e=i.characters(),n=t.length,r=0;r=0)return;s[e]="set-cookie"===e?(s[e]?s[e]:[]).concat([n]):s[e]?s[e]+", "+n:n}}),s):s}},function(t,e,n){"use strict";var r=n(1);t.exports=r.isStandardBrowserEnv()?function(){function t(t){var e=t;return n&&(i.setAttribute("href",e),e=i.href),i.setAttribute("href",e),{href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}var e,n=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");return e=t(window.location.href),function(n){var i=r.isString(n)?t(n):n;return i.protocol===e.protocol&&i.host===e.host}}():function(){return function(){return!0}}()},function(t,e,n){"use strict";function r(){this.message="String contains an invalid character"}function i(t){for(var e,n,i=String(t),s="",a=0,u=o;i.charAt(0|a)||(u="=",a%1);s+=u.charAt(63&e>>8-a%1*8)){if((n=i.charCodeAt(a+=.75))>255)throw new r;e=e<<8|n}return s}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.prototype=new Error,r.prototype.code=5,r.prototype.name="InvalidCharacterError",t.exports=i},function(t,e,n){"use strict";var r=n(1);t.exports=r.isStandardBrowserEnv()?function(){return{write:function(t,e,n,i,o,s){var a=[];a.push(t+"="+encodeURIComponent(e)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(i)&&a.push("path="+i),r.isString(o)&&a.push("domain="+o),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(t,e,n){"use strict";function r(){this.handlers=[]}var i=n(1);r.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},r.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},r.prototype.forEach=function(t){i.forEach(this.handlers,function(e){null!==e&&t(e)})},t.exports=r},function(t,e,n){"use strict";function r(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var i=n(1),o=n(74),s=n(20),a=n(13),u=n(75),c=n(76);t.exports=function(t){return r(t),t.baseURL&&!u(t.url)&&(t.url=c(t.baseURL,t.url)),t.headers=t.headers||{},t.data=o(t.data,t.headers,t.transformRequest),t.headers=i.merge(t.headers.common||{},t.headers[t.method]||{},t.headers||{}),i.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]}),(t.adapter||a.adapter)(t).then(function(e){return r(t),e.data=o(e.data,e.headers,t.transformResponse),e},function(e){return s(e)||(r(t),e&&e.response&&(e.response.data=o(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)})}},function(t,e,n){"use strict";var r=n(1);t.exports=function(t,e,n){return r.forEach(n,function(n){t=n(t,e)}),t}},function(t,e,n){"use strict";t.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}},function(t,e,n){"use strict";t.exports=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}},function(t,e,n){"use strict";function r(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(t){e=t});var n=this;t(function(t){n.reason||(n.reason=new i(t),e(n.reason))})}var i=n(21);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var t;return{token:new r(function(e){t=e}),cancel:t}},t.exports=r},function(t,e,n){"use strict";t.exports=function(t){return function(e){return t.apply(null,e)}}},function(t,e,n){"use strict";(function(e){function r(t){var e;t.auth&&(e=t.auth.match(/^(.+):(.+)$/),e?(t.username=e[1],t.password=e[2]):t.username=t.auth)}function i(t,e){function n(t){return e.servers&&(t._reconnectCount&&t._reconnectCount!==e.servers.length||(t._reconnectCount=0),e.host=e.servers[t._reconnectCount].host,e.port=e.servers[t._reconnectCount].port,e.hostname=e.host,t._reconnectCount++),c[e.protocol](t,e)}if("object"!=typeof t||e||(e=t,t=null),e=e||{},t){var i=a.parse(t,!0);if(null!=i.port&&(i.port=Number(i.port)),e=u(i,e),null===e.protocol)throw new Error("Missing protocol");e.protocol=e.protocol.replace(/:$/,"")}if(r(e),e.query&&"string"==typeof e.query.clientId&&(e.clientId=e.query.clientId),e.cert&&e.key){if(!e.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs"].indexOf(e.protocol))switch(e.protocol){case"mqtt":e.protocol="mqtts";break;case"ws":e.protocol="wss";break;case"wx":e.protocol="wxs";break;default:throw new Error('Unknown protocol for secure connection: "'+e.protocol+'"!')}}if(!c[e.protocol]){var s=-1!==["mqtts","wss"].indexOf(e.protocol);e.protocol=["mqtt","mqtts","ws","wss","wx","wxs"].filter(function(t,e){return(!s||e%2!=0)&&"function"==typeof c[t]})[0]}if(!1===e.clean&&!e.clientId)throw new Error("Missing clientId for unclean clients");return new o(n,e)}var o=n(80),s=n(22),a=n(15),u=n(14),c={};"browser"!==e.title?(c.mqtt=n(34),c.tcp=n(34),c.ssl=n(16),c.tls=n(16),c.mqtts=n(16)):(c.wx=n(35),c.wxs=n(35)),c.ws=n(37),c.wss=n(37),t.exports=i,t.exports.connect=i,t.exports.MqttClient=o,t.exports.Store=s}).call(e,n(0))},function(t,e,n){"use strict";(function(e,r){function i(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function o(t,e,n){t.emit("packetsend",e),!h.writeToStream(e,t.stream)&&n?t.stream.once("drain",n):n&&n()}function s(t,e,n){t.outgoingStore.put(e,function(r){if(r)return n&&n(r);o(t,e,n)})}function a(){}function u(t,e){var n,r=this;if(!(this instanceof u))return new u(t,e);this.options=e||{};for(n in v)void 0===this.options[n]?this.options[n]=v[n]:this.options[n]=e[n];this.options.clientId="string"==typeof this.options.clientId?this.options.clientId:i(),this.streamBuilder=t,this.outgoingStore=this.options.outgoingStore||new l,this.incomingStore=this.options.incomingStore||new l,this.queueQoSZero=void 0===this.options.queueQoSZero||this.options.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this.nextId=Math.floor(65535*Math.random()),this.outgoing={},this.on("connect",function(){if(!this.disconnected){this.connected=!0;var t=null;t=this.outgoingStore.createStream(),t.once("readable",function(){function e(){var n,i=t.read(1);i&&(!r.disconnecting&&!r.reconnectTimer&&r.options.reconnectPeriod>0?(t.read(0),n=r.outgoing[i.messageId],r.outgoing[i.messageId]=function(t,r){n&&n(t,r),e()},r._sendPacket(i)):t.destroy&&t.destroy())}e()}).on("error",this.emit.bind(this,"error"))}}),this.on("close",function(){this.connected=!1,clearTimeout(this.connackTimer)}),this.on("connect",this._setupPingTimer),this.on("connect",function(){function t(){var n=e.shift(),i=null;n&&(i=n.packet,r._sendPacket(i,function(e){n.cb&&n.cb(e),t()}))}var e=this.queue;t()});var o=!0;this.on("connect",function(){!o&&this.options.clean&&Object.keys(this._resubscribeTopics).length>0&&(this.options.resubscribe?(this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics)):this._resubscribeTopics={}),o=!1}),this.on("close",function(){null!==r.pingTimer&&(r.pingTimer.clear(),r.pingTimer=null)}),this.on("close",this._setupReconnect),c.EventEmitter.call(this),this._setupStream()}var c=n(5),l=n(22),f=n(30),h=n(91),p=n(9).Writable,d=n(3),g=n(100),b=n(101),m=n(14),y=e.setImmediate||function(t){r.nextTick(t)},v={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0};d(u,c.EventEmitter),u.prototype._setupStream=function(){function t(){r.nextTick(e)}function e(){var e=l.shift(),n=c;e?i._handlePacket(e,t):(c=null,n())}var n,i=this,s=new p,u=h.parser(this.options),c=null,l=[];this._clearReconnect(),this.stream=this.streamBuilder(this),u.on("packet",function(t){l.push(t)}),s._write=function(t,n,r){c=r,u.parse(t),e()},this.stream.pipe(s),this.stream.on("error",a),f(this.stream,this.emit.bind(this,"close")),n=Object.create(this.options),n.cmd="connect",o(this,n),u.on("error",this.emit.bind(this,"error")),this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){i._cleanUp(!0)},this.options.connectTimeout)},u.prototype._handlePacket=function(t,e){switch(this.emit("packetreceive",t),t.cmd){case"publish":this._handlePublish(t,e);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(t),e();break;case"pubrel":this._handlePubrel(t,e);break;case"connack":this._handleConnack(t),e();break;case"pingresp":this._handlePingresp(t),e()}},u.prototype._checkDisconnecting=function(t){return this.disconnecting&&(t?t(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},u.prototype.publish=function(t,e,n,r){var i;if("function"==typeof n&&(r=n,n=null),n=m({qos:0,retain:!1,dup:!1},n),this._checkDisconnecting(r))return this;switch(i={cmd:"publish",topic:t,payload:e,qos:n.qos,retain:n.retain,messageId:this._nextId(),dup:n.dup},n.qos){case 1:case 2:this.outgoing[i.messageId]=r||a,this._sendPacket(i);break;default:this._sendPacket(i,r)}return this},u.prototype.subscribe=function(){var t,e,n=Array.prototype.slice.call(arguments),r=[],i=n.shift(),o=i.resubscribe,s=n.pop()||a,u=n.pop(),c=this;if(delete i.resubscribe,"string"==typeof i&&(i=[i]),"function"!=typeof s&&(u=s,s=a),null!==(e=b.validateTopics(i)))return y(s,new Error("Invalid topic "+e)),this;if(this._checkDisconnecting(s))return this;if(u=m({qos:0},u),Array.isArray(i)?i.forEach(function(t){(c._resubscribeTopics[t]0&&(c._resubscribeTopics[t.topic]=t.qos,l.push(t.topic))}),c.messageIdToTopic[t.messageId]=l}return this.outgoing[t.messageId]=function(t,e){if(!t)for(var n=e.granted,i=0;i0?this.once("outgoingEmpty",setTimeout.bind(null,r,10)):r(),this)},u.prototype.removeOutgoingMessage=function(t){var e=this.outgoing[t];return delete this.outgoing[t],this.outgoingStore.del({messageId:t},function(){e(new Error("Message removed"))}),this},u.prototype.reconnect=function(t){var e=this,n=function(){t?(e.options.incomingStore=t.incomingStore,e.options.outgoingStore=t.outgoingStore):(e.options.incomingStore=null,e.options.outgoingStore=null),e.incomingStore=e.options.incomingStore||new l,e.outgoingStore=e.options.outgoingStore||new l,e.disconnecting=!1,e.disconnected=!1,e._deferredReconnect=null,e._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=n:n(),this},u.prototype._reconnect=function(){this.emit("reconnect"),this._setupStream()},u.prototype._setupReconnect=function(){var t=this;!t.disconnecting&&!t.reconnectTimer&&t.options.reconnectPeriod>0&&(this.reconnecting||(this.emit("offline"),this.reconnecting=!0),t.reconnectTimer=setInterval(function(){t._reconnect()},t.options.reconnectPeriod))},u.prototype._clearReconnect=function(){this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},u.prototype._cleanUp=function(t,e){e&&this.stream.on("close",e),t?this.stream.destroy():this._sendPacket({cmd:"disconnect"},y.bind(null,this.stream.end.bind(this.stream))),this.disconnecting||(this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(this.pingTimer.clear(),this.pingTimer=null)},u.prototype._sendPacket=function(t,e){if(!this.connected)return void(0===(t.qos||0)&&this.queueQoSZero||"publish"!==t.cmd?this.queue.push({packet:t,cb:e}):t.qos>0?this.outgoingStore.put(t,function(t){if(t)return e&&e(t)}):e&&e(new Error("No connection to broker")));if(this._shiftPingInterval(),"publish"!==t.cmd)return void o(this,t,e);switch(t.qos){case 2:case 1:s(this,t,e);break;case 0:default:o(this,t,e)}},u.prototype._setupPingTimer=function(){var t=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=g(function(){t._checkPing()},1e3*this.options.keepalive))},u.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},u.prototype._checkPing=function(){this.pingResp?(this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):this._cleanUp(!0)},u.prototype._handlePingresp=function(){this.pingResp=!0},u.prototype._handleConnack=function(t){var e=t.returnCode,n=["","Unacceptable protocol version","Identifier rejected","Server unavailable","Bad username or password","Not authorized"];if(clearTimeout(this.connackTimer),0===e)this.reconnecting=!1,this.emit("connect",t);else if(e>0){var r=new Error("Connection refused: "+n[e]);r.code=e,this.emit("error",r)}},u.prototype._handlePublish=function(t,e){var n=t.topic.toString(),r=t.payload,i=t.qos,o=t.messageId,s=this;switch(i){case 2:this.incomingStore.put(t,function(){s._sendPacket({cmd:"pubrec",messageId:o},e)});break;case 1:this.emit("message",n,r,t),this.handleMessage(t,function(t){if(t)return e&&e(t);s._sendPacket({cmd:"puback",messageId:o},e)});break;case 0:this.emit("message",n,r,t),this.handleMessage(t,e)}},u.prototype.handleMessage=function(t,e){e()},u.prototype._handleAck=function(t){var e=t.messageId,n=t.cmd,r=null,i=this.outgoing[e],o=this;if(i){switch(n){case"pubcomp":case"puback":delete this.outgoing[e],this.outgoingStore.del(t,i);break;case"pubrec":r={cmd:"pubrel",qos:2,messageId:e},this._sendPacket(r);break;case"suback":if(delete this.outgoing[e],1===t.granted.length&&0!=(128&t.granted[0])){var s=this.messageIdToTopic[e];s&&s.forEach(function(t){delete o._resubscribeTopics[t]})}i(null,t);break;case"unsuback":delete this.outgoing[e],i(null);break;default:o.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}},u.prototype._handlePubrel=function(t,e){var n=t.messageId,r=this,i={cmd:"pubcomp",messageId:n};r.incomingStore.get(t,function(n,o){n||"pubrel"===o.cmd?r._sendPacket(i,e):(r.emit("message",o.topic,o.payload,o),r.incomingStore.put(t),r.handleMessage(o,function(t){if(t)return e&&e(t);r._sendPacket(i,e)}))})},u.prototype._nextId=function(){var t=this.nextId++;return 65535===t&&(this.nextId=1),t},u.prototype.getLastMessageId=function(){return 1===this.nextId?65535:this.nextId-1},t.exports=u}).call(e,n(2),n(0))},function(t,e,n){"use strict";function r(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function i(t){return 3*t.length/4-r(t)}function o(t){var e,n,i,o,s,a=t.length;o=r(t),s=new f(3*a/4-o),n=o>0?a-4:a;var u=0;for(e=0;e>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=l[t.charCodeAt(e)]<<2|l[t.charCodeAt(e+1)]>>4,s[u++]=255&i):1===o&&(i=l[t.charCodeAt(e)]<<10|l[t.charCodeAt(e+1)]<<4|l[t.charCodeAt(e+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}function s(t){return c[t>>18&63]+c[t>>12&63]+c[t>>6&63]+c[63&t]}function a(t,e,n){for(var r,i=[],o=e;ou?u:s+16383));return 1===r?(e=t[n-1],i+=c[e>>2],i+=c[e<<4&63],i+="=="):2===r&&(e=(t[n-2]<<8)+t[n-1],i+=c[e>>10],i+=c[e>>4&63],i+=c[e<<2&63],i+="="),o.push(i),o.join("")}e.byteLength=i,e.toByteArray=o,e.fromByteArray=u;for(var c=[],l=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,d=h.length;p>1,l=-7,f=n?i-1:0,h=n?-1:1,p=t[e+f];for(f+=h,o=p&(1<<-l)-1,p>>=-l,l+=a;l>0;o=256*o+t[e+f],f+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+t[e+f],f+=h,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var s,a,u,c=8*o-i-1,l=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+f>=1?h/u:h*Math.pow(2,1-f),e*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(e*u-1)*Math.pow(2,i),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;t[n+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;t[n+p]=255&s,p+=d,s/=256,c-=8);t[n+p-d]|=128*g}},function(t,e){},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e,n){t.copy(e,n)}var o=n(4).Buffer;t.exports=function(){function t(){r(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n},t.prototype.concat=function(t){if(0===this.length)return o.alloc(0);if(1===this.length)return this.head.data;for(var e=o.allocUnsafe(t>>>0),n=this.head,r=0;n;)i(n.data,e,r),r+=n.data.length,n=n.next;return e},t}()},function(t,e,n){function r(t,e){this._id=t,this._clearFn=e}var i=Function.prototype.apply;e.setTimeout=function(){return new r(i.call(setTimeout,window,arguments),clearTimeout)},e.setInterval=function(){return new r(i.call(setInterval,window,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(window,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n(86),e.setImmediate=setImmediate,e.clearImmediate=clearImmediate},function(t,e,n){(function(t,e){!function(t,n){"use strict";function r(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n0)&&this[this._states[this._stateCounter]]()&&!this.error;)++this._stateCounter>=this._states.length&&(this._stateCounter=0);return this._list.length},r.prototype._parseHeader=function(){var t=this._list.readUInt8(0);return this.packet.cmd=u.types[t>>u.CMD_SHIFT],this.packet.retain=0!=(t&u.RETAIN_MASK),this.packet.qos=t>>u.QOS_SHIFT&u.QOS_MASK,this.packet.dup=0!=(t&u.DUP_MASK),this._list.consume(1),!0},r.prototype._parseLength=function(){for(var t,e=0,n=1,r=0,i=!0;e<5&&(t=this._list.readUInt8(e++),r+=n*(t&u.LENGTH_MASK),n*=128,0!=(t&u.LENGTH_FIN_MASK));)if(this._list.length<=e){i=!1;break}return i&&(this.packet.length=r,this._list.consume(e)),i},r.prototype._parsePayload=function(){var t=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseMessageId();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":case"disconnect":break;default:this._emitError(new Error("Not supported"))}t=!0}return t},r.prototype._parseConnect=function(){var t,e,n,r,i,o,s={},a=this.packet;if(null===(t=this._parseString()))return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==t&&"MQIsdp"!==t)return this._emitError(new Error("Invalid protocolId"));if(a.protocolId=t,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(a.protocolVersion=this._list.readUInt8(this._pos),3!==a.protocolVersion&&4!==a.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(++this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(s.username=this._list.readUInt8(this._pos)&u.USERNAME_MASK,s.password=this._list.readUInt8(this._pos)&u.PASSWORD_MASK,s.will=this._list.readUInt8(this._pos)&u.WILL_FLAG_MASK,s.will&&(a.will={},a.will.retain=0!=(this._list.readUInt8(this._pos)&u.WILL_RETAIN_MASK),a.will.qos=(this._list.readUInt8(this._pos)&u.WILL_QOS_MASK)>>u.WILL_QOS_SHIFT),a.clean=0!=(this._list.readUInt8(this._pos)&u.CLEAN_SESSION_MASK),this._pos++,a.keepalive=this._parseNum(),-1===a.keepalive)return this._emitError(new Error("Packet too short"));if(null===(e=this._parseString()))return this._emitError(new Error("Packet too short"));if(a.clientId=e,s.will){if(null===(n=this._parseString()))return this._emitError(new Error("Cannot parse will topic"));if(a.will.topic=n,null===(r=this._parseBuffer()))return this._emitError(new Error("Cannot parse will payload"));a.will.payload=r}if(s.username){if(null===(o=this._parseString()))return this._emitError(new Error("Cannot parse username"));a.username=o}if(s.password){if(null===(i=this._parseBuffer()))return this._emitError(new Error("Cannot parse password"));a.password=i}return a},r.prototype._parseConnack=function(){var t=this.packet;return this._list.length<2?null:(t.sessionPresent=!!(this._list.readUInt8(this._pos++)&u.SESSIONPRESENT_MASK),t.returnCode=this._list.readUInt8(this._pos),-1===t.returnCode?this._emitError(new Error("Cannot parse return code")):void 0)},r.prototype._parsePublish=function(){var t=this.packet;if(t.topic=this._parseString(),null===t.topic)return this._emitError(new Error("Cannot parse topic"));t.qos>0&&!this._parseMessageId()||(t.payload=this._list.slice(this._pos,t.length))},r.prototype._parseSubscribe=function(){var t,e,n=this.packet;if(1!==n.qos)return this._emitError(new Error("Wrong subscribe header"));if(n.subscriptions=[],this._parseMessageId())for(;this._posthis._list.length||r>this.packet.length?null:(e=this._list.toString("utf8",this._pos,r),this._pos+=n,e)},r.prototype._parseBuffer=function(){var t,e=this._parseNum(),n=e+this._pos;return-1===e||n>this._list.length||n>this.packet.length?null:(t=this._list.slice(this._pos,n),this._pos+=e,t)},r.prototype._parseNum=function(){if(this._list.length-this._pos<2)return-1;var t=this._list.readUInt16BE(this._pos);return this._pos+=2,t},r.prototype._newPacket=function(){return this.packet&&(this._list.consume(this.packet.length),this.emit("packet",this.packet)),this.packet=new a,!0},r.prototype._emitError=function(t){this.error=t,this.emit("error",t)},t.exports=r},function(t,e,n){(function(e){function r(t){if(!(this instanceof r))return new r(t);if(this._bufs=[],this.length=0,"function"==typeof t){this._callback=t;var e=function(t){this._callback&&(this._callback(t),this._callback=null)}.bind(this);this.on("pipe",function(t){t.on("error",e)}),this.on("unpipe",function(t){t.removeListener("error",e)})}else this.append(t);i.call(this)}var i=n(94);n(95).inherits(r,i),r.prototype._offset=function(t){var e,n=0,r=0;if(0===t)return[0,0];for(;rthis.length)&&(i=this.length),r>=this.length)return t||new e(0);if(i<=0)return t||new e(0);var o,s,a=!!t,u=this._offset(r),c=i-r,l=c,f=a&&n||0,h=u[1];if(0===r&&i==this.length){if(!a)return 1===this._bufs.length?this._bufs[0]:e.concat(this._bufs,this.length);for(s=0;so)){this._bufs[s].copy(t,f,h,h+l);break}this._bufs[s].copy(t,f,h),f+=o,l-=o,h&&(h=0)}return t},r.prototype.shallowSlice=function(t,e){t=t||0,e=e||this.length,t<0&&(t+=this.length),e<0&&(e+=this.length);var n=this._offset(t),i=this._offset(e),o=this._bufs.slice(n[0],i[0]+1);return 0==i[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,i[1]),0!=n[1]&&(o[0]=o[0].slice(n[1])),new r(o)},r.prototype.toString=function(t,e,n){return this.slice(e,n).toString(t)},r.prototype.consume=function(t){for(;this._bufs.length;){if(!(t>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(t),this.length-=t;break}t-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},r.prototype.duplicate=function(){for(var t=0,e=new r;t=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),g(n)?r.showHidden=n:n&&e._extend(r,n),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),u(r,t,r.depth)}function o(t,e){var n=i.styles[e];return n?"["+i.colors[n][0]+"m"+t+"["+i.colors[n][1]+"m":t}function s(t,e){return t}function a(t){var e={};return t.forEach(function(t,n){e[t]=!0}),e}function u(t,n,r){if(t.customInspect&&n&&I(n.inspect)&&n.inspect!==e.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,t);return v(i)||(i=u(t,i,r)),i}var o=c(t,n);if(o)return o;var s=Object.keys(n),g=a(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(n)),x(n)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return l(n);if(0===s.length){if(I(n)){var b=n.name?": "+n.name:"";return t.stylize("[Function"+b+"]","special")}if(S(n))return t.stylize(RegExp.prototype.toString.call(n),"regexp");if(k(n))return t.stylize(Date.prototype.toString.call(n),"date");if(x(n))return l(n)}var m="",y=!1,w=["{","}"];if(d(n)&&(y=!0,w=["[","]"]),I(n)){m=" [Function"+(n.name?": "+n.name:"")+"]"}if(S(n)&&(m=" "+RegExp.prototype.toString.call(n)),k(n)&&(m=" "+Date.prototype.toUTCString.call(n)),x(n)&&(m=" "+l(n)),0===s.length&&(!y||0==n.length))return w[0]+m+w[1];if(r<0)return S(n)?t.stylize(RegExp.prototype.toString.call(n),"regexp"):t.stylize("[Object]","special");t.seen.push(n);var _;return _=y?f(t,n,r,g,s):s.map(function(e){return h(t,n,r,g,e,y)}),t.seen.pop(),p(_,m,w)}function c(t,e){if(_(e))return t.stylize("undefined","undefined");if(v(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}return y(e)?t.stylize(""+e,"number"):g(e)?t.stylize(""+e,"boolean"):b(e)?t.stylize("null","null"):void 0}function l(t){return"["+Error.prototype.toString.call(t)+"]"}function f(t,e,n,r,i){for(var o=[],s=0,a=e.length;s-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n"))):a=t.stylize("[Circular]","special")),_(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function p(t,e,n){var r=0;return t.reduce(function(t,e){return r++,e.indexOf("\n")>=0&&r++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1]:n[0]+e+" "+t.join(", ")+" "+n[1]}function d(t){return Array.isArray(t)}function g(t){return"boolean"==typeof t}function b(t){return null===t}function m(t){return null==t}function y(t){return"number"==typeof t}function v(t){return"string"==typeof t}function w(t){return"symbol"==typeof t}function _(t){return void 0===t}function S(t){return E(t)&&"[object RegExp]"===A(t)}function E(t){return"object"==typeof t&&null!==t}function k(t){return E(t)&&"[object Date]"===A(t)}function x(t){return E(t)&&("[object Error]"===A(t)||t instanceof Error)}function I(t){return"function"==typeof t}function T(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t}function A(t){return Object.prototype.toString.call(t)}function O(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var R=/%[sdj%]/g;e.format=function(t){if(!v(t)){for(var e=[],n=0;n=o)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return t}}),a=r[n];n>8,0,!0),e.writeUInt8(255&t,1,!0),e}function i(){for(var t=0;t0){t=new Array(arguments.length-2);for(var e=0;e1&&(r=n[0]+"@",t=n[1]),t=t.replace(C,"."),r+a(t.split("."),e).join(".")}function c(t){for(var e,n,r=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(t-=65536,e+=L(t>>>10&1023|55296),t=56320|1023&t),e+=L(t)}).join("")}function f(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:_}function h(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function p(t,e,n){var r=0;for(t=n?j(t/x):t>>1,t+=j(t/e);t>M*E>>1;r+=_)t=j(t/M);return j(r+(M+1)*t/(t+k))}function d(t){var e,n,r,i,o,a,u,c,h,d,g=[],b=t.length,m=0,y=T,v=I;for(n=t.lastIndexOf(A),n<0&&(n=0),r=0;r=128&&s("not-basic"),g.push(t.charCodeAt(r));for(i=n>0?n+1:0;i=b&&s("invalid-input"),c=f(t.charCodeAt(i++)),(c>=_||c>j((w-m)/a))&&s("overflow"),m+=c*a,h=u<=v?S:u>=v+E?E:u-v,!(cj(w/d)&&s("overflow"),a*=d;e=g.length+1,v=p(m-o,e,0==o),j(m/e)>w-y&&s("overflow"),y+=j(m/e),m%=e,g.splice(m++,0,y)}return l(g)}function g(t){var e,n,r,i,o,a,u,l,f,d,g,b,m,y,v,k=[];for(t=c(t),b=t.length,e=T,n=0,o=I,a=0;a=e&&gj((w-n)/m)&&s("overflow"),n+=(u-e)*m,e=u,a=0;aw&&s("overflow"),g==e){for(l=n,f=_;d=f<=o?S:f>=o+E?E:f-o,!(l= 0x80 (not a basic code point)","invalid-input":"Invalid input"},M=_-S,j=Math.floor,L=String.fromCharCode;v={version:"1.4.1",ucs2:{decode:c,encode:l},decode:d,encode:g,toASCII:m,toUnicode:b},void 0!==(i=function(){return v}.call(e,n,e,t))&&(t.exports=i)}()}).call(e,n(33)(t),n(2))},function(t,e,n){"use strict";t.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},function(t,e,n){"use strict";e.decode=e.parse=n(105),e.encode=e.stringify=n(106)},function(t,e,n){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,n,o){e=e||"&",n=n||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var l=0;l=0?(f=g.substr(0,b),h=g.substr(b+1)):(f=g,h=""),p=decodeURIComponent(f),d=decodeURIComponent(h),r(s,p)?i(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,n){"use strict";function r(t,e){if(t.map)return t.map(e);for(var n=[],r=0;r64)&&!/\s|\/|\\|\+|\*|#/gi.test(t))},encryptedStorage:function(){var t=this;return{get:function(e){return i.get(e)?JSON.parse(t.decrypt(i.get(e))):{}},set:function(e,n){return n="object"===(void 0===n?"undefined":r(n))?JSON.stringify(n):n,i.set(e,t.encrypt(n)),t}}},decrypt:function(t){return String(t).split("").map(function(t,e){return String.fromCharCode(t.charCodeAt(0)-s.charCodeAt(e%s.length))}).join("")},encrypt:function(t){return String(t).split("").map(function(t,e){return String.fromCharCode(t.charCodeAt(0)+s.charCodeAt(e%s.length))}).join("")},getAppDomain:function(t,e){return e?o.HOST_DEV:-1===o.EXCLUSIVE_APPIDS.indexOf(t)?t.replace("-demo","")+"."+o.HOST:o.HOST},defaultDevice:function(t){var e=t.appId,r=t.userId,i=t.token,s=t.realtime;i=i||"disabled";var u=navigator.connection||navigator.mozConnection||navigator.webkitConnection||{type:null};return i=Object.keys(i).length?JSON.stringify(Object.assign(i,{expirationTime:0})):"notSupported"===i?"---":"disabled",{realtime:s,launchCount:+this.encryptedStorage().get(o.STORAGE_KEY).launchCount,launchTime:Date.now(),appId:e,userId:r,deviceToken:i,deviceType:"web",deviceModel:a.name?a.name.toLowerCase():"NodeJS",osVersion:a.os.version,deviceManufacture:a.os.family,browserVersion:a.version,appVersion:n(115).version,subscriptions:o.DEFAULT_CHANNELS,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,connection:u.type}},toTopicName:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"user",i=void 0,o=void 0;switch(r){case"user":var s=n.split("/");"public"===s[0]?(i=s[0],o=s[1]):(i=e,o=s[0]);break;case"publish":i="*"===e?"public":e,o=n;break;case"event":case"track":i=n,o=e||"+";break;default:throw new Error("Invalid topic type.")}return["app",t,r,i,o].join("/")},fromChabokChannel:function(t){var e=t.split("/"),n=void 0;switch(e.length){case 1:n="public/"+e[0];break;case 2:if("public"!==e[0]&&"private"!==e[0])throw new Error("Invalid channel name format, please read documentations.");n="public"===e[0]?"public/"+e[1]:e[1];break;default:throw new Error("Invalid channel name format, please read documentations.")}return n},toChabokMessage:function(t,e){var n=t.split("/"),r=n[3]+"/"+n[4];try{var i=JSON.parse(e);return i.channel=r,i}catch(t){return e}},toEventMessage:function(t,e){var n=t.split("/"),r=n[1],i=n[3],o=n[4],s={appId:r,eventName:i,deviceId:o,receivedAt:Date.now()};try{return s.data=JSON.parse(e),s.createdAt=s.data.createdAt,s.id=s.data.id,s}catch(t){return e}}};t.exports=u},function(t,e){!function(e,n){var r={version:"2.5.2",areas:{},apis:{},inherit:function(t,e){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n]);return e},stringify:function(t){return void 0===t||"function"==typeof t?t+"":JSON.stringify(t)},parse:function(t){try{return JSON.parse(t)}catch(e){return t}},fn:function(t,e){r.storeAPI[t]=e;for(var n in r.apis)r.apis[n][t]=e},get:function(t,e){return t.getItem(e)},set:function(t,e,n){t.setItem(e,n)},remove:function(t,e){t.removeItem(e)},key:function(t,e){return t.key(e)},length:function(t){return t.length},clear:function(t){t.clear()},Store:function(t,e,n){var i=r.inherit(r.storeAPI,function(t,e,n){return 0===arguments.length?i.getAll():"function"==typeof e?i.transact(t,e,n):void 0!==e?i.set(t,e,n):"string"==typeof t||"number"==typeof t?i.get(t):t?i.setAll(t,e):i.clear()});i._id=t;try{e.setItem("_safariPrivate_","sucks"),i._area=e,e.removeItem("_safariPrivate_")}catch(t){}return i._area||(i._area=r.inherit(r.storageAPI,{items:{},name:"fake"})),i._ns=n||"",r.areas[t]||(r.areas[t]=i._area),r.apis[i._ns+i._id]||(r.apis[i._ns+i._id]=i),i},storeAPI:{area:function(t,e){var n=this[t];return n&&n.area||(n=r.Store(t,e,this._ns),this[t]||(this[t]=n)),n},namespace:function(t,e){if(!t)return this._ns?this._ns.substring(0,this._ns.length-1):"";var n=t,i=this[n];return i&&i.namespace||(i=r.Store(this._id,this._area,this._ns+n+"."),this[n]||(this[n]=i),e||i.area("session",r.areas.session)),i},isFake:function(){return"fake"===this._area.name},toString:function(){return"store"+(this._ns?"."+this.namespace():"")+"["+this._id+"]"},has:function(t){return this._area.has?this._area.has(this._in(t)):!!(this._in(t)in this._area)},size:function(){return this.keys().length},each:function(t,e){for(var n=0,i=r.length(this._area);nr.length(this._area)&&(i--,n--)}return e||this},keys:function(){return this.each(function(t,e){e.push(t)},[])},get:function(t,e){var n=r.get(this._area,this._in(t));return null!==n?r.parse(n):e||n},getAll:function(){return this.each(function(t,e){e[t]=this.get(t)},{})},transact:function(t,e,n){var r=this.get(t,n),i=e(r);return this.set(t,void 0===i?r:i),this},set:function(t,e,n){var i=this.get(t);return null!=i&&!1===n?e:r.set(this._area,this._in(t),r.stringify(e),n)||i},setAll:function(t,e){var n,r;for(var i in t)r=t[i],this.set(i,r,e)!==r&&(n=!0);return n},remove:function(t){var e=this.get(t);return r.remove(this._area,this._in(t)),e},clear:function(){return this._ns?this.each(function(t){r.remove(this._area,this._in(t))},1):r.clear(this._area),this},clearAll:function(){var t=this._area;for(var e in r.areas)r.areas.hasOwnProperty(e)&&(this._area=r.areas[e],this.clear());return this._area=t,this},_in:function(t){return"string"!=typeof t&&(t=r.stringify(t)),this._ns?this._ns+t:t},_out:function(t){return this._ns?t&&0===t.indexOf(this._ns)?t.substring(this._ns.length):void 0:t}},storageAPI:{length:0,has:function(t){return this.items.hasOwnProperty(t)},key:function(t){var e=0;for(var n in this.items)if(this.has(n)&&t===e++)return n},setItem:function(t,e){this.has(t)||this.length++,this.items[t]=e},removeItem:function(t){this.has(t)&&(delete this.items[t],this.length--)},getItem:function(t){return this.has(t)?this.items[t]:null},clear:function(){for(var t in this.items)this.removeItem(t)},toString:function(){return this.length+" items in "+this.name+"Storage"}}},i=r.Store("local",function(){try{return localStorage}catch(t){}}());i.local=i,i._=r,i.area("session",function(){try{return sessionStorage}catch(t){}}()),"function"==typeof n&&void 0!==n.amd?n("store2",[],function(){return i}):void 0!==t&&t.exports?t.exports=i:(e.store&&(r.conflict=e.store),e.store=i)}(this,this.define)},function(t,e,n){(function(t,r){var i;(function(){"use strict";function o(t){return t=String(t),t.charAt(0).toUpperCase()+t.slice(1)}function s(t,e,n){var r={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return e&&n&&/^Win/i.test(t)&&!/^Windows Phone /i.test(t)&&(r=r[/[\d.]+$/.exec(t)])&&(t="Windows "+r),t=String(t),e&&n&&(t=t.replace(RegExp(e,"i"),n)),t=u(t.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}function a(t,e){var n=-1,r=t?t.length:0;if("number"==typeof r&&r>-1&&r<=S)for(;++n3&&"WebKit"||/\bOpera\b/.test(W)&&(/\bOPR\b/.test(t)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(F)&&"WebKit"||!F&&/\bMSIE\b/i.test(t)&&("Mac OS"==z?"Tasman":"Trident")||"WebKit"==F&&/\bPlayStation\b(?! Vita\b)/i.test(W)&&"NetFront")&&(F=[b]),"IE"==W&&(b=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(W+=" Mobile",z="Windows Phone "+(/\+$/.test(b)?b:b+".x"),U.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(W="IE Mobile",z="Windows Phone 8.x",U.unshift("desktop mode"),q||(q=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=W&&"Trident"==F&&(b=/\brv:([\d.]+)/.exec(t))&&(W&&U.push("identifying as "+W+(q?" "+q:"")),W="IE",q=b[1]),D){if(f(r,"global"))if(O&&(b=O.lang.System,N=b.getProperty("os.arch"),z=z||b.getProperty("os.name")+" "+b.getProperty("os.version")),w&&f(r,"system")&&(b=[r.system])[0]){z||(z=b[0].os||null);try{b[1]=r.require("ringo/engine").version,q=b[1].join("."),W="RingoJS"}catch(t){b[0].global.system==r.system&&(W="Narwhal")}}else"object"==typeof r.process&&!r.process.browser&&(b=r.process)?"object"==typeof b.versions?"string"==typeof b.versions.electron?(U.push("Node "+b.versions.node),W="Electron",q=b.versions.electron):"string"==typeof b.versions.nw&&(U.push("Chromium "+q,"Node "+b.versions.node),W="NW.js",q=b.versions.nw):(W="Node.js",N=b.arch,z=b.platform,q=/[\d.]+/.exec(b.version),q=q?q[0]:"unknown"):R&&(W="Rhino");else l(b=r.runtime)==S?(W="Adobe AIR",z=b.flash.system.Capabilities.os):l(b=r.phantom)==A?(W="PhantomJS",q=(b=b.version||null)&&b.major+"."+b.minor+"."+b.patch):"number"==typeof M.documentMode&&(b=/\bTrident\/(\d+)/i.exec(t))?(q=[q,M.documentMode],(b=+b[1]+4)!=q[1]&&(U.push("IE "+q[1]+" mode"),F&&(F[1]=""),q[1]=b),q="IE"==W?String(q[1].toFixed(1)):q[0]):"number"==typeof M.documentMode&&/^(?:Chrome|Firefox)\b/.test(W)&&(U.push("masking as "+W+" "+q),W="IE",q="11.0",F=["Trident"],z="Windows");z=z&&u(z)}if(q&&(b=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(q)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(D&&o.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(B=/b/i.test(b)?"beta":"alpha",q=q.replace(RegExp(b+"\\+?$"),"")+("beta"==B?P:C)+(/\d+\+?/.exec(b)||"")),"Fennec"==W||"Firefox"==W&&/\b(?:Android|Firefox OS)\b/.test(z))W="Firefox Mobile";else if("Maxthon"==W&&q)q=q.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(K))"Xbox 360"==K&&(z=null),"Xbox 360"==K&&/\bIEMobile\b/.test(t)&&U.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(W)&&(!W||K||/Browser|Mobi/.test(W))||"Windows CE"!=z&&!/Mobi/i.test(t))if("IE"==W&&D)try{null===r.external&&U.unshift("platform preview")}catch(t){U.unshift("embedded")}else(/\bBlackBerry\b/.test(K)||/\bBB10\b/.test(t))&&(b=(RegExp(K.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||q)?(b=[b,/BB10/.test(t)],z=(b[1]?(K=null,H="BlackBerry"):"Device Software")+" "+b[0],q=null):this!=c&&"Wii"!=K&&(D&&j||/Opera/.test(W)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==W&&/\bOS X (?:\d+\.){2,}/.test(z)||"IE"==W&&(z&&!/^Win/.test(z)&&q>5.5||/\bWindows XP\b/.test(z)&&q>8||8==q&&!/\bTrident\b/.test(t)))&&!E.test(b=g.call(c,t.replace(E,"")+";"))&&b.name&&(b="ing as "+b.name+((b=b.version)?" "+b:""),E.test(W)?(/\bIE\b/.test(b)&&"Mac OS"==z&&(z=null),b="identify"+b):(b="mask"+b,W=L?u(L.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(b)&&(z=null),D||(q=null)),F=["Presto"],U.push(b));else W+=" Mobile";(b=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(b=[parseFloat(b.replace(/\.(\d)$/,".0$1")),b],"Safari"==W&&"+"==b[1].slice(-1)?(W="WebKit Nightly",B="alpha",q=b[1].slice(0,-1)):q!=b[1]&&q!=(b[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(q=null),b[1]=(/\bChrome\/([\d.]+)/i.exec(t)||0)[1],537.36==b[0]&&537.36==b[2]&&parseFloat(b[1])>=28&&"WebKit"==F&&(F=["Blink"]),D&&(_||b[1])?(F&&(F[1]="like Chrome"),b=b[1]||(b=b[0],b<530?1:b<532?2:b<532.05?3:b<533?4:b<534.03?5:b<534.07?6:b<534.1?7:b<534.13?8:b<534.16?9:b<534.24?10:b<534.3?11:b<535.01?12:b<535.02?"13+":b<535.07?15:b<535.11?16:b<535.19?17:b<536.05?18:b<536.1?19:b<537.01?20:b<537.11?"21+":b<537.13?23:b<537.18?24:b<537.24?25:b<537.36?26:"Blink"!=F?"27":"28")):(F&&(F[1]="like Safari"),b=b[0],b=b<400?1:b<500?2:b<526?3:b<533?4:b<534?"4+":b<535?5:b<537?6:b<538?7:b<601?8:"8"),F&&(F[1]+=" "+(b+="number"==typeof b?".x":/[.+]/.test(b)?"":"+")),"Safari"==W&&(!q||parseInt(q)>45)&&(q=b)),"Opera"==W&&(b=/\bzbov|zvav$/.exec(z))?(W+=" ",U.unshift("desktop mode"),"zvav"==b?(W+="Mini",q=null):W+="Mobile",z=z.replace(RegExp(" *"+b+"$"),"")):"Safari"==W&&/\bChrome\b/.exec(F&&F[1])&&(U.unshift("desktop mode"),W="Chrome Mobile",q=null,/\bOS X\b/.test(z)?(H="Apple",z="iOS 4.3+"):z=null),q&&0==q.indexOf(b=/[\d.]+$/.exec(z))&&t.indexOf("/"+b+"-")>-1&&(z=d(z.replace(b,""))),F&&!/\b(?:Avant|Nook)\b/.test(W)&&(/Browser|Lunascape|Maxthon/.test(W)||"Safari"!=W&&/^iOS/.test(z)&&/\bSafari\b/.test(F[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|Web)/.test(W)&&F[1])&&(b=F[F.length-1])&&U.push(b),U.length&&(U=["("+U.join("; ")+")"]),H&&K&&K.indexOf(H)<0&&U.push("on "+H),K&&U.push((/^on /.test(U[U.length-1])?"":"on ")+K),z&&(b=/ ([\d.+]+)$/.exec(z),v=b&&"/"==z.charAt(z.length-b[0].length-1),z={architecture:32,family:b&&!v?z.replace(b[0],""):z,version:b?b[1]:null,toString:function(){var t=this.version;return this.family+(t&&!v?" "+t:"")+(64==this.architecture?" 64-bit":"")}}),(b=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(N))&&!/\bi686\b/i.test(N)?(z&&(z.architecture=64,z.family=z.family.replace(RegExp(" *"+b),"")),W&&(/\bWOW64\b/i.test(t)||D&&/\w(?:86|32)$/.test(o.cpuClass||o.platform)&&!/\bWin64; x64\b/i.test(t))&&U.unshift("32-bit")):z&&/^OS X/.test(z.family)&&"Chrome"==W&&parseFloat(q)>=39&&(z.architecture=64),t||(t=null);var G={};return G.description=t,G.layout=F&&F[0],G.manufacturer=H,G.name=W,G.prerelease=B,G.product=K,G.ua=t,G.version=W&&q,G.os=z||{architecture:null,family:null,version:null,toString:function(){return"null"}},G.parse=g,G.toString=n,G.version&&U.unshift(q),G.name&&U.unshift(W),z&&W&&(z!=String(z).split(" ")[0]||z!=W.split(" ")[0]&&!K)&&U.push(K?"("+z+")":"on "+z),U.length&&(G.description=U.join(" ")),G}var b={function:!0,object:!0},m=b[typeof window]&&window||this,y=m,v=b[typeof e]&&e,w=b[typeof t]&&t&&!t.nodeType&&t,_=v&&w&&"object"==typeof r&&r;!_||_.global!==_&&_.window!==_&&_.self!==_||(m=_);var S=Math.pow(2,53)-1,E=/\bOpera/,k=this,x=Object.prototype,I=x.hasOwnProperty,T=x.toString,A=g();m.platform=A,void 0!==(i=function(){return A}.call(e,n,e,t))&&(t.exports=i)}).call(this)}).call(e,n(33)(t),n(2))},function(t,e){t.exports={name:"chabokpush",version:"1.0.3",description:"Chabok Javascript client for browsers, React-Native, Web Workers & Node.js",main:"dist/chabokpush.min.js",homepage:"http://chabokpush.com/",scripts:{build:"webpack --env build","demo-build":"webpack --env demo && node ./development.js","dev-build":"webpack --env demo && NODE_ENV=staging node ./development.js",dev:"webpack --progress --colors --watch --env dev",pretest:"webpack --env build",test:"mocha --compilers js:babel-core/register --colors ./test/*.spec.js -r ./test/setup.js","test:watch":"mocha --compilers js:babel-core/register --colors -w ./test/*.spec.js -r ./test/setup.js",release:"./release.sh"},repository:{type:"git",url:"https://github.com/chabokpush/chabok-client-js.git"},author:"ADP digital",license:"ISC",eslintConfig:{env:{browser:!0,node:!0},parserOptions:{ecmaVersion:6,sourceType:"module"},rules:{semi:2}},dependencies:{axios:"^0.17.1","es6-symbol":"^3.1.1","faye-websocket":"^0.11.1",mqtt:"^2.15.0",platform:"^1.3.4",shortid:"^2.2.8",store2:"^2.5.2"},devDependencies:{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.0.3","babel-loader":"^7.1.2","babel-plugin-add-module-exports":"0.2.1","babel-preset-es2015":"6.24.1",chai:"^4.1.2","copy-webpack-plugin":"^4.3.0",eslint:"^4.13.1","eslint-loader":"^1.9.0","html-webpack-plugin":"^2.30.1",mocha:"^4.0.1",webpack:"^3.10.0",yargs:"^10.0.3"}}},function(t,e,n){"use strict";t.exports=n(117)},function(t,e,n){"use strict";function r(e){return a.seed(e),t.exports}function i(e){return f=e,t.exports}function o(t){return void 0!==t&&a.characters(t),a.shuffled()}function s(){return c(f)}var a=n(11),u=(n(39),n(120)),c=n(121),l=n(122),f=n(123)||0;t.exports=s,t.exports.generate=s,t.exports.seed=r,t.exports.worker=i,t.exports.characters=o,t.exports.decode=u,t.exports.isValid=l},function(t,e,n){"use strict";function r(){return(o=(9301*o+49297)%233280)/233280}function i(t){o=t}var o=1;t.exports={nextValue:r,seed:i}},function(t,e,n){"use strict";function r(){if(!i||!i.getRandomValues)return 48&Math.floor(256*Math.random());var t=new Uint8Array(1);return i.getRandomValues(t),48&t[0]}var i="object"==typeof window&&(window.crypto||window.msCrypto);t.exports=r},function(t,e,n){"use strict";function r(t){var e=i.shuffled();return{version:15&e.indexOf(t.substr(0,1)),worker:15&e.indexOf(t.substr(1,1))}}var i=n(11);t.exports=r},function(t,e,n){"use strict";function r(t){var e="",n=Math.floor(.001*(Date.now()-u));return n===o?i++:(i=0,o=n),e+=s(a.lookup,c),e+=s(a.lookup,t),i>0&&(e+=s(a.lookup,i)),e+=s(a.lookup,n)}var i,o,s=n(39),a=n(11),u=1459707606518,c=6;t.exports=r},function(t,e,n){"use strict";function r(t){if(!t||"string"!=typeof t||t.length<6)return!1;for(var e=i.characters(),n=t.length,r=0;r - Chabok Web SDK Sample v1.0.2 + Chabok Web SDK Sample v1.0.3