Gozala / lunet

Exploration: P2P Network access through the service worker
https://lunet.link
36 stars 2 forks source link

Dat support through `dat-js` would be nice. #10

Open Gozala opened 5 years ago

Gozala commented 5 years ago

I think there is some interesting opportunities to bridge protocols like ipfs, dat, ssb instead competing. The way things are designed to work it does not matter what protocol has being used to deliver app or publish to. In fact app can be coming from one and data from another. While things are already complicated & there are obvious risks in making it even more complicated I still thing there is a huge opportunity to find synergy across protocols that currently lacks.

Gozala commented 5 years ago

@RangerMauve I'd love your feedback

RangerMauve commented 5 years ago

This would be so awesome. 😍

dat-js seems to be in a good place right now with regards to support. I haven't tried to get it to work inside a worker context yet and you might run into some trouble since it expects WebRTC to be present. But I think I could do something about it if you'd like to pursue it further. 😉 At the very least it'll work with a WS gateway inside workers.

RangerMauve commented 5 years ago

I'll talk to the dat folks to see if this is something I can do as part of my grant. If I was, it'd be after I got something running with React Native.

Gozala commented 5 years ago

dat-js seems to be in a good place right now with regards to support. I haven't tried to get it to work inside a worker context yet and you might run into some trouble since it expects WebRTC to be present. But I think I could do something about it if you'd like to pursue it further. 😉 At the very least it'll work with a WS gateway inside workers.

I'm actually not sure if running inside workers would need to be a goal for Dat case. Unlike IPFS there is not much value in sharing a node because each dat is pretty isolated from other dats so it might be totally reasonable to use it in window context.

RangerMauve commented 5 years ago

Only reasoning I have is that you might want to share storage across contexts. But you're right it can totally work inside a window.

Gozala commented 5 years ago

Only reasoning I have is that you might want to share storage across contexts. But you're right it can totally work inside a window.

That is a good point, but I think that would be a case either way though. The way things are setup is proxy SW forwards all requests to an iframe (or window.top in a new setup) which is always the same document (URL is the same). In case of IPFS that document also happens to forward messages to SharedWorker so that all the connections etc is shared.

In case of Dat even without SharedWorker storage (assuming indexedb) will be still shared due to same origin. However not the connections (which is unfortunate if you have say multiple tabs for the same thing), however storage will likely be shared, assuming indexedDB is used. With some effort likely web sockets connections could also probably move to SharedWorker but that's definitely an optimization that not worth making unless this proves to be useful in first place.