agrasya-voice-sdk 1.0.29 → 1.0.31

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_0x49183f=a0_0x394e;function a0_0x3ca8(){const _0x56f489=['onmessage','default','957VamGFy','10FonjLC','154MEGXpb','ontrack','message','cleanup','getPrototypeOf','prototype','events','1sWlvOa','create','onCallDurationUpdate','error','dataChannel','1654219trLFYc','createDataChannel','apiKey','315xjIjTM','/v1/agrasya/usage','addTrack','/v1/agrasya/connect','hasOwnProperty','getTracks','join_session','stopTimer','application/json','/v1/agrasya/client-token?language=','forEach','Failed\x20to\x20initialize\x20session:\x20','setStatus','http://localhost:4001','__esModule','172704FqOmKJ','close','success','socket','function','object','ephKey','websocket','setRemoteDescription','fetchMinutesUsage','log','getUserMedia','streams','model','durationInterval','oai-events','audioStream','8qDgYmM','Failed\x20to\x20fetch\x20minutes\x20usage:\x20','GET','initializeBackendSession','onStatusChange','POST','createOffer','startVoiceSession','catch','audio','3536322KOkMFI','text','sdp','statusText','25660EiBiim','1082406zWOFos','exports','connected','baseUrl','debug','setLocalDescription','json','key\x20is\x20null\x20or\x20undefined.','data','config','[AgrasyaSDK]','stopVoiceSession','getOwnPropertyNames','sessionId','1423821DGdTdE','mediaDevices','Minutes\x20left:\x20','startTimer','callDuration','body','defineProperty','peerConnection','4pfceJp','emit','setupSocketListeners','type','application/sdp','204386idDmdQ'];a0_0x3ca8=function(){return _0x56f489;};return a0_0x3ca8();}(function(_0x2e544a,_0x5c6825){const _0x17d666=a0_0x394e,_0x2db565=_0x2e544a();while(!![]){try{const _0x17da94=parseInt(_0x17d666(0x175))/0x1*(parseInt(_0x17d666(0x1ac))/0x2)+parseInt(_0x17d666(0x1ba))/0x3*(parseInt(_0x17d666(0x1c2))/0x4)+-parseInt(_0x17d666(0x16d))/0x5*(parseInt(_0x17d666(0x1a7))/0x6)+-parseInt(_0x17d666(0x17a))/0x7*(parseInt(_0x17d666(0x19d))/0x8)+parseInt(_0x17d666(0x17d))/0x9*(-parseInt(_0x17d666(0x1ab))/0xa)+-parseInt(_0x17d666(0x16c))/0xb*(-parseInt(_0x17d666(0x18c))/0xc)+-parseInt(_0x17d666(0x169))/0xd*(-parseInt(_0x17d666(0x16e))/0xe);if(_0x17da94===_0x5c6825)break;else _0x2db565['push'](_0x2db565['shift']());}catch(_0xa675c2){_0x2db565['push'](_0x2db565['shift']());}}}(a0_0x3ca8,0xe4813));var __create=Object[a0_0x49183f(0x176)],__defProp=Object[a0_0x49183f(0x1c0)],__getOwnPropDesc=Object['getOwnPropertyDescriptor'],__getOwnPropNames=Object[a0_0x49183f(0x1b8)],__getProtoOf=Object[a0_0x49183f(0x172)],__hasOwnProp=Object[a0_0x49183f(0x173)][a0_0x49183f(0x181)],__export=(_0x18cf73,_0x529dd3)=>{for(var _0x21eacd in _0x529dd3)__defProp(_0x18cf73,_0x21eacd,{'get':_0x529dd3[_0x21eacd],'enumerable':!![]});},__copyProps=(_0x45928c,_0x427998,_0x1068e8,_0x2ae692)=>{const _0x20da73=a0_0x49183f;if(_0x427998&&typeof _0x427998===_0x20da73(0x191)||typeof _0x427998===_0x20da73(0x190)){for(let _0x3edbec of __getOwnPropNames(_0x427998))if(!__hasOwnProp['call'](_0x45928c,_0x3edbec)&&_0x3edbec!==_0x1068e8)__defProp(_0x45928c,_0x3edbec,{'get':()=>_0x427998[_0x3edbec],'enumerable':!(_0x2ae692=__getOwnPropDesc(_0x427998,_0x3edbec))||_0x2ae692['enumerable']});}return _0x45928c;},__toESM=(_0x53df75,_0x2e5445,_0x3fb9c6)=>(_0x3fb9c6=_0x53df75!=null?__create(__getProtoOf(_0x53df75)):{},__copyProps(_0x2e5445||!_0x53df75||!_0x53df75[a0_0x49183f(0x18b)]?__defProp(_0x3fb9c6,a0_0x49183f(0x16b),{'value':_0x53df75,'enumerable':!![]}):_0x3fb9c6,_0x53df75)),__toCommonJS=_0x375510=>__copyProps(__defProp({},a0_0x49183f(0x18b),{'value':!![]}),_0x375510),index_exports={};function a0_0x394e(_0x31f577,_0x54d8aa){_0x31f577=_0x31f577-0x167;const _0x3ca822=a0_0x3ca8();let _0x394e64=_0x3ca822[_0x31f577];return _0x394e64;}__export(index_exports,{'AgrasyaVoiceSDK':()=>AgrasyaVoiceSDK}),module[a0_0x49183f(0x1ad)]=__toCommonJS(index_exports);var import_socket=__toESM(require('socket.io-client')),AgrasyaVoiceSDK=class{['config'];[a0_0x49183f(0x174)];['peerConnection']=null;[a0_0x49183f(0x179)]=null;[a0_0x49183f(0x19c)]=null;[a0_0x49183f(0x18f)]=null;['sessionId']=null;[a0_0x49183f(0x192)]=null;['dataUrl']=null;[a0_0x49183f(0x199)]=null;['callDuration']=0x0;[a0_0x49183f(0x19a)]=null;constructor(_0x4c92c1,_0x1926ce={}){const _0x1f8f14=a0_0x49183f;this[_0x1f8f14(0x1b5)]={'baseUrl':_0x1f8f14(0x18a),'language':'','debug':![],..._0x4c92c1},this[_0x1f8f14(0x174)]=_0x1926ce;}[a0_0x49183f(0x196)](..._0x1cc588){const _0x4b6ec0=a0_0x49183f;this[_0x4b6ec0(0x1b5)][_0x4b6ec0(0x1b0)]&&console[_0x4b6ec0(0x196)](_0x4b6ec0(0x1b6),..._0x1cc588);}['setStatus'](_0x50d78d){const _0x4452df=a0_0x49183f;this[_0x4452df(0x174)][_0x4452df(0x1a1)]?.(_0x50d78d);}[a0_0x49183f(0x1bd)](){const _0x3dda2f=a0_0x49183f;this[_0x3dda2f(0x1be)]=0x0,this[_0x3dda2f(0x19a)]=setInterval(()=>{const _0x4add02=_0x3dda2f;this['callDuration']+=0x1,this[_0x4add02(0x174)][_0x4add02(0x177)]?.(this[_0x4add02(0x1be)]);},0x3e8);}[a0_0x49183f(0x184)](){const _0xed28f8=a0_0x49183f;this[_0xed28f8(0x19a)]&&(clearInterval(this[_0xed28f8(0x19a)]),this[_0xed28f8(0x19a)]=null);}async['initializeBackendSession'](){const _0x3914a5=a0_0x49183f,_0x4acffb=this['config'][_0x3914a5(0x1af)]+_0x3914a5(0x186)+this[_0x3914a5(0x1b5)]['language'],_0x314063=await fetch(_0x4acffb,{'method':_0x3914a5(0x19f),'headers':{'x-agrasya-client-api-key':this[_0x3914a5(0x1b5)][_0x3914a5(0x17c)],'Content-Type':_0x3914a5(0x185)}});if(!_0x314063['ok']){const _0x330c3e=await _0x314063[_0x3914a5(0x1b2)]()[_0x3914a5(0x1a5)](()=>({'message':_0x314063[_0x3914a5(0x1aa)]}));throw new Error(_0x3914a5(0x188)+(_0x330c3e[_0x3914a5(0x170)]||_0x314063[_0x3914a5(0x1aa)]));}const _0x2cf2d4=await _0x314063[_0x3914a5(0x1b2)]();if(!_0x2cf2d4['success'])throw new Error(_0x2cf2d4[_0x3914a5(0x170)]||'Backend\x20initialization\x20failed');return _0x2cf2d4[_0x3914a5(0x1b4)];}async['setupWebRTC'](_0x57be48){const _0x19004a=a0_0x49183f;this[_0x19004a(0x1c1)]=new RTCPeerConnection(),this['dataChannel']=this['peerConnection'][_0x19004a(0x17b)](_0x19004a(0x19b));this[_0x19004a(0x179)]&&(this[_0x19004a(0x179)][_0x19004a(0x16a)]=_0x483375=>{const _0x36a1c2=_0x19004a,_0x401047=JSON['parse'](_0x483375[_0x36a1c2(0x1b4)]);this[_0x36a1c2(0x174)]['onTranscript']?.(_0x401047);});this[_0x19004a(0x1c1)][_0x19004a(0x16f)]=_0x5073c6=>{const _0x525142=_0x19004a,_0x10d1b6=document['createElement'](_0x525142(0x1a6));_0x10d1b6['srcObject']=_0x5073c6[_0x525142(0x198)][0x0],_0x10d1b6['autoplay']=!![],document[_0x525142(0x1bf)]['appendChild'](_0x10d1b6);},this[_0x19004a(0x19c)]=await navigator[_0x19004a(0x1bb)][_0x19004a(0x197)]({'audio':!![]});if(this[_0x19004a(0x19c)]){const _0x284b3f=this[_0x19004a(0x19c)][_0x19004a(0x182)]()[0x0];this[_0x19004a(0x1c1)][_0x19004a(0x17f)](_0x284b3f,this[_0x19004a(0x19c)]);}const _0x1aa3dc=await this['peerConnection'][_0x19004a(0x1a3)]();await this[_0x19004a(0x1c1)][_0x19004a(0x1b1)](_0x1aa3dc);const _0x4cd9c5=this[_0x19004a(0x1b5)][_0x19004a(0x1af)]+_0x19004a(0x180),_0x285bfe=await fetch(_0x4cd9c5,{'method':_0x19004a(0x1a2),'body':JSON['stringify']({'sessionId':this[_0x19004a(0x1b9)],'sdp':_0x1aa3dc['sdp']}),'headers':{'x-agrasya-client-api-key':this[_0x19004a(0x1b5)][_0x19004a(0x17c)],'Content-Type':_0x19004a(0x168)}});if(!_0x285bfe['ok'])throw new Error('SDP\x20exchange\x20failed:\x20'+_0x285bfe[_0x19004a(0x1aa)]);const _0x2ec730={'type':'answer','sdp':await _0x285bfe[_0x19004a(0x1a8)]()},_0x31d655={'type':_0x2ec730[_0x19004a(0x167)],'sdp':_0x2ec730[_0x19004a(0x1a9)]};await this[_0x19004a(0x1c1)][_0x19004a(0x194)](_0x31d655);}[a0_0x49183f(0x1c4)](_0x592726){_0x592726['on']('disconnect',()=>{const _0x2361e0=a0_0x394e;this[_0x2361e0(0x171)]();}),_0x592726['on']('session_ended',()=>{const _0x5d0f95=a0_0x394e;this[_0x5d0f95(0x171)]();});}async[a0_0x49183f(0x1a4)](_0x2d88a3){const _0x1f0090=a0_0x49183f;try{this[_0x1f0090(0x189)]('initializing');const _0x32a8a6=await this[_0x1f0090(0x1a0)]();this['sessionId']=_0x32a8a6[_0x1f0090(0x1b9)],this['ephKey']=_0x32a8a6[_0x1f0090(0x192)];if(!this[_0x1f0090(0x192)])throw new Error(_0x1f0090(0x1b3));const _0x5a44a7=await this['fetchMinutesUsage']();this[_0x1f0090(0x196)](_0x1f0090(0x1bc)+_0x5a44a7),await this['setupWebRTC'](this[_0x1f0090(0x192)]),this[_0x1f0090(0x18f)]=(0x0,import_socket[_0x1f0090(0x16b)])(this[_0x1f0090(0x1b5)][_0x1f0090(0x1af)],{'transports':[_0x1f0090(0x193)]}),this[_0x1f0090(0x18f)][_0x1f0090(0x1c3)](_0x1f0090(0x183),{'sessionId':this['sessionId']}),this[_0x1f0090(0x1c4)](this[_0x1f0090(0x18f)]),this[_0x1f0090(0x189)](_0x1f0090(0x1ae)),this['startTimer']();}catch(_0x4a9b5f){this[_0x1f0090(0x189)](_0x1f0090(0x178));throw _0x4a9b5f;}}async[a0_0x49183f(0x1b7)](){const _0xa1aa72=a0_0x49183f;this[_0xa1aa72(0x171)]();}['cleanup'](){const _0x460725=a0_0x49183f;this['peerConnection']&&(this[_0x460725(0x1c1)]['close'](),this[_0x460725(0x1c1)]=null),this['dataChannel']&&(this[_0x460725(0x179)][_0x460725(0x18d)](),this[_0x460725(0x179)]=null),this[_0x460725(0x19c)]&&(this[_0x460725(0x19c)]['getTracks']()[_0x460725(0x187)](_0x34129e=>_0x34129e['stop']()),this[_0x460725(0x19c)]=null),this[_0x460725(0x18f)]&&(this[_0x460725(0x18f)]['disconnect'](),this[_0x460725(0x18f)]=null),this['stopTimer'](),this['setStatus']('idle');}async[a0_0x49183f(0x195)](){const _0x110648=a0_0x49183f,_0x27340a=this['config']['baseUrl']+_0x110648(0x17e),_0x35bf2d=await fetch(_0x27340a,{'method':_0x110648(0x19f),'headers':{'x-agrasya-client-api-key':this[_0x110648(0x1b5)][_0x110648(0x17c)],'Content-Type':_0x110648(0x185)}});if(!_0x35bf2d['ok']){const _0x45d3bd=await _0x35bf2d[_0x110648(0x1b2)]()[_0x110648(0x1a5)](()=>({'message':_0x35bf2d[_0x110648(0x1aa)]}));throw new Error(_0x110648(0x19e)+(_0x45d3bd[_0x110648(0x170)]||_0x35bf2d[_0x110648(0x1aa)]));}const _0x56788b=await _0x35bf2d[_0x110648(0x1b2)]();if(!_0x56788b[_0x110648(0x18e)])throw new Error(_0x56788b['message']||'Failed\x20to\x20fetch\x20minutes\x20usage');return _0x56788b[_0x110648(0x1b4)]['minutesLeft'];}};0x0&&(module[a0_0x49183f(0x1ad)]={'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
+ const a1_0x1f7b57=a1_0x2c62;(function(_0x135dfe,_0x440dba){const _0x2633a0=a1_0x2c62,_0x4987b1=_0x135dfe();while(!![]){try{const _0x4b2fa4=-parseInt(_0x2633a0(0x16f))/0x1*(parseInt(_0x2633a0(0x180))/0x2)+parseInt(_0x2633a0(0x184))/0x3+-parseInt(_0x2633a0(0x147))/0x4*(-parseInt(_0x2633a0(0x17e))/0x5)+-parseInt(_0x2633a0(0x177))/0x6*(-parseInt(_0x2633a0(0x191))/0x7)+-parseInt(_0x2633a0(0x143))/0x8+parseInt(_0x2633a0(0x167))/0x9+-parseInt(_0x2633a0(0x181))/0xa;if(_0x4b2fa4===_0x440dba)break;else _0x4987b1['push'](_0x4987b1['shift']());}catch(_0x1ec3ef){_0x4987b1['push'](_0x4987b1['shift']());}}}(a1_0x6d67,0x54173));function a1_0x6d67(){const _0x3427bb=['/v1/agrasya/usage','statusText','startVoiceSession','initializing','dataChannel','30ZZQlQT','connected','onTranscript','appendChild','setLocalDescription','srcObject','oai-events','891600lwIXTW','config','552778qnvSUj','6912060mBXlOK','body','forEach','1216365wzjiEX','/v1/agrasya/client-token?language=','onStatusChange','createOffer','createElement','json','setRemoteDescription','Failed\x20to\x20fetch\x20minutes\x20usage','message','sessionId','startTimer','application/sdp','ephKey','844641DwgeFX','streams','peerConnection','setupWebRTC','success','text','autoplay','750288EOsDuy','emit','ontrack','Failed\x20to\x20initialize\x20session:\x20','8XrGcIf','durationInterval','setupSocketListeners','key\x20is\x20null\x20or\x20undefined.','[AgrasyaSDK]','stopTimer','error','apiKey','addTrack','parse','application/json','audio','baseUrl','data','session_ended','fetchMinutesUsage','onCallDurationUpdate','sdp','close','idle','setStatus','initializeBackendSession','disconnect','http://localhost:4001','log','callDuration','getTracks','audioStream','language','/v1/agrasya/connect','debug','createDataChannel','2851155sXhCmE','catch','cleanup','POST','Failed\x20to\x20fetch\x20minutes\x20usage:\x20','socket','SDP\x20exchange\x20failed:\x20','GET','2VLwMDr','stop','events'];a1_0x6d67=function(){return _0x3427bb;};return a1_0x6d67();}import a1_0x2a3ce6 from'socket.io-client';function a1_0x2c62(_0x1a4fd1,_0x50b7ee){_0x1a4fd1=_0x1a4fd1-0x13f;const _0x6d6796=a1_0x6d67();let _0x2c6252=_0x6d6796[_0x1a4fd1];return _0x2c6252;}var AgrasyaVoiceSDK=class{[a1_0x1f7b57(0x17f)];[a1_0x1f7b57(0x171)];[a1_0x1f7b57(0x193)]=null;[a1_0x1f7b57(0x176)]=null;[a1_0x1f7b57(0x162)]=null;['socket']=null;[a1_0x1f7b57(0x18d)]=null;['ephKey']=null;['dataUrl']=null;['model']=null;[a1_0x1f7b57(0x160)]=0x0;[a1_0x1f7b57(0x148)]=null;constructor(_0x40f8cc,_0x31e7e5={}){const _0xb8acce=a1_0x1f7b57;this[_0xb8acce(0x17f)]={'baseUrl':_0xb8acce(0x15e),'language':'','debug':![],..._0x40f8cc},this[_0xb8acce(0x171)]=_0x31e7e5;}[a1_0x1f7b57(0x15f)](..._0x33e2c3){const _0x208ac1=a1_0x1f7b57;this[_0x208ac1(0x17f)][_0x208ac1(0x165)]&&console[_0x208ac1(0x15f)](_0x208ac1(0x14b),..._0x33e2c3);}[a1_0x1f7b57(0x15b)](_0x54c124){const _0x4b549f=a1_0x1f7b57;this[_0x4b549f(0x171)][_0x4b549f(0x186)]?.(_0x54c124);}['startTimer'](){const _0x45b396=a1_0x1f7b57;this[_0x45b396(0x160)]=0x0,this['durationInterval']=setInterval(()=>{const _0x3e3112=_0x45b396;this[_0x3e3112(0x160)]+=0x1,this['events'][_0x3e3112(0x157)]?.(this['callDuration']);},0x3e8);}[a1_0x1f7b57(0x14c)](){const _0x3de275=a1_0x1f7b57;this['durationInterval']&&(clearInterval(this[_0x3de275(0x148)]),this['durationInterval']=null);}async[a1_0x1f7b57(0x15c)](){const _0x483f00=a1_0x1f7b57,_0x447afd=this[_0x483f00(0x17f)][_0x483f00(0x153)]+_0x483f00(0x185)+this[_0x483f00(0x17f)][_0x483f00(0x163)],_0x16762b=await fetch(_0x447afd,{'method':_0x483f00(0x16e),'headers':{'x-agrasya-client-api-key':this[_0x483f00(0x17f)][_0x483f00(0x14e)],'Content-Type':'application/json'}});if(!_0x16762b['ok']){const _0x212792=await _0x16762b[_0x483f00(0x189)]()[_0x483f00(0x168)](()=>({'message':_0x16762b['statusText']}));throw new Error(_0x483f00(0x146)+(_0x212792[_0x483f00(0x18c)]||_0x16762b['statusText']));}const _0x1e11c8=await _0x16762b[_0x483f00(0x189)]();if(!_0x1e11c8[_0x483f00(0x140)])throw new Error(_0x1e11c8[_0x483f00(0x18c)]||'Backend\x20initialization\x20failed');return _0x1e11c8[_0x483f00(0x154)];}async[a1_0x1f7b57(0x13f)](_0x5965e6){const _0xf7c31b=a1_0x1f7b57;this[_0xf7c31b(0x193)]=new RTCPeerConnection(),this[_0xf7c31b(0x176)]=this[_0xf7c31b(0x193)][_0xf7c31b(0x166)](_0xf7c31b(0x17d));this[_0xf7c31b(0x176)]&&(this['dataChannel']['onmessage']=_0x37f9d2=>{const _0x5c94ab=_0xf7c31b,_0x74cb7=JSON[_0x5c94ab(0x150)](_0x37f9d2[_0x5c94ab(0x154)]);this['events'][_0x5c94ab(0x179)]?.(_0x74cb7);});this['peerConnection'][_0xf7c31b(0x145)]=_0x55ad69=>{const _0x3bd453=_0xf7c31b,_0x27e0cf=document[_0x3bd453(0x188)](_0x3bd453(0x152));_0x27e0cf[_0x3bd453(0x17c)]=_0x55ad69[_0x3bd453(0x192)][0x0],_0x27e0cf[_0x3bd453(0x142)]=!![],document[_0x3bd453(0x182)][_0x3bd453(0x17a)](_0x27e0cf);},this['audioStream']=await navigator['mediaDevices']['getUserMedia']({'audio':!![]});if(this[_0xf7c31b(0x162)]){const _0x3eb38f=this[_0xf7c31b(0x162)][_0xf7c31b(0x161)]()[0x0];this[_0xf7c31b(0x193)][_0xf7c31b(0x14f)](_0x3eb38f,this[_0xf7c31b(0x162)]);}const _0x2d537e=await this[_0xf7c31b(0x193)][_0xf7c31b(0x187)]();await this[_0xf7c31b(0x193)][_0xf7c31b(0x17b)](_0x2d537e);const _0xeb9ef7=this[_0xf7c31b(0x17f)][_0xf7c31b(0x153)]+_0xf7c31b(0x164),_0x15269b=await fetch(_0xeb9ef7,{'method':_0xf7c31b(0x16a),'body':JSON['stringify']({'sessionId':this[_0xf7c31b(0x18d)],'sdp':_0x2d537e['sdp']}),'headers':{'x-agrasya-client-api-key':this[_0xf7c31b(0x17f)]['apiKey'],'Content-Type':_0xf7c31b(0x18f)}});if(!_0x15269b['ok'])throw new Error(_0xf7c31b(0x16d)+_0x15269b[_0xf7c31b(0x173)]);const _0x7229f2={'type':'answer','sdp':await _0x15269b[_0xf7c31b(0x141)]()},_0x56bbc0={'type':_0x7229f2['type'],'sdp':_0x7229f2[_0xf7c31b(0x158)]};await this[_0xf7c31b(0x193)][_0xf7c31b(0x18a)](_0x56bbc0);}[a1_0x1f7b57(0x149)](_0x2fbd4e){const _0x2afb13=a1_0x1f7b57;_0x2fbd4e['on']('disconnect',()=>{this['cleanup']();}),_0x2fbd4e['on'](_0x2afb13(0x155),()=>{const _0x24637a=_0x2afb13;this[_0x24637a(0x169)]();});}async[a1_0x1f7b57(0x174)](_0x47d93f){const _0x56da5b=a1_0x1f7b57;try{this[_0x56da5b(0x15b)](_0x56da5b(0x175));const _0x29e200=await this[_0x56da5b(0x15c)]();this[_0x56da5b(0x18d)]=_0x29e200['sessionId'],this[_0x56da5b(0x190)]=_0x29e200[_0x56da5b(0x190)];if(!this[_0x56da5b(0x190)])throw new Error(_0x56da5b(0x14a));const _0x42800a=await this[_0x56da5b(0x156)]();this['log']('Minutes\x20left:\x20'+_0x42800a),await this[_0x56da5b(0x13f)](this['ephKey']),this[_0x56da5b(0x16c)]=a1_0x2a3ce6(this['config'][_0x56da5b(0x153)],{'transports':['websocket']}),this[_0x56da5b(0x16c)][_0x56da5b(0x144)]('join_session',{'sessionId':this['sessionId']}),this[_0x56da5b(0x149)](this[_0x56da5b(0x16c)]),this['setStatus'](_0x56da5b(0x178)),this[_0x56da5b(0x18e)]();}catch(_0x699458){this[_0x56da5b(0x15b)](_0x56da5b(0x14d));throw _0x699458;}}async['stopVoiceSession'](){const _0x417da3=a1_0x1f7b57;this[_0x417da3(0x169)]();}[a1_0x1f7b57(0x169)](){const _0x3ee878=a1_0x1f7b57;this[_0x3ee878(0x193)]&&(this['peerConnection']['close'](),this['peerConnection']=null),this['dataChannel']&&(this[_0x3ee878(0x176)][_0x3ee878(0x159)](),this['dataChannel']=null),this['audioStream']&&(this[_0x3ee878(0x162)][_0x3ee878(0x161)]()[_0x3ee878(0x183)](_0x1bf9cd=>_0x1bf9cd[_0x3ee878(0x170)]()),this['audioStream']=null),this['socket']&&(this['socket'][_0x3ee878(0x15d)](),this[_0x3ee878(0x16c)]=null),this['stopTimer'](),this[_0x3ee878(0x15b)](_0x3ee878(0x15a));}async['fetchMinutesUsage'](){const _0x1cefb3=a1_0x1f7b57,_0x389c16=this[_0x1cefb3(0x17f)][_0x1cefb3(0x153)]+_0x1cefb3(0x172),_0xf69327=await fetch(_0x389c16,{'method':'GET','headers':{'x-agrasya-client-api-key':this[_0x1cefb3(0x17f)][_0x1cefb3(0x14e)],'Content-Type':_0x1cefb3(0x151)}});if(!_0xf69327['ok']){const _0x15f2ef=await _0xf69327[_0x1cefb3(0x189)]()['catch'](()=>({'message':_0xf69327[_0x1cefb3(0x173)]}));throw new Error(_0x1cefb3(0x16b)+(_0x15f2ef[_0x1cefb3(0x18c)]||_0xf69327[_0x1cefb3(0x173)]));}const _0x59a878=await _0xf69327[_0x1cefb3(0x189)]();if(!_0x59a878[_0x1cefb3(0x140)])throw new Error(_0x59a878[_0x1cefb3(0x18c)]||_0x1cefb3(0x18b));return _0x59a878[_0x1cefb3(0x154)]['minutesLeft'];}};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.31",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",