agrasya-voice-sdk 1.0.29 → 1.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- 'use strict';function a0_0x473b(_0x4b418d,_0xacdec8){_0x4b418d=_0x4b418d-0x133;const _0x191d32=a0_0x191d();let _0x473b77=_0x191d32[_0x4b418d];return _0x473b77;}const a0_0x4b0eee=a0_0x473b;(function(_0x5cfa7f,_0x109407){const _0x4a0511=a0_0x473b,_0x451ee3=_0x5cfa7f();while(!![]){try{const _0x4bcd72=parseInt(_0x4a0511(0x162))/0x1*(-parseInt(_0x4a0511(0x17a))/0x2)+parseInt(_0x4a0511(0x183))/0x3+-parseInt(_0x4a0511(0x146))/0x4*(-parseInt(_0x4a0511(0x13e))/0x5)+parseInt(_0x4a0511(0x15d))/0x6+parseInt(_0x4a0511(0x195))/0x7+parseInt(_0x4a0511(0x18f))/0x8*(-parseInt(_0x4a0511(0x175))/0x9)+parseInt(_0x4a0511(0x169))/0xa*(parseInt(_0x4a0511(0x152))/0xb);if(_0x4bcd72===_0x109407)break;else _0x451ee3['push'](_0x451ee3['shift']());}catch(_0x16e1bb){_0x451ee3['push'](_0x451ee3['shift']());}}}(a0_0x191d,0x6239d));function a0_0x191d(){const _0x3f2df3=['session_ended','message','forEach','/v1/agrasya/client-token?language=','POST','878745iIXSQm','socket','getOwnPropertyDescriptor','getTracks','setupWebRTC','sessionId','hasOwnProperty','Minutes\x20left:\x20','setRemoteDescription','connected','default','http://localhost:4001','GET','100cydlMr','autoplay','model','stopTimer','initializeBackendSession','function','object','enumerable','10068UEIDqk','parse','audio','stringify','json','log','setStatus','onmessage','createOffer','/agrasya/connect','durationInterval','data','484SzUtZc','Failed\x20to\x20fetch\x20minutes\x20usage:\x20','SDP\x20exchange\x20failed:\x20','events','dataUrl','audioStream','success','disconnect','Failed\x20to\x20initialize\x20session:\x20','startTimer','getPrototypeOf','2573850MUoalL','startVoiceSession','dataChannel','__esModule','srcObject','167608XkwPgJ','ephKey','prototype','text','emit','streams','answer','51960sqCwcS','peerConnection','fetchMinutesUsage','create','Failed\x20to\x20fetch\x20minutes\x20usage','close','key\x20is\x20null\x20or\x20undefined.','debug','appendChild','setLocalDescription','/v1/agrasya/usage','exports','19098USjSun','error','baseUrl','catch','[AgrasyaSDK]','2hooWuZ','apiKey','callDuration','onCallDurationUpdate','socket.io-client','setupSocketListeners','cleanup','createElement','sdp','1386573pObCHj','addTrack','config','stopVoiceSession','oai-events','minutesLeft','statusText','join_session','application/json','createDataChannel','type','initializing','2736TDQPvi'];a0_0x191d=function(){return _0x3f2df3;};return a0_0x191d();}var __create=Object[a0_0x4b0eee(0x16c)],__defProp=Object['defineProperty'],__getOwnPropDesc=Object[a0_0x4b0eee(0x133)],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object[a0_0x4b0eee(0x15c)],__hasOwnProp=Object[a0_0x4b0eee(0x164)][a0_0x4b0eee(0x137)],__export=(_0x51c2d4,_0x230103)=>{for(var _0x12364d in _0x230103)__defProp(_0x51c2d4,_0x12364d,{'get':_0x230103[_0x12364d],'enumerable':!![]});},__copyProps=(_0x49da7f,_0x59a05c,_0x31d96f,_0x30e9d0)=>{const _0x594e88=a0_0x4b0eee;if(_0x59a05c&&typeof _0x59a05c===_0x594e88(0x144)||typeof _0x59a05c===_0x594e88(0x143)){for(let _0x1ad2c7 of __getOwnPropNames(_0x59a05c))if(!__hasOwnProp['call'](_0x49da7f,_0x1ad2c7)&&_0x1ad2c7!==_0x31d96f)__defProp(_0x49da7f,_0x1ad2c7,{'get':()=>_0x59a05c[_0x1ad2c7],'enumerable':!(_0x30e9d0=__getOwnPropDesc(_0x59a05c,_0x1ad2c7))||_0x30e9d0[_0x594e88(0x145)]});}return _0x49da7f;},__toESM=(_0x3841af,_0x5529c3,_0x224110)=>(_0x224110=_0x3841af!=null?__create(__getProtoOf(_0x3841af)):{},__copyProps(_0x5529c3||!_0x3841af||!_0x3841af['__esModule']?__defProp(_0x224110,a0_0x4b0eee(0x13b),{'value':_0x3841af,'enumerable':!![]}):_0x224110,_0x3841af)),__toCommonJS=_0x141168=>__copyProps(__defProp({},a0_0x4b0eee(0x160),{'value':!![]}),_0x141168),index_exports={};__export(index_exports,{'AgrasyaVoiceSDK':()=>AgrasyaVoiceSDK}),module[a0_0x4b0eee(0x174)]=__toCommonJS(index_exports);var import_socket=__toESM(require(a0_0x4b0eee(0x17e))),AgrasyaVoiceSDK=class{['config'];[a0_0x4b0eee(0x155)];[a0_0x4b0eee(0x16a)]=null;[a0_0x4b0eee(0x15f)]=null;[a0_0x4b0eee(0x157)]=null;[a0_0x4b0eee(0x196)]=null;[a0_0x4b0eee(0x136)]=null;[a0_0x4b0eee(0x163)]=null;[a0_0x4b0eee(0x156)]=null;[a0_0x4b0eee(0x140)]=null;[a0_0x4b0eee(0x17c)]=0x0;[a0_0x4b0eee(0x150)]=null;constructor(_0x2b1be8,_0x54a39b={}){const _0x21654b=a0_0x4b0eee;this['config']={'baseUrl':_0x21654b(0x13c),'language':'','debug':![],..._0x2b1be8},this['events']=_0x54a39b;}['log'](..._0x553c0c){const _0x1caeba=a0_0x4b0eee;this['config'][_0x1caeba(0x170)]&&console[_0x1caeba(0x14b)](_0x1caeba(0x179),..._0x553c0c);}[a0_0x4b0eee(0x14c)](_0x122589){this['events']['onStatusChange']?.(_0x122589);}[a0_0x4b0eee(0x15b)](){const _0x4e24ed=a0_0x4b0eee;this['callDuration']=0x0,this[_0x4e24ed(0x150)]=setInterval(()=>{const _0x5065b9=_0x4e24ed;this[_0x5065b9(0x17c)]+=0x1,this[_0x5065b9(0x155)][_0x5065b9(0x17d)]?.(this['callDuration']);},0x3e8);}[a0_0x4b0eee(0x141)](){const _0x2c479d=a0_0x4b0eee;this[_0x2c479d(0x150)]&&(clearInterval(this[_0x2c479d(0x150)]),this[_0x2c479d(0x150)]=null);}async[a0_0x4b0eee(0x142)](){const _0x3b52d1=a0_0x4b0eee,_0x1b8b3f=this[_0x3b52d1(0x185)][_0x3b52d1(0x177)]+_0x3b52d1(0x193)+this[_0x3b52d1(0x185)]['language'],_0x454440=await fetch(_0x1b8b3f,{'method':_0x3b52d1(0x13d),'headers':{'x-agrasya-client-api-key':this[_0x3b52d1(0x185)][_0x3b52d1(0x17b)],'Content-Type':'application/json'}});if(!_0x454440['ok']){const _0x1cca64=await _0x454440[_0x3b52d1(0x14a)]()[_0x3b52d1(0x178)](()=>({'message':_0x454440[_0x3b52d1(0x189)]}));throw new Error(_0x3b52d1(0x15a)+(_0x1cca64[_0x3b52d1(0x191)]||_0x454440[_0x3b52d1(0x189)]));}const _0x1dacb0=await _0x454440[_0x3b52d1(0x14a)]();if(!_0x1dacb0['success'])throw new Error(_0x1dacb0[_0x3b52d1(0x191)]||'Backend\x20initialization\x20failed');return _0x1dacb0[_0x3b52d1(0x151)];}async[a0_0x4b0eee(0x135)](_0x296984){const _0xc7f871=a0_0x4b0eee;this[_0xc7f871(0x16a)]=new RTCPeerConnection(),this[_0xc7f871(0x15f)]=this[_0xc7f871(0x16a)][_0xc7f871(0x18c)](_0xc7f871(0x187));this[_0xc7f871(0x15f)]&&(this[_0xc7f871(0x15f)][_0xc7f871(0x14d)]=_0x35b47a=>{const _0x2c70bb=_0xc7f871,_0x32448a=JSON[_0x2c70bb(0x147)](_0x35b47a[_0x2c70bb(0x151)]);this[_0x2c70bb(0x155)]['onTranscript']?.(_0x32448a);});this['peerConnection']['ontrack']=_0x3edc0f=>{const _0x5ab90f=_0xc7f871,_0x32c0e9=document[_0x5ab90f(0x181)](_0x5ab90f(0x148));_0x32c0e9[_0x5ab90f(0x161)]=_0x3edc0f[_0x5ab90f(0x167)][0x0],_0x32c0e9[_0x5ab90f(0x13f)]=!![],document['body'][_0x5ab90f(0x171)](_0x32c0e9);},this[_0xc7f871(0x157)]=await navigator['mediaDevices']['getUserMedia']({'audio':!![]});if(this[_0xc7f871(0x157)]){const _0x15de96=this[_0xc7f871(0x157)][_0xc7f871(0x134)]()[0x0];this[_0xc7f871(0x16a)][_0xc7f871(0x184)](_0x15de96,this['audioStream']);}const _0x195533=await this[_0xc7f871(0x16a)][_0xc7f871(0x14e)]();await this[_0xc7f871(0x16a)][_0xc7f871(0x172)](_0x195533);const _0x406797=this[_0xc7f871(0x185)][_0xc7f871(0x177)]+_0xc7f871(0x14f),_0x320c71=await fetch(_0x406797,{'method':_0xc7f871(0x194),'body':JSON[_0xc7f871(0x149)]({'sessionId':this[_0xc7f871(0x136)],'sdp':_0x195533[_0xc7f871(0x182)]}),'headers':{'x-agrasya-client-api-key':this[_0xc7f871(0x185)][_0xc7f871(0x17b)],'Content-Type':_0xc7f871(0x18b)}});if(!_0x320c71['ok'])throw new Error(_0xc7f871(0x154)+_0x320c71['statusText']);const _0xd6e0dc={'type':_0xc7f871(0x168),'sdp':await _0x320c71[_0xc7f871(0x165)]()},_0x512651={'type':_0xd6e0dc[_0xc7f871(0x18d)],'sdp':_0xd6e0dc[_0xc7f871(0x182)]};await this[_0xc7f871(0x16a)][_0xc7f871(0x139)](_0x512651);}['setupSocketListeners'](_0x2e252d){const _0x109a1c=a0_0x4b0eee;_0x2e252d['on'](_0x109a1c(0x159),()=>{const _0x54a33b=_0x109a1c;this[_0x54a33b(0x180)]();}),_0x2e252d['on'](_0x109a1c(0x190),()=>{this['cleanup']();});}async[a0_0x4b0eee(0x15e)](_0x53084d){const _0x1ab448=a0_0x4b0eee;try{this['setStatus'](_0x1ab448(0x18e));const _0x4ace87=await this['initializeBackendSession']();this[_0x1ab448(0x136)]=_0x4ace87[_0x1ab448(0x136)],this[_0x1ab448(0x163)]=_0x4ace87[_0x1ab448(0x163)];if(!this[_0x1ab448(0x163)])throw new Error(_0x1ab448(0x16f));const _0x2d9d2c=await this[_0x1ab448(0x16b)]();this[_0x1ab448(0x14b)](_0x1ab448(0x138)+_0x2d9d2c),await this[_0x1ab448(0x135)](this['ephKey']),this[_0x1ab448(0x196)]=(0x0,import_socket[_0x1ab448(0x13b)])(this[_0x1ab448(0x185)][_0x1ab448(0x177)],{'transports':['websocket']}),this[_0x1ab448(0x196)][_0x1ab448(0x166)](_0x1ab448(0x18a),{'sessionId':this[_0x1ab448(0x136)]}),this[_0x1ab448(0x17f)](this[_0x1ab448(0x196)]),this['setStatus'](_0x1ab448(0x13a)),this[_0x1ab448(0x15b)]();}catch(_0x37e6b7){this[_0x1ab448(0x14c)](_0x1ab448(0x176));throw _0x37e6b7;}}async[a0_0x4b0eee(0x186)](){const _0x55b2d4=a0_0x4b0eee;this[_0x55b2d4(0x180)]();}[a0_0x4b0eee(0x180)](){const _0x1a31e7=a0_0x4b0eee;this[_0x1a31e7(0x16a)]&&(this[_0x1a31e7(0x16a)]['close'](),this[_0x1a31e7(0x16a)]=null),this[_0x1a31e7(0x15f)]&&(this[_0x1a31e7(0x15f)][_0x1a31e7(0x16e)](),this[_0x1a31e7(0x15f)]=null),this[_0x1a31e7(0x157)]&&(this[_0x1a31e7(0x157)][_0x1a31e7(0x134)]()[_0x1a31e7(0x192)](_0x1927ac=>_0x1927ac['stop']()),this[_0x1a31e7(0x157)]=null),this[_0x1a31e7(0x196)]&&(this[_0x1a31e7(0x196)][_0x1a31e7(0x159)](),this[_0x1a31e7(0x196)]=null),this[_0x1a31e7(0x141)](),this[_0x1a31e7(0x14c)]('idle');}async[a0_0x4b0eee(0x16b)](){const _0x213862=a0_0x4b0eee,_0x266ecd=this[_0x213862(0x185)][_0x213862(0x177)]+_0x213862(0x173),_0x270a00=await fetch(_0x266ecd,{'method':_0x213862(0x13d),'headers':{'x-agrasya-client-api-key':this[_0x213862(0x185)][_0x213862(0x17b)],'Content-Type':_0x213862(0x18b)}});if(!_0x270a00['ok']){const _0x423837=await _0x270a00[_0x213862(0x14a)]()[_0x213862(0x178)](()=>({'message':_0x270a00['statusText']}));throw new Error(_0x213862(0x153)+(_0x423837[_0x213862(0x191)]||_0x270a00[_0x213862(0x189)]));}const _0x38d0d4=await _0x270a00['json']();if(!_0x38d0d4[_0x213862(0x158)])throw new Error(_0x38d0d4['message']||_0x213862(0x16d));return _0x38d0d4[_0x213862(0x151)][_0x213862(0x188)];}};0x0&&(module['exports']={'AgrasyaVoiceSDK':AgrasyaVoiceSDK});
1
+ 'use strict';const a0_0xa582e2=a0_0x48eb;function a0_0x48eb(_0xbc7851,_0x9c76a5){_0xbc7851=_0xbc7851-0x1ba;const _0x14e474=a0_0x14e4();let _0x48eb55=_0x14e474[_0xbc7851];return _0x48eb55;}(function(_0xbbdb20,_0x2e7693){const _0x59a2dc=a0_0x48eb,_0xcc53fd=_0xbbdb20();while(!![]){try{const _0x2b42c9=parseInt(_0x59a2dc(0x1f8))/0x1+-parseInt(_0x59a2dc(0x215))/0x2*(parseInt(_0x59a2dc(0x1c5))/0x3)+-parseInt(_0x59a2dc(0x214))/0x4*(-parseInt(_0x59a2dc(0x1e7))/0x5)+-parseInt(_0x59a2dc(0x1fd))/0x6*(parseInt(_0x59a2dc(0x204))/0x7)+parseInt(_0x59a2dc(0x1c6))/0x8*(-parseInt(_0x59a2dc(0x207))/0x9)+parseInt(_0x59a2dc(0x1ba))/0xa*(parseInt(_0x59a2dc(0x202))/0xb)+parseInt(_0x59a2dc(0x1d8))/0xc*(-parseInt(_0x59a2dc(0x213))/0xd);if(_0x2b42c9===_0x2e7693)break;else _0xcc53fd['push'](_0xcc53fd['shift']());}catch(_0x2d8388){_0xcc53fd['push'](_0xcc53fd['shift']());}}}(a0_0x14e4,0x704f3));function a0_0x14e4(){const _0x13159c=['setupWebRTC','text','key\x20is\x20null\x20or\x20undefined.','prototype','initializeBackendSession','setLocalDescription','createDataChannel','dataChannel','901585GWugbm','session_ended','/v1/agrasya/connect','fetchMinutesUsage','success','134586WOkelK','getPrototypeOf','apiKey','Failed\x20to\x20initialize\x20session:\x20','onmessage','1793voHYlN','srcObject','70doTCqa','default','baseUrl','18216SMkdbF','stopVoiceSession','setStatus','answer','body','disconnect','initializing','statusText','sessionId','POST','data','join_session','23777sOMljY','8hovCfR','6418RQSGAV','parse','oai-events','application/json','error','addTrack','2960xiVIaM','message','createOffer','defineProperty','create','cleanup','sdp','socket.io-client','audioStream','ephKey','getTracks','21KDEYEx','608erbxaU','emit','durationInterval','mediaDevices','GET','config','debug','setupSocketListeners','type','idle','exports','log','setRemoteDescription','http://localhost:4001','createElement','events','hasOwnProperty','minutesLeft','4908FmRtOI','Backend\x20initialization\x20failed','Failed\x20to\x20fetch\x20minutes\x20usage:\x20','callDuration','stringify','autoplay','appendChild','dataUrl','ontrack','getOwnPropertyNames','socket','function','getUserMedia','/v1/agrasya/usage','json','1647110oPQcrI','stopTimer','peerConnection','__esModule','close','model','audio','/v1/agrasya/client-token?language=','streams'];a0_0x14e4=function(){return _0x13159c;};return a0_0x14e4();}var __create=Object[a0_0xa582e2(0x1be)],__defProp=Object[a0_0xa582e2(0x1bd)],__getOwnPropDesc=Object['getOwnPropertyDescriptor'],__getOwnPropNames=Object[a0_0xa582e2(0x1e1)],__getProtoOf=Object[a0_0xa582e2(0x1fe)],__hasOwnProp=Object[a0_0xa582e2(0x1f3)][a0_0xa582e2(0x1d6)],__export=(_0x140def,_0x1fc01b)=>{for(var _0x2d5404 in _0x1fc01b)__defProp(_0x140def,_0x2d5404,{'get':_0x1fc01b[_0x2d5404],'enumerable':!![]});},__copyProps=(_0xb0b648,_0x2001fc,_0x2e4239,_0x408bb9)=>{const _0x1a5d69=a0_0xa582e2;if(_0x2001fc&&typeof _0x2001fc==='object'||typeof _0x2001fc===_0x1a5d69(0x1e3)){for(let _0x149f70 of __getOwnPropNames(_0x2001fc))if(!__hasOwnProp['call'](_0xb0b648,_0x149f70)&&_0x149f70!==_0x2e4239)__defProp(_0xb0b648,_0x149f70,{'get':()=>_0x2001fc[_0x149f70],'enumerable':!(_0x408bb9=__getOwnPropDesc(_0x2001fc,_0x149f70))||_0x408bb9['enumerable']});}return _0xb0b648;},__toESM=(_0x3f8440,_0x5585f0,_0x56a80d)=>(_0x56a80d=_0x3f8440!=null?__create(__getProtoOf(_0x3f8440)):{},__copyProps(_0x5585f0||!_0x3f8440||!_0x3f8440['__esModule']?__defProp(_0x56a80d,'default',{'value':_0x3f8440,'enumerable':!![]}):_0x56a80d,_0x3f8440)),__toCommonJS=_0x1b67a5=>__copyProps(__defProp({},a0_0xa582e2(0x1ea),{'value':!![]}),_0x1b67a5),index_exports={};__export(index_exports,{'AgrasyaVoiceSDK':()=>AgrasyaVoiceSDK}),module[a0_0xa582e2(0x1d0)]=__toCommonJS(index_exports);var import_socket=__toESM(require(a0_0xa582e2(0x1c1))),AgrasyaVoiceSDK=class{['config'];[a0_0xa582e2(0x1d5)];[a0_0xa582e2(0x1e9)]=null;['dataChannel']=null;[a0_0xa582e2(0x1c2)]=null;['socket']=null;['sessionId']=null;[a0_0xa582e2(0x1c3)]=null;[a0_0xa582e2(0x1df)]=null;[a0_0xa582e2(0x1ec)]=null;['callDuration']=0x0;[a0_0xa582e2(0x1c8)]=null;constructor(_0x5d20db,_0x27a276={}){const _0x2cfea4=a0_0xa582e2;this['config']={'baseUrl':_0x2cfea4(0x1d3),'language':'','debug':![],..._0x5d20db},this['events']=_0x27a276;}[a0_0xa582e2(0x1d1)](..._0x5f103e){const _0x3c01ca=a0_0xa582e2;this[_0x3c01ca(0x1cb)][_0x3c01ca(0x1cc)]&&console['log']('[AgrasyaSDK]',..._0x5f103e);}['setStatus'](_0x5d3c2c){const _0x3766bf=a0_0xa582e2;this[_0x3766bf(0x1d5)]['onStatusChange']?.(_0x5d3c2c);}['startTimer'](){const _0x43f47b=a0_0xa582e2;this[_0x43f47b(0x1db)]=0x0,this[_0x43f47b(0x1c8)]=setInterval(()=>{const _0x487d62=_0x43f47b;this[_0x487d62(0x1db)]+=0x1,this[_0x487d62(0x1d5)]['onCallDurationUpdate']?.(this[_0x487d62(0x1db)]);},0x3e8);}[a0_0xa582e2(0x1e8)](){const _0x2fa50d=a0_0xa582e2;this[_0x2fa50d(0x1c8)]&&(clearInterval(this[_0x2fa50d(0x1c8)]),this['durationInterval']=null);}async[a0_0xa582e2(0x1f4)](){const _0x530740=a0_0xa582e2,_0x43f55a=this[_0x530740(0x1cb)][_0x530740(0x206)]+_0x530740(0x1ee)+this[_0x530740(0x1cb)]['language'],_0x3a795b=await fetch(_0x43f55a,{'method':'GET','headers':{'x-agrasya-client-api-key':this['config'][_0x530740(0x1ff)],'Content-Type':_0x530740(0x218)}});if(!_0x3a795b['ok']){const _0x50ca4e=await _0x3a795b[_0x530740(0x1e6)]()['catch'](()=>({'message':_0x3a795b[_0x530740(0x20e)]}));throw new Error(_0x530740(0x200)+(_0x50ca4e[_0x530740(0x1bb)]||_0x3a795b[_0x530740(0x20e)]));}const _0x2120b4=await _0x3a795b[_0x530740(0x1e6)]();if(!_0x2120b4['success'])throw new Error(_0x2120b4[_0x530740(0x1bb)]||_0x530740(0x1d9));return _0x2120b4['data'];}async['setupWebRTC'](_0x473485){const _0x5c8f47=a0_0xa582e2;this[_0x5c8f47(0x1e9)]=new RTCPeerConnection(),this[_0x5c8f47(0x1f7)]=this[_0x5c8f47(0x1e9)][_0x5c8f47(0x1f6)](_0x5c8f47(0x217));this[_0x5c8f47(0x1f7)]&&(this[_0x5c8f47(0x1f7)][_0x5c8f47(0x201)]=_0x17f471=>{const _0x248c47=_0x5c8f47,_0x20a33b=JSON[_0x248c47(0x216)](_0x17f471[_0x248c47(0x211)]);this['events']['onTranscript']?.(_0x20a33b);});this['peerConnection'][_0x5c8f47(0x1e0)]=_0x4b8df3=>{const _0x3ea09a=_0x5c8f47,_0x40398d=document[_0x3ea09a(0x1d4)](_0x3ea09a(0x1ed));_0x40398d[_0x3ea09a(0x203)]=_0x4b8df3[_0x3ea09a(0x1ef)][0x0],_0x40398d[_0x3ea09a(0x1dd)]=!![],document[_0x3ea09a(0x20b)][_0x3ea09a(0x1de)](_0x40398d);},this[_0x5c8f47(0x1c2)]=await navigator[_0x5c8f47(0x1c9)][_0x5c8f47(0x1e4)]({'audio':!![]});if(this['audioStream']){const _0x4fbcfe=this[_0x5c8f47(0x1c2)][_0x5c8f47(0x1c4)]()[0x0];this[_0x5c8f47(0x1e9)][_0x5c8f47(0x21a)](_0x4fbcfe,this[_0x5c8f47(0x1c2)]);}const _0x54cfb3=await this[_0x5c8f47(0x1e9)][_0x5c8f47(0x1bc)]();await this[_0x5c8f47(0x1e9)][_0x5c8f47(0x1f5)](_0x54cfb3);const _0xadaa55=this['config'][_0x5c8f47(0x206)]+_0x5c8f47(0x1fa),_0x54c9ac=await fetch(_0xadaa55,{'method':_0x5c8f47(0x210),'body':JSON[_0x5c8f47(0x1dc)]({'sessionId':this[_0x5c8f47(0x20f)],'sdp':_0x54cfb3[_0x5c8f47(0x1c0)]}),'headers':{'x-agrasya-client-api-key':this[_0x5c8f47(0x1cb)][_0x5c8f47(0x1ff)],'Content-Type':_0x5c8f47(0x218)}});if(!_0x54c9ac['ok'])throw new Error('SDP\x20exchange\x20failed:\x20'+_0x54c9ac[_0x5c8f47(0x20e)]);const _0x5a596b={'type':_0x5c8f47(0x20a),'sdp':await _0x54c9ac[_0x5c8f47(0x1f1)]()},_0xa7d79c={'type':_0x5a596b[_0x5c8f47(0x1ce)],'sdp':_0x5a596b[_0x5c8f47(0x1c0)]};await this[_0x5c8f47(0x1e9)][_0x5c8f47(0x1d2)](_0xa7d79c);}['setupSocketListeners'](_0x4d70cb){const _0x470035=a0_0xa582e2;_0x4d70cb['on'](_0x470035(0x20c),()=>{const _0x4c1f79=_0x470035;this[_0x4c1f79(0x1bf)]();}),_0x4d70cb['on'](_0x470035(0x1f9),()=>{const _0x3fc1eb=_0x470035;this[_0x3fc1eb(0x1bf)]();});}async['startVoiceSession'](_0xa46916){const _0x5cf6e=a0_0xa582e2;try{this[_0x5cf6e(0x209)](_0x5cf6e(0x20d));const _0x5637c9=await this[_0x5cf6e(0x1f4)]();this[_0x5cf6e(0x20f)]=_0x5637c9['sessionId'],this['ephKey']=_0x5637c9['ephKey'];if(!this[_0x5cf6e(0x1c3)])throw new Error(_0x5cf6e(0x1f2));const _0x228b5f=await this[_0x5cf6e(0x1fb)]();this[_0x5cf6e(0x1d1)]('Minutes\x20left:\x20'+_0x228b5f),await this[_0x5cf6e(0x1f0)](this[_0x5cf6e(0x1c3)]),this[_0x5cf6e(0x1e2)]=(0x0,import_socket[_0x5cf6e(0x205)])(this[_0x5cf6e(0x1cb)][_0x5cf6e(0x206)],{'transports':['websocket']}),this['socket'][_0x5cf6e(0x1c7)](_0x5cf6e(0x212),{'sessionId':this[_0x5cf6e(0x20f)]}),this[_0x5cf6e(0x1cd)](this['socket']),this[_0x5cf6e(0x209)]('connected'),this['startTimer']();}catch(_0x168aa6){this[_0x5cf6e(0x209)](_0x5cf6e(0x219));throw _0x168aa6;}}async[a0_0xa582e2(0x208)](){this['cleanup']();}[a0_0xa582e2(0x1bf)](){const _0x4c88d7=a0_0xa582e2;this[_0x4c88d7(0x1e9)]&&(this[_0x4c88d7(0x1e9)][_0x4c88d7(0x1eb)](),this['peerConnection']=null),this[_0x4c88d7(0x1f7)]&&(this[_0x4c88d7(0x1f7)][_0x4c88d7(0x1eb)](),this[_0x4c88d7(0x1f7)]=null),this[_0x4c88d7(0x1c2)]&&(this[_0x4c88d7(0x1c2)][_0x4c88d7(0x1c4)]()['forEach'](_0x4cafca=>_0x4cafca['stop']()),this[_0x4c88d7(0x1c2)]=null),this[_0x4c88d7(0x1e2)]&&(this['socket'][_0x4c88d7(0x20c)](),this[_0x4c88d7(0x1e2)]=null),this[_0x4c88d7(0x1e8)](),this['setStatus'](_0x4c88d7(0x1cf));}async[a0_0xa582e2(0x1fb)](){const _0x5d4645=a0_0xa582e2,_0x40791a=this[_0x5d4645(0x1cb)][_0x5d4645(0x206)]+_0x5d4645(0x1e5),_0x6ccefd=await fetch(_0x40791a,{'method':_0x5d4645(0x1ca),'headers':{'x-agrasya-client-api-key':this[_0x5d4645(0x1cb)][_0x5d4645(0x1ff)],'Content-Type':_0x5d4645(0x218)}});if(!_0x6ccefd['ok']){const _0x2f6fc7=await _0x6ccefd['json']()['catch'](()=>({'message':_0x6ccefd[_0x5d4645(0x20e)]}));throw new Error(_0x5d4645(0x1da)+(_0x2f6fc7[_0x5d4645(0x1bb)]||_0x6ccefd[_0x5d4645(0x20e)]));}const _0x5df3ad=await _0x6ccefd[_0x5d4645(0x1e6)]();if(!_0x5df3ad[_0x5d4645(0x1fc)])throw new Error(_0x5df3ad['message']||'Failed\x20to\x20fetch\x20minutes\x20usage');return _0x5df3ad[_0x5d4645(0x211)][_0x5d4645(0x1d7)];}};0x0&&(module['exports']={'AgrasyaVoiceSDK':AgrasyaVoiceSDK});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- function a1_0x4333(){const _0x195abc=['startVoiceSession','cleanup','createDataChannel','390837zYmUKL','GET','srcObject','onCallDurationUpdate','Failed\x20to\x20fetch\x20minutes\x20usage','addTrack','message','forEach','error','statusText','Backend\x20initialization\x20failed','socket','9MQHBFI','592664zNqXOC','stopTimer','setLocalDescription','log','key\x20is\x20null\x20or\x20undefined.','http://localhost:4001','762FfKjxN','setStatus','dataUrl','2166106VlzfBl','dataChannel','data','ephKey','46735gegDkX','/agrasya/connect','Minutes\x20left:\x20','json','onTranscript','catch','stringify','2441194hZJYoi','setRemoteDescription','join_session','minutesLeft','text','getUserMedia','ontrack','baseUrl','1205404lfMgsQ','/v1/agrasya/usage','initializing','language','close','disconnect','callDuration','application/json','debug','success','answer','createOffer','events','audioStream','setupWebRTC','autoplay','mediaDevices','config','SDP\x20exchange\x20failed:\x20','initializeBackendSession','durationInterval','fetchMinutesUsage','apiKey','createElement','appendChild','sdp','POST','sessionId','stop','1495431XRhPnE','streams','startTimer','oai-events','body','Failed\x20to\x20fetch\x20minutes\x20usage:\x20','session_ended','[AgrasyaSDK]','peerConnection','setupSocketListeners','websocket'];a1_0x4333=function(){return _0x195abc;};return a1_0x4333();}const a1_0x26c0e4=a1_0x5de9;(function(_0xc3faee,_0x40f405){const _0x460112=a1_0x5de9,_0xf26bb2=_0xc3faee();while(!![]){try{const _0x5a8775=-parseInt(_0x460112(0x108))/0x1+parseInt(_0x460112(0x12c))/0x2+parseInt(_0x460112(0x116))/0x3+parseInt(_0x460112(0x13f))/0x4+-parseInt(_0x460112(0x130))/0x5*(-parseInt(_0x460112(0x129))/0x6)+-parseInt(_0x460112(0x137))/0x7+-parseInt(_0x460112(0x123))/0x8*(parseInt(_0x460112(0x122))/0x9);if(_0x5a8775===_0x40f405)break;else _0xf26bb2['push'](_0xf26bb2['shift']());}catch(_0xde5377){_0xf26bb2['push'](_0xf26bb2['shift']());}}}(a1_0x4333,0xbf488));import a1_0x12baa5 from'socket.io-client';var AgrasyaVoiceSDK=class{[a1_0x26c0e4(0xfc)];[a1_0x26c0e4(0x14b)];['peerConnection']=null;[a1_0x26c0e4(0x12d)]=null;[a1_0x26c0e4(0x14c)]=null;[a1_0x26c0e4(0x121)]=null;[a1_0x26c0e4(0x106)]=null;[a1_0x26c0e4(0x12f)]=null;[a1_0x26c0e4(0x12b)]=null;['model']=null;['callDuration']=0x0;[a1_0x26c0e4(0xff)]=null;constructor(_0x4c43d0,_0x8721bb={}){const _0x277da5=a1_0x26c0e4;this['config']={'baseUrl':_0x277da5(0x128),'language':'','debug':![],..._0x4c43d0},this[_0x277da5(0x14b)]=_0x8721bb;}[a1_0x26c0e4(0x126)](..._0x13ecb6){const _0x29003b=a1_0x26c0e4;this['config'][_0x29003b(0x147)]&&console[_0x29003b(0x126)](_0x29003b(0x10f),..._0x13ecb6);}[a1_0x26c0e4(0x12a)](_0x2095dc){const _0x948b77=a1_0x26c0e4;this[_0x948b77(0x14b)]['onStatusChange']?.(_0x2095dc);}[a1_0x26c0e4(0x10a)](){const _0x2e36d5=a1_0x26c0e4;this[_0x2e36d5(0x145)]=0x0,this[_0x2e36d5(0xff)]=setInterval(()=>{const _0x422aea=_0x2e36d5;this[_0x422aea(0x145)]+=0x1,this['events'][_0x422aea(0x119)]?.(this['callDuration']);},0x3e8);}[a1_0x26c0e4(0x124)](){const _0xb6db93=a1_0x26c0e4;this[_0xb6db93(0xff)]&&(clearInterval(this['durationInterval']),this[_0xb6db93(0xff)]=null);}async[a1_0x26c0e4(0xfe)](){const _0x4c166f=a1_0x26c0e4,_0x58639e=this[_0x4c166f(0xfc)][_0x4c166f(0x13e)]+'/v1/agrasya/client-token?language='+this[_0x4c166f(0xfc)][_0x4c166f(0x142)],_0x56789d=await fetch(_0x58639e,{'method':'GET','headers':{'x-agrasya-client-api-key':this[_0x4c166f(0xfc)][_0x4c166f(0x101)],'Content-Type':'application/json'}});if(!_0x56789d['ok']){const _0x470053=await _0x56789d['json']()[_0x4c166f(0x135)](()=>({'message':_0x56789d[_0x4c166f(0x11f)]}));throw new Error('Failed\x20to\x20initialize\x20session:\x20'+(_0x470053[_0x4c166f(0x11c)]||_0x56789d['statusText']));}const _0x5120c2=await _0x56789d[_0x4c166f(0x133)]();if(!_0x5120c2[_0x4c166f(0x148)])throw new Error(_0x5120c2[_0x4c166f(0x11c)]||_0x4c166f(0x120));return _0x5120c2[_0x4c166f(0x12e)];}async[a1_0x26c0e4(0x14d)](_0x354dd4){const _0x54b0cb=a1_0x26c0e4;this[_0x54b0cb(0x110)]=new RTCPeerConnection(),this[_0x54b0cb(0x12d)]=this['peerConnection'][_0x54b0cb(0x115)](_0x54b0cb(0x10b));this[_0x54b0cb(0x12d)]&&(this['dataChannel']['onmessage']=_0x5613e5=>{const _0x4a2fc0=_0x54b0cb,_0x26304c=JSON['parse'](_0x5613e5[_0x4a2fc0(0x12e)]);this[_0x4a2fc0(0x14b)][_0x4a2fc0(0x134)]?.(_0x26304c);});this[_0x54b0cb(0x110)][_0x54b0cb(0x13d)]=_0x3c814b=>{const _0x572370=_0x54b0cb,_0x5368fb=document[_0x572370(0x102)]('audio');_0x5368fb[_0x572370(0x118)]=_0x3c814b[_0x572370(0x109)][0x0],_0x5368fb[_0x572370(0xfa)]=!![],document[_0x572370(0x10c)][_0x572370(0x103)](_0x5368fb);},this['audioStream']=await navigator[_0x54b0cb(0xfb)][_0x54b0cb(0x13c)]({'audio':!![]});if(this[_0x54b0cb(0x14c)]){const _0x4101bc=this['audioStream']['getTracks']()[0x0];this['peerConnection'][_0x54b0cb(0x11b)](_0x4101bc,this['audioStream']);}const _0x42331b=await this[_0x54b0cb(0x110)][_0x54b0cb(0x14a)]();await this[_0x54b0cb(0x110)][_0x54b0cb(0x125)](_0x42331b);const _0x4e4958=this['config'][_0x54b0cb(0x13e)]+_0x54b0cb(0x131),_0x55d732=await fetch(_0x4e4958,{'method':_0x54b0cb(0x105),'body':JSON[_0x54b0cb(0x136)]({'sessionId':this[_0x54b0cb(0x106)],'sdp':_0x42331b[_0x54b0cb(0x104)]}),'headers':{'x-agrasya-client-api-key':this[_0x54b0cb(0xfc)][_0x54b0cb(0x101)],'Content-Type':'application/json'}});if(!_0x55d732['ok'])throw new Error(_0x54b0cb(0xfd)+_0x55d732[_0x54b0cb(0x11f)]);const _0x10cb77={'type':_0x54b0cb(0x149),'sdp':await _0x55d732[_0x54b0cb(0x13b)]()},_0x19cd01={'type':_0x10cb77['type'],'sdp':_0x10cb77['sdp']};await this['peerConnection'][_0x54b0cb(0x138)](_0x19cd01);}['setupSocketListeners'](_0x2db756){const _0x310eaf=a1_0x26c0e4;_0x2db756['on'](_0x310eaf(0x144),()=>{this['cleanup']();}),_0x2db756['on'](_0x310eaf(0x10e),()=>{const _0x19b98a=_0x310eaf;this[_0x19b98a(0x114)]();});}async[a1_0x26c0e4(0x113)](_0x1efeeb){const _0x1c8d55=a1_0x26c0e4;try{this['setStatus'](_0x1c8d55(0x141));const _0x23b44a=await this[_0x1c8d55(0xfe)]();this[_0x1c8d55(0x106)]=_0x23b44a['sessionId'],this['ephKey']=_0x23b44a[_0x1c8d55(0x12f)];if(!this[_0x1c8d55(0x12f)])throw new Error(_0x1c8d55(0x127));const _0x3f994c=await this[_0x1c8d55(0x100)]();this['log'](_0x1c8d55(0x132)+_0x3f994c),await this[_0x1c8d55(0x14d)](this['ephKey']),this['socket']=a1_0x12baa5(this[_0x1c8d55(0xfc)]['baseUrl'],{'transports':[_0x1c8d55(0x112)]}),this[_0x1c8d55(0x121)]['emit'](_0x1c8d55(0x139),{'sessionId':this['sessionId']}),this[_0x1c8d55(0x111)](this[_0x1c8d55(0x121)]),this[_0x1c8d55(0x12a)]('connected'),this[_0x1c8d55(0x10a)]();}catch(_0x8e620d){this['setStatus'](_0x1c8d55(0x11e));throw _0x8e620d;}}async['stopVoiceSession'](){this['cleanup']();}[a1_0x26c0e4(0x114)](){const _0x26de12=a1_0x26c0e4;this[_0x26de12(0x110)]&&(this[_0x26de12(0x110)][_0x26de12(0x143)](),this['peerConnection']=null),this[_0x26de12(0x12d)]&&(this[_0x26de12(0x12d)][_0x26de12(0x143)](),this[_0x26de12(0x12d)]=null),this[_0x26de12(0x14c)]&&(this[_0x26de12(0x14c)]['getTracks']()[_0x26de12(0x11d)](_0x10e163=>_0x10e163[_0x26de12(0x107)]()),this['audioStream']=null),this[_0x26de12(0x121)]&&(this[_0x26de12(0x121)][_0x26de12(0x144)](),this[_0x26de12(0x121)]=null),this[_0x26de12(0x124)](),this['setStatus']('idle');}async['fetchMinutesUsage'](){const _0x4098eb=a1_0x26c0e4,_0x4baa06=this['config'][_0x4098eb(0x13e)]+_0x4098eb(0x140),_0x33a978=await fetch(_0x4baa06,{'method':_0x4098eb(0x117),'headers':{'x-agrasya-client-api-key':this[_0x4098eb(0xfc)][_0x4098eb(0x101)],'Content-Type':_0x4098eb(0x146)}});if(!_0x33a978['ok']){const _0x3de784=await _0x33a978[_0x4098eb(0x133)]()[_0x4098eb(0x135)](()=>({'message':_0x33a978[_0x4098eb(0x11f)]}));throw new Error(_0x4098eb(0x10d)+(_0x3de784[_0x4098eb(0x11c)]||_0x33a978[_0x4098eb(0x11f)]));}const _0x201f4d=await _0x33a978[_0x4098eb(0x133)]();if(!_0x201f4d[_0x4098eb(0x148)])throw new Error(_0x201f4d[_0x4098eb(0x11c)]||_0x4098eb(0x11a));return _0x201f4d[_0x4098eb(0x12e)][_0x4098eb(0x13a)];}};function a1_0x5de9(_0x5f3998,_0x45211b){_0x5f3998=_0x5f3998-0xfa;const _0x433373=a1_0x4333();let _0x5de9b0=_0x433373[_0x5f3998];return _0x5de9b0;}export{AgrasyaVoiceSDK};
1
+ function a1_0xd835(_0x1e3c50,_0x337c69){_0x1e3c50=_0x1e3c50-0x102;const _0x39aab1=a1_0x39aa();let _0xd8353d=_0x39aab1[_0x1e3c50];return _0xd8353d;}const a1_0x41d950=a1_0xd835;(function(_0x5d51a5,_0x188c21){const _0x5af730=a1_0xd835,_0x1988a7=_0x5d51a5();while(!![]){try{const _0x515219=-parseInt(_0x5af730(0x116))/0x1*(-parseInt(_0x5af730(0x11a))/0x2)+parseInt(_0x5af730(0x10b))/0x3*(-parseInt(_0x5af730(0x106))/0x4)+-parseInt(_0x5af730(0x11e))/0x5*(parseInt(_0x5af730(0x11c))/0x6)+-parseInt(_0x5af730(0x13b))/0x7*(parseInt(_0x5af730(0x109))/0x8)+parseInt(_0x5af730(0x136))/0x9+-parseInt(_0x5af730(0x140))/0xa+parseInt(_0x5af730(0x137))/0xb*(parseInt(_0x5af730(0x132))/0xc);if(_0x515219===_0x188c21)break;else _0x1988a7['push'](_0x1988a7['shift']());}catch(_0x43e079){_0x1988a7['push'](_0x1988a7['shift']());}}}(a1_0x39aa,0xe823a));function a1_0x39aa(){const _0x1d1e13=['autoplay','36cidKwR','minutesLeft','154370cugRmM','stop','mediaDevices','setupSocketListeners','audio','baseUrl','dataUrl','sessionId','stopVoiceSession','apiKey','audioStream','/v1/agrasya/usage','error','dataChannel','srcObject','/v1/agrasya/connect','onStatusChange','ontrack','callDuration','emit','204wCDjzk','idle','json','close','5971797gtQRha','1877711KmCHgn','application/json','socket','connected','177982PUszeV','Failed\x20to\x20fetch\x20minutes\x20usage','startVoiceSession','sdp','streams','5648140trMjjv','addTrack','fetchMinutesUsage','createDataChannel','durationInterval','events','setStatus','startTimer','cleanup','log','answer','GET','peerConnection','debug','setLocalDescription','Failed\x20to\x20initialize\x20session:\x20','websocket','config','statusText','setupWebRTC','data','model','message','POST','key\x20is\x20null\x20or\x20undefined.','4jnWorP','stringify','initializing','512Nvefmy','type','4826937HpqPcI','ephKey','getTracks','forEach','http://localhost:4001','createOffer','stopTimer','disconnect','success','onTranscript','Minutes\x20left:\x20','159ufTmCB','onmessage','initializeBackendSession','catch','17254WevieP'];a1_0x39aa=function(){return _0x1d1e13;};return a1_0x39aa();}import a1_0x19e74a from'socket.io-client';var AgrasyaVoiceSDK=class{[a1_0x41d950(0x151)];['events'];[a1_0x41d950(0x14c)]=null;[a1_0x41d950(0x12b)]=null;['audioStream']=null;[a1_0x41d950(0x139)]=null;[a1_0x41d950(0x125)]=null;[a1_0x41d950(0x10c)]=null;[a1_0x41d950(0x124)]=null;[a1_0x41d950(0x102)]=null;['callDuration']=0x0;[a1_0x41d950(0x144)]=null;constructor(_0x58765f,_0x420180={}){const _0x4f345d=a1_0x41d950;this[_0x4f345d(0x151)]={'baseUrl':_0x4f345d(0x10f),'language':'','debug':![],..._0x58765f},this[_0x4f345d(0x145)]=_0x420180;}[a1_0x41d950(0x149)](..._0x45c973){const _0x40542f=a1_0x41d950;this[_0x40542f(0x151)][_0x40542f(0x14d)]&&console['log']('[AgrasyaSDK]',..._0x45c973);}['setStatus'](_0x517cb6){const _0x527f3b=a1_0x41d950;this[_0x527f3b(0x145)][_0x527f3b(0x12e)]?.(_0x517cb6);}[a1_0x41d950(0x147)](){const _0x51a551=a1_0x41d950;this[_0x51a551(0x130)]=0x0,this['durationInterval']=setInterval(()=>{const _0x2c0dd8=_0x51a551;this[_0x2c0dd8(0x130)]+=0x1,this['events']['onCallDurationUpdate']?.(this[_0x2c0dd8(0x130)]);},0x3e8);}[a1_0x41d950(0x111)](){const _0x4a30c8=a1_0x41d950;this[_0x4a30c8(0x144)]&&(clearInterval(this[_0x4a30c8(0x144)]),this[_0x4a30c8(0x144)]=null);}async[a1_0x41d950(0x118)](){const _0x750921=a1_0x41d950,_0x229371=this['config']['baseUrl']+'/v1/agrasya/client-token?language='+this[_0x750921(0x151)]['language'],_0x16d19d=await fetch(_0x229371,{'method':_0x750921(0x14b),'headers':{'x-agrasya-client-api-key':this[_0x750921(0x151)]['apiKey'],'Content-Type':_0x750921(0x138)}});if(!_0x16d19d['ok']){const _0x19f255=await _0x16d19d[_0x750921(0x134)]()[_0x750921(0x119)](()=>({'message':_0x16d19d[_0x750921(0x152)]}));throw new Error(_0x750921(0x14f)+(_0x19f255['message']||_0x16d19d[_0x750921(0x152)]));}const _0xe7838e=await _0x16d19d[_0x750921(0x134)]();if(!_0xe7838e[_0x750921(0x113)])throw new Error(_0xe7838e[_0x750921(0x103)]||'Backend\x20initialization\x20failed');return _0xe7838e['data'];}async['setupWebRTC'](_0x321af1){const _0x230d0=a1_0x41d950;this[_0x230d0(0x14c)]=new RTCPeerConnection(),this['dataChannel']=this[_0x230d0(0x14c)][_0x230d0(0x143)]('oai-events');this[_0x230d0(0x12b)]&&(this[_0x230d0(0x12b)][_0x230d0(0x117)]=_0x33bdd7=>{const _0x1a8006=_0x230d0,_0x5d82d4=JSON['parse'](_0x33bdd7[_0x1a8006(0x154)]);this['events'][_0x1a8006(0x114)]?.(_0x5d82d4);});this['peerConnection'][_0x230d0(0x12f)]=_0x32beb3=>{const _0x4121de=_0x230d0,_0x383b2c=document['createElement'](_0x4121de(0x122));_0x383b2c[_0x4121de(0x12c)]=_0x32beb3[_0x4121de(0x13f)][0x0],_0x383b2c[_0x4121de(0x11b)]=!![],document['body']['appendChild'](_0x383b2c);},this[_0x230d0(0x128)]=await navigator[_0x230d0(0x120)]['getUserMedia']({'audio':!![]});if(this[_0x230d0(0x128)]){const _0x483210=this[_0x230d0(0x128)][_0x230d0(0x10d)]()[0x0];this['peerConnection'][_0x230d0(0x141)](_0x483210,this[_0x230d0(0x128)]);}const _0x4903ce=await this['peerConnection'][_0x230d0(0x110)]();await this[_0x230d0(0x14c)][_0x230d0(0x14e)](_0x4903ce);const _0x3fedbc=this['config'][_0x230d0(0x123)]+_0x230d0(0x12d),_0x15e5e0=await fetch(_0x3fedbc,{'method':_0x230d0(0x104),'body':JSON[_0x230d0(0x107)]({'sessionId':this[_0x230d0(0x125)],'sdp':_0x4903ce[_0x230d0(0x13e)]}),'headers':{'x-agrasya-client-api-key':this[_0x230d0(0x151)]['apiKey'],'Content-Type':_0x230d0(0x138)}});if(!_0x15e5e0['ok'])throw new Error('SDP\x20exchange\x20failed:\x20'+_0x15e5e0['statusText']);const _0x5b5782={'type':_0x230d0(0x14a),'sdp':await _0x15e5e0['text']()},_0x4939ef={'type':_0x5b5782[_0x230d0(0x10a)],'sdp':_0x5b5782[_0x230d0(0x13e)]};await this[_0x230d0(0x14c)]['setRemoteDescription'](_0x4939ef);}[a1_0x41d950(0x121)](_0x4cc384){const _0xea81c2=a1_0x41d950;_0x4cc384['on'](_0xea81c2(0x112),()=>{const _0x21455c=_0xea81c2;this[_0x21455c(0x148)]();}),_0x4cc384['on']('session_ended',()=>{const _0x68a85b=_0xea81c2;this[_0x68a85b(0x148)]();});}async[a1_0x41d950(0x13d)](_0x7248de){const _0x4af00f=a1_0x41d950;try{this[_0x4af00f(0x146)](_0x4af00f(0x108));const _0x54ff32=await this[_0x4af00f(0x118)]();this[_0x4af00f(0x125)]=_0x54ff32[_0x4af00f(0x125)],this[_0x4af00f(0x10c)]=_0x54ff32[_0x4af00f(0x10c)];if(!this['ephKey'])throw new Error(_0x4af00f(0x105));const _0x4df3b1=await this[_0x4af00f(0x142)]();this[_0x4af00f(0x149)](_0x4af00f(0x115)+_0x4df3b1),await this[_0x4af00f(0x153)](this[_0x4af00f(0x10c)]),this[_0x4af00f(0x139)]=a1_0x19e74a(this['config'][_0x4af00f(0x123)],{'transports':[_0x4af00f(0x150)]}),this[_0x4af00f(0x139)][_0x4af00f(0x131)]('join_session',{'sessionId':this[_0x4af00f(0x125)]}),this['setupSocketListeners'](this[_0x4af00f(0x139)]),this['setStatus'](_0x4af00f(0x13a)),this['startTimer']();}catch(_0x31d71c){this[_0x4af00f(0x146)](_0x4af00f(0x12a));throw _0x31d71c;}}async[a1_0x41d950(0x126)](){const _0xc3c798=a1_0x41d950;this[_0xc3c798(0x148)]();}[a1_0x41d950(0x148)](){const _0x2021db=a1_0x41d950;this[_0x2021db(0x14c)]&&(this['peerConnection'][_0x2021db(0x135)](),this['peerConnection']=null),this[_0x2021db(0x12b)]&&(this[_0x2021db(0x12b)]['close'](),this[_0x2021db(0x12b)]=null),this[_0x2021db(0x128)]&&(this[_0x2021db(0x128)]['getTracks']()[_0x2021db(0x10e)](_0x221650=>_0x221650[_0x2021db(0x11f)]()),this[_0x2021db(0x128)]=null),this[_0x2021db(0x139)]&&(this['socket'][_0x2021db(0x112)](),this[_0x2021db(0x139)]=null),this[_0x2021db(0x111)](),this[_0x2021db(0x146)](_0x2021db(0x133));}async[a1_0x41d950(0x142)](){const _0x4dbcbe=a1_0x41d950,_0x2dd6c8=this[_0x4dbcbe(0x151)][_0x4dbcbe(0x123)]+_0x4dbcbe(0x129),_0x15838=await fetch(_0x2dd6c8,{'method':_0x4dbcbe(0x14b),'headers':{'x-agrasya-client-api-key':this[_0x4dbcbe(0x151)][_0x4dbcbe(0x127)],'Content-Type':'application/json'}});if(!_0x15838['ok']){const _0x283cd2=await _0x15838['json']()[_0x4dbcbe(0x119)](()=>({'message':_0x15838[_0x4dbcbe(0x152)]}));throw new Error('Failed\x20to\x20fetch\x20minutes\x20usage:\x20'+(_0x283cd2[_0x4dbcbe(0x103)]||_0x15838[_0x4dbcbe(0x152)]));}const _0x1366ae=await _0x15838[_0x4dbcbe(0x134)]();if(!_0x1366ae['success'])throw new Error(_0x1366ae[_0x4dbcbe(0x103)]||_0x4dbcbe(0x13c));return _0x1366ae['data'][_0x4dbcbe(0x11d)];}};export{AgrasyaVoiceSDK};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agrasya-voice-sdk",
3
- "version": "1.0.29",
3
+ "version": "1.0.30",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",