wallet_recovery_pdf

pull/33/head
Niko PLP 4 months ago
parent 46c6228de2
commit 8b2558cd9c
  1. 144
      Cargo.lock
  2. 2
      nextgraph/Cargo.toml
  3. 614
      nextgraph/src/local_broker.rs
  4. 2
      ng-app/src-tauri/build.rs
  5. 6
      ng-app/src-tauri/src/lib.rs
  6. 3
      ng-app/src/api.ts
  7. 3
      ng-app/src/locales/en.json
  8. 2
      ng-net/src/broker.rs
  9. 4
      ng-oxigraph/build.rs
  10. 8
      ng-oxigraph/src/oxigraph/storage/backend/mod.rs
  11. 40
      ng-oxigraph/tests/store.rs
  12. 1
      ng-repo/src/errors.rs
  13. 6
      ng-sdk-js/src/lib.rs
  14. 4
      ng-storage-rocksdb/build.rs
  15. 4
      ng-storage-rocksdb/src/lib.rs
  16. 4
      ng-verifier/build.rs
  17. 3
      ng-verifier/src/lib.rs
  18. 17
      ng-wallet/src/bip39.rs
  19. 13
      ng-wallet/src/types.rs
  20. 8
      ngaccount/src/main.rs

144
Cargo.lock generated

