Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

centrifuge

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

centrifuge - npm Package Compare versions

Comparing version 1.4.7 to 1.4.8

2

bower.json
{
"name": "centrifuge",
"version": "1.4.7",
"version": "1.4.8",
"ignore": [

@@ -5,0 +5,0 @@ "gulp",

@@ -1,2 +0,3 @@

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.Centrifuge=e()}}(function(){var e;return function t(e,n,i){function s(o,c){if(!n[o]){if(!e[o]){var a="function"==typeof require&&require;if(!c&&a)return a(o,!0);if(r)return r(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var h=n[o]={exports:{}};e[o][0].call(h.exports,function(t){var n=e[o][1][t];return s(n?n:t)},h,h.exports,t,e,n,i)}return n[o].exports}for(var r="function"==typeof require&&require,o=0;o<i.length;o++)s(i[o]);return s}({1:[function(e,t){function n(){}var i=t.exports={};i.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.MutationObserver,n="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};var i=[];if(t){var s=document.createElement("div"),r=new MutationObserver(function(){var e=i.slice();i.length=0,e.forEach(function(e){e()})});return r.observe(s,{attributes:!0}),function(e){i.length||s.setAttribute("yes","no"),i.push(e)}}return n?(window.addEventListener("message",function(e){var t=e.source;if((t===window||null===t)&&"process-tick"===e.data&&(e.stopPropagation(),i.length>0)){var n=i.shift();n()}},!0),function(e){i.push(e),window.postMessage("process-tick","*")}):function(e){setTimeout(e,0)}}(),i.title="browser",i.browser=!0,i.env={},i.argv=[],i.on=n,i.addListener=n,i.once=n,i.off=n,i.removeListener=n,i.removeAllListeners=n,i.emit=n,i.binding=function(){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(){throw new Error("process.chdir is not supported")}},{}],2:[function(t,n,i){(function(s,r){!function(t,s){"object"==typeof i&&"undefined"!=typeof n?n.exports=s():"function"==typeof e&&e.amd?e(s):t.ES6Promise=s()}(this,function(){"use strict";function e(e){return"function"==typeof e||"object"==typeof e&&null!==e}function n(e){return"function"==typeof e}function i(e){Y=e}function o(e){$=e}function c(){return function(){return s.nextTick(l)}}function a(){return"undefined"!=typeof K?function(){K(l)}:f()}function u(){var e=0,t=new Z(l),n=document.createTextNode("");return t.observe(n,{characterData:!0}),function(){n.data=e=++e%2}}function h(){var e=new MessageChannel;return e.port1.onmessage=l,function(){return e.port2.postMessage(0)}}function f(){var e=setTimeout;return function(){return e(l,1)}}function l(){for(var e=0;V>e;e+=2){var t=ne[e],n=ne[e+1];t(n),ne[e]=void 0,ne[e+1]=void 0}V=0}function _(){try{var e=t,n=e("vertx");return K=n.runOnLoop||n.runOnContext,a()}catch(i){return f()}}function d(e,t){var n=arguments,i=this,s=new this.constructor(p);void 0===s[se]&&L(s);var r=i._state;return r?!function(){var e=n[r-1];$(function(){return A(r,s,e,i._result)})}():x(i,s,e,t),s}function g(e){var t=this;if(e&&"object"==typeof e&&e.constructor===t)return e;var n=new t(p);return j(n,e),n}function p(){}function b(){return new TypeError("You cannot resolve a promise with itself")}function v(){return new TypeError("A promises callback cannot return that same promise.")}function m(e){try{return e.then}catch(t){return ae.error=t,ae}}function y(e,t,n,i){try{e.call(t,n,i)}catch(s){return s}}function w(e,t,n){$(function(e){var i=!1,s=y(n,t,function(n){i||(i=!0,t!==n?j(e,n):O(e,n))},function(t){i||(i=!0,R(e,t))},"Settle: "+(e._label||" unknown promise"));!i&&s&&(i=!0,R(e,s))},e)}function S(e,t){t._state===oe?O(e,t._result):t._state===ce?R(e,t._result):x(t,void 0,function(t){return j(e,t)},function(t){return R(e,t)})}function k(e,t,i){t.constructor===e.constructor&&i===d&&t.constructor.resolve===g?S(e,t):i===ae?R(e,ae.error):void 0===i?O(e,t):n(i)?w(e,t,i):O(e,t)}function j(t,n){t===n?R(t,b()):e(n)?k(t,n,m(n)):O(t,n)}function C(e){e._onerror&&e._onerror(e._result),E(e)}function O(e,t){e._state===re&&(e._result=t,e._state=oe,0!==e._subscribers.length&&$(E,e))}function R(e,t){e._state===re&&(e._state=ce,e._result=t,$(C,e))}function x(e,t,n,i){var s=e._subscribers,r=s.length;e._onerror=null,s[r]=t,s[r+oe]=n,s[r+ce]=i,0===r&&e._state&&$(E,e)}function E(e){var t=e._subscribers,n=e._state;if(0!==t.length){for(var i=void 0,s=void 0,r=e._result,o=0;o<t.length;o+=3)i=t[o],s=t[o+n],i?A(n,i,s,r):s(r);e._subscribers.length=0}}function T(){this.error=null}function M(e,t){try{return e(t)}catch(n){return ue.error=n,ue}}function A(e,t,i,s){var r=n(i),o=void 0,c=void 0,a=void 0,u=void 0;if(r){if(o=M(i,s),o===ue?(u=!0,c=o.error,o=null):a=!0,t===o)return void R(t,v())}else o=s,a=!0;t._state!==re||(r&&a?j(t,o):u?R(t,c):e===oe?O(t,o):e===ce&&R(t,o))}function I(e,t){try{t(function(t){j(e,t)},function(t){R(e,t)})}catch(n){R(e,n)}}function P(){return he++}function L(e){e[se]=he++,e._state=void 0,e._result=void 0,e._subscribers=[]}function J(e,t){this._instanceConstructor=e,this.promise=new e(p),this.promise[se]||L(this.promise),z(t)?(this._input=t,this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?O(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&O(this.promise,this._result))):R(this.promise,D())}function D(){return new Error("Array Methods must be provided an Array")}function N(e){return new J(this,e).promise}function q(e){var t=this;return new t(z(e)?function(n,i){for(var s=e.length,r=0;s>r;r++)t.resolve(e[r]).then(n,i)}:function(e,t){return t(new TypeError("You must pass an array to race."))})}function U(e){var t=this,n=new t(p);return R(n,e),n}function B(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function F(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function H(e){this[se]=P(),this._result=this._state=void 0,this._subscribers=[],p!==e&&("function"!=typeof e&&B(),this instanceof H?I(this,e):F())}function W(){var e=void 0;if("undefined"!=typeof r)e=r;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=e.Promise;if(n){var i=null;try{i=Object.prototype.toString.call(n.resolve())}catch(t){}if("[object Promise]"===i&&!n.cast)return}e.Promise=H}var X=void 0;X=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};var z=X,V=0,K=void 0,Y=void 0,$=function(e,t){ne[V]=e,ne[V+1]=t,V+=2,2===V&&(Y?Y(l):ie())},G="undefined"!=typeof window?window:void 0,Q=G||{},Z=Q.MutationObserver||Q.WebKitMutationObserver,ee="undefined"==typeof self&&"undefined"!=typeof s&&"[object process]"==={}.toString.call(s),te="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,ne=new Array(1e3),ie=void 0;ie=ee?c():Z?u():te?h():void 0===G&&"function"==typeof t?_():f();var se=Math.random().toString(36).substring(16),re=void 0,oe=1,ce=2,ae=new T,ue=new T,he=0;return J.prototype._enumerate=function(){for(var e=this.length,t=this._input,n=0;this._state===re&&e>n;n++)this._eachEntry(t[n],n)},J.prototype._eachEntry=function(e,t){var n=this._instanceConstructor,i=n.resolve;if(i===g){var s=m(e);if(s===d&&e._state!==re)this._settledAt(e._state,t,e._result);else if("function"!=typeof s)this._remaining--,this._result[t]=e;else if(n===H){var r=new n(p);k(r,e,s),this._willSettleAt(r,t)}else this._willSettleAt(new n(function(t){return t(e)}),t)}else this._willSettleAt(i(e),t)},J.prototype._settledAt=function(e,t,n){var i=this.promise;i._state===re&&(this._remaining--,e===ce?R(i,n):this._result[t]=n),0===this._remaining&&O(i,this._result)},J.prototype._willSettleAt=function(e,t){var n=this;x(e,void 0,function(e){return n._settledAt(oe,t,e)},function(e){return n._settledAt(ce,t,e)})},H.all=N,H.race=q,H.resolve=g,H.reject=U,H._setScheduler=i,H._setAsap=o,H._asap=$,H.prototype={constructor:H,then:d,"catch":function(e){return this.then(null,e)}},H.polyfill=W,H.Promise=H,H})}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:1}],3:[function(t,n){(function(){"use strict";function t(){}function i(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function s(e){return function(){return this[e].apply(this,arguments)}}var r=t.prototype,o=this,c=o.EventEmitter;r.getListeners=function(e){var t,n,i=this._getEvents();if(e instanceof RegExp){t={};for(n in i)i.hasOwnProperty(n)&&e.test(n)&&(t[n]=i[n])}else t=i[e]||(i[e]=[]);return t},r.flattenListeners=function(e){var t,n=[];for(t=0;t<e.length;t+=1)n.push(e[t].listener);return n},r.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},r.addListener=function(e,t){var n,s=this.getListenersAsObject(e),r="object"==typeof t;for(n in s)s.hasOwnProperty(n)&&-1===i(s[n],t)&&s[n].push(r?t:{listener:t,once:!1});return this},r.on=s("addListener"),r.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},r.once=s("addOnceListener"),r.defineEvent=function(e){return this.getListeners(e),this},r.defineEvents=function(e){for(var t=0;t<e.length;t+=1)this.defineEvent(e[t]);return this},r.removeListener=function(e,t){var n,s,r=this.getListenersAsObject(e);for(s in r)r.hasOwnProperty(s)&&(n=i(r[s],t),-1!==n&&r[s].splice(n,1));return this},r.off=s("removeListener"),r.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},r.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},r.manipulateListeners=function(e,t,n){var i,s,r=e?this.removeListener:this.addListener,o=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(i=n.length;i--;)r.call(this,t,n[i]);else for(i in t)t.hasOwnProperty(i)&&(s=t[i])&&("function"==typeof s?r.call(this,i,s):o.call(this,i,s));return this},r.removeEvent=function(e){var t,n=typeof e,i=this._getEvents();if("string"===n)delete i[e];else if(e instanceof RegExp)for(t in i)i.hasOwnProperty(t)&&e.test(t)&&delete i[t];else delete this._events;return this},r.removeAllListeners=s("removeEvent"),r.emitEvent=function(e,t){var n,i,s,r,o,c=this.getListenersAsObject(e);for(r in c)if(c.hasOwnProperty(r))for(n=c[r].slice(0),s=n.length;s--;)i=n[s],i.once===!0&&this.removeListener(e,i.listener),o=i.listener.apply(this,t||[]),o===this._getOnceReturnValue()&&this.removeListener(e,i.listener);return this},r.trigger=s("emitEvent"),r.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},r.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},r._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},r._getEvents=function(){return this._events||(this._events={})},t.noConflict=function(){return o.EventEmitter=c,t},"function"==typeof e&&e.amd?e(function(){return t}):"object"==typeof n&&n.exports?n.exports=t:o.EventEmitter=t}).call(this)},{}],4:[function(e,t){(function(n){function i(e,t){return e.prototype=Object.create(t.prototype),e.prototype.constructor=e,t.prototype}function s(e,t){try{return e[t]}catch(n){return void 0}}function r(e,t){for(var n=t||{},i=2;i<arguments.length;++i){var o=arguments[i];if(void 0!==o&&null!==o)for(var c in o){var a=s(o,c),u=s(n,c);if(a!==t&&void 0!==a)if(e&&"object"==typeof a&&null!==a)if(a instanceof Array)n[c]=r(e,u instanceof Array?u:[],a);else{var h="object"!=typeof u||u instanceof Array?{}:u;n[c]=r(e,h,a)}else n[c]=a}}return n}function o(e,t){return-1!==e.indexOf(t,e.length-t.length)}function c(e,t){return 0===e.lastIndexOf(t,0)}function a(e){return"/"==e.substring(e.length-1)&&(e=e.substring(0,e.length-1)),e}function u(e){return void 0===e||null===e?!1:"string"==typeof e||e instanceof String}function h(e){return void 0===e||null===e?!1:"function"==typeof e}function f(e,t){if(n.console){var i=n.console[e];h(i)&&i.apply(n.console,t)}}function l(e,t,n){var i=.5*Math.random(),s=t*Math.pow(2,e+1);return s>n&&(s=n),Math.floor((1-i)*s)}function _(e){return"error"in e&&null!==e.error&&""!==e.error}function d(e){this._sockJS=null,this._isSockJS=!1,this._status="disconnected",this._reconnect=!0,this._reconnecting=!1,this._transport=null,this._transportName=null,this._transportClosed=!0,this._messageId=0,this._clientID=null,this._subs={},this._lastMessageID={},this._messages=[],this._isBatching=!1,this._isAuthBatching=!1,this._authChannels={},this._numRefreshFailed=0,this._refreshTimeout=null,this._pingInterval=null,this._pongTimeout=null,this._retries=0,this._callbacks={},this._latency=null,this._latencyStart=null,this._config={sockJS:null,retry:1e3,maxRetry:2e4,timeout:5e3,info:"",resubscribe:!0,ping:!0,pingInterval:3e4,pongWaitTimeout:5e3,debug:!1,insecure:!1,server:null,privateChannelPrefix:"$",onTransportClose:null,transports:["websocket","xdr-streaming","xhr-streaming","eventsource","iframe-eventsource","iframe-htmlfile","xdr-polling","xhr-polling","iframe-xhr-polling","jsonp-polling"],onRefresh:null,refreshEndpoint:"/centrifuge/refresh/",refreshHeaders:{},refreshParams:{},refreshData:{},refreshTransport:"ajax",refreshAttempts:null,refreshInterval:3e3,refreshFailed:null,onPrivateChannelAuth:null,authEndpoint:"/centrifuge/auth/",authHeaders:{},authParams:{},authTransport:"ajax"},e&&this.configure(e)}function g(e,t,n){this._status=m,this._error=null,this._centrifuge=e,this.channel=t,this._setEvents(n),this._isResubscribe=!1,this._recovered=!1,this._ready=!1,this._promise=null,this._noResubscribe=!1,this._initializePromise()}var p=e("es6-promise").Promise,b=e("wolfy87-eventemitter");Object.create||(Object.create=function(){function e(){}return function(t){if(1!=arguments.length)throw new Error("Object.create implementation only accepts one parameter.");return e.prototype=t,new e}}()),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){if(null==this)throw new TypeError;var t,n,i=Object(this),s=i.length>>>0;if(0===s)return-1;if(t=0,arguments.length>1&&(t=Number(arguments[1]),t!=t?t=0:0!=t&&1/0!=t&&t!=-1/0&&(t=(t>0||-1)*Math.floor(Math.abs(t)))),t>=s)return-1;for(n=t>=0?t:Math.max(s-Math.abs(t),0);s>n;n++)if(n in i&&i[n]===e)return n;return-1}),i(d,b),d._jsonpCallbacks={},d._jsonpTimeouts={},d._nextJSONPCallbackID=1;var v=d.prototype;v._jsonp=function(e,t,i,s,r){i.length>0&&this._log("Only AJAX request allows to send custom headers, it's not possible with JSONP."),self._debug("sending JSONP request to",e);var o="centrifuge_jsonp_"+d._nextJSONPCallbackID.toString();d._nextJSONPCallbackID++;var c=n.document,a=c.createElement("script"),u=setTimeout(function(){d._jsonpCallbacks[o]=function(){},r(!0,"timeout")},3e3);d._jsonpCallbacks[o]=function(e){clearTimeout(u),r(!1,e),delete d[o]};var h="";for(var f in t)h.length>0&&(h+="&"),h+=encodeURIComponent(f)+"="+encodeURIComponent(t[f]);var l="Centrifuge._jsonpCallbacks['"+o+"']";a.src=this._config.authEndpoint+"?callback="+encodeURIComponent(l)+"&data="+encodeURIComponent(JSON.stringify(s))+"&"+h;var _=c.getElementsByTagName("head")[0]||c.documentElement;_.insertBefore(a,_.firstChild)},v._ajax=function(e,t,i,s,r){var o=this;o._debug("sending AJAX request to",e);var c=n.XMLHttpRequest?new n.XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),a="";for(var u in t)a.length>0&&(a+="&"),a+=encodeURIComponent(u)+"="+encodeURIComponent(t[u]);a.length>0&&(a="?"+a),c.open("POST",e+a,!0),c.setRequestHeader("X-Requested-With","XMLHttpRequest"),c.setRequestHeader("Content-Type","application/json");for(var h in i)c.setRequestHeader(h,i[h]);return c.onreadystatechange=function(){if(4===c.readyState)if(200===c.status){var e,t=!1;try{e=JSON.parse(c.responseText),t=!0}catch(n){r(!0,"JSON returned was invalid, yet status code was 200. Data was: "+c.responseText)}t&&r(!1,e)}else o._log("Couldn't get auth info from application",c.status),r(!0,c.status)},setTimeout(function(){c.send(JSON.stringify(s))},20),c},v._log=function(){f("info",arguments)},v._debug=function(){this._config.debug===!0&&f("debug",arguments)},v._websocketSupported=function(){return!("function"!=typeof WebSocket&&"object"!=typeof WebSocket)},v._sockjsEndpoint=function(){var e=this._config.url;return e=e.replace("ws://","http://"),e=e.replace("wss://","https://"),e=a(e),o(this._config.url,"connection")||(e+="/connection"),e},v._rawWebsocketEndpoint=function(){var e=this._config.url;return e=e.replace("http://","ws://"),e=e.replace("https://","wss://"),e=a(e),o(this._config.url,"connection/websocket")||(e+="/connection/websocket"),e},v._configure=function(e){if(this._debug("Configuring centrifuge object with",e),e||(e={}),this._config=r(!1,this._config,e),!this._config.url)throw"Missing required configuration parameter 'url' specifying server URL";if(!this._config.user&&""!==this._config.user){if(!this._config.insecure)throw"Missing required configuration parameter 'user' specifying user's unique ID in your application";this._debug("user not found but this is OK for insecure mode - anonymous access will be used"),this._config.user=""}if(!this._config.timestamp){if(!this._config.insecure)throw"Missing required configuration parameter 'timestamp'";this._debug("token not found but this is OK for insecure mode")}if(!this._config.token){if(!this._config.insecure)throw"Missing required configuration parameter 'token' specifying the sign of authorization request";this._debug("timestamp not found but this is OK for insecure mode")}if(this._config.url=a(this._config.url),o(this._config.url,"connection"))if(this._debug("client will connect to SockJS endpoint"),null!==this._config.sockJS)this._debug("SockJS explicitly provided in options"),this._sockJS=this._config.sockJS;else{if("undefined"==typeof SockJS)throw"include SockJS client library before Centrifuge javascript client library or provide SockJS object in options or use raw Websocket connection endpoint";this._debug("use globally defined SockJS"),this._sockJS=SockJS}else o(this._config.url,"connection/websocket")?this._debug("client will connect to raw Websocket endpoint"):(this._debug("client will detect connection endpoint itself"),null!==this._config.sockJS?(this._debug("SockJS explicitly provided in options"),this._sockJS=this._config.sockJS):"undefined"==typeof SockJS?this._debug("SockJS not found"):(this._debug("use globally defined SockJS"),this._sockJS=SockJS))},v._setStatus=function(e){this._status!==e&&(this._debug("Status",this._status,"->",e),this._status=e)},v._isDisconnected=function(){return"disconnected"===this._status},v._isConnecting=function(){return"connecting"===this._status},v._isConnected=function(){return"connected"===this._status},v._nextMessageId=function(){return++this._messageId},v._resetRetry=function(){this._debug("reset retries count to 0"),this._retries=0},v._getRetryInterval=function(){var e=l(this._retries,this._config.retry,this._config.maxRetry);return this._retries+=1,e},v._clearConnectedState=function(e){this._clientID=null;for(var t in this._callbacks){var n=this._callbacks[t],i=n.errback;i&&i(this._createErrorObject("disconnected","retry"))}this._callbacks={};for(var s in this._subs){var r=this._subs[s];e?(r._isSuccess()&&r._triggerUnsubscribe(),r._setSubscribing()):r._setUnsubscribed()}this._config.resubscribe&&this._reconnect||(this._subs={})},v._send=function(e){0!==e.length&&(1==e.length&&(e=e[0]),this._debug("Send",e),this._transport.send(JSON.stringify(e)))},v._setupTransport=function(){var e=this;if(this._isSockJS=!1,null!==this._sockJS){var t={transports:this._config.transports};null!==this._config.server&&(t.server=this._config.server),this._isSockJS=!0,this._transport=new this._sockJS(this._sockjsEndpoint(),null,t)}else{if(!this._websocketSupported())return void this._debug("No Websocket support and no SockJS configured, can't connect");this._transport=new WebSocket(this._rawWebsocketEndpoint())}this._transport.onopen=function(){e._transportClosed=!1,e._reconnecting=!1,e._isSockJS?(e._transportName=e._transport.transport,e._transport.onheartbeat=function(){e._restartPing()}):e._transportName="raw-websocket",e._resetRetry(),u(e._config.user)||e._log("user expected to be string"),u(e._config.info)||e._log("info expected to be string");var t={method:"connect",params:{user:e._config.user,info:e._config.info}};e._config.insecure||(t.params.timestamp=e._config.timestamp,t.params.token=e._config.token,u(e._config.timestamp)||e._log("timestamp expected to be string"),u(e._config.token)||e._log("token expected to be string")),e._addMessage(t),e._latencyStart=new Date},this._transport.onerror=function(t){e._debug("transport level error",t)},this._transport.onclose=function(t){e._transportClosed=!0;var n="connection closed",i=!0;if(t&&"reason"in t&&t.reason)try{var s=JSON.parse(t.reason);e._debug("reason is an advice object",s),n=s.reason,i=s.reconnect}catch(r){n=t.reason,e._debug("reason is a plain string",n),i="disconnect"!==n}if(null!==e._config.onTransportClose&&e._config.onTransportClose({event:t,reason:n,reconnect:i}),e._disconnect(n,i),e._reconnect===!0){e._reconnecting=!0;var o=e._getRetryInterval();e._debug("reconnect after "+o+" milliseconds"),setTimeout(function(){e._reconnect===!0&&e._connect.call(e)},o)}},this._transport.onmessage=function(t){var n;n=JSON.parse(t.data),e._debug("Received",n),e._receive(n),e._restartPing()}},v._connect=function(e){return this.isConnected()?void this._debug("connect called when already connected"):void("connecting"!=this._status&&(this._debug("start connecting"),this._setStatus("connecting"),this._clientID=null,this._reconnect=!0,e&&this.on("connect",e),this._setupTransport()))},v._disconnect=function(e,t){if(!this.isDisconnected()){this._debug("disconnected:",e,t);var n=t||!1;if(n===!1&&(this._reconnect=!1),this._clearConnectedState(t),!this.isDisconnected()){this._setStatus("disconnected");var i={reason:e,reconnect:n};this._refreshTimeout&&clearTimeout(this._refreshTimeout),this._reconnecting===!1&&this.trigger("disconnect",[i])}this._transportClosed||this._transport.close()}},v._refreshFailed=function(){self._numRefreshFailed=0,this.isDisconnected()||this._disconnect("refresh failed",!1),null!==this._config.refreshFailed&&this._config.refreshFailed()},v._refresh=function(){var e=this;if(this._debug("refresh credentials"),0===e._config.refreshAttempts)return this._debug("refresh attempts set to 0, do not send refresh request at all"),void e._refreshFailed();null!==e._refreshTimeout&&clearTimeout(e._refreshTimeout);var t=function(t,n){if(t===!0)return e._debug("error getting connection credentials from refresh endpoint",n),e._numRefreshFailed++,e._refreshTimeout&&clearTimeout(e._refreshTimeout),null!==e._config.refreshAttempts&&e._numRefreshFailed>=e._config.refreshAttempts?void e._refreshFailed():void(e._refreshTimeout=setTimeout(function(){e._refresh.call(e)},e._config.refreshInterval+Math.round(1e3*Math.random())));if(e._numRefreshFailed=0,e._config.user=n.user,e._config.timestamp=n.timestamp,"info"in n&&(e._config.info=n.info),e._config.token=n.token,e.isDisconnected())e._debug("credentials refreshed, connect from scratch"),e._connect();else{e._debug("send refreshed credentials");var i={method:"refresh",params:{user:e._config.user,timestamp:e._config.timestamp,info:e._config.info,token:e._config.token}};e._addMessage(i)}};if(null!==this._config.onRefresh)context={},this._config.onRefresh(context,t);else{var n=this._config.refreshTransport.toLowerCase();if("ajax"===n)this._ajax(this._config.refreshEndpoint,this._config.refreshParams,this._config.refreshHeaders,this._config.refreshData,t);else{if("jsonp"!==n)throw"Unknown refresh transport "+n;this._jsonp(this._config.refreshEndpoint,this._config.refreshParams,this._config.refreshHeaders,this._config.refreshData,t)}}},v._subscribe=function(e){var t=e.channel;if(t in this._subs||(this._subs[t]=e),!this.isConnected())return void e._setNew();e._setSubscribing();var n={method:"subscribe",params:{channel:t}};if(c(t,this._config.privateChannelPrefix))this._isAuthBatching?this._authChannels[t]=!0:(this.startAuthBatching(),this._subscribe(e),this.stopAuthBatching());else{var i=this._recover(t);i===!0&&(n.params.recover=!0,n.params.last=this._getLastID(t)),this._addMessage(n)}},v._unsubscribe=function(e){if(this.isConnected()){var t={method:"unsubscribe",params:{channel:e.channel}};this._addMessage(t)}},v._getSub=function(e){var t=this._subs[e];return t?t:null},v._connectResponse=function(e){if(!this.isConnected())if(_(e))this.trigger("error",[{message:e}]);else{if(null!==this._latencyStart&&(this._latency=(new Date).getTime()-this._latencyStart.getTime(),this._latencyStart=null),!e.body)return;if(e.body.expires){var t=e.body.expired;if(t)return this._reconnecting=!0,this._disconnect("expired",!0),void this._refresh()}this._clientID=e.body.client,this._setStatus("connected"),this._refreshTimeout&&clearTimeout(this._refreshTimeout);var n=this;if(e.body.expires&&(this._refreshTimeout=setTimeout(function(){n._refresh.call(n)},1e3*e.body.ttl)),this._config.resubscribe){this.startBatching(),this.startAuthBatching();for(var i in this._subs){var s=this._subs[i];s._shouldResubscribe()&&this._subscribe(s)}this.stopAuthBatching(),this.stopBatching(!0)}var r={client:e.body.client,transport:this._transportName,latency:this._latency};this._restartPing(),this.trigger("connect",[r])}},v._stopPing=function(){null!==this._pongTimeout&&clearTimeout(this._pongTimeout),null!==this._pingInterval&&clearInterval(this._pingInterval)},v._startPing=function(){if(!(this._config.ping!==!0||this._config.pingInterval<=0)&&this.isConnected()){var e=this;this._pingInterval=setInterval(function(){return e.isConnected()?(e.ping(),void(e._pongTimeout=setTimeout(function(){e._disconnect("no ping",!0)},e._config.pongWaitTimeout))):void e._stopPing()},this._config.pingInterval)}},v._restartPing=function(){this._stopPing(),this._startPing()},v._disconnectResponse=function(e){if(_(e))this.trigger("error",[{message:e}]);else{var t=!1;"reconnect"in e.body&&(t=e.body.reconnect);var n="";"reason"in e.body&&(n=e.body.reason),this._disconnect(n,t)}},v._subscribeResponse=function(e){var t=e.body;if(null!==t){var n=t.channel,i=this._getSub(n);if(i&&i._isSubscribing())if(_(e))this.trigger("error",[{message:e}]),i._setSubscribeError(this._errorObjectFromMessage(e));else{var s=t.messages;if(s&&s.length>0)for(var r in s.reverse())this._messageResponse({body:s[r]});else"last"in t&&(this._lastMessageID[n]=t.last);var o=!1;"recovered"in t&&(o=t.recovered),i._setSubscribeSuccess(o)}}},v._unsubscribeResponse=function(e){var t=e.uid,n=e.body,i=n.channel,s=this._getSub(i);s&&(_(e)?this.trigger("error",[{message:e}]):t||s._setUnsubscribed(!0))},v._publishResponse=function(e){var t=e.uid,n=e.body;if(t in this._callbacks){var i=this._callbacks[t];if(delete this._callbacks[t],_(e)){var s=i.errback;if(!s)return;s(this._errorObjectFromMessage(e)),this.trigger("error",[{message:e}])}else{var r=i.callback;if(!r)return;r(n)}}},v._presenceResponse=function(e){var t=e.uid,n=e.body;if(t in this._callbacks){var i=this._callbacks[t];if(delete this._callbacks[t],_(e)){var s=i.errback;if(!s)return;s(this._errorObjectFromMessage(e)),this.trigger("error",[{message:e}])}else{var r=i.callback;if(!r)return;r(n)}}},v._historyResponse=function(e){var t=e.uid,n=e.body;if(t in this._callbacks){var i=this._callbacks[t];if(delete this._callbacks[t],_(e)){var s=i.errback;if(!s)return;s(this._errorObjectFromMessage(e)),this.trigger("error",[{message:e}])}else{var r=i.callback;if(!r)return;r(n)}}},v._joinResponse=function(e){var t=e.body,n=t.channel,i=this._getSub(n);i&&i.trigger("join",[t])},v._leaveResponse=function(e){var t=e.body,n=t.channel,i=this._getSub(n);i&&i.trigger("leave",[t])},v._messageResponse=function(e){var t=e.body,n=t.channel;this._lastMessageID[n]=t.uid;var i=this._getSub(n);i&&i.trigger("message",[t])},v._refreshResponse=function(e){if(this._refreshTimeout&&clearTimeout(this._refreshTimeout),_(e))this.trigger("error",[{message:e}]);else if(e.body.expires){var t=this,n=e.body.expired;if(n)return void(t._refreshTimeout=setTimeout(function(){t._refresh.call(t)},t._config.refreshInterval+Math.round(1e3*Math.random())));this._clientID=e.body.client,t._refreshTimeout=setTimeout(function(){t._refresh.call(t)},1e3*e.body.ttl)}},v._dispatchMessage=function(e){if(void 0===e||null===e)return void this._debug("dispatch: got undefined or null message");var t=e.method;if(!t)return void this._debug("dispatch: got message with empty method");switch(t){case"connect":this._connectResponse(e);break;case"disconnect":this._disconnectResponse(e);break;case"subscribe":this._subscribeResponse(e);break;case"unsubscribe":this._unsubscribeResponse(e);break;case"publish":this._publishResponse(e);break;case"presence":this._presenceResponse(e);break;case"history":this._historyResponse(e);break;case"join":this._joinResponse(e);break;case"leave":this._leaveResponse(e);break;case"ping":break;case"refresh":this._refreshResponse(e);break;case"message":this._messageResponse(e);break;default:this._debug("dispatch: got message with unknown method"+t)}},v._receive=function(e){if(Object.prototype.toString.call(e)===Object.prototype.toString.call([])){for(var t in e)if(e.hasOwnProperty(t)){var n=e[t];this._dispatchMessage(n)}}else Object.prototype.toString.call(e)===Object.prototype.toString.call({})&&this._dispatchMessage(e)},v._flush=function(){var e=this._messages.slice(0);this._messages=[],this._send(e)},v._ping=function(){var e={method:"ping"};this._addMessage(e)},v._recover=function(e){return e in this._lastMessageID},v._getLastID=function(e){var t=this._lastMessageID[e];return t?(this._debug("last uid found and sent for channel",e),t):(this._debug("no last uid found for channel",e),"")},v._createErrorObject=function(e,t){var n={error:e};return t&&(n.advice=t),n},v._errorObjectFromMessage=function(e){var t=e.error,n=e.advice;return this._createErrorObject(t,n)},v._registerCall=function(e,t,n){var i=this;this._callbacks[e]={callback:t,errback:n},setTimeout(function(){delete i._callbacks[e],h(n)&&n(i._createErrorObject("timeout","retry"))},this._config.timeout)},v._addMessage=function(e){var t=""+this._nextMessageId();return e.uid=t,this._isBatching===!0?this._messages.push(e):this._send([e]),t},v.getClientId=function(){return this._clientID},v.isConnected=v._isConnected,v.isDisconnected=v._isDisconnected,v.configure=function(e){this._configure.call(this,e)},v.connect=v._connect,v.disconnect=function(){this._disconnect("client",!1)},v.ping=v._ping,v.startBatching=function(){this._isBatching=!0},v.stopBatching=function(e){e=e||!1,this._isBatching=!1,e===!0&&this.flush()},v.flush=function(){this._flush()},v.startAuthBatching=function(){this._isAuthBatching=!0},v.stopAuthBatching=function(){this._isAuthBatching=!1;var e=this._authChannels;this._authChannels={};var t=[];for(var n in e){var i=this._getSub(n);i&&t.push(n)}if(0!=t.length){var s={client:this.getClientId(),channels:t},r=this,o=function(e,n){if(e!==!0){var i=!1;r._isBatching||(r.startBatching(),i=!0);for(var s in t){var o=t[s],c=n[o];if(c)if(c.status&&200!==c.status)r._subscribeResponse({error:c.status,body:{channel:o}});else{var a={method:"subscribe",params:{channel:o,client:r.getClientId(),info:c.info,sign:c.sign}},u=r._recover(o);u===!0&&(a.params.recover=!0,a.params.last=r._getLastID(o)),r._addMessage(a)}else r._subscribeResponse({error:"channel not found in authorization response",advice:"fix",body:{channel:o}})}i&&r.stopBatching(!0)}else{r._debug("authorization request failed");for(var s in t){var o=t[s];r._subscribeResponse({error:"authorization request failed",advice:"fix",body:{channel:o}})}}};if(null!==this._config.onPrivateChannelAuth)context={data:s},this._config.onPrivateChannelAuth(context,o);else{var c=this._config.authTransport.toLowerCase();if("ajax"===c)this._ajax(this._config.authEndpoint,this._config.authParams,this._config.authHeaders,s,o);
else{if("jsonp"!==c)throw"Unknown private channel auth transport "+c;this._jsonp(this._config.authEndpoint,this._config.authParams,this._config.authHeaders,s,o)}}}},v.subscribe=function(e,t){if(arguments.length<1)throw"Illegal arguments number: required 1, got "+arguments.length;if(!u(e))throw"Illegal argument type: channel must be a string";if(!this._config.resubscribe&&!this.isConnected())throw"Can not only subscribe in connected state when resubscribe option is off";var n=this._getSub(e);if(null!==n)return n._setEvents(t),n._isUnsubscribed()&&n.subscribe(),n;var i=new g(this,e,t);return this._subs[e]=i,i.subscribe(),i};var m=0,y=1,w=2,S=3,k=4;i(g,b);var j=g.prototype;j._initializePromise=function(){this._ready=!1;var e=this;this._promise=new p(function(t,n){e._resolve=function(n){e._ready=!0,t(n)},e._reject=function(t){e._ready=!0,n(t)}})},j._setEvents=function(e){if(e)if(h(e))this.on("message",e);else if(Object.prototype.toString.call(e)===Object.prototype.toString.call({})){var t=["message","join","leave","unsubscribe","subscribe","error"];for(var n in t){var i=t[n];i in e&&this.on(i,e[i])}}},j._isNew=function(){return this._status===m},j._isUnsubscribed=function(){return this._status===k},j._isSubscribing=function(){return this._status===y},j._isReady=function(){return this._status===w||this._status===S},j._isSuccess=function(){return this._status===w},j._isError=function(){return this._status===S},j._setNew=function(){this._status=m},j._setSubscribing=function(){this._ready===!0&&(this._initializePromise(),this._isResubscribe=!0),this._status=y},j._setSubscribeSuccess=function(e){if(this._status!=w){this._recovered=e,this._status=w;var t=this._getSubscribeSuccessContext(e);this.trigger("subscribe",[t]),this._resolve(t)}},j._setSubscribeError=function(e){if(this._status!=S){this._status=S,this._error=e;var t=this._getSubscribeErrorContext();this.trigger("error",[t]),this._reject(t)}},j._triggerUnsubscribe=function(){var e={channel:this.channel};this.trigger("unsubscribe",[e])},j._setUnsubscribed=function(e){this._status!=k&&(this._status=k,e===!0&&(this._noResubscribe=!0),this._triggerUnsubscribe())},j._shouldResubscribe=function(){return!this._noResubscribe},j._getSubscribeSuccessContext=function(){return{channel:this.channel,isResubscribe:this._isResubscribe,recovered:this._recovered}},j._getSubscribeErrorContext=function(){var e=this._error;return e.channel=this.channel,e.isResubscribe=this._isResubscribe,e},j.ready=function(e,t){this._ready&&(this._isSuccess()?e(this._getSubscribeSuccessContext()):t(this._getSubscribeErrorContext()))},j.subscribe=function(){return this._status!=w?(this._centrifuge._subscribe(this),this):void 0},j.unsubscribe=function(){this._setUnsubscribed(!0),this._centrifuge._unsubscribe(this)},j.publish=function(e){var t=this;return new p(function(n,i){return t._isUnsubscribed()?void i(t._centrifuge._createErrorObject("subscription unsubscribed","fix")):void t._promise.then(function(){if(!t._centrifuge.isConnected())return void i(t._centrifuge._createErrorObject("disconnected","retry"));var s={method:"publish",params:{channel:t.channel,data:e}},r=t._centrifuge._addMessage(s);t._centrifuge._registerCall(r,n,i)},function(e){i(e)})})},j.presence=function(){var e=this;return new p(function(t,n){return e._isUnsubscribed()?void n(e._centrifuge._createErrorObject("subscription unsubscribed","fix")):void e._promise.then(function(){if(!e._centrifuge.isConnected())return void n(e._centrifuge._createErrorObject("disconnected","retry"));var i={method:"presence",params:{channel:e.channel}},s=e._centrifuge._addMessage(i);e._centrifuge._registerCall(s,t,n)},function(e){n(e)})})},j.history=function(){var e=this;return new p(function(t,n){return e._isUnsubscribed()?void n(e._centrifuge._createErrorObject("subscription unsubscribed","fix")):void e._promise.then(function(){if(!e._centrifuge.isConnected())return void n(e._centrifuge._createErrorObject("disconnected","retry"));var i={method:"history",params:{channel:e.channel}},s=e._centrifuge._addMessage(i);e._centrifuge._registerCall(s,t,n)},function(e){n(e)})})},t.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"es6-promise":2,"wolfy87-eventemitter":3}]},{},[4])(4)});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.Centrifuge=e()}}(function(){var e;return function t(e,n,i){function s(o,c){if(!n[o]){if(!e[o]){var a="function"==typeof require&&require;if(!c&&a)return a(o,!0);if(r)return r(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var h=n[o]={exports:{}};e[o][0].call(h.exports,function(t){var n=e[o][1][t];return s(n?n:t)},h,h.exports,t,e,n,i)}return n[o].exports}for(var r="function"==typeof require&&require,o=0;o<i.length;o++)s(i[o]);return s}({1:[function(e,t){function n(){}var i=t.exports={};i.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.MutationObserver,n="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};var i=[];if(t){var s=document.createElement("div"),r=new MutationObserver(function(){var e=i.slice();i.length=0,e.forEach(function(e){e()})});return r.observe(s,{attributes:!0}),function(e){i.length||s.setAttribute("yes","no"),i.push(e)}}return n?(window.addEventListener("message",function(e){var t=e.source;if((t===window||null===t)&&"process-tick"===e.data&&(e.stopPropagation(),i.length>0)){var n=i.shift();n()}},!0),function(e){i.push(e),window.postMessage("process-tick","*")}):function(e){setTimeout(e,0)}}(),i.title="browser",i.browser=!0,i.env={},i.argv=[],i.on=n,i.addListener=n,i.once=n,i.off=n,i.removeListener=n,i.removeAllListeners=n,i.emit=n,i.binding=function(){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(){throw new Error("process.chdir is not supported")}},{}],2:[function(t,n,i){(function(s,r){!function(t,s){"object"==typeof i&&"undefined"!=typeof n?n.exports=s():"function"==typeof e&&e.amd?e(s):t.ES6Promise=s()}(this,function(){"use strict";function e(e){return"function"==typeof e||"object"==typeof e&&null!==e}function n(e){return"function"==typeof e}function i(e){Y=e}function o(e){$=e}function c(){return function(){return s.nextTick(l)}}function a(){return"undefined"!=typeof K?function(){K(l)}:f()}function u(){var e=0,t=new Z(l),n=document.createTextNode("");return t.observe(n,{characterData:!0}),function(){n.data=e=++e%2}}function h(){var e=new MessageChannel;return e.port1.onmessage=l,function(){return e.port2.postMessage(0)}}function f(){var e=setTimeout;return function(){return e(l,1)}}function l(){for(var e=0;V>e;e+=2){var t=ne[e],n=ne[e+1];t(n),ne[e]=void 0,ne[e+1]=void 0}V=0}function _(){try{var e=t,n=e("vertx");return K=n.runOnLoop||n.runOnContext,a()}catch(i){return f()}}function d(e,t){var n=arguments,i=this,s=new this.constructor(p);void 0===s[se]&&L(s);var r=i._state;return r?!function(){var e=n[r-1];$(function(){return P(r,s,e,i._result)})}():x(i,s,e,t),s}function g(e){var t=this;if(e&&"object"==typeof e&&e.constructor===t)return e;var n=new t(p);return O(n,e),n}function p(){}function b(){return new TypeError("You cannot resolve a promise with itself")}function v(){return new TypeError("A promises callback cannot return that same promise.")}function m(e){try{return e.then}catch(t){return ae.error=t,ae}}function y(e,t,n,i){try{e.call(t,n,i)}catch(s){return s}}function w(e,t,n){$(function(e){var i=!1,s=y(n,t,function(n){i||(i=!0,t!==n?O(e,n):C(e,n))},function(t){i||(i=!0,R(e,t))},"Settle: "+(e._label||" unknown promise"));!i&&s&&(i=!0,R(e,s))},e)}function S(e,t){t._state===oe?C(e,t._result):t._state===ce?R(e,t._result):x(t,void 0,function(t){return O(e,t)},function(t){return R(e,t)})}function k(e,t,i){t.constructor===e.constructor&&i===d&&t.constructor.resolve===g?S(e,t):i===ae?R(e,ae.error):void 0===i?C(e,t):n(i)?w(e,t,i):C(e,t)}function O(t,n){t===n?R(t,b()):e(n)?k(t,n,m(n)):C(t,n)}function j(e){e._onerror&&e._onerror(e._result),E(e)}function C(e,t){e._state===re&&(e._result=t,e._state=oe,0!==e._subscribers.length&&$(E,e))}function R(e,t){e._state===re&&(e._state=ce,e._result=t,$(j,e))}function x(e,t,n,i){var s=e._subscribers,r=s.length;e._onerror=null,s[r]=t,s[r+oe]=n,s[r+ce]=i,0===r&&e._state&&$(E,e)}function E(e){var t=e._subscribers,n=e._state;if(0!==t.length){for(var i=void 0,s=void 0,r=e._result,o=0;o<t.length;o+=3)i=t[o],s=t[o+n],i?P(n,i,s,r):s(r);e._subscribers.length=0}}function T(){this.error=null}function A(e,t){try{return e(t)}catch(n){return ue.error=n,ue}}function P(e,t,i,s){var r=n(i),o=void 0,c=void 0,a=void 0,u=void 0;if(r){if(o=A(i,s),o===ue?(u=!0,c=o.error,o=null):a=!0,t===o)return void R(t,v())}else o=s,a=!0;t._state!==re||(r&&a?O(t,o):u?R(t,c):e===oe?C(t,o):e===ce&&R(t,o))}function M(e,t){try{t(function(t){O(e,t)},function(t){R(e,t)})}catch(n){R(e,n)}}function I(){return he++}function L(e){e[se]=he++,e._state=void 0,e._result=void 0,e._subscribers=[]}function J(e,t){this._instanceConstructor=e,this.promise=new e(p),this.promise[se]||L(this.promise),z(t)?(this._input=t,this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?C(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&C(this.promise,this._result))):R(this.promise,D())}function D(){return new Error("Array Methods must be provided an Array")}function q(e){return new J(this,e).promise}function N(e){var t=this;return new t(z(e)?function(n,i){for(var s=e.length,r=0;s>r;r++)t.resolve(e[r]).then(n,i)}:function(e,t){return t(new TypeError("You must pass an array to race."))})}function U(e){var t=this,n=new t(p);return R(n,e),n}function B(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function F(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function H(e){this[se]=I(),this._result=this._state=void 0,this._subscribers=[],p!==e&&("function"!=typeof e&&B(),this instanceof H?M(this,e):F())}function W(){var e=void 0;if("undefined"!=typeof r)e=r;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=e.Promise;if(n){var i=null;try{i=Object.prototype.toString.call(n.resolve())}catch(t){}if("[object Promise]"===i&&!n.cast)return}e.Promise=H}var X=void 0;X=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};var z=X,V=0,K=void 0,Y=void 0,$=function(e,t){ne[V]=e,ne[V+1]=t,V+=2,2===V&&(Y?Y(l):ie())},G="undefined"!=typeof window?window:void 0,Q=G||{},Z=Q.MutationObserver||Q.WebKitMutationObserver,ee="undefined"==typeof self&&"undefined"!=typeof s&&"[object process]"==={}.toString.call(s),te="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,ne=new Array(1e3),ie=void 0;ie=ee?c():Z?u():te?h():void 0===G&&"function"==typeof t?_():f();var se=Math.random().toString(36).substring(16),re=void 0,oe=1,ce=2,ae=new T,ue=new T,he=0;return J.prototype._enumerate=function(){for(var e=this.length,t=this._input,n=0;this._state===re&&e>n;n++)this._eachEntry(t[n],n)},J.prototype._eachEntry=function(e,t){var n=this._instanceConstructor,i=n.resolve;if(i===g){var s=m(e);if(s===d&&e._state!==re)this._settledAt(e._state,t,e._result);else if("function"!=typeof s)this._remaining--,this._result[t]=e;else if(n===H){var r=new n(p);k(r,e,s),this._willSettleAt(r,t)}else this._willSettleAt(new n(function(t){return t(e)}),t)}else this._willSettleAt(i(e),t)},J.prototype._settledAt=function(e,t,n){var i=this.promise;i._state===re&&(this._remaining--,e===ce?R(i,n):this._result[t]=n),0===this._remaining&&C(i,this._result)},J.prototype._willSettleAt=function(e,t){var n=this;x(e,void 0,function(e){return n._settledAt(oe,t,e)},function(e){return n._settledAt(ce,t,e)})},H.all=q,H.race=N,H.resolve=g,H.reject=U,H._setScheduler=i,H._setAsap=o,H._asap=$,H.prototype={constructor:H,then:d,"catch":function(e){return this.then(null,e)}},H.polyfill=W,H.Promise=H,H})}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:1}],3:[function(t,n){(function(){"use strict";function t(){}function i(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function s(e){return function(){return this[e].apply(this,arguments)}}var r=t.prototype,o=this,c=o.EventEmitter;r.getListeners=function(e){var t,n,i=this._getEvents();if(e instanceof RegExp){t={};for(n in i)i.hasOwnProperty(n)&&e.test(n)&&(t[n]=i[n])}else t=i[e]||(i[e]=[]);return t},r.flattenListeners=function(e){var t,n=[];for(t=0;t<e.length;t+=1)n.push(e[t].listener);return n},r.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},r.addListener=function(e,t){var n,s=this.getListenersAsObject(e),r="object"==typeof t;for(n in s)s.hasOwnProperty(n)&&-1===i(s[n],t)&&s[n].push(r?t:{listener:t,once:!1});return this},r.on=s("addListener"),r.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},r.once=s("addOnceListener"),r.defineEvent=function(e){return this.getListeners(e),this},r.defineEvents=function(e){for(var t=0;t<e.length;t+=1)this.defineEvent(e[t]);return this},r.removeListener=function(e,t){var n,s,r=this.getListenersAsObject(e);for(s in r)r.hasOwnProperty(s)&&(n=i(r[s],t),-1!==n&&r[s].splice(n,1));return this},r.off=s("removeListener"),r.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},r.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},r.manipulateListeners=function(e,t,n){var i,s,r=e?this.removeListener:this.addListener,o=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(i=n.length;i--;)r.call(this,t,n[i]);else for(i in t)t.hasOwnProperty(i)&&(s=t[i])&&("function"==typeof s?r.call(this,i,s):o.call(this,i,s));return this},r.removeEvent=function(e){var t,n=typeof e,i=this._getEvents();if("string"===n)delete i[e];else if(e instanceof RegExp)for(t in i)i.hasOwnProperty(t)&&e.test(t)&&delete i[t];else delete this._events;return this},r.removeAllListeners=s("removeEvent"),r.emitEvent=function(e,t){var n,i,s,r,o,c=this.getListenersAsObject(e);for(r in c)if(c.hasOwnProperty(r))for(n=c[r].slice(0),s=n.length;s--;)i=n[s],i.once===!0&&this.removeListener(e,i.listener),o=i.listener.apply(this,t||[]),o===this._getOnceReturnValue()&&this.removeListener(e,i.listener);return this},r.trigger=s("emitEvent"),r.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},r.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},r._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},r._getEvents=function(){return this._events||(this._events={})},t.noConflict=function(){return o.EventEmitter=c,t},"function"==typeof e&&e.amd?e(function(){return t}):"object"==typeof n&&n.exports?n.exports=t:o.EventEmitter=t}).call(this)},{}],4:[function(e,t){(function(n){function i(e,t){return e.prototype=Object.create(t.prototype),e.prototype.constructor=e,t.prototype}function s(e,t){try{return e[t]}catch(n){return void 0}}function r(e,t){for(var n=t||{},i=2,o=arguments.length;o>i;i++){var c=arguments[i];if(void 0!==c&&null!==c)for(var a in c){var u=s(c,a),h=s(n,a);if(u!==t&&void 0!==u)if(e&&"object"==typeof u&&null!==u)if(u instanceof Array)n[a]=r(e,h instanceof Array?h:[],u);else{var f="object"!=typeof h||h instanceof Array?{}:h;n[a]=r(e,f,u)}else n[a]=u}}return n}function o(e,t){return-1!==e.indexOf(t,e.length-t.length)}function c(e,t){return 0===e.lastIndexOf(t,0)}function a(e){return"/"===e.substring(e.length-1)&&(e=e.substring(0,e.length-1)),e}function u(e){return void 0===e||null===e?!1:"string"==typeof e||e instanceof String}function h(e){return void 0===e||null===e?!1:"function"==typeof e}function f(e,t){if(n.console){var i=n.console[e];h(i)&&i.apply(n.console,t)}}function l(e,t,n){var i=.5*Math.random(),s=t*Math.pow(2,e+1);return s>n&&(s=n),Math.floor((1-i)*s)}function _(e){return"error"in e&&null!==e.error&&""!==e.error}function d(e){this._sockJS=null,this._isSockJS=!1,this._status="disconnected",this._reconnect=!0,this._reconnecting=!1,this._transport=null,this._transportName=null,this._transportClosed=!0,this._messageId=0,this._clientID=null,this._subs={},this._lastMessageID={},this._messages=[],this._isBatching=!1,this._isAuthBatching=!1,this._authChannels={},this._numRefreshFailed=0,this._refreshTimeout=null,this._pingInterval=null,this._pongTimeout=null,this._retries=0,this._callbacks={},this._latency=null,this._latencyStart=null,this._config={sockJS:null,retry:1e3,maxRetry:2e4,timeout:5e3,info:"",resubscribe:!0,ping:!0,pingInterval:3e4,pongWaitTimeout:5e3,debug:!1,insecure:!1,server:null,privateChannelPrefix:"$",onTransportClose:null,transports:["websocket","xdr-streaming","xhr-streaming","eventsource","iframe-eventsource","iframe-htmlfile","xdr-polling","xhr-polling","iframe-xhr-polling","jsonp-polling"],onRefresh:null,refreshEndpoint:"/centrifuge/refresh/",refreshHeaders:{},refreshParams:{},refreshData:{},refreshTransport:"ajax",refreshAttempts:null,refreshInterval:3e3,refreshFailed:null,onPrivateChannelAuth:null,authEndpoint:"/centrifuge/auth/",authHeaders:{},authParams:{},authTransport:"ajax"},e&&this.configure(e)}function g(e,t,n){this._status=m,this._error=null,this._centrifuge=e,this.channel=t,this._setEvents(n),this._isResubscribe=!1,this._recovered=!1,this._ready=!1,this._promise=null,this._noResubscribe=!1,this._initializePromise()}var p=e("es6-promise").Promise,b=e("wolfy87-eventemitter");Object.create||(Object.create=function(){var e=function(){};return function(t){if(1!==arguments.length)throw new Error("Object.create implementation only accepts one parameter.");return e.prototype=t,new e}}()),Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t){if(!this)throw new TypeError('Array.prototype.indexOf() - can not convert "'+this+'" to object');var n=isFinite(t)?Math.floor(t):0,i=this instanceof Object?this:new Object(this),s=isFinite(i.length)?Math.floor(i.length):0;if(n>=s)return-1;if(0>n&&(n=Math.max(s+n,0)),void 0===e){do if(n in i&&void 0===i[n])return n;while(++n<s)}else do if(i[n]===e)return n;while(++n<s);return-1}),i(d,b),d._jsonpCallbacks={},d._jsonpTimeouts={},d._nextJSONPCallbackID=1;var v=d.prototype;v._jsonp=function(e,t,i,s,r){i.length>0&&this._log("Only AJAX request allows to send custom headers, it is not possible with JSONP."),self._debug("sending JSONP request to",e);var o="centrifuge_jsonp_"+d._nextJSONPCallbackID.toString();d._nextJSONPCallbackID++;var c=n.document,a=c.createElement("script"),u=setTimeout(function(){d._jsonpCallbacks[o]=function(){},r(!0,"timeout")},3e3);d._jsonpCallbacks[o]=function(e){clearTimeout(u),r(!1,e),delete d[o]};var h="";for(var f in t)t.hasOwnProperty(f)&&(h.length>0&&(h+="&"),h+=encodeURIComponent(f)+"="+encodeURIComponent(t[f]));var l="Centrifuge._jsonpCallbacks['"+o+"']";a.src=this._config.authEndpoint+"?callback="+encodeURIComponent(l)+"&data="+encodeURIComponent(JSON.stringify(s))+"&"+h;var _=c.getElementsByTagName("head")[0]||c.documentElement;_.insertBefore(a,_.firstChild)},v._ajax=function(e,t,i,s,r){var o=this;o._debug("sending AJAX request to",e);var c=n.XMLHttpRequest?new n.XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),a="";for(var u in t)t.hasOwnProperty(u)&&(a.length>0&&(a+="&"),a+=encodeURIComponent(u)+"="+encodeURIComponent(t[u]));a.length>0&&(a="?"+a),c.open("POST",e+a,!0),"withCredentials"in c&&(c.withCredentials=!0),c.setRequestHeader("X-Requested-With","XMLHttpRequest"),c.setRequestHeader("Content-Type","application/json");for(var h in i)i.hasOwnProperty(h)&&c.setRequestHeader(h,i[h]);return c.onreadystatechange=function(){if(4===c.readyState)if(200===c.status){var e,t=!1;try{e=JSON.parse(c.responseText),t=!0}catch(n){r(!0,"JSON returned was invalid, yet status code was 200. Data was: "+c.responseText)}t&&r(!1,e)}else o._log("Couldn't get auth info from application",c.status),r(!0,c.status)},setTimeout(function(){c.send(JSON.stringify(s))},20),c},v._log=function(){f("info",arguments)},v._debug=function(){this._config.debug===!0&&f("debug",arguments)},v._websocketSupported=function(){return!("function"!=typeof WebSocket&&"object"!=typeof WebSocket)},v._sockjsEndpoint=function(){var e=this._config.url;return e=e.replace("ws://","http://").replace("wss://","https://"),e=a(e),o(this._config.url,"connection")||(e+="/connection"),e},v._rawWebsocketEndpoint=function(){var e=this._config.url;return e=e.replace("http://","ws://").replace("https://","wss://"),e=a(e),o(this._config.url,"connection/websocket")||(e+="/connection/websocket"),e},v._configure=function(e){if(this._debug("Configuring centrifuge object with",e),e||(e={}),this._config=r(!1,this._config,e),!this._config.url)throw"Missing required configuration parameter 'url' specifying server URL";if(!this._config.user&&""!==this._config.user){if(!this._config.insecure)throw"Missing required configuration parameter 'user' specifying user's unique ID in your application";this._debug("user not found but this is OK for insecure mode - anonymous access will be used"),this._config.user=""}if(!this._config.timestamp){if(!this._config.insecure)throw"Missing required configuration parameter 'timestamp'";this._debug("token not found but this is OK for insecure mode")}if(!this._config.token){if(!this._config.insecure)throw"Missing required configuration parameter 'token' specifying the sign of authorization request";this._debug("timestamp not found but this is OK for insecure mode")}if(this._config.url=a(this._config.url),o(this._config.url,"connection"))if(this._debug("client will connect to SockJS endpoint"),null!==this._config.sockJS)this._debug("SockJS explicitly provided in options"),this._sockJS=this._config.sockJS;else{if("undefined"==typeof SockJS)throw"include SockJS client library before Centrifuge javascript client library or provide SockJS object in options or use raw Websocket connection endpoint";this._debug("use globally defined SockJS"),this._sockJS=SockJS}else o(this._config.url,"connection/websocket")?this._debug("client will connect to raw Websocket endpoint"):(this._debug("client will detect connection endpoint itself"),null!==this._config.sockJS?(this._debug("SockJS explicitly provided in options"),this._sockJS=this._config.sockJS):"undefined"==typeof SockJS?this._debug("SockJS not found"):(this._debug("use globally defined SockJS"),this._sockJS=SockJS))},v._setStatus=function(e){this._status!==e&&(this._debug("Status",this._status,"->",e),this._status=e)},v._isDisconnected=function(){return"disconnected"===this._status},v._isConnecting=function(){return"connecting"===this._status},v._isConnected=function(){return"connected"===this._status},v._nextMessageId=function(){return++this._messageId},v._resetRetry=function(){this._debug("reset retries count to 0"),this._retries=0},v._getRetryInterval=function(){var e=l(this._retries,this._config.retry,this._config.maxRetry);return this._retries+=1,e},v._clearConnectedState=function(e){this._clientID=null;for(var t in this._callbacks)if(this._callbacks.hasOwnProperty(t)){var n=this._callbacks[t],i=n.errback;if(!i)continue;i(this._createErrorObject("disconnected","retry"))}this._callbacks={};for(var s in this._subs)if(this._subs.hasOwnProperty(s)){var r=this._subs[s];e?(r._isSuccess()&&r._triggerUnsubscribe(),r._setSubscribing()):r._setUnsubscribed()}this._config.resubscribe&&this._reconnect||(this._subs={})},v._send=function(e){0!==e.length&&(1===e.length&&(e=e[0]),this._debug("Send",e),this._transport.send(JSON.stringify(e)))},v._setupTransport=function(){var e=this;if(this._isSockJS=!1,null!==this._sockJS){var t={transports:this._config.transports};null!==this._config.server&&(t.server=this._config.server),this._isSockJS=!0,this._transport=new this._sockJS(this._sockjsEndpoint(),null,t)}else{if(!this._websocketSupported())return void this._debug("No Websocket support and no SockJS configured, can not connect");this._transport=new WebSocket(this._rawWebsocketEndpoint())}this._transport.onopen=function(){e._transportClosed=!1,e._reconnecting=!1,e._isSockJS?(e._transportName=e._transport.transport,e._transport.onheartbeat=function(){e._restartPing()}):e._transportName="raw-websocket",e._resetRetry(),u(e._config.user)||e._log("user expected to be string"),u(e._config.info)||e._log("info expected to be string");var t={method:"connect",params:{user:e._config.user,info:e._config.info}};e._config.insecure||(t.params.timestamp=e._config.timestamp,t.params.token=e._config.token,u(e._config.timestamp)||e._log("timestamp expected to be string"),u(e._config.token)||e._log("token expected to be string")),e._addMessage(t),e._latencyStart=new Date},this._transport.onerror=function(t){e._debug("transport level error",t)},this._transport.onclose=function(t){e._transportClosed=!0;var n="connection closed",i=!0;if(t&&"reason"in t&&t.reason)try{var s=JSON.parse(t.reason);e._debug("reason is an advice object",s),n=s.reason,i=s.reconnect}catch(r){n=t.reason,e._debug("reason is a plain string",n),i="disconnect"!==n}if(null!==e._config.onTransportClose&&e._config.onTransportClose({event:t,reason:n,reconnect:i}),e._disconnect(n,i),e._reconnect===!0){e._reconnecting=!0;var o=e._getRetryInterval();e._debug("reconnect after "+o+" milliseconds"),setTimeout(function(){e._reconnect===!0&&e._connect.call(e)},o)}},this._transport.onmessage=function(t){var n;n=JSON.parse(t.data),e._debug("Received",n),e._receive(n),e._restartPing()}},v._connect=function(e){return this.isConnected()?void this._debug("connect called when already connected"):void("connecting"!==this._status&&(this._debug("start connecting"),this._setStatus("connecting"),this._clientID=null,this._reconnect=!0,e&&this.on("connect",e),this._setupTransport()))},v._disconnect=function(e,t){if(!this.isDisconnected()){this._debug("disconnected:",e,t);var n=t||!1;n===!1&&(this._reconnect=!1),this._clearConnectedState(t),this.isDisconnected()||(this._setStatus("disconnected"),this._refreshTimeout&&clearTimeout(this._refreshTimeout),this._reconnecting===!1&&this.trigger("disconnect",[{reason:e,reconnect:n}])),this._transportClosed||this._transport.close()}},v._refreshFailed=function(){self._numRefreshFailed=0,this.isDisconnected()||this._disconnect("refresh failed",!1),null!==this._config.refreshFailed&&this._config.refreshFailed()},v._refresh=function(){var e=this;if(this._debug("refresh credentials"),0===e._config.refreshAttempts)return this._debug("refresh attempts set to 0, do not send refresh request at all"),void e._refreshFailed();null!==e._refreshTimeout&&clearTimeout(e._refreshTimeout);var t=function(t,n){return t===!0?(e._debug("error getting connection credentials from refresh endpoint",n),e._numRefreshFailed++,e._refreshTimeout&&clearTimeout(e._refreshTimeout),null!==e._config.refreshAttempts&&e._numRefreshFailed>=e._config.refreshAttempts?void e._refreshFailed():void(e._refreshTimeout=setTimeout(function(){e._refresh.call(e)},e._config.refreshInterval+Math.round(1e3*Math.random())))):(e._numRefreshFailed=0,e._config.user=n.user,e._config.timestamp=n.timestamp,"info"in n&&(e._config.info=n.info),e._config.token=n.token,void(e.isDisconnected()?(e._debug("credentials refreshed, connect from scratch"),e._connect()):(e._debug("send refreshed credentials"),e._addMessage({method:"refresh",params:{user:e._config.user,timestamp:e._config.timestamp,info:e._config.info,token:e._config.token}}))))};if(null!==this._config.onRefresh)context={},this._config.onRefresh(context,t);else{var n=this._config.refreshTransport.toLowerCase();if("ajax"===n)this._ajax(this._config.refreshEndpoint,this._config.refreshParams,this._config.refreshHeaders,this._config.refreshData,t);else{if("jsonp"!==n)throw"Unknown refresh transport "+n;this._jsonp(this._config.refreshEndpoint,this._config.refreshParams,this._config.refreshHeaders,this._config.refreshData,t)}}},v._subscribe=function(e){var t=e.channel;if(t in this._subs||(this._subs[t]=e),!this.isConnected())return void e._setNew();e._setSubscribing();var n={method:"subscribe",params:{channel:t}};if(c(t,this._config.privateChannelPrefix))this._isAuthBatching?this._authChannels[t]=!0:(this.startAuthBatching(),this._subscribe(e),this.stopAuthBatching());else{var i=this._recover(t);i===!0&&(n.params.recover=!0,n.params.last=this._getLastID(t)),this._addMessage(n)}},v._unsubscribe=function(e){this.isConnected()&&this._addMessage({method:"unsubscribe",params:{channel:e.channel}})},v._getSub=function(e){var t=this._subs[e];return t?t:null},v._connectResponse=function(e){if(!this.isConnected())if(_(e))this.trigger("error",[{message:e}]);else{if(null!==this._latencyStart&&(this._latency=(new Date).getTime()-this._latencyStart.getTime(),this._latencyStart=null),!e.body)return;if(e.body.expires){var t=e.body.expired;if(t)return this._reconnecting=!0,this._disconnect("expired",!0),void this._refresh()}this._clientID=e.body.client,this._setStatus("connected"),this._refreshTimeout&&clearTimeout(this._refreshTimeout);var n=this;if(e.body.expires&&(this._refreshTimeout=setTimeout(function(){n._refresh.call(n)},1e3*e.body.ttl)),this._config.resubscribe){this.startBatching(),this.startAuthBatching();for(var i in this._subs)if(this._subs.hasOwnProperty(i)){var s=this._subs[i];s._shouldResubscribe()&&this._subscribe(s)}this.stopAuthBatching(),this.stopBatching(!0)}this._restartPing(),this.trigger("connect",[{client:e.body.client,transport:this._transportName,latency:this._latency}])}},v._stopPing=function(){null!==this._pongTimeout&&clearTimeout(this._pongTimeout),null!==this._pingInterval&&clearInterval(this._pingInterval)},v._startPing=function(){if(!(this._config.ping!==!0||this._config.pingInterval<=0)&&this.isConnected()){var e=this;this._pingInterval=setInterval(function(){return e.isConnected()?(e.ping(),void(e._pongTimeout=setTimeout(function(){e._disconnect("no ping",!0)},e._config.pongWaitTimeout))):void e._stopPing()},this._config.pingInterval)}},v._restartPing=function(){this._stopPing(),this._startPing()},v._disconnectResponse=function(e){if(_(e))this.trigger("error",[{message:e}]);else{var t=!1;"reconnect"in e.body&&(t=e.body.reconnect);var n="";"reason"in e.body&&(n=e.body.reason),this._disconnect(n,t)}},v._subscribeResponse=function(e){var t=e.body;if(null!==t){var n=t.channel,i=this._getSub(n);if(i&&i._isSubscribing())if(_(e))this.trigger("error",[{message:e}]),i._setSubscribeError(this._errorObjectFromMessage(e));else{var s=t.messages;if(s&&s.length>0){s=s.reverse();for(var r in s)s.hasOwnProperty(r)&&this._messageResponse({body:s[r]})}else"last"in t&&(this._lastMessageID[n]=t.last);var o=!1;"recovered"in t&&(o=t.recovered),i._setSubscribeSuccess(o)}}},v._unsubscribeResponse=function(e){var t=e.uid,n=e.body,i=n.channel,s=this._getSub(i);s&&(_(e)?this.trigger("error",[{message:e}]):t||s._setUnsubscribed())},v._publishResponse=function(e){var t=e.uid,n=e.body;if(t in this._callbacks){var i=this._callbacks[t];if(delete this._callbacks[t],_(e)){var s=i.errback;if(!s)return;s(this._errorObjectFromMessage(e)),this.trigger("error",[{message:e}])}else{var r=i.callback;if(!r)return;r(n)}}},v._presenceResponse=function(e){var t=e.uid,n=e.body;if(t in this._callbacks){var i=this._callbacks[t];if(delete this._callbacks[t],_(e)){var s=i.errback;if(!s)return;s(this._errorObjectFromMessage(e)),this.trigger("error",[{message:e}])}else{var r=i.callback;if(!r)return;r(n)}}},v._historyResponse=function(e){var t=e.uid,n=e.body;if(t in this._callbacks){var i=this._callbacks[t];if(delete this._callbacks[t],_(e)){var s=i.errback;if(!s)return;s(this._errorObjectFromMessage(e)),this.trigger("error",[{message:e}])}else{var r=i.callback;if(!r)return;r(n)}}},v._joinResponse=function(e){var t=e.body,n=t.channel,i=this._getSub(n);i&&i.trigger("join",[t])},v._leaveResponse=function(e){var t=e.body,n=t.channel,i=this._getSub(n);i&&i.trigger("leave",[t])},v._messageResponse=function(e){var t=e.body,n=t.channel;this._lastMessageID[n]=t.uid;var i=this._getSub(n);i&&i.trigger("message",[t])},v._refreshResponse=function(e){if(this._refreshTimeout&&clearTimeout(this._refreshTimeout),_(e))this.trigger("error",[{message:e}]);else if(e.body.expires){var t=this,n=e.body.expired;if(n)return void(t._refreshTimeout=setTimeout(function(){t._refresh.call(t)},t._config.refreshInterval+Math.round(1e3*Math.random())));this._clientID=e.body.client,t._refreshTimeout=setTimeout(function(){t._refresh.call(t)},1e3*e.body.ttl)}},v._dispatchMessage=function(e){if(void 0===e||null===e)return void this._debug("dispatch: got undefined or null message");var t=e.method;if(!t)return void this._debug("dispatch: got message with empty method");switch(t){case"connect":this._connectResponse(e);break;case"disconnect":this._disconnectResponse(e);break;case"subscribe":this._subscribeResponse(e);break;case"unsubscribe":this._unsubscribeResponse(e);break;case"publish":this._publishResponse(e);break;case"presence":this._presenceResponse(e);break;case"history":this._historyResponse(e);break;case"join":this._joinResponse(e);break;case"leave":this._leaveResponse(e);break;case"ping":break;case"refresh":this._refreshResponse(e);break;case"message":this._messageResponse(e);break;default:this._debug("dispatch: got message with unknown method"+t)}},v._receive=function(e){if(Object.prototype.toString.call(e)===Object.prototype.toString.call([]))for(var t in e)e.hasOwnProperty(t)&&this._dispatchMessage(e[t]);else Object.prototype.toString.call(e)===Object.prototype.toString.call({})&&this._dispatchMessage(e)},v._flush=function(){var e=this._messages.slice(0);this._messages=[],this._send(e)},v._ping=function(){this._addMessage({method:"ping"})},v._recover=function(e){return e in this._lastMessageID},v._getLastID=function(e){var t=this._lastMessageID[e];return t?(this._debug("last uid found and sent for channel",e),t):(this._debug("no last uid found for channel",e),"")},v._createErrorObject=function(e,t){var n={error:e};return t&&(n.advice=t),n},v._errorObjectFromMessage=function(e){return this._createErrorObject(e.error,e.advice)},v._registerCall=function(e,t,n){var i=this;this._callbacks[e]={callback:t,errback:n},setTimeout(function(){delete i._callbacks[e],h(n)&&n(i._createErrorObject("timeout","retry"))},this._config.timeout)},v._addMessage=function(e){var t=""+this._nextMessageId();return e.uid=t,this._isBatching===!0?this._messages.push(e):this._send([e]),t},v.getClientId=function(){return this._clientID},v.isConnected=v._isConnected,v.isDisconnected=v._isDisconnected,v.configure=function(e){this._configure.call(this,e)},v.connect=v._connect,v.disconnect=function(){this._disconnect("client",!1)},v.ping=v._ping,v.startBatching=function(){this._isBatching=!0},v.stopBatching=function(e){e=e||!1,this._isBatching=!1,e===!0&&this.flush()},v.flush=function(){this._flush()},v.startAuthBatching=function(){this._isAuthBatching=!0},v.stopAuthBatching=function(){var e,t;this._isAuthBatching=!1;var n=this._authChannels;this._authChannels={};var i=[];for(t in n)if(n.hasOwnProperty(t)){var s=this._getSub(t);if(!s)continue;i.push(t)}if(0!==i.length){var r={client:this.getClientId(),channels:i},o=this,c=function(n,s){if(n!==!0){var r=!1;o._isBatching||(o.startBatching(),r=!0);for(e in i)if(i.hasOwnProperty(e)){t=i[e];var c=s[t];if(!c){o._subscribeResponse({error:"channel not found in authorization response",advice:"fix",body:{channel:t}});continue}if(c.status&&200!==c.status)o._subscribeResponse({error:c.status,body:{channel:t}});else{var a={method:"subscribe",params:{channel:t,client:o.getClientId(),info:c.info,sign:c.sign}},u=o._recover(t);u===!0&&(a.params.recover=!0,a.params.last=o._getLastID(t)),o._addMessage(a)}}r&&o.stopBatching(!0)}else{o._debug("authorization request failed");
for(e in i)i.hasOwnProperty(e)&&(t=i[e],o._subscribeResponse({error:"authorization request failed",advice:"fix",body:{channel:t}}))}};if(null!==this._config.onPrivateChannelAuth)this._config.onPrivateChannelAuth({data:r},c);else{var a=this._config.authTransport.toLowerCase();if("ajax"===a)this._ajax(this._config.authEndpoint,this._config.authParams,this._config.authHeaders,r,c);else{if("jsonp"!==a)throw"Unknown private channel auth transport "+a;this._jsonp(this._config.authEndpoint,this._config.authParams,this._config.authHeaders,r,c)}}}},v.subscribe=function(e,t){if(arguments.length<1)throw"Illegal arguments number: required 1, got "+arguments.length;if(!u(e))throw"Illegal argument type: channel must be a string";if(!this._config.resubscribe&&!this.isConnected())throw"Can not only subscribe in connected state when resubscribe option is off";var n=this._getSub(e);if(null!==n)return n._setEvents(t),n._isUnsubscribed()&&n.subscribe(),n;var i=new g(this,e,t);return this._subs[e]=i,i.subscribe(),i};var m=0,y=1,w=2,S=3,k=4;i(g,b);var O=g.prototype;O._initializePromise=function(){this._ready=!1;var e=this;this._promise=new p(function(t,n){e._resolve=function(n){e._ready=!0,t(n)},e._reject=function(t){e._ready=!0,n(t)}})},O._setEvents=function(e){if(e)if(h(e))this.on("message",e);else if(Object.prototype.toString.call(e)===Object.prototype.toString.call({}))for(var t=["message","join","leave","unsubscribe","subscribe","error"],n=0,i=t.length;i>n;n++){var s=t[n];s in e&&this.on(s,e[s])}},O._isNew=function(){return this._status===m},O._isUnsubscribed=function(){return this._status===k},O._isSubscribing=function(){return this._status===y},O._isReady=function(){return this._status===w||this._status===S},O._isSuccess=function(){return this._status===w},O._isError=function(){return this._status===S},O._setNew=function(){this._status=m},O._setSubscribing=function(){this._ready===!0&&(this._initializePromise(),this._isResubscribe=!0),this._status=y},O._setSubscribeSuccess=function(e){if(this._status!==w){this._recovered=e,this._status=w;var t=this._getSubscribeSuccessContext(e);this.trigger("subscribe",[t]),this._resolve(t)}},O._setSubscribeError=function(e){if(this._status!==S){this._status=S,this._error=e;var t=this._getSubscribeErrorContext();this.trigger("error",[t]),this._reject(t)}},O._triggerUnsubscribe=function(){this.trigger("unsubscribe",[{channel:this.channel}])},O._setUnsubscribed=function(e){this._status!==k&&(this._status=k,e===!0&&(this._noResubscribe=!0),this._triggerUnsubscribe())},O._shouldResubscribe=function(){return!this._noResubscribe},O._getSubscribeSuccessContext=function(){return{channel:this.channel,isResubscribe:this._isResubscribe,recovered:this._recovered}},O._getSubscribeErrorContext=function(){var e=this._error;return e.channel=this.channel,e.isResubscribe=this._isResubscribe,e},O.ready=function(e,t){this._ready&&(this._isSuccess()?e(this._getSubscribeSuccessContext()):t(this._getSubscribeErrorContext()))},O.subscribe=function(){return this._status!==w?(this._centrifuge._subscribe(this),this):void 0},O.unsubscribe=function(){this._setUnsubscribed(!0),this._centrifuge._unsubscribe(this)},O.publish=function(e){var t=this;return new p(function(n,i){return t._isUnsubscribed()?void i(t._centrifuge._createErrorObject("subscription unsubscribed","fix")):void t._promise.then(function(){if(!t._centrifuge.isConnected())return void i(t._centrifuge._createErrorObject("disconnected","retry"));var s=t._centrifuge._addMessage({method:"publish",params:{channel:t.channel,data:e}});t._centrifuge._registerCall(s,n,i)},function(e){i(e)})})},O.presence=function(){var e=this;return new p(function(t,n){return e._isUnsubscribed()?void n(e._centrifuge._createErrorObject("subscription unsubscribed","fix")):void e._promise.then(function(){if(!e._centrifuge.isConnected())return void n(e._centrifuge._createErrorObject("disconnected","retry"));var i=e._centrifuge._addMessage({method:"presence",params:{channel:e.channel}});e._centrifuge._registerCall(i,t,n)},function(e){n(e)})})},O.history=function(){var e=this;return new p(function(t,n){return e._isUnsubscribed()?void n(e._centrifuge._createErrorObject("subscription unsubscribed","fix")):void e._promise.then(function(){if(!e._centrifuge.isConnected())return void n(e._centrifuge._createErrorObject("disconnected","retry"));var i=e._centrifuge._addMessage({method:"history",params:{channel:e.channel}});e._centrifuge._registerCall(i,t,n)},function(e){n(e)})})},t.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"es6-promise":2,"wolfy87-eventemitter":3}]},{},[4])(4)});

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

