From 4d6c7411b94285580db7d963426cfbdd418fb6f0 Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Sun, 19 Oct 2025 02:16:03 +0300 Subject: [PATCH] refactor of third aprty webapp login is working --- DEV.md | 2 +- engine/broker/auth/src/App.svelte | 3 +- engine/broker/src/server_ws.rs | 26 +- infra/ngaccount/README.md | 3 +- infra/ngaccount/web/index.html | 2 +- infra/ngaccount/web/jsconfig.json | 2 +- infra/ngaccount/web/src/main.js | 2 +- .../ngaccount/web/src/routes/NotFound.svelte | 1 - infra/ngaccount/web/src/styles.css | 368 ++++++++++++++++++ infra/ngnet/Cargo.toml | 3 + infra/ngnet/README.md | 2 +- infra/ngnet/bootstrap/src/App.svelte | 4 +- infra/ngnet/src/main.rs | 5 +- infra/ngnet/web/index.html | 2 +- infra/ngnet/web/package.json | 1 - sdk/js/examples/react-ldo/README.md | 19 +- sdk/js/web/src/index.ts | 4 +- 17 files changed, 414 insertions(+), 35 deletions(-) create mode 100644 infra/ngaccount/web/src/styles.css diff --git a/DEV.md b/DEV.md index 352bef5..7ca596f 100644 --- a/DEV.md +++ b/DEV.md @@ -6,7 +6,7 @@ On OpenBSD, for LLVM you need to choose llvm-17. -Until this [PR](https://github.com/rustwasm/wasm-pack/pull/1271) is accepted, will have to install wasm-pack this way: +On all platforms, we have to install wasm-pack this way: ``` cargo install wasm-pack --git https://git.nextgraph.org/NextGraph/wasm-pack.git --branch master diff --git a/engine/broker/auth/src/App.svelte b/engine/broker/auth/src/App.svelte index 244c639..d032906 100644 --- a/engine/broker/auth/src/App.svelte +++ b/engine/broker/auth/src/App.svelte @@ -89,9 +89,10 @@ // let walls = await ng.get_wallets(); // wallets.set(walls); // }; + const redirect_server = import.meta.env.NG_REDIR_SERVER || "nextgraph.net"; const iframe_config = import.meta.env.DEV ? {src:"http://localhost:14404/?o=", origin: "http://localhost:14404"} : import.meta.env.NG_DEV ? {src:"http://localhost:1421/auth.html?o=", origin: "http://localhost:1421"} : - {src:"https://nextgraph.net/auth/?o=", origin: "https://nextgraph.net"} ; + {src:`https://${redirect_server}/auth/?o=`, origin: `https://${redirect_server}`} ; // to test ngnet //const iframe_config = {src:"http://127.0.0.1:3033/auth/?o=", origin: "http://127.0.0.1:3033"}; diff --git a/engine/broker/src/server_ws.rs b/engine/broker/src/server_ws.rs index 2707b16..4d8f3ca 100644 --- a/engine/broker/src/server_ws.rs +++ b/engine/broker/src/server_ws.rs @@ -277,19 +277,19 @@ fn upgrade_ws_or_serve_app( // if referer.is_none() || referer.unwrap().to_str().is_err() || referer.unwrap().to_str().unwrap() != "https://nextgraph.net/" { // return Err(make_error(StatusCode::FORBIDDEN)); // } - let webapp_origin = match uri.query() { - Some(query) => { - if query.starts_with("o=") { - match decode(&query.chars().skip(2).collect::()) { - Err(_) => return Err(make_error(StatusCode::BAD_REQUEST)), - Ok(cow) => cow.into_owned(), - } - } else { - return Err(make_error(StatusCode::BAD_REQUEST)); - } - } - None => return Err(make_error(StatusCode::BAD_REQUEST)), - }; + // let webapp_origin = match uri.query() { + // Some(query) => { + // if query.starts_with("o=") { + // match decode(&query.chars().skip(2).collect::()) { + // Err(_) => return Err(make_error(StatusCode::BAD_REQUEST)), + // Ok(cow) => cow.into_owned(), + // } + // } else { + // return Err(make_error(StatusCode::BAD_REQUEST)); + // } + // } + // None => return Err(make_error(StatusCode::BAD_REQUEST)), + // }; let sha_file = AppAuth::get("index.sha256").unwrap(); let sha = format!( "\"{}\"", diff --git a/infra/ngaccount/README.md b/infra/ngaccount/README.md index dc66aa0..3eb561e 100644 --- a/infra/ngaccount/README.md +++ b/infra/ngaccount/README.md @@ -7,7 +7,7 @@ This server is used internally by NextGraph to handle the creation of accounts a ``` cd web npm install -g pnpm -pnpm --ignore-workspace install +pnpm install ``` ## Dev @@ -28,7 +28,6 @@ export NG_ACCOUNT_SERVER=127.0.0.1,14400,[YOUR_NGD_PEER_ID] export RUST_LOG=debug ``` - ```bash cd web pnpm run dev --host diff --git a/infra/ngaccount/web/index.html b/infra/ngaccount/web/index.html index 46cadf2..e436f1a 100644 --- a/infra/ngaccount/web/index.html +++ b/infra/ngaccount/web/index.html @@ -58,7 +58,7 @@ NextGraph