diff --git a/app/nextgraph/src/main-web.ts b/app/nextgraph/src/main-web.ts index 25bad9bd..0b0e4631 100644 --- a/app/nextgraph/src/main-web.ts +++ b/app/nextgraph/src/main-web.ts @@ -11,7 +11,7 @@ import * as web_api from "@ng-org/lib-wasm"; import {init_api} from "@ng-org/ui-common/api"; init_api(web_api); -const NEW_VERSION = "0.1.2-alpha.1"; +const NEW_VERSION = "0.1.2-alpha.2"; // cleaning old wallets :( try { diff --git a/app/ui-common/src/api.ts b/app/ui-common/src/api.ts index 4c32cc62..43743310 100644 --- a/app/ui-common/src/api.ts +++ b/app/ui-common/src/api.ts @@ -23,14 +23,14 @@ let api = createAsyncProxy({},{ export default api; -export const NG_EU_BSP = "https://nextgraph.eu"; +export const NG_EU_BSP = import.meta.env.NG_ENV_ALT ? "https://"+import.meta.env.NG_ENV_ALT : "https://nextgraph.eu"; export const NG_EU_BSP_REGISTER = import.meta.env.PROD -? import.meta.env.NG_ENV_ALT ? "https://pnm.allelo.eco" : "https://account.nextgraph.eu/#/create" +? import.meta.env.NG_ENV_ALT_ACCOUNT ? import.meta.env.NG_ENV_ALT_ACCOUNT : "https://account.nextgraph.eu/#/create" : "http://account-dev.nextgraph.eu:5173/#/create"; export const NG_ONE_BSP = "https://nextgraph.one"; export const NG_ONE_BSP_REGISTER = import.meta.env.PROD -? import.meta.env.NG_ENV_ALT ? "https://account.allelo.eco/#/create" : "https://account.nextgraph.one/#/create" +? "https://account.nextgraph.one/#/create" : "http://account-dev.nextgraph.one:5173/#/create"; export const APP_ACCOUNT_REGISTERED_SUFFIX = "/#/user/registered"; diff --git a/app/ui-common/src/locales/en.json b/app/ui-common/src/locales/en.json index ac188205..719fae9d 100644 --- a/app/ui-common/src/locales/en.json +++ b/app/ui-common/src/locales/en.json @@ -342,7 +342,7 @@ }, "no_wallet": { "welcome": "Welcome to NextGraph", - "description": "We could not find a wallet saved on this device.", + "description": "We could not find a wallet on this device.", "instructions_login": "If you already have a wallet, select \"Login\"", "instructions_create": ", otherwise, select \"Create Wallet\" here below.", "instructions_nocreate": ". Creation of a Wallet is not possible while
logging-in to a third-party app.", diff --git a/app/ui-common/src/routes/WalletCreate.svelte b/app/ui-common/src/routes/WalletCreate.svelte index daae9f77..5c6f6df5 100644 --- a/app/ui-common/src/routes/WalletCreate.svelte +++ b/app/ui-common/src/routes/WalletCreate.svelte @@ -23,6 +23,7 @@ import { t } from "svelte-i18n"; import CenteredLayout from "../lib/CenteredLayout.svelte"; import PasswordInput from "../lib/components/PasswordInput.svelte"; + import { redirect_server, bootstrap_redirect, base64UrlEncode } from "./index"; // @ts-ignore import Logo from "../assets/nextgraph.svg?component"; @@ -39,11 +40,6 @@ const param = new URLSearchParams($querystring); - function base64UrlEncode(str) { - const base64 = btoa(str); // Standard Base64 encoding - return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""); - } - let tauri_platform = import.meta.env.TAURI_PLATFORM; let wait: any = false; @@ -80,15 +76,6 @@ top.scrollIntoView(); } - const redirect_server = import.meta.env.NG_REDIR_SERVER || "nextgraph.net"; - const bootstrap_redirect = import.meta.env.NG_DEV - ? "http://localhost:1421/bootstrap.html#/?b=" - : import.meta.env.DEV - ? "http://localhost:14403/#/?b=" - : import.meta.env.NG_DEV3 - ? "http://127.0.0.1:3033/bootstrap/#/?b=" - : `https://${redirect_server}/bootstrap/#/?b=`; - async function bootstrap() { //console.log(await ng.client_info()); if (!tauri_platform || tauri_platform == "android") { @@ -236,10 +223,6 @@ unsub_register = undefined; }); - onDestroy(async () => { - unsub_register(); - }); - const select_bsp = async (bsp_url, bsp_name) => { if (!tauri_platform || tauri_platform == "android") { let redirect_url; @@ -306,7 +289,7 @@ const selectEU = async (event) => { await select_bsp( NG_EU_BSP_REGISTER, - import.meta.env.NG_ENV_ALT ? "pnm.allelo.eco" : "nextgraph.eu" + import.meta.env.NG_ENV_ALT ? import.meta.env.NG_ENV_ALT : "nextgraph.eu" ); }; diff --git a/app/ui-common/src/routes/WalletLogin.svelte b/app/ui-common/src/routes/WalletLogin.svelte index 500e9dc0..83d0c401 100644 --- a/app/ui-common/src/routes/WalletLogin.svelte +++ b/app/ui-common/src/routes/WalletLogin.svelte @@ -23,6 +23,11 @@ import CenteredLayout from "../lib/CenteredLayout.svelte"; import ng from "../api"; import { Fileupload, Button } from "flowbite-svelte"; + import { + redirect_server, + bootstrap_redirect, + base64UrlEncode, + } from "./index"; // @ts-ignore import Logo from "../assets/nextgraph.svg?component"; import { @@ -162,21 +167,22 @@ $redirect_after_login = undefined; $redirect_if_wallet_is = undefined; let in_memory = !event.detail.trusted; - //console.log("IMPORTING", in_memory, event.detail.wallet, wallet); - // TODO : register bootstrap when importing - // if (!in_memory && !tauri_platform) { - // let bootstrap_iframe_msgs = - // await ng.get_bootstrap_iframe_msgs_for_brokers( - // event.detail.wallet.V0.brokers - // ); - // let res = await register_bootstrap(bootstrap_iframe_msgs); - // if (res !== true) { - // throw new Error( - // "We could not save your bootstrap information at nextgraph.net. This is needed for links and third-party webapps to work properly. so we are stopping here. Reason: " + - // res - // ); - // } - // } + console.log("IMPORTING", in_memory, event.detail.wallet, wallet); + //register bootstrap when importing + if (!in_memory && !tauri_platform) { + let bootstrap_iframe_msgs = + await ng.get_bootstrap_iframe_msgs_for_brokers( + event.detail.wallet.V0.brokers + ); + let encoded = base64UrlEncode(JSON.stringify(bootstrap_iframe_msgs)); + let register_bootstrap_url = + bootstrap_redirect + + encoded + + "&close=1&m=add&ab=" + + encodeURIComponent(window.location.href); + console.log(register_bootstrap_url); + window.open(register_bootstrap_url, "_blank"); + } let client = await ng.wallet_import( wallet, event.detail.wallet, @@ -328,14 +334,38 @@ on:click={start_login_from_import} on:keypress={start_login_from_import} > - {$wallet_from_import.V0.content.security_txt} - - {$wallet_from_import.V0.content.security_txt} + {#if $wallet_from_import.V0.content.password} +
+ +
+ {#if mobile}Tap{:else}Click{/if} here to login with your wallet +
+
+ +
+ +
+ {:else} + {$wallet_from_import.V0.content.security_txt} + + {$wallet_from_import.V0.content.security_txt} + {/if} @@ -361,7 +391,9 @@ /> {:else if !$active_wallet && !selected}
-

{$t("pages.wallet_login.select_wallet")}

diff --git a/app/ui-common/src/routes/index.ts b/app/ui-common/src/routes/index.ts index 3856a6f3..1f8d5c0f 100644 --- a/app/ui-common/src/routes/index.ts +++ b/app/ui-common/src/routes/index.ts @@ -11,4 +11,18 @@ export { default as WalletInfo} from "./WalletInfo.svelte"; export { default as WalletLogin} from "./WalletLogin.svelte"; export { default as WalletLoginQr} from "./WalletLoginQr.svelte"; export { default as WalletLoginTextCode} from "./WalletLoginTextCode.svelte"; -export { default as WalletLoginUsername} from "./WalletLoginUsername.svelte"; \ No newline at end of file +export { default as WalletLoginUsername} from "./WalletLoginUsername.svelte"; + +export const redirect_server = import.meta.env.NG_REDIR_SERVER || "nextgraph.net"; +export const bootstrap_redirect = import.meta.env.NG_DEV + ? "http://localhost:1421/bootstrap.html#/?b=" + : import.meta.env.DEV + ? "http://localhost:14403/#/?b=" + : import.meta.env.NG_DEV3 + ? "http://127.0.0.1:3033/bootstrap/#/?b=" + : `https://${redirect_server}/bootstrap/#/?b=`; + +export function base64UrlEncode(str) { + const base64 = btoa(str); // Standard Base64 encoding + return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""); +} \ No newline at end of file diff --git a/engine/net/src/bsps.rs b/engine/net/src/bsps.rs index ff7a2210..56c91266 100644 --- a/engine/net/src/bsps.rs +++ b/engine/net/src/bsps.rs @@ -37,6 +37,26 @@ lazy_static! { }, ); + if let Some(alt) = option_env!("NG_ENV_ALT") { + let s: &'static str = Box::leak(format!("https://{alt}").into_boxed_str()); + assert!(d + .insert( + s, + BSPDetail { + domain: alt, + country: "us", + sysadmin: "team@nextgraph.org", + owned: false, + since: Date::from_calendar_date(2025, Month::November, 1).unwrap(), + has_free: true, + has_paid: false, + official: true, + description: "Alternative BSP" + } + ) + .is_none()); + } + assert!(d.insert("https://nextgraph.one", BSPDetail { domain: "nextgraph.one", country: "de", diff --git a/engine/wallet/src/types.rs b/engine/wallet/src/types.rs index fd59b1e2..3b166882 100644 --- a/engine/wallet/src/types.rs +++ b/engine/wallet/src/types.rs @@ -421,7 +421,7 @@ impl ClientV0 { } } -/// Save to nextgraph.one +/// Save to nextgraph.net #[derive(Clone, Debug, Serialize, Deserialize)] pub enum SaveToNGOne { No, diff --git a/infra/ngaccount/web/vite.config.js b/infra/ngaccount/web/vite.config.js index ae97ff24..2ea5178f 100644 --- a/infra/ngaccount/web/vite.config.js +++ b/infra/ngaccount/web/vite.config.js @@ -7,7 +7,7 @@ import svelteSVG from "vite-plugin-svelte-svg"; export default defineConfig({ envPrefix: ["VITE_", "NG_"], server: { - allowedHosts: ["account-dev.nextgraph.eu","account-dev.nextgraph.one"] + allowedHosts: ["account-dev.nextgraph.eu"] }, plugins: [svelte({ preprocess: [ diff --git a/infra/ngnet/bootstrap/src/App.svelte b/infra/ngnet/bootstrap/src/App.svelte index 2f9d1588..21448f94 100644 --- a/infra/ngnet/bootstrap/src/App.svelte +++ b/infra/ngnet/bootstrap/src/App.svelte @@ -33,12 +33,16 @@ routes.set("*", NotFound); // TODO: take this list from local API - const bsp_list = [ + let bsp_list = [ "https://nextgraph.eu", "https://nextgraph.one", "https://stage1.nextgraph.eu" ]; + if (import.meta.env.NG_ENV_ALT) { + bsp_list.push("https://"+import.meta.env.NG_ENV_ALT); + } + let channel; try { channel = new BroadcastChannel("ng_bootstrap"); @@ -172,7 +176,11 @@ // url.searchParams.set('i', param.get("i")); // url.searchParams.set('rs', param.get("rs")); // url.searchParams.set('ab', "1"); - window.location.href = u + "&ab=1"; + if (param.get("close")) { + window.close(); + } else { + window.location.href = u + "&ab=1"; + } }catch {} }); diff --git a/sdk/rust/src/local_broker.rs b/sdk/rust/src/local_broker.rs index 639edc68..08f922c9 100644 --- a/sdk/rust/src/local_broker.rs +++ b/sdk/rust/src/local_broker.rs @@ -1856,12 +1856,14 @@ lazy_static! { #[cfg(not(debug_assertions))] lazy_static! { + static ref DOMAIN: &'static str = option_env!("NG_ENV_ALT").unwrap_or("nextgraph.eu"); + static ref PEERID: &'static str = + option_env!("NG_ENV_ALT_PEERID").unwrap_or("LZn-rQD_NUNxrWT_hBXeHk6cjI6WAy-knRVOdovIjwsA"); static ref NEXTGRAPH_EU: BrokerServerV0 = BrokerServerV0 { - server_type: BrokerServerTypeV0::Domain("nextgraph.eu".to_string()), + server_type: BrokerServerTypeV0::Domain(DOMAIN.to_string()), can_verify: false, can_forward: false, - peer_id: ng_repo::utils::decode_key("LZn-rQD_NUNxrWT_hBXeHk6cjI6WAy-knRVOdovIjwsA") - .unwrap(), + peer_id: ng_repo::utils::decode_key(&PEERID).unwrap(), }; }