c3d2-web/content/static/candy/libs.min.js

3 lines
78 KiB
JavaScript
Raw Permalink Normal View History

2015-07-22 01:01:23 +02:00
!function(a){return function(a,b){"function"==typeof define&&define.amd?define("strophe-base64",function(){return b()}):a.Base64=b()}(this,function(){var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",b={encode:function(b){var c,d,e,f,g,h,i,j="",k=0;do c=b.charCodeAt(k++),d=b.charCodeAt(k++),e=b.charCodeAt(k++),f=c>>2,g=(3&c)<<4|d>>4,h=(15&d)<<2|e>>6,i=63&e,isNaN(d)?(g=(3&c)<<4,h=i=64):isNaN(e)&&(i=64),j=j+a.charAt(f)+a.charAt(g)+a.charAt(h)+a.charAt(i);while(k<b.length);return j},decode:function(b){var c,d,e,f,g,h,i,j="",k=0;b=b.replace(/[^A-Za-z0-9\+\/\=]/g,"");do f=a.indexOf(b.charAt(k++)),g=a.indexOf(b.charAt(k++)),h=a.indexOf(b.charAt(k++)),i=a.indexOf(b.charAt(k++)),c=f<<2|g>>4,d=(15&g)<<4|h>>2,e=(3&h)<<6|i,j+=String.fromCharCode(c),64!=h&&(j+=String.fromCharCode(d)),64!=i&&(j+=String.fromCharCode(e));while(k<b.length);return j}};return b}),function(a,b){"function"==typeof define&&define.amd?define("strophe-sha1",function(){return b()}):a.SHA1=b()}(this,function(){function a(a,d){a[d>>5]|=128<<24-d%32,a[(d+64>>9<<4)+15]=d;var g,h,i,j,k,l,m,n,o=new Array(80),p=1732584193,q=-271733879,r=-1732584194,s=271733878,t=-1009589776;for(g=0;g<a.length;g+=16){for(j=p,k=q,l=r,m=s,n=t,h=0;80>h;h++)16>h?o[h]=a[g+h]:o[h]=f(o[h-3]^o[h-8]^o[h-14]^o[h-16],1),i=e(e(f(p,5),b(h,q,r,s)),e(e(t,o[h]),c(h))),t=s,s=r,r=f(q,30),q=p,p=i;p=e(p,j),q=e(q,k),r=e(r,l),s=e(s,m),t=e(t,n)}return[p,q,r,s,t]}function b(a,b,c,d){return 20>a?b&c|~b&d:40>a?b^c^d:60>a?b&c|b&d|c&d:b^c^d}function c(a){return 20>a?1518500249:40>a?1859775393:60>a?-1894007588:-899497514}function d(b,c){var d=g(b);d.length>16&&(d=a(d,8*b.length));for(var e=new Array(16),f=new Array(16),h=0;16>h;h++)e[h]=909522486^d[h],f[h]=1549556828^d[h];var i=a(e.concat(g(c)),512+8*c.length);return a(f.concat(i),672)}function e(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c}function f(a,b){return a<<b|a>>>32-b}function g(a){for(var b=[],c=255,d=0;d<8*a.length;d+=8)b[d>>5]|=(a.charCodeAt(d/8)&c)<<24-d%32;return b}function h(a){for(var b="",c=255,d=0;d<32*a.length;d+=8)b+=String.fromCharCode(a[d>>5]>>>24-d%32&c);return b}function i(a){for(var b,c,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e="",f=0;f<4*a.length;f+=3)for(b=(a[f>>2]>>8*(3-f%4)&255)<<16|(a[f+1>>2]>>8*(3-(f+1)%4)&255)<<8|a[f+2>>2]>>8*(3-(f+2)%4)&255,c=0;4>c;c++)e+=8*f+6*c>32*a.length?"=":d.charAt(b>>6*(3-c)&63);return e}return{b64_hmac_sha1:function(a,b){return i(d(a,b))},b64_sha1:function(b){return i(a(g(b),8*b.length))},binb2str:h,core_hmac_sha1:d,str_hmac_sha1:function(a,b){return h(d(a,b))},str_sha1:function(b){return h(a(g(b),8*b.length))}}}),function(a,b){"function"==typeof define&&define.amd?define("strophe-md5",function(){return b()}):a.MD5=b()}(this,function(a){var b=function(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c},c=function(a,b){return a<<b|a>>>32-b},d=function(a){for(var b=[],c=0;c<8*a.length;c+=8)b[c>>5]|=(255&a.charCodeAt(c/8))<<c%32;return b},e=function(a){for(var b="",c=0;c<32*a.length;c+=8)b+=String.fromCharCode(a[c>>5]>>>c%32&255);return b},f=function(a){for(var b="0123456789abcdef",c="",d=0;d<4*a.length;d++)c+=b.charAt(a[d>>2]>>d%4*8+4&15)+b.charAt(a[d>>2]>>d%4*8&15);return c},g=function(a,d,e,f,g,h){return b(c(b(b(d,a),b(f,h)),g),e)},h=function(a,b,c,d,e,f,h){return g(b&c|~b&d,a,b,e,f,h)},i=function(a,b,c,d,e,f,h){return g(b&d|c&~d,a,b,e,f,h)},j=function(a,b,c,d,e,f,h){return g(b^c^d,a,b,e,f,h)},k=function(a,b,c,d,e,f,h){return g(c^(b|~d),a,b,e,f,h)},l=function(a,c){a[c>>5]|=128<<c%32,a[(c+64>>>9<<4)+14]=c;for(var d,e,f,g,l=1732584193,m=-271733879,n=-1732584194,o=271733878,p=0;p<a.length;p+=16)d=l,e=m,f=n,g=o,l=h(l,m,n,o,a[p+0],7,-680876936),o=h(o,l,m,n,a[p+1],12,-389564586),n=h(n,o,l,m,a[p+2],17,606105819),m=h(m,n,o,l,a[p+3],22,-1044525330),l=h(l,m,n,o,a[p+4],7,-176418897),o=h(o,l,m,n,a[p+5],12,1200080426),n=h(n,o,l,m,a[p+6],17,-1473231341),m=h(m,n,o,l,a[p+7],22,-45705983),l=h(l,m,n,o,a[p+8],7,1770035416),o=h(o,l,m,n,a[p+9],12,-1958414417),n=h(n,o,l,m,a[p+10],17,-42063),m=h(m,n,o,l,a[p+11],22,-19
return b+="\x00",b+=a.authcid,b+="\x00",b+=a.pass},h.Connection.prototype.mechanisms[h.SASLPlain.prototype.name]=h.SASLPlain,h.SASLSHA1=function(){},h.SASLSHA1.prototype=new h.SASLMechanism("SCRAM-SHA-1",!0,40),h.SASLSHA1.test=function(a){return null!==a.authcid},h.SASLSHA1.prototype.onChallenge=function(d,e,f){var g=f||c.hexdigest(1234567890*Math.random()),h="n="+d.authcid;return h+=",r=",h+=g,d._sasl_data.cnonce=g,d._sasl_data["client-first-message-bare"]=h,h="n,,"+h,this.onChallenge=function(c,d){for(var e,f,g,h,i,j,k,l,m,n,o,p="c=biws,",q=c._sasl_data["client-first-message-bare"]+","+d+",",r=c._sasl_data.cnonce,s=/([a-z]+)=([^,]+)(,|$)/;d.match(s);){var t=d.match(s);switch(d=d.replace(t[0],""),t[1]){case"r":e=t[2];break;case"s":f=t[2];break;case"i":g=t[2]}}if(e.substr(0,r.length)!==r)return c._sasl_data={},c._sasl_failure_cb();for(p+="r="+e,q+=p,f=b.decode(f),f+="\x00\x00\x00",h=j=a.core_hmac_sha1(c.pass,f),k=1;g>k;k++){for(i=a.core_hmac_sha1(c.pass,a.binb2str(j)),l=0;5>l;l++)h[l]^=i[l];j=i}for(h=a.binb2str(h),m=a.core_hmac_sha1(h,"Client Key"),n=a.str_hmac_sha1(h,"Server Key"),o=a.core_hmac_sha1(a.str_sha1(a.binb2str(m)),q),c._sasl_data["server-signature"]=a.b64_hmac_sha1(n,q),l=0;5>l;l++)m[l]^=o[l];return p+=",p="+b.encode(a.binb2str(m))}.bind(this),h},h.Connection.prototype.mechanisms[h.SASLSHA1.prototype.name]=h.SASLSHA1,h.SASLMD5=function(){},h.SASLMD5.prototype=new h.SASLMechanism("DIGEST-MD5",!1,30),h.SASLMD5.test=function(a){return null!==a.authcid},h.SASLMD5.prototype._quote=function(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'},h.SASLMD5.prototype.onChallenge=function(a,b,d){for(var e,f=/([a-z]+)=("[^"]+"|[^,"]+)(?:,|$)/,g=d||c.hexdigest(""+1234567890*Math.random()),h="",i=null,j="",k="";b.match(f);)switch(e=b.match(f),b=b.replace(e[0],""),e[2]=e[2].replace(/^"(.+)"$/,"$1"),e[1]){case"realm":h=e[2];break;case"nonce":j=e[2];break;case"qop":k=e[2];break;case"host":i=e[2]}var l=a.servtype+"/"+a.domain;null!==i&&(l=l+"/"+i);var m=c.hash(a.authcid+":"+h+":"+this._connection.pass)+":"+j+":"+g,n="AUTHENTICATE:"+l,o="";return o+="charset=utf-8,",o+="username="+this._quote(a.authcid)+",",o+="realm="+this._quote(h)+",",o+="nonce="+this._quote(j)+",",o+="nc=00000001,",o+="cnonce="+this._quote(g)+",",o+="digest-uri="+this._quote(l)+",",o+="response="+c.hexdigest(c.hexdigest(m)+":"+j+":00000001:"+g+":auth:"+c.hexdigest(n))+",",o+="qop=auth",this.onChallenge=function(){return""}.bind(this),o},h.Connection.prototype.mechanisms[h.SASLMD5.prototype.name]=h.SASLMD5,{Strophe:h,$build:d,$msg:e,$iq:f,$pres:g,SHA1:a,Base64:b,MD5:c}}),function(a,b){return"function"==typeof define&&define.amd?void define("strophe-bosh",["strophe-core"],function(a){return b(a.Strophe,a.$build)}):b(Strophe,$build)}(this,function(a,b){return a.Request=function(b,c,d,e){this.id=++a._requestId,this.xmlData=b,this.data=a.serialize(b),this.origFunc=c,this.func=c,this.rid=d,this.date=NaN,this.sends=e||0,this.abort=!1,this.dead=null,this.age=function(){if(!this.date)return 0;var a=new Date;return(a-this.date)/1e3},this.timeDead=function(){if(!this.dead)return 0;var a=new Date;return(a-this.dead)/1e3},this.xhr=this._newXHR()},a.Request.prototype={getResponse:function(){var b=null;if(this.xhr.responseXML&&this.xhr.responseXML.documentElement){if(b=this.xhr.responseXML.documentElement,"parsererror"==b.tagName)throw a.error("invalid response received"),a.error("responseText: "+this.xhr.responseText),a.error("responseXML: "+a.serialize(this.xhr.responseXML)),"parsererror"}else this.xhr.responseText&&(a.error("invalid response received"),a.error("responseText: "+this.xhr.responseText),a.error("responseXML: "+a.serialize(this.xhr.responseXML)));return b},_newXHR:function(){var a=null;return window.XMLHttpRequest?(a=new XMLHttpRequest,a.overrideMimeType&&a.overrideMimeType("text/xml; charset=utf-8")):window.ActiveXObject&&(a=new ActiveXObject("Microsoft.XMLHTTP")),a.onreadystatechange=this.func.bind(null,this),a}},a.Bosh=function(a){this._conn=a,this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.hold=1,this.wait=60,this.window=5,thi
this},a}()}.call(this),Strophe.addConnectionPlugin("roster",{init:function(a){this._connection=a,this._callbacks=[],this._callbacks_request=[],items=[],ver=null;var b,c=this,d=a.connect,e=a.attach,f=function(d){if(d==Strophe.Status.ATTACHED||d==Strophe.Status.CONNECTED)try{a.addHandler(c._onReceivePresence.bind(c),null,"presence",null,null,null),a.addHandler(c._onReceiveIQ.bind(c),Strophe.NS.ROSTER,"iq","set",null,null)}catch(e){Strophe.error(e)}"function"==typeof b&&b.apply(this,arguments)};a.connect=function(c,e,g,h,i,j,k){b=g,"undefined"==typeof c&&(c=null),"undefined"==typeof e&&(e=null),g=f,d.apply(a,[c,e,g,h,i,j,k])},a.attach=function(c,d,g,h,i,j,k){b=h,"undefined"==typeof c&&(c=null),"undefined"==typeof d&&(d=null),"undefined"==typeof g&&(g=null),h=f,e.apply(a,[c,d,g,h,i,j,k])},Strophe.addNamespace("ROSTER_VER","urn:xmpp:features:rosterver"),Strophe.addNamespace("NICK","http://jabber.org/protocol/nick")},supportVersioning:function(){return this._connection.features&&this._connection.features.getElementsByTagName("ver").length>0},get:function(a,b,c){var d={xmlns:Strophe.NS.ROSTER};this.items=[],this.supportVersioning()&&(d.ver=b||"",this.items=c||[]);var e=$iq({type:"get",id:this._connection.getUniqueId("roster")}).c("query",d);return this._connection.sendIQ(e,this._onReceiveRosterSuccess.bind(this,a),this._onReceiveRosterError.bind(this,a))},registerCallback:function(a){this._callbacks.push(a)},registerRequestCallback:function(a){this._callbacks_request.push(a)},findItem:function(a){for(var b=0;b<this.items.length;b++)if(this.items[b]&&this.items[b].jid==a)return this.items[b];return!1},removeItem:function(a){for(var b=0;b<this.items.length;b++)if(this.items[b]&&this.items[b].jid==a)return this.items.splice(b,1),!0;return!1},subscribe:function(a,b,c){var d=$pres({to:a,type:"subscribe"});b&&""!==b&&d.c("status").t(b).up(),c&&""!==c&&d.c("nick",{xmlns:Strophe.NS.NICK}).t(c).up(),this._connection.send(d)},unsubscribe:function(a,b){var c=$pres({to:a,type:"unsubscribe"});b&&""!==b&&c.c("status").t(b),this._connection.send(c)},authorize:function(a,b){var c=$pres({to:a,type:"subscribed"});b&&""!==b&&c.c("status").t(b),this._connection.send(c)},unauthorize:function(a,b){var c=$pres({to:a,type:"unsubscribed"});b&&""!==b&&c.c("status").t(b),this._connection.send(c)},add:function(a,b,c,d){for(var e=$iq({type:"set"}).c("query",{xmlns:Strophe.NS.ROSTER}).c("item",{jid:a,name:b}),f=0;f<c.length;f++)e.c("group").t(c[f]).up();this._connection.sendIQ(e,d,d)},update:function(a,b,c,d){var e=this.findItem(a);if(!e)throw"item not found";for(var f=b||e.name,g=c||e.groups,h=$iq({type:"set"}).c("query",{xmlns:Strophe.NS.ROSTER}).c("item",{jid:e.jid,name:f}),i=0;i<g.length;i++)h.c("group").t(g[i]).up();return this._connection.sendIQ(h,d,d)},remove:function(a,b){var c=this.findItem(a);if(!c)throw"item not found";var d=$iq({type:"set"}).c("query",{xmlns:Strophe.NS.ROSTER}).c("item",{jid:c.jid,subscription:"remove"});this._connection.sendIQ(d,b,b)},_onReceiveRosterSuccess:function(a,b){this._updateItems(b),this._call_backs(this.items),"function"==typeof a&&a(this.items)},_onReceiveRosterError:function(a,b){a(this.items)},_onReceivePresence:function(a){var b=a.getAttribute("from"),c=Strophe.getBareJidFromJid(b),d=this.findItem(c),e=a.getAttribute("type");if(!d)return"subscribe"===e&&this._call_backs_request(c),!0;if("unavailable"==e)delete d.resources[Strophe.getResourceFromJid(b)];else{if(e)return!0;d.resources[Strophe.getResourceFromJid(b)]={show:0!==a.getElementsByTagName("show").length?Strophe.getText(a.getElementsByTagName("show")[0]):"",status:0!==a.getElementsByTagName("status").length?Strophe.getText(a.getElementsByTagName("status")[0]):"",priority:0!==a.getElementsByTagName("priority").length?Strophe.getText(a.getElementsByTagName("priority")[0]):""}}return this._call_backs(this.items,d),!0},_call_backs_request:function(a){for(var b=0;b<this._callbacks_request.length;b++)this._callbacks_request[b](a)},_call_backs:function(a,b,c){for(var d=0;d<this._callbacks.length;d++)this._callbacks[d](a,b,c)},_onReceiveIQ:function(a){var b=a.getA