fix sesamefilter default
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rpclibrary",
|
||||
"version": "1.9.1",
|
||||
"version": "1.9.2",
|
||||
"description": "rpclibrary is a websocket on steroids!",
|
||||
"main": "./js/Index.js",
|
||||
"repository": {
|
||||
|
||||
+7
-2
@@ -38,14 +38,19 @@ export class RPCServer<
|
||||
private exporters: Exporters<InterfaceT, SubResType> = [],
|
||||
conf: T.ServerConf<InterfaceT, SubResType> = {}
|
||||
){
|
||||
if(!conf.visibility) this.visibility = "127.0.0.1"
|
||||
if(!conf.visibility) this.visibility = "0.0.0.0"
|
||||
|
||||
this.accessFilter = conf.accessFilter || (async () => true)
|
||||
|
||||
if(conf.sesame){
|
||||
this.sesame = U.makeSesameFunction(conf.sesame)
|
||||
}
|
||||
|
||||
this.accessFilter = conf.accessFilter || (async (sesame) => {
|
||||
if(!this.sesame) return true
|
||||
return this.sesame!(sesame!)
|
||||
})
|
||||
|
||||
|
||||
this.errorHandler = (socket:I.Socket) => (error:any, rpcName:string, args: any[]) => {
|
||||
if(conf.errorHandler) conf.errorHandler(socket, error, rpcName, args)
|
||||
else throw error
|
||||
|
||||
+9
-34
@@ -316,30 +316,26 @@ describe('Sesame should unlock the socket', () => {
|
||||
it('should not work without sesame', (done) => {
|
||||
const sock = new RPCSocket(21004, "localhost")
|
||||
sock.connect<SesameTestIfc>( /* no sesame */).then(async (cli) => {
|
||||
cli.test.checkCandy().then(d => {
|
||||
done(d)
|
||||
}).catch(e => {
|
||||
//console.log("EXPECTED CLIENT EXCEPTION", String(e));
|
||||
if(!cli.test)
|
||||
done()
|
||||
}).finally(() => {
|
||||
else{
|
||||
done(new Error("Function supposed to be removed without sesame"))
|
||||
}
|
||||
cli.destroy()
|
||||
sock.destroy()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('should fail with wrong sesame', (done) => {
|
||||
const sock = new RPCSocket(21004, "localhost")
|
||||
sock.connect<SesameTestIfc>('abasd').then(async (cli) => {
|
||||
cli.test.checkCandy().then(d => {
|
||||
done("should not be able to get candy")
|
||||
}).catch(e => {
|
||||
//console.log("EXPECTED CLIENT EXCEPTION", String(e));
|
||||
if(!cli.test)
|
||||
done()
|
||||
}).finally(() => {
|
||||
sock.destroy()
|
||||
else{
|
||||
done(new Error("Function supposed to be removed without sesame"))
|
||||
}
|
||||
cli.destroy()
|
||||
})
|
||||
sock.destroy()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -355,27 +351,6 @@ describe('Sesame should unlock the socket', () => {
|
||||
client.test.checkCandy()
|
||||
})
|
||||
})
|
||||
|
||||
it('callback should not work without sesame', (done) => {
|
||||
const sock = new RPCSocket(21004, "localhost")
|
||||
sock.connect<SesameTestIfc>( /* no sesame */).then(async (cli) => {
|
||||
cli.test.subscribe((c) => {
|
||||
console.log("CALLBACK TRIGGERED UNEXPECTED");
|
||||
|
||||
if(c === candy)
|
||||
done("super not")
|
||||
}).then(async d => {
|
||||
await client.test.checkCandy()
|
||||
if(d == null){
|
||||
done()
|
||||
|
||||
}else
|
||||
done('unexpected valid response '+(d) )
|
||||
}).finally(() => {
|
||||
sock.destroy()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user