Safe network access

I saw that the invitation system that used to be integrated in the SAFE browser is gone. I’m trying out of curiosity to develop a small PoC app around articles sharing - authors gets paid if users like the articles and so on. I have the basic idea drafted out from documentation point of view and I can start writing some code. I want to build the app in Rust. So, I have two questions:

  • Is there a new way of creating account and accessing the network?

I need to authenticate users so I know who is who. I’ll also need to be able to upload files to the network so that articles get stored. Some sort of basic cataloging system would also be part of the PoC but I can figure something quick and easy if files can be stored and accessed.

  • What crate (Rust dependency) I need to use to access SAFE API?

Thank you!

9 Likes

As long as this isn’t outdated then New Release: Vault Phase 1 (real vault) but I’m pretty sure Maidsafe has been updating it. I’ll poke around for more resources.

The safe-api is a Rust crate which exposes the SAFE API with all the functions needed to communicate with the SAFE Network and the SAFE Authenticator. If you are developing a Rust application for SAFE, this is all you need as a dependency from your app.

8 Likes

Thank you! I managed to add the "safe-api = “0.6.0” crate to my dependencies and got a build. There are no docs on https://docs.rs/crate/safe-api/0.6.0 so I built them myself locally but I don’t see any examples. I would appreciate if someone can show me some example implementations that can help me get the hang of it.

As for the steps on the Vault Phase 1 release I can honestly say that I haven’t had much luck with it. I’m asked for a secret and password which I don’t have - I don’t know how to create an account nowadays and the only pointers I managed to find are to the invite system that was taken down. I’ll grab latest binaries and keep trying - maybe I am missing the point somewhere.

4 Likes

Update on the vault testing. I’m doing those steps:

  • Running safe_vault
kstaykov@devz:~/Downloads/safenet$ safe_vault 
Checking target-arch... x86_64-unknown-linux-musl
Checking current version... v0.20.1
Checking latest released version... v0.20.1
Update status: `0.20.1`!
Our connection info:
{"peer_addr":"127.0.0.1:48184","peer_cert_der":[48,130,1,78,48,129,246,160,3,2,1,2,2,1,42,48,10,6,8,42,134,72,206,61,4,3,2,48,33,49,31,48,29,6,3,85,4,3,12,22,114,99,103,101,110,32,115,101,108,102,32,115,105,103,110,101,100,32,99,101,114,116,48,34,24,15,49,57,55,53,48,49,48,49,48,48,48,48,48,48,90,24,15,52,48,57,54,48,49,48,49,48,48,48,48,48,48,90,48,33,49,31,48,29,6,3,85,4,3,12,22,114,99,103,101,110,32,115,101,108,102,32,115,105,103,110,101,100,32,99,101,114,116,48,89,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,3,66,0,4,45,17,64,218,113,255,23,216,51,179,145,35,167,23,90,109,167,178,152,16,8,76,150,143,70,132,140,118,221,77,78,111,64,51,235,143,42,203,87,172,166,194,183,174,7,28,32,90,60,133,159,116,44,104,147,97,1,3,67,245,225,99,2,225,163,27,48,25,48,23,6,3,85,29,17,4,16,48,14,130,12,77,97,105,100,83,65,70,69,46,110,101,116,48,10,6,8,42,134,72,206,61,4,3,2,3,71,0,48,68,2,32,97,139,164,4,237,36,182,30,122,215,69,157,96,185,110,199,138,11,207,202,15,144,238,38,93,36,224,190,218,203,221,222,2,32,123,172,237,85,87,10,73,200,42,178,116,175,223,11,42,18,189,154,8,140,178,176,223,23,214,126,134,0,242,212,167,127]}

Writing connection info to: /home/kstaykov/.config/safe_vault/vault_connection_info.config
Waiting for connections ...
  • Using safe_auth with --test-coins which seems like is creating an account for me. I put the same string when asked for Secret and Password:
kstaykov@devz:~/Downloads/safenet$ safe_auth --daemon 41805 --test-coins
Secret: 
Password: 
Account was created successfully!
SafeKey created and preloaded with test-coins. Owner key pair generated:
Public Key = 95853c2b109ff8350fd50e3d7....<removed some of it>
Secret Key = 96053254cb9c7e59ea0dbaf6e......<removed some of it>
Exposing service on 127.0.0.1:41805
  • I then tried to authenticate but that fails:
kstaykov@devz:~/Downloads/safenet$ safe auth login --self-auth
Passphrase: 
Password: 
Sending login action request to authd...
[2020-01-04T22:25:43Z ERROR safe] safe-cli error: [Error] AuthdError - [Error] AuthError - Failed to log in: no SAFE account found with the passphrase provided
kstaykov@devz:~/Downloads/safenet$ 

I tried putting the same string in Passphrase and Password that I used before with safe_auth. I also tried the Public Key and Secret Key I was given but no luck.

What am I doing wrong?

3 Likes

I don’t think we can launch directly safe_auth anymore. The procedure is to launch it indirectly with safe command:

$ safe auth start

and then to create the account:

$ safe auth create-acc --test-coins

(notice the blank between safe and auth, instead of an underscore)

7 Likes

This might be handy. What’s included in Phase 1 Vaults?

@tfa made a nice tutorial awhile back. Maybe this could help. New Release: Vault Phase 1 (mock vault)

4 Likes

Unfortunately this tutorial is not valid anymore (it uses former safe_auth).

CLI complete documentation is here:

9 Likes

Thanks @tfa I had forgotten that auth is bundled into the CLI now.

5 Likes

Thank you! That was the missing piece - now it works and I can continue playing with it.

9 Likes

I had a look at the dev forum and I found that safe-app might be a better dependency to use. Here’s an example the guys created:

https://docs.rs/crate/safe_app/0.12.0/source/examples/self_authentication.rs

Repo: https://github.com/maidsafe/safe_client_libs

It looks rather nice. Too bad I’m back at work tomorrow but when I get the chance I’ll play with it some more.

5 Likes

Is bash completions implemented yet? Docs suggest they are but …

willie@gagarin:~/projects/maidsafe$ SC=/tmp/safe.rc && safe setup completions bash > $SC && source $SC
error: Found argument 'setup' which wasn't expected, or isn't valid in this context

USAGE:
 safe [FLAGS] [OPTIONS] [SUBCOMMAND]

For more information try --help

I’m on the latest version
willie@gagarin:~/projects/maidsafe$ safe update
Checking target-arch… x86_64-unknown-linux-gnu
Checking current version… v0.6.0
Checking latest released version… v0.6.0
Update status: 0.6.0!

Apart from that little niggle, everything I tried Just Works as per the docs

2 Likes

@Southside that command is implemented on master branch already but not released yet, so you need to either use master branch (building CLI yourself), or use the older auto-completion implementation detailed in the 0.6.0 release notes: https://github.com/maidsafe/safe-api/releases/tag/0.6.0

5 Likes