I’ve just updated the readme now, which should clarify some things, as well as updating the outdated initial example.
So safe-js can be used in node, or any browser, and that would use methods as listed in the readme.
However, when using the SAFE Browser, these methods are baked into the window object, which means 1) they run internally in the background in beaker, and 2) you dont need to include your own copy of safe-js, they are automatically (and only) available to safe: sites.
So your example here, when uploaded to the network, should look like:
Is that code you supplied supposed to work in the console? It looks like the window function of “authorise” can’t work that way, is this what @joshuef was talking about for the “polyfill” thing (which I’m still not quite clear on what it is)?
I’m guessing not, and will try it in a hosted SAFE page now
Your safejs code looks good in itself (and as you note, with the latest version of the browser/safejs, you don’t need to supply a token as it will be overridden by the url of the site in beaker anyway).
So to get this code running, I think you only need remove those two lines.
Well for me personally it’s a good entry point into safe-js for uploading files etc. I think a web app replacement of the demo app will be a great thing, since all you need to do with it is create public / private folders, upload files, and map dns. Should take some burden off MaidSafe if I can get it done.
In general, everyone should take it every Direction they can! SAFE apps need to be built! Replace clearnet in every use case