@compendiumfi/pendax
Version:
connector for centralized cryptocurrency exchanges
1 lines • 9.56 kB
JavaScript
const a0_0x21e62a=a0_0x1283;(function(_0x17bb45,_0x544d62){const _0x5eefc5=a0_0x1283,_0x5a7b58=_0x17bb45();while(!![]){try{const _0x3f8a17=parseInt(_0x5eefc5(0xa8))/0x1+-parseInt(_0x5eefc5(0xd1))/0x2*(parseInt(_0x5eefc5(0xcb))/0x3)+-parseInt(_0x5eefc5(0xdc))/0x4+-parseInt(_0x5eefc5(0xb2))/0x5*(parseInt(_0x5eefc5(0xa3))/0x6)+parseInt(_0x5eefc5(0x9d))/0x7+-parseInt(_0x5eefc5(0x93))/0x8*(-parseInt(_0x5eefc5(0x8e))/0x9)+-parseInt(_0x5eefc5(0xb5))/0xa*(-parseInt(_0x5eefc5(0xc7))/0xb);if(_0x3f8a17===_0x544d62)break;else _0x5a7b58['push'](_0x5a7b58['shift']());}catch(_0x285f49){_0x5a7b58['push'](_0x5a7b58['shift']());}}}(a0_0x1e9f,0x1eeec));import a0_0x208e46 from'ws';function a0_0x1e9f(){const _0x2e86ef=['clientOnClose','onOpen','Hmac','retryNumber','subclassOnClose','pong:\x20','socket','TbLel','onMessage','loggedOut','getPublicChannels','pong','getSocketState','readyState','isPublic','onClose','425079TfaFkV','log','getAutoReconnect','ping\x20','subclassOnOpen','8fmhhTx','none','kill','length','getClosedReason','close','name','closed\x20from\x20client','kaPHd','error','1037295Hbqjam','msg','publicChannels','clientOnError','autoReconnectOnClose','url','30wxMGNu','digest','secret','getRetryNumber','kefdg','253105SxwQYb','getPrivateChannels','getOptions','autoReconnect','update','resetRetries','ping','AXzlQ','lVuLW','code','55340pUpGPm','isLoggedIn','onError','582070upCJnC','includes','getSubscriptionArgsHash','_timerArgs',',\x20msg\x20=\x20','subclassOnError','OxdzO','kill()\x20called\x20with\x20no\x20source','BntyV','getConnectionName','clientOnOpen','OPEN','connect','subclassOnPong','reconnectWaitTime','getConnectionUrl','terminate','CJApi','22LpGmXj','subclassOnMessage','GxVpo','subscriptions','12015CECfgq','sha256','clientReconnect','LHNfU','hex','stringify','70ZATCpO','toUTCString','loggedIn','closed\x20from\x20ping()','XEITN','connected','open','customPing','removeSubscriptionHavingArgs','closed:\x20code\x20=\x20','bumpRetries','970880wOZbcO'];a0_0x1e9f=function(){return _0x2e86ef;};return a0_0x1e9f();}function a0_0x1283(_0x1f79a0,_0x3a3431){const _0x1e9fec=a0_0x1e9f();return a0_0x1283=function(_0x12834a,_0x3f2328){_0x12834a=_0x12834a-0x7e;let _0xdfa798=_0x1e9fec[_0x12834a];return _0xdfa798;},a0_0x1283(_0x1f79a0,_0x3a3431);}import*as a0_0x37c884 from'crypto';import{v4}from'uuid';export class PendaxSocket extends a0_0x208e46{#pings=0x0;#pongs=0x0;#pingIntervalTimer;#defaultPingInterval=0x3a98;#defaultReconnectWaitTime=0x1f4;#reconnectTries=0x0;#defaultMaxReconnectTries=-0x1;#options={};#url='';[a0_0x21e62a(0xd3)]=![];[a0_0x21e62a(0xd6)]=![];#closeCode_NORMAL=0xfa0;#closeCode_NOPONG=0xfa1;#closeCode_CLIENTKILL=0xfa2;#closeCode_UNHANDLEDERROR=0xfa3;#closedReason='';#defaultOptions={'name':v4(),'key':a0_0x21e62a(0x94),'secret':a0_0x21e62a(0x94),'pingInterval':0x3a98,'autoReconnectOnError':![],'autoReconnectOnClose':![],'retryNumber':0x0,'maxRetries':this.#defaultMaxReconnectTries,'timestampPings':![]};['subscriptions']={};constructor(_0x4e03ef){const _0xfce8e6=a0_0x21e62a;let _0x23c00f=_0x4e03ef?_0x4e03ef[_0xfce8e6(0xa2)]||'':'';super(_0x23c00f),this[_0xfce8e6(0xc1)](),this.#url=_0x23c00f,this.#options={...this.#defaultOptions,..._0x4e03ef},this.#options['removeSubscriptionHavingArgs']=this[_0xfce8e6(0xd9)],!this.#options['maxRetries']&&(this.#options['maxRetries']=this.#defaultMaxReconnectTries);}[a0_0x21e62a(0xbe)](){const _0x27cb6d=a0_0x21e62a;return this.#options[_0x27cb6d(0x99)];}[a0_0x21e62a(0xc4)](){return this.#url;}['getPingInterval'](){return this.#options['pingInterval']||this.#defaultPingInterval;}[a0_0x21e62a(0x90)](){const _0x10a454=a0_0x21e62a;return this.#options[_0x10a454(0xab)]||!![];}[a0_0x21e62a(0x8a)](){const _0x7b4eca=a0_0x21e62a;return this[_0x7b4eca(0x8b)];}[a0_0x21e62a(0xaa)](){return this.#options;}[a0_0x21e62a(0xa6)](){const _0x610f6b=a0_0x21e62a;return this.#options[_0x610f6b(0x81)];}[a0_0x21e62a(0x97)](){return this.#closedReason;}['getSubscriptions'](){const _0x44d90c=a0_0x21e62a;return this[_0x44d90c(0xca)];}[a0_0x21e62a(0xb3)](){return this['loggedIn']==!![];}[a0_0x21e62a(0x87)](){const _0x4f7ae9=a0_0x21e62a;this[_0x4f7ae9(0xd3)]=![];}[a0_0x21e62a(0x88)](){const _0x5ef515=a0_0x21e62a;return this[_0x5ef515(0x9f)];}[a0_0x21e62a(0xa9)](){return this['privateChannels'];}[a0_0x21e62a(0x8c)](_0x365379){const _0x1d330a=a0_0x21e62a;return this['publicChannels'][_0x1d330a(0xb6)](_0x365379);}[a0_0x21e62a(0xb7)](_0x344fd4){const _0x3c5c7a=a0_0x21e62a,_0x4b05fe=JSON[_0x3c5c7a(0xd0)](_0x344fd4),_0x2e6218=a0_0x37c884[_0x3c5c7a(0x80)](_0x3c5c7a(0xcc),this.#options[_0x3c5c7a(0xa5)])[_0x3c5c7a(0xac)](_0x4b05fe)[_0x3c5c7a(0xa4)](_0x3c5c7a(0xcf));return _0x2e6218;}#heartbeat(){const _0x2f4990=a0_0x21e62a;let _0x3ee2ed=this[_0x2f4990(0xb8)][0x0];if(_0x3ee2ed[_0x2f4990(0x8b)]==_0x3ee2ed[_0x2f4990(0xc0)]){if(_0x3ee2ed.#pongs<_0x3ee2ed.#pings){if('LHNfU'===_0x2f4990(0xce))_0x3ee2ed.#disconnect({'code':_0x3ee2ed.#closeCode_NOPONG,'msg':_0x2f4990(0xd4),'socketObject':_0x3ee2ed},!![]);else return this[_0x2f4990(0xd3)]==!![];}else{if(_0x2f4990(0xa7)!==_0x2f4990(0xc9)){_0x3ee2ed.#pings=_0x3ee2ed.#pings+0x1;_0x3ee2ed.#options['timestampPings']===!![]?_0x2f4990(0xd5)!=='XEITN'?this[_0x2f4990(0xc5)]():console[_0x2f4990(0x8f)](_0x2f4990(0x91)+_0x3ee2ed.#pings+':\x20'+new Date()[_0x2f4990(0xd2)]()):console[_0x2f4990(0x8f)](_0x2f4990(0x91)+_0x3ee2ed.#pings);_0x3ee2ed[_0x2f4990(0xae)]();if(_0x3ee2ed.#options[_0x2f4990(0xd8)]){if(_0x2f4990(0xbd)!=='hwHHm')_0x3ee2ed.#options[_0x2f4990(0xd8)]();else return this['privateChannels'];}}else return this[_0x2f4990(0x8b)];}}}[a0_0x21e62a(0xc1)](){const _0x144984=a0_0x21e62a;this['on'](_0x144984(0xd7),this['onOpen']),this['on'](_0x144984(0x98),this[_0x144984(0x8d)]),this['on'](_0x144984(0x9c),this[_0x144984(0xb4)]),this['on']('message',this[_0x144984(0x86)]),this['on'](_0x144984(0x89),this.#onPong);}[a0_0x21e62a(0x95)](_0x701267,_0x30d13a){const _0x3f6c78=a0_0x21e62a;let _0x45f81e,_0xf32e0;if(_0x701267)_0x45f81e=_0x701267,_0xf32e0=_0x30d13a||![];else{if(this[_0x3f6c78(0xb8)]&&this[_0x3f6c78(0xb8)][_0x3f6c78(0x96)]>0x0)_0x45f81e=this[_0x3f6c78(0xb8)][0x0],_0xf32e0=this[_0x3f6c78(0xb8)][0x1]||![];else throw _0x3f6c78(0xbc);}_0x45f81e.#disconnect({'code':_0x45f81e.#closeCode_CLIENTKILL,'msg':_0x3f6c78(0x9a),'socketObject':_0x45f81e},_0xf32e0);}[a0_0x21e62a(0x7f)](){const _0x4ce6e9=a0_0x21e62a;this.#options[_0x4ce6e9(0x84)]=this,console[_0x4ce6e9(0x8f)]('opened'),this.#startPingTimer(),this[_0x4ce6e9(0xd6)]=!![];if(this.#options[_0x4ce6e9(0x92)])this.#options['subclassOnOpen'](this.#options);else this.#options['clientOnOpen']&&this.#options[_0x4ce6e9(0xbf)](this.#options);}['onClose'](_0x44bf01,_0x266e82){const _0x5f0ba5=a0_0x21e62a;this.#pingIntervalTimer&&(_0x5f0ba5(0x9b)===_0x5f0ba5(0x9b)?(clearInterval(this.#pingIntervalTimer),this.#pingIntervalTimer=undefined):(_0x4e5014=this[_0x5f0ba5(0xb8)][0x0],_0x54cc07=this[_0x5f0ba5(0xb8)][0x1]||![]));this.#options[_0x5f0ba5(0xa1)]&&_0x44bf01!==this.#closeCode_NORMAL&&this.#options['clientReconnect']&&(this[_0x5f0ba5(0xdb)](),this.#startReconnectTimer(_0x44bf01));if(this.#options['subclassOnClose'])this.#options[_0x5f0ba5(0x82)](_0x44bf01,_0x266e82,this.#options);else{if(this.#options[_0x5f0ba5(0x7e)]){if('aueXV'===_0x5f0ba5(0xb0))return this[_0x5f0ba5(0x9f)][_0x5f0ba5(0xb6)](_0x471fe5);else this.#options[_0x5f0ba5(0x7e)](_0x44bf01,_0x266e82,this.#options);}else console[_0x5f0ba5(0x8f)](_0x5f0ba5(0xda)+_0x44bf01+_0x5f0ba5(0xb9)+_0x266e82);}this[_0x5f0ba5(0xd6)]=![],this[_0x5f0ba5(0xd3)]=![];}[a0_0x21e62a(0xb4)](_0x2bcdab){const _0x4e8e1f=a0_0x21e62a;this.#pingIntervalTimer&&(clearInterval(this.#pingIntervalTimer),this.#pingIntervalTimer=undefined);this.#options['autoReconnectOnError']===!![]&&this.#options[_0x4e8e1f(0xcd)]&&(this[_0x4e8e1f(0xdb)](),this.#startReconnectTimer());if(this.#options[_0x4e8e1f(0xba)])this.#options[_0x4e8e1f(0xba)](_0x2bcdab,this.#options);else this.#options[_0x4e8e1f(0xa0)]?this.#options[_0x4e8e1f(0xa0)](_0x2bcdab,this.#options):console[_0x4e8e1f(0x8f)](_0x2bcdab);this[_0x4e8e1f(0xd6)]=![],this[_0x4e8e1f(0xd3)]=![];}[a0_0x21e62a(0x86)](_0x10df0c){const _0x5627ef=a0_0x21e62a;if(this.#options['subclassOnMessage'])this.#options[_0x5627ef(0xc8)](this,_0x10df0c,this.#options);else this.#options['clientOnMessage']&&(_0x5627ef(0xbb)==='OxdzO'?this.#options[_0x5627ef(0xa0)](_0x10df0c,this.#options):_0x2755a7['log'](_0x249a3d));}#onPong(_0x3d2b39){const _0x1cac1d=a0_0x21e62a;if(this.#options[_0x1cac1d(0xc2)]){if(_0x1cac1d(0xaf)!==_0x1cac1d(0x85))this.#options[_0x1cac1d(0xc2)](this,_0x3d2b39,this.#options);else return this[_0x1cac1d(0x9f)];}else this.#pongs=this.#pongs+0x1,console['log'](_0x1cac1d(0x83)+this.#pongs);}#disconnect(_0x643943,_0x4eb188){const _0x198512=a0_0x21e62a;let _0x1bd10a=parseInt(_0x643943[_0x198512(0xb1)])||0x0,_0x1f6508=_0x643943[_0x198512(0x9e)]||'';this.#closedReason=_0x1f6508,_0x4eb188?this[_0x198512(0xc5)]():this['close'](_0x1bd10a,_0x1f6508);}[a0_0x21e62a(0xdb)](){const _0x5abba5=a0_0x21e62a;this.#options[_0x5abba5(0x81)]=this.#options['retryNumber']+0x1;}[a0_0x21e62a(0xad)](){const _0x554a4a=a0_0x21e62a;this.#options[_0x554a4a(0x81)]=0x0;}#startPingTimer(){this.#pingIntervalTimer=setInterval(this.#heartbeat,this.#options['pingInterval']||this.#defaultPingInterval,this);}#startReconnectTimer(_0x5d1f60){const _0x5bb222=a0_0x21e62a;if(this.#options[_0x5bb222(0xcd)]){if(_0x5bb222(0xc6)!=='TGBVo')setTimeout(this.#options[_0x5bb222(0xcd)],this.#options[_0x5bb222(0xc3)]||this.#defaultReconnectWaitTime,this,_0x5d1f60);else throw'kill()\x20called\x20with\x20no\x20source';}}}