diff --git a/Cargo.lock b/Cargo.lock index 829a076..806147a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3326,7 +3326,6 @@ dependencies = [ "ng-repo", "noise-protocol", "noise-rust-crypto", - "num_enum", "once_cell", "reqwest", "serde", @@ -3355,6 +3354,7 @@ dependencies = [ "gloo-timers", "hex", "log", + "num_enum", "once_cell", "os_info", "rand 0.7.3", diff --git a/nextgraph/examples/open.rs b/nextgraph/examples/open.rs index 6c3cefc..8bc6293 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 = "hQK0RBKua5TUm2jqeSGPOMMzqplllAkbUgEh5P6Otf4".to_string(); + let wallet_name = "9ivXl3TpgcQlDKTmR9NOipjhPWxQw6Yg5jkWBTlJuXw".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,7 +48,7 @@ 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![134, 54, 112, 46, 94, 65, 20, 2, 99], + vec![110, 139, 115, 94, 9, 40, 74, 25, 52], [2, 3, 2, 3], )?; diff --git a/nextgraph/src/local_broker.rs b/nextgraph/src/local_broker.rs index e21c3c2..78764a3 100644 --- a/nextgraph/src/local_broker.rs +++ b/nextgraph/src/local_broker.rs @@ -12,7 +12,6 @@ use async_std::sync::{Arc, Mutex, RwLock, RwLockReadGuard}; use core::fmt; use ng_net::actor::EActor; use ng_net::connection::{ClientConfig, IConnect, NoiseFSM, StartConfig}; -use ng_net::errors::ProtocolError; use ng_net::types::{ClientInfo, ClientType, ProtocolMessage}; use ng_net::utils::{Receiver, Sender}; use ng_repo::block_storage::HashMapBlockStorage; @@ -30,7 +29,7 @@ use zeroize::{Zeroize, ZeroizeOnDrop}; use ng_net::broker::*; use ng_repo::block_storage::BlockStorage; -use ng_repo::errors::NgError; +use ng_repo::errors::{NgError, ProtocolError}; use ng_repo::log::*; use ng_repo::types::*; use ng_repo::utils::derive_key; @@ -1424,6 +1423,7 @@ mod test { }; use ng_net::types::BootstrapContentV0; use ng_wallet::{display_mnemonic, emojis::display_pazzle}; + use std::env::current_dir; use std::fs::read_to_string; use std::fs::{create_dir_all, File}; use std::io::BufReader; @@ -1537,6 +1537,62 @@ mod test { file.write_all(&ser).expect("write of opened_wallet file"); } + #[async_std::test] + async fn gen_opened_wallet_file_for_test_with_pazzle_array() { + 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 = vec![114, 45, 86, 104, 1, 135, 17, 50, 65]; + let opened_wallet = + wallet_open_with_pazzle(&wallet, pazzle, [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_std::test] + async fn import_session_for_test_to_disk() { + 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 = + serde_bare::from_slice(&opened_wallet_file).expect("deserialization of opened_wallet"); + + let mut current_path = current_dir().expect("cur_dir"); + current_path.push(".."); + current_path.push(".ng"); + current_path.push("example"); + create_dir_all(current_path.clone()).expect("create_dir"); + + // initialize the local_broker with config to save to disk in a folder called `.ng/example` in the current directory + init_local_broker(Box::new(move || { + LocalBrokerConfig::BasePath(current_path.clone()) + })) + .await; + + let wallet = wallet_read_file(wallet_file) + .await + .expect("wallet_read_file"); + + let wallet_name = wallet.name(); + let user_id = opened_wallet.personal_identity(); + + let _client = wallet_import(wallet, opened_wallet, false) + .await + .expect("wallet_import"); + + let _session = session_start(SessionConfig::new_in_memory(&user_id, &wallet_name)) + .await + .expect(""); + } + 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"); diff --git a/ng-app/dist-file.tar.gz b/ng-app/dist-file.tar.gz index 3dd7138..abaa5a2 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 480da94..feaa396 100644 --- a/ng-app/src/routes/WalletCreate.svelte +++ b/ng-app/src/routes/WalletCreate.svelte @@ -245,7 +245,7 @@ window.wallet_channel.postMessage(new_in_mem, location.href); } } - + console.log(ready.pazzle); console.log(display_pazzle(ready.pazzle)); download_name = "wallet-" + ready.wallet_name + ".ngw"; if (options.cloud) { @@ -1207,10 +1207,12 @@ would be the victim of a phishing attempt.

-

+

Here are the rules for the security phrase and image :

-