OverviewFilesCommitsIssuesDocsReleasesPeers

keet-cli / deobfuscated / api / v2 / debug / index.js

97 lines · javascript ref:
const _0x4064be=(function(){let _0x404af6=!![];return function(_0x3b2d3e,_0x1ad795){_0x430823=_0x404af6?function(){if(_0x1ad795){const _0x52779b=_0x1ad795.apply(_0x3b2d3e,arguments);return _0x1ad795=null,_0x52779b;}}:function(){};return _0x404af6=![],_0x430823;};}()),_0x11a9d9=_0x4064be(this,function(){_0x54a400={_0x4d60c4:0x1c0},_0x40e654={_0x504c2a:0x29e};return _0x11a9d9.toString().search("(((.+)+)+)+$").toString().constructor(_0x11a9d9).search("(((.+)+)+)+$");});
_0x11a9d9();
const HypercoreId=require('hypercore-id-encoding');
const ReadyResource=require('ready-resource'),BareInspector=require('bare-inspector'),safetyCatch=require('safety-catch');
const b4a=require('b4a'),{
  hashDebugPassword}
=require('../../../lib/debug'),defaultConsole=global.console;
class Inspector extends ReadyResource{
  constructor(){
    _0x19c953={
      _0x4f6198:0x1b0,_0x1c9169:0x1d9},_0x43d90d={
      _0xd6ca89:0x1f,_0xd5e318:0x15f,_0x420f2a:0x789}
    ;
    super(),this.url=null;
    this._server=null,this._console=null,this.ready().catch(safetyCatch);
  }
async._open(){
  _0x1193ba={
    _0x2f6d2f:0x1c1,_0x371b27:0x14d},_0x2a03fd={
    _0x416f11:0x118,_0x5c54ca:0x131}
  ;
  console.log(0x0);
  this._server=new BareInspector.Server(0x0,"localhost"),console.log(0x1),await new Promise(_0x5cf1bf=>this._server.once("listening",_0x5cf1bf)),console.log(-0xe9a);
  const {
    port:_0x288dce}
  =this._server.address();
  console.log(0x5);
  this.url="devtools://devtools/bundled/js_app.html?ws=localhost:"+_0x288dce,console.log("Keet core inspector url: "+this.url),console.log(0x6);
}
async._close(){
  _0x393d00={
    _0xe8b8dd:0x47,_0x4b98f7:0x5d0},_0x4df79f={
    _0x8abf93:0x2d2}
  ;
  global.console=defaultConsole;
  await new Promise((_0x364d7c,_0x4016d8)=>this._server.close(_0x4125c5=>{if(_0x4125c5)_0x4016d8(_0x4125c5);else _0x364d7c(_0x4125c5);}));
}
}
module.exports=class V2KeetDebugAPI extends ReadyResource{
  constructor(_0x320106){
    _0x2e0623={
      _0x2c5175:0x564,_0x887a6:0xa,_0x5de6a9:0x118},_0x1a3674={
      _0x53ff61:0x99,_0x2ac2f9:0xe8,_0x4ed9b5:0x203}
    ;
    super(),this.backend=_0x320106,this.keet=this.backend.keet,this.rpc=this.backend.rpc;
    this._inspector=null,this._onupdate=this._onConfigUpdated.bind(this),this.keet.on("force-update",this._onupdate),this.rpc.onDebugEnable(this.onEnable.bind(this)),this.rpc.onDebugDisable(this.onDisable.bind(this));
  }
._close(){
  _0x5abfac={
    _0x3811d9:0x41,_0x2ab774:0x1bc,_0x261319:0x516},_0x4bfb5f={
    _0x1f3b16:0x1c6}
  ;
  this.keet.removeListener("force-update",this._onupdate);
}
async._onConfigUpdated(){
  _0x435f4c={
    _0x326482:0x6a,_0x32b3ec:0x36,_0x2bcb60:0x49c}
  ;
  try{
    await this.onDisable();
  }catch(_0x5b8696){
  safetyCatch(_0x5b8696);
}
}
._respond(_0x1e10ca){
  return{
    'header':{
      'duration':0x0},..._0x1e10ca}
  ;
}
async.onEnable({password:_0x24d366}){
  _0x21d915={
    _0x25668b:0x127,_0x51bd63:0xd3},_0x7d3ad8={
    _0x6d6ff:0x18e,_0x170166:0x2,_0x312877:0x53f}
  ;
  if(!this.keet.opened)await this.keet.ready();
  if(this.keet.isProduction){
    const _0x558c21=this.keet.config.debug.unlockHash,_0x421809=hashDebugPassword(HypercoreId.decode(_0x24d366));
    if(!b4a.equals(_0x558c21,_0x421809))throw new Error("Invalid password");
  }
if(!this._inspector)this._inspector=new Inspector();
console.log("pre inspector ready");
await this._inspector.ready(),console.log("post inspector ready");
return this._respond({'inspector':this._inspector.url});
}
async.onDisable(){
  _0x5d7ca3={
    _0x5d4538:0x10,_0x463fc2:0xd1,_0x26ab00:0x2},_0x1bcb2b={
    _0x30a2e6:0x1ce,_0x2ac3c9:0x1d5,_0x4b8165:0x35}
  ;
  if(!this.inspector)return;
  await this.inspector.close();
  return this._respond(null);
}
}
;