agrasya-voice-sdk 1.0.32 → 1.0.34
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 +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';const
|
|
1
|
+
'use strict';const a0_0x1ff248=a0_0x2f49;(function(_0x20a3b0,_0x3ffa6b){const _0x3c743d=a0_0x2f49,_0x29faff=_0x20a3b0();while(!![]){try{const _0x1a315a=-parseInt(_0x3c743d(0xca))/0x1*(parseInt(_0x3c743d(0xa0))/0x2)+parseInt(_0x3c743d(0xb6))/0x3+parseInt(_0x3c743d(0x85))/0x4*(parseInt(_0x3c743d(0xa2))/0x5)+parseInt(_0x3c743d(0x8f))/0x6*(-parseInt(_0x3c743d(0xa5))/0x7)+parseInt(_0x3c743d(0xd0))/0x8*(parseInt(_0x3c743d(0xb4))/0x9)+-parseInt(_0x3c743d(0x77))/0xa+-parseInt(_0x3c743d(0xc0))/0xb*(-parseInt(_0x3c743d(0xbe))/0xc);if(_0x1a315a===_0x3ffa6b)break;else _0x29faff['push'](_0x29faff['shift']());}catch(_0x10df87){_0x29faff['push'](_0x29faff['shift']());}}}(a0_0x1f99,0x9f441));function a0_0x2f49(_0x4f4c8d,_0x135501){_0x4f4c8d=_0x4f4c8d-0x73;const _0x1f99fa=a0_0x1f99();let _0x2f491a=_0x1f99fa[_0x4f4c8d];return _0x2f491a;}var __create=Object[a0_0x1ff248(0x8b)],__defProp=Object[a0_0x1ff248(0xcc)],__getOwnPropDesc=Object[a0_0x1ff248(0x9f)],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object[a0_0x1ff248(0x83)],__hasOwnProp=Object[a0_0x1ff248(0xa3)]['hasOwnProperty'],__export=(_0x501bb5,_0x16146a)=>{for(var _0x289cf4 in _0x16146a)__defProp(_0x501bb5,_0x289cf4,{'get':_0x16146a[_0x289cf4],'enumerable':!![]});},__copyProps=(_0x154796,_0x1f50d2,_0x5536d8,_0x41ce3e)=>{const _0x4a748c=a0_0x1ff248;if(_0x1f50d2&&typeof _0x1f50d2===_0x4a748c(0x8d)||typeof _0x1f50d2===_0x4a748c(0xb8)){for(let _0x2bdb73 of __getOwnPropNames(_0x1f50d2))if(!__hasOwnProp[_0x4a748c(0xbb)](_0x154796,_0x2bdb73)&&_0x2bdb73!==_0x5536d8)__defProp(_0x154796,_0x2bdb73,{'get':()=>_0x1f50d2[_0x2bdb73],'enumerable':!(_0x41ce3e=__getOwnPropDesc(_0x1f50d2,_0x2bdb73))||_0x41ce3e['enumerable']});}return _0x154796;},__toESM=(_0x481e8b,_0xcb1016,_0x48ab3f)=>(_0x48ab3f=_0x481e8b!=null?__create(__getProtoOf(_0x481e8b)):{},__copyProps(_0xcb1016||!_0x481e8b||!_0x481e8b[a0_0x1ff248(0xa7)]?__defProp(_0x48ab3f,a0_0x1ff248(0xb9),{'value':_0x481e8b,'enumerable':!![]}):_0x48ab3f,_0x481e8b)),__toCommonJS=_0x3cca89=>__copyProps(__defProp({},a0_0x1ff248(0xa7),{'value':!![]}),_0x3cca89),index_exports={};function a0_0x1f99(){const _0x4b5f37=['application/json','cleanup','body','mediaDevices','Failed\x20to\x20initialize\x20session:\x20','setupWebRTC','18LLaCxz','initializing','2600271Xuqmxd','success','function','default','peerConnection','call','fetchMinutesUsage','events','12ZGQJhk','initializeBackendSession','7772831fAgLph','minutesLeft','close','idle','debug','getTracks','error','sdp','stopTimer','startVoiceSession','97YkESSJ','setStatus','defineProperty','connected','dataChannel','GET','1629056yTTkyA','config','log','Backend\x20initialization\x20failed','emit','5166050HsjFZW','onmessage','/v1/agrasya/connect','audio','session_ended','Minutes\x20left:\x20','socket.io-client','callDuration','disconnect','socket','ephKey','addTrack','getPrototypeOf','statusText','524012wIlluJ','baseUrl','/v1/agrasya/client-token?language=','forEach','audioStream','setLocalDescription','create','setRemoteDescription','object','onCallDurationUpdate','2896332qMuvig','exports','sessionId','srcObject','language','SDP\x20exchange\x20failed:\x20','getUserMedia','answer','setupSocketListeners','appendChild','message','catch','websocket','createDataChannel','model','durationInterval','getOwnPropertyDescriptor','14886ofNWvk','apiKey','15aLGKJs','prototype','ontrack','7zVKkwo','startTimer','__esModule','stop','createOffer','json','parse','data','stringify'];a0_0x1f99=function(){return _0x4b5f37;};return a0_0x1f99();}__export(index_exports,{'AgrasyaVoiceSDK':()=>AgrasyaVoiceSDK}),module[a0_0x1ff248(0x90)]=__toCommonJS(index_exports);var import_socket=__toESM(require(a0_0x1ff248(0x7d))),AgrasyaVoiceSDK=class{['config'];[a0_0x1ff248(0xbd)];['peerConnection']=null;['dataChannel']=null;[a0_0x1ff248(0x89)]=null;['socket']=null;[a0_0x1ff248(0x91)]=null;['ephKey']=null;['dataUrl']=null;[a0_0x1ff248(0x9d)]=null;[a0_0x1ff248(0x7e)]=0x0;['durationInterval']=null;constructor(_0x88fd03,_0x5c0fed={}){const _0x3896b6=a0_0x1ff248;this[_0x3896b6(0x73)]={'baseUrl':'http://localhost:4001','language':'','debug':![],..._0x88fd03},this['events']=_0x5c0fed;}[a0_0x1ff248(0x74)](..._0x30e3ee){const _0x23d357=a0_0x1ff248;this[_0x23d357(0x73)][_0x23d357(0xc4)]&&console[_0x23d357(0x74)]('[AgrasyaSDK]',..._0x30e3ee);}['setStatus'](_0xbf9460){const _0x4d4ad9=a0_0x1ff248;this[_0x4d4ad9(0xbd)]['onStatusChange']?.(_0xbf9460);}['startTimer'](){const _0x561c7d=a0_0x1ff248;this[_0x561c7d(0x7e)]=0x0,this[_0x561c7d(0x9e)]=setInterval(()=>{const _0xa449af=_0x561c7d;this['callDuration']+=0x1,this[_0xa449af(0xbd)][_0xa449af(0x8e)]?.(this['callDuration']);},0x3e8);}[a0_0x1ff248(0xc8)](){const _0x1ac606=a0_0x1ff248;this[_0x1ac606(0x9e)]&&(clearInterval(this[_0x1ac606(0x9e)]),this[_0x1ac606(0x9e)]=null);}async[a0_0x1ff248(0xbf)](){const _0x3fce5c=a0_0x1ff248,_0x26dab7=this[_0x3fce5c(0x73)]['baseUrl']+_0x3fce5c(0x87)+this[_0x3fce5c(0x73)][_0x3fce5c(0x93)],_0x3ccd0a=await fetch(_0x26dab7,{'method':_0x3fce5c(0xcf),'headers':{'x-agrasya-client-api-key':this[_0x3fce5c(0x73)][_0x3fce5c(0xa1)],'Content-Type':'application/json'}});if(!_0x3ccd0a['ok']){const _0x6de229=await _0x3ccd0a[_0x3fce5c(0xaa)]()[_0x3fce5c(0x9a)](()=>({'message':_0x3ccd0a[_0x3fce5c(0x84)]}));throw new Error(_0x3fce5c(0xb2)+(_0x6de229[_0x3fce5c(0x99)]||_0x3ccd0a[_0x3fce5c(0x84)]));}const _0x47eeb5=await _0x3ccd0a[_0x3fce5c(0xaa)]();if(!_0x47eeb5['success'])throw new Error(_0x47eeb5[_0x3fce5c(0x99)]||_0x3fce5c(0x75));return _0x47eeb5[_0x3fce5c(0xac)];}async[a0_0x1ff248(0xb3)](_0x352645){const _0x1359b1=a0_0x1ff248;this[_0x1359b1(0xba)]=new RTCPeerConnection(),this[_0x1359b1(0xce)]=this[_0x1359b1(0xba)][_0x1359b1(0x9c)]('oai-events');this[_0x1359b1(0xce)]&&(this[_0x1359b1(0xce)][_0x1359b1(0x78)]=_0x20b180=>{const _0x3774bc=_0x1359b1,_0xbc630a=JSON[_0x3774bc(0xab)](_0x20b180[_0x3774bc(0xac)]);this[_0x3774bc(0xbd)]['onTranscript']?.(_0xbc630a);});this[_0x1359b1(0xba)][_0x1359b1(0xa4)]=_0x3adc2f=>{const _0x44ec60=_0x1359b1,_0x5b0823=document['createElement'](_0x44ec60(0x7a));_0x5b0823[_0x44ec60(0x92)]=_0x3adc2f['streams'][0x0],_0x5b0823['autoplay']=!![],document[_0x44ec60(0xb0)][_0x44ec60(0x98)](_0x5b0823);},this[_0x1359b1(0x89)]=await navigator[_0x1359b1(0xb1)][_0x1359b1(0x95)]({'audio':!![]});if(this[_0x1359b1(0x89)]){const _0x3a4e5a=this[_0x1359b1(0x89)][_0x1359b1(0xc5)]()[0x0];this[_0x1359b1(0xba)][_0x1359b1(0x82)](_0x3a4e5a,this[_0x1359b1(0x89)]);}const _0x32d3fb=await this[_0x1359b1(0xba)][_0x1359b1(0xa9)]();await this[_0x1359b1(0xba)][_0x1359b1(0x8a)](_0x32d3fb);const _0x201f34=this[_0x1359b1(0x73)][_0x1359b1(0x86)]+_0x1359b1(0x79),_0x19c6b4=await fetch(_0x201f34,{'method':'POST','body':JSON[_0x1359b1(0xad)]({'sessionId':this['sessionId'],'sdp':_0x32d3fb['sdp']}),'headers':{'x-agrasya-client-api-key':this[_0x1359b1(0x73)][_0x1359b1(0xa1)],'Content-Type':_0x1359b1(0xae)}});if(!_0x19c6b4['ok'])throw new Error(_0x1359b1(0x94)+_0x19c6b4[_0x1359b1(0x84)]);const _0x2dbfaf=await _0x19c6b4['json'](),_0x3ddb8b=_0x2dbfaf['data'][_0x1359b1(0xc7)],_0x299531={'type':_0x1359b1(0x96),'sdp':_0x3ddb8b};await this[_0x1359b1(0xba)][_0x1359b1(0x8c)](_0x299531);}[a0_0x1ff248(0x97)](_0xa2b7fc){const _0x219cd7=a0_0x1ff248;_0xa2b7fc['on'](_0x219cd7(0x7f),()=>{this['cleanup']();}),_0xa2b7fc['on'](_0x219cd7(0x7b),()=>{this['cleanup']();});}async[a0_0x1ff248(0xc9)](_0x2e0006){const _0x39f487=a0_0x1ff248;try{this[_0x39f487(0xcb)](_0x39f487(0xb5));const _0x1c167c=await this['initializeBackendSession']();this[_0x39f487(0x91)]=_0x1c167c[_0x39f487(0x91)],this[_0x39f487(0x81)]=_0x1c167c['ephKey'];if(!this[_0x39f487(0x81)])throw new Error('key\x20is\x20null\x20or\x20undefined.');const _0x32bc41=await this[_0x39f487(0xbc)]();this[_0x39f487(0x74)](_0x39f487(0x7c)+_0x32bc41),await this[_0x39f487(0xb3)](this[_0x39f487(0x81)]),this[_0x39f487(0x80)]=(0x0,import_socket[_0x39f487(0xb9)])(this[_0x39f487(0x73)][_0x39f487(0x86)],{'transports':[_0x39f487(0x9b)]}),this[_0x39f487(0x80)][_0x39f487(0x76)]('join_session',{'sessionId':this[_0x39f487(0x91)]}),this[_0x39f487(0x97)](this[_0x39f487(0x80)]),this[_0x39f487(0xcb)](_0x39f487(0xcd)),this[_0x39f487(0xa6)]();}catch(_0x4e8c91){this[_0x39f487(0xcb)](_0x39f487(0xc6));throw _0x4e8c91;}}async['stopVoiceSession'](){const _0x185735=a0_0x1ff248;this[_0x185735(0xaf)]();}[a0_0x1ff248(0xaf)](){const _0x58c622=a0_0x1ff248;this['peerConnection']&&(this[_0x58c622(0xba)][_0x58c622(0xc2)](),this[_0x58c622(0xba)]=null),this['dataChannel']&&(this[_0x58c622(0xce)][_0x58c622(0xc2)](),this['dataChannel']=null),this['audioStream']&&(this[_0x58c622(0x89)]['getTracks']()[_0x58c622(0x88)](_0x1fe3a5=>_0x1fe3a5[_0x58c622(0xa8)]()),this['audioStream']=null),this['socket']&&(this[_0x58c622(0x80)][_0x58c622(0x7f)](),this[_0x58c622(0x80)]=null),this[_0x58c622(0xc8)](),this[_0x58c622(0xcb)](_0x58c622(0xc3));}async['fetchMinutesUsage'](){const _0x14fe4f=a0_0x1ff248,_0x8644b8=this[_0x14fe4f(0x73)][_0x14fe4f(0x86)]+'/v1/agrasya/usage',_0x308ad3=await fetch(_0x8644b8,{'method':_0x14fe4f(0xcf),'headers':{'x-agrasya-client-api-key':this[_0x14fe4f(0x73)][_0x14fe4f(0xa1)],'Content-Type':'application/json'}});if(!_0x308ad3['ok']){const _0x2d1976=await _0x308ad3[_0x14fe4f(0xaa)]()[_0x14fe4f(0x9a)](()=>({'message':_0x308ad3[_0x14fe4f(0x84)]}));throw new Error('Failed\x20to\x20fetch\x20minutes\x20usage:\x20'+(_0x2d1976['message']||_0x308ad3[_0x14fe4f(0x84)]));}const _0x3d5143=await _0x308ad3[_0x14fe4f(0xaa)]();if(!_0x3d5143[_0x14fe4f(0xb7)])throw new Error(_0x3d5143['message']||'Failed\x20to\x20fetch\x20minutes\x20usage');return _0x3d5143[_0x14fe4f(0xac)][_0x14fe4f(0xc1)];}};0x0&&(module['exports']={'AgrasyaVoiceSDK':AgrasyaVoiceSDK});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a1_0x10eb9d=a1_0x36f5;function a1_0x36f5(_0x57cc83,_0x4eed7b){_0x57cc83=_0x57cc83-0x18d;const _0x2e86b1=a1_0x2e86();let _0x36f5fb=_0x2e86b1[_0x57cc83];return _0x36f5fb;}(function(_0x19145e,_0x457c88){const _0x50db16=a1_0x36f5,_0x43fbbe=_0x19145e();while(!![]){try{const _0x262cb1=parseInt(_0x50db16(0x1c0))/0x1+-parseInt(_0x50db16(0x1d8))/0x2+-parseInt(_0x50db16(0x1cd))/0x3*(-parseInt(_0x50db16(0x1bd))/0x4)+-parseInt(_0x50db16(0x19a))/0x5*(parseInt(_0x50db16(0x1dc))/0x6)+parseInt(_0x50db16(0x1ca))/0x7+-parseInt(_0x50db16(0x1a2))/0x8*(parseInt(_0x50db16(0x1da))/0x9)+parseInt(_0x50db16(0x1a3))/0xa*(-parseInt(_0x50db16(0x1ac))/0xb);if(_0x262cb1===_0x457c88)break;else _0x43fbbe['push'](_0x43fbbe['shift']());}catch(_0x1c1b83){_0x43fbbe['push'](_0x43fbbe['shift']());}}}(a1_0x2e86,0x79e48));import a1_0x2e9fff from'socket.io-client';function a1_0x2e86(){const _0x58dd65=['SDP\x20exchange\x20failed:\x20','1431VGvrQB','http://localhost:4001','6ZtjSMe','stopTimer','statusText','setupWebRTC','cleanup','setRemoteDescription','peerConnection','[AgrasyaSDK]','sdp','onTranscript','srcObject','audioStream','emit','error','ephKey','getUserMedia','model','733765NZmfob','events','onmessage','mediaDevices','/v1/agrasya/usage','initializing','forEach','GET','49608umouKT','10ShsEbD','streams','/v1/agrasya/connect','join_session','catch','json','Failed\x20to\x20fetch\x20minutes\x20usage','success','data','1433839aSKRNn','language','setLocalDescription','session_ended','createElement','message','createOffer','appendChild','answer','minutesLeft','Backend\x20initialization\x20failed','parse','debug','fetchMinutesUsage','POST','dataUrl','startTimer','1254716nuTYPL','initializeBackendSession','audio','840928rhFqhR','connected','close','application/json','oai-events','log','apiKey','key\x20is\x20null\x20or\x20undefined.','socket','dataChannel','278782hwjnMK','onCallDurationUpdate','onStatusChange','9zkLzGL','setStatus','baseUrl','getTracks','sessionId','setupSocketListeners','durationInterval','Failed\x20to\x20initialize\x20session:\x20','config','callDuration','Minutes\x20left:\x20','118916VhYHeS'];a1_0x2e86=function(){return _0x58dd65;};return a1_0x2e86();}var AgrasyaVoiceSDK=class{[a1_0x10eb9d(0x1d5)];[a1_0x10eb9d(0x19b)];[a1_0x10eb9d(0x18f)]=null;[a1_0x10eb9d(0x1c9)]=null;[a1_0x10eb9d(0x194)]=null;[a1_0x10eb9d(0x1c8)]=null;[a1_0x10eb9d(0x1d1)]=null;[a1_0x10eb9d(0x197)]=null;[a1_0x10eb9d(0x1bb)]=null;[a1_0x10eb9d(0x199)]=null;[a1_0x10eb9d(0x1d6)]=0x0;['durationInterval']=null;constructor(_0x51c53a,_0x11182e={}){const _0x8dd2a4=a1_0x10eb9d;this[_0x8dd2a4(0x1d5)]={'baseUrl':_0x8dd2a4(0x1db),'language':'','debug':![],..._0x51c53a},this[_0x8dd2a4(0x19b)]=_0x11182e;}[a1_0x10eb9d(0x1c5)](..._0x42bed1){const _0x1fd153=a1_0x10eb9d;this['config'][_0x1fd153(0x1b8)]&&console[_0x1fd153(0x1c5)](_0x1fd153(0x190),..._0x42bed1);}[a1_0x10eb9d(0x1ce)](_0x4477cd){const _0x3511ff=a1_0x10eb9d;this[_0x3511ff(0x19b)][_0x3511ff(0x1cc)]?.(_0x4477cd);}[a1_0x10eb9d(0x1bc)](){const _0x19786a=a1_0x10eb9d;this[_0x19786a(0x1d6)]=0x0,this['durationInterval']=setInterval(()=>{const _0x4720d3=_0x19786a;this[_0x4720d3(0x1d6)]+=0x1,this[_0x4720d3(0x19b)][_0x4720d3(0x1cb)]?.(this[_0x4720d3(0x1d6)]);},0x3e8);}[a1_0x10eb9d(0x1dd)](){const _0x48d76a=a1_0x10eb9d;this[_0x48d76a(0x1d3)]&&(clearInterval(this[_0x48d76a(0x1d3)]),this[_0x48d76a(0x1d3)]=null);}async[a1_0x10eb9d(0x1be)](){const _0x47ff1c=a1_0x10eb9d,_0x4e579b=this['config'][_0x47ff1c(0x1cf)]+'/v1/agrasya/client-token?language='+this[_0x47ff1c(0x1d5)][_0x47ff1c(0x1ad)],_0x2d8a24=await fetch(_0x4e579b,{'method':'GET','headers':{'x-agrasya-client-api-key':this[_0x47ff1c(0x1d5)]['apiKey'],'Content-Type':_0x47ff1c(0x1c3)}});if(!_0x2d8a24['ok']){const _0xe70751=await _0x2d8a24[_0x47ff1c(0x1a8)]()[_0x47ff1c(0x1a7)](()=>({'message':_0x2d8a24['statusText']}));throw new Error(_0x47ff1c(0x1d4)+(_0xe70751['message']||_0x2d8a24[_0x47ff1c(0x1de)]));}const _0xb2d4a0=await _0x2d8a24[_0x47ff1c(0x1a8)]();if(!_0xb2d4a0[_0x47ff1c(0x1aa)])throw new Error(_0xb2d4a0[_0x47ff1c(0x1b1)]||_0x47ff1c(0x1b6));return _0xb2d4a0[_0x47ff1c(0x1ab)];}async[a1_0x10eb9d(0x1df)](_0xe6da4c){const _0x44b95b=a1_0x10eb9d;this[_0x44b95b(0x18f)]=new RTCPeerConnection(),this[_0x44b95b(0x1c9)]=this['peerConnection']['createDataChannel'](_0x44b95b(0x1c4));this['dataChannel']&&(this[_0x44b95b(0x1c9)][_0x44b95b(0x19c)]=_0x3751ef=>{const _0xb16233=_0x44b95b,_0x575022=JSON[_0xb16233(0x1b7)](_0x3751ef['data']);this[_0xb16233(0x19b)][_0xb16233(0x192)]?.(_0x575022);});this[_0x44b95b(0x18f)]['ontrack']=_0x82a043=>{const _0x20628a=_0x44b95b,_0x48f497=document[_0x20628a(0x1b0)](_0x20628a(0x1bf));_0x48f497[_0x20628a(0x193)]=_0x82a043[_0x20628a(0x1a4)][0x0],_0x48f497['autoplay']=!![],document['body'][_0x20628a(0x1b3)](_0x48f497);},this[_0x44b95b(0x194)]=await navigator[_0x44b95b(0x19d)][_0x44b95b(0x198)]({'audio':!![]});if(this['audioStream']){const _0x2cf0ee=this[_0x44b95b(0x194)][_0x44b95b(0x1d0)]()[0x0];this['peerConnection']['addTrack'](_0x2cf0ee,this['audioStream']);}const _0x38cff8=await this[_0x44b95b(0x18f)][_0x44b95b(0x1b2)]();await this[_0x44b95b(0x18f)][_0x44b95b(0x1ae)](_0x38cff8);const _0x50570=this['config'][_0x44b95b(0x1cf)]+_0x44b95b(0x1a5),_0x48ed03=await fetch(_0x50570,{'method':_0x44b95b(0x1ba),'body':JSON['stringify']({'sessionId':this[_0x44b95b(0x1d1)],'sdp':_0x38cff8['sdp']}),'headers':{'x-agrasya-client-api-key':this['config'][_0x44b95b(0x1c6)],'Content-Type':_0x44b95b(0x1c3)}});if(!_0x48ed03['ok'])throw new Error(_0x44b95b(0x1d9)+_0x48ed03[_0x44b95b(0x1de)]);const _0x5d3362=await _0x48ed03[_0x44b95b(0x1a8)](),_0x425cb1=_0x5d3362['data'][_0x44b95b(0x191)],_0x1f03fd={'type':_0x44b95b(0x1b4),'sdp':_0x425cb1};await this[_0x44b95b(0x18f)][_0x44b95b(0x18e)](_0x1f03fd);}[a1_0x10eb9d(0x1d2)](_0x47d7df){const _0x364aab=a1_0x10eb9d;_0x47d7df['on']('disconnect',()=>{this['cleanup']();}),_0x47d7df['on'](_0x364aab(0x1af),()=>{const _0xe9cc21=_0x364aab;this[_0xe9cc21(0x18d)]();});}async['startVoiceSession'](_0x310447){const _0x56fd3b=a1_0x10eb9d;try{this[_0x56fd3b(0x1ce)](_0x56fd3b(0x19f));const _0x28949b=await this[_0x56fd3b(0x1be)]();this['sessionId']=_0x28949b[_0x56fd3b(0x1d1)],this[_0x56fd3b(0x197)]=_0x28949b[_0x56fd3b(0x197)];if(!this[_0x56fd3b(0x197)])throw new Error(_0x56fd3b(0x1c7));const _0x5136ed=await this[_0x56fd3b(0x1b9)]();this[_0x56fd3b(0x1c5)](_0x56fd3b(0x1d7)+_0x5136ed),await this[_0x56fd3b(0x1df)](this[_0x56fd3b(0x197)]),this[_0x56fd3b(0x1c8)]=a1_0x2e9fff(this[_0x56fd3b(0x1d5)]['baseUrl'],{'transports':['websocket']}),this['socket'][_0x56fd3b(0x195)](_0x56fd3b(0x1a6),{'sessionId':this[_0x56fd3b(0x1d1)]}),this[_0x56fd3b(0x1d2)](this[_0x56fd3b(0x1c8)]),this[_0x56fd3b(0x1ce)](_0x56fd3b(0x1c1)),this[_0x56fd3b(0x1bc)]();}catch(_0x2953b6){this[_0x56fd3b(0x1ce)](_0x56fd3b(0x196));throw _0x2953b6;}}async['stopVoiceSession'](){this['cleanup']();}['cleanup'](){const _0xa02172=a1_0x10eb9d;this[_0xa02172(0x18f)]&&(this[_0xa02172(0x18f)][_0xa02172(0x1c2)](),this[_0xa02172(0x18f)]=null),this[_0xa02172(0x1c9)]&&(this[_0xa02172(0x1c9)][_0xa02172(0x1c2)](),this[_0xa02172(0x1c9)]=null),this[_0xa02172(0x194)]&&(this[_0xa02172(0x194)][_0xa02172(0x1d0)]()[_0xa02172(0x1a0)](_0x52a399=>_0x52a399['stop']()),this['audioStream']=null),this[_0xa02172(0x1c8)]&&(this[_0xa02172(0x1c8)]['disconnect'](),this[_0xa02172(0x1c8)]=null),this['stopTimer'](),this[_0xa02172(0x1ce)]('idle');}async['fetchMinutesUsage'](){const _0x4ec69e=a1_0x10eb9d,_0x5f4a0e=this[_0x4ec69e(0x1d5)][_0x4ec69e(0x1cf)]+_0x4ec69e(0x19e),_0xb70b88=await fetch(_0x5f4a0e,{'method':_0x4ec69e(0x1a1),'headers':{'x-agrasya-client-api-key':this['config'][_0x4ec69e(0x1c6)],'Content-Type':_0x4ec69e(0x1c3)}});if(!_0xb70b88['ok']){const _0x84476a=await _0xb70b88[_0x4ec69e(0x1a8)]()[_0x4ec69e(0x1a7)](()=>({'message':_0xb70b88[_0x4ec69e(0x1de)]}));throw new Error('Failed\x20to\x20fetch\x20minutes\x20usage:\x20'+(_0x84476a[_0x4ec69e(0x1b1)]||_0xb70b88[_0x4ec69e(0x1de)]));}const _0x19f5f6=await _0xb70b88[_0x4ec69e(0x1a8)]();if(!_0x19f5f6['success'])throw new Error(_0x19f5f6[_0x4ec69e(0x1b1)]||_0x4ec69e(0x1a9));return _0x19f5f6['data'][_0x4ec69e(0x1b5)];}};export{AgrasyaVoiceSDK};
|