sandstorm-io / sandstorm

Sandstorm is a self-hostable web productivity suite. It's implemented as a security-hardened web app package manager.
https://sandstorm.io
Other
6.75k stars 706 forks source link

Implement SessionContext.request #2959

Open zenhack opened 7 years ago

zenhack commented 7 years ago

Per grain.capnp:

request @3 (query :List(Powerbox.PowerboxDescriptor), requiredPermissions :Identity.PermissionSet)
        -> (cap :Capability, descriptor :Powerbox.PowerboxDescriptor);
# Although this method exists, it is unimplemented and currently you are meant to use the
# postMessage api to get a temporary token and then restore it with claimRequest().
#
# [...]

I didn't see an issue open actually tracking this, so I'm opening one. The postMessage workflow is a bit obnoxious, especially in an app that doesn't otherwise use/need javascript and is written in a language that has good capnp support.

I might consider taking a whack at this if/when I find the time -- wouldn't mind pointers as to where to start, as I'm still unfamiliar with the codebase.

kentonv commented 7 years ago

You'll probably want to trace through the implementation of SessionContext.offer(), which does something similar: it's a server-side call that invokes a client-side UI dialog. request() will be more complicated, though, since it has to return a result. Actually, this may prove problematic -- e.g. what happens if the session context gets disconnected while the user is making their choice? So I'm not entirely sure that this is the right API, though I'm also not sure what would be better.