1.4.8
=====
* `withCredentials` support for XHR requests - [#39](https://github.com/centrifugal/centrifuge-js/issues/39).
* fix resubscribe bug introduced in 1.4.7
1.4.7

@@ -2,0 +8,0 @@ =====

{
"name": "centrifuge",
"version": "1.4.7",
"version": "1.4.8",
"description": "Centrifuge javascript client",

@@ -20,3 +20,3 @@ "main": "src/centrifuge.js",

"vinyl-source-stream": "^1.0.0",
"require-dir": "^0.1.0"
"require-dir": "^0.3.2"
},

@@ -23,0 +23,0 @@ "scripts": {

@@ -9,10 +9,11 @@ var Promise = require('es6-promise').Promise;

if (!Object.create) {
Object.create = (function(){
function F(){}
return function(o){
if (arguments.length != 1) {
Object.create = (function () {
var F = function () {
};
return function (o) {
if (arguments.length !== 1) {
throw new Error('Object.create implementation only accepts one parameter.');
}
F.prototype = o;
return new F()
return new F();
}

@@ -28,8 +29,53 @@ })()

/**
* Array.prototype.indexOf polyfill from
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
*/
if (!Array.prototype.indexOf) {
Array.prototype.indexOf=function(r){if(null==this)throw new TypeError;var t,e,n=Object(this),a=n.length>>>0;if(0===a)return-1;if(t=0,arguments.length>1&&(t=Number(arguments[1]),t!=t?t=0:0!=t&&1/0!=t&&t!=-1/0&&(t=(t>0||-1)*Math.floor(Math.abs(t)))),t>=a)return-1;for(e=t>=0?t:Math.max(a-Math.abs(t),0);a>e;e++)if(e in n&&n[e]===r)return e;return-1};
Array.prototype.indexOf = function (vMember, nStartFrom) {
/*
In non-strict mode, if the `this` variable is null or undefined, then it is
set the window object. Otherwise, `this` is automaticly converted to an
object. In strict mode if the `this` variable is null or undefined a
`TypeError` is thrown.
*/
if (!this) {
throw new TypeError('Array.prototype.indexOf() - can not convert "' + this + '" to object');
}
var nIdx = isFinite(nStartFrom) ? Math.floor(nStartFrom) : 0,
oThis = this instanceof Object ? this : new Object(this),
nLen = isFinite(oThis.length) ? Math.floor(oThis.length) : 0;
if (nIdx >= nLen) {
return -1;
}
if (nIdx < 0) {
nIdx = Math.max(nLen + nIdx, 0);
}
if (vMember === undefined) {
/*
Since `vMember` is undefined, keys that don't exist will have the same
value as `vMember`, and thus do need to be checked.
*/
do {
if (nIdx in oThis && oThis[nIdx] === undefined) {
return nIdx;
}
} while (++nIdx < nLen);
} else {
do {
if (oThis[nIdx] === vMember) {
return nIdx;
}
} while (++nIdx < nLen);
}
return -1;
};
}
function fieldValue(object, name) {
try {return object[name];} catch (x) {return undefined;}
try {
return object[name];
} catch (x) {
return undefined;
}
}

@@ -45,3 +91,3 @@

var result = target || {};
for (var i = 2; i < arguments.length; ++i) { // Skip first 2 parameters (deep and target), and loop over the others
for (var i = 2, l = arguments.length; i < l; i++) { // Skip first 2 parameters (deep and target), and loop over the others
var object = arguments[i];

@@ -84,3 +130,3 @@ if (object === undefined || object === null) {

function stripSlash(value) {
if (value.substring(value.length - 1) == "/") {
if (value.substring(value.length - 1) === '/') {
value = value.substring(0, value.length - 1);

@@ -116,11 +162,11 @@ }

var jitter = 0.5 * Math.random();
var interval = min * Math.pow(2, step+1);
var interval = min * Math.pow(2, step + 1);
if (interval > max) {
interval = max
interval = max;
}
return Math.floor((1-jitter) * interval);
return Math.floor((1 - jitter) * interval);
}
function errorExists(data) {
return "error" in data && data.error !== null && data.error !== "";
return 'error' in data && data.error !== null && data.error !== '';
}

@@ -158,3 +204,3 @@

timeout: 5000,
info: "",
info: '',
resubscribe: true,

@@ -167,3 +213,3 @@ ping: true,

server: null,
privateChannelPrefix: "$",
privateChannelPrefix: '$',
onTransportClose: null,

@@ -183,7 +229,7 @@ transports: [

onRefresh: null,
refreshEndpoint: "/centrifuge/refresh/",
refreshEndpoint: '/centrifuge/refresh/',
refreshHeaders: {},
refreshParams: {},
refreshData: {},
refreshTransport: "ajax",
refreshTransport: 'ajax',
refreshAttempts: null,

@@ -193,6 +239,6 @@ refreshInterval: 3000,

onPrivateChannelAuth: null,
authEndpoint: "/centrifuge/auth/",
authEndpoint: '/centrifuge/auth/',
authHeaders: {},
authParams: {},
authTransport: "ajax"
authTransport: 'ajax'
};

@@ -214,15 +260,16 @@ if (options) {

if (headers.length > 0) {
this._log("Only AJAX request allows to send custom headers, it's not possible with JSONP.");
this._log('Only AJAX request allows to send custom headers, it is not possible with JSONP.');
}
self._debug("sending JSONP request to", url);
self._debug('sending JSONP request to', url);
var callbackName = "centrifuge_jsonp_" + Centrifuge._nextJSONPCallbackID.toString();
var callbackName = 'centrifuge_jsonp_' + Centrifuge._nextJSONPCallbackID.toString();
Centrifuge._nextJSONPCallbackID++;
var document = global.document;
var script = document.createElement("script");
var script = document.createElement('script');
var timeoutTrigger = setTimeout(function(){
Centrifuge._jsonpCallbacks[callbackName] = function() {};
callback(true, "timeout");
var timeoutTrigger = setTimeout(function () {
Centrifuge._jsonpCallbacks[callbackName] = function () {
};
callback(true, 'timeout');
}, 3000);

@@ -236,11 +283,13 @@

var query = "";
var query = '';
for (var i in params) {
if (query.length > 0) {
query += "&";
if (params.hasOwnProperty(i)) {
if (query.length > 0) {
query += '&';
}
query += encodeURIComponent(i) + '=' + encodeURIComponent(params[i]);
}
query += encodeURIComponent(i) + "=" + encodeURIComponent(params[i]);
}
var callback_name = "Centrifuge._jsonpCallbacks['" + callbackName + "']";
var callback_name = 'Centrifuge._jsonpCallbacks[\'' + callbackName + '\']';
script.src = this._config.authEndpoint +

@@ -251,3 +300,3 @@ '?callback=' + encodeURIComponent(callback_name) +

var head = document.getElementsByTagName("head")[0] || document.documentElement;
var head = document.getElementsByTagName('head')[0] || document.documentElement;
head.insertBefore(script, head.firstChild);

@@ -258,23 +307,30 @@ };

var self = this;
self._debug("sending AJAX request to", url);
self._debug('sending AJAX request to', url);
var xhr = (global.XMLHttpRequest ? new global.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"));
var xhr = (global.XMLHttpRequest ? new global.XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'));
var query = "";
var query = '';
for (var i in params) {
if (query.length > 0) {
query += "&";
if (params.hasOwnProperty(i)) {
if (query.length > 0) {
query += '&';
}
query += encodeURIComponent(i) + '=' + encodeURIComponent(params[i]);
}
query += encodeURIComponent(i) + "=" + encodeURIComponent(params[i]);
}
if (query.length > 0) {
query = "?" + query;
query = '?' + query;
}
xhr.open("POST", url + query, true);
xhr.open('POST', url + query, true);
if ('withCredentials' in xhr) {
xhr.withCredentials = true;
}
// add request headers
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader('Content-Type', 'application/json');
for (var headerName in headers) {
xhr.setRequestHeader(headerName, headers[headerName]);
if (headers.hasOwnProperty(headerName)) {
xhr.setRequestHeader(headerName, headers[headerName]);
}
}

@@ -302,3 +358,3 @@

setTimeout(function() {
setTimeout(function () {
xhr.send(JSON.stringify(data));

@@ -310,3 +366,3 @@ }, 20);

centrifugeProto._log = function () {
log("info", arguments);
log('info', arguments);
};

@@ -316,3 +372,3 @@

if (this._config.debug === true) {
log("debug", arguments);
log('debug', arguments);
}

@@ -327,7 +383,8 @@ };

var url = this._config.url;
url = url.replace("ws://", "http://");
url = url.replace("wss://", "https://");
url = url
.replace('ws://', 'http://')
.replace('wss://', 'https://');
url = stripSlash(url);
if (!endsWith(this._config.url, 'connection')) {
url = url + "/connection";
url = url + '/connection';
}

@@ -339,7 +396,8 @@ return url;

var url = this._config.url;
url = url.replace("http://", "ws://");
url = url.replace("https://", "wss://");
url = url
.replace('http://', 'ws://')
.replace('https://', 'wss://');
url = stripSlash(url);
if (!endsWith(this._config.url, 'connection/websocket')) {
url = url + "/connection/websocket";
url = url + '/connection/websocket';
}

@@ -366,4 +424,4 @@ return url;

} else {
this._debug("user not found but this is OK for insecure mode - anonymous access will be used");
this._config.user = "";
this._debug('user not found but this is OK for insecure mode - anonymous access will be used');
this._config.user = '';
}

@@ -376,3 +434,3 @@ }

} else {
this._debug("token not found but this is OK for insecure mode");
this._debug('token not found but this is OK for insecure mode');
}

@@ -385,3 +443,3 @@ }

} else {
this._debug("timestamp not found but this is OK for insecure mode");
this._debug('timestamp not found but this is OK for insecure mode');
}

@@ -393,5 +451,5 @@ }

if (endsWith(this._config.url, 'connection')) {
this._debug("client will connect to SockJS endpoint");
this._debug('client will connect to SockJS endpoint');
if (this._config.sockJS !== null) {
this._debug("SockJS explicitly provided in options");
this._debug('SockJS explicitly provided in options');
this._sockJS = this._config.sockJS;

@@ -402,17 +460,17 @@ } else {

}
this._debug("use globally defined SockJS");
this._debug('use globally defined SockJS');
this._sockJS = SockJS;
}
} else if (endsWith(this._config.url, 'connection/websocket')) {
this._debug("client will connect to raw Websocket endpoint");
this._debug('client will connect to raw Websocket endpoint');
} else {
this._debug("client will detect connection endpoint itself");
this._debug('client will detect connection endpoint itself');
if (this._config.sockJS !== null) {
this._debug("SockJS explicitly provided in options");
this._debug('SockJS explicitly provided in options');
this._sockJS = this._config.sockJS;
} else {
if (typeof SockJS === 'undefined') {
this._debug("SockJS not found");
this._debug('SockJS not found');
} else {
this._debug("use globally defined SockJS");
this._debug('use globally defined SockJS');
this._sockJS = SockJS;

@@ -435,3 +493,3 @@ }

centrifugeProto._isConnecting = function() {
centrifugeProto._isConnecting = function () {
return this._status === 'connecting';

@@ -448,8 +506,8 @@ };

centrifugeProto._resetRetry = function() {
this._debug("reset retries count to 0");
centrifugeProto._resetRetry = function () {
this._debug('reset retries count to 0');
this._retries = 0;
};
centrifugeProto._getRetryInterval = function() {
centrifugeProto._getRetryInterval = function () {
var interval = backoff(this._retries, this._config.retry, this._config.maxRetry);

@@ -465,8 +523,10 @@ this._retries += 1;

for (var uid in this._callbacks) {
var callbacks = this._callbacks[uid];
var errback = callbacks["errback"];
if (!errback) {
continue;
if (this._callbacks.hasOwnProperty(uid)) {
var callbacks = this._callbacks[uid];
var errback = callbacks.errback;
if (!errback) {
continue;
}
errback(this._createErrorObject('disconnected', 'retry'));
}
errback(this._createErrorObject("disconnected", "retry"));
}

@@ -477,10 +537,12 @@ this._callbacks = {};

for (var channel in this._subs) {
var sub = this._subs[channel];
if (reconnect) {
if (sub._isSuccess()) {
sub._triggerUnsubscribe();
if (this._subs.hasOwnProperty(channel)) {
var sub = this._subs[channel];
if (reconnect) {
if (sub._isSuccess()) {
sub._triggerUnsubscribe();
}
sub._setSubscribing();
} else {
sub._setUnsubscribed();
}
sub._setSubscribing();
} else {
sub._setUnsubscribed();
}

@@ -499,3 +561,3 @@ }

}
if (messages.length == 1) {
if (messages.length === 1) {
// small optimization to send single object to server to reduce allocations required

@@ -509,3 +571,3 @@ // to parse array compared to parse single object client request.

centrifugeProto._setupTransport = function() {
centrifugeProto._setupTransport = function () {

@@ -519,6 +581,6 @@ var self = this;

var sockjsOptions = {
"transports": this._config.transports
transports: this._config.transports
};
if (this._config.server !== null) {
sockjsOptions['server'] = this._config.server;
sockjsOptions.server = this._config.server;
}

@@ -529,3 +591,3 @@ this._isSockJS = true;

if (!this._websocketSupported()) {
this._debug("No Websocket support and no SockJS configured, can't connect");
this._debug('No Websocket support and no SockJS configured, can not connect');
return;

@@ -542,7 +604,7 @@ }

self._transportName = self._transport.transport;
self._transport.onheartbeat = function(){
self._transport.onheartbeat = function () {
self._restartPing();
};
} else {
self._transportName = "raw-websocket";
self._transportName = 'raw-websocket';
}

@@ -553,13 +615,13 @@

if (!isString(self._config.user)) {
self._log("user expected to be string");
self._log('user expected to be string');
}
if (!isString(self._config.info)) {
self._log("info expected to be string");
self._log('info expected to be string');
}
var msg = {
'method': 'connect',
'params': {
'user': self._config.user,
'info': self._config.info
method: 'connect',
params: {
user: self._config.user,
info: self._config.info
}

@@ -570,9 +632,9 @@ };

// in insecure client mode we don't need timestamp and token.
msg["params"]["timestamp"] = self._config.timestamp;
msg["params"]["token"] = self._config.token;
msg.params.timestamp = self._config.timestamp;
msg.params.token = self._config.token;
if (!isString(self._config.timestamp)) {
self._log("timestamp expected to be string");
self._log('timestamp expected to be string');
}
if (!isString(self._config.token)) {
self._log("token expected to be string");
self._log('token expected to be string');
}

@@ -585,3 +647,3 @@ }

this._transport.onerror = function (error) {
self._debug("transport level error", error);
self._debug('transport level error', error);
};

@@ -591,14 +653,14 @@

self._transportClosed = true;
var reason = "connection closed";
var reason = 'connection closed';
var needReconnect = true;
if (closeEvent && "reason" in closeEvent && closeEvent["reason"]) {
if (closeEvent && 'reason' in closeEvent && closeEvent.reason) {
try {
var advice = JSON.parse(closeEvent["reason"]);
self._debug("reason is an advice object", advice);
var advice = JSON.parse(closeEvent.reason);
self._debug('reason is an advice object', advice);
reason = advice.reason;
needReconnect = advice.reconnect;
} catch (e) {
reason = closeEvent["reason"];
self._debug("reason is a plain string", reason);
needReconnect = reason !== "disconnect";
reason = closeEvent.reason;
self._debug('reason is a plain string', reason);
needReconnect = reason !== 'disconnect';
}

@@ -613,5 +675,5 @@ }

self._config.onTransportClose({
"event": closeEvent,
"reason": reason,
"reconnect": needReconnect
event: closeEvent,
reason: reason,
reconnect: needReconnect
});

@@ -625,3 +687,3 @@ }

var interval = self._getRetryInterval();
self._debug("reconnect after " + interval + " milliseconds");
self._debug('reconnect after ' + interval + ' milliseconds');
setTimeout(function () {

@@ -648,11 +710,11 @@ if (self._reconnect === true) {

if (this.isConnected()) {
this._debug("connect called when already connected");
this._debug('connect called when already connected');
return;
}
if (this._status == 'connecting') {
if (this._status === 'connecting') {
return;
}
this._debug("start connecting");
this._debug('start connecting');

@@ -677,3 +739,3 @@ this._setStatus('connecting');

this._debug("disconnected:", reason, shouldReconnect);
this._debug('disconnected:', reason, shouldReconnect);

@@ -689,6 +751,2 @@ var reconnect = shouldReconnect || false;

this._setStatus('disconnected');
var disconnectContext = {
"reason": reason,
"reconnect": reconnect
};
if (this._refreshTimeout) {

@@ -698,3 +756,6 @@ clearTimeout(this._refreshTimeout);

if (this._reconnecting === false) {
this.trigger('disconnect', [disconnectContext]);
this.trigger('disconnect', [{
reason: reason,
reconnect: reconnect
}]);
}

@@ -708,6 +769,6 @@ }

centrifugeProto._refreshFailed = function() {
centrifugeProto._refreshFailed = function () {
self._numRefreshFailed = 0;
if (!this.isDisconnected()) {
this._disconnect("refresh failed", false);
this._disconnect('refresh failed', false);
}

@@ -735,7 +796,7 @@ if (this._config.refreshFailed !== null) {

var cb = function(error, data) {
var cb = function (error, data) {
if (error === true) {
// We don't perform any connection status related actions here as we are
// relying on Centrifugo that must close connection eventually.
self._debug("error getting connection credentials from refresh endpoint", data);
self._debug('error getting connection credentials from refresh endpoint', data);
self._numRefreshFailed++;

@@ -749,3 +810,3 @@ if (self._refreshTimeout) {

}
self._refreshTimeout = setTimeout(function(){
self._refreshTimeout = setTimeout(function () {
self._refresh.call(self);

@@ -758,3 +819,3 @@ }, self._config.refreshInterval + Math.round(Math.random() * 1000));

self._config.timestamp = data.timestamp;
if ("info" in data) {
if ('info' in data) {
self._config.info = data.info;

@@ -764,16 +825,15 @@ }

if (self.isDisconnected()) {
self._debug("credentials refreshed, connect from scratch");
self._debug('credentials refreshed, connect from scratch');
self._connect();
} else {
self._debug("send refreshed credentials");
var msg = {
"method": "refresh",
"params": {
'user': self._config.user,
'timestamp': self._config.timestamp,
'info': self._config.info,
'token': self._config.token
self._debug('send refreshed credentials');
self._addMessage({
method: 'refresh',
params: {
user: self._config.user,
timestamp: self._config.timestamp,
info: self._config.info,
token: self._config.token
}
};
self._addMessage(msg);
});
}

@@ -787,5 +847,5 @@ };

var transport = this._config.refreshTransport.toLowerCase();
if (transport === "ajax") {
if (transport === 'ajax') {
this._ajax(this._config.refreshEndpoint, this._config.refreshParams, this._config.refreshHeaders, this._config.refreshData, cb);
} else if (transport === "jsonp") {
} else if (transport === 'jsonp') {
this._jsonp(this._config.refreshEndpoint, this._config.refreshParams, this._config.refreshHeaders, this._config.refreshData, cb);

@@ -798,3 +858,3 @@ } else {

centrifugeProto._subscribe = function(sub) {
centrifugeProto._subscribe = function (sub) {

@@ -816,5 +876,5 @@ var channel = sub.channel;

var msg = {
"method": "subscribe",
"params": {
"channel": channel
method: 'subscribe',
params: {
channel: channel
}

@@ -839,4 +899,4 @@ };

if (recover === true) {
msg["params"]["recover"] = true;
msg["params"]["last"] = this._getLastID(channel);
msg.params.recover = true;
msg.params.last = this._getLastID(channel);
}

@@ -847,16 +907,15 @@ this._addMessage(msg);

centrifugeProto._unsubscribe = function(sub) {
centrifugeProto._unsubscribe = function (sub) {
if (this.isConnected()) {
// No need to unsubscribe in disconnected state - i.e. client already unsubscribed.
var msg = {
"method": "unsubscribe",
"params": {
"channel": sub.channel
this._addMessage({
method: 'unsubscribe',
params: {
channel: sub.channel
}
};
this._addMessage(msg);
});
}
};
centrifugeProto._getSub = function(channel) {
centrifugeProto._getSub = function (channel) {
var sub = this._subs[channel];

@@ -870,3 +929,2 @@ if (!sub) {

centrifugeProto._connectResponse = function (message) {
if (this.isConnected()) {

@@ -889,4 +947,4 @@ return;

if (isExpired) {
this._reconnecting = true
this._disconnect("expired", true)
this._reconnecting = true;
this._disconnect('expired', true);
this._refresh();

@@ -906,3 +964,3 @@ return;

if (message.body.expires) {
this._refreshTimeout = setTimeout(function() {
this._refreshTimeout = setTimeout(function () {
self._refresh.call(self);

@@ -916,5 +974,7 @@ }, message.body.ttl * 1000);

for (var channel in this._subs) {
var sub = this._subs[channel];
if (sub._shouldResubscribe()) {
this._subscribe(sub);
if (this._subs.hasOwnProperty(channel)) {
var sub = this._subs[channel];
if (sub._shouldResubscribe()) {
this._subscribe(sub);
}
}

@@ -926,16 +986,16 @@ }

var connectContext = {
"client": message.body.client,
"transport": this._transportName,
"latency": this._latency
};
this._restartPing();
this.trigger('connect', [connectContext]);
this.trigger('connect', [{
client: message.body.client,
transport: this._transportName,
latency: this._latency
}]);
} else {
this.trigger('error', [{"message": message}]);
this.trigger('error', [{
message: message
}]);
}
};
centrifugeProto._stopPing = function() {
centrifugeProto._stopPing = function () {
if (this._pongTimeout !== null) {

@@ -949,3 +1009,3 @@ clearTimeout(this._pongTimeout);

centrifugeProto._startPing = function() {
centrifugeProto._startPing = function () {
if (this._config.ping !== true || this._config.pingInterval <= 0) {

@@ -960,3 +1020,3 @@ return;

this._pingInterval = setInterval(function() {
this._pingInterval = setInterval(function () {
if (!self.isConnected()) {

@@ -967,4 +1027,4 @@ self._stopPing();

self.ping();
self._pongTimeout = setTimeout(function() {
self._disconnect("no ping", true);
self._pongTimeout = setTimeout(function () {
self._disconnect('no ping', true);
}, self._config.pongWaitTimeout);

@@ -974,3 +1034,3 @@ }, this._config.pingInterval);

centrifugeProto._restartPing = function() {
centrifugeProto._restartPing = function () {
this._stopPing();

@@ -983,12 +1043,14 @@ this._startPing();

var shouldReconnect = false;
if ("reconnect" in message.body) {
shouldReconnect = message.body["reconnect"];
if ('reconnect' in message.body) {
shouldReconnect = message.body.reconnect;
}
var reason = "";
if ("reason" in message.body) {
reason = message.body["reason"];
var reason = '';
if ('reason' in message.body) {
reason = message.body.reason;
}
this._disconnect(reason, shouldReconnect);
} else {
this.trigger('error', [{"message": message}]);
this.trigger('error', [{
message: message
}]);
}

@@ -1014,21 +1076,28 @@ };

if (!errorExists(message)) {
var messages = body["messages"];
var messages = body.messages;
if (messages && messages.length > 0) {
// handle missed messages
for (var i in messages.reverse()) {
this._messageResponse({body: messages[i]});
messages = messages.reverse();
for (var i in messages) {
if (messages.hasOwnProperty(i)) {
this._messageResponse({
body: messages[i]
});
}
}
} else {
if ("last" in body) {
if ('last' in body) {
// no missed messages found so set last message id from body.
this._lastMessageID[channel] = body["last"];
this._lastMessageID[channel] = body.last;
}
}
var recovered = false;
if ("recovered" in body) {
recovered = body["recovered"]
if ('recovered' in body) {
recovered = body.recovered;
}
sub._setSubscribeSuccess(recovered);
} else {
this.trigger('error', [{"message": message}]);
this.trigger('error', [{
message: message
}]);
sub._setSubscribeError(this._errorObjectFromMessage(message));

@@ -1051,3 +1120,3 @@ }

// unsubscribe command from server – unsubscribe all current subs
sub._setUnsubscribed(true);
sub._setUnsubscribed();
}

@@ -1057,3 +1126,5 @@ // ignore client initiated successful unsubscribe responses as we

} else {
this.trigger('error', [{"message": message}]);
this.trigger('error', [{
message: message
}]);
}

@@ -1071,3 +1142,3 @@ };

if (!errorExists(message)) {
var callback = callbacks["callback"];
var callback = callbacks.callback;
if (!callback) {

@@ -1078,3 +1149,3 @@ return;

} else {
var errback = callbacks["errback"];
var errback = callbacks.errback;
if (!errback) {

@@ -1084,3 +1155,5 @@ return;

errback(this._errorObjectFromMessage(message));
this.trigger('error', [{"message": message}]);
this.trigger('error', [{
message: message
}]);
}

@@ -1098,3 +1171,3 @@ };

if (!errorExists(message)) {
var callback = callbacks["callback"];
var callback = callbacks.callback;
if (!callback) {

@@ -1105,3 +1178,3 @@ return;

} else {
var errback = callbacks["errback"];
var errback = callbacks.errback;
if (!errback) {

@@ -1111,3 +1184,5 @@ return;

errback(this._errorObjectFromMessage(message));
this.trigger('error', [{"message": message}]);
this.trigger('error', [{
message: message
}]);
}

@@ -1125,3 +1200,3 @@ };

if (!errorExists(message)) {
var callback = callbacks["callback"];
var callback = callbacks.callback;
if (!callback) {

@@ -1132,3 +1207,3 @@ return;

} else {
var errback = callbacks["errback"];
var errback = callbacks.errback;
if (!errback) {

@@ -1138,7 +1213,9 @@ return;

errback(this._errorObjectFromMessage(message));
this.trigger('error', [{"message": message}]);
this.trigger('error', [{
message: message
}]);
}
};
centrifugeProto._joinResponse = function(message) {
centrifugeProto._joinResponse = function (message) {
var body = message.body;

@@ -1154,3 +1231,3 @@ var channel = body.channel;

centrifugeProto._leaveResponse = function(message) {
centrifugeProto._leaveResponse = function (message) {
var body = message.body;

@@ -1171,3 +1248,3 @@ var channel = body.channel;

// keep last uid received from channel.
this._lastMessageID[channel] = body["uid"];
this._lastMessageID[channel] = body.uid;

@@ -1201,9 +1278,11 @@ var sub = this._getSub(channel);

} else {
this.trigger('error', [{"message": message}]);
this.trigger('error', [{
message: message
}]);
}
};
centrifugeProto._dispatchMessage = function(message) {
centrifugeProto._dispatchMessage = function (message) {
if (message === undefined || message === null) {
this._debug("dispatch: got undefined or null message");
this._debug('dispatch: got undefined or null message');
return;

@@ -1215,3 +1294,3 @@ }

if (!method) {
this._debug("dispatch: got message with empty method");
this._debug('dispatch: got message with empty method');
return;

@@ -1257,3 +1336,3 @@ }

default:
this._debug("dispatch: got message with unknown method" + method);
this._debug('dispatch: got message with unknown method' + method);
break;

@@ -1268,4 +1347,3 @@ }

if (data.hasOwnProperty(i)) {
var msg = data[i];
this._dispatchMessage(msg);
this._dispatchMessage(data[i]);
}

@@ -1279,3 +1357,3 @@ }

centrifugeProto._flush = function() {
centrifugeProto._flush = function () {
var messages = this._messages.slice(0);

@@ -1287,29 +1365,28 @@ this._messages = [];

centrifugeProto._ping = function () {
var msg = {
"method": "ping"
};
this._addMessage(msg);
this._addMessage({
method: 'ping'
});
};
centrifugeProto._recover = function(channel) {
centrifugeProto._recover = function (channel) {
return channel in this._lastMessageID;
};
centrifugeProto._getLastID = function(channel) {
centrifugeProto._getLastID = function (channel) {
var lastUID = this._lastMessageID[channel];
if (lastUID) {
this._debug("last uid found and sent for channel", channel);
this._debug('last uid found and sent for channel', channel);
return lastUID;
} else {
this._debug("no last uid found for channel", channel);
return "";
this._debug('no last uid found for channel', channel);
return '';
}
};
centrifugeProto._createErrorObject = function(err, advice) {
centrifugeProto._createErrorObject = function (err, advice) {
var errObject = {
"error": err
error: err
};
if (advice) {
errObject["advice"] = advice;
errObject.advice = advice;
}

@@ -1319,18 +1396,16 @@ return errObject;

centrifugeProto._errorObjectFromMessage = function(message) {
var err = message.error;
var advice = message["advice"];
return this._createErrorObject(err, advice);
centrifugeProto._errorObjectFromMessage = function (message) {
return this._createErrorObject(message.error, message.advice);
};
centrifugeProto._registerCall = function(uid, callback, errback) {
centrifugeProto._registerCall = function (uid, callback, errback) {
var self = this;
this._callbacks[uid] = {
"callback": callback,
"errback": errback
callback: callback,
errback: errback
};
setTimeout(function() {
setTimeout(function () {
delete self._callbacks[uid];
if (isFunction(errback)) {
errback(self._createErrorObject("timeout", "retry"));
errback(self._createErrorObject('timeout', 'retry'));
}

@@ -1365,4 +1440,4 @@ }, this._config.timeout);

centrifugeProto.disconnect = function() {
this._disconnect("client", false);
centrifugeProto.disconnect = function () {
this._disconnect('client', false);
};

@@ -1378,3 +1453,3 @@

centrifugeProto.stopBatching = function(flush) {
centrifugeProto.stopBatching = function (flush) {
// stop collecting messages

@@ -1388,3 +1463,3 @@ flush = flush || false;

centrifugeProto.flush = function() {
centrifugeProto.flush = function () {
// send batched messages to Centrifuge

@@ -1394,3 +1469,3 @@ this._flush();

centrifugeProto.startAuthBatching = function() {
centrifugeProto.startAuthBatching = function () {
// start collecting private channels to create bulk authentication

@@ -1401,3 +1476,6 @@ // request to authEndpoint when stopAuthBatching will be called

centrifugeProto.stopAuthBatching = function() {
centrifugeProto.stopAuthBatching = function () {
var i,
channel;
// create request to authEndpoint with collected private channels

@@ -1410,11 +1488,13 @@ // to ask if this client can subscribe on each channel

for (var channel in authChannels) {
var sub = this._getSub(channel);
if (!sub) {
continue;
for (channel in authChannels) {
if (authChannels.hasOwnProperty(channel)) {
var sub = this._getSub(channel);
if (!sub) {
continue;
}
channels.push(channel);
}
channels.push(channel);
}
if (channels.length == 0) {
if (channels.length === 0) {
return;

@@ -1424,4 +1504,4 @@ }

var data = {
"client": this.getClientId(),
"channels": channels
client: this.getClientId(),
channels: channels
};

@@ -1431,14 +1511,16 @@

var cb = function(error, data) {
var cb = function (error, data) {
if (error === true) {
self._debug("authorization request failed");
for (var i in channels) {
var channel = channels[i];
self._subscribeResponse({
"error": "authorization request failed",
"advice": "fix",
"body": {
"channel": channel
}
});
self._debug('authorization request failed');
for (i in channels) {
if (channels.hasOwnProperty(i)) {
channel = channels[i];
self._subscribeResponse({
error: 'authorization request failed',
advice: 'fix',
body: {
channel: channel
}
});
}
}

@@ -1455,39 +1537,41 @@ return;

for (var i in channels) {
var channel = channels[i];
var channelResponse = data[channel];
if (!channelResponse) {
// subscription:error
self._subscribeResponse({
"error": "channel not found in authorization response",
"advice": "fix",
"body": {
"channel": channel
for (i in channels) {
if (channels.hasOwnProperty(i)) {
channel = channels[i];
var channelResponse = data[channel];
if (!channelResponse) {
// subscription:error
self._subscribeResponse({
error: 'channel not found in authorization response',
advice: 'fix',
body: {
channel: channel
}
});
continue;
}
if (!channelResponse.status || channelResponse.status === 200) {
var msg = {
method: 'subscribe',
params: {
channel: channel,
client: self.getClientId(),
info: channelResponse.info,
sign: channelResponse.sign
}
};
var recover = self._recover(channel);
if (recover === true) {
msg.params.recover = true;
msg.params.last = self._getLastID(channel);
}
});
continue;
}
if (!channelResponse.status || channelResponse.status === 200) {
var msg = {
"method": "subscribe",
"params": {
"channel": channel,
"client": self.getClientId(),
"info": channelResponse.info,
"sign": channelResponse.sign
}
};
var recover = self._recover(channel);
if (recover === true) {
msg["params"]["recover"] = true;
msg["params"]["last"] = self._getLastID(channel);
self._addMessage(msg);
} else {
self._subscribeResponse({
error: channelResponse.status,
body: {
channel: channel
}
});
}
self._addMessage(msg);
} else {
self._subscribeResponse({
"error": channelResponse.status,
"body": {
"channel": channel
}
});
}

@@ -1503,11 +1587,10 @@ }

if (this._config.onPrivateChannelAuth !== null) {
context = {
"data": data
};
this._config.onPrivateChannelAuth(context, cb);
this._config.onPrivateChannelAuth({
data: data
}, cb);
} else {
var transport = this._config.authTransport.toLowerCase();
if (transport === "ajax") {
if (transport === 'ajax') {
this._ajax(this._config.authEndpoint, this._config.authParams, this._config.authHeaders, data, cb);
} else if (transport === "jsonp") {
} else if (transport === 'jsonp') {
this._jsonp(this._config.authEndpoint, this._config.authParams, this._config.authHeaders, data, cb);

@@ -1571,11 +1654,11 @@ } else {

subProto._initializePromise = function() {
subProto._initializePromise = function () {
this._ready = false;
var self = this;
this._promise = new Promise(function(resolve, reject) {
self._resolve = function(value) {
this._promise = new Promise(function (resolve, reject) {
self._resolve = function (value) {
self._ready = true;
resolve(value);
};
self._reject = function(err) {
self._reject = function (err) {
self._ready = true;

@@ -1587,3 +1670,3 @@ reject(err);

subProto._setEvents = function(events) {
subProto._setEvents = function (events) {
if (!events) {

@@ -1593,9 +1676,6 @@ return;

if (isFunction(events)) {
this.on("message", events);
this.on('message', events);
} else if (Object.prototype.toString.call(events) === Object.prototype.toString.call({})) {
var knownEvents = [
"message", "join", "leave", "unsubscribe",
"subscribe", "error"
];
for (var i in knownEvents) {
var knownEvents = ['message', 'join', 'leave', 'unsubscribe', 'subscribe', 'error'];
for (var i = 0, l = knownEvents.length; i < l; i++) {
var ev = knownEvents[i];

@@ -1609,31 +1689,31 @@ if (ev in events) {

subProto._isNew = function() {
subProto._isNew = function () {
return this._status === _STATE_NEW;
};
subProto._isUnsubscribed = function() {
subProto._isUnsubscribed = function () {
return this._status === _STATE_UNSUBSCRIBED;
};
subProto._isSubscribing = function() {
subProto._isSubscribing = function () {
return this._status === _STATE_SUBSCRIBING;
};
subProto._isReady = function() {
subProto._isReady = function () {
return this._status === _STATE_SUCCESS || this._status === _STATE_ERROR;
};
subProto._isSuccess = function() {
subProto._isSuccess = function () {
return this._status === _STATE_SUCCESS;
};
subProto._isError = function() {
subProto._isError = function () {
return this._status === _STATE_ERROR;
};
subProto._setNew = function() {
subProto._setNew = function () {
this._status = _STATE_NEW;
};
subProto._setSubscribing = function() {
subProto._setSubscribing = function () {
if (this._ready === true) {

@@ -1647,4 +1727,4 @@ // new promise for this subscription

subProto._setSubscribeSuccess = function(recovered) {
if (this._status == _STATE_SUCCESS) {
subProto._setSubscribeSuccess = function (recovered) {
if (this._status === _STATE_SUCCESS) {
return;

@@ -1655,8 +1735,8 @@ }

var successContext = this._getSubscribeSuccessContext(recovered);
this.trigger("subscribe", [successContext]);
this.trigger('subscribe', [successContext]);
this._resolve(successContext);
};
subProto._setSubscribeError = function(err) {
if (this._status == _STATE_ERROR) {
subProto._setSubscribeError = function (err) {
if (this._status === _STATE_ERROR) {
return;

@@ -1667,15 +1747,14 @@ }

var errContext = this._getSubscribeErrorContext();
this.trigger("error", [errContext]);
this.trigger('error', [errContext]);
this._reject(errContext);
};
subProto._triggerUnsubscribe = function() {
var unsubscribeContext = {
"channel": this.channel
};
this.trigger("unsubscribe", [unsubscribeContext]);
subProto._triggerUnsubscribe = function () {
this.trigger('unsubscribe', [{
channel: this.channel
}]);
};
subProto._setUnsubscribed = function(noResubscribe) {
if (this._status == _STATE_UNSUBSCRIBED) {
subProto._setUnsubscribed = function (noResubscribe) {
if (this._status === _STATE_UNSUBSCRIBED) {
return;

@@ -1690,22 +1769,22 @@ }

subProto._shouldResubscribe = function() {
subProto._shouldResubscribe = function () {
return !this._noResubscribe;
}
};
subProto._getSubscribeSuccessContext = function() {
subProto._getSubscribeSuccessContext = function () {
return {
"channel": this.channel,
"isResubscribe": this._isResubscribe,
"recovered": this._recovered
channel: this.channel,
isResubscribe: this._isResubscribe,
recovered: this._recovered
};
};
subProto._getSubscribeErrorContext = function() {
subProto._getSubscribeErrorContext = function () {
var subscribeErrorContext = this._error;
subscribeErrorContext["channel"] = this.channel;
subscribeErrorContext["isResubscribe"] = this._isResubscribe;
subscribeErrorContext.channel = this.channel;
subscribeErrorContext.isResubscribe = this._isResubscribe;
return subscribeErrorContext;
};
subProto.ready = function(callback, errback) {
subProto.ready = function (callback, errback) {
if (this._ready) {

@@ -1720,4 +1799,4 @@ if (this._isSuccess()) {

subProto.subscribe = function() {
if (this._status == _STATE_SUCCESS) {
subProto.subscribe = function () {
if (this._status === _STATE_SUCCESS) {
return;

@@ -1736,22 +1815,21 @@ }

var self = this;
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
if (self._isUnsubscribed()) {
reject(self._centrifuge._createErrorObject("subscription unsubscribed", "fix"));
reject(self._centrifuge._createErrorObject('subscription unsubscribed', 'fix'));
return;
}
self._promise.then(function(){
self._promise.then(function () {
if (!self._centrifuge.isConnected()) {
reject(self._centrifuge._createErrorObject("disconnected", "retry"));
reject(self._centrifuge._createErrorObject('disconnected', 'retry'));
return;
}
var msg = {
"method": "publish",
"params": {
"channel": self.channel,
"data": data
var uid = self._centrifuge._addMessage({
method: 'publish',
params: {
channel: self.channel,
data: data
}
};
var uid = self._centrifuge._addMessage(msg);
});
self._centrifuge._registerCall(uid, resolve, reject);
}, function(err){
}, function (err) {
reject(err);

@@ -1762,23 +1840,22 @@ });

subProto.presence = function() {
subProto.presence = function () {
var self = this;
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
if (self._isUnsubscribed()) {
reject(self._centrifuge._createErrorObject("subscription unsubscribed", "fix"));
reject(self._centrifuge._createErrorObject('subscription unsubscribed', 'fix'));
return;
}
self._promise.then(function(){
self._promise.then(function () {
if (!self._centrifuge.isConnected()) {
reject(self._centrifuge._createErrorObject("disconnected", "retry"));
reject(self._centrifuge._createErrorObject('disconnected', 'retry'));
return;
}
var msg = {
"method": "presence",
"params": {
"channel": self.channel
var uid = self._centrifuge._addMessage({
method: 'presence',
params: {
channel: self.channel
}
};
var uid = self._centrifuge._addMessage(msg);
});
self._centrifuge._registerCall(uid, resolve, reject);
}, function(err){
}, function (err) {
reject(err);

@@ -1789,23 +1866,22 @@ });

subProto.history = function() {
subProto.history = function () {
var self = this;
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
if (self._isUnsubscribed()) {
reject(self._centrifuge._createErrorObject("subscription unsubscribed", "fix"));
reject(self._centrifuge._createErrorObject('subscription unsubscribed', 'fix'));
return;
}
self._promise.then(function(){
self._promise.then(function () {
if (!self._centrifuge.isConnected()) {
reject(self._centrifuge._createErrorObject("disconnected", "retry"));
reject(self._centrifuge._createErrorObject('disconnected', 'retry'));
return;
}
var msg = {
"method": "history",
"params": {
"channel": self.channel
var uid = self._centrifuge._addMessage({
method: 'history',
params: {
channel: self.channel
}
};
var uid = self._centrifuge._addMessage(msg);
});
self._centrifuge._registerCall(uid, resolve, reject);
}, function(err){
}, function (err) {
reject(err);

@@ -1812,0 +1888,0 @@ });

Sorry, the diff of this file is not supported yet

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc