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

sendbird

Package Overview
Dependencies
Maintainers
1
Versions
226
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sendbird - npm Package Compare versions

Comparing version 2.4.9 to 2.4.10

2

bower.json
{
"name": "sendbird",
"version": "2.4.9",
"version": "2.4.10",
"authors": [

@@ -5,0 +5,0 @@ "SendBird <support@sendbird.com>"

@@ -5,3 +5,3 @@ Changelog

## v2.4.9
## v2.4.10

@@ -8,0 +8,0 @@ ### update

{
"name": "sendbird",
"version": "2.4.9",
"version": "2.4.10",
"description": "SendBird JavaScript SDK",

@@ -5,0 +5,0 @@ "main": "SendBird.min.js",

@@ -30,3 +30,3 @@ SendBird-SDK-JavaScript

## Upgrading to v2.4.9
## Upgrading to v2.4.10
If you want to check the record of other version, go to [Change Log](https://github.com/smilefam/SendBird-SDK-JavaScript/blob/master/CHANGELOG.md).

@@ -33,0 +33,0 @@

/**
* SendBird JavaScript SDK v2.4.9
* SendBird JavaScript SDK v2.4.10
*/
var _isLeavingPage=!1;"object"==typeof window&&(window.onbeforeunload=function(){_isLeavingPage=!0}),function(e,n){"function"==typeof define&&define.amd?define([],n().getInstance()):"object"==typeof exports?module.exports=n().getInstance():(e.SB=n(),e.sendbird=e.SB.getInstance())}(this,function(){function e(){var e=navigator.userAgent.toLowerCase();return-1!=e.indexOf("msie")?parseInt(e.split("msie")[1]):!1}function n(n,t,s,i,r,a){var u=new XMLHttpRequest,g=e();if(!("withCredentials"in u)&&g&&10>g){u=new XDomainRequest,u.withCredentials=!0;try{switch(s.toLowerCase()){case"get":u.open("GET",n);break;default:u.open("POST",n)}}catch(p){u.open("POST",n)}for(var d in i)t[d]=i[d];u.onload=function(){var e=JSON.parse(u.responseText);e.error?a(u.status,u.statusText):r(e)},u.onerror=function(){a(404,"There was a connection error")}}else{try{switch(u=new XMLHttpRequest,s.toLowerCase()){case"get":u.open("GET",n);break;default:u.open("POST",n)}u.onload=function(){if(u.status>=o&&u.status<c){var e=u.responseText;r(JSON.parse(e))}else a(u.status,u.statusText)},u.onerror=function(){a(404,"There was a connection error")}}catch(f){u=new ActiveXObject("Microsoft.XMLHTTP");try{switch(s.toLowerCase()){case"get":u.open("GET",n);break;default:u.open("POST",n)}}catch(p){u.open("POST",n)}u.onreadystatechange=function(){if(4==u.readyState)if(u.status>=o&&u.status<c){var e=u.responseText;r(JSON.parse(e))}else a(u.status,u.statusText)}}u.setRequestHeader("Content-Type","text/plain; charset=UTF-8");for(var d in i)u.setRequestHeader(d,i[d])}switch(s.toLowerCase()){case"get":u.send();break;default:u.send(JSON.stringify(t))}}var t=!1,s=!1,i=window.console||{log:function(){}},r=function(e){t&&i.log(e)},a=function(e){e=e||{};for(var n=arguments.length,t=1;n>t;t++)if(arguments[t])for(var s in arguments[t])arguments[t].hasOwnProperty(s)&&(e[s]=arguments[t][s]);return e};"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});var o=200,c=400,u=function(){function e(){var e=new g;return e}var n,t=function(t){var s=a({},{newInstance:!1},t);return s.newInstance?e():(n||(n=e()),n)};return{getInstance:t}}(),g=function(){function e(e){return u(_+k.app_id),p+"v"+l.replace(/[^(0-9)]/gi,"")+"/"+e}function i(e){return u(_+k.app_id),p+"v3/"+e}function u(e,t,s){if(f)d="ws://localtest.me:9000",p="http://api.localtest.me:8000/","function"==typeof t&&t();else{var i=(new Date).getTime()/1e3;0==C||C-i>3?n(e,{},"GET",{SendBird:S+k.app_id},function(e){d=e.ws_server,p=e.api_server+"/",r("Routing Info Update: "+d+", "+p),C=i,"function"==typeof t&&t()},function(e,n){"function"==typeof s&&s(e,n)}):"function"==typeof t&&t()}}function g(e){k.app_id=e.app_id,k.guest_id=e.guest_id,k.user_name=e.user_name,k.image_url=void 0==e.image_url||null==e.image_url?"":e.image_url,k.access_token=void 0==e.access_token||null==e.access_token?"":e.access_token,G({successFunc:function(n){e.successFunc(n)},errorFunc:function(n,t){e.errorFunc(n,t)},async:e.async})}var p,d,f=!1,l="1",_="https://sbrouting.sendbird.com/app/",m="2.4.9",v="/?p=JS&pv="+encodeURI(navigator.userAgent)+"&sv="+m+"&ai=",S="JS,"+encodeURI(navigator.userAgent)+","+m+",",y=null,h={MESG:"MESG",FILE:"FILE",LOGI:"LOGI",JOIN:"JOIN",SYSM:"SYSM",BRDM:"BRDM",MCUP:"MCUP",READ:"READ",TPST:"TPST",TPEN:"TPEN",BAAN:"BAAN",FREZ:"FREZ",PING:"PING",PONG:"PONG"},k={},F={},T=0,M=0,O=null,P=null,R=null,w=0,N=!1,b=0,I=1e4,C=0,L=function(e,n){switch(e){case h.MESG:B.onMessageReceived(JSON.parse(n));break;case h.SYSM:B.onSystemMessageReceived(JSON.parse(n));break;case h.FILE:B.onFileMessageReceived(JSON.parse(n));break;case h.BRDM:B.onBroadcastMessageReceived(JSON.parse(n));break;case h.TPST:B.onTypeStartReceived(JSON.parse(n));break;case h.TPEN:B.onTypeEndReceived(JSON.parse(n));break;case h.PONG:r(h.PONG);break;case h.READ:B.onReadReceived(JSON.parse(n));break;case h.BAAN:B.onBanReceived(JSON.parse(n));break;case h.FREZ:var t=JSON.parse(n),s=!1;try{s=t.freeze}catch(i){s=!1}F.data=JSON.stringify({freeze:s}),B.onChannelFreezeReceived(t);break;default:B.onUndefinedMessageReceived(e,JSON.parse(n))}return JSON.parse(n)},E={successFunc:function(e){},errorFunc:function(e,n){r(e),r(n)}},B={onMessageReceived:function(e){r(e)},onSystemMessageReceived:function(e){r(e)},onFileMessageReceived:function(e){r(e)},onBroadcastMessageReceived:function(e){r(e)},onReadReceived:function(e){r(e)},onMessagingChannelUpdateReceived:function(e){r(e)},onTypeStartReceived:function(e){r(e)},onTypeEndReceived:function(e){r(e)},onMessageDelivery:function(e){r(e)},onBanReceived:function(e){r(e)},onChannelFreezeReceived:function(e){r(e)},onUndefinedMessageReceived:function(e,n){r(e),r(n)}},J=6,D=5,G=function(t){r("=== Start SendBird SDK ===");var s=a({},E,t),i="guest_login/",c={guest_id:k.guest_id,app_id:k.app_id,nickname:k.user_name,image_url:k.image_url,access_token:k.access_token};void 0!=k.gcm_reg_token&&""!=k.gcm_reg_token&&(c.gcm_reg_token=k.gcm_reg_token),void 0!=k.apns_device_token&&""!=k.apns_device_token&&(c.apns_device_token=k.apns_device_token),u(_+k.app_id,function(){n(e(i),c,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(o,e.message):(k.guest_key=e.key,s.successFunc({}))},function(e,n){s.errorFunc(e,n)})},function(e,n){s.errorFunc(e,n)})},A=function(t,s){r("=== Join Channel ===");var i=a({},E,s),c="channel_join/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:t},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(e.isMessaging=!1,a(F,e),g=F,i.successFunc(g))},function(e,n){i.errorFunc(e,n)})},x=function(t,s){r("=== Leave Channel ===");var i=a({},E,s),c="channel_leave",u={app_id:k.app_id,session_key:k.guest_key,channel_url:t},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(g=e,i.successFunc(g))},function(e,n){i.errorFunc(e,n)})},U=function(t,s){r("=== Member List ===");var i=a({},E,s),c="member_list/",u={app_id:k.app_id,channel_url:t},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(g=e,i.successFunc(g))},function(e,n){i.errorFunc(e,n)})},W=function(t){r("=== Channel List ==="),t=a({},{limit:20,page:1,query:""},t);var s=a({},E,t),i="channel_list/",c={app_id:k.app_id,page:s.page,limit:s.limit,query:s.query},u={};n(e(i),c,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(o,e.message):(u=e,s.successFunc(u))},function(e,n){s.errorFunc(e,n)})},z=function(e){W(e)},j=function(e){return void 0!=e.last_message&&""!=e.last_message&&(e.last_message=JSON.parse(e.last_message.substring(4))),e},q=function(t,s){r("=== Join Messaging Channel ===");var i=a({},E,s),c="messaging_join/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:t},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(e.channel.isMessaging=!0,a(F,e.channel),g=e,i.successFunc(j(g)))},function(e,n){i.errorFunc(e,n)})},H=function(t,s){r("=== Start Messaging ==="),t=t instanceof Array?t:new Array(t);var i=a({},E,s),c="messaging_start/",u={app_id:k.app_id,session_key:k.guest_key,guest_ids:t},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(a(F,e.channel),g=e,i.successFunc(j(g)))},function(e,n){i.errorFunc(e,n)})},X=function(e,n,t){if(2==arguments.length){var s=arguments[1].channel_url;(void 0==s||""==s)&&(s=F.channel_url),Y(arguments[0],s,arguments[1])}else Y(e,n,t)},Y=function(t,s,i){r("=== Invite Messaging ==="),t=t instanceof Array?t:new Array(t);var c=a({},E,i),u="messaging_invite/",g={app_id:k.app_id,session_key:k.guest_key,channel_url:s,guest_ids:t},p={};n(e(u),g,"POST",{SendBird:S+k.app_id},function(e){e.error?c.errorFunc(o,e.message):(a(F,e.channel),p=e,c.successFunc(j(p)))},function(e,n){c.errorFunc(e,n)})},Z=function(t,s){r("=== End Messaging ===");var i=a({},E,s),c="messaging_end/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:t},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(a(F,e),g=e,i.successFunc(j(g)))},function(e,n){i.errorFunc(e,n)})},K=function(t){r("=== Messaging Channel List ==="),t=a({},{limit:9999,page:1},t);var s=a({},E,t),i="messaging_list/",c={app_id:k.app_id,session_key:k.guest_key,page:s.page,limit:s.limit},u={};n(e(i),c,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(o,e.message):(u=e,u.channels.forEach(function(e,n){e=j(e)}),s.successFunc(u))},function(e,n){s.errorFunc(e,n)})},$=function(e){r("=== Messaging Channel List ==="),e=a({},{limit:9999,page:1},e);var t=a({},E,e),s="messaging_list/",c={app_id:k.app_id,session_key:k.guest_key,page:t.page,limit:t.limit},u={};n(i(s),c,"POST",{SendBird:S+k.app_id},function(e){e.error?t.errorFunc(o,e.message):(u=e,u.channels.forEach(function(e,n){e=j(e)}),t.successFunc(u))},function(e,n){t.errorFunc(e,n)})},Q=function(t,s){r("=== Messaging Channel Info ===");var i=a({},E,s),c="messaging_info/",u={app_id:k.app_id,session_key:k.guest_key,channel_id:t};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):B.onMessagingChannelUpdateReceived(j(e))},function(e,n){i.errorFunc(e,n)})},V=function(t,s){r("=== Message Mark As Read ===");var i=a({},E,s),c="mark_as_read/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:t},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(g=e,i.successFunc(g))},function(e,n){i.errorFunc(e,n)})},ee=function(t){r("=== Message Load More ==="),t=a({},{limit:20},t);var s=a({},E,t),i=(new Date).getTime(),c="message_list",u={app_id:k.app_id,session_key:k.guest_key,channel_url:F.channel_url,message_ts:0==M?i:M,prev_limit:s.limit,next_limit:0,include:!1},g=[];n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(o,e.message):(e.messages.forEach(function(e,n){var t=JSON.parse(e.substring(4));0==M?M=t.ts:M>t.ts&&(M=t.ts),g.push(Fe(e))}),s.successFunc({messages:g}))},function(e,n){s.errorFunc(e,n)})},ne=function(t){r("=== User List ==="),t=a({},{token:"",page:1,limit:30},t);var s=a({},E,t),i="user_list/",c={app_id:k.app_id,session_key:k.guest_key,token:s.token,page:s.page,limit:s.limit};n(e(i),c,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(o,e.message):s.successFunc(e)},function(e,n){s.errorFunc(e,n)})},te=function(e,n){r("=== Upload File ===");var t=a({},E,n),s="upload_file/",i='{"app_id": "'+k.app_id+'"}',u=new FormData;u.append("meta",i),u.append("file",e);var g="",d=p+"v"+l.replace(/[^(0-9)]/gi,"")+"/"+s,f=void 0==t.async?!0:t.async,_=new XMLHttpRequest;_.open("POST",d,f),_.onload=function(){if(_.status>=o&&_.status<c){var n=_.responseText,s=JSON.parse(n);s.error?t.errorFunc(o,s.message):(g={error:!1,url:s.url},he({url:s.url,name:e.name,type:e.type,size:e.size,custom:""}),t.successFunc(g))}else t.errorFunc(_.status,_.statusText)},_.send(u)},se=function(){r("=== Typing Start ===");var e=(new Date).getTime();de(h.TPST,{channel_id:F.id,time:e}),b=e,N=!0},ie=function(){r("=== Typing End ===");var e=(new Date).getTime();de(h.TPEN,{channel_id:F.id,time:e}),b=0,N=!1},re=(setInterval(function(){var e=(new Date).getTime();N&&e-b>I&&ie()},I),function(t,s){r("=== Delete Message ===");var i=a({},E,s),c="message_delete/",u={app_id:k.app_id,session_key:k.guest_key,msg_id:t};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):i.successFunc(e)},function(e,n){i.errorFunc(e,n)})}),ae=function(e){r("=== Web Socket Connect ==="),ge();var n=a({},E,e);y=new WebSocket(d+v+k.app_id+"&key="+k.guest_key),y.onopen=function(e){fe(k.guest_key);var t=(new Date).getTime();if(void 0===F.id||le(F.id,t)){var s={};n.successFunc(s)}else n.errorFunc(c,"WebSocket is not connected yet.");me(!0)},y.onmessage=function(e){T=(new Date).getTime();for(var n=e.data.split("\n"),t=0;t<n.length;t++)if(0!=n[t].trim().length){var s=n[t].substring(0,4),i=n[t].substring(4);if(0!==s.trim().length||0!==i.trim().length)if(s===h.PONG)ve(!1);else if(s==h.MCUP){var r=JSON.parse(i);Q(r.channel_id)}else L(s,i)}},y.onerror=function(e){r("=== Web Socket onerror ==="),r(e),_isLeavingPage||ce(),me(!1),ve(!1)},y.onclose=function(e){r("=== Web Socket onclose ==="),r(e),_isLeavingPage||ce(),me(!1),ve(!1)}},oe=function(e){s="undefined"==typeof e?!0:e,r("=== Web Socket Disconnect ==="),ue()},ce=function(){s||(null==R?(r("=== Start Reconnect ==="),R=setTimeout(function(){ae(),R=null,r("=== Reconnect done ===")},3e3)):r("=== Reconnect is in progress. (skip) ==="))},ue=function(){y&&ge(),F={},M=0,O=null,P=null,R=null,w=0},ge=function(){y&&(y.close(),y.onmessage=function(e){},y.onopen=function(e){},y.onerror=function(e){},y.onclose=function(e){},y=null),M=0},pe=function(){return y?y.readyState:WebSocket.CLOSED},de=function(e,n){var t=e+JSON.stringify(n)+"\n";try{if(1!=y.readyState)return!1;y.send(t)}catch(s){return r(s),!1}return!0},fe=function(e){de(h.LOGI,{key:e})},le=function(e,n){return de(h.JOIN,{channel_id:e,last_ts:n})},_e=function(){var e=(new Date).getTime();w=e,de(h.PING,{id:e})},me=function(e){null!=O&&(clearInterval(O),O=null),e?(r("=== Start Pinger ==="),O=setInterval(function(){var e=(new Date).getTime(),n=e-T,t=parseInt(n/1e3);t>0&&t%15==0&&(r(h.PING),_e(),ve(!0))},1e3)):r("=== Stop Pinger ===")},ve=function(e){null!=P&&(clearInterval(P),P=null),e?(r("=== Start Watchdog ==="),P=setInterval(function(){var e=(new Date).getTime(),n=e-T,t=parseInt(n/1e3);t>=20&&(r("=== Watchdog Barks! ==="),me(!1),ce())},4500)):r("=== Watchdog ===")},Se=function(e,n){"string"!=typeof e&&(e=e.toString()),n=n||"","string"!=typeof n&&(n=n.toString());var t=de(h.MESG,{channel_id:F.id,message:e,data:"",tid:n});B.onMessageDelivery({sent:t,message:e,data:"",id:n}),t&&F.isMessaging&&setTimeout(function(){ie()},100)},ye=function(e,n,t){"string"!=typeof e&&(e=e.toString()),t=t||"","string"!=typeof t&&(t=t.toString());var s=de(h.MESG,{channel_id:F.id,message:e,data:n,tid:t});B.onMessageDelivery({sent:s,message:e,data:n,tid:t}),s&&F.isMessaging&&setTimeout(function(){ie()},100)},he=function(e){de(h.FILE,{channel_id:F.id,name:e.name,url:e.url,type:e.type,size:e.size,custom:e.custom})},ke=function(e){t=e},Fe=function(e){var n=e.substring(0,4),t=JSON.parse(e.substring(4));return{cmd:n,payload:t}},Te=function(e){return e==h.MESG},Me=function(e){return e==h.FILE},Oe=function(e){var n=e.url.split("."),t=n[n.length-1];return"png"==t||"jpeg"==t||"jpg"==t||"gif"==t||"bmp"==t?!0:e.type.indexOf("image")>=0},Pe=function(e){return e==J},Re=function(e){return e==D},we=function(e){var n=!1;try{n=JSON.parse(F.data).freeze}catch(t){n=!1}e({channel_url:F.channel_url,cover_img_url:F.cover_img_url,member_count:F.member_count,name:F.name,isMessaging:F.isMessaging,max_length_message:F.max_length_message,freeze:n})},Ne=function(e){e({guest_id:k.guest_id,image_url:k.image_url,nickname:k.user_name})},be=function(e){k.gcm_reg_token=e},Ie=function(e){k.apns_device_token=e},Ce="[version] "+m,Le=function(e){M="string"==typeof e?parseInt(e):e};return{version:Ce,events:B,joinChannel:A,leaveChannel:x,getMemberList:U,getChannelSearch:W,getChannelList:z,joinMessagingChannel:q,startMessaging:H,inviteMessaging:X,endMessaging:Z,getMessagingChannelList:K,getPrivateChannelList:$,markAsRead:V,getMessageLoadMore:ee,getUserList:ne,sendFile:te,typeStart:se,typeEnd:ie,deleteMessage:re,connect:ae,disconnect:oe,message:Se,messageWithData:ye,sendFileURL:he,setDebugMessage:ke,isMessage:Te,isFileMessage:Me,hasImage:Oe,isGroupMessaging:Pe,isGroupMessagingChannel:Pe,isMessagingChannel:Re,getChannelInfo:we,getUserInfo:Ne,getConnectionState:pe,registerGCMToken:be,registerAPNSToken:Ie,init:g,setMinMessageTs:Le}};return u});
var _isLeavingPage=!1;"object"==typeof window&&(window.onbeforeunload=function(){_isLeavingPage=!0}),function(e,n){"function"==typeof define&&define.amd?define([],n().getInstance()):"object"==typeof exports?module.exports=n().getInstance():(e.SB=n(),e.sendbird=e.SB.getInstance())}(this,function(){function e(){try{if("undefined"==typeof navigator||"undefined"==typeof navigator.userAgent)return!1;var e=navigator.userAgent.toLowerCase();return-1!=e.indexOf("msie")?parseInt(e.split("msie")[1]):!1}catch(n){return!1}}function n(n,t,s,i,r,a){var u=new XMLHttpRequest,g=e();if(!("withCredentials"in u)&&g&&10>g){u=new XDomainRequest,u.withCredentials=!0;try{switch(s.toLowerCase()){case"get":u.open("GET",n);break;default:u.open("POST",n)}}catch(d){u.open("POST",n)}for(var p in i)t[p]=i[p];u.onload=function(){var e=JSON.parse(u.responseText);e.error?a(u.status,u.statusText):r(e)},u.onerror=function(){a(404,"There was a connection error")}}else{try{switch(u=new XMLHttpRequest,s.toLowerCase()){case"get":u.open("GET",n);break;default:u.open("POST",n)}u.onload=function(){if(u.status>=o&&u.status<c){var e=u.responseText;r(JSON.parse(e))}else a(u.status,u.statusText)},u.onerror=function(){a(404,"There was a connection error")}}catch(f){u=new ActiveXObject("Microsoft.XMLHTTP");try{switch(s.toLowerCase()){case"get":u.open("GET",n);break;default:u.open("POST",n)}}catch(d){u.open("POST",n)}u.onreadystatechange=function(){if(4==u.readyState)if(u.status>=o&&u.status<c){var e=u.responseText;r(JSON.parse(e))}else a(u.status,u.statusText)}}u.setRequestHeader("Content-Type","text/plain; charset=UTF-8");for(var p in i)u.setRequestHeader(p,i[p])}switch(s.toLowerCase()){case"get":u.send();break;default:u.send(JSON.stringify(t))}}var t=!1,s=!1,i=window.console||{log:function(){}},r=function(e){t&&i.log(e)},a=function(e){e=e||{};for(var n=arguments.length,t=1;n>t;t++)if(arguments[t])for(var s in arguments[t])arguments[t].hasOwnProperty(s)&&(e[s]=arguments[t][s]);return e};"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});var o=200,c=400,u=function(){function e(){var e=new g;return e}var n,t=function(t){var s=a({},{newInstance:!1},t);return s.newInstance?e():(n||(n=e()),n)};return{getInstance:t}}(),g=function(){function e(e){return u(_+k.app_id),d+"v"+l.replace(/[^(0-9)]/gi,"")+"/"+e}function i(e){return u(_+k.app_id),d+"v3/"+e}function u(e,t,s){if(f)p="ws://localtest.me:9000",d="http://api.localtest.me:8000/","function"==typeof t&&t();else{var i=(new Date).getTime()/1e3;0==C||C-i>3?n(e,{},"GET",{SendBird:S+k.app_id},function(e){p=e.ws_server,d=e.api_server+"/",r("Routing Info Update: "+p+", "+d),C=i,"function"==typeof t&&t()},function(e,n){"function"==typeof s&&s(e,n)}):"function"==typeof t&&t()}}function g(e){k.app_id=e.app_id,k.guest_id=e.guest_id,k.user_name=e.user_name,k.image_url=void 0==e.image_url||null==e.image_url?"":e.image_url,k.access_token=void 0==e.access_token||null==e.access_token?"":e.access_token,G({successFunc:function(n){e.successFunc(n)},errorFunc:function(n,t){e.errorFunc(n,t)},async:e.async})}var d,p,f=!1,l="1",_="https://sbrouting.sendbird.com/app/",m="2.4.10",v="/?p=JS&pv="+encodeURI(navigator.userAgent)+"&sv="+m+"&ai=",S="JS,"+encodeURI(navigator.userAgent)+","+m+",",y=null,h={MESG:"MESG",FILE:"FILE",LOGI:"LOGI",JOIN:"JOIN",SYSM:"SYSM",BRDM:"BRDM",MCUP:"MCUP",READ:"READ",TPST:"TPST",TPEN:"TPEN",BAAN:"BAAN",FREZ:"FREZ",PING:"PING",PONG:"PONG"},k={},F={},T=0,M=0,O=null,P=null,R=null,w=0,N=!1,b=0,I=1e4,C=0,L=function(e,n){switch(e){case h.MESG:B.onMessageReceived(JSON.parse(n));break;case h.SYSM:B.onSystemMessageReceived(JSON.parse(n));break;case h.FILE:B.onFileMessageReceived(JSON.parse(n));break;case h.BRDM:B.onBroadcastMessageReceived(JSON.parse(n));break;case h.TPST:B.onTypeStartReceived(JSON.parse(n));break;case h.TPEN:B.onTypeEndReceived(JSON.parse(n));break;case h.PONG:r(h.PONG);break;case h.READ:B.onReadReceived(JSON.parse(n));break;case h.BAAN:B.onBanReceived(JSON.parse(n));break;case h.FREZ:var t=JSON.parse(n),s=!1;try{s=t.freeze}catch(i){s=!1}F.data=JSON.stringify({freeze:s}),B.onChannelFreezeReceived(t);break;default:B.onUndefinedMessageReceived(e,JSON.parse(n))}return JSON.parse(n)},E={successFunc:function(e){},errorFunc:function(e,n){r(e),r(n)}},B={onMessageReceived:function(e){r(e)},onSystemMessageReceived:function(e){r(e)},onFileMessageReceived:function(e){r(e)},onBroadcastMessageReceived:function(e){r(e)},onReadReceived:function(e){r(e)},onMessagingChannelUpdateReceived:function(e){r(e)},onTypeStartReceived:function(e){r(e)},onTypeEndReceived:function(e){r(e)},onMessageDelivery:function(e){r(e)},onBanReceived:function(e){r(e)},onChannelFreezeReceived:function(e){r(e)},onUndefinedMessageReceived:function(e,n){r(e),r(n)}},J=6,D=5,G=function(t){r("=== Start SendBird SDK ===");var s=a({},E,t),i="guest_login/",c={guest_id:k.guest_id,app_id:k.app_id,nickname:k.user_name,image_url:k.image_url,access_token:k.access_token};void 0!=k.gcm_reg_token&&""!=k.gcm_reg_token&&(c.gcm_reg_token=k.gcm_reg_token),void 0!=k.apns_device_token&&""!=k.apns_device_token&&(c.apns_device_token=k.apns_device_token),u(_+k.app_id,function(){n(e(i),c,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(o,e.message):(k.guest_key=e.key,s.successFunc({}))},function(e,n){s.errorFunc(e,n)})},function(e,n){s.errorFunc(e,n)})},A=function(t,s){r("=== Join Channel ===");var i=a({},E,s),c="channel_join/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:t},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(e.isMessaging=!1,a(F,e),g=F,i.successFunc(g))},function(e,n){i.errorFunc(e,n)})},x=function(t,s){r("=== Leave Channel ===");var i=a({},E,s),c="channel_leave",u={app_id:k.app_id,session_key:k.guest_key,channel_url:t},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(g=e,i.successFunc(g))},function(e,n){i.errorFunc(e,n)})},U=function(t,s){r("=== Member List ===");var i=a({},E,s),c="member_list/",u={app_id:k.app_id,channel_url:t},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(g=e,i.successFunc(g))},function(e,n){i.errorFunc(e,n)})},W=function(t){r("=== Channel List ==="),t=a({},{limit:20,page:1,query:""},t);var s=a({},E,t),i="channel_list/",c={app_id:k.app_id,page:s.page,limit:s.limit,query:s.query},u={};n(e(i),c,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(o,e.message):(u=e,s.successFunc(u))},function(e,n){s.errorFunc(e,n)})},z=function(e){W(e)},j=function(e){return void 0!=e.last_message&&""!=e.last_message&&(e.last_message=JSON.parse(e.last_message.substring(4))),e},q=function(t,s){r("=== Join Messaging Channel ===");var i=a({},E,s),c="messaging_join/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:t},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(e.channel.isMessaging=!0,a(F,e.channel),g=e,i.successFunc(j(g)))},function(e,n){i.errorFunc(e,n)})},H=function(t,s){r("=== Start Messaging ==="),t=t instanceof Array?t:new Array(t);var i=a({},E,s),c="messaging_start/",u={app_id:k.app_id,session_key:k.guest_key,guest_ids:t},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(a(F,e.channel),g=e,i.successFunc(j(g)))},function(e,n){i.errorFunc(e,n)})},X=function(e,n,t){if(2==arguments.length){var s=arguments[1].channel_url;(void 0==s||""==s)&&(s=F.channel_url),Y(arguments[0],s,arguments[1])}else Y(e,n,t)},Y=function(t,s,i){r("=== Invite Messaging ==="),t=t instanceof Array?t:new Array(t);var c=a({},E,i),u="messaging_invite/",g={app_id:k.app_id,session_key:k.guest_key,channel_url:s,guest_ids:t},d={};n(e(u),g,"POST",{SendBird:S+k.app_id},function(e){e.error?c.errorFunc(o,e.message):(a(F,e.channel),d=e,c.successFunc(j(d)))},function(e,n){c.errorFunc(e,n)})},Z=function(t,s){r("=== End Messaging ===");var i=a({},E,s),c="messaging_end/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:t},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(a(F,e),g=e,i.successFunc(j(g)))},function(e,n){i.errorFunc(e,n)})},K=function(t){r("=== Messaging Channel List ==="),t=a({},{limit:9999,page:1},t);var s=a({},E,t),i="messaging_list/",c={app_id:k.app_id,session_key:k.guest_key,page:s.page,limit:s.limit},u={};n(e(i),c,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(o,e.message):(u=e,u.channels.forEach(function(e,n){e=j(e)}),s.successFunc(u))},function(e,n){s.errorFunc(e,n)})},$=function(e){r("=== Messaging Channel List ==="),e=a({},{limit:9999,page:1},e);var t=a({},E,e),s="messaging_list/",c={app_id:k.app_id,session_key:k.guest_key,page:t.page,limit:t.limit},u={};n(i(s),c,"POST",{SendBird:S+k.app_id},function(e){e.error?t.errorFunc(o,e.message):(u=e,u.channels.forEach(function(e,n){e=j(e)}),t.successFunc(u))},function(e,n){t.errorFunc(e,n)})},Q=function(t,s){r("=== Messaging Channel Info ===");var i=a({},E,s),c="messaging_info/",u={app_id:k.app_id,session_key:k.guest_key,channel_id:t};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):B.onMessagingChannelUpdateReceived(j(e))},function(e,n){i.errorFunc(e,n)})},V=function(t,s){r("=== Message Mark As Read ===");var i=a({},E,s),c="mark_as_read/",u={app_id:k.app_id,session_key:k.guest_key,channel_url:t},g={};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):(g=e,i.successFunc(g))},function(e,n){i.errorFunc(e,n)})},ee=function(t){r("=== Message Load More ==="),t=a({},{limit:20},t);var s=a({},E,t),i=(new Date).getTime(),c="message_list",u={app_id:k.app_id,session_key:k.guest_key,channel_url:F.channel_url,message_ts:0==M?i:M,prev_limit:s.limit,next_limit:0,include:!1},g=[];n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(o,e.message):(e.messages.forEach(function(e,n){var t=JSON.parse(e.substring(4));0==M?M=t.ts:M>t.ts&&(M=t.ts),g.push(Fe(e))}),s.successFunc({messages:g}))},function(e,n){s.errorFunc(e,n)})},ne=function(t){r("=== User List ==="),t=a({},{token:"",page:1,limit:30},t);var s=a({},E,t),i="user_list/",c={app_id:k.app_id,session_key:k.guest_key,token:s.token,page:s.page,limit:s.limit};n(e(i),c,"POST",{SendBird:S+k.app_id},function(e){e.error?s.errorFunc(o,e.message):s.successFunc(e)},function(e,n){s.errorFunc(e,n)})},te=function(e,n){r("=== Upload File ===");var t=a({},E,n),s="upload_file/",i='{"app_id": "'+k.app_id+'"}',u=new FormData;u.append("meta",i),u.append("file",e);var g="",p=d+"v"+l.replace(/[^(0-9)]/gi,"")+"/"+s,f=void 0==t.async?!0:t.async,_=new XMLHttpRequest;_.open("POST",p,f),_.onload=function(){if(_.status>=o&&_.status<c){var n=_.responseText,s=JSON.parse(n);s.error?t.errorFunc(o,s.message):(g={error:!1,url:s.url},he({url:s.url,name:e.name,type:e.type,size:e.size,custom:""}),t.successFunc(g))}else t.errorFunc(_.status,_.statusText)},_.send(u)},se=function(){r("=== Typing Start ===");var e=(new Date).getTime();pe(h.TPST,{channel_id:F.id,time:e}),b=e,N=!0},ie=function(){r("=== Typing End ===");var e=(new Date).getTime();pe(h.TPEN,{channel_id:F.id,time:e}),b=0,N=!1},re=(setInterval(function(){var e=(new Date).getTime();N&&e-b>I&&ie()},I),function(t,s){r("=== Delete Message ===");var i=a({},E,s),c="message_delete/",u={app_id:k.app_id,session_key:k.guest_key,msg_id:t};n(e(c),u,"POST",{SendBird:S+k.app_id},function(e){e.error?i.errorFunc(o,e.message):i.successFunc(e)},function(e,n){i.errorFunc(e,n)})}),ae=function(e){r("=== Web Socket Connect ==="),ge();var n=a({},E,e);y=new WebSocket(p+v+k.app_id+"&key="+k.guest_key),y.onopen=function(e){fe(k.guest_key);var t=(new Date).getTime();if(void 0===F.id||le(F.id,t)){var s={};n.successFunc(s)}else n.errorFunc(c,"WebSocket is not connected yet.");me(!0)},y.onmessage=function(e){T=(new Date).getTime();for(var n=e.data.split("\n"),t=0;t<n.length;t++)if(0!=n[t].trim().length){var s=n[t].substring(0,4),i=n[t].substring(4);if(0!==s.trim().length||0!==i.trim().length)if(s===h.PONG)ve(!1);else if(s==h.MCUP){var r=JSON.parse(i);Q(r.channel_id)}else L(s,i)}},y.onerror=function(e){r("=== Web Socket onerror ==="),r(e),_isLeavingPage||ce(),me(!1),ve(!1)},y.onclose=function(e){r("=== Web Socket onclose ==="),r(e),_isLeavingPage||ce(),me(!1),ve(!1)}},oe=function(e){s="undefined"==typeof e?!0:e,r("=== Web Socket Disconnect ==="),ue()},ce=function(){s||(null==R?(r("=== Start Reconnect ==="),R=setTimeout(function(){ae(),R=null,r("=== Reconnect done ===")},3e3)):r("=== Reconnect is in progress. (skip) ==="))},ue=function(){y&&ge(),F={},M=0,O=null,P=null,R=null,w=0},ge=function(){y&&(y.close(),y.onmessage=function(e){},y.onopen=function(e){},y.onerror=function(e){},y.onclose=function(e){},y=null),M=0},de=function(){return y?y.readyState:WebSocket.CLOSED},pe=function(e,n){var t=e+JSON.stringify(n)+"\n";try{if(1!=y.readyState)return!1;y.send(t)}catch(s){return r(s),!1}return!0},fe=function(e){pe(h.LOGI,{key:e})},le=function(e,n){return pe(h.JOIN,{channel_id:e,last_ts:n})},_e=function(){var e=(new Date).getTime();w=e,pe(h.PING,{id:e})},me=function(e){null!=O&&(clearInterval(O),O=null),e?(r("=== Start Pinger ==="),O=setInterval(function(){var e=(new Date).getTime(),n=e-T,t=parseInt(n/1e3);t>0&&t%15==0&&(r(h.PING),_e(),ve(!0))},1e3)):r("=== Stop Pinger ===")},ve=function(e){null!=P&&(clearInterval(P),P=null),e?(r("=== Start Watchdog ==="),P=setInterval(function(){var e=(new Date).getTime(),n=e-T,t=parseInt(n/1e3);t>=20&&(r("=== Watchdog Barks! ==="),me(!1),ce())},4500)):r("=== Watchdog ===")},Se=function(e,n){"string"!=typeof e&&(e=e.toString()),n=n||"","string"!=typeof n&&(n=n.toString());var t=pe(h.MESG,{channel_id:F.id,message:e,data:"",tid:n});B.onMessageDelivery({sent:t,message:e,data:"",id:n}),t&&F.isMessaging&&setTimeout(function(){ie()},100)},ye=function(e,n,t){"string"!=typeof e&&(e=e.toString()),t=t||"","string"!=typeof t&&(t=t.toString());var s=pe(h.MESG,{channel_id:F.id,message:e,data:n,tid:t});B.onMessageDelivery({sent:s,message:e,data:n,tid:t}),s&&F.isMessaging&&setTimeout(function(){ie()},100)},he=function(e){pe(h.FILE,{channel_id:F.id,name:e.name,url:e.url,type:e.type,size:e.size,custom:e.custom})},ke=function(e){t=e},Fe=function(e){var n=e.substring(0,4),t=JSON.parse(e.substring(4));return{cmd:n,payload:t}},Te=function(e){return e==h.MESG},Me=function(e){return e==h.FILE},Oe=function(e){var n=e.url.split("."),t=n[n.length-1];return"png"==t||"jpeg"==t||"jpg"==t||"gif"==t||"bmp"==t?!0:e.type.indexOf("image")>=0},Pe=function(e){return e==J},Re=function(e){return e==D},we=function(e){var n=!1;try{n=JSON.parse(F.data).freeze}catch(t){n=!1}e({channel_url:F.channel_url,cover_img_url:F.cover_img_url,member_count:F.member_count,name:F.name,isMessaging:F.isMessaging,max_length_message:F.max_length_message,freeze:n})},Ne=function(e){e({guest_id:k.guest_id,image_url:k.image_url,nickname:k.user_name})},be=function(e){k.gcm_reg_token=e},Ie=function(e){k.apns_device_token=e},Ce="[version] "+m,Le=function(e){M="string"==typeof e?parseInt(e):e};return{version:Ce,events:B,joinChannel:A,leaveChannel:x,getMemberList:U,getChannelSearch:W,getChannelList:z,joinMessagingChannel:q,startMessaging:H,inviteMessaging:X,endMessaging:Z,getMessagingChannelList:K,getPrivateChannelList:$,markAsRead:V,getMessageLoadMore:ee,getUserList:ne,sendFile:te,typeStart:se,typeEnd:ie,deleteMessage:re,connect:ae,disconnect:oe,message:Se,messageWithData:ye,sendFileURL:he,setDebugMessage:ke,isMessage:Te,isFileMessage:Me,hasImage:Oe,isGroupMessaging:Pe,isGroupMessagingChannel:Pe,isMessagingChannel:Re,getChannelInfo:we,getUserInfo:Ne,getConnectionState:de,registerGCMToken:be,registerAPNSToken:Ie,init:g,setMinMessageTs:Le}};return u});

Sorry, the diff of this file is not supported yet

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