Create a restricted ZeroFrame wrapper

This commit is contained in:
shortcutme 2018-02-21 03:02:00 +01:00
parent 91e83b3397
commit c438b9f8a5
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 23 additions and 1 deletions

View file

@ -0,0 +1,22 @@
class WrapperZeroFrame
constructor: (wrapper) ->
@wrapperCmd = wrapper.cmd
@wrapperResponse = wrapper.ws.response
console.log "WrapperZeroFrame", wrapper
cmd: (cmd, params={}, cb=null) =>
@wrapperCmd(cmd, params, cb)
response: (to, result) =>
@wrapperResponse(to, result)
isProxyRequest: ->
return window.location.pathname == "/"
certSelectGotoSite: (elem) =>
href = $(elem).attr("href")
if @isProxyRequest() # Fix for proxy request
$(elem).attr("href", "http://zero#{href}")
window.zeroframe = new WrapperZeroFrame(window.wrapper)

View file

@ -37,7 +37,7 @@ class ZeroWebsocket
@log "Unknown command", message
response: (to, result) ->
response: (to, result) =>
@send {"cmd": "response", "to": to, "result": result}