const ReadyResource=require('ready-resource'),HypercoreId=require('hypercore-id-encoding'),b4a=require('b4a');
module.exports=class RoomFirewall extends ReadyResource{
constructor(_0x5c4f8e,_0x44cd99){
_0x1692a9={
_0x2dd9d3:0x12d},_0x51a057={
_0x2622f7:0xf8}
;
super(),this.keet=_0x5c4f8e,this.discoveryId=_0x44cd99,this.discoveryKey=HypercoreId.decode(_0x44cd99),this.key=null;
this.core=null,this.ready().catch(this.keet.onerror);
}
async.allow(_0x599555){
_0x4cc158={
_0x25a896:0x104},_0x356d95={
_0x1b9d4f:0x3a6}
;
await this.ready();
const _0xa64448=this.keet.internalOpenExistingRoom(this.key);
try{
await _0xa64448.ready();
const _0x161dec=await _0xa64448.db.get("@keet/devices-by-swarm-key",{'profile':{'swarmKey':_0x599555}});
if(_0x161dec)return _0x161dec.status.isActive;
for(const _0x2886d8 of this.core.peers){
if(b4a.equals(_0x2886d8.remotePublicKey,_0x599555))return!![];
}
return![];
}finally{
this.keet.internalReleaseRoom(_0xa64448);
}
}
async._close(){
_0x4c1a58={
_0x40e1db:0x154},_0x50e488={
_0x5efb22:0x103,_0x5cb565:0xea,_0x2bc7d2:0x685}
;
if(this.core)await this.core.close();
}
async._open(){
_0x44858d={
_0x2cc019:0x108,_0x151332:0x611},_0x48060d={
_0x19b782:0x172,_0x27722e:0x60f}
;
await this.keet.ready();
const _0x575ef2=await this.keet.local.get("@local/rooms-by-discovery-key",{'discoveryKey':this.discoveryKey});
if(!_0x575ef2)throw new Error("Room\x20does\x20not exist");
this.key=_0x575ef2.roomKey;
const _0x5464b3=this.keet.internalOpenExistingRoom(this.key);
try{
await _0x5464b3.ready(),this.core=_0x5464b3.base.core.session({'active':![]});
}finally{
this.keet.internalReleaseRoom(_0x5464b3);
}
}
}
;