Does SafeBrowser - Alpha 2 support modern frameworks such as React or Angular?

Sorry if this is a silly question or has been asked before, just starting to get into SAFE. Thanks

2 Likes

It does support most things supported by Chrome.

XmlHttpRequests doesn’t work in the SAFE Browser though, since the sites are not served through HTTP, but rather the SAFE protocol. That means that any XmlHttpRequest has to replaced by a corresponding SAFE API request.

6 Likes

Yes. It is a fork of Beaker Browser, which is based on Chrome, so very up to date.

2 Likes

These requests work successfully with SAFE Browser used on clear net. I was thinking about using them to work around cost of PUT operations needed for mutable data.

I didn’t test them on safe network though, but a Google search shows that the server (a clear net site) must send “Access-Control-Allow-Origin: *” header to allow cross origin requests. So, in theory it should work with this header set by the server. Can someone from Maidsafe confirm this hypothesis?

Of course, such sites wouldn’t be pure safe sites because some javascript code would made XML Http requests to a clear net site.

Hm, I thought they were supposed to be blocked to prevent privacy leaks.

In any case, if you want to make a pure SAFE site, you have to replace any XmlHttpRequest with SAFE API calls. Some libraries do get a bit annoying because they assume your site is hosted on HTTP.

Eventually we should have all popular libraries with versions that supports SAFE. If you, for exaple, you’d want to use jquery’s $.get(... method you’d replace the implementation with window.safeApp.webFetch. If SAFE gets popular enough it should even get built in to the official jquery release, but I don’t think we should expect that in the near future.

There isn’t an exact 1-1 mapping between the clearnet and SAFE though, so some frameworks built for SAFE might end up being more useful than something like Angular or perhaps we’ll see forks of existing frameworks with new features specifically for SAFE.

Now, I have tested these requests in a local safe network (with “Access-Control-Allow-Origin: *” header set by a distant server on clear net). But I get “Failed to load resource: net::ERR_BLOCKED_BY_CLIENT” error displayed in SAFE Browser console and simultaneously, Microsoft Edge Browser opens with the content of the XML resource returned by the XMLHttpRequest. This is annoying because I had hope to work around PUT cost for dynamic data with these requests.

Can someone from Maidsafe explain if there is a way to get the result of a XMLHttpRequest from the javascript code of a safe site?

Or, if this method doesn’t work, would WebSockets do the job?

All non-safe: requests are blocked by default for security/privacy etc.

So while you can browse in non-safe mode, you probably shouldn’t rely on users doing this for your app.

3 Likes