SAFEBBrowser Pre-release: 0.2.4 Test the API!

safe-browser

#1

A mini dev update:

Here’s a developers preview of the Safe Beaker Browser candidate with safe-js api inclusion!

Right now, within the window var, you can access safeAuth, safeNFS and safeDNS objects, with their respective functions coming from safe-js https://github.com/joshuef/safe-js/tree/master/src

Auth tokens are currently not stored between SBB runs, but you can (currently) save that to localStorage to persist between sessions.

This should eliminate any need to call localhost:8100, thus (hopefully) negating a bunch of CSP/CORS problems some people have been having.

Packages:

mac/linux: https://github.com/joshuef/beaker/releases/tag/0.2.4-pre4
win: https://github.com/joshuef/beaker/releases/tag/untagged-9454501c80a9d8cc4711

Next steps

  • Addressing any issues.
  • Sorting Mac build problems
  • safe-js documentation
  • beaker integration improvements
  • tests for all of the things!

#2

Awesome! Does this mean safe-js has been updated to fit the Alpha network?


#3

Oh, just remembered I forgot to test the Ubuntu version for you… Getting on that!


#4

This is the more or less the same version of safe-js as previous, with added extra functionality to be included with beaker (alpha didnt really implement many changes AFAIK, just codified 0.5 for docs on release).

So it’s got API versioning in there for 0.5, and as far as I saw things (getting/creating dirs, authenticating) were all still compatible. So you should be good. But I’ve yet to comprehensively go over safe-js with the latest docs, so if you come across an implementation inconsistency, please let me know or open a safe-js issue.


Thanks, @WhiteOutMashups! let me knowhow you get on.


#5

Definitely! At a starbucks, just finished getting my new ubuntu setup running a few mins ago (dual boot on a MS Surface-- very slick! :smiley: ) so I’ll be able to download and test this when I get home


#6

Just gave it a shot, and couldn’t build with ./configure or make, which I usually use to compile.

Also just tried getting the last releases (0.2.3 and 0.2.2) to work on my new Ubuntu surface and couldn’t get them to start. I would just double click on the application and nothing would happen

Don’t know if I need / am missing any special dependencies perhaps?


#7

Great news ! I’ll test this right now and see if I can revive my safeshare project thanks to your work on safe-js


#8

Mac release available here now: https://github.com/joshuef/beaker/releases/tag/0.2.4-pre2

Ill update op.


#9

could you elaborate a bit ? I tried to call safe-js authorise from a script inside a safe hosted web page, with no avail so far .

What would be the correct syntax to call safe.utils.authorise( LOCAL_STORAGE_TOKEN_KEY, app ); in this context ?

what looked natural to me was :

window.safeAuth.autorise( key, app ) , but this returns undefined


#10

I can! I’ve changed ‘utils’ to safeAuth inside of beaker (makes more sense than the vague ‘utils’), this will be reflected in safe-js soon, but for now in SBB: window.safeAuth.authorise is indeed what you’re looking for (though you have a typo in what you posted here, fyi).

Are you on a safe: site? the APIs are only present on safe protocol sites. Let me know if you’re still not seeing the APIs at all, please.


#11

yes this is on : safe://testing.testbeakerapp, you can check it, it is online, but here is the page source anyways :

<!doctype html>
<html lang="en">
<head>
  <title>beaker web app test</title>
  <meta charset="utf-8">
</head>
<body style="margin: 0;">
    auth ?
 
  <script>            
 
    window.onload = function() {
    const LOCAL_STORAGE_TOKEN_KEY = 'BING';
    const app =
    {
        name: "beakerapptest",
        id: "id",
        version: "0.1",
        vendor: "vendor_name"
    };
    
    var test = window.safeAuth.authorise( LOCAL_STORAGE_TOKEN_KEY, app );    
        
    console.log ("test" , test );   
    }
  </script>
</body>
</html>

I suppose I am missing some linking or import ?


#12

aha! you’re running in to a bug in safe-js/beaker compat.

I’ve got this sorted locally, and you’ll be please to know that your site auths. I’ll going to finalise this commit and push the fix, so hopefully in ~30 mins there’ll be a new build that will work.

Coming back to you with the link once it’s up!


#13

new builds:

mac/linux: https://github.com/joshuef/beaker/releases/tag/0.2.4-pre3
win : https://github.com/joshuef/beaker/releases/tag/untagged-0e008b804cf43918aa43

Your code is working for me with this release on mac :thumbsup:


op updated


#14

As im working through here, I’m seeing issues with file writing, Auth is working fine for me locally, as is directory interaction, but creating / modifying files is currently broken.

Working on fixes for this now.


#15

Bing !

Good news :smiley: this works just fine now, building from the source for 0.2.4-pre3 that you released here : https://github.com/joshuef/beaker/archive/0.2.4-pre3.tar.gz

Bad news : I still do not manage to use the binaries that you released : if I try to run the browser as extracted from safer-beaker-browser-0.2.4-0.tar.gz , I get an error with ressources/app.asar :

A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module '~/archives/maidsafe/beaker-binaries/safer-beaker-browser-0.2.4-0/resources/app.asar/node_modules/sqlite3/lib/binding/electron-v1.3-linux-x64/node_sqlite3.node'

When browsing the unpacked folders, ressources/app.asar doesn’t appear as a folder but as an unknown file type , same for electron.asar - ie , there is no node_modules folder inside app.asar

I am not sure if the error comes from my side, like I am skipping a step somewhere, or from your packaging ?


#16

All news is good news. One step closer. Hmmmmm…

So this is on linux? (which build?)

Definitely seems like something is going wrong with the CI packaging there. Not sure what’s changed, I had it running on ubun16 VBs here. I’ll dive back in with the build once I’m a bit further with the API.

Good that you can get it going for now at least!


I expect to get another test release out later today, with file writing sorted. So you should be able to start using the network for app data storage properly oh so soon. :smiley:


#17

this is on fedora 21, 64 bits

Hint : when building from the git repo, if I do a npm run burnthemall, then starting the browser fails with a very similar error:

A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module '~/archives/maidsafe/beaker/app/node_modules/sqlite3/lib/binding/electron-v1.3-linux-x64/node_sqlite3.node'

then if I do a npm run rebuild, sqlite3.c is being rebuilt and everything goes fine

so my guess is that the package that you release is missing the sqlite module built some way.
I am not very aware of npm and packaging, but I hope this can help !


#18

it does. It’s a textbook error so far as this project goes :slight_smile:

npm rebuild has to be done for dev, but as to why it’s not being done in packaging. Hmmmmm. Well, it’s a lead for fedora problems. So :thumbsup:

Thanks for testing, @nice


#19

Aaand, a build with read/write/rename functionality working:

mac/linux: https://github.com/joshuef/beaker/releases/tag/0.2.4-pre4
win: https://github.com/joshuef/beaker/releases/tag/untagged-9454501c80a9d8cc4711


#20

I’m now experimenting with NFS functions, and it took me a while to understand how to retrieve a directory content.

I have had to dig deep into window.safeNFS.getDir 's response in order to decode the returned directory information, this way :

        var dir = window.safeNFS.getDir ( tok , "" , false );
        dir.then ( function (result) {                                
                var data = result.body._readableState.buffer.head.data ; 
                var datastr = Decodeuint8arr ( data ) ; console.log ( datastr );        
                 } );        

This gives me :

> {"info":{"name":"beakerapptest-Root-Dir","isPrivate":true,"createdOn":"2016-09-14T13:53:21.341Z","modifiedOn":"2016-09-14T13:53:21.341Z","metadata":""},"files":[],"subDirectories":[]}

with which I am quite happy :slight_smile:

If I understand correctly, safeNFS.getDir returns ‘body’ as a stream, is it how things are supposed to be now ? I think I remember reading a dev update about this a few weeks ago, but I think I must have missed a train !