terminal-gateway 1.0.18 → 1.0.20
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/lib/terminal.js +1 -1
- package/package.json +1 -1
package/lib/terminal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function a0_0x44f2(){const _0x54849f=['Timeout','1494830GWuBzq','serial','cancel','onSale','1182976EQhKdy','5892808aKOfCl','SALE_CANCEL','VOID','handleReleasePort','232159izaAVn','error','addEventListener','7hZZnbo','onErrors','69GBNdjt','requestPort','then','Your\x20browser\x20is\x20not\x20supported.','Key\x20is\x20not\x20empty.','stringify','Device\x20lost\x20connection','connect','length','Device\x20has\x20connected.','pipeTo','toString','4183490mrYiCK','message','close','getWriter','getReader','onSuccess','releaseLock','readable','catch','9mmbYWv','You\x20do\x20not\x20provide\x20me\x20your\x20key.\x20Please\x20help\x20provide\x20me\x20your\x20key.','getTesting','push','Connected','writable','read','replace','disconnect','getPorts','write','slice','7858CfisSO','2358576xyLWVJ','open','onVoid','none','toUpperCase','split','onCancel','MEMENQ','SALE','onEnquiry'];a0_0x44f2=function(){return _0x54849f;};return a0_0x44f2();}const a0_0x252ee6=a0_0x2d22;(function(_0x55e08b,_0x4f27f9){const _0x4c2424=a0_0x2d22,_0x2188a0=_0x55e08b();while(!![]){try{const _0x3426da=parseInt(_0x4c2424(0xcb))/0x1+parseInt(_0x4c2424(0xb6))/0x2*(parseInt(_0x4c2424(0x95))/0x3)+-parseInt(_0x4c2424(0xc6))/0x4+-parseInt(_0x4c2424(0xc2))/0x5+parseInt(_0x4c2424(0xb7))/0x6+-parseInt(_0x4c2424(0xce))/0x7*(-parseInt(_0x4c2424(0xc7))/0x8)+-parseInt(_0x4c2424(0xaa))/0x9*(parseInt(_0x4c2424(0xa1))/0xa);if(_0x3426da===_0x4f27f9)break;else _0x2188a0['push'](_0x2188a0['shift']());}catch(_0x53be2d){_0x2188a0['push'](_0x2188a0['shift']());}}}(a0_0x44f2,0x6b37c));function a0_0x2d22(_0x2b8426,_0x721bdb){const _0x44f201=a0_0x44f2();return a0_0x2d22=function(_0x2d2251,_0x557375){_0x2d2251=_0x2d2251-0x94;let _0x139258=_0x44f201[_0x2d2251];return _0x139258;},a0_0x2d22(_0x2b8426,_0x721bdb);}import a0_0x341cf0,{enc}from'crypto-js';class Terminal{#KEY=null;#DATA=null;#PORT=null;#TIMER=null;#WRITER=null;#READER=null;#TIMEOUT=null;#DATE_BITS=0x8;#STOP_BITS=0x1;#BAUD_RATE=0x1c200;#PARITY=a0_0x252ee6(0xba);#BUFFER_SIZE=0x400;#MD5_ENCRYPTION=null;#WRITABLE_STREAM_CLOSED=null;#READABLE_STREAM_CLOSED=null;#DATE_FORMAT=new Date()['toISOString']()['replace']('T','\x20')[a0_0x252ee6(0xb1)]('Z','')[a0_0x252ee6(0xbc)]('.')[0x0];#FILTERS=[{'usbVendorId':0x5c6,'usbProductId':0x9025},{'usbVendorId':0x67b,'usbProductId':0x2303}];#SUPPORTED_BROWSER=0x1;#OPEN_SERIAL_PORT_ERROR=0x2;#OPEN_SERIAL_PORT_PAIR_ERROR=0x3;#WRITE_STREAM_ERROR=0x4;#READ_STREAM_ERROR=0x5;#VALIDATE_KEY=0x6;#CONNECTED_SERIAL_PORT=0x7;#DISCONNECTED_SERIAL_PORT=0x8;constructor({key:_0x6997da,timeout:_0x254f49,onConnected:_0x8dc339,onSuccess:_0x10cd38,onErrors:_0x3a0ad8}){const _0x10f6e9=a0_0x252ee6;if(!_0x6997da)console[_0x10f6e9(0xcc)](_0x10f6e9(0xab));this.#KEY=_0x6997da,this.#TIMEOUT=_0x254f49||0xea60,this[_0x10f6e9(0xa6)]=_0x10cd38||function(){},this[_0x10f6e9(0x94)]=_0x3a0ad8||function(){},this['onConnected']=_0x8dc339||function(){},!this.#isSupportedBrowser()&&(console['error'](_0x10f6e9(0x98)),this[_0x10f6e9(0x94)]({'status':this.#SUPPORTED_BROWSER,'message':'Your\x20browser\x20is\x20not\x20supported.'})),navigator[_0x10f6e9(0xc3)][_0x10f6e9(0xcd)](_0x10f6e9(0x9c),_0x487485=>{const _0x512879=_0x10f6e9;this[_0x512879(0xa6)]({'status':this.#CONNECTED_SERIAL_PORT,'message':_0x512879(0x9e)});if(this.#TIMER)clearTimeout(this.#TIMER);}),navigator[_0x10f6e9(0xc3)][_0x10f6e9(0xcd)](_0x10f6e9(0xb2),async _0x718132=>{const _0x18f704=_0x10f6e9;this[_0x18f704(0xa6)]({'status':this.#DISCONNECTED_SERIAL_PORT,'message':_0x18f704(0x9b)});if(this.#TIMER)clearTimeout(this.#TIMER);});}#handleRequestSerialPort(){return new Promise((_0x453048,_0x4b7d52)=>{const _0xbcc22c=a0_0x2d22;return navigator[_0xbcc22c(0xc3)][_0xbcc22c(0x96)]({'filters':this.#FILTERS})['then'](_0x5e77d0=>{_0x453048(_0x5e77d0);})['catch'](_0x492473=>{_0x4b7d52({'status':this.#OPEN_SERIAL_PORT_ERROR,'message':_0x492473?.['message']});});});}#handleOpenSerialPort(){return new Promise((_0x57f8e5,_0x5af292)=>{const _0x54cae7=a0_0x2d22;return this.#PORT[_0x54cae7(0xb8)]({'baudRate':this.#BAUD_RATE,'dataBits':this.#DATE_BITS,'stopBits':this.#STOP_BITS,'parity':this.#PARITY,'bufferSize':this.#BUFFER_SIZE})[_0x54cae7(0x97)](_0x7559e9=>_0x57f8e5(_0x7559e9))[_0x54cae7(0xa9)](_0x4de97b=>{const _0x3adbb1=_0x54cae7;_0x5af292({'status':this.#OPEN_SERIAL_PORT_PAIR_ERROR,'message':_0x4de97b?.[_0x3adbb1(0xa2)]});});});}async[a0_0x252ee6(0xc5)]({amount:_0x4538d9,type:_0x4362b9,currency:_0x5bbf6e,invoice:_0x3e5824}){const _0xc51a77=a0_0x252ee6;try{if(!this.#isSupportedBrowser()){console[_0xc51a77(0xcc)](_0xc51a77(0x98)),this[_0xc51a77(0x94)]({'status':this.#SUPPORTED_BROWSER,'message':_0xc51a77(0x98)});return;}if(!this.#KEY){this['onErrors']({'status':this.#VALIDATE_KEY,'message':_0xc51a77(0x99)});return;}const _0x141dd6=await navigator['serial'][_0xc51a77(0xb3)]();!this.#PORT&&!_0x141dd6[_0xc51a77(0x9d)]?(this.#PORT=await this.#handleRequestSerialPort(),await this.#handleOpenSerialPort(),this['onSuccess']({'status':this.#SUPPORTED_BROWSER,'message':_0xc51a77(0xae)})):(this.#PORT=_0x141dd6[0x0],await this.#handleOpenSerialPort());this.#DATA=this.#handleGenerateJSONObject({'CMD':_0xc51a77(0xbf),'type':_0x4362b9,'amount':_0x4538d9,'currency':_0x5bbf6e,'invoice':_0x3e5824});const _0x12fc47=this.#handleGenerateMD5(this.#DATA);await this.#handleWriteStream(_0x12fc47),this.#handleSetTimeout(),this.#handleReadStream(),await this.#listenToTerminal();}catch(_0x479a00){this[_0xc51a77(0x94)](_0x479a00);}}async[a0_0x252ee6(0xb9)]({traceId:_0xce6623}){const _0x57e748=a0_0x252ee6;try{if(!this.#isSupportedBrowser()){console['error']('Your\x20browser\x20is\x20not\x20supported.'),this[_0x57e748(0x94)]({'status':this.#SUPPORTED_BROWSER,'message':_0x57e748(0x98)});return;}if(!this.#KEY){this[_0x57e748(0x94)]({'status':this.#VALIDATE_KEY,'message':_0x57e748(0x99)});return;}if(!this.#PORT&&!ports[_0x57e748(0x9d)])this.#PORT=await this.#handleRequestSerialPort(),await this.#handleOpenSerialPort(),this[_0x57e748(0xa6)]({'status':this.#SUPPORTED_BROWSER,'message':_0x57e748(0xae)});else{const _0x5b5cc0=await navigator[_0x57e748(0xc3)][_0x57e748(0xb3)]();this.#PORT=_0x5b5cc0[0x0],await this.#handleOpenSerialPort();}const _0x8f9a99=this.#handleGenerateJSONObject({'CMD':'VOID','traceId':_0xce6623}),_0x216bb0=this.#handleGenerateMD5(_0x8f9a99);await this.#handleWriteStream(_0x216bb0),this.#handleReadStream(),await this.#listenToTerminal();}catch(_0x577a48){this[_0x57e748(0x94)](_0x577a48);}}async[a0_0x252ee6(0xc0)]({invoice:_0x585ae9}){const _0x2c645a=a0_0x252ee6;try{if(!this.#isSupportedBrowser()){console[_0x2c645a(0xcc)](_0x2c645a(0x98)),this[_0x2c645a(0x94)]({'status':this.#SUPPORTED_BROWSER,'message':_0x2c645a(0x98)});return;}if(!this.#KEY){this[_0x2c645a(0x94)]({'status':this.#VALIDATE_KEY,'message':'Key\x20is\x20not\x20empty.'});return;}if(!this.#PORT&&!ports[_0x2c645a(0x9d)])this.#PORT=await this.#handleRequestSerialPort(),await this.#handleOpenSerialPort(),this[_0x2c645a(0xa6)]({'status':this.#SUPPORTED_BROWSER,'message':'Connected'});else{const _0x547e7f=await navigator[_0x2c645a(0xc3)]['getPorts']();this.#PORT=_0x547e7f[0x0],await this.#handleOpenSerialPort();}const _0x33c175=this.#handleGenerateJSONObject({'CMD':_0x2c645a(0xbe),'invoice':_0x585ae9}),_0x275a5c=this.#handleGenerateMD5(_0x33c175);await this.#handleWriteStream(_0x275a5c),this.#handleReadStream(),await this.#listenToTerminal();}catch(_0xf01657){this[_0x2c645a(0x94)](_0xf01657);}}async[a0_0x252ee6(0xbd)](){const _0x187ef5=a0_0x252ee6;try{if(!this.#isSupportedBrowser()){console['error'](_0x187ef5(0x98)),this[_0x187ef5(0x94)]({'status':this.#SUPPORTED_BROWSER,'message':_0x187ef5(0x98)});return;}if(!this.#KEY){this['onErrors']({'status':this.#VALIDATE_KEY,'message':_0x187ef5(0x99)});return;}this[_0x187ef5(0xca)]();const _0x35a772=await navigator[_0x187ef5(0xc3)][_0x187ef5(0xb3)]();this.#PORT=_0x35a772[0x0],await this.#handleOpenSerialPort();const _0x1addf0=this.#handleGenerateJSONObject({'CMD':_0x187ef5(0xc8)}),_0x75137f=this.#handleGenerateMD5(_0x1addf0);await this.#handleWriteStream(_0x75137f),this.#handleReadStream(),await this.#listenToTerminal();}catch(_0x3c3d3b){this[_0x187ef5(0x94)](_0x3c3d3b);}}#handleWriteStream(_0x939160){return new Promise((_0x8816d7,_0x136434)=>{const _0x45b10f=a0_0x2d22,_0x562fd6=new TextEncoderStream();return this.#WRITABLE_STREAM_CLOSED=_0x562fd6[_0x45b10f(0xa8)][_0x45b10f(0x9f)](this.#PORT[_0x45b10f(0xaf)]),this.#WRITER=_0x562fd6[_0x45b10f(0xaf)][_0x45b10f(0xa4)](),this.#WRITER[_0x45b10f(0xb4)](_0x939160)[_0x45b10f(0x97)](_0xbea4b2=>{_0x8816d7(_0xbea4b2);})[_0x45b10f(0xa9)](_0x5617fb=>{const _0x1b2a5e=_0x45b10f;_0x136434({'status':this.#WRITE_STREAM_ERROR,'message':_0x5617fb?.[_0x1b2a5e(0xa2)]});});});}#handleReadStream(){const _0x12b4e0=a0_0x252ee6;try{const _0x80b998=new TextDecoderStream();this.#READABLE_STREAM_CLOSED=this.#PORT[_0x12b4e0(0xa8)][_0x12b4e0(0x9f)](_0x80b998[_0x12b4e0(0xaf)]),this.#READER=_0x80b998[_0x12b4e0(0xa8)][_0x12b4e0(0xa5)]();}catch(_0x2e08a6){this[_0x12b4e0(0x94)]({'status':this.#READ_STREAM_ERROR,'message':_0x2e08a6?.[_0x12b4e0(0xa2)]});}}#handleGenerateJSONObject({CMD:_0x5e3f30,type:_0x365df3,amount:_0x3f424e,currency:_0xd64c6f,invoice:_0x947587,traceId:_0x760547}){const _0x5b2794=a0_0x252ee6;let _0x5c483f={};switch(_0x5e3f30){case'SALE':_0x5c483f={'CMD':'SALE','TYPE':_0x365df3[_0x5b2794(0xa0)](),'AMT':_0x3f424e[_0x5b2794(0xa0)](),'CURRCODE':_0xd64c6f[_0x5b2794(0xa0)](),'TIMESTAMP':this.#DATE_FORMAT,'ECRREF':_0x947587[_0x5b2794(0xa0)]()};break;case _0x5b2794(0xc9):_0x5c483f={'CMD':_0x5b2794(0xc9),'TIMESTAMP':this.#DATE_FORMAT,'TRACE':_0x760547[_0x5b2794(0xa0)]()};break;case'MEMENQ':_0x5c483f={'CMD':_0x5b2794(0xbe),'TIMESTAMP':this.#DATE_FORMAT,'ECRREF':_0x947587[_0x5b2794(0xa0)]()};break;case _0x5b2794(0xc8):_0x5c483f={'CMD':_0x5b2794(0xc8),'TIMESTAMP':this.#DATE_FORMAT};break;}return _0x5c483f;}#handleGenerateMD5(_0x19c4fd){const _0xa29aa6=a0_0x252ee6,_0x5599be=JSON[_0xa29aa6(0x9a)](_0x19c4fd)+this.#KEY;return this.#MD5_ENCRYPTION=a0_0x341cf0['MD5'](_0x5599be)[_0xa29aa6(0xa0)]()[_0xa29aa6(0xbb)](),'@'+this.#MD5_ENCRYPTION+JSON[_0xa29aa6(0x9a)](_0x19c4fd);}async #listenToTerminal(){const _0x2f7319=a0_0x252ee6;try{const _0x51376b=[];let _0x39eb62='',_0x27c817=0x0;while(!![]){const {value:_0x17ce92,done:_0x46d4b1}=await this.#READER[_0x2f7319(0xb0)]();if(_0x46d4b1){this.#READER[_0x2f7319(0xa7)]();break;}if(this.#TIMER)clearTimeout(this.#TIMER);_0x39eb62+=_0x17ce92,_0x27c817+=0x1;const _0x4292f8=setTimeout(async()=>{this.#handlePrintResult(_0x39eb62),this.#handleReleasePort();},0x64);_0x51376b[_0x2f7319(0xad)](_0x4292f8),clearTimeout(_0x51376b[_0x27c817-0x2]);}}catch(_0x5d0aee){this[_0x2f7319(0x94)]({'status':this.#READ_STREAM_ERROR,'message':_0x5d0aee?.['message']});}}#handleSetTimeout(){this.#TIMER=setTimeout(async()=>{const _0x50abd3=a0_0x2d22,_0x5d5328='@'+this.#MD5_ENCRYPTION+JSON[_0x50abd3(0x9a)]({...this.#DATA,'APV':'','PAN':'','PAYER':'','MESSAGE':'','TRXN_ID':'','TRACE':'','STATUS':_0x50abd3(0xc1)});this.#handlePrintResult(_0x5d5328),this.#handleReleasePort();},this.#TIMEOUT);}#handlePrintResult(_0x3808d3){const _0x4a41e4=a0_0x252ee6;if(!_0x3808d3)return;this[_0x4a41e4(0xa6)]({'key':this.#KEY,'value':JSON['parse'](_0x3808d3[_0x4a41e4(0xb5)](0x21))});}async #handleReleasePort(){const _0x58a64e=a0_0x252ee6;this.#READER[_0x58a64e(0xc4)](),await this.#READABLE_STREAM_CLOSED[_0x58a64e(0xa9)](()=>{}),this.#WRITER[_0x58a64e(0xa3)](),await this.#WRITABLE_STREAM_CLOSED[_0x58a64e(0xa9)](()=>{}),await this.#PORT[_0x58a64e(0xa3)]();}#isSupportedBrowser(){const _0x42e0fd=a0_0x252ee6;return _0x42e0fd(0xc3)in navigator;}[a0_0x252ee6(0xac)](){return'your\x20testing\x20it\x20ok';}}export default Terminal;
|
|
1
|
+
const a0_0xb487c4=a0_0xba58;(function(_0x239f7a,_0x8b761){const _0x2a6154=a0_0xba58,_0x25af3d=_0x239f7a();while(!![]){try{const _0x2c8cf0=parseInt(_0x2a6154(0x15b))/0x1*(parseInt(_0x2a6154(0x160))/0x2)+-parseInt(_0x2a6154(0x158))/0x3*(parseInt(_0x2a6154(0x164))/0x4)+parseInt(_0x2a6154(0x136))/0x5+parseInt(_0x2a6154(0x15c))/0x6+-parseInt(_0x2a6154(0x16a))/0x7+-parseInt(_0x2a6154(0x149))/0x8*(parseInt(_0x2a6154(0x13e))/0x9)+parseInt(_0x2a6154(0x14b))/0xa;if(_0x2c8cf0===_0x8b761)break;else _0x25af3d['push'](_0x25af3d['shift']());}catch(_0x1a1544){_0x25af3d['push'](_0x25af3d['shift']());}}}(a0_0x456a,0x84e57));function a0_0xba58(_0x158501,_0x421ff6){const _0x456a46=a0_0x456a();return a0_0xba58=function(_0xba581c,_0x29ff32){_0xba581c=_0xba581c-0x136;let _0x5801b0=_0x456a46[_0xba581c];return _0x5801b0;},a0_0xba58(_0x158501,_0x421ff6);}import a0_0x25d0ac from'crypto-js/md5';function a0_0x456a(){const _0x1d8b82=['push','split','catch','length','onError','then','onConnected','addEventListener','Connected','134584jxlmnh','close','11112380lnLAwA','CANCEL','keys','onForget','toUpperCase','forget','getPorts','releaseLock','connect','stringify','replace','cmd','serial','9uCyXNb','disconnect','readable','82077oBvSrI','2236194KjqEYj','Forget\x20device\x20success','writable','onSuccess','10iYwCRR','log','Timeout','getReader','332084LSxRDD','write','getWriter','onSale','toString','Device\x20has\x20been\x20lost\x20connection','2002574ZgXPSZ','open','1056845FvVdKN','requestPort','Your\x20browser\x20is\x20not\x20supported.','Not\x20provide\x20key.','message','reduce','onCancel','none','549HvxjUR','SALE'];a0_0x456a=function(){return _0x1d8b82;};return a0_0x456a();}export default class Terminal{#KEY=null;#DATA=null;#PORT=null;#TIMER=null;#WRITER=null;#READER=null;#TIMEOUT=null;#DATE_BITS=0x8;#STOP_BITS=0x1;#BAUD_RATE=0x1c200;#PARITY=a0_0xb487c4(0x13d);#BUFFER_SIZE=0x400;#MD5_ENCRYPTION=null;#WRITABLE_STREAM_CLOSED=null;#READABLE_STREAM_CLOSED=null;#DATE_FORMAT=new Date()['toISOString']()['replace']('T','\x20')[a0_0xb487c4(0x155)]('Z','')[a0_0xb487c4(0x141)]('.')[0x0];#FILTERS=[{'usbVendorId':0x67b,'usbProductId':0x23a3},{'usbVendorId':0x67b,'usbProductId':0x2303}];#SUPPORTED_BROWSER=0x1;#OPEN_SERIAL_PORT_ERROR=0x2;#OPEN_SERIAL_PORT_PAIR_ERROR=0x3;#WRITE_STREAM_ERROR=0x4;#READ_STREAM_ERROR=0x5;#VALIDATE_KEY=0x6;#CONNECTED_SERIAL_PORT=0x7;#DISCONNECTED_SERIAL_PORT=0x8;#FORGET_PORT=0x9;#CANCEL_TRANSACTION=0xa;constructor({key:_0x55a303,timeout:_0x89a5a8,onConnected:_0x5acae3,onSuccess:_0x3cedf4,onError:_0x31d1fc}){const _0x422a41=a0_0xb487c4;!_0x55a303&&(console[_0x422a41(0x161)]('You\x20do\x20not\x20provide\x20me\x20your\x20key.\x20Please\x20help\x20provide\x20me\x20your\x20key.'),this[_0x422a41(0x144)]({'status':this.#VALIDATE_KEY,'message':_0x422a41(0x139)})),this.#KEY=_0x55a303,this.#TIMEOUT=_0x89a5a8||0xea60,this[_0x422a41(0x15f)]=_0x3cedf4||function(){},this[_0x422a41(0x144)]=_0x31d1fc||function(){},this[_0x422a41(0x146)]=_0x5acae3||function(){},!this.#isSupportedBrowser()&&(console[_0x422a41(0x161)](_0x422a41(0x138)),this['onError']({'status':this.#SUPPORTED_BROWSER,'message':'Your\x20browser\x20is\x20not\x20supported.'})),navigator[_0x422a41(0x157)]['addEventListener'](_0x422a41(0x153),_0x3aa406=>{const _0x4feeb7=_0x422a41;this[_0x4feeb7(0x15f)]({'status':this.#CONNECTED_SERIAL_PORT,'message':'Device\x20has\x20been\x20connected.'});if(this.#TIMER)clearTimeout(this.#TIMER);}),navigator['serial'][_0x422a41(0x147)](_0x422a41(0x159),_0xa882b5=>{const _0x3e8b81=_0x422a41;this['onError']({'status':this.#DISCONNECTED_SERIAL_PORT,'message':_0x3e8b81(0x169)});if(this.#TIMER)clearTimeout(this.#TIMER);});}#handleRequestSerialPort(){return new Promise((_0x41491f,_0x2bacba)=>{const _0x461789=a0_0xba58;return navigator[_0x461789(0x157)][_0x461789(0x137)]({'filters':this.#FILTERS})[_0x461789(0x145)](_0x6815f2=>{_0x41491f(_0x6815f2);})[_0x461789(0x142)](_0x8caa0e=>{const _0x57f2fb=_0x461789;_0x2bacba({'status':this.#OPEN_SERIAL_PORT_ERROR,'message':_0x8caa0e?.[_0x57f2fb(0x13a)]});});});}#handleOpenSerialPort(){return new Promise((_0x4dc71a,_0x5267fc)=>{const _0x16c378=a0_0xba58;return this.#PORT[_0x16c378(0x16b)]({'baudRate':this.#BAUD_RATE,'dataBits':this.#DATE_BITS,'stopBits':this.#STOP_BITS,'parity':this.#PARITY,'bufferSize':this.#BUFFER_SIZE})[_0x16c378(0x145)](_0x26e2b2=>_0x4dc71a(_0x26e2b2))['catch'](_0x49781a=>{const _0x5a9fa0=_0x16c378;_0x5267fc({'status':this.#OPEN_SERIAL_PORT_PAIR_ERROR,'message':_0x49781a?.[_0x5a9fa0(0x13a)]});});});}#handleWriteStream(_0xe7514b){return new Promise((_0x55d7fb,_0x45af5f)=>{const _0x108ea8=a0_0xba58,_0xfe0152=new TextEncoderStream();return this.#WRITABLE_STREAM_CLOSED=_0xfe0152[_0x108ea8(0x15a)]['pipeTo'](this.#PORT[_0x108ea8(0x15e)]),this.#WRITER=_0xfe0152[_0x108ea8(0x15e)][_0x108ea8(0x166)](),this.#WRITER[_0x108ea8(0x165)](_0xe7514b)[_0x108ea8(0x145)](_0x304373=>{_0x55d7fb(_0x304373);})['catch'](_0x847bb9=>{const _0x401549=_0x108ea8;_0x45af5f({'status':this.#WRITE_STREAM_ERROR,'message':_0x847bb9?.[_0x401549(0x13a)]});});});}#handleReadStream(){const _0x2ca26a=a0_0xb487c4;try{const _0x457ade=new TextDecoderStream();this.#READABLE_STREAM_CLOSED=this.#PORT['readable']['pipeTo'](_0x457ade[_0x2ca26a(0x15e)]),this.#READER=_0x457ade[_0x2ca26a(0x15a)][_0x2ca26a(0x163)]();}catch(_0x28b131){this[_0x2ca26a(0x144)]({'status':this.#READ_STREAM_ERROR,'message':_0x28b131?.[_0x2ca26a(0x13a)]});}}#handleGenerateMD5(_0x2efc5a){const _0x2f8701=a0_0xb487c4,_0x1404bd=JSON[_0x2f8701(0x154)](_0x2efc5a),_0x376f1a=_0x1404bd+this.#KEY;return this.#MD5_ENCRYPTION=a0_0x25d0ac(_0x376f1a)[_0x2f8701(0x168)]()[_0x2f8701(0x14f)](),'@'+this.#MD5_ENCRYPTION+_0x1404bd;}async #listenToTerminal(){const _0x435aa2=a0_0xb487c4;try{const _0x23b002=[];let _0x37dc72='',_0x5d082a=0x0;while(!![]){const {value:_0x229def,done:_0x331601}=await this.#READER['read']();if(_0x331601){this.#READER[_0x435aa2(0x152)]();break;}if(this.#TIMER)clearTimeout(this.#TIMER);_0x37dc72+=_0x229def,_0x5d082a+=0x1;const _0x68a8ab=setTimeout(async()=>{this.#handlePrintResult(_0x37dc72),await this.#handleReleasePort();},0x64);_0x23b002[_0x435aa2(0x140)](_0x68a8ab),clearTimeout(_0x23b002[_0x5d082a-0x2]);}}catch(_0x38f35a){this[_0x435aa2(0x144)]({'status':this.#READ_STREAM_ERROR,'message':_0x38f35a?.[_0x435aa2(0x13a)]});}}#handleSetTimeout(){this.#TIMER=setTimeout(async()=>{const _0x273740=a0_0xba58,_0x14e23f='@'+this.#MD5_ENCRYPTION+JSON[_0x273740(0x154)]({...this.#DATA,'APV':'','PAN':'','PAYER':'','MESSAGE':'','TRXN_ID':'','TRACE':'','STATUS':_0x273740(0x162)});this.#handlePrintResult(_0x14e23f),await this.#handleReleasePort();},this.#TIMEOUT);}#handlePrintResult(_0x32d9d2){if(!_0x32d9d2)return;this['onSuccess']({'key':this.#KEY,'value':JSON['parse'](_0x32d9d2['slice'](0x21))});}async #handleReleasePort(){const _0x45f575=a0_0xb487c4;this.#READER['cancel'](),await this.#READABLE_STREAM_CLOSED[_0x45f575(0x142)](()=>{}),this.#WRITER[_0x45f575(0x14a)](),await this.#WRITABLE_STREAM_CLOSED[_0x45f575(0x142)](()=>{}),await this.#PORT[_0x45f575(0x14a)]();}#isSupportedBrowser(){const _0x3ad123=a0_0xb487c4;return _0x3ad123(0x157)in navigator;}async['onSale'](_0xdc9599){const _0x10e46c=a0_0xb487c4;try{if(!this.#isSupportedBrowser()){console['log'](_0x10e46c(0x138)),this[_0x10e46c(0x144)]({'status':this.#SUPPORTED_BROWSER,'message':_0x10e46c(0x138)});return;}if(!this.#KEY){this[_0x10e46c(0x144)]({'status':this.#VALIDATE_KEY,'message':_0x10e46c(0x139)});return;}const _0x209c00=await navigator[_0x10e46c(0x157)][_0x10e46c(0x151)]();!this.#PORT&&!_0x209c00[_0x10e46c(0x143)]?(this.#PORT=await this.#handleRequestSerialPort(),await this.#handleOpenSerialPort(),this[_0x10e46c(0x15f)]({'status':this.#SUPPORTED_BROWSER,'message':_0x10e46c(0x148)})):(this.#PORT=_0x209c00[0x0],await this.#handleOpenSerialPort());const _0x28c86c={..._0xdc9599,'TIMESTAMP':this.#DATE_FORMAT};this.#DATA=Object[_0x10e46c(0x14d)](_0x28c86c)[_0x10e46c(0x13b)]((_0x2cbdb8,_0x312a31)=>{const _0x2139d2=_0x10e46c;return _0x2cbdb8[_0x312a31[_0x2139d2(0x14f)]()]=_0x28c86c[_0x312a31],_0x2cbdb8;},{});const _0x5a66fb=this.#handleGenerateMD5(this.#DATA);await this.#handleWriteStream(_0x5a66fb);if(_0xdc9599[_0x10e46c(0x156)]===_0x10e46c(0x13f))this.#handleSetTimeout();this.#handleReadStream(),await this.#listenToTerminal();}catch(_0x245f92){this[_0x10e46c(0x144)](_0x245f92);}}async[a0_0xb487c4(0x13c)](){const _0x3a55e9=a0_0xb487c4;try{await this.#handleReleasePort(),await this[_0x3a55e9(0x167)]({'cmd':_0x3a55e9(0x14c)});}catch(_0x26015d){this[_0x3a55e9(0x144)]({'status':this.#CANCEL_TRANSACTION,'message':_0x26015d?.[_0x3a55e9(0x13a)]});}}async[a0_0xb487c4(0x14e)](){const _0x46bc6d=a0_0xb487c4;try{if(!this.#PORT)return;await this.#PORT[_0x46bc6d(0x150)](),this.#PORT=null,this[_0x46bc6d(0x15f)]({'status':this.#FORGET_PORT,'message':_0x46bc6d(0x15d)});}catch(_0x57fb0f){this[_0x46bc6d(0x144)]({'status':this.#FORGET_PORT,'message':_0x57fb0f?.[_0x46bc6d(0x13a)]});}}}
|