diff --git a/Cargo.lock b/Cargo.lock index 9a568ee..829a076 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3419,6 +3419,7 @@ dependencies = [ "automerge", "blake3", "chacha20", + "either", "getrandom 0.2.10", "ng-net", "ng-repo", diff --git a/nextgraph/.gitignore b/nextgraph/.gitignore new file mode 100644 index 0000000..3598c30 --- /dev/null +++ b/nextgraph/.gitignore @@ -0,0 +1 @@ +tests \ No newline at end of file diff --git a/nextgraph/examples/open.rs b/nextgraph/examples/open.rs index a733d03..6c3cefc 100644 --- a/nextgraph/examples/open.rs +++ b/nextgraph/examples/open.rs @@ -37,7 +37,7 @@ async fn main() -> std::io::Result<()> { })) .await; - let wallet_name = "EJdLRVx93o3iUXoB0wSTqxh1-zYac-84vHb3oBbZ_HY".to_string(); + let wallet_name = "hQK0RBKua5TUm2jqeSGPOMMzqplllAkbUgEh5P6Otf4".to_string(); // as we have previously saved the wallet, // we can retrieve it, display the security phrase and image to the user, ask for the pazzle or mnemonic, and then open the wallet @@ -48,8 +48,8 @@ async fn main() -> std::io::Result<()> { // now let's open the wallet, by providing the pazzle and PIN code let opened_wallet = wallet_open_with_pazzle( &wallet, - vec![117, 134, 59, 92, 98, 35, 70, 22, 9], - [1, 2, 1, 2], + vec![134, 54, 112, 46, 94, 65, 20, 2, 99], + [2, 3, 2, 3], )?; let user_id = opened_wallet.personal_identity(); @@ -65,8 +65,8 @@ async fn main() -> std::io::Result<()> { let status = user_connect(&user_id).await?; // The connection cannot succeed because we miss-configured the core_bootstrap of the wallet. its Peer ID is invalid. - let error_reason = status[0].3.as_ref().unwrap(); - assert!(error_reason == "NoiseHandshakeFailed" || error_reason == "ConnectionError"); + println!("Connection was : {:?}", status[0]); + //assert!(error_reason == "NoiseHandshakeFailed" || error_reason == "ConnectionError"); // Then we should disconnect user_disconnect(&user_id).await?; diff --git a/nextgraph/examples/persistent.rs b/nextgraph/examples/persistent.rs index 753427f..803e002 100644 --- a/nextgraph/examples/persistent.rs +++ b/nextgraph/examples/persistent.rs @@ -44,7 +44,6 @@ async fn main() -> std::io::Result<()> { // the peer_id should come from somewhere else. // this is just given for the sake of an example - #[allow(deprecated)] let peer_id_of_server_broker = PubKey::nil(); // Create your wallet diff --git a/nextgraph/src/local_broker.rs b/nextgraph/src/local_broker.rs index 4521761..e21c3c2 100644 --- a/nextgraph/src/local_broker.rs +++ b/nextgraph/src/local_broker.rs @@ -168,6 +168,12 @@ impl LocalBrokerConfig { _ => false, } } + pub fn is_persistent(&self) -> bool { + match self { + Self::BasePath(_) => true, + _ => false, + } + } #[doc(hidden)] pub fn is_js(&self) -> bool { match self { @@ -702,7 +708,7 @@ impl LocalBroker { key_material.as_slice(), ); key_material.zeroize(); - let verifier = Verifier::new( + let mut verifier = Verifier::new( VerifierConfig { config_type: broker.verifier_config_type_from_session_config(&config), user_master_key: key, @@ -714,6 +720,10 @@ impl LocalBroker { block_storage, )?; key.zeroize(); + + //load verifier from local_storage (if rocks_db) + let _ = verifier.load(); + broker.opened_sessions_list.push(Some(Session { config, peer_key: session.peer_key.clone(), @@ -722,6 +732,7 @@ impl LocalBroker { })); let idx = broker.opened_sessions_list.len() - 1; broker.opened_sessions.insert(user_id, idx as u8); + Ok(SessionInfo { session_id: idx as u8, user: user_id, @@ -892,7 +903,7 @@ pub async fn wallet_create_v0(params: CreateWalletV0) -> Result (UserId, String) { + #[async_std::test] + async fn gen_opened_wallet_file_for_test() { + let wallet_file = read("tests/wallet.ngw").expect("read wallet file"); + + init_local_broker(Box::new(|| LocalBrokerConfig::InMemory)).await; + + let wallet = wallet_read_file(wallet_file) + .await + .expect("wallet_read_file"); + + let pazzle_string = read_to_string("tests/wallet.pazzle").expect("read pazzle file"); + let pazzle_words = pazzle_string.split(' ').map(|s| s.to_string()).collect(); + + let opened_wallet = wallet_open_with_pazzle_words(&wallet, &pazzle_words, [2, 3, 2, 3]) + .expect("opening of wallet"); + + let mut file = + File::create("tests/opened_wallet.ngw").expect("open for write opened_wallet file"); + let ser = serde_bare::to_vec(&opened_wallet).expect("serialization of opened wallet"); + + file.write_all(&ser).expect("write of opened_wallet file"); + } + + async fn import_session_for_test() -> (UserId, String) { let wallet_file = read("tests/wallet.ngw").expect("read wallet file"); let opened_wallet_file = read("tests/opened_wallet.ngw").expect("read opened_wallet file"); let opened_wallet: SensitiveWallet = @@ -1523,7 +1565,7 @@ mod test { #[async_std::test] async fn import_wallet() { - let (user_id, wallet_name) = init_session_for_test().await; + let (user_id, wallet_name) = import_session_for_test().await; let status = user_connect(&user_id).await.expect("user_connect"); diff --git a/ng-app/dist-file.tar.gz b/ng-app/dist-file.tar.gz index 15fc5c1..3dd7138 100644 Binary files a/ng-app/dist-file.tar.gz and b/ng-app/dist-file.tar.gz differ diff --git a/ng-app/src/routes/WalletCreate.svelte b/ng-app/src/routes/WalletCreate.svelte index 0641b93..480da94 100644 --- a/ng-app/src/routes/WalletCreate.svelte +++ b/ng-app/src/routes/WalletCreate.svelte @@ -1527,7 +1527,10 @@ /> then throw it away.
The order of each image is important.
- Now click on "Continue to Login"

+ Now click on "Continue to Login."

It is important that + you login with this wallet at least once from this device
+ (while connected to the internet), so that your personal site is + created on your broker.