diff --git a/ng-app/dist-file.tar.gz b/ng-app/dist-file.tar.gz index 64124a1..d466dcb 100644 Binary files a/ng-app/dist-file.tar.gz and b/ng-app/dist-file.tar.gz differ diff --git a/ng-app/dist.tar.gz b/ng-app/dist.tar.gz deleted file mode 100644 index 6e93e3d..0000000 Binary files a/ng-app/dist.tar.gz and /dev/null differ diff --git a/ng-app/src/routes/WalletCreate.svelte b/ng-app/src/routes/WalletCreate.svelte index 114016b..7226453 100644 --- a/ng-app/src/routes/WalletCreate.svelte +++ b/ng-app/src/routes/WalletCreate.svelte @@ -109,6 +109,7 @@ let cloud_link; let animateDownload = true; let invitation; + let pre_invitation; let unsub_register_accepted; let unsub_register_error; @@ -159,7 +160,10 @@ param.get("i") ); console.log(invitation); - if (!invitation) { + if (invitation && invitation.V0.url) { + pre_invitation = invitation; + invitation = undefined; + } else if (!invitation) { let redirect = await ng.get_ngone_url_of_invitation(param.get("i")); if (redirect) { console.error("got an invitation for another broker. redirecting"); @@ -169,6 +173,11 @@ console.error("invalid invitation. ignoring it"); } } + } else { + pre_invitation = await ng.get_local_bootstrap_with_public( + location.href + ); + console.log("pre_invitation", pre_invitation); } } scrollToTop(); @@ -176,10 +185,11 @@ function create_wallet() { intro = false; - if (invitation && invitation.V0.url) { - // we redirect to the TOS url of the invitation. - window.location.href = invitation.V0.url; - } + // if (invitation && invitation.V0.url) { + // // we redirect to the TOS url of the invitation. + // wait = "Redirecting to TOS"; + // window.location.href = invitation.V0.url; + // } scrollToTop(); } @@ -890,39 +900,67 @@

Please choose one broker among the list

-
- -
+ {#if pre_invitation} +
+ +
+ {:else} +
+ +
-
- -
+ + For the rest of the world + + + {/if}
{/if}
- {:else} - {#if ca} -
-

- You would like to choose {domain} as your Broker Service - Provider.
Please read carefully the Terms of Service here below, - before accepting them. + {#if error} +

+ + +

+ An error occurred while registering on this broker:
{error}

+ {#if go_back} + + {/if}
- {/if} -
-
-

{domain} Terms of Service

+ {:else} + {#if ca} +
+

+ You would like to choose {domain} as your Broker Service + Provider.
Please read carefully the Terms of Service here + below, before accepting them. +

+
+ {/if} +
+
+

{domain} Terms of Service

-
    - {#if domain == "nextgraph.eu"} +
      + {#if domain == "nextgraph.eu"} +
    • + + Our servers are located in Germany, and we comply with the + GDPR regulation. +
    • +
    • + + legal details about GDPR... TBD +
    • + {/if}
    • Our servers are located in Germany, and we comply with the GDPR - regulation.All the data you exchange with us while using the broker is + end-to-end encrypted and we do not have access to your + decryption keys, meaning that we cannot see the content of your + documents.
    • @@ -194,93 +269,87 @@ - legal details about GDPR... TBD + We do not log any private information about you (nor IP, nor + country, nor statistics of any kind). Only your UserId is kept, + together with the list of devices (clientId) you use to connect + to the broker. We collect general purpose information about your + device (OS version, browser version, and if you use the app, the + version and date of last update). We do not have access to any + unique tracking identifier of your device (like Android MAID or + iPhone IDFA). We could nevertheless be asked by law enforcement + authorities, depending on the jurisdiction of the server, to log + the IP you use when connecting to the broker, and/or to provide + them with the encrypted content you have stored on our servers. + If you prefer to avoid that eventually, please refrain from any + illegal activity while using this broker.
    • - {/if} -
    • - - All the data you exchange with us while using the broker is - end-to-end encrypted and we do not have access to your decryption - keys, meaning that we cannot see the content of your documents. -
    • -
    • - - We do not log any private information about you (nor IP, nor - country, nor statistics of any kind). Only your UserId is kept, - together with the list of devices (clientId) you use to connect to - the broker. We collect general purpose information about your - device (OS version, browser version, and if you use the app, the - version and date of last update). We do not have access to any - unique tracking identifier of your device (like Android MAID or - iPhone IDFA). We could nevertheless be asked by law enforcement - authorities, depending on the jurisdiction of the server, to log - the IP you use when connecting to the broker, and/or to provide - them with the encrypted content you have stored on our servers. If - you prefer to avoid that eventually, please refrain from any - illegal activity while using this broker. -
    • -
    • - - - You can delete your account with us at any time by going to the - link https://account.{domain}/#/delete or by entering in your NextGraph application and selecting the menu, - then Accounts, then under broker "delete registration" -
    • -
    • +
    • + + + You can delete your account with us at any time by going to the + link https://account.{domain}/#/delete or by entering in your NextGraph application and selecting the + menu, then Accounts, then under broker "delete registration" +
    • +
    • + + Registration is free of charge. And it would be very nice of + you if you wanted to donate a small amount to help us cover the + fees we have to pay for operating the servers. Here is the + donation link: https://nextgraph.org/donate + +
    • +
    +
+
+ {#if ca} +
+
-
- {#if ca} -
- - -
+ I refuse + +
+ {/if} {/if} - {/if} - + +{/if} diff --git a/ngd/README.md b/ngd/README.md index 190c90d..2bd3c3c 100644 --- a/ngd/README.md +++ b/ngd/README.md @@ -13,8 +13,13 @@ If you prefer to change the base directory, use the argument `--base [PATH]` whe ``` ngcli gen-key -ngd --save-key -d -l 1440 --admin -// note the server peerID in the logs +ngd -v --save-key -d -l 1440 --admin +// note the server peerID from the logs +``` + +in another terminal: + +``` ngcli --save-key -s 127.0.0.1,1440, -u admin add-user -a ``` diff --git a/ngd/src/main.rs b/ngd/src/main.rs index 1987550..ded78ab 100644 --- a/ngd/src/main.rs +++ b/ngd/src/main.rs @@ -996,7 +996,7 @@ async fn main_inner() -> Result<(), ()> { config_path.to_str().unwrap() ); log_info!( - "You not be able to use any Quick config options anymore on the command line at the next command-line start of the server. But you can go to modify the config file directly, or delete it.", + "You will not be able to use any Quick config options anymore on the command line at the next command-line start of the server. But you can go to modify the config file directly, or delete it.", ); } } else { diff --git a/p2p-broker/src/server_ws.rs b/p2p-broker/src/server_ws.rs index 1afcb2f..cb3d4f9 100644 --- a/p2p-broker/src/server_ws.rs +++ b/p2p-broker/src/server_ws.rs @@ -656,6 +656,8 @@ pub async fn run_server_v0( let mut servers: Vec = vec![]; + let registration_url = config.registration_url; + // Preparing the listeners addrs and infos for listener in config.listeners { if !listener.accept_direct && listener.accept_forward_for == AcceptForwardForV0::No { @@ -757,8 +759,13 @@ pub async fn run_server_v0( log_warn!("There isn't any listener that accept clients. This is a misconfiguration as a core server that cannot receive client connections is useless"); } let bootstrap_v0 = BootstrapContentV0 { servers }; - let bootstrap = BootstrapContent::V0(bootstrap_v0.clone()); - BOOTSTRAP_STRING.set(json!(bootstrap).to_string()).unwrap(); + let local_bootstrap_info = LocalBootstrapInfo::V0(LocalBootstrapInfoV0 { + bootstrap: bootstrap_v0.clone(), + registration_url: registration_url.clone(), + }); + BOOTSTRAP_STRING + .set(json!(local_bootstrap_info).to_string()) + .unwrap(); // saving the infos in the broker. This needs to happen before we start listening, as new incoming connections can happen anytime after that. // and we need those infos for permission checking. @@ -772,7 +779,7 @@ pub async fn run_server_v0( &mut path, wallet_master_key, if admin_invite { - Some(bootstrap_v0) + Some(bootstrap_v0.clone()) } else { None }, @@ -788,9 +795,9 @@ pub async fn run_server_v0( overlays_configs: config.overlays_configs, registration: config.registration, admin_user: config.admin_user, - registration_url: config.registration_url, + registration_url, peer_id, - bootstrap, + bootstrap: BootstrapContent::V0(bootstrap_v0), }; broker.set_server_config(server_config); } diff --git a/p2p-net/src/types.rs b/p2p-net/src/types.rs index 0c975ce..56d6bb9 100644 --- a/p2p-net/src/types.rs +++ b/p2p-net/src/types.rs @@ -546,6 +546,15 @@ impl BootstrapContentV0 { pub fn get_first_peer_id(&self) -> Option { self.servers.first().map(|s| s.peer_id) } + + pub fn get_domain(&self) -> Option { + for server in self.servers.iter() { + if let BrokerServerTypeV0::Domain(name) = &server.server_type { + return Some(name.clone()); + } + } + None + } } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -561,6 +570,43 @@ impl BootstrapContent { } } +/// Local Bootstrap info Version 0, served at /.ng_bootstrap +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct LocalBootstrapInfoV0 { + /// list of servers, in order of preference + pub bootstrap: BootstrapContentV0, + + /// optional registration_url for public server that accept to be BSP for new clients + pub registration_url: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub enum LocalBootstrapInfo { + V0(LocalBootstrapInfoV0), +} + +impl LocalBootstrapInfo { + pub fn servers(&self) -> &Vec { + match self { + Self::V0(v0) => &v0.bootstrap.servers, + } + } +} + +impl From for Invitation { + fn from(value: LocalBootstrapInfo) -> Self { + let LocalBootstrapInfo::V0(info) = value; + let name = info.bootstrap.get_domain(); + let url = info.registration_url.clone(); + Invitation::V0(InvitationV0 { + bootstrap: info.bootstrap, + code: None, + name, + url, + }) + } +} + #[derive(Clone, Debug, Serialize, Deserialize)] pub enum InvitationCode { Unique(SymKey), @@ -609,7 +655,7 @@ impl InvitationV0 { } pub fn empty(name: Option) -> Self { InvitationV0 { - bootstrap: BootstrapContentV0 { servers: vec![] }, + bootstrap: BootstrapContentV0::new(), code: None, name, url: None, @@ -668,7 +714,7 @@ impl Invitation { pub fn intersects(&self, invite2: Invitation) -> Invitation { let Invitation::V0(v0) = self; let mut new_invite = InvitationV0 { - bootstrap: BootstrapContentV0 { servers: vec![] }, + bootstrap: BootstrapContentV0::new(), code: v0.code.clone(), name: v0.name.clone(), url: v0.url.clone(), @@ -763,18 +809,18 @@ pub enum Invitation { V0(InvitationV0), } -impl From for Invitation { - fn from(value: BootstrapContent) -> Self { - let BootstrapContent::V0(boot) = value; - - Invitation::V0(InvitationV0 { - bootstrap: boot, - code: None, - name: None, - url: None, - }) - } -} +// impl From for Invitation { +// fn from(value: BootstrapContent) -> Self { +// let BootstrapContent::V0(boot) = value; +// let name = boot.get_domain(); +// Invitation::V0(InvitationV0 { +// bootstrap: boot, +// code: None, +// name, +// url: None, +// }) +// } +// } /// Create an account at a Broker Service Provider (BSP). #[derive(Clone, Debug, Serialize, Deserialize)] diff --git a/p2p-net/src/utils.rs b/p2p-net/src/utils.rs index 34361ec..1d4c055 100644 --- a/p2p-net/src/utils.rs +++ b/p2p-net/src/utils.rs @@ -115,7 +115,7 @@ pub fn check_is_local_url(bootstrap: &BrokerServerV0, location: &String) -> Opti } #[cfg(target_arch = "wasm32")] -async fn retrieve_ng_bootstrap(location: &String) -> Option { +async fn retrieve_ng_bootstrap(location: &String) -> Option { let prefix = if (APP_PREFIX == "") { let url = Url::parse(location).unwrap(); url.origin().unicode_serialization() @@ -126,7 +126,7 @@ async fn retrieve_ng_bootstrap(location: &String) -> Option { //log_info!("url {}", url); let resp = reqwest::get(url).await; if resp.is_ok() { - let resp = resp.unwrap().json::().await; + let resp = resp.unwrap().json::().await; return Some(resp.unwrap()); } else { //log_info!("err {}", resp.unwrap_err()); @@ -136,11 +136,11 @@ async fn retrieve_ng_bootstrap(location: &String) -> Option { #[cfg(target_arch = "wasm32")] pub async fn retrieve_local_url(location: String) -> Option { - let bootstraps = retrieve_ng_bootstrap(&location).await; - if bootstraps.is_none() { + let info = retrieve_ng_bootstrap(&location).await; + if info.is_none() { return None; } - for bootstrap in bootstraps.unwrap().servers() { + for bootstrap in info.unwrap().servers() { let res = check_is_local_url(bootstrap, &location); if res.is_some() { return res; @@ -165,12 +165,11 @@ pub async fn retrieve_local_bootstrap( log_debug!("invite_String {:?} invite1{:?}", invite_string, invite1); let invite2: Option = { - let bootstraps = retrieve_ng_bootstrap(&location_string).await; - if bootstraps.is_none() { + let info = retrieve_ng_bootstrap(&location_string).await; + if info.is_none() { None } else { - let mut inv: Invitation = bootstraps.unwrap().into(); - inv.set_url(BROKER.read().await.get_registration_url()); + let mut inv: Invitation = info.unwrap().into(); Some(inv) } };