diff --git a/ng-app/package.json b/ng-app/package.json index eeca364..3c533c3 100644 --- a/ng-app/package.json +++ b/ng-app/package.json @@ -47,6 +47,7 @@ "@milkdown/theme-nord": "7.4.0", "@milkdown/transformer": "7.2.0", "@milkdown/utils": "7.4.0", + "@nextgraph-monorepo/ng-sdk-js": "workspace:*", "@popperjs/core": "^2.11.8", "@replit/codemirror-lang-svelte": "^6.0.0", "@sindresorhus/is": "4.6.0", @@ -67,12 +68,12 @@ "immutable-json-patch": "^6.0.1", "katex": "^0.16.11", "lodash.debounce": "4.0.8", - "@nextgraph-monorepo/ng-sdk-js": "workspace:*", "prism-themes": "^1.9.0", "prosemirror-model": "^1.7.1", "prosemirror-state": "^1.2.3", "prosemirror-svelte": "^0.2.4", "prosemirror-view": "^1.9.10", + "remote-web-streams": "^0.2.0", "skin-tone": "2.0.0", "style-mod": "^4.1.2", "svelte-codemirror-editor": "^1.4.0", @@ -85,8 +86,7 @@ "y-codemirror.next": "^0.3.5", "y-prosemirror": "^1.2.10", "y-protocols": "^1.0.1", - "yjs": "^13.6.18", - "remote-web-streams": "^0.2.0" + "yjs": "^13.6.18" }, "devDependencies": { "@sveltejs/vite-plugin-svelte": "2.0.0", diff --git a/ng-app/src/lib/Login.svelte b/ng-app/src/lib/Login.svelte index a26da4c..69dacde 100644 --- a/ng-app/src/lib/Login.svelte +++ b/ng-app/src/lib/Login.svelte @@ -32,7 +32,7 @@ } from "svelte-heros-v2"; import PasswordInput from "./components/PasswordInput.svelte"; import Spinner from "./components/Spinner.svelte"; - import { display_error, test_bootstrap, NG_BOOTSTRAP_IFRAME_SRC } from "../store"; + import { display_error } from "../store"; //import Worker from "../worker.js?worker&inline"; export let wallet; export let for_import = false; @@ -46,24 +46,6 @@ const dispatch = createEventDispatcher(); - async function test_local_storage() { - if (!tauri_platform) { - if ((await ng.get_bowser())=="Safari") return; - await tick(); - let iframe: HTMLIFrameElement = window.document.getElementById('nextgraph-bootstrap-iframe'); - return new Promise(async (resolve) => { - iframe.addEventListener("load", async function() { - if (!await test_bootstrap()){ - trusted = false; - no_local_storage = true; - } - resolve(null); - }); - iframe.src=NG_BOOTSTRAP_IFRAME_SRC as string; - }); - } - } - onMount(async () => { loaded = false; if (for_import) { @@ -79,9 +61,8 @@ } catch (e) { trusted = false; no_local_storage = true; - console.log("no access to localStorage") + console.log("no access to localStorage"); } - await test_local_storage(); } }); @@ -285,7 +266,11 @@ } } catch (e) { console.error(e); - if (e.message && e.message.includes("constructor") || (typeof e === "string" && e.includes("constructor") )) e = "BrowserTooOld"; + if ( + (e.message && e.message.includes("constructor")) || + (typeof e === "string" && e.includes("constructor")) + ) + e = "BrowserTooOld"; error = e; step = "end"; dispatch("error", { error: e }); @@ -301,7 +286,10 @@ async function on_pin_key(val) { pin_code = [...pin_code, val]; if (pin_code.length == 4) { - setTimeout(()=>window.document.getElementById("confirm_pin_btn").focus(),50); + setTimeout( + () => window.document.getElementById("confirm_pin_btn").focus(), + 50 + ); } } @@ -372,12 +360,6 @@ } -{#if NG_BOOTSTRAP_IFRAME_SRC} - -{/if} -
640} @@ -426,29 +408,32 @@ {#if for_import} {#if no_local_storage} -
- - Access to local storage is denied.
You won't be able to save your wallet in this browser.
- If you wanted to save it, please allow storing local data
for the websites {location.origin}
- and https://nextgraph.net and then reload the page.
You might need to all third-party cookies too. -
-
+
+ + Access to local storage is denied.
You won't be able to save + your wallet in this browser.
+ If you wanted to save it, please allow storing local data
+ for the websites {location.origin}
+ and https://nextgraph.net and then reload the page.
You might + need to all third-party cookies too. +
+
{:else} -
- {$t("pages.wallet_create.save_wallet_options.trust")} -
-

- {$t("pages.wallet_create.save_wallet_options.trust_description")} - {#if !tauri_platform} - {$t("pages.login.trust_device_allow_cookies")}{/if}
-

-
- {$t("pages.login.trust_device_yes")} +
+ {$t("pages.wallet_create.save_wallet_options.trust")} +
+

+ {$t("pages.wallet_create.save_wallet_options.trust_description")} + {#if !tauri_platform} + {$t("pages.login.trust_device_allow_cookies")}{/if}
+

+
+ {$t("pages.login.trust_device_yes")} +
-
{/if} {/if} @@ -635,7 +620,10 @@ class:h-[160px]={!mobile} class:h-[93px]={mobile} class:text-8xl={!mobile} - on:click={async () => {window.document.activeElement.blur(); await on_pin_key(num)}} + on:click={async () => { + window.document.activeElement.blur(); + await on_pin_key(num); + }} disabled={pin_code.length >= 4} > {num} @@ -651,7 +639,10 @@ class:h-[160px]={!mobile} class:h-[93px]={mobile} class:text-8xl={!mobile} - on:click={async () => {window.document.activeElement.blur();await on_pin_key(shuffle_pin[9])}} + on:click={async () => { + window.document.activeElement.blur(); + await on_pin_key(shuffle_pin[9]); + }} disabled={pin_code.length >= 4} > {shuffle_pin[9]} diff --git a/ng-app/src/routes/WalletCreate.svelte b/ng-app/src/routes/WalletCreate.svelte index 96b5e85..be37058 100644 --- a/ng-app/src/routes/WalletCreate.svelte +++ b/ng-app/src/routes/WalletCreate.svelte @@ -45,11 +45,21 @@ } from "../wallet_emojis"; import { onMount, onDestroy, tick } from "svelte"; - import { wallets, has_wallets, display_error, register_bootstrap, NG_BOOTSTRAP_IFRAME_SRC, test_bootstrap } from "../store"; + import { + wallets, + has_wallets, + display_error, + register_bootstrap, + } from "../store"; import Spinner from "../lib/components/Spinner.svelte"; 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 mobile = tauri_platform == "android" || tauri_platform == "ios"; let is_touch_device = @@ -152,29 +162,28 @@ function validate_pin() { // check for same digit doesnt appear 3 times - if ((pin[0] == pin[1] && pin[0] == pin[2]) - || (pin[0] == pin[1] && pin[0] == pin[3]) - || (pin[0] == pin[2] && pin[0] == pin[3]) - || (pin[1] == pin[2] && pin[1] == pin[3])) - { - return false; + if ( + (pin[0] == pin[1] && pin[0] == pin[2]) || + (pin[0] == pin[1] && pin[0] == pin[3]) || + (pin[0] == pin[2] && pin[0] == pin[3]) || + (pin[1] == pin[2] && pin[1] == pin[3]) + ) { + return false; } // check for ascending series - if (pin[1] == pin[0] + 1 - && pin[2] == pin[1] + 1 - && pin[3] == pin[2] + 1) - { - return false; + if (pin[1] == pin[0] + 1 && pin[2] == pin[1] + 1 && pin[3] == pin[2] + 1) { + return false; } // check for descending series - if (pin[3] >= 3 - && pin[2] == pin[3] - 1 - && pin[1] == pin[2] - 1 - && pin[0] == pin[1] - 1) - { - return false; + if ( + pin[3] >= 3 && + pin[2] == pin[3] - 1 && + pin[1] == pin[2] - 1 && + pin[0] == pin[1] - 1 + ) { + return false; } return true; } @@ -201,28 +210,17 @@ ? "api/v1/" : "http://localhost:3030/api/v1/"; - async function test_local_storage() { - if (!tauri_platform) { - if ((await ng.get_bowser())=="Safari") return; - await tick(); - let iframe: HTMLIFrameElement = window.document.getElementById('nextgraph-bootstrap-iframe'); - return new Promise(async (resolve) => { - iframe.addEventListener("load", async function() { - if (!await test_bootstrap()){ - registration_error = "NoLocalStorage"; - } - resolve(null); - }); - iframe.src=NG_BOOTSTRAP_IFRAME_SRC as string; - }); - } - } + const bootstrap_redirect = import.meta.env.DEV + ? "http://localhost:14403/#/?b=" + : import.meta.env.NG_DEV + ? "http://localhost:1421/bootstrap.html#/?b=" + : "https://nextgraph.net/bootstrap/#/?b="; + // to test ngnet + //const bootstrap_redirect = "http://127.0.0.1:3033/bootstrap/#/?b="; async function bootstrap() { - //console.log(await ng.client_info()); if (!tauri_platform || tauri_platform == "android") { - if (!tauri_platform) { try { sessionStorage.getItem("test"); @@ -240,7 +238,7 @@ } } - if (param.get("skipintro") || param.get("rs")) { + if (param.get("skipintro") || param.get("rs") || param.get("ab")) { // if (!tauri_platform) { // setTimeout(async ()=>{ // if (!await test_bootstrap()){ @@ -248,13 +246,39 @@ // } // },1); // } - await test_local_storage(); intro = false; } if (param.get("re")) { registration_error = param.get("re"); - } - if (param.get("rs")) { + } else if ( + (param.get("rs") || param.get("i")) && + !tauri_platform && + !param.get("ab") + ) { + registration_success = param.get("rs"); + + // doing the bootstrap recording at nextgraph.net + let i = param.get("i"); + invitation = await ng.decode_invitation(i); + let bootstrap_iframe_msgs = await ng.bootstrap_to_iframe_msgs( + invitation.V0.bootstrap + ); + let local_invitation = await ng.get_local_bootstrap(location.href); + if (local_invitation) { + bootstrap_iframe_msgs.push( + ...(await ng.bootstrap_to_iframe_msgs( + local_invitation.V0.bootstrap + )) + ); + } + let encoded = base64UrlEncode(JSON.stringify(bootstrap_iframe_msgs)); + window.location.href = + bootstrap_redirect + + encoded + + "&m=add&ab=" + + encodeURIComponent(window.location.href); + return; + } else if (param.get("rs")) { registration_success = param.get("rs"); invitation = await ng.decode_invitation(param.get("i")); window.location.replace(window.location.href.split("?")[0]); @@ -294,8 +318,6 @@ } async function create_wallet() { - - await test_local_storage(); intro = false; // if (invitation && invitation.V0.url) { // // we redirect to the TOS url of the invitation. @@ -323,12 +345,16 @@ async function do_wallet() { creating = true; - let bootstrap_iframe_msgs = await ng.bootstrap_to_iframe_msgs(invitation.V0.bootstrap); + // let bootstrap_iframe_msgs = await ng.bootstrap_to_iframe_msgs( + // invitation.V0.bootstrap + // ); let local_invitation = await ng.get_local_bootstrap(location.href); let additional_bootstrap; if (local_invitation) { additional_bootstrap = local_invitation.V0.bootstrap; - bootstrap_iframe_msgs.push(...await ng.bootstrap_to_iframe_msgs(additional_bootstrap)); + // bootstrap_iframe_msgs.push( + // ...(await ng.bootstrap_to_iframe_msgs(additional_bootstrap)) + // ); } let core_registration; if (invitation.V0.code) { @@ -347,18 +373,20 @@ core_registration, additional_bootstrap, device_name, - pdf: options.pdf + pdf: options.pdf, }; //console.log("do wallet with params", params); try { ready = await ng.wallet_create(params); - if (!tauri_platform && (await ng.get_bowser())!=="Safari") { - let res = await register_bootstrap(bootstrap_iframe_msgs); - if (res !== true) { - 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; - return; - } - } + // if (!tauri_platform) { + // let res = await register_bootstrap(bootstrap_iframe_msgs); + // if (res !== true) { + // 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; + // return; + // } + // } wallets.set(await ng.get_wallets()); if (!options.trusted && !tauri_platform) { let lws = $wallets[ready.wallet_name]; @@ -627,12 +655,6 @@ -{#if NG_BOOTSTRAP_IFRAME_SRC} - -{/if}
{#if wait} @@ -760,12 +782,24 @@ {@html $t("pages.wallet_create.wallet_about.2")}
  • - - {@html $t("pages.wallet_create.wallet_about.password")} + + {@html $t( + "pages.wallet_create.wallet_about.password" + )}
  • - - {@html $t("pages.wallet_create.wallet_about.mnemonic")} + + {@html $t( + "pages.wallet_create.wallet_about.mnemonic" + )}
  • @@ -784,7 +818,9 @@ d="M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959v0a.64.64 0 01-.657.643 48.39 48.39 0 01-4.163-.3c.186 1.613.293 3.25.315 4.907a.656.656 0 01-.658.663v0c-.355 0-.676-.186-.959-.401a1.647 1.647 0 00-1.003-.349c-1.036 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401v0c.31 0 .555.26.532.57a48.039 48.039 0 01-.642 5.056c1.518.19 3.058.309 4.616.354a.64.64 0 00.657-.643v0c0-.355-.186-.676-.401-.959a1.647 1.647 0 01-.349-1.003c0-1.035 1.008-1.875 2.25-1.875 1.243 0 2.25.84 2.25 1.875 0 .369-.128.713-.349 1.003-.215.283-.4.604-.4.959v0c0 .333.277.599.61.58a48.1 48.1 0 005.427-.63 48.05 48.05 0 00.582-4.717.532.532 0 00-.533-.57v0c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.035 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.37 0 .713.128 1.003.349.283.215.604.401.96.401v0a.656.656 0 00.658-.663 48.422 48.422 0 00-.37-5.36c-1.886.342-3.81.574-5.766.689a.578.578 0 01-.61-.58v0z" /> - {@html $t("pages.wallet_create.wallet_about.pazzle")} + {@html $t("pages.wallet_create.wallet_about.pazzle")}
  • @@ -883,7 +919,9 @@ {@html $t("pages.wallet_create.wallet_about.8")}
  • - + {@html $t("pages.wallet_create.wallet_about.9")}
  • @@ -925,9 +963,7 @@

    {$t("pages.wallet_create.broker_about.title")} {@html $t( - "pages.wallet_create.please_read" - )} {@html $t("pages.wallet_create.please_read")}

      {$t("pages.wallet_create.register_with_broker", { - values: { broker: pre_invitation.V0.name || $t("pages.wallet_create.this_broker") }, + values: { + broker: + pre_invitation.V0.name || + $t("pages.wallet_create.this_broker"), + }, })}
    @@ -1200,100 +1240,117 @@
    --> {#if import.meta.env.NG_APP_WEB} - -
    - - - - {@html $t("pages.wallet_create.broker_about.8")} - -
    - + + + {$t("pages.wallet_create.install_app")} + + +
    {/if}