fraction / oasis

Free, open-source, peer-to-peer social application that helps you follow friends and discover new ones on Secure Scuttlebutt (SSB).
http://oasis-demo.fraction.io
GNU Affero General Public License v3.0
287 stars 42 forks source link

Turn oasis into a browser extension #173

Open Powersource opened 4 years ago

Powersource commented 4 years ago

Now this title isn't saying Please do this, it's saying I want to try to do this, it's fine if you ignore any eventual PR/changes, although collaboration would make this easier and would be appreciated

I think this would be super cool, we could have a purely browser-extension p2p client (not counting pubs), I don't think there are many of those in the world (e.g. metamask uses a centralized server; that dat thing tunnels all traffic through a specific server as well).

2 simple (lol) steps needed:

Any thoughts/help/etc appreciated :) Especially with oasis's inner workings, which I'm not familiar with so far.

@georgeowell @arj03

Powersource commented 4 years ago

I don't know how easy it would be to use choo, since it doesn't support async routes/rendering and oasis seems to use that a lot.

Powersource commented 4 years ago

@soapdog would it be a good idea to try this in patchfox instead? Or how stable/in flux is it? :grimacing:

cinnamon-bun commented 4 years ago

Browser extensions can't run on special pages made by other browser extensions. So I can't use these things with Patchfox: my Vim keyboard shortcuts, CSS customization extensions, etc.

Is it possible to run a full localhost webserver in an extension so the pages will be normal localhost pages and not, like, moz-extension://...?

I ask this not in opposition, just thinking ahead.

soapdog commented 4 years ago

You can't run a webserver on an extension. There is no way to bundle the server code. You can however launch a local program, which could be a server. That's how the initial version of Patchfox was able to start Scuttle Shell on its own. This uses the Native Messaging API. So you could have a minimal add-on that start a compiled Oasis server if you want. The user will need a separate procedure to install this native server, add-ons can't install native apps.

georgeowell commented 4 years ago

@Powersource is cool and valid... but this issue is not :smile:

Powersource commented 4 years ago

To clarify, I'm not saying anyone should turn oasis into a browser extension (although I wouldn't mind because I think it would be pretty cool). I just want to try to put a scuttlebutt client into a browser extension and have it run there without connecting to some local ssb-server (i.e. using ssb-browser-core instead). And I thought maybe the best way of doing that was with oasis. But idk, it looks like a pretty big effort to do it with oasis atm so I might just do it with the ssb-browser-demo instead.

arj03 commented 4 years ago

I'll be happy to help how I can. I was waiting for Christian to chime in, but it appears he is sick.

The security model aspect is interesting. I actually was not aware of that when browsing this project, maybe it should be more front and center as its actually a pretty nice selling point for some people. Disabling JS is not going to work if you run SSB in the same tab, but I'm wondering if running ssb-browser-core as a browser extension might work. And then run oasis as normal.

Powersource commented 4 years ago

if running ssb-browser-core as a browser extension might work. And then run oasis as normal.

I'm guessing it wouldn't since like soapdog says, "You can't run a webserver on an extension". Or maybe there's some other way for them to connect?

on a similar topic, @soapdog how well do the custom protocol handlers work nowadays? Could we maybe have the user on ssb:/feed/something instead of moz-extension://..., and would that let us use stuff like vimium on the pages?

christianbundy commented 4 years ago

Meta-note: In my mind, the 'invalid' label is usually for when you open an issue in the wrong repository, open a pull request into the wrong branch, or some other "oops". I think there might be some semantic conflicts around this label, so I'd like to suggest that we don't use it until/unless we iron those out. :heart:

christianbundy commented 4 years ago

I'm probably not going to be :100: for a few days so I'll probably give this some more thought when I'm feeling better, but quick notes:

soapdog commented 4 years ago

To clarify, I'm not saying anyone should turn oasis into a browser extension (although I wouldn't mind because I think it would be pretty cool). I just want to try to put a scuttlebutt client into a browser extension and have it run there without connecting to some local ssb-server (i.e. using ssb-browser-core instead).

@Powersource it should be easy to do that with Oasis as long as you're connecting to an externally running ssb-server which is exactly how Patchfox work.

The only ticky part is browserifying the client. You can't really rollup/webpack it as there are dependencies which don't run in strict mode and at least rollup will refuse to compile.

You'd need some sort of shim or very thin JS to act as the router and decide which view to send. I don't know how those views are built, but if this little shim could build them then it should work.

A minimal version would need:

soapdog commented 4 years ago

on a similar topic, @soapdog how well do the custom protocol handlers work nowadays? Could we maybe have the user on ssb:/feed/something instead of moz-extension://..., and would that let us use stuff like vimium on the pages?

@Powersource I think that mozilla changed something in Firefox because all my ssb:<hash> have been failing for a while. TBH they were never valid URLs, so changing something maybe Mozilla means just fixed something. We can't agree on a real URL conformant scheme in the community. The best current option is ssb-uri by @christianbundy which I want to support, I remember there being a bug that prevented me from browserifying it, some access to fs.* in the source, so I couldn't use it in Patchfox.

Still, even with real URLs we can't have them appear in the URL of Firefox as ssb:. As soon as the add-on takes over, it changes the URLs as custom URLs are actually redirects to internal add-on pages. Libdweb had a way around it but it is quite dead.

Powersource commented 4 years ago

So I started on a fork of ssb-browser-demo. It's technically a browser extension now, but nothing works since I think the js doesn't run or something hehe https://github.com/Powersource/ssb-webextension-demo/pull/1

image

christianbundy commented 4 years ago

@Powersource Nice! I'll look forward to updates on your project.

Anything I can do to close this issue?

Powersource commented 4 years ago

I think it's fine to close this issue (if you want to minimize open issues), as long as it isn't locked, so we can possibly continue discussion :)

Powersource commented 4 years ago

booyakasha https://addons.mozilla.org/en-US/firefox/addon/ssb-webextension-demo/

christianbundy commented 4 years ago

WOOP WOOP. I don't want to close this issue because it's something you're working on, maybe we could transfer it to your repo? If you add me as a collaborator on your project I think that'll let me do it? Not 100% sure.

soapdog commented 4 years ago

booyakasha https://addons.mozilla.org/en-US/firefox/addon/ssb-webextension-demo/

one of us! one of us! one of us!

Powersource commented 4 years ago

@christianbundy I don't have any code on this for oasis, only done the browser-demo one so far. Would maybe be keen on helping you with http-spa and getting that into oasis, as a first step (if that's something you want).

christianbundy commented 4 years ago

I'm super interested in figuring out a way to do routing that's engine-agnostic and doesn't require Node.js, but HTTP-SPA is so hacky and prototypy that I'd really like to avoid using it in production. My guess is that the best way to do this would be to copy the shape of an existing router, either Express or Koa or something, and make a browserify-able variant, but honestly at that point I'm thinking we might as well just write Oasis in a language that compiles to WASM or something.

:man_shrugging:

I think this is too far in the future to be actionable for me, personally.