From e0e5738eda65d81abcc870177ab75512d23aa469 Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Fri, 22 Mar 2024 19:01:41 +0200 Subject: [PATCH] fixed invitation from localhost --- ng-app/src/App.svelte | 2 ++ ng-app/src/routes/Invitation.svelte | 18 ++++++++++++++++++ ng-app/src/routes/WalletCreate.svelte | 7 ++++--- ngd/README.md | 16 ++++++++++++++-- ngone/web/src/routes/WalletCreate.svelte | 5 +++-- p2p-net/src/utils.rs | 4 ++++ 6 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 ng-app/src/routes/Invitation.svelte diff --git a/ng-app/src/App.svelte b/ng-app/src/App.svelte index 07fdc40..9f520c1 100644 --- a/ng-app/src/App.svelte +++ b/ng-app/src/App.svelte @@ -27,6 +27,7 @@ import URI from "./routes/URI.svelte"; import NotFound from "./routes/NotFound.svelte"; import WalletCreate from "./routes/WalletCreate.svelte"; + import Invitation from "./routes/Invitation.svelte"; import WalletLogin from "./routes/WalletLogin.svelte"; import User from "./routes/User.svelte"; import UserRegistered from "./routes/UserRegistered.svelte"; @@ -39,6 +40,7 @@ routes.set("/test", Test); routes.set("/wallet/login", WalletLogin); routes.set("/wallet/create", WalletCreate); + routes.set("/i/:invitation", Invitation); routes.set("/user", User); routes.set("/user/registered", UserRegistered); if (import.meta.env.NG_APP_WEB) routes.set("/install", Install); diff --git a/ng-app/src/routes/Invitation.svelte b/ng-app/src/routes/Invitation.svelte new file mode 100644 index 0000000..b18e078 --- /dev/null +++ b/ng-app/src/routes/Invitation.svelte @@ -0,0 +1,18 @@ + + + diff --git a/ng-app/src/routes/WalletCreate.svelte b/ng-app/src/routes/WalletCreate.svelte index 366b637..56f1a59 100644 --- a/ng-app/src/routes/WalletCreate.svelte +++ b/ng-app/src/routes/WalletCreate.svelte @@ -156,7 +156,7 @@ invitation = await ng.decode_invitation(param.get("i")); window.location.replace(window.location.href.split("?")[0]); } else if (param.get("i")) { - invitation = await ng.get_local_bootstrap_with_public( + invitation = await ng.get_local_bootstrap( location.href, param.get("i") ); @@ -473,8 +473,9 @@

A NextGraph Wallet is unique to each person. It stores your - credentials and authorizations to access documents.

If - you already have a wallet, you should not create a new one, instead, + credentials and authorizations to access documents. You need one in + order to start using NextGraph.

If you already have a + wallet, you should not create a new one, instead, login here with your existing wallet. diff --git a/ngd/README.md b/ngd/README.md index 2bd3c3c..c4692e7 100644 --- a/ngd/README.md +++ b/ngd/README.md @@ -13,7 +13,7 @@ If you prefer to change the base directory, use the argument `--base [PATH]` whe ``` ngcli gen-key -ngd -v --save-key -d -l 1440 --admin +ngd -v --save-key -l 1440 --admin // note the server peerID from the logs ``` @@ -36,6 +36,18 @@ should return your userId you can now save the configs of both the server and client ``` -ngd -d -l 1440 --save-config +ngd -l 1440 --save-config ngcli -s 127.0.0.1,1440, -u --save-config ``` + +### Create an invitation for yourself so you can create your wallet + +``` +ngcli admin add-invitation +``` + +this will give you a link that you should open in your web browser. If there are many links, choose the one that starts with `http://localhost:`. + +The computer you use to open the link should have direct access to the ngd server on localhost. In most of the cases, it will work, as you are running ngd on localhost. If you are running ngd in a docker container, then you need to give access to the container to the local network of the host by using `docker run --network="host"`. https://docs.docker.com/network/drivers/host/ + +Follow the steps on the screen :) diff --git a/ngone/web/src/routes/WalletCreate.svelte b/ngone/web/src/routes/WalletCreate.svelte index 085e70f..46ad494 100644 --- a/ngone/web/src/routes/WalletCreate.svelte +++ b/ngone/web/src/routes/WalletCreate.svelte @@ -49,8 +49,9 @@

A NextGraph Wallet is unique to each person.
It stores your - credentials to access documents.
If you already have a wallet, you - should not create a new one, instead, + credentials to access documents. You need one in order to start using + NextGraph.
If you already have a wallet, you should not create a new + one, instead, {#if display_note_on_local_wallets} login here with your existing wallet. {:else} diff --git a/p2p-net/src/utils.rs b/p2p-net/src/utils.rs index 41f2863..b328b40 100644 --- a/p2p-net/src/utils.rs +++ b/p2p-net/src/utils.rs @@ -10,12 +10,16 @@ */ use crate::types::*; +#[cfg(target_arch = "wasm32")] +use crate::NG_BOOTSTRAP_LOCAL_PATH; use async_std::task; use ed25519_dalek::*; use futures::{channel::mpsc, Future}; use noise_protocol::U8Array; use noise_protocol::DH; use noise_rust_crypto::sensitive::Sensitive; +#[cfg(target_arch = "wasm32")] +use p2p_repo::errors::*; use p2p_repo::types::PubKey; use p2p_repo::{log::*, types::PrivKey}; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};