@ -520,6 +520,12 @@ version = "0.21.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d"
[[package]]
name = "base64"
version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]] [[package]]
name = "base64-url" name = "base64-url"
version = "2.0.0" version = "2.0.0"
@ -1421,6 +1427,12 @@ version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]]
name = "data-url"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a"
[[package]] [[package]]
name = "debug_print" name = "debug_print"
version = "1.0.0" version = "1.0.0"
@ -1791,6 +1803,12 @@ dependencies = [
"miniz_oxide", "miniz_oxide",
] ]
[[package]]
name = "float-cmp"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4"
[[package]] [[package]]
name = "flume" name = "flume"
version = "0.10.14" version = "0.10.14"
@ -2620,6 +2638,12 @@ dependencies = [
"tiff", "tiff",
] ]
[[package]]
name = "imagesize"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "029d73f573d8e8d63e6d5020011d3255b28c3ba85d6cf870a07184ed23de9284"
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.9.3" version = "1.9.3"
@ -2830,6 +2854,16 @@ dependencies = [
"selectors", "selectors",
] ]
[[package]]
name = "kurbo"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e5aa9f0f96a938266bdb12928a67169e8d22c6a786fda8ed984b85e6ba93c3c"
dependencies = [
"arrayvec",
"smallvec",
]
[[package]] [[package]]
name = "kv-log-macro" name = "kv-log-macro"
version = "1.0.7" version = "1.0.7"
@ -3271,10 +3305,12 @@ dependencies = [
"ng-verifier", "ng-verifier",
"ng-wallet", "ng-wallet",
"once_cell", "once_cell",
"pdf-writer",
"qrcode", "qrcode",
"serde_bare", "serde_bare",
"serde_bytes", "serde_bytes",
"serde_json", "serde_json",
"svg2pdf",
"web-time", "web-time",
"whoami", "whoami",
"zeroize", "zeroize",
@ -4046,6 +4082,18 @@ version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79"
[[package]]
name = "pdf-writer"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af6a7882fda7808481d43c51cadfc3ec934c6af72612a1fe6985ce329a2f0469"
dependencies = [
"bitflags 2.5.0",
"itoa 1.0.6",
"memchr",
"ryu",
]
[[package]] [[package]]
name = "peeking_take_while" name = "peeking_take_while"
version = "0.1.2" version = "0.1.2"
@ -4203,6 +4251,12 @@ dependencies = [
"siphasher 0.3.10", "siphasher 0.3.10",
] ]
[[package]]
name = "pico-args"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315"
[[package]] [[package]]
name = "pin-project" name = "pin-project"
version = "1.1.0" version = "1.1.0"
@ -4711,6 +4765,12 @@ dependencies = [
"winreg 0.10.1", "winreg 0.10.1",
] ]
[[package]]
name = "roxmltree"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97"
[[package]] [[package]]
name = "rust-embed" name = "rust-embed"
version = "6.7.0" version = "6.7.0"
@ -5160,6 +5220,15 @@ version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f" checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f"
[[package]]
name = "simplecss"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a11be7c62927d9427e9f40f3444d5499d868648e2edbc4e2116de69e7ec0e89d"
dependencies = [
"log",
]
[[package]] [[package]]
name = "siphasher" name = "siphasher"
version = "0.3.10" version = "0.3.10"
@ -5292,6 +5361,15 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strict-num"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
dependencies = [
"float-cmp",
]
[[package]] [[package]]
name = "string_cache" name = "string_cache"
version = "0.8.7" version = "0.8.7"
@ -5330,6 +5408,29 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]]
name = "svg2pdf"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e31565956eb1dc398c0d9776ee1d1bac4e34759af63dcbe0520df32313a5b53b"
dependencies = [
"log",
"miniz_oxide",
"once_cell",
"pdf-writer",
"usvg",
]
[[package]]
name = "svgtypes"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fae3064df9b89391c9a76a0425a69d124aee9c5c28455204709e72c39868a43c"
dependencies = [
"kurbo",
"siphasher 1.0.1",
]
[[package]] [[package]]
name = "swift-rs" name = "swift-rs"
version = "1.0.6" version = "1.0.6"
@ -5854,6 +5955,17 @@ dependencies = [
"crunchy", "crunchy",
] ]
[[package]]
name = "tiny-skia-path"
version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93"
dependencies = [
"arrayref",
"bytemuck",
"strict-num",
]
[[package]] [[package]]
name = "tinytemplate" name = "tinytemplate"
version = "1.2.1" version = "1.2.1"
@ -6194,6 +6306,28 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "usvg"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b84ea542ae85c715f07b082438a4231c3760539d902e11d093847a0b22963032"
dependencies = [
"base64 0.22.1",
"data-url",
"flate2",
"imagesize",
"kurbo",
"log",
"pico-args",
"roxmltree",
"simplecss",
"siphasher 1.0.1",
"strict-num",
"svgtypes",
"tiny-skia-path",
"xmlwriter",
]
[[package]] [[package]]
name = "utf-8" name = "utf-8"
version = "0.7.6" version = "0.7.6"
@ -6568,9 +6702,9 @@ dependencies = [
[[package]] [[package]]
name = "weezl" name = "weezl"
version = "0.1.7" version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
[[package]] [[package]]
name = "whoami" name = "whoami"
@ -7042,6 +7176,12 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "xmlwriter"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
[[package]] [[package]]
name = "xsalsa20poly1305" name = "xsalsa20poly1305"
version = "0.9.1" version = "0.9.1"

@ -30,6 +30,8 @@ lazy_static = "1.4.0"
web-time = "0.2.0" web-time = "0.2.0"
whoami = "1.5.1" whoami = "1.5.1"
qrcode = { version = "0.14.1", default-features = false, features = ["svg"] } qrcode = { version = "0.14.1", default-features = false, features = ["svg"] }
svg2pdf = { version = "0.11.0", default-features = false }
pdf-writer = "0.10.0"
ng-repo = { path = "../ng-repo", version = "0.1.0-preview.1" } ng-repo = { path = "../ng-repo", version = "0.1.0-preview.1" }
ng-net = { path = "../ng-net", version = "0.1.0-preview.1" } ng-net = { path = "../ng-net", version = "0.1.0-preview.1" }
ng-wallet = { path = "../ng-wallet", version = "0.1.0-preview.5" } ng-wallet = { path = "../ng-wallet", version = "0.1.0-preview.5" }

File diff suppressed because it is too large Load Diff

@ -1,3 +1,3 @@
fn main() { fn main() {
tauri_build::build() tauri_build::build()
} }

@ -111,12 +111,12 @@ async fn wallet_open_with_pazzle(
#[tauri::command(rename_all = "snake_case")] #[tauri::command(rename_all = "snake_case")]
async fn wallet_open_with_mnemonic( async fn wallet_open_with_mnemonic(
wallet: Wallet, wallet: Wallet,
mnemonic: Vec<u16>, mnemonic: [u16; 12],
pin: [u8; 4], pin: [u8; 4],
_app: tauri::AppHandle, _app: tauri::AppHandle,
) -> Result<SensitiveWallet, String> { ) -> Result<SensitiveWallet, String> {
let wallet = nextgraph::local_broker::wallet_open_with_mnemonic(&wallet, mnemonic, pin) let wallet =
.map_err(|e| e.to_string())?; ng_wallet::open_wallet_with_mnemonic(&wallet, mnemonic, pin).map_err(|e| e.to_string())?;
Ok(wallet) Ok(wallet)
} }

@ -17,6 +17,7 @@ const mapping = {
"wallet_gen_shuffle_for_pin": [], "wallet_gen_shuffle_for_pin": [],
"wallet_open_with_pazzle": ["wallet","pazzle","pin"], "wallet_open_with_pazzle": ["wallet","pazzle","pin"],
"wallet_open_with_mnemonic_words": ["wallet","mnemonic_words","pin"], "wallet_open_with_mnemonic_words": ["wallet","mnemonic_words","pin"],
"wallet_open_with_mnemonic": ["wallet","mnemonic","pin"],
"wallet_was_opened": ["opened_wallet"], "wallet_was_opened": ["opened_wallet"],
"wallet_create": ["params"], "wallet_create": ["params"],
"wallet_read_file": ["file"], "wallet_read_file": ["file"],
@ -189,7 +190,7 @@ const handler = {
return false; return false;
} else if (path[0] === "get_local_url") { } else if (path[0] === "get_local_url") {
return false; return false;
} else if (path[0] === "wallet_open_with_pazzle" || path[0] === "wallet_open_with_mnemonic_words") { } else if (path[0] === "wallet_open_with_pazzle" || path[0] === "wallet_open_with_mnemonic_words" || path[0] === "wallet_open_with_mnemonic") {
let arg:any = {}; let arg:any = {};
args.map((el,ix) => arg[mapping[path[0]][ix]]=el) args.map((el,ix) => arg[mapping[path[0]][ix]]=el)
let img = Array.from(new Uint8Array(arg.wallet.V0.content.security_img)); let img = Array.from(new Uint8Array(arg.wallet.V0.content.security_img));

@ -348,7 +348,8 @@
"InvalidNuri": "Invalid NextGraph URI.", "InvalidNuri": "Invalid NextGraph URI.",
"InvalidTarget": "Cannot resolve target.", "InvalidTarget": "Cannot resolve target.",
"ExportWalletTimeOut": "Export of wallet has expired.", "ExportWalletTimeOut": "Export of wallet has expired.",
"ConnectionError": "Could not connect to the server." "ConnectionError": "Could not connect to the server.",
"IncompatibleQrCode": "You scanned a NextGraph QR-Code that is of the wrong type"
}, },
"connectivity": { "connectivity": {
"stopped": "Stopped", "stopped": "Stopped",

@ -639,7 +639,7 @@ impl Broker {
let res = join.next().await; let res = join.next().await;
match res { match res {
Some(Either::Right(remote_peer_id)) => { Some(Either::Right(remote_peer_id)) => {
let res = join.next().await; let _res = join.next().await;
// if res.is_some() // if res.is_some()
// && res.as_ref().unwrap().as_ref().unwrap_left() == &NetError::Closing // && res.as_ref().unwrap().as_ref().unwrap_left() == &NetError::Closing

@ -1,7 +1,5 @@
fn main() { fn main() {
if std::env::var("DOCS_RS").is_ok() { if std::env::var("DOCS_RS").is_ok() {
println!("cargo:rustc-cfg=docsrs"); println!("cargo:rustc-cfg=docsrs");
} }
}
}

@ -1,12 +1,12 @@
//! A storage backend //! A storage backend
//! RocksDB is available, if not in memory //! RocksDB is available, if not in memory
#[cfg(any(target_family = "wasm",docsrs))] #[cfg(any(target_family = "wasm", docsrs))]
pub use fallback::{ColumnFamily, ColumnFamilyDefinition, Db, Iter, Reader, Transaction}; pub use fallback::{ColumnFamily, ColumnFamilyDefinition, Db, Iter, Reader, Transaction};
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
pub use oxi_rocksdb::{ColumnFamily, ColumnFamilyDefinition, Db, Iter, Reader, Transaction}; pub use oxi_rocksdb::{ColumnFamily, ColumnFamilyDefinition, Db, Iter, Reader, Transaction};
#[cfg(any(target_family = "wasm",docsrs))] #[cfg(any(target_family = "wasm", docsrs))]
mod fallback; mod fallback;
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
mod oxi_rocksdb; mod oxi_rocksdb;

@ -5,20 +5,20 @@ use ng_oxigraph::oxigraph::io::RdfFormat;
use ng_oxigraph::oxigraph::model::vocab::{rdf, xsd}; use ng_oxigraph::oxigraph::model::vocab::{rdf, xsd};
use ng_oxigraph::oxigraph::model::*; use ng_oxigraph::oxigraph::model::*;
use ng_oxigraph::oxigraph::store::Store; use ng_oxigraph::oxigraph::store::Store;
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
use rand::random; use rand::random;
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
use std::env::temp_dir; use std::env::temp_dir;
use std::error::Error; use std::error::Error;
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
use std::fs::{create_dir_all, remove_dir_all, File}; use std::fs::{create_dir_all, remove_dir_all, File};
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
use std::io::Write; use std::io::Write;
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
use std::iter::empty; use std::iter::empty;
#[cfg(all(target_os = "linux"))] #[cfg(all(target_os = "linux"))]
use std::iter::once; use std::iter::once;
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
#[cfg(all(target_os = "linux"))] #[cfg(all(target_os = "linux"))]
use std::process::Command; use std::process::Command;
@ -121,7 +121,7 @@ fn test_load_graph() -> Result<(), Box<dyn Error>> {
} }
#[test] #[test]
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
fn test_bulk_load_graph() -> Result<(), Box<dyn Error>> { fn test_bulk_load_graph() -> Result<(), Box<dyn Error>> {
let store = Store::new()?; let store = Store::new()?;
store store
@ -135,7 +135,7 @@ fn test_bulk_load_graph() -> Result<(), Box<dyn Error>> {
} }
#[test] #[test]
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
fn test_bulk_load_graph_lenient() -> Result<(), Box<dyn Error>> { fn test_bulk_load_graph_lenient() -> Result<(), Box<dyn Error>> {
let store = Store::new()?; let store = Store::new()?;
store.bulk_loader().on_parse_error(|_| Ok(())).load_from_read( store.bulk_loader().on_parse_error(|_| Ok(())).load_from_read(
@ -154,7 +154,7 @@ fn test_bulk_load_graph_lenient() -> Result<(), Box<dyn Error>> {
} }
#[test] #[test]
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
fn test_bulk_load_empty() -> Result<(), Box<dyn Error>> { fn test_bulk_load_empty() -> Result<(), Box<dyn Error>> {
let store = Store::new()?; let store = Store::new()?;
store.bulk_loader().load_quads(empty::<Quad>())?; store.bulk_loader().load_quads(empty::<Quad>())?;
@ -177,7 +177,7 @@ fn test_load_dataset() -> Result<(), Box<dyn Error>> {
} }
#[test] #[test]
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
fn test_bulk_load_dataset() -> Result<(), Box<dyn Error>> { fn test_bulk_load_dataset() -> Result<(), Box<dyn Error>> {
let store = Store::new()?; let store = Store::new()?;
store store
@ -258,7 +258,7 @@ fn test_snapshot_isolation_iterator() -> Result<(), Box<dyn Error>> {
} }
#[test] #[test]
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
fn test_bulk_load_on_existing_delete_overrides_the_delete() -> Result<(), Box<dyn Error>> { fn test_bulk_load_on_existing_delete_overrides_the_delete() -> Result<(), Box<dyn Error>> {
let quad = QuadRef::new( let quad = QuadRef::new(
NamedNodeRef::new_unchecked("http://example.com/s"), NamedNodeRef::new_unchecked("http://example.com/s"),
@ -274,7 +274,7 @@ fn test_bulk_load_on_existing_delete_overrides_the_delete() -> Result<(), Box<dy
} }
#[test] #[test]
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
fn test_open_bad_dir() -> Result<(), Box<dyn Error>> { fn test_open_bad_dir() -> Result<(), Box<dyn Error>> {
let dir = TempDir::default(); let dir = TempDir::default();
create_dir_all(&dir.0)?; create_dir_all(&dir.0)?;
@ -344,7 +344,7 @@ fn test_bad_stt_open() -> Result<(), Box<dyn Error>> {
// } // }
#[test] #[test]
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
fn test_bad_backup() -> Result<(), Box<dyn Error>> { fn test_bad_backup() -> Result<(), Box<dyn Error>> {
let store_dir = TempDir::default(); let store_dir = TempDir::default();
let backup_dir = TempDir::default(); let backup_dir = TempDir::default();
@ -355,7 +355,7 @@ fn test_bad_backup() -> Result<(), Box<dyn Error>> {
} }
#[test] #[test]
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
fn test_backup_on_in_memory() -> Result<(), Box<dyn Error>> { fn test_backup_on_in_memory() -> Result<(), Box<dyn Error>> {
let backup_dir = TempDir::default(); let backup_dir = TempDir::default();
Store::new()?.backup(&backup_dir).unwrap_err(); Store::new()?.backup(&backup_dir).unwrap_err();
@ -442,7 +442,7 @@ fn test_backward_compatibility() -> Result<(), Box<dyn Error>> {
// } // }
#[test] #[test]
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
fn test_read_only() -> Result<(), Box<dyn Error>> { fn test_read_only() -> Result<(), Box<dyn Error>> {
let s = NamedNodeRef::new_unchecked("http://example.com/s"); let s = NamedNodeRef::new_unchecked("http://example.com/s");
let p = NamedNodeRef::new_unchecked("http://example.com/p"); let p = NamedNodeRef::new_unchecked("http://example.com/p");
@ -491,7 +491,7 @@ fn test_read_only() -> Result<(), Box<dyn Error>> {
} }
#[test] #[test]
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
fn test_open_read_only_bad_dir() -> Result<(), Box<dyn Error>> { fn test_open_read_only_bad_dir() -> Result<(), Box<dyn Error>> {
let dir = TempDir::default(); let dir = TempDir::default();
create_dir_all(&dir.0)?; create_dir_all(&dir.0)?;
@ -515,24 +515,24 @@ fn reset_dir(dir: &str) -> Result<(), Box<dyn Error>> {
Ok(()) Ok(())
} }
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
struct TempDir(PathBuf); struct TempDir(PathBuf);
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
impl Default for TempDir { impl Default for TempDir {
fn default() -> Self { fn default() -> Self {
Self(temp_dir().join(format!("oxigraph-test-{}", random::<u128>()))) Self(temp_dir().join(format!("oxigraph-test-{}", random::<u128>())))
} }
} }
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
impl AsRef<Path> for TempDir { impl AsRef<Path> for TempDir {
fn as_ref(&self) -> &Path { fn as_ref(&self) -> &Path {
&self.0 &self.0
} }
} }
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
impl Drop for TempDir { impl Drop for TempDir {
fn drop(&mut self) { fn drop(&mut self) {
if self.0.is_dir() { if self.0.is_dir() {

@ -87,6 +87,7 @@ pub enum NgError {
InvalidQrCode, InvalidQrCode,
NotImplemented, NotImplemented,
NotARendezVous, NotARendezVous,
IncompatibleQrCode,
} }
impl Error for NgError {} impl Error for NgError {}

@ -148,14 +148,16 @@ pub fn wallet_open_with_pazzle(
#[wasm_bindgen] #[wasm_bindgen]
pub fn wallet_open_with_mnemonic( pub fn wallet_open_with_mnemonic(
wallet: JsValue, wallet: JsValue,
mnemonic: Vec<u16>, mnemonic: JsValue,
pin: JsValue, pin: JsValue,
) -> Result<JsValue, JsValue> { ) -> Result<JsValue, JsValue> {
let encrypted_wallet = serde_wasm_bindgen::from_value::<Wallet>(wallet) let encrypted_wallet = serde_wasm_bindgen::from_value::<Wallet>(wallet)
.map_err(|_| "Deserialization error of wallet")?; .map_err(|_| "Deserialization error of wallet")?;
let pin = serde_wasm_bindgen::from_value::<[u8; 4]>(pin) let pin = serde_wasm_bindgen::from_value::<[u8; 4]>(pin)
.map_err(|_| "Deserialization error of pin")?; .map_err(|_| "Deserialization error of pin")?;
let res = nextgraph::local_broker::wallet_open_with_mnemonic(&encrypted_wallet, mnemonic, pin); let mnemonic = serde_wasm_bindgen::from_value::<[u16; 12]>(mnemonic)
.map_err(|_| "Deserialization error of mnemonic")?;
let res = ng_wallet::open_wallet_with_mnemonic(&encrypted_wallet, mnemonic, pin);
match res { match res {
Ok(r) => Ok(r Ok(r) => Ok(r
.serialize(&serde_wasm_bindgen::Serializer::new().serialize_maps_as_objects(true)) .serialize(&serde_wasm_bindgen::Serializer::new().serialize_maps_as_objects(true))

@ -1,7 +1,5 @@
fn main() { fn main() {
if std::env::var("DOCS_RS").is_ok() { if std::env::var("DOCS_RS").is_ok() {
println!("cargo:rustc-cfg=docsrs"); println!("cargo:rustc-cfg=docsrs");
} }
}
}

@ -1,5 +1,5 @@
#[cfg(all(not(target_arch = "wasm32"),not(docsrs)))] #[cfg(all(not(target_arch = "wasm32"), not(docsrs)))]
pub mod block_storage; pub mod block_storage;
#[cfg(all(not(target_arch = "wasm32"),not(docsrs)))] #[cfg(all(not(target_arch = "wasm32"), not(docsrs)))]
pub mod kcv_storage; pub mod kcv_storage;

@ -1,7 +1,5 @@
fn main() { fn main() {
if std::env::var("DOCS_RS").is_ok() { if std::env::var("DOCS_RS").is_ok() {
println!("cargo:rustc-cfg=docsrs"); println!("cargo:rustc-cfg=docsrs");
} }
}
}

@ -1,4 +1,3 @@
pub mod types; pub mod types;
pub mod site; pub mod site;
@ -12,5 +11,5 @@ mod commits;
mod request_processor; mod request_processor;
#[cfg(all(not(target_family = "wasm"),not(docsrs)))] #[cfg(all(not(target_family = "wasm"), not(docsrs)))]
mod rocksdb_user_storage; mod rocksdb_user_storage;

@ -227,14 +227,15 @@ lazy_static! {
} }
/// Taking a list of bip39 words, returns a list of u16 codes /// Taking a list of bip39 words, returns a list of u16 codes
pub fn encode_mnemonic(words: &Vec<String>) -> Result<Vec<u16>, NgError> { pub fn encode_mnemonic(words: &Vec<String>) -> Result<[u16; 12], NgError> {
let mut res = vec![]; if words.len() != 12 {
for word in words { return Err(NgError::InvalidMnemonic);
res.push( }
*BIP39_WORD_MAP let mut res = [0u16; 12];
.get(word.as_str()) for (idx, word) in words.iter().enumerate() {
.ok_or(NgError::InvalidMnemonic)?, res[idx] = *BIP39_WORD_MAP
); .get(word.as_str())
.ok_or(NgError::InvalidMnemonic)?;
} }
Ok(res) Ok(res)
} }

@ -1428,16 +1428,25 @@ pub struct ShuffledPazzle {
} }
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub struct NgQRCodeV0 { pub struct NgQRCodeWalletTransferV0 {
pub broker: BrokerServerV0, pub broker: BrokerServerV0,
pub rendezvous: SymKey, // Rendez-vous ID pub rendezvous: SymKey, // Rendez-vous ID
pub secret_key: SymKey, pub secret_key: SymKey,
pub is_rendezvous: bool, pub is_rendezvous: bool,
} }
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct NgQRCodeWalletRecoveryV0 {
pub wallet: WalletContentV0, //of which security_img is emptied
pub pazzle: Vec<u8>,
pub mnemonic: [u16; 12],
pub pin: [u8; 4],
}
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub enum NgQRCode { pub enum NgQRCode {
V0(NgQRCodeV0), WalletTransferV0(NgQRCodeWalletTransferV0),
WalletRecoveryV0(NgQRCodeWalletRecoveryV0),
} }
impl NgQRCode { impl NgQRCode {

@ -12,17 +12,17 @@ extern crate anyhow;
mod types; mod types;
use std::convert::Infallible; use std::convert::Infallible;
use std::env;
use std::net::IpAddr; use std::net::IpAddr;
use std::str::FromStr; use std::str::FromStr;
use std::sync::Arc; use std::sync::Arc;
use std::{env};
use duration_str::parse; use duration_str::parse;
use rust_embed::RustEmbed;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use warp::http::header::{HeaderMap, HeaderValue}; use warp::http::header::{HeaderMap, HeaderValue};
use warp::reply::Response; use warp::reply::Response;
use warp::{Filter, Reply}; use warp::{Filter, Reply};
use rust_embed::RustEmbed;
use ng_repo::log::*; use ng_repo::log::*;
use ng_repo::types::*; use ng_repo::types::*;
@ -32,12 +32,11 @@ use ng_net::actors::admin::add_invitation::*;
use ng_net::broker::BROKER; use ng_net::broker::BROKER;
use ng_net::types::{ use ng_net::types::{
AdminResponseContentV0, BindAddress, CreateAccountBSP, Invitation, InvitationCode, AdminResponseContentV0, BindAddress, CreateAccountBSP, Invitation, InvitationCode,
APP_ACCOUNT_REGISTERED_SUFFIX, APP_ACCOUNT_REGISTERED_SUFFIX,
}; };
use ng_client_ws::remote_ws::ConnectionWebSocket; use ng_client_ws::remote_ws::ConnectionWebSocket;
#[derive(RustEmbed)] #[derive(RustEmbed)]
#[folder = "web/dist"] #[folder = "web/dist"]
struct Static; struct Static;
@ -261,7 +260,6 @@ async fn main() -> anyhow::Result<()> {
"default-src 'self' data:; connect-src ipc: https://ipc.localhost 'self' http://localhost:3031", "default-src 'self' data:; connect-src ipc: https://ipc.localhost 'self' http://localhost:3031",
#[cfg(not(debug_assertions))] #[cfg(not(debug_assertions))]
"default-src 'self' data:; connect-src ipc: https://ipc.localhost 'self'", "default-src 'self' data:; connect-src ipc: https://ipc.localhost 'self'",
), ),
); );

Loading…
Cancel
Save