SAFE Browser 10.0.2 mock --- connectAuthorised errors

api

#1

I have downloaded the latest version of the SAFE Browser. Live as well as mock. I can’t seem to make the connectAuthorised call to work.

The following is from within the SAFE Browser mock console:

It does not get past connectAuthorised and returns the infamous “Could not connect to the SAFE Network” error.


I have also encountered the exact same using the API playground by @hunterlester. (Using the same order: initialise, authorise and connectedAuthorised.) However, it only happens in the mock browser. It does not happen on the live Alpha 2 network.


Could anyone confirm this or spot a mistake in my process?


#2

@bzee I’d recommend using the latest versions of Peruse for dev (from the webId POC, using a newer version of safe-app-nodejs).

For authing apps in Peruse (such as the webId manager), this should get you going:

    const app = await safe.initialiseApp( APP_INFO.info );
    const authUri = await app.auth.genAuthUri( APP_INFO.permissions, APP_INFO.opts );
    const response = await safe.authorise( authUri );
    const connectedApp = await app.auth.loginFromUri( response );

For reference, the file for these actions: https://github.com/maidsafe/safe-web-id-manager-js/blob/master/src/actions/safe_actions.js

You’d also need the 3.0 branch of the playground


#3

Thanks for the quick reply. The reason for using the SAFE Browser is that I’m trying to test if something works that uses the old API.

It’s unfortunate that the mock browser now seems broken. Although I can understand that it won’t be fixed anymore.


On the newer Peruse everything works. But that’s not my question. My problem is specifically with the 10.0.2 SAFE Browser (mock).


#4

Okay fair enough.

I dont see anything obviously wrong in your code.

This error can be thrown if the network configs are missing. But if you’ve downloaded the latest browser package, then it should be included (grabbing now to double check for me).

In the meantime, can you log the appHandle / uri just to check they are legit.


#5

I checked both the handle and URI to be legit. The exact same snippet works on the live network.


#6

@bzee if you are using the mock version of SAFE Beaker browser 0.10.2 you’ll need to set the env var NODE_ENV=dev in order to work properly, did you set this when trying with mock?


#7

I downloaded the mock browser from the releases page from GitHub.

Anyway, I just tried running the ‘SAFE Browser’ executable from an environment with the variable set. It makes no difference. So I assume it’s not needed.


#8

Can you please try by first removing you MockVault file and launching the mock browser again with the env set? (please make a backup of the mockvault we might be able to use it to reproduce the issue actually)


#9

Thanks, that seems to work! I do not remember having to set the environment variable for a mock build specifically (especially since it’s a hassle in comparison to just launching the executable). Has this changed?


#10

Ok, cool, then it’s just this same issue reported some time ago: https://maidsafe.atlassian.net/browse/MAID-2658
(cc: @nbaksalyar )

It hasn’t change, it’s been always like that for Beaker browser, and we were actually trying to remove it, and that’s what we did in Peruse already as it’s really not nice.


#11

Thanks for looking into this! Sorry for not seeing it was reported already on the JIRA; I’ve tried searching for the issue there briefly but could not find any.


#12

No worries at all @bzee, I’m very glad you are trying things out, honestly. I edited my previous response in regard to the env var btw


#13

I’m confused. It if has always supposed to be like this, then there is no issue, right? Then this is just expected behavior.

I just looked at the README and it does not mention setting the variable before launching the executable. I also downloaded version 0.9, and it works without setting the environment variable. I’m quite sure I’ve never had to set NODE_ENV before launching the executable…


#14

Yes it was always like this for our Beaker browser, so it’s expected that you need to set the env var when running it for mock. What it’s not expected is the error you had even when setting the env var which is reported in Jira.

In the README we have replaced the part where we explained setting the env var with the instruction to use another script which does it for you:
"If you're actively developing, you can run 'yarn mock' instead of 'yarn' in order to get the 'safe_client' libraries which use the 'MockVault' file rather than connecting to the SAFE Network."

I can only speculate with you having it set globally in your env? but I don’t know obviously, but if you look at the dev hub we even made sure to include that in the instructions:
https://hub.safedev.org/platform/web/#install-a-safe-browser


#15

Interesting! But, I’m not talking about the build process. I’m using pre-built releases from GitHub…

I just tested three versions: 0.8, 0.9 and 0.10. I first removed the mock vault file, then launched the version (mock) and used the playground to connect. Only 0.10 gives me the error ‘Could not connect …’, the other two do not.

This might be connected with the issue in 0.10?


Thanks for pointing me to that! Could it be added to the 5th step of the README too?

It tells how to package, but it doesn’t say the NODE_ENV should be set to dev when launching the mock build. (Which is why I thought the environment variable was never needed to be set before launching the mock version.)


I appreciate the answers. I’m sorry for the confusion…


#16

Yeah, probably it’s a bug introduced in safe_client_libs v0.6.0 as browser v0.10.x upgraded it from v0.5.0: https://github.com/maidsafe/safe_browser/blob/master/CHANGELOG.md#indirect-dependencies-2

BTW, I’m not sure if this is still happening in safe_app lib 0.7.x or 0.8.0.

Yes probably it can be added.