ssb-browser-client
A starting point for your ssb browser app
Some ssb appllications, like Patchwork, require Electron to run. Others, like Patchfoo implement their own http server, and that http server in turn talks to sbot. If you have an instance of sbot already running, eihter on a pub or locally, there is a more minimal option: Just talk to sbot directy from the browser trhough websockets! (this is sometimes referred to as a "lite" client, because in this scenario the client has no database). This is possible through the magic of multiserver, muxrpc and ssb-ws, a plugin for sbot that exposes the sbot API via websockets.
This module is meant as a starting point for your own browser applications.
Installation
You need git-ssb
and an instance of scuttlebot
running.
$ git clone ssb://%Jlj4UHbLrIQBAokyzrEllQ3DnK1p1huBa0NjTPhKKGQ=.sha256 ssb-browser-client
Try it out
$ cd ssb-browser-client
$ npm install
# Get your sbots websocket address
$ sbot ws.getAddress
# now paste that string into index.js at sbotAddress=
$ npm start
Navigate your browser to the link you see in the terminal. Your browser will now create a keypair and store it in localstorage. It will then try to call the whoami
method on sbot, which will fail, because the browser's public key is not yet authorized to call non-whitelisted methods. Open your browser's console to see the error message.
You have to go to localstorage in your browser, there should be an entry for "mykeys". Copy the public property from there and prefix it with @
and then put it into your ~/.ssb/config
under master (it's an array), like so:
{
"ws": {
"port": 8989
},
"master":[
"@ok/BE7mwDhFryrDWy9cDhd3DUJO3xkBbu4pN2fZD2S8=.ed25519"
]
}
Now restart sbot and reload the page. The call to whoami
should now succeed. If everything works, you'll see an ssb feed id.
License
MIT