A full peer that runs in the browser. Proof of Concept!
This is a minimal proof of concept of a database for ssb running inside the browser via flumedb. It's not api compatible with secure-scuttlebutt, but it demonstrates basically enough features to make a usable application.
It connects to your local sbot via ssb-client, and replicates the log into a flumelog-idb
this is unfortunately quite slow, taking a about 5-10 minutes for me, with ~80k messages. It will check what it's latest message is, and sync with your local sbot in order, so each time you restart it it will load the latest messages.
Also, it builds a few indexes. not all the indexes are used for anything in the demo, but they are there because they would be necessary for any real ssb app to function. secure-scuttlebutt has more indexes, but for the browser I wanted to minimize this.
The first index is
keys - this maps from the message id to the flumelog sequence, as needed for retriving a message from id. (for example, following a link)
The next index is
last this is a table of information about the last message seen from a given feed,
needed for validing messages and replication.
Finally, we have the
backlink index. This indexes the messages which mention other messages,
to be queried for digs, replies, git-ssb changes, etc. Using a few tricks, I have gotten the size of
the index down to 600k, for 80k messages. that is less that 7.5 bytes per message on average,
even encoded as json! of course, not all messages have backlinks.
(i think this is boarderline okay to keep in memory, although I do have plans to back this by indexeddb,
but with an in memory cache - the best of both worlds)
Not implemented: graph of follows or namings, but these would follow the same pattern. received messages are not verified, because I was wanting mainly to verify that indexeddb was viable.
easiest to run in electro:
electro index.js (make sure to have your
sbot server already running in another tab)
todo: browserify and run in browser - this should work if you have a id in your browser that your sbot follows.
Built with git-ssb-web