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

getstream

Package Overview
Dependencies
Maintainers
1
Versions
182
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

getstream - npm Package Compare versions

Comparing version 1.0.7 to 1.0.9

cov.html

2

bower.json
{
"name": "getstream",
"version": "1.0.7",
"version": "1.0.9",
"main": "dist/js/getstream.js",

@@ -5,0 +5,0 @@ "ignore": [

!function(e){if("object"==typeof exports)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.stream=e()}}(function(){var define,module,exports;return function e(t,n,i){function r(o,a){if(!n[o]){if(!t[o]){var c="function"==typeof require&&require;if(!a&&c)return c(o,!0);if(s)return s(o,!0);throw new Error("Cannot find module '"+o+"'")}var u=n[o]={exports:{}};t[o][0].call(u.exports,function(e){var n=t[o][1][e];return r(n?n:e)},u,u.exports,e,t,n,i)}return n[o].exports}for(var s="function"==typeof require&&require,o=0;o<i.length;o++)r(i[o]);return r}({1:[function(e,t){function n(e,t){if("function"!=typeof t)throw new Error("Bad callback given: "+t);if(!e)throw new Error("No options given");var o=e.onResponse;if(e="string"==typeof e?{uri:e}:JSON.parse(JSON.stringify(e)),e.onResponse=o,e.verbose&&(n.log=s()),e.url&&(e.uri=e.url,delete e.url),!e.uri&&""!==e.uri)throw new Error("options.uri is a required argument");if("string"!=typeof e.uri)throw new Error("options.uri must be a string");for(var a=["proxy","_redirectsFollowed","maxRedirects","followRedirect"],u=0;u<a.length;u++)if(e[a[u]])throw new Error("options."+a[u]+" is not supported");if(e.callback=t,e.method=e.method||"GET",e.headers=e.headers||{},e.body=e.body||null,e.timeout=e.timeout||n.DEFAULT_TIMEOUT,e.headers.host)throw new Error("Options.headers.host is not supported");e.json&&(e.headers.accept=e.headers.accept||"application/json","GET"!==e.method&&(e.headers["content-type"]="application/json"),"boolean"!=typeof e.json?e.body=JSON.stringify(e.json):"string"!=typeof e.body&&(e.body=JSON.stringify(e.body)));var h=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t.join("&")};if(e.qs){var l="string"==typeof e.qs?e.qs:h(e.qs);e.uri=-1!==e.uri.indexOf("?")?e.uri+"&"+l:e.uri+"?"+l}var f=function(e){var t={};t.boundry="-------------------------------"+Math.floor(1e9*Math.random());var n=[];for(var i in e)e.hasOwnProperty(i)&&n.push("--"+t.boundry+'\nContent-Disposition: form-data; name="'+i+'"\n\n'+e[i]+"\n");return n.push("--"+t.boundry+"--"),t.body=n.join(""),t.length=t.body.length,t.type="multipart/form-data; boundary="+t.boundry,t};if(e.form){if("string"==typeof e.form)throw"form name unsupported";if("POST"===e.method){var d=(e.encoding||"application/x-www-form-urlencoded").toLowerCase();switch(e.headers["content-type"]=d,d){case"application/x-www-form-urlencoded":e.body=h(e.form).replace(/%20/g,"+");break;case"multipart/form-data":var p=f(e.form);e.body=p.body,e.headers["content-type"]=p.type;break;default:throw new Error("unsupported encoding:"+d)}}}return e.onResponse=e.onResponse||r,e.onResponse===!0&&(e.onResponse=t,e.callback=r),!e.headers.authorization&&e.auth&&(e.headers.authorization="Basic "+c(e.auth.username+":"+e.auth.password)),i(e)}function i(e){function t(){h=!0;var t=new Error("ETIMEDOUT");return t.code="ETIMEDOUT",t.duration=e.timeout,n.log.error("Timeout",{id:c._id,milliseconds:e.timeout}),e.callback(t,c)}function i(){if(h)return n.log.debug("Ignoring timed out state change",{state:c.readyState,id:c.id});if(n.log.debug("State change",{state:c.readyState,id:c.id,timed_out:h}),c.readyState===u.OPENED){n.log.debug("Request started",{id:c.id});for(var t in e.headers)c.setRequestHeader(t,e.headers[t])}else c.readyState===u.HEADERS_RECEIVED?r():c.readyState===u.LOADING?(r(),s()):c.readyState===u.DONE&&(r(),s(),o())}function r(){if(!y.response){if(y.response=!0,n.log.debug("Got response",{id:c.id,status:c.status}),clearTimeout(c.timeoutTimer),c.statusCode=c.status,f&&0==c.statusCode){var t=new Error("CORS request rejected: "+e.uri);return t.cors="rejected",y.loading=!0,y.end=!0,e.callback(t,c)}e.onResponse(null,c)}}function s(){y.loading||(y.loading=!0,n.log.debug("Response body loading",{id:c.id}))}function o(){if(!y.end){if(y.end=!0,n.log.debug("Request done",{id:c.id}),c.body=c.responseText,e.json)try{c.body=JSON.parse(c.responseText)}catch(t){return e.callback(t,c)}e.callback(null,c,c.body)}}var c=new u,h=!1,f=a(e.uri),d="withCredentials"in c;if(l+=1,c.seq_id=l,c.id=l+": "+e.method+" "+e.uri,c._id=c.id,f&&!d){var p=new Error("Browser does not support cross-origin request: "+e.uri);return p.cors="unsupported",e.callback(p,c)}c.timeoutTimer=setTimeout(t,e.timeout);var y={response:!1,loading:!1,end:!1};return c.onreadystatechange=i,c.open(e.method,e.uri,!0),f&&(c.withCredentials=!!e.withCredentials),c.send(e.body),c}function r(){}function s(){var e,t,n={},i=["trace","debug","info","warn","error"];for(t=0;t<i.length;t++)e=i[t],n[e]=r,"undefined"!=typeof console&&console&&console[e]&&(n[e]=o(console,e));return n}function o(e,t){function n(n,i){return"object"==typeof i&&(n+=" "+JSON.stringify(i)),e[t].call(e,n)}return n}function a(e){var t,n=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/;try{t=location.href}catch(i){t=document.createElement("a"),t.href="",t=t.href}var r=n.exec(t.toLowerCase())||[],s=n.exec(e.toLowerCase()),o=!(!s||s[1]==r[1]&&s[2]==r[2]&&(s[3]||("http:"===s[1]?80:443))==(r[3]||("http:"===r[1]?80:443)));return o}function c(e){var t,n,i,r,s,o,a,c,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h=0,l=0,f="",d=[];if(!e)return e;do t=e.charCodeAt(h++),n=e.charCodeAt(h++),i=e.charCodeAt(h++),c=t<<16|n<<8|i,r=c>>18&63,s=c>>12&63,o=c>>6&63,a=63&c,d[l++]=u.charAt(r)+u.charAt(s)+u.charAt(o)+u.charAt(a);while(h<e.length);switch(f=d.join(""),e.length%3){case 1:f=f.slice(0,-2)+"==";break;case 2:f=f.slice(0,-1)+"="}return f}var u=XMLHttpRequest;if(!u)throw new Error("missing XMLHttpRequest");n.log={trace:r,debug:r,info:r,warn:r,error:r};var h=18e4,l=0;n.withCredentials=!1,n.DEFAULT_TIMEOUT=h,n.defaults=function(e){var t=function(t){var n=function(n,i){n="string"==typeof n?{uri:n}:JSON.parse(JSON.stringify(n));for(var r in e)void 0===n[r]&&(n[r]=e[r]);return t(n,i)};return n},i=t(n);return i.get=t(n.get),i.post=t(n.post),i.put=t(n.put),i.head=t(n.head),i};var f=["get","put","post","head"];f.forEach(function(e){var t=e.toUpperCase(),i=e.toLowerCase();n[i]=function(e){"string"==typeof e?e={method:t,uri:e}:(e=JSON.parse(JSON.stringify(e)),e.method=t);var i=[e].concat(Array.prototype.slice.apply(arguments,[1]));return n.apply(this,i)}}),n.couch=function(e,t){function i(e,n,i){if(e)return t(e,n,i);if((n.statusCode<200||n.statusCode>299)&&i.error){e=new Error("CouchDB error: "+(i.error.reason||i.error.error));for(var r in i)e[r]=i[r];return t(e,n,i)}return t(e,n,i)}"string"==typeof e&&(e={uri:e}),e.json=!0,e.body&&(e.json=e.body),delete e.body,t=t||r;var s=n(e,i);return s},t.exports=n},{}],2:[function(_dereq_,module,exports){(function(process,global){!function(){"use strict";var Faye={VERSION:"1.0.1",BAYEUX_VERSION:"1.0",ID_LENGTH:160,JSONP_CALLBACK:"jsonpcallback",CONNECTION_TYPES:["long-polling","cross-origin-long-polling","callback-polling","websocket","eventsource","in-process"],MANDATORY_CONNECTION_TYPES:["long-polling","callback-polling","in-process"],ENV:"undefined"!=typeof window?window:global,extend:function(e,t,n){if(!t)return e;for(var i in t)t.hasOwnProperty(i)&&(e.hasOwnProperty(i)&&n===!1||e[i]!==t[i]&&(e[i]=t[i]));return e},random:function(e){return e=e||this.ID_LENGTH,csprng(e,36)},clientIdFromMessages:function(e){var t=this.filter([].concat(e),function(e){return"/meta/connect"===e.channel});return t[0]&&t[0].clientId},copyObject:function(e){var t,n,i;if(e instanceof Array){for(t=[],n=e.length;n--;)t[n]=Faye.copyObject(e[n]);return t}if("object"==typeof e){t=null===e?null:{};for(i in e)t[i]=Faye.copyObject(e[i]);return t}return e},commonElement:function(e,t){for(var n=0,i=e.length;i>n;n++)if(-1!==this.indexOf(t,e[n]))return e[n];return null},indexOf:function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,i=e.length;i>n;n++)if(e[n]===t)return n;return-1},map:function(e,t,n){if(e.map)return e.map(t,n);var i=[];if(e instanceof Array)for(var r=0,s=e.length;s>r;r++)i.push(t.call(n||null,e[r],r));else for(var o in e)e.hasOwnProperty(o)&&i.push(t.call(n||null,o,e[o]));return i},filter:function(e,t,n){if(e.filter)return e.filter(t,n);for(var i=[],r=0,s=e.length;s>r;r++)t.call(n||null,e[r],r)&&i.push(e[r]);return i},asyncEach:function(e,t,n,i){var r=e.length,s=-1,o=0,a=!1,c=function(){return o-=1,s+=1,s===r?n&&n.call(i):void t(e[s],h)},u=function(){if(!a){for(a=!0;o>0;)c();a=!1}},h=function(){o+=1,u()};h()},toJSON:function(e){return this.stringify?this.stringify(e,function(e,t){return this[e]instanceof Array?this[e]:t}):JSON.stringify(e)}};"undefined"!=typeof module?module.exports=Faye:"undefined"!=typeof window&&(window.Faye=Faye),Faye.Class=function(e,t){"function"!=typeof e&&(t=e,e=Object);var n=function(){return this.initialize?this.initialize.apply(this,arguments)||this:this},i=function(){};return i.prototype=e.prototype,n.prototype=new i,Faye.extend(n.prototype,t),n},function(){function e(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;n++)if(t===e[n])return n;return-1}var t=Faye.EventEmitter=function(){},n="function"==typeof Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};t.prototype.emit=function(e){if("error"===e&&(!this._events||!this._events.error||n(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var t=this._events[e];if(!t)return!1;if("function"==typeof t){switch(arguments.length){case 1:t.call(this);break;case 2:t.call(this,arguments[1]);break;case 3:t.call(this,arguments[1],arguments[2]);break;default:var i=Array.prototype.slice.call(arguments,1);t.apply(this,i)}return!0}if(n(t)){for(var i=Array.prototype.slice.call(arguments,1),r=t.slice(),s=0,o=r.length;o>s;s++)r[s].apply(this,i);return!0}return!1},t.prototype.addListener=function(e,t){if("function"!=typeof t)throw new Error("addListener only takes instances of Function");return this._events||(this._events={}),this.emit("newListener",e,t),this._events[e]?n(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,this},t.prototype.on=t.prototype.addListener,t.prototype.once=function(e,t){var n=this;return n.on(e,function i(){n.removeListener(e,i),t.apply(this,arguments)}),this},t.prototype.removeListener=function(t,i){if("function"!=typeof i)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[t])return this;var r=this._events[t];if(n(r)){var s=e(r,i);if(0>s)return this;r.splice(s,1),0==r.length&&delete this._events[t]}else this._events[t]===i&&delete this._events[t];return this},t.prototype.removeAllListeners=function(e){return 0===arguments.length?(this._events={},this):(e&&this._events&&this._events[e]&&(this._events[e]=null),this)},t.prototype.listeners=function(e){return this._events||(this._events={}),this._events[e]||(this._events[e]=[]),n(this._events[e])||(this._events[e]=[this._events[e]]),this._events[e]}}(),Faye.Namespace=Faye.Class({initialize:function(){this._used={}},exists:function(e){return this._used.hasOwnProperty(e)},generate:function(){for(var e=Faye.random();this._used.hasOwnProperty(e);)e=Faye.random();return this._used[e]=e},release:function(e){delete this._used[e]}}),function(){var e,t=setTimeout;e="function"==typeof setImmediate?function(e){setImmediate(e)}:"object"==typeof process&&process.nextTick?function(e){process.nextTick(e)}:function(e){t(e,0)};var n=0,i=1,r=2,s=function(e){return e},o=function(e){throw e},a=function(e){if(this._state=n,this._callbacks=[],this._errbacks=[],"function"==typeof e){var t=this;e(function(e){f(t,e)},function(e){d(t,e)})}};a.prototype.then=function(e,t){var n={},i=this;return n.promise=new a(function(r,s){n.fulfill=r,n.reject=s,c(i,e,n),u(i,t,n)}),n.promise};var c=function(e,t,r){"function"!=typeof t&&(t=s);var o=function(e){h(t,e,r)};e._state===n?e._callbacks.push(o):e._state===i&&o(e._value)},u=function(e,t,i){"function"!=typeof t&&(t=o);var s=function(e){h(t,e,i)};e._state===n?e._errbacks.push(s):e._state===r&&s(e._reason)},h=function(t,n,i){e(function(){l(t,n,i)})},l=function(e,t,n){var i,r,o,a=!1;try{if(i=e(t),r=typeof i,o=null!==i&&("function"===r||"object"===r)&&i.then,i===n.promise)return n.reject(new TypeError("Recursive promise chain detected"));if("function"!=typeof o)return n.fulfill(i);o.call(i,function(e){a||(a=!0,l(s,e,n))},function(e){a||(a=!0,n.reject(e))})}catch(c){if(a)return;a=!0,n.reject(c)}},f=a.fulfill=a.resolve=function(e,t){if(e._state===n){e._state=i,e._value=t,e._errbacks=[];for(var r,s=e._callbacks;r=s.shift();)r(t)}},d=a.reject=function(e,t){if(e._state===n){e._state=r,e._reason=t,e._callbacks=[];for(var i,s=e._errbacks;i=s.shift();)i(t)}};a.defer=e,a.deferred=a.pending=function(){var e={};return e.promise=new a(function(t,n){e.fulfill=e.resolve=t,e.reject=n}),e},a.fulfilled=a.resolved=function(e){return new a(function(t){t(e)})},a.rejected=function(e){return new a(function(t,n){n(e)})},"undefined"==typeof Faye?module.exports=a:Faye.Promise=a}(),Faye.Set=Faye.Class({initialize:function(){this._index={}},add:function(e){var t=void 0!==e.id?e.id:e;return this._index.hasOwnProperty(t)?!1:(this._index[t]=e,!0)},forEach:function(e,t){for(var n in this._index)this._index.hasOwnProperty(n)&&e.call(t,this._index[n])},isEmpty:function(){for(var e in this._index)if(this._index.hasOwnProperty(e))return!1;return!0},member:function(e){for(var t in this._index)if(this._index[t]===e)return!0;return!1},remove:function(e){var t=void 0!==e.id?e.id:e,n=this._index[t];return delete this._index[t],n},toArray:function(){var e=[];return this.forEach(function(t){e.push(t)}),e}}),Faye.URI={isURI:function(e){return e&&e.protocol&&e.host&&e.path},isSameOrigin:function(e){var t=Faye.ENV.location;return e.protocol===t.protocol&&e.hostname===t.hostname&&e.port===t.port},parse:function(e){if("string"!=typeof e)return e;var t,n,i,r,s,o,a={},c=function(t,n){e=e.replace(n,function(e){return a[t]=e,""}),a[t]=a[t]||""};for(c("protocol",/^[a-z]+\:/i),c("host",/^\/\/[^\/\?#]+/),/^\//.test(e)||a.host||(e=Faye.ENV.location.pathname.replace(/[^\/]*$/,"")+e),c("pathname",/^[^\?#]*/),c("search",/^\?[^#]*/),c("hash",/^#.*/),a.protocol=a.protocol||Faye.ENV.location.protocol,a.host?(a.host=a.host.substr(2),t=a.host.split(":"),a.hostname=t[0],a.port=t[1]||""):(a.host=Faye.ENV.location.host,a.hostname=Faye.ENV.location.hostname,a.port=Faye.ENV.location.port),a.pathname=a.pathname||"/",a.path=a.pathname+a.search,n=a.search.replace(/^\?/,""),i=n?n.split("&"):[],o={},r=0,s=i.length;s>r;r++)t=i[r].split("="),o[decodeURIComponent(t[0]||"")]=decodeURIComponent(t[1]||"");return a.query=o,a.href=this.stringify(a),a},stringify:function(e){var t=e.protocol+"//"+e.hostname;return e.port&&(t+=":"+e.port),t+=e.pathname+this.queryString(e.query)+(e.hash||"")},queryString:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return 0===t.length?"":"?"+t.join("&")}},Faye.Error=Faye.Class({initialize:function(e,t,n){this.code=e,this.params=Array.prototype.slice.call(t),this.message=n},toString:function(){return this.code+":"+this.params.join(",")+":"+this.message}}),Faye.Error.parse=function(e){if(e=e||"",!Faye.Grammar.ERROR.test(e))return new this(null,[],e);var t=e.split(":"),n=parseInt(t[0]),i=t[1].split(","),e=t[2];return new this(n,i,e)},Faye.Error.versionMismatch=function(){return new this(300,arguments,"Version mismatch").toString()},Faye.Error.conntypeMismatch=function(){return new this(301,arguments,"Connection types not supported").toString()},Faye.Error.extMismatch=function(){return new this(302,arguments,"Extension mismatch").toString()},Faye.Error.badRequest=function(){return new this(400,arguments,"Bad request").toString()},Faye.Error.clientUnknown=function(){return new this(401,arguments,"Unknown client").toString()},Faye.Error.parameterMissing=function(){return new this(402,arguments,"Missing required parameter").toString()},Faye.Error.channelForbidden=function(){return new this(403,arguments,"Forbidden channel").toString()},Faye.Error.channelUnknown=function(){return new this(404,arguments,"Unknown channel").toString()},Faye.Error.channelInvalid=function(){return new this(405,arguments,"Invalid channel").toString()},Faye.Error.extUnknown=function(){return new this(406,arguments,"Unknown extension").toString()},Faye.Error.publishFailed=function(){return new this(407,arguments,"Failed to publish").toString()},Faye.Error.serverError=function(){return new this(500,arguments,"Internal server error").toString()},Faye.Deferrable={then:function(e,t){var n=this;return this._promise||(this._promise=new Faye.Promise(function(e,t){n._fulfill=e,n._reject=t})),0===arguments.length?this._promise:this._promise.then(e,t)},callback:function(e,t){return this.then(function(n){e.call(t,n)})},errback:function(e,t){return this.then(null,function(n){e.call(t,n)})},timeout:function(e,t){this.then();var n=this;this._timer=Faye.ENV.setTimeout(function(){n._reject(t)},1e3*e)},setDeferredStatus:function(e,t){this._timer&&Faye.ENV.clearTimeout(this._timer);this.then();"succeeded"===e?this._fulfill(t):"failed"===e?this._reject(t):delete this._promise}},Faye.Publisher={countListeners:function(e){return this.listeners(e).length},bind:function(e,t,n){var i=Array.prototype.slice,r=function(){t.apply(n,i.call(arguments))};return this._listeners=this._listeners||[],this._listeners.push([e,t,n,r]),this.on(e,r)},unbind:function(e,t,n){this._listeners=this._listeners||[];for(var i,r=this._listeners.length;r--;)i=this._listeners[r],i[0]===e&&(!t||i[1]===t&&i[2]===n)&&(this._listeners.splice(r,1),this.removeListener(e,i[3]))}},Faye.extend(Faye.Publisher,Faye.EventEmitter.prototype),Faye.Publisher.trigger=Faye.Publisher.emit,Faye.Timeouts={addTimeout:function(e,t,n,i){if(this._timeouts=this._timeouts||{},!this._timeouts.hasOwnProperty(e)){var r=this;this._timeouts[e]=Faye.ENV.setTimeout(function(){delete r._timeouts[e],n.call(i)},1e3*t)}},removeTimeout:function(e){this._timeouts=this._timeouts||{};var t=this._timeouts[e];t&&(clearTimeout(t),delete this._timeouts[e])},removeAllTimeouts:function(){this._timeouts=this._timeouts||{};for(var e in this._timeouts)this.removeTimeout(e)}},Faye.Logging={LOG_LEVELS:{fatal:4,error:3,warn:2,info:1,debug:0},writeLog:function(e,t){if(Faye.logger){var e=Array.prototype.slice.apply(e),n="[Faye",i=this.className,r=e.shift().replace(/\?/g,function(){try{return Faye.toJSON(e.shift())}catch(t){return"[Object]"}});for(var s in Faye)i||"function"==typeof Faye[s]&&this instanceof Faye[s]&&(i=s);i&&(n+="."+i),n+="] ","function"==typeof Faye.logger[t]?Faye.logger[t](n+r):"function"==typeof Faye.logger&&Faye.logger(n+r)}}},function(){for(var e in Faye.Logging.LOG_LEVELS)(function(e){Faye.Logging[e]=function(){this.writeLog(arguments,e)}})(e,Faye.Logging.LOG_LEVELS[e])}(),Faye.Grammar={CHANNEL_NAME:/^\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$/,CHANNEL_PATTERN:/^(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*\/\*{1,2}$/,ERROR:/^([0-9][0-9][0-9]:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*(,(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)*:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*|[0-9][0-9][0-9]::(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)$/,VERSION:/^([0-9])+(\.(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*)*$/},Faye.Extensible={addExtension:function(e){this._extensions=this._extensions||[],this._extensions.push(e),e.added&&e.added(this)},removeExtension:function(e){if(this._extensions)for(var t=this._extensions.length;t--;)this._extensions[t]===e&&(this._extensions.splice(t,1),e.removed&&e.removed(this))},pipeThroughExtensions:function(e,t,n,i,r){if(this.debug("Passing through ? extensions: ?",e,t),!this._extensions)return i.call(r,t);var s=this._extensions.slice(),o=function(t){if(!t)return i.call(r,t);var a=s.shift();if(!a)return i.call(r,t);var c=a[e];return c?void(c.length>=3?a[e](t,n,o):a[e](t,o)):o(t)};o(t)}},Faye.extend(Faye.Extensible,Faye.Logging),Faye.Channel=Faye.Class({initialize:function(e){this.id=this.name=e},push:function(e){this.trigger("message",e)},isUnused:function(){return 0===this.countListeners("message")}}),Faye.extend(Faye.Channel.prototype,Faye.Publisher),Faye.extend(Faye.Channel,{HANDSHAKE:"/meta/handshake",CONNECT:"/meta/connect",SUBSCRIBE:"/meta/subscribe",UNSUBSCRIBE:"/meta/unsubscribe",DISCONNECT:"/meta/disconnect",META:"meta",SERVICE:"service",expand:function(e){var t=this.parse(e),n=["/**",e],i=t.slice();i[i.length-1]="*",n.push(this.unparse(i));for(var r=1,s=t.length;s>r;r++)i=t.slice(0,r),i.push("**"),n.push(this.unparse(i));return n},isValid:function(e){return Faye.Grammar.CHANNEL_NAME.test(e)||Faye.Grammar.CHANNEL_PATTERN.test(e)},parse:function(e){return this.isValid(e)?e.split("/").slice(1):null},unparse:function(e){return"/"+e.join("/")},isMeta:function(e){var t=this.parse(e);return t?t[0]===this.META:null},isService:function(e){var t=this.parse(e);return t?t[0]===this.SERVICE:null},isSubscribable:function(e){return this.isValid(e)?!this.isMeta(e)&&!this.isService(e):null},Set:Faye.Class({initialize:function(){this._channels={}},getKeys:function(){var e=[];for(var t in this._channels)e.push(t);return e},remove:function(e){delete this._channels[e]},hasSubscription:function(e){return this._channels.hasOwnProperty(e)},subscribe:function(e,t,n){if(t)for(var i,r=0,s=e.length;s>r;r++){i=e[r];var o=this._channels[i]=this._channels[i]||new Faye.Channel(i);o.bind("message",t,n)}},unsubscribe:function(e,t,n){var i=this._channels[e];return i?(i.unbind("message",t,n),i.isUnused()?(this.remove(e),!0):!1):!1},distributeMessage:function(e){for(var t=Faye.Channel.expand(e.channel),n=0,i=t.length;i>n;n++){var r=this._channels[t[n]];r&&r.trigger("message",e.data)}}})}),Faye.Envelope=Faye.Class({initialize:function(e,t){this.id=e.id,this.message=e,void 0!==t&&this.timeout(t/1e3,!1)}}),Faye.extend(Faye.Envelope.prototype,Faye.Deferrable),Faye.Publication=Faye.Class(Faye.Deferrable),Faye.Subscription=Faye.Class({initialize:function(e,t,n,i){this._client=e,this._channels=t,this._callback=n,this._context=i,this._cancelled=!1},cancel:function(){this._cancelled||(this._client.unsubscribe(this._channels,this._callback,this._context),this._cancelled=!0)},unsubscribe:function(){this.cancel()}}),Faye.extend(Faye.Subscription.prototype,Faye.Deferrable),Faye.Client=Faye.Class({UNCONNECTED:1,CONNECTING:2,CONNECTED:3,DISCONNECTED:4,HANDSHAKE:"handshake",RETRY:"retry",NONE:"none",CONNECTION_TIMEOUT:60,DEFAULT_RETRY:5,MAX_REQUEST_SIZE:2048,DEFAULT_ENDPOINT:"/bayeux",INTERVAL:0,initialize:function(e,t){this.info("New client created for ?",e),this._options=t||{},this.endpoint=Faye.URI.parse(e||this.DEFAULT_ENDPOINT),this.endpoints=this._options.endpoints||{},this.transports={},this.cookies=Faye.CookieJar&&new Faye.CookieJar,this.headers={},this.ca=this._options.ca,this._disabled=[],this._retry=this._options.retry||this.DEFAULT_RETRY;for(var n in this.endpoints)this.endpoints[n]=Faye.URI.parse(this.endpoints[n]);this.maxRequestSize=this.MAX_REQUEST_SIZE,this._state=this.UNCONNECTED,this._channels=new Faye.Channel.Set,this._messageId=0,this._responseCallbacks={},this._advice={reconnect:this.RETRY,interval:1e3*(this._options.interval||this.INTERVAL),timeout:1e3*(this._options.timeout||this.CONNECTION_TIMEOUT)},Faye.Event&&void 0!==Faye.ENV.onbeforeunload&&Faye.Event.on(Faye.ENV,"beforeunload",function(){Faye.indexOf(this._disabled,"autodisconnect")<0&&this.disconnect()},this)},disable:function(e){this._disabled.push(e)},setHeader:function(e,t){this.headers[e]=t},handshake:function(e,t){if(this._advice.reconnect!==this.NONE&&this._state===this.UNCONNECTED){this._state=this.CONNECTING;var n=this;this.info("Initiating handshake with ?",Faye.URI.stringify(this.endpoint)),this._selectTransport(Faye.MANDATORY_CONNECTION_TYPES),this._send({channel:Faye.Channel.HANDSHAKE,version:Faye.BAYEUX_VERSION,supportedConnectionTypes:[this._transport.connectionType]},function(i){i.successful?(this._state=this.CONNECTED,this._clientId=i.clientId,this._selectTransport(i.supportedConnectionTypes),this.info("Handshake successful: ?",this._clientId),this.subscribe(this._channels.getKeys(),!0),e&&Faye.Promise.defer(function(){e.call(t)})):(this.info("Handshake unsuccessful"),Faye.ENV.setTimeout(function(){n.handshake(e,t)},this._advice.interval),this._state=this.UNCONNECTED)},this)}},connect:function(e,t){if(this._advice.reconnect!==this.NONE&&this._state!==this.DISCONNECTED){if(this._state===this.UNCONNECTED)return this.handshake(function(){this.connect(e,t)},this);this.callback(e,t),this._state===this.CONNECTED&&(this.info("Calling deferred actions for ?",this._clientId),this.setDeferredStatus("succeeded"),this.setDeferredStatus("unknown"),this._connectRequest||(this._connectRequest=!0,this.info("Initiating connection for ?",this._clientId),this._send({channel:Faye.Channel.CONNECT,clientId:this._clientId,connectionType:this._transport.connectionType},this._cycleConnection,this)))}},disconnect:function(){this._state===this.CONNECTED&&(this._state=this.DISCONNECTED,this.info("Disconnecting ?",this._clientId),this._send({channel:Faye.Channel.DISCONNECT,clientId:this._clientId},function(e){e.successful&&(this._transport.close(),delete this._transport)},this),this.info("Clearing channel listeners for ?",this._clientId),this._channels=new Faye.Channel.Set)},subscribe:function(e,t,n){if(e instanceof Array)return Faye.map(e,function(e){return this.subscribe(e,t,n)},this);var i=new Faye.Subscription(this,e,t,n),r=t===!0,s=this._channels.hasSubscription(e);return s&&!r?(this._channels.subscribe([e],t,n),i.setDeferredStatus("succeeded"),i):(this.connect(function(){this.info("Client ? attempting to subscribe to ?",this._clientId,e),r||this._channels.subscribe([e],t,n),this._send({channel:Faye.Channel.SUBSCRIBE,clientId:this._clientId,subscription:e},function(r){if(!r.successful)return i.setDeferredStatus("failed",Faye.Error.parse(r.error)),this._channels.unsubscribe(e,t,n);var s=[].concat(r.subscription);this.info("Subscription acknowledged for ? to ?",this._clientId,s),i.setDeferredStatus("succeeded")},this)},this),i)},unsubscribe:function(e,t,n){if(e instanceof Array)return Faye.map(e,function(e){return this.unsubscribe(e,t,n)},this);var i=this._channels.unsubscribe(e,t,n);i&&this.connect(function(){this.info("Client ? attempting to unsubscribe from ?",this._clientId,e),this._send({channel:Faye.Channel.UNSUBSCRIBE,clientId:this._clientId,subscription:e},function(e){if(e.successful){var t=[].concat(e.subscription);this.info("Unsubscription acknowledged for ? from ?",this._clientId,t)}},this)},this)},publish:function(e,t){var n=new Faye.Publication;return this.connect(function(){this.info("Client ? queueing published message to ?: ?",this._clientId,e,t),this._send({channel:e,data:t,clientId:this._clientId},function(e){e.successful?n.setDeferredStatus("succeeded"):n.setDeferredStatus("failed",Faye.Error.parse(e.error))},this)},this),n},receiveMessage:function(e){var t,n=e.id;void 0!==e.successful&&(t=this._responseCallbacks[n],delete this._responseCallbacks[n]),this.pipeThroughExtensions("incoming",e,null,function(e){e&&(e.advice&&this._handleAdvice(e.advice),this._deliverMessage(e),t&&t[0].call(t[1],e))},this),this._transportUp!==!0&&(this._transportUp=!0,this.trigger("transport:up"))},messageError:function(e,t){for(var n,i,r=this._retry,s=this,o=0,a=e.length;a>o;o++)i=e[o],n=i.id,t?this._transportSend(i):Faye.ENV.setTimeout(function(){s._transportSend(i)},1e3*r);t||this._transportUp===!1||(this._transportUp=!1,this.trigger("transport:down"))},_selectTransport:function(e){Faye.Transport.get(this,e,this._disabled,function(e){this.debug("Selected ? transport for ?",e.connectionType,Faye.URI.stringify(e.endpoint)),e!==this._transport&&(this._transport&&this._transport.close(),this._transport=e)},this)},_send:function(e,t,n){this._transport&&(e.id=e.id||this._generateMessageId(),this.pipeThroughExtensions("outgoing",e,null,function(e){e&&(t&&(this._responseCallbacks[e.id]=[t,n]),this._transportSend(e))},this))},_transportSend:function(e){if(this._transport){var t=1.2*(this._advice.timeout||1e3*this._retry),n=new Faye.Envelope(e,t);n.errback(function(t){this.messageError([e],t)},this),this._transport.send(n)}},_generateMessageId:function(){return this._messageId+=1,this._messageId>=Math.pow(2,32)&&(this._messageId=0),this._messageId.toString(36)},_handleAdvice:function(e){Faye.extend(this._advice,e),this._advice.reconnect===this.HANDSHAKE&&this._state!==this.DISCONNECTED&&(this._state=this.UNCONNECTED,this._clientId=null,this._cycleConnection())},_deliverMessage:function(e){e.channel&&void 0!==e.data&&(this.info("Client ? calling listeners for ? with ?",this._clientId,e.channel,e.data),this._channels.distributeMessage(e))},_cycleConnection:function(){this._connectRequest&&(this._connectRequest=null,this.info("Closed connection for ?",this._clientId));var e=this;Faye.ENV.setTimeout(function(){e.connect()},this._advice.interval)}}),Faye.extend(Faye.Client.prototype,Faye.Deferrable),Faye.extend(Faye.Client.prototype,Faye.Publisher),Faye.extend(Faye.Client.prototype,Faye.Logging),Faye.extend(Faye.Client.prototype,Faye.Extensible),Faye.Transport=Faye.extend(Faye.Class({MAX_DELAY:0,batching:!0,initialize:function(e,t){this._client=e,this.endpoint=t,this._outbox=[]},close:function(){},encode:function(){return""},send:function(e){var t=e.message;return this.debug("Client ? sending message to ?: ?",this._client._clientId,Faye.URI.stringify(this.endpoint),t),this.batching?(this._outbox.push(e),t.channel===Faye.Channel.HANDSHAKE?this.addTimeout("publish",.01,this.flush,this):(t.channel===Faye.Channel.CONNECT&&(this._connectMessage=t),this.flushLargeBatch(),void this.addTimeout("publish",this.MAX_DELAY,this.flush,this))):this.request([e])},flush:function(){this.removeTimeout("publish"),this._outbox.length>1&&this._connectMessage&&(this._connectMessage.advice={timeout:0}),this.request(this._outbox),this._connectMessage=null,this._outbox=[]},flushLargeBatch:function(){var e=this.encode(this._outbox);if(!(e.length<this._client.maxRequestSize)){var t=this._outbox.pop();this.flush(),t&&this._outbox.push(t)}},receive:function(e,t){for(var n=e.length;n--;)e[n].setDeferredStatus("succeeded");t=[].concat(t),this.debug("Client ? received from ?: ?",this._client._clientId,Faye.URI.stringify(this.endpoint),t);for(var i=0,n=t.length;n>i;i++)this._client.receiveMessage(t[i])},handleError:function(e,t){for(var n=e.length;n--;)e[n].setDeferredStatus("failed",t)},_getCookies:function(){var e=this._client.cookies;return e?e.getCookies({domain:this.endpoint.hostname,path:this.endpoint.path,secure:"https:"===this.endpoint.protocol}).toValueString():""},_storeCookies:function(e){if(e&&this._client.cookies){e=[].concat(e);for(var t,n=0,i=e.length;i>n;n++)t=this._client.cookies.setCookie(e[n]),t=t[0]||t,t.domain=t.domain||this.endpoint.hostname}}}),{get:function(e,t,n,i,r){var s=e.endpoint;Faye.asyncEach(this._transports,function(o,a){var c=o[0],u=o[1],h=e.endpoints[c]||s;return Faye.indexOf(n,c)>=0?a():Faye.indexOf(t,c)<0?(u.isUsable(e,h,function(){}),a()):void u.isUsable(e,h,function(t){if(!t)return a();var n=u.hasOwnProperty("create")?u.create(e,h):new u(e,h);i.call(r,n)})},function(){throw new Error("Could not find a usable connection type for "+Faye.URI.stringify(s))})},register:function(e,t){this._transports.push([e,t]),t.prototype.connectionType=e},_transports:[]}),Faye.extend(Faye.Transport.prototype,Faye.Logging),Faye.extend(Faye.Transport.prototype,Faye.Timeouts),Faye.Event={_registry:[],on:function(e,t,n,i){var r=function(){n.call(i)};e.addEventListener?e.addEventListener(t,r,!1):e.attachEvent("on"+t,r),this._registry.push({_element:e,_type:t,_callback:n,_context:i,_handler:r})
},detach:function(e,t,n,i){for(var r,s=this._registry.length;s--;)r=this._registry[s],e&&e!==r._element||t&&t!==r._type||n&&n!==r._callback||i&&i!==r._context||(r._element.removeEventListener?r._element.removeEventListener(r._type,r._handler,!1):r._element.detachEvent("on"+r._type,r._handler),this._registry.splice(s,1),r=null)}},void 0!==Faye.ENV.onunload&&Faye.Event.on(Faye.ENV,"unload",Faye.Event.detach,Faye.Event),"object"!=typeof JSON&&(JSON={}),function(){function f(e){return 10>e?"0"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'"'+e.replace(escapable,function(e){var t=meta[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var n,i,r,s,o,a=gap,c=t[e];switch(c&&"object"==typeof c&&"function"==typeof c.toJSON&&(c=c.toJSON(e)),"function"==typeof rep&&(c=rep.call(t,e,c)),typeof c){case"string":return quote(c);case"number":return isFinite(c)?String(c):"null";case"boolean":case"null":return String(c);case"object":if(!c)return"null";if(gap+=indent,o=[],"[object Array]"===Object.prototype.toString.apply(c)){for(s=c.length,n=0;s>n;n+=1)o[n]=str(n,c)||"null";return r=0===o.length?"[]":gap?"[\n"+gap+o.join(",\n"+gap)+"\n"+a+"]":"["+o.join(",")+"]",gap=a,r}if(rep&&"object"==typeof rep)for(s=rep.length,n=0;s>n;n+=1)"string"==typeof rep[n]&&(i=rep[n],r=str(i,c),r&&o.push(quote(i)+(gap?": ":":")+r));else for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(r=str(i,c),r&&o.push(quote(i)+(gap?": ":":")+r));return r=0===o.length?"{}":gap?"{\n"+gap+o.join(",\n"+gap)+"\n"+a+"}":"{"+o.join(",")+"}",gap=a,r}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;Faye.stringify=function(e,t,n){var i;if(gap="",indent="","number"==typeof n)for(i=0;n>i;i+=1)indent+=" ";else"string"==typeof n&&(indent=n);if(rep=t,t&&"function"!=typeof t&&("object"!=typeof t||"number"!=typeof t.length))throw new Error("JSON.stringify");return str("",{"":e})},"function"!=typeof JSON.stringify&&(JSON.stringify=Faye.stringify),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(e,t){var n,i,r=e[t];if(r&&"object"==typeof r)for(n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i=walk(r,n),void 0!==i?r[n]=i:delete r[n]);return reviver.call(e,t,r)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),Faye.Transport.WebSocket=Faye.extend(Faye.Class(Faye.Transport,{UNCONNECTED:1,CONNECTING:2,CONNECTED:3,batching:!1,isUsable:function(e,t){this.callback(function(){e.call(t,!0)}),this.errback(function(){e.call(t,!1)}),this.connect()},request:function(e){this._pending=this._pending||new Faye.Set;for(var t=0,n=e.length;n>t;t++)this._pending.add(e[t]);this.callback(function(t){if(t){var n=Faye.map(e,function(e){return e.message});t.send(Faye.toJSON(n))}},this),this.connect()},connect:function(){if(!Faye.Transport.WebSocket._unloaded&&(this._state=this._state||this.UNCONNECTED,this._state===this.UNCONNECTED)){this._state=this.CONNECTING;var e=this._createSocket();if(!e)return this.setDeferredStatus("failed");var t=this;e.onopen=function(){e.headers&&t._storeCookies(e.headers["set-cookie"]),t._socket=e,t._state=t.CONNECTED,t._everConnected=!0,t._ping(),t.setDeferredStatus("succeeded",e)};var n=!1;e.onclose=e.onerror=function(){if(!n){n=!0;var i=t._state===t.CONNECTED;e.onopen=e.onclose=e.onerror=e.onmessage=null,delete t._socket,t._state=t.UNCONNECTED,t.removeTimeout("ping"),t.setDeferredStatus("unknown");var r=t._pending?t._pending.toArray():[];delete t._pending,i?t.handleError(r,!0):t._everConnected?t.handleError(r):t.setDeferredStatus("failed")}},e.onmessage=function(e){var n,i=JSON.parse(e.data),r=[];if(i){i=[].concat(i);for(var s=0,o=i.length;o>s;s++)void 0!==i[s].successful&&(n=t._pending.remove(i[s]),n&&r.push(n));t.receive(r,i)}}}},close:function(){this._socket&&this._socket.close()},_createSocket:function(){var e=Faye.Transport.WebSocket.getSocketUrl(this.endpoint),t={headers:Faye.copyObject(this._client.headers),ca:this._client.ca};return t.headers.Cookie=this._getCookies(),Faye.WebSocket?new Faye.WebSocket.Client(e,[],t):Faye.ENV.MozWebSocket?new MozWebSocket(e):Faye.ENV.WebSocket?new WebSocket(e):void 0},_ping:function(){this._socket&&(this._socket.send("[]"),this.addTimeout("ping",this._client._advice.timeout/2e3,this._ping,this))}}),{PROTOCOLS:{"http:":"ws:","https:":"wss:"},create:function(e,t){var n=e.transports.websocket=e.transports.websocket||{};return n[t.href]=n[t.href]||new this(e,t),n[t.href]},getSocketUrl:function(e){return e=Faye.copyObject(e),e.protocol=this.PROTOCOLS[e.protocol],Faye.URI.stringify(e)},isUsable:function(e,t,n,i){this.create(e,t).isUsable(n,i)}}),Faye.extend(Faye.Transport.WebSocket.prototype,Faye.Deferrable),Faye.Transport.register("websocket",Faye.Transport.WebSocket),Faye.Event&&Faye.Event.on(Faye.ENV,"beforeunload",function(){Faye.Transport.WebSocket._unloaded=!0}),Faye.Transport.EventSource=Faye.extend(Faye.Class(Faye.Transport,{initialize:function(e,t){if(Faye.Transport.prototype.initialize.call(this,e,t),!Faye.ENV.EventSource)return this.setDeferredStatus("failed");this._xhr=new Faye.Transport.XHR(e,t),t=Faye.copyObject(t),t.pathname+="/"+e._clientId;var n=new EventSource(Faye.URI.stringify(t)),i=this;n.onopen=function(){i._everConnected=!0,i.setDeferredStatus("succeeded")},n.onerror=function(){i._everConnected?i._client.messageError([]):(i.setDeferredStatus("failed"),n.close())},n.onmessage=function(e){i.receive([],JSON.parse(e.data))},this._socket=n},close:function(){this._socket&&(this._socket.onopen=this._socket.onerror=this._socket.onmessage=null,this._socket.close(),delete this._socket)},isUsable:function(e,t){this.callback(function(){e.call(t,!0)}),this.errback(function(){e.call(t,!1)})},encode:function(e){return this._xhr.encode(e)},request:function(e){this._xhr.request(e)}}),{isUsable:function(e,t,n,i){var r=e._clientId;return r?void Faye.Transport.XHR.isUsable(e,t,function(r){return r?void this.create(e,t).isUsable(n,i):n.call(i,!1)},this):n.call(i,!1)},create:function(e,t){var n=e.transports.eventsource=e.transports.eventsource||{},i=e._clientId;t=Faye.copyObject(t),t.pathname+="/"+(i||"");var r=Faye.URI.stringify(t);return n[r]=n[r]||new this(e,t),n[r]}}),Faye.extend(Faye.Transport.EventSource.prototype,Faye.Deferrable),Faye.Transport.register("eventsource",Faye.Transport.EventSource),Faye.Transport.XHR=Faye.extend(Faye.Class(Faye.Transport,{encode:function(e){var t=Faye.map(e,function(e){return e.message});return Faye.toJSON(t)},request:function(e){var t=this.endpoint.path,n=Faye.ENV.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest,i=this;n.open("POST",t,!0),n.setRequestHeader("Content-Type","application/json"),n.setRequestHeader("Pragma","no-cache"),n.setRequestHeader("X-Requested-With","XMLHttpRequest");var r=this._client.headers;for(var s in r)r.hasOwnProperty(s)&&n.setRequestHeader(s,r[s]);var o=function(){n.abort()};Faye.Event.on(Faye.ENV,"beforeunload",o),n.onreadystatechange=function(){if(n&&4===n.readyState){var t=null,r=n.status,s=n.responseText,a=r>=200&&300>r||304===r||1223===r;if(Faye.Event.detach(Faye.ENV,"beforeunload",o),n.onreadystatechange=function(){},n=null,!a)return i.handleError(e);try{t=JSON.parse(s)}catch(c){}t?i.receive(e,t):i.handleError(e)}},n.send(this.encode(e))}}),{isUsable:function(e,t,n,i){n.call(i,Faye.URI.isSameOrigin(t))}}),Faye.Transport.register("long-polling",Faye.Transport.XHR),Faye.Transport.CORS=Faye.extend(Faye.Class(Faye.Transport,{encode:function(e){var t=Faye.map(e,function(e){return e.message});return"message="+encodeURIComponent(Faye.toJSON(t))},request:function(e){var t,n=Faye.ENV.XDomainRequest?XDomainRequest:XMLHttpRequest,i=new n,r=this._client.headers,s=this;if(i.open("POST",Faye.URI.stringify(this.endpoint),!0),i.setRequestHeader){i.setRequestHeader("Pragma","no-cache");for(t in r)r.hasOwnProperty(t)&&i.setRequestHeader(t,r[t])}var o=function(){return i?(i.onload=i.onerror=i.ontimeout=i.onprogress=null,void(i=null)):!1};i.onload=function(){var t=null;try{t=JSON.parse(i.responseText)}catch(n){}o(),t?s.receive(e,t):s.handleError(e)},i.onerror=i.ontimeout=function(){o(),s.handleError(e)},i.onprogress=function(){},i.send(this.encode(e))}}),{isUsable:function(e,t,n,i){if(Faye.URI.isSameOrigin(t))return n.call(i,!1);if(Faye.ENV.XDomainRequest)return n.call(i,t.protocol===Faye.ENV.location.protocol);if(Faye.ENV.XMLHttpRequest){var r=new Faye.ENV.XMLHttpRequest;return n.call(i,void 0!==r.withCredentials)}return n.call(i,!1)}}),Faye.Transport.register("cross-origin-long-polling",Faye.Transport.CORS),Faye.Transport.JSONP=Faye.extend(Faye.Class(Faye.Transport,{encode:function(e){var t=Faye.map(e,function(e){return e.message}),n=Faye.copyObject(this.endpoint);return n.query.message=Faye.toJSON(t),n.query.jsonp="__jsonp"+Faye.Transport.JSONP._cbCount+"__",Faye.URI.stringify(n)},request:function(e){var t=Faye.map(e,function(e){return e.message}),n=document.getElementsByTagName("head")[0],i=document.createElement("script"),r=Faye.Transport.JSONP.getCallbackName(),s=Faye.copyObject(this.endpoint),o=this;s.query.message=Faye.toJSON(t),s.query.jsonp=r,Faye.ENV[r]=function(t){if(!Faye.ENV[r])return!1;Faye.ENV[r]=void 0;try{delete Faye.ENV[r]}catch(n){}i.parentNode.removeChild(i),o.receive(e,t)},i.type="text/javascript",i.src=Faye.URI.stringify(s),n.appendChild(i)}}),{_cbCount:0,getCallbackName:function(){return this._cbCount+=1,"__jsonp"+this._cbCount+"__"},isUsable:function(e,t,n,i){n.call(i,!0)}}),Faye.Transport.register("callback-polling",Faye.Transport.JSONP)}()}).call(this,_dereq_("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"1YiZ5S":4}],3:[function(){},{}],4:[function(e,t){function n(){}var i=t.exports={};i.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var n=[];return window.addEventListener("message",function(e){var t=e.source;if((t===window||null===t)&&"process-tick"===e.data&&(e.stopPropagation(),n.length>0)){var i=n.shift();i()}},!0),function(e){n.push(e),window.postMessage("process-tick","*")}}return 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")}},{}],5:[function(e,t){(function(n){function i(e,t,i){if("undefined"!=typeof n&&n.env.STREAM_URL&&!e){var s=/https\:\/\/(\w+)\:(\w+).*site=(\d+)/.exec(n.env.STREAM_URL);e=s[1],t=s[2],i=s[3]}return new r(e,t,i)}var r=e("./lib/client"),s=e("./lib/errors"),o=e("request");t.exports.connect=i,t.exports.errors=s,t.exports.request=o,t.exports.Client=r}).call(this,e("1YiZ5S"))},{"./lib/client":6,"./lib/errors":7,"1YiZ5S":4,request:1}],6:[function(e,t){(function(n){var i=e("request"),r=e("./feed"),s=e("./signing"),o=e("./errors"),a=e("crypto"),c=function(){this.initialize.apply(this,arguments)};c.prototype={baseUrl:"https://getstream.io",initialize:function(e,t,i,r){this.key=e,this.secret=t,this.siteId=i,this.fayeUrl=r?r:"https://getstream.io/faye","undefined"!=typeof n&&n.env.LOCAL&&(this.baseUrl="http://localhost:8000"),this.handlers={},this.node="undefined"==typeof window},on:function(e,t){this.handlers[e]=t},off:function(e){void 0==e?this.handlers={}:delete this.handlers[e]},send:function(e){var t=Array.prototype.slice.call(arguments),e=t[0];t=t.slice(1),this.handlers[e]&&this.handlers[e].apply(this,t)},wrapCallback:function(e){function t(){var t=Array.prototype.slice.call(arguments),i=["response"].concat(t);n.send.apply(n,i),void 0!=e&&e.apply(n,t)}var n=this;return t},userAgent:function(){var e=this.node?"node":"browser",t="unknown";return"stream-javascript-client-"+e+"-"+t},feed:function(e,t,n){var i=e.match(/\:/g);if(null===i||1!=i.length)throw new o.FeedError("Wrong feed format "+e+" correct format is flat:1");if(a.createHash&&this.secret&&!t&&(t=s.sign(this.secret,e.replace(":",""))),!t)throw new o.FeedError("Missing token, in client side mode please provide a feed secret");var c=new r(this,e,t,n);return c},enrichUrl:function(e){var t=this.baseUrl+e;return t+=-1!=t.indexOf("?")?"&api_key="+this.key:"?api_key="+this.key},enrichKwargs:function(e){e.url=this.enrichUrl(e.url),e.json=!0;var t=e.authorization||this.authorization;e.headers={},e.headers.Authorization=t;var n=this.node?"User-Agent":"X-Stream-Client";return e.headers[n]=this.userAgent(),e},signActivity:function(e){return this.signActivities([e])[0]},signActivities:function(e){if(!this.secret)return e;for(var t=0;t<e.length;t++){for(var n=e[t],i=n.to||[],r=[],s=0;s<i.length;s++){var o=i[s],a=this.feed(o).token,c=o+" "+a;r.push(c)}n.to=r}return e},get:function(e,t){this.send("request","get",e,t),e=this.enrichKwargs(e),e.method="GET";var n=this.wrapCallback(t);return i.get(e,n)},post:function(e,t){this.send("request","post",e,t),e=this.enrichKwargs(e),e.method="POST";var n=this.wrapCallback(t);return i(e,n)},"delete":function(e,t){this.send("request","delete",e,t),e=this.enrichKwargs(e),e.method="DELETE";var n=this.wrapCallback(t);return i(e,n)}},t.exports=c}).call(this,e("1YiZ5S"))},{"./errors":7,"./feed":8,"./signing":9,"1YiZ5S":4,crypto:3,request:1}],7:[function(e,t){function n(e,t){this.message=e,Error.call(this,this.message),r?Error.captureStackTrace(this,t):this.stack=s?(new Error).stack:""}var i=t.exports,r="function"==typeof Error.captureStackTrace,s=!!(new Error).stack;i._Abstract=n,n.prototype=new Error,i.FeedError=function(e){n.call(this,e)},i.FeedError.prototype=new n,i.SiteError=function(e){n.call(this,e)},i.SiteError.prototype=new n},{}],8:[function(e,t){var n=e("./errors"),i=function(){this.initialize.apply(this,arguments)};i.prototype={initialize:function(e,t,n){this.client=e,this.feed=t,this.token=n,this.feedUrl=t.replace(":","/"),this.feedTogether=t.replace(":",""),this.authorization=this.feedTogether+" "+this.token,this.fayeClient=null,this.notificationChannel="site-"+this.client.siteId+"-feed-"+this.feedTogether},addActivity:function(e,t){var e=this.client.signActivity(e),n=this.client.post({url:"/api/feed/"+this.feedUrl+"/",body:e,authorization:this.authorization},t);return n},removeActivity:function(e,t){var n=(e.foreignId?e.foreignId:e,{});e.foreignId&&(n.foreign_id="1");var i=this.client.delete({url:"/api/feed/"+this.feedUrl+"/"+e+"/",qs:n,authorization:this.authorization},t);return i},addActivities:function(e,t){var e=this.client.signActivities(e),n={activities:e},i=this.client.post({url:"/api/feed/"+this.feedUrl+"/",body:n,authorization:this.authorization},t);return i},follow:function(e,t,n){if(void 0!=t)var i=t.call?null:t,n=t.call?t:n;this.client.secret&&!i&&(i=this.client.feed(e).token);var r=this.client.post({url:"/api/feed/"+this.feedUrl+"/follows/",body:{target:e,target_token:i},authorization:this.authorization},n);return r},unfollow:function(e,t){var n=this.client.delete({url:"/api/feed/"+this.feedUrl+"/follows/"+e+"/",authorization:this.authorization},t);return n},following:function(e,t){void 0!=e&&e.filter&&(e.filter=e.filter.join(","));var n=this.client.get({url:"/api/feed/"+this.feedUrl+"/following/",qs:e,authorization:this.authorization},t);return n},followers:function(e,t){void 0!=e&&e.filter&&(e.filter=e.filter.join(","));var n=this.client.get({url:"/api/feed/"+this.feedUrl+"/followers/",qs:e,authorization:this.authorization},t);return n},get:function(e,t){e&&e.mark_read&&(e.mark_read=e.mark_read.join(",")),e&&e.mark_seen&&(e.mark_seen=e.mark_seen.join(","));var n=this.client.get({url:"/api/feed/"+this.feedUrl+"/",qs:e,authorization:this.authorization},t);return n},getFayeAuthorization:function(){var e=this.client.key,t=this.notificationChannel,n=this.token;return{incoming:function(e,t){t(e)},outgoing:function(i,r){i.ext={user_id:t,api_key:e,signature:n},r(i)}}},getFayeClient:function(){var t=e("faye");if(null===this.fayeClient){this.fayeClient=new t.Client(this.client.fayeUrl);var n=this.getFayeAuthorization();this.fayeClient.addExtension(n)}return this.fayeClient},subscribe:function(e){if(!this.client.siteId)throw new n.SiteError("Missing site id, which is needed to subscribe, use var client = stream.connect(key, secret, siteId);");return this.getFayeClient().subscribe("/"+this.notificationChannel,e)}},t.exports=i},{"./errors":7,faye:2}],9:[function(e,t,n){function i(e){var t=e.replace("+","-").replace("/","_");return t.replace(/^=+/,"").replace(/=+$/,"")}var r=e("crypto");n.sign=function(e,t){var n=new r.createHash("sha1").update(e).digest(),s=r.createHmac("sha1",n),o=s.update(t).digest("base64"),a=i(o);return a}},{crypto:3}]},{},[5])(5)});
},detach:function(e,t,n,i){for(var r,s=this._registry.length;s--;)r=this._registry[s],e&&e!==r._element||t&&t!==r._type||n&&n!==r._callback||i&&i!==r._context||(r._element.removeEventListener?r._element.removeEventListener(r._type,r._handler,!1):r._element.detachEvent("on"+r._type,r._handler),this._registry.splice(s,1),r=null)}},void 0!==Faye.ENV.onunload&&Faye.Event.on(Faye.ENV,"unload",Faye.Event.detach,Faye.Event),"object"!=typeof JSON&&(JSON={}),function(){function f(e){return 10>e?"0"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'"'+e.replace(escapable,function(e){var t=meta[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var n,i,r,s,o,a=gap,c=t[e];switch(c&&"object"==typeof c&&"function"==typeof c.toJSON&&(c=c.toJSON(e)),"function"==typeof rep&&(c=rep.call(t,e,c)),typeof c){case"string":return quote(c);case"number":return isFinite(c)?String(c):"null";case"boolean":case"null":return String(c);case"object":if(!c)return"null";if(gap+=indent,o=[],"[object Array]"===Object.prototype.toString.apply(c)){for(s=c.length,n=0;s>n;n+=1)o[n]=str(n,c)||"null";return r=0===o.length?"[]":gap?"[\n"+gap+o.join(",\n"+gap)+"\n"+a+"]":"["+o.join(",")+"]",gap=a,r}if(rep&&"object"==typeof rep)for(s=rep.length,n=0;s>n;n+=1)"string"==typeof rep[n]&&(i=rep[n],r=str(i,c),r&&o.push(quote(i)+(gap?": ":":")+r));else for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(r=str(i,c),r&&o.push(quote(i)+(gap?": ":":")+r));return r=0===o.length?"{}":gap?"{\n"+gap+o.join(",\n"+gap)+"\n"+a+"}":"{"+o.join(",")+"}",gap=a,r}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;Faye.stringify=function(e,t,n){var i;if(gap="",indent="","number"==typeof n)for(i=0;n>i;i+=1)indent+=" ";else"string"==typeof n&&(indent=n);if(rep=t,t&&"function"!=typeof t&&("object"!=typeof t||"number"!=typeof t.length))throw new Error("JSON.stringify");return str("",{"":e})},"function"!=typeof JSON.stringify&&(JSON.stringify=Faye.stringify),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(e,t){var n,i,r=e[t];if(r&&"object"==typeof r)for(n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i=walk(r,n),void 0!==i?r[n]=i:delete r[n]);return reviver.call(e,t,r)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),Faye.Transport.WebSocket=Faye.extend(Faye.Class(Faye.Transport,{UNCONNECTED:1,CONNECTING:2,CONNECTED:3,batching:!1,isUsable:function(e,t){this.callback(function(){e.call(t,!0)}),this.errback(function(){e.call(t,!1)}),this.connect()},request:function(e){this._pending=this._pending||new Faye.Set;for(var t=0,n=e.length;n>t;t++)this._pending.add(e[t]);this.callback(function(t){if(t){var n=Faye.map(e,function(e){return e.message});t.send(Faye.toJSON(n))}},this),this.connect()},connect:function(){if(!Faye.Transport.WebSocket._unloaded&&(this._state=this._state||this.UNCONNECTED,this._state===this.UNCONNECTED)){this._state=this.CONNECTING;var e=this._createSocket();if(!e)return this.setDeferredStatus("failed");var t=this;e.onopen=function(){e.headers&&t._storeCookies(e.headers["set-cookie"]),t._socket=e,t._state=t.CONNECTED,t._everConnected=!0,t._ping(),t.setDeferredStatus("succeeded",e)};var n=!1;e.onclose=e.onerror=function(){if(!n){n=!0;var i=t._state===t.CONNECTED;e.onopen=e.onclose=e.onerror=e.onmessage=null,delete t._socket,t._state=t.UNCONNECTED,t.removeTimeout("ping"),t.setDeferredStatus("unknown");var r=t._pending?t._pending.toArray():[];delete t._pending,i?t.handleError(r,!0):t._everConnected?t.handleError(r):t.setDeferredStatus("failed")}},e.onmessage=function(e){var n,i=JSON.parse(e.data),r=[];if(i){i=[].concat(i);for(var s=0,o=i.length;o>s;s++)void 0!==i[s].successful&&(n=t._pending.remove(i[s]),n&&r.push(n));t.receive(r,i)}}}},close:function(){this._socket&&this._socket.close()},_createSocket:function(){var e=Faye.Transport.WebSocket.getSocketUrl(this.endpoint),t={headers:Faye.copyObject(this._client.headers),ca:this._client.ca};return t.headers.Cookie=this._getCookies(),Faye.WebSocket?new Faye.WebSocket.Client(e,[],t):Faye.ENV.MozWebSocket?new MozWebSocket(e):Faye.ENV.WebSocket?new WebSocket(e):void 0},_ping:function(){this._socket&&(this._socket.send("[]"),this.addTimeout("ping",this._client._advice.timeout/2e3,this._ping,this))}}),{PROTOCOLS:{"http:":"ws:","https:":"wss:"},create:function(e,t){var n=e.transports.websocket=e.transports.websocket||{};return n[t.href]=n[t.href]||new this(e,t),n[t.href]},getSocketUrl:function(e){return e=Faye.copyObject(e),e.protocol=this.PROTOCOLS[e.protocol],Faye.URI.stringify(e)},isUsable:function(e,t,n,i){this.create(e,t).isUsable(n,i)}}),Faye.extend(Faye.Transport.WebSocket.prototype,Faye.Deferrable),Faye.Transport.register("websocket",Faye.Transport.WebSocket),Faye.Event&&Faye.Event.on(Faye.ENV,"beforeunload",function(){Faye.Transport.WebSocket._unloaded=!0}),Faye.Transport.EventSource=Faye.extend(Faye.Class(Faye.Transport,{initialize:function(e,t){if(Faye.Transport.prototype.initialize.call(this,e,t),!Faye.ENV.EventSource)return this.setDeferredStatus("failed");this._xhr=new Faye.Transport.XHR(e,t),t=Faye.copyObject(t),t.pathname+="/"+e._clientId;var n=new EventSource(Faye.URI.stringify(t)),i=this;n.onopen=function(){i._everConnected=!0,i.setDeferredStatus("succeeded")},n.onerror=function(){i._everConnected?i._client.messageError([]):(i.setDeferredStatus("failed"),n.close())},n.onmessage=function(e){i.receive([],JSON.parse(e.data))},this._socket=n},close:function(){this._socket&&(this._socket.onopen=this._socket.onerror=this._socket.onmessage=null,this._socket.close(),delete this._socket)},isUsable:function(e,t){this.callback(function(){e.call(t,!0)}),this.errback(function(){e.call(t,!1)})},encode:function(e){return this._xhr.encode(e)},request:function(e){this._xhr.request(e)}}),{isUsable:function(e,t,n,i){var r=e._clientId;return r?void Faye.Transport.XHR.isUsable(e,t,function(r){return r?void this.create(e,t).isUsable(n,i):n.call(i,!1)},this):n.call(i,!1)},create:function(e,t){var n=e.transports.eventsource=e.transports.eventsource||{},i=e._clientId;t=Faye.copyObject(t),t.pathname+="/"+(i||"");var r=Faye.URI.stringify(t);return n[r]=n[r]||new this(e,t),n[r]}}),Faye.extend(Faye.Transport.EventSource.prototype,Faye.Deferrable),Faye.Transport.register("eventsource",Faye.Transport.EventSource),Faye.Transport.XHR=Faye.extend(Faye.Class(Faye.Transport,{encode:function(e){var t=Faye.map(e,function(e){return e.message});return Faye.toJSON(t)},request:function(e){var t=this.endpoint.path,n=Faye.ENV.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest,i=this;n.open("POST",t,!0),n.setRequestHeader("Content-Type","application/json"),n.setRequestHeader("Pragma","no-cache"),n.setRequestHeader("X-Requested-With","XMLHttpRequest");var r=this._client.headers;for(var s in r)r.hasOwnProperty(s)&&n.setRequestHeader(s,r[s]);var o=function(){n.abort()};Faye.Event.on(Faye.ENV,"beforeunload",o),n.onreadystatechange=function(){if(n&&4===n.readyState){var t=null,r=n.status,s=n.responseText,a=r>=200&&300>r||304===r||1223===r;if(Faye.Event.detach(Faye.ENV,"beforeunload",o),n.onreadystatechange=function(){},n=null,!a)return i.handleError(e);try{t=JSON.parse(s)}catch(c){}t?i.receive(e,t):i.handleError(e)}},n.send(this.encode(e))}}),{isUsable:function(e,t,n,i){n.call(i,Faye.URI.isSameOrigin(t))}}),Faye.Transport.register("long-polling",Faye.Transport.XHR),Faye.Transport.CORS=Faye.extend(Faye.Class(Faye.Transport,{encode:function(e){var t=Faye.map(e,function(e){return e.message});return"message="+encodeURIComponent(Faye.toJSON(t))},request:function(e){var t,n=Faye.ENV.XDomainRequest?XDomainRequest:XMLHttpRequest,i=new n,r=this._client.headers,s=this;if(i.open("POST",Faye.URI.stringify(this.endpoint),!0),i.setRequestHeader){i.setRequestHeader("Pragma","no-cache");for(t in r)r.hasOwnProperty(t)&&i.setRequestHeader(t,r[t])}var o=function(){return i?(i.onload=i.onerror=i.ontimeout=i.onprogress=null,void(i=null)):!1};i.onload=function(){var t=null;try{t=JSON.parse(i.responseText)}catch(n){}o(),t?s.receive(e,t):s.handleError(e)},i.onerror=i.ontimeout=function(){o(),s.handleError(e)},i.onprogress=function(){},i.send(this.encode(e))}}),{isUsable:function(e,t,n,i){if(Faye.URI.isSameOrigin(t))return n.call(i,!1);if(Faye.ENV.XDomainRequest)return n.call(i,t.protocol===Faye.ENV.location.protocol);if(Faye.ENV.XMLHttpRequest){var r=new Faye.ENV.XMLHttpRequest;return n.call(i,void 0!==r.withCredentials)}return n.call(i,!1)}}),Faye.Transport.register("cross-origin-long-polling",Faye.Transport.CORS),Faye.Transport.JSONP=Faye.extend(Faye.Class(Faye.Transport,{encode:function(e){var t=Faye.map(e,function(e){return e.message}),n=Faye.copyObject(this.endpoint);return n.query.message=Faye.toJSON(t),n.query.jsonp="__jsonp"+Faye.Transport.JSONP._cbCount+"__",Faye.URI.stringify(n)},request:function(e){var t=Faye.map(e,function(e){return e.message}),n=document.getElementsByTagName("head")[0],i=document.createElement("script"),r=Faye.Transport.JSONP.getCallbackName(),s=Faye.copyObject(this.endpoint),o=this;s.query.message=Faye.toJSON(t),s.query.jsonp=r,Faye.ENV[r]=function(t){if(!Faye.ENV[r])return!1;Faye.ENV[r]=void 0;try{delete Faye.ENV[r]}catch(n){}i.parentNode.removeChild(i),o.receive(e,t)},i.type="text/javascript",i.src=Faye.URI.stringify(s),n.appendChild(i)}}),{_cbCount:0,getCallbackName:function(){return this._cbCount+=1,"__jsonp"+this._cbCount+"__"},isUsable:function(e,t,n,i){n.call(i,!0)}}),Faye.Transport.register("callback-polling",Faye.Transport.JSONP)}()}).call(this,_dereq_("1YiZ5S"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"1YiZ5S":4}],3:[function(){},{}],4:[function(e,t){function n(){}var i=t.exports={};i.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var n=[];return window.addEventListener("message",function(e){var t=e.source;if((t===window||null===t)&&"process-tick"===e.data&&(e.stopPropagation(),n.length>0)){var i=n.shift();i()}},!0),function(e){n.push(e),window.postMessage("process-tick","*")}}return 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")}},{}],5:[function(e,t){(function(n){function i(e,t,i){if("undefined"!=typeof n&&n.env.STREAM_URL&&!e){var s=/https\:\/\/(\w+)\:(\w+).*site=(\d+)/.exec(n.env.STREAM_URL);e=s[1],t=s[2],i=s[3]}return new r(e,t,i)}var r=e("./lib/client"),s=e("./lib/errors"),o=e("request");t.exports.connect=i,t.exports.errors=s,t.exports.request=o,t.exports.Client=r}).call(this,e("1YiZ5S"))},{"./lib/client":6,"./lib/errors":7,"1YiZ5S":4,request:1}],6:[function(e,t){(function(n){var i=e("request"),r=e("./feed"),s=e("./signing"),o=e("./errors"),a=e("crypto"),c=function(){this.initialize.apply(this,arguments)};c.prototype={baseUrl:"https://getstream.io",initialize:function(e,t,i,r){this.key=e,this.secret=t,this.siteId=i,this.fayeUrl=r?r:"https://getstream.io/faye","undefined"!=typeof n&&n.env.LOCAL&&(this.baseUrl="http://localhost:8000"),this.handlers={},this.node="undefined"==typeof window},on:function(e,t){this.handlers[e]=t},off:function(e){void 0==e?this.handlers={}:delete this.handlers[e]},send:function(e){var t=Array.prototype.slice.call(arguments),e=t[0];t=t.slice(1),this.handlers[e]&&this.handlers[e].apply(this,t)},wrapCallback:function(e){function t(){var t=Array.prototype.slice.call(arguments),i=["response"].concat(t);n.send.apply(n,i),void 0!=e&&e.apply(n,t)}var n=this;return t},userAgent:function(){var e=this.node?"node":"browser",t="unknown";return"stream-javascript-client-"+e+"-"+t},feed:function(e,t,n){var i=e.match(/\:/g);if(null===i||1!=i.length)throw new o.FeedError("Wrong feed format "+e+" correct format is flat:1");if(!a.createHash)throw new o.FeedError("crypto is not available, are you running this on a browser?");if(this.secret&&!t&&(t=s.sign(this.secret,e.replace(":",""))),!t)throw new o.FeedError("Missing token, in client side mode please provide a feed secret");var c=new r(this,e,t,n);return c},enrichUrl:function(e){var t=this.baseUrl+e;return t},enrichKwargs:function(e){e.url=this.enrichUrl(e.url),void 0==e.qs&&(e.qs={}),e.qs.api_key=this.key,e.json=!0;var t=e.authorization||this.authorization;e.headers={},e.headers.Authorization=t;var n=this.node?"User-Agent":"X-Stream-Client";return e.headers[n]=this.userAgent(),e},signActivity:function(e){return this.signActivities([e])[0]},signActivities:function(e){if(!this.secret)return e;for(var t=0;t<e.length;t++){for(var n=e[t],i=n.to||[],r=[],s=0;s<i.length;s++){var o=i[s],a=this.feed(o).token,c=o+" "+a;r.push(c)}n.to=r}return e},get:function(e,t){this.send("request","get",e,t),e=this.enrichKwargs(e),e.method="GET";var n=this.wrapCallback(t);return i(e,n)},post:function(e,t){this.send("request","post",e,t),e=this.enrichKwargs(e),e.method="POST";var n=this.wrapCallback(t);return i(e,n)},"delete":function(e,t){this.send("request","delete",e,t),e=this.enrichKwargs(e),e.method="DELETE";var n=this.wrapCallback(t);return i(e,n)}},t.exports=c}).call(this,e("1YiZ5S"))},{"./errors":7,"./feed":8,"./signing":9,"1YiZ5S":4,crypto:3,request:1}],7:[function(e,t){function n(e,t){this.message=e,Error.call(this,this.message),r?Error.captureStackTrace(this,t):this.stack=s?(new Error).stack:""}var i=t.exports,r="function"==typeof Error.captureStackTrace,s=!!(new Error).stack;i._Abstract=n,n.prototype=new Error,i.FeedError=function(e){n.call(this,e)},i.FeedError.prototype=new n,i.SiteError=function(e){n.call(this,e)},i.SiteError.prototype=new n},{}],8:[function(e,t){var n=e("./errors"),i=function(){this.initialize.apply(this,arguments)};i.prototype={initialize:function(e,t,n){this.client=e,this.feed=t,this.token=n,this.feedUrl=t.replace(":","/"),this.feedTogether=t.replace(":",""),this.authorization=this.feedTogether+" "+this.token,this.fayeClient=null,this.notificationChannel="site-"+this.client.siteId+"-feed-"+this.feedTogether},addActivity:function(e,t){var e=this.client.signActivity(e),n=this.client.post({url:"/api/feed/"+this.feedUrl+"/",body:e,authorization:this.authorization},t);return n},removeActivity:function(e,t){var n=(e.foreignId?e.foreignId:e,{});e.foreignId&&(n.foreign_id="1");var i=this.client.delete({url:"/api/feed/"+this.feedUrl+"/"+e+"/",qs:n,authorization:this.authorization},t);return i},addActivities:function(e,t){var e=this.client.signActivities(e),n={activities:e},i=this.client.post({url:"/api/feed/"+this.feedUrl+"/",body:n,authorization:this.authorization},t);return i},follow:function(e,t,n){if(void 0!=t)var i=t.call?null:t,n=t.call?t:n;this.client.secret&&!i&&(i=this.client.feed(e).token);var r=this.client.post({url:"/api/feed/"+this.feedUrl+"/follows/",body:{target:e,target_token:i},authorization:this.authorization},n);return r},unfollow:function(e,t){var n=this.client.delete({url:"/api/feed/"+this.feedUrl+"/follows/"+e+"/",authorization:this.authorization},t);return n},following:function(e,t){void 0!=e&&e.filter&&(e.filter=e.filter.join(","));var n=this.client.get({url:"/api/feed/"+this.feedUrl+"/following/",qs:e,authorization:this.authorization},t);return n},followers:function(e,t){void 0!=e&&e.filter&&(e.filter=e.filter.join(","));var n=this.client.get({url:"/api/feed/"+this.feedUrl+"/followers/",qs:e,authorization:this.authorization},t);return n},get:function(e,t){e&&e.mark_read&&(e.mark_read=e.mark_read.join(",")),e&&e.mark_seen&&(e.mark_seen=e.mark_seen.join(","));var n=this.client.get({url:"/api/feed/"+this.feedUrl+"/",qs:e,authorization:this.authorization},t);return n},getFayeAuthorization:function(){var e=this.client.key,t=this.notificationChannel,n=this.token;return{incoming:function(e,t){t(e)},outgoing:function(i,r){i.ext={user_id:t,api_key:e,signature:n},r(i)}}},getFayeClient:function(){var t=e("faye");if(null===this.fayeClient){this.fayeClient=new t.Client(this.client.fayeUrl);var n=this.getFayeAuthorization();this.fayeClient.addExtension(n)}return this.fayeClient},subscribe:function(e){if(!this.client.siteId)throw new n.SiteError("Missing site id, which is needed to subscribe, use var client = stream.connect(key, secret, siteId);");return this.getFayeClient().subscribe("/"+this.notificationChannel,e)}},t.exports=i},{"./errors":7,faye:2}],9:[function(e,t,n){function i(e){var t=e.replace("+","-").replace("/","_");return t.replace(/^=+/,"").replace(/=+$/,"")}var r=e("crypto");n.sign=function(e,t){var n=new r.createHash("sha1").update(e).digest(),s=r.createHmac("sha1",n),o=s.update(t).digest("base64"),a=i(o);return a}},{crypto:3}]},{},[5])(5)});

@@ -10,3 +10,3 @@ {

"homepage": "https://getstream.io/",
"version": "1.0.7",
"version": "1.0.9",
"config": {

@@ -28,2 +28,3 @@ "blanket": {

"browserify": "~4.1.11",
"crypto-browserify": "^3.2.8",
"connect": "^3.0.1",

@@ -30,0 +31,0 @@ "coveralls": "~2.10.1",

@@ -100,3 +100,7 @@ var request = require('request');

if (crypto.createHash && this.secret && !token) {
if (!crypto.createHash) {
throw new errors.FeedError('crypto is not available, are you running this on a browser?');
}
if (this.secret && !token) {
// we are server side, have a secret but no feed signature

@@ -116,7 +120,2 @@ token = signing.sign(this.secret, feedId.replace(':', ''));

var url = this.baseUrl + relativeUrl;
if (url.indexOf('?') != -1) {
url += '&api_key=' + this.key;
} else {
url += '?api_key=' + this.key;
}
return url;

@@ -127,2 +126,6 @@ },

kwargs.url = this.enrichUrl(kwargs.url);
if (kwargs.qs == undefined) {
kwargs.qs = {};
}
kwargs.qs['api_key'] = this.key;
kwargs.json = true;

@@ -175,3 +178,3 @@ var authorization = kwargs.authorization || this.authorization;

var callback = this.wrapCallback(cb);
return request.get(kwargs, callback);
return request(kwargs, callback);
},

@@ -194,2 +197,2 @@ post: function (kwargs, cb) {

module.exports = StreamClient;
module.exports = StreamClient;

@@ -190,3 +190,3 @@

activity['route'] = {'name': 'Vondelpark', 'distance': '20'};
activity['to'] = ['flat:33'];
activity['to'] = ['flat:33', 'user:everyone'];
//flat3

@@ -193,0 +193,0 @@ if (!node) activity['to'] = ['flat:33' + ' ' + flat3.token];

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