agrasya-voice-sdk 1.0.27 → 1.0.29

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.d.mts CHANGED
@@ -62,7 +62,6 @@ declare class AgrasyaVoiceSDK {
62
62
  stopVoiceSession(): Promise<void>;
63
63
  private cleanup;
64
64
  fetchMinutesUsage(): Promise<number>;
65
- private cleanSDP;
66
65
  }
67
66
 
68
67
  export { AgrasyaVoiceSDK };
package/dist/index.d.ts CHANGED
@@ -62,7 +62,6 @@ declare class AgrasyaVoiceSDK {
62
62
  stopVoiceSession(): Promise<void>;
63
63
  private cleanup;
64
64
  fetchMinutesUsage(): Promise<number>;
65
- private cleanSDP;
66
65
  }
67
66
 
68
67
  export { AgrasyaVoiceSDK };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- 'use strict';const a0_0x251f4b=a0_0x34aa;(function(_0x89599d,_0x4ae75b){const _0x55d2fd=a0_0x34aa,_0xfdd3e3=_0x89599d();while(!![]){try{const _0x20d4b3=-parseInt(_0x55d2fd(0xf0))/0x1+-parseInt(_0x55d2fd(0xbb))/0x2*(parseInt(_0x55d2fd(0xcd))/0x3)+parseInt(_0x55d2fd(0xa4))/0x4+parseInt(_0x55d2fd(0xe3))/0x5+parseInt(_0x55d2fd(0xd0))/0x6+-parseInt(_0x55d2fd(0xb0))/0x7+parseInt(_0x55d2fd(0xd6))/0x8;if(_0x20d4b3===_0x4ae75b)break;else _0xfdd3e3['push'](_0xfdd3e3['shift']());}catch(_0x9072f9){_0xfdd3e3['push'](_0xfdd3e3['shift']());}}}(a0_0x1ab6,0xe15bf));var __create=Object[a0_0x251f4b(0xc5)],__defProp=Object[a0_0x251f4b(0xfc)],__getOwnPropDesc=Object[a0_0x251f4b(0xc2)],__getOwnPropNames=Object[a0_0x251f4b(0xf2)],__getProtoOf=Object[a0_0x251f4b(0xdc)],__hasOwnProp=Object[a0_0x251f4b(0x9b)][a0_0x251f4b(0xf8)],__export=(_0x1928f7,_0x1d4aa4)=>{for(var _0x3fa4f4 in _0x1d4aa4)__defProp(_0x1928f7,_0x3fa4f4,{'get':_0x1d4aa4[_0x3fa4f4],'enumerable':!![]});},__copyProps=(_0x30c564,_0x18ccf2,_0x46040d,_0x44c0d3)=>{const _0xa68e8=a0_0x251f4b;if(_0x18ccf2&&typeof _0x18ccf2===_0xa68e8(0xb6)||typeof _0x18ccf2===_0xa68e8(0xdf)){for(let _0x238d02 of __getOwnPropNames(_0x18ccf2))if(!__hasOwnProp[_0xa68e8(0xbc)](_0x30c564,_0x238d02)&&_0x238d02!==_0x46040d)__defProp(_0x30c564,_0x238d02,{'get':()=>_0x18ccf2[_0x238d02],'enumerable':!(_0x44c0d3=__getOwnPropDesc(_0x18ccf2,_0x238d02))||_0x44c0d3['enumerable']});}return _0x30c564;},__toESM=(_0x475911,_0x673257,_0x44f5e6)=>(_0x44f5e6=_0x475911!=null?__create(__getProtoOf(_0x475911)):{},__copyProps(_0x673257||!_0x475911||!_0x475911[a0_0x251f4b(0x92)]?__defProp(_0x44f5e6,a0_0x251f4b(0xaf),{'value':_0x475911,'enumerable':!![]}):_0x44f5e6,_0x475911)),__toCommonJS=_0x3fbd95=>__copyProps(__defProp({},'__esModule',{'value':!![]}),_0x3fbd95),index_exports={};function a0_0x34aa(_0x47231b,_0x58ff8f){_0x47231b=_0x47231b-0x8e;const _0x1ab6e5=a0_0x1ab6();let _0x34aa10=_0x1ab6e5[_0x47231b];return _0x34aa10;}function a0_0x1ab6(){const _0x4892b2=['Minutes\x20left:\x20','split','idle','forEach','emit','DataUrl','dataChannel','27975PfAjvQ','stopTimer','addTrack','4013202UGSqCW','setupSocketListeners','onCallDurationUpdate','body','session_ended','onStatusChange','9421528dtygNL','model','add','startVoiceSession','language','parse','getPrototypeOf','success','catch','function','websocket','onTranscript','Invalid\x20SDP\x20received:\x20Missing\x20or\x20malformed\x20\x27v=\x27\x20line.','7364445IhqeGf','exports','json','Backend\x20initialization\x20failed','createElement','answer','socket.io-client','streams','connected','setStatus','createDataChannel','data','events','1744454pwNCIJ','dataUrl','getOwnPropertyNames','/v1/agrasya/client-token?language=','ontrack','Failed\x20to\x20fetch\x20minutes\x20usage:\x20','application/json','sessionId','hasOwnProperty','a=rtpmap','minutesLeft','log','defineProperty','audio','getTracks','a=fmtp','audioStream','v=0','stopVoiceSession','join_session','filter','join','__esModule','POST','Response\x20from\x20/agrasya/connect:','statusText','close','baseUrl','callDuration','Cleaned\x20SDP:','peerConnection','prototype','message','disconnect','debug','sdp','[AgrasyaSDK]','/v1/agrasya/usage','key\x20is\x20null\x20or\x20undefined.','getUserMedia','4727760AWbZcC','config','initializeBackendSession','http://localhost:4001','cleanup','appendChild','socket','o=-','error','setRemoteDescription','has','default','11335709NchsTd','initializing','mediaDevices','fetchMinutesUsage','stop','durationInterval','object','/v1/agrasya/connect','cleanSDP','setupWebRTC','stringify','46tWHPYO','call','Failed\x20to\x20fetch\x20minutes\x20usage','ephKey','oai-events','onmessage','apiKey','getOwnPropertyDescriptor','startsWith','Failed\x20to\x20initialize\x20session:\x20','create'];a0_0x1ab6=function(){return _0x4892b2;};return a0_0x1ab6();}__export(index_exports,{'AgrasyaVoiceSDK':()=>AgrasyaVoiceSDK}),module['exports']=__toCommonJS(index_exports);var import_socket=__toESM(require(a0_0x251f4b(0xe9))),AgrasyaVoiceSDK=class{[a0_0x251f4b(0xa5)];['events'];['peerConnection']=null;[a0_0x251f4b(0xcc)]=null;[a0_0x251f4b(0x100)]=null;[a0_0x251f4b(0xaa)]=null;[a0_0x251f4b(0xf7)]=null;[a0_0x251f4b(0xbe)]=null;['dataUrl']=null;[a0_0x251f4b(0xd7)]=null;[a0_0x251f4b(0x98)]=0x0;[a0_0x251f4b(0xb5)]=null;constructor(_0x145054,_0x18960b={}){const _0x36e090=a0_0x251f4b;this['config']={'baseUrl':_0x36e090(0xa7),'language':'','debug':![],..._0x145054},this[_0x36e090(0xef)]=_0x18960b;}[a0_0x251f4b(0xfb)](..._0x2929a3){const _0x400de8=a0_0x251f4b;this[_0x400de8(0xa5)][_0x400de8(0x9e)]&&console[_0x400de8(0xfb)](_0x400de8(0xa0),..._0x2929a3);}[a0_0x251f4b(0xec)](_0x151771){const _0x1b3cad=a0_0x251f4b;this[_0x1b3cad(0xef)][_0x1b3cad(0xd5)]?.(_0x151771);}['startTimer'](){const _0x50f4ce=a0_0x251f4b;this['callDuration']=0x0,this[_0x50f4ce(0xb5)]=setInterval(()=>{const _0x41704d=_0x50f4ce;this[_0x41704d(0x98)]+=0x1,this[_0x41704d(0xef)][_0x41704d(0xd2)]?.(this[_0x41704d(0x98)]);},0x3e8);}[a0_0x251f4b(0xce)](){const _0x499c08=a0_0x251f4b;this[_0x499c08(0xb5)]&&(clearInterval(this['durationInterval']),this[_0x499c08(0xb5)]=null);}async[a0_0x251f4b(0xa6)](){const _0x1397e3=a0_0x251f4b,_0xb8ddc5=this[_0x1397e3(0xa5)][_0x1397e3(0x97)]+_0x1397e3(0xf3)+this[_0x1397e3(0xa5)][_0x1397e3(0xda)],_0x48eb41=await fetch(_0xb8ddc5,{'method':'GET','headers':{'x-agrasya-client-api-key':this[_0x1397e3(0xa5)]['apiKey'],'Content-Type':_0x1397e3(0xf6)}});if(!_0x48eb41['ok']){const _0x2c4e35=await _0x48eb41[_0x1397e3(0xe5)]()[_0x1397e3(0xde)](()=>({'message':_0x48eb41[_0x1397e3(0x95)]}));throw new Error(_0x1397e3(0xc4)+(_0x2c4e35[_0x1397e3(0x9c)]||_0x48eb41[_0x1397e3(0x95)]));}const _0x269f1b=await _0x48eb41[_0x1397e3(0xe5)]();if(!_0x269f1b[_0x1397e3(0xdd)])throw new Error(_0x269f1b[_0x1397e3(0x9c)]||_0x1397e3(0xe6));return this[_0x1397e3(0xf1)]=_0x269f1b[_0x1397e3(0xee)][_0x1397e3(0xcb)],this[_0x1397e3(0xd7)]=_0x269f1b['data'][_0x1397e3(0xd7)],_0x269f1b[_0x1397e3(0xee)];}async[a0_0x251f4b(0xb9)](_0xc8bd91){const _0x11df09=a0_0x251f4b;this['peerConnection']=new RTCPeerConnection(),this[_0x11df09(0xcc)]=this[_0x11df09(0x9a)][_0x11df09(0xed)](_0x11df09(0xbf));this['dataChannel']&&(this[_0x11df09(0xcc)][_0x11df09(0xc0)]=_0x219fd5=>{const _0x56a9e9=_0x11df09,_0x2c5253=JSON[_0x56a9e9(0xdb)](_0x219fd5[_0x56a9e9(0xee)]);this[_0x56a9e9(0xef)][_0x56a9e9(0xe1)]?.(_0x2c5253);});this[_0x11df09(0x9a)][_0x11df09(0xf4)]=_0x3b632f=>{const _0x32133d=_0x11df09,_0x1acec0=document[_0x32133d(0xe7)](_0x32133d(0xfd));_0x1acec0['srcObject']=_0x3b632f[_0x32133d(0xea)][0x0],_0x1acec0['autoplay']=!![],document[_0x32133d(0xd3)][_0x32133d(0xa9)](_0x1acec0);},this[_0x11df09(0x100)]=await navigator[_0x11df09(0xb2)][_0x11df09(0xa3)]({'audio':!![]});if(this[_0x11df09(0x100)]){const _0x42dc48=this[_0x11df09(0x100)]['getTracks']()[0x0];this[_0x11df09(0x9a)][_0x11df09(0xcf)](_0x42dc48,this[_0x11df09(0x100)]);}const _0x377f86=await this[_0x11df09(0x9a)]['createOffer']();await this[_0x11df09(0x9a)]['setLocalDescription'](_0x377f86);const _0x214f2d=this[_0x11df09(0xa5)][_0x11df09(0x97)]+_0x11df09(0xb7),_0x51f6bc=await fetch(_0x214f2d,{'method':_0x11df09(0x93),'body':JSON[_0x11df09(0xba)]({'sessionId':this[_0x11df09(0xf7)],'sdp':_0x377f86[_0x11df09(0x9f)],'model':this[_0x11df09(0xd7)]}),'headers':{'x-agrasya-client-api-key':this[_0x11df09(0xa5)][_0x11df09(0xc1)],'Content-Type':'application/json'}});if(!_0x51f6bc['ok']){const _0x583666=await _0x51f6bc[_0x11df09(0xe5)]()['catch'](()=>({'message':_0x51f6bc['statusText']}));throw new Error('SDP\x20exchange\x20failed:\x20'+(_0x583666['message']||_0x51f6bc['statusText']));}const _0x39b713=await _0x51f6bc[_0x11df09(0xe5)]();this[_0x11df09(0xfb)](_0x11df09(0x94),_0x39b713);let _0x1114fd=_0x39b713[_0x11df09(0x9f)];_0x1114fd=this['cleanSDP'](_0x1114fd);if(!_0x1114fd[_0x11df09(0xc3)](_0x11df09(0x101)))throw new Error(_0x11df09(0xe2));this[_0x11df09(0xfb)](_0x11df09(0x99),_0x1114fd);const _0xa3966a={'type':_0x11df09(0xe8),'sdp':_0x1114fd};await this[_0x11df09(0x9a)][_0x11df09(0xad)](_0xa3966a);}[a0_0x251f4b(0xd1)](_0x53760c){const _0x143cc5=a0_0x251f4b;_0x53760c['on'](_0x143cc5(0x9d),()=>{const _0xf37630=_0x143cc5;this[_0xf37630(0xa8)]();}),_0x53760c['on'](_0x143cc5(0xd4),()=>{const _0x41b525=_0x143cc5;this[_0x41b525(0xa8)]();});}async[a0_0x251f4b(0xd9)](_0x4f34ae){const _0x3f8dfa=a0_0x251f4b;try{this[_0x3f8dfa(0xec)](_0x3f8dfa(0xb1));const _0x5385e3=await this['initializeBackendSession']();this[_0x3f8dfa(0xf7)]=_0x5385e3[_0x3f8dfa(0xf7)],this[_0x3f8dfa(0xbe)]=_0x5385e3['ephKey'];if(!this[_0x3f8dfa(0xbe)])throw new Error(_0x3f8dfa(0xa2));const _0x501502=await this[_0x3f8dfa(0xb3)]();this[_0x3f8dfa(0xfb)](_0x3f8dfa(0xc6)+_0x501502),await this[_0x3f8dfa(0xb9)](this[_0x3f8dfa(0xbe)]),this[_0x3f8dfa(0xaa)]=(0x0,import_socket[_0x3f8dfa(0xaf)])(this[_0x3f8dfa(0xa5)][_0x3f8dfa(0x97)],{'transports':[_0x3f8dfa(0xe0)]}),this[_0x3f8dfa(0xaa)][_0x3f8dfa(0xca)](_0x3f8dfa(0x8f),{'sessionId':this[_0x3f8dfa(0xf7)]}),this['setupSocketListeners'](this[_0x3f8dfa(0xaa)]),this['setStatus'](_0x3f8dfa(0xeb)),this['startTimer']();}catch(_0x5aca3d){this[_0x3f8dfa(0xec)](_0x3f8dfa(0xac));throw _0x5aca3d;}}async[a0_0x251f4b(0x8e)](){const _0x1c656e=a0_0x251f4b;this[_0x1c656e(0xa8)]();}['cleanup'](){const _0x423eb3=a0_0x251f4b;this[_0x423eb3(0x9a)]&&(this[_0x423eb3(0x9a)][_0x423eb3(0x96)](),this[_0x423eb3(0x9a)]=null),this[_0x423eb3(0xcc)]&&(this[_0x423eb3(0xcc)][_0x423eb3(0x96)](),this['dataChannel']=null),this[_0x423eb3(0x100)]&&(this['audioStream'][_0x423eb3(0xfe)]()[_0x423eb3(0xc9)](_0x353fc5=>_0x353fc5[_0x423eb3(0xb4)]()),this[_0x423eb3(0x100)]=null),this[_0x423eb3(0xaa)]&&(this[_0x423eb3(0xaa)]['disconnect'](),this[_0x423eb3(0xaa)]=null),this[_0x423eb3(0xce)](),this[_0x423eb3(0xec)](_0x423eb3(0xc8));}async['fetchMinutesUsage'](){const _0x348d88=a0_0x251f4b,_0x1fdd58=this[_0x348d88(0xa5)][_0x348d88(0x97)]+_0x348d88(0xa1),_0x35c435=await fetch(_0x1fdd58,{'method':'GET','headers':{'x-agrasya-client-api-key':this[_0x348d88(0xa5)][_0x348d88(0xc1)],'Content-Type':_0x348d88(0xf6)}});if(!_0x35c435['ok']){const _0x3dde1a=await _0x35c435[_0x348d88(0xe5)]()['catch'](()=>({'message':_0x35c435['statusText']}));throw new Error(_0x348d88(0xf5)+(_0x3dde1a[_0x348d88(0x9c)]||_0x35c435[_0x348d88(0x95)]));}const _0xb0a43f=await _0x35c435[_0x348d88(0xe5)]();if(!_0xb0a43f[_0x348d88(0xdd)])throw new Error(_0xb0a43f[_0x348d88(0x9c)]||_0x348d88(0xbd));return _0xb0a43f[_0x348d88(0xee)][_0x348d88(0xfa)];}[a0_0x251f4b(0xb8)](_0x51b900){const _0x29d918=a0_0x251f4b,_0x5d61b9=_0x51b900[_0x29d918(0xc7)]('\x0d\x0a'),_0x1bb585=new Set(),_0x3c4eb4=_0x5d61b9[_0x29d918(0x90)](_0x343b50=>{const _0x1801d5=_0x29d918;if(_0x343b50[_0x1801d5(0xc3)](_0x1801d5(0xab)))return![];if(_0x343b50[_0x1801d5(0xc3)](_0x1801d5(0xf9))||_0x343b50[_0x1801d5(0xc3)](_0x1801d5(0xff))){if(_0x1bb585[_0x1801d5(0xae)](_0x343b50))return![];_0x1bb585[_0x1801d5(0xd8)](_0x343b50);}return!![];});return _0x3c4eb4[_0x29d918(0x91)]('\x0d\x0a');}};0x0&&(module[a0_0x251f4b(0xe4)]={'AgrasyaVoiceSDK':AgrasyaVoiceSDK});
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});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- const a1_0xd67632=a1_0x3674;function a1_0x3674(_0x586bd0,_0x57f272){_0x586bd0=_0x586bd0-0xc8;const _0x58bdf1=a1_0x58bd();let _0x3674e0=_0x58bdf1[_0x586bd0];return _0x3674e0;}(function(_0x43f1dd,_0x1230f8){const _0x541ad9=a1_0x3674,_0x108127=_0x43f1dd();while(!![]){try{const _0x20c679=parseInt(_0x541ad9(0xd1))/0x1*(parseInt(_0x541ad9(0xcb))/0x2)+-parseInt(_0x541ad9(0x10f))/0x3+-parseInt(_0x541ad9(0x121))/0x4*(parseInt(_0x541ad9(0xe8))/0x5)+-parseInt(_0x541ad9(0xf1))/0x6*(-parseInt(_0x541ad9(0xd2))/0x7)+-parseInt(_0x541ad9(0xd5))/0x8+-parseInt(_0x541ad9(0x106))/0x9*(-parseInt(_0x541ad9(0x11c))/0xa)+parseInt(_0x541ad9(0xe6))/0xb;if(_0x20c679===_0x1230f8)break;else _0x108127['push'](_0x108127['shift']());}catch(_0x455b83){_0x108127['push'](_0x108127['shift']());}}}(a1_0x58bd,0x443e6));function a1_0x58bd(){const _0xd6b02e=['json','catch','socket','sdp','callDuration','cleanSDP','2334dbapzq','srcObject','setRemoteDescription','onCallDurationUpdate','body','apiKey','374inHcLF','2916809TUCmhL','cleanup','GET','614176AElPWe','message','stopTimer','startsWith','setStatus','language','oai-events','createOffer','join','idle','session_ended','startTimer','stringify','has','sessionId','/v1/agrasya/client-token?language=','filter','890494uAWCKM','audio','359915hkfbMP','createDataChannel','statusText','DataUrl','Backend\x20initialization\x20failed','startVoiceSession','audioStream','initializeBackendSession','parse','6ELJabR','POST','key\x20is\x20null\x20or\x20undefined.','disconnect','getUserMedia','setupSocketListeners','onmessage','log','/v1/agrasya/usage','config','dataChannel','durationInterval','Invalid\x20SDP\x20received:\x20Missing\x20or\x20malformed\x20\x27v=\x27\x20line.','onStatusChange','split','close','websocket','error','Cleaned\x20SDP:','v=0','o=-','153diRHar','minutesLeft','events','add','Response\x20from\x20/agrasya/connect:','getTracks','streams','success','Failed\x20to\x20initialize\x20session:\x20','1310619sJhXph','dataUrl','data','baseUrl','Failed\x20to\x20fetch\x20minutes\x20usage','fetchMinutesUsage','stop','model','Failed\x20to\x20fetch\x20minutes\x20usage:\x20','Minutes\x20left:\x20','mediaDevices','a=rtpmap','setupWebRTC','44130MigZth','peerConnection','[AgrasyaSDK]','stopVoiceSession','SDP\x20exchange\x20failed:\x20','12gMaDTv','application/json','initializing','ontrack','ephKey','/v1/agrasya/connect'];a1_0x58bd=function(){return _0xd6b02e;};return a1_0x58bd();}import a1_0x5412c5 from'socket.io-client';var AgrasyaVoiceSDK=class{[a1_0xd67632(0xfa)];['events'];['peerConnection']=null;['dataChannel']=null;[a1_0xd67632(0xee)]=null;[a1_0xd67632(0x129)]=null;[a1_0xd67632(0xe3)]=null;[a1_0xd67632(0x125)]=null;[a1_0xd67632(0x110)]=null;['model']=null;[a1_0xd67632(0xc9)]=0x0;[a1_0xd67632(0xfc)]=null;constructor(_0x21405c,_0x353c2b={}){const _0x14a617=a1_0xd67632;this[_0x14a617(0xfa)]={'baseUrl':'http://localhost:4001','language':'','debug':![],..._0x21405c},this[_0x14a617(0x108)]=_0x353c2b;}[a1_0xd67632(0xf8)](..._0x36d16d){const _0x48ab15=a1_0xd67632;this[_0x48ab15(0xfa)]['debug']&&console['log'](_0x48ab15(0x11e),..._0x36d16d);}['setStatus'](_0x480791){const _0x25c36b=a1_0xd67632;this[_0x25c36b(0x108)][_0x25c36b(0xfe)]?.(_0x480791);}[a1_0xd67632(0xe0)](){const _0x2fcb0d=a1_0xd67632;this[_0x2fcb0d(0xc9)]=0x0,this[_0x2fcb0d(0xfc)]=setInterval(()=>{const _0x20e301=_0x2fcb0d;this['callDuration']+=0x1,this['events'][_0x20e301(0xce)]?.(this['callDuration']);},0x3e8);}[a1_0xd67632(0xd7)](){const _0xf69e74=a1_0xd67632;this[_0xf69e74(0xfc)]&&(clearInterval(this[_0xf69e74(0xfc)]),this[_0xf69e74(0xfc)]=null);}async[a1_0xd67632(0xef)](){const _0x4c716f=a1_0xd67632,_0x45b0d3=this[_0x4c716f(0xfa)][_0x4c716f(0x112)]+_0x4c716f(0xe4)+this['config'][_0x4c716f(0xda)],_0xb6e633=await fetch(_0x45b0d3,{'method':_0x4c716f(0xd4),'headers':{'x-agrasya-client-api-key':this[_0x4c716f(0xfa)][_0x4c716f(0xd0)],'Content-Type':'application/json'}});if(!_0xb6e633['ok']){const _0x1c22e6=await _0xb6e633[_0x4c716f(0x127)]()['catch'](()=>({'message':_0xb6e633[_0x4c716f(0xea)]}));throw new Error(_0x4c716f(0x10e)+(_0x1c22e6['message']||_0xb6e633['statusText']));}const _0x4ce9d8=await _0xb6e633['json']();if(!_0x4ce9d8['success'])throw new Error(_0x4ce9d8['message']||_0x4c716f(0xec));return this[_0x4c716f(0x110)]=_0x4ce9d8[_0x4c716f(0x111)][_0x4c716f(0xeb)],this[_0x4c716f(0x116)]=_0x4ce9d8[_0x4c716f(0x111)]['model'],_0x4ce9d8[_0x4c716f(0x111)];}async[a1_0xd67632(0x11b)](_0x200811){const _0x44ba61=a1_0xd67632;this[_0x44ba61(0x11d)]=new RTCPeerConnection(),this['dataChannel']=this[_0x44ba61(0x11d)][_0x44ba61(0xe9)](_0x44ba61(0xdb));this[_0x44ba61(0xfb)]&&(this['dataChannel'][_0x44ba61(0xf7)]=_0x208bc2=>{const _0x5ceeb4=_0x44ba61,_0x460471=JSON[_0x5ceeb4(0xf0)](_0x208bc2[_0x5ceeb4(0x111)]);this[_0x5ceeb4(0x108)]['onTranscript']?.(_0x460471);});this['peerConnection'][_0x44ba61(0x124)]=_0x548247=>{const _0x54dab7=_0x44ba61,_0x4f7ddd=document['createElement'](_0x54dab7(0xe7));_0x4f7ddd[_0x54dab7(0xcc)]=_0x548247[_0x54dab7(0x10c)][0x0],_0x4f7ddd['autoplay']=!![],document[_0x54dab7(0xcf)]['appendChild'](_0x4f7ddd);},this['audioStream']=await navigator[_0x44ba61(0x119)][_0x44ba61(0xf5)]({'audio':!![]});if(this[_0x44ba61(0xee)]){const _0x3f37a6=this['audioStream'][_0x44ba61(0x10b)]()[0x0];this[_0x44ba61(0x11d)]['addTrack'](_0x3f37a6,this[_0x44ba61(0xee)]);}const _0x548bd8=await this['peerConnection'][_0x44ba61(0xdc)]();await this[_0x44ba61(0x11d)]['setLocalDescription'](_0x548bd8);const _0xe42d45=this[_0x44ba61(0xfa)][_0x44ba61(0x112)]+_0x44ba61(0x126),_0x30a9e1=await fetch(_0xe42d45,{'method':_0x44ba61(0xf2),'body':JSON[_0x44ba61(0xe1)]({'sessionId':this[_0x44ba61(0xe3)],'sdp':_0x548bd8[_0x44ba61(0xc8)],'model':this[_0x44ba61(0x116)]}),'headers':{'x-agrasya-client-api-key':this[_0x44ba61(0xfa)][_0x44ba61(0xd0)],'Content-Type':_0x44ba61(0x122)}});if(!_0x30a9e1['ok']){const _0x4324dd=await _0x30a9e1[_0x44ba61(0x127)]()['catch'](()=>({'message':_0x30a9e1[_0x44ba61(0xea)]}));throw new Error(_0x44ba61(0x120)+(_0x4324dd['message']||_0x30a9e1[_0x44ba61(0xea)]));}const _0x401002=await _0x30a9e1[_0x44ba61(0x127)]();this[_0x44ba61(0xf8)](_0x44ba61(0x10a),_0x401002);let _0x3255c2=_0x401002['sdp'];_0x3255c2=this[_0x44ba61(0xca)](_0x3255c2);if(!_0x3255c2[_0x44ba61(0xd8)](_0x44ba61(0x104)))throw new Error(_0x44ba61(0xfd));this[_0x44ba61(0xf8)](_0x44ba61(0x103),_0x3255c2);const _0x1f3daa={'type':'answer','sdp':_0x3255c2};await this['peerConnection'][_0x44ba61(0xcd)](_0x1f3daa);}['setupSocketListeners'](_0x32fe2c){const _0x6cf36=a1_0xd67632;_0x32fe2c['on'](_0x6cf36(0xf4),()=>{this['cleanup']();}),_0x32fe2c['on'](_0x6cf36(0xdf),()=>{this['cleanup']();});}async[a1_0xd67632(0xed)](_0x5924e5){const _0x1fb8c2=a1_0xd67632;try{this['setStatus'](_0x1fb8c2(0x123));const _0x2482b3=await this['initializeBackendSession']();this[_0x1fb8c2(0xe3)]=_0x2482b3[_0x1fb8c2(0xe3)],this[_0x1fb8c2(0x125)]=_0x2482b3[_0x1fb8c2(0x125)];if(!this['ephKey'])throw new Error(_0x1fb8c2(0xf3));const _0x25db82=await this[_0x1fb8c2(0x114)]();this[_0x1fb8c2(0xf8)](_0x1fb8c2(0x118)+_0x25db82),await this['setupWebRTC'](this[_0x1fb8c2(0x125)]),this[_0x1fb8c2(0x129)]=a1_0x5412c5(this[_0x1fb8c2(0xfa)]['baseUrl'],{'transports':[_0x1fb8c2(0x101)]}),this[_0x1fb8c2(0x129)]['emit']('join_session',{'sessionId':this['sessionId']}),this[_0x1fb8c2(0xf6)](this[_0x1fb8c2(0x129)]),this[_0x1fb8c2(0xd9)]('connected'),this[_0x1fb8c2(0xe0)]();}catch(_0x4f2622){this[_0x1fb8c2(0xd9)](_0x1fb8c2(0x102));throw _0x4f2622;}}async[a1_0xd67632(0x11f)](){const _0x49d3ec=a1_0xd67632;this[_0x49d3ec(0xd3)]();}[a1_0xd67632(0xd3)](){const _0x4a6c92=a1_0xd67632;this['peerConnection']&&(this['peerConnection']['close'](),this[_0x4a6c92(0x11d)]=null),this[_0x4a6c92(0xfb)]&&(this['dataChannel'][_0x4a6c92(0x100)](),this[_0x4a6c92(0xfb)]=null),this['audioStream']&&(this[_0x4a6c92(0xee)]['getTracks']()['forEach'](_0x3a1253=>_0x3a1253[_0x4a6c92(0x115)]()),this[_0x4a6c92(0xee)]=null),this[_0x4a6c92(0x129)]&&(this[_0x4a6c92(0x129)][_0x4a6c92(0xf4)](),this[_0x4a6c92(0x129)]=null),this['stopTimer'](),this[_0x4a6c92(0xd9)](_0x4a6c92(0xde));}async['fetchMinutesUsage'](){const _0x1e45fe=a1_0xd67632,_0x122103=this[_0x1e45fe(0xfa)]['baseUrl']+_0x1e45fe(0xf9),_0x529f18=await fetch(_0x122103,{'method':_0x1e45fe(0xd4),'headers':{'x-agrasya-client-api-key':this[_0x1e45fe(0xfa)][_0x1e45fe(0xd0)],'Content-Type':'application/json'}});if(!_0x529f18['ok']){const _0x4c4080=await _0x529f18[_0x1e45fe(0x127)]()[_0x1e45fe(0x128)](()=>({'message':_0x529f18[_0x1e45fe(0xea)]}));throw new Error(_0x1e45fe(0x117)+(_0x4c4080['message']||_0x529f18[_0x1e45fe(0xea)]));}const _0xf4371f=await _0x529f18[_0x1e45fe(0x127)]();if(!_0xf4371f[_0x1e45fe(0x10d)])throw new Error(_0xf4371f[_0x1e45fe(0xd6)]||_0x1e45fe(0x113));return _0xf4371f[_0x1e45fe(0x111)][_0x1e45fe(0x107)];}[a1_0xd67632(0xca)](_0xc7bff3){const _0x5a0b78=a1_0xd67632,_0x379282=_0xc7bff3[_0x5a0b78(0xff)]('\x0d\x0a'),_0x3e953d=new Set(),_0x65eedb=_0x379282[_0x5a0b78(0xe5)](_0x256956=>{const _0x1ce09a=_0x5a0b78;if(_0x256956['startsWith'](_0x1ce09a(0x105)))return![];if(_0x256956['startsWith'](_0x1ce09a(0x11a))||_0x256956[_0x1ce09a(0xd8)]('a=fmtp')){if(_0x3e953d[_0x1ce09a(0xe2)](_0x256956))return![];_0x3e953d[_0x1ce09a(0x109)](_0x256956);}return!![];});return _0x65eedb[_0x5a0b78(0xdd)]('\x0d\x0a');}};export{AgrasyaVoiceSDK};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agrasya-voice-sdk",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",