fix android tauri window doesnt have js injected

pull/19/head
Niko PLP 1 year ago
parent 949d3ba519
commit 2e0c6dfdb0
  1. 7
      ng-app/package.json
  2. 2
      ng-app/src-tauri/Cargo.toml
  3. 4
      ng-app/src-tauri/src/lib.rs
  4. 2
      ng-app/src/App.svelte
  5. 4
      ng-app/src/api.ts
  6. 4
      ng-app/src/lib/Login.svelte
  7. 41
      ng-app/src/routes/WalletCreate.svelte
  8. 2
      ngaccount/src/main.rs
  9. 2
      ngaccount/web/package.json
  10. 9
      ngaccount/web/pnpm-lock.yaml
  11. 2
      ngaccount/web/src/routes/Create.svelte
  12. 2
      ngaccount/web/src/routes/Delete.svelte
  13. 10
      ngaccount/web/src/routes/Home.svelte
  14. 2
      ngone/src/store/dynpeer.rs
  15. 2
      ngone/src/store/wallet_record.rs
  16. 2
      p2p-broker/src/broker_store/wallet.rs
  17. 9
      pnpm-lock.yaml

@ -6,17 +6,18 @@
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"webdev": "cross-env NG_APP_WEB=1 TAURI_DEBUG=1 vite", "webdev": "cross-env NG_APP_WEB=1 TAURI_DEBUG=1 vite",
"webbuild": "cross-env NG_APP_WEB=1 vite build", "webbuild": "cross-env NG_APP_WEB=1 vite build && rm ./dist/assets/*.svg",
"filebuild": "cross-env NG_APP_WEB=1 NG_APP_FILE=1 vite build && node prepare-app-file.cjs", "filebuild": "cross-env NG_APP_WEB=1 NG_APP_FILE=1 vite build && node prepare-app-file.cjs",
"filebuilddebug": "cross-env NG_APP_WEB=1 NG_APP_FILE=1 TAURI_DEBUG=1 vite build -m debug", "filebuilddebug": "cross-env NG_APP_WEB=1 NG_APP_FILE=1 TAURI_DEBUG=1 vite build -m debug",
"build": "vite build", "build": "vite build && rm ./dist/assets/*.svg",
"buildfile": "cross-env NG_APP_FILE=1 vite build && rm -r ./dist/assets",
"preview": "vite preview", "preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json", "check": "svelte-check --tsconfig ./tsconfig.json",
"tauri": "tauri" "tauri": "tauri"
}, },
"dependencies": { "dependencies": {
"@popperjs/core": "^2.11.8", "@popperjs/core": "^2.11.8",
"@tauri-apps/api": "2.0.0-alpha.4", "@tauri-apps/api": "2.0.0-alpha.5",
"@tauri-apps/plugin-window": "2.0.0-alpha.0", "@tauri-apps/plugin-window": "2.0.0-alpha.0",
"async-proxy": "^0.4.1", "async-proxy": "^0.4.1",
"classnames": "^2.3.2", "classnames": "^2.3.2",

@ -17,7 +17,7 @@ crate-type = ["staticlib", "cdylib", "rlib"]
tauri-build = { version = "2.0.0-alpha.5", features = [] } tauri-build = { version = "2.0.0-alpha.5", features = [] }
[dependencies] [dependencies]
tauri = { version = "2.0.0-alpha.9", features = [] } tauri = { version = "2.0.0-alpha.10", features = [] }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
p2p-repo = { path = "../../p2p-repo" } p2p-repo = { path = "../../p2p-repo" }

@ -208,7 +208,8 @@ async fn open_window(
) -> Result<(), ()> { ) -> Result<(), ()> {
log_debug!("open window url {:?}", url); log_debug!("open window url {:?}", url);
let already_exists = app.get_window(&label); let already_exists = app.get_window(&label);
if (already_exists.is_some()) { #[cfg(desktop)]
if already_exists.is_some() {
let _ = already_exists.unwrap().close(); let _ = already_exists.unwrap().close();
std::thread::sleep(std::time::Duration::from_secs(1)); std::thread::sleep(std::time::Duration::from_secs(1));
} }
@ -332,6 +333,7 @@ impl AppBuilder {
app.ipc_scope().configure_remote_access( app.ipc_scope().configure_remote_access(
RemoteDomainAccessScope::new(domain) RemoteDomainAccessScope::new(domain)
.add_window("registration") .add_window("registration")
.add_window("main")
.add_plugins(["window", "event"]), .add_plugins(["window", "event"]),
); );
} }

@ -11,7 +11,7 @@
<script lang="ts"> <script lang="ts">
// this line is needed to have the SDK working when compiling for a single file bundle (pnpm filebuild) // this line is needed to have the SDK working when compiling for a single file bundle (pnpm filebuild)
import * as api from "ng-sdk-js"; //import * as api from "ng-sdk-js";
import { push, default as Router } from "svelte-spa-router"; import { push, default as Router } from "svelte-spa-router";
import { onMount, tick, onDestroy } from "svelte"; import { onMount, tick, onDestroy } from "svelte";
import { import {

@ -112,10 +112,10 @@ const handler = {
return res; return res;
} else if (path[0] === "get_wallets_from_localstorage") { } else if (path[0] === "get_wallets_from_localstorage") {
let res = await tauri.invoke(path[0],{}); let res = await tauri.invoke(path[0],{});
for (let e of Object.entries(res)) { if (res) for (let e of Object.entries(res)) {
e[1].wallet.V0.content.security_img = Uint8Array.from(e[1].wallet.V0.content.security_img); e[1].wallet.V0.content.security_img = Uint8Array.from(e[1].wallet.V0.content.security_img);
} }
return res; return res || {};
} else if (path[0] === "wallet_create_wallet") { } else if (path[0] === "wallet_create_wallet") {
let params = args[0]; let params = args[0];

@ -191,7 +191,7 @@
</svg> </svg>
</div> </div>
{:else if step == "pazzle"} {:else if step == "pazzle"}
<div class="h-screen aspect-[3/5] pazzleline max-w-[600px] min-w-[500px]"> <div class="h-screen aspect-[3/5] pazzleline max-w-[600px] min-w-[350px]">
{#each [0, 1, 2, 3, 4] as row} {#each [0, 1, 2, 3, 4] as row}
<div class="columns-3 gap-0"> <div class="columns-3 gap-0">
{#each emojis2[display]?.slice(0 + row * 3, 3 + row * 3) || [] as emoji, i} {#each emojis2[display]?.slice(0 + row * 3, 3 + row * 3) || [] as emoji, i}
@ -210,7 +210,7 @@
</div> </div>
{:else if step == "order"} {:else if step == "order"}
<!-- console.log(cat_idx, emoji_cat[cat_idx], idx, cat[idx].code); --> <!-- console.log(cat_idx, emoji_cat[cat_idx], idx, cat[idx].code); -->
<div class="h-screen aspect-[3/3] pazzleline max-w-[600px] min-w-[500px]"> <div class="h-screen aspect-[3/3] pazzleline max-w-[600px] min-w-[350px]">
{#each [0, 1, 2] as row} {#each [0, 1, 2] as row}
<div class="columns-3 gap-0"> <div class="columns-3 gap-0">
{#each selection.slice(0 + row * 3, 3 + row * 3) || [] as emoji, i} {#each selection.slice(0 + row * 3, 3 + row * 3) || [] as emoji, i}

@ -125,10 +125,14 @@
} }
} }
function confirm_pin(val) { async function confirm_pin(val) {
if (pin_confirm.length < 4) { if (pin_confirm.length < 4) {
pin_confirm.push(val); pin_confirm.push(val);
pin_confirm = pin_confirm; pin_confirm = pin_confirm;
if (pin_confirm.length == 4) {
await tick();
scrollToTop();
}
} }
} }
@ -138,7 +142,7 @@
async function bootstrap() { async function bootstrap() {
//console.log(await ng.client_info()); //console.log(await ng.client_info());
if (!tauri_platform) { if (!tauri_platform || tauri_platform == "android") {
if (param.get("skipintro") || param.get("rs")) { if (param.get("skipintro") || param.get("rs")) {
intro = false; intro = false;
} }
@ -148,14 +152,14 @@
if (param.get("rs")) { if (param.get("rs")) {
registration_success = param.get("rs"); registration_success = param.get("rs");
invitation = await ng.decode_invitation(param.get("i")); invitation = await ng.decode_invitation(param.get("i"));
} else { 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_with_public(
location.href, location.href,
param.get("i") param.get("i")
); );
}
console.log(invitation); console.log(invitation);
if (!invitation && param.get("i")) { if (!invitation) {
let redirect = await ng.get_ngone_url_of_invitation(param.get("i")); let redirect = await ng.get_ngone_url_of_invitation(param.get("i"));
if (redirect) { if (redirect) {
console.error("got an invitation for another broker. redirecting"); console.error("got an invitation for another broker. redirecting");
@ -166,6 +170,7 @@
} }
} }
} }
}
scrollToTop(); scrollToTop();
} }
@ -277,14 +282,23 @@
}); });
const select_bsp = async (bsp_url, bsp_name) => { const select_bsp = async (bsp_url, bsp_name) => {
if (!tauri_platform) { if (!tauri_platform || tauri_platform == "android") {
let local_url = await ng.get_local_url(location.href); let redirect_url;
if (tauri_platform) {
redirect_url = window.location.href;
} else {
let local_url;
if (!import.meta.env.PROD) { if (!import.meta.env.PROD) {
local_url = "http://localhost:1421"; local_url = "http://localhost:1421";
} else {
local_url = await ng.get_local_url(location.href);
}
redirect_url = local_url + APP_WALLET_CREATE_SUFFIX;
} }
let create = { let create = {
V0: { V0: {
redirect_url: local_url + APP_WALLET_CREATE_SUFFIX, redirect_url,
}, },
}; };
let ca = await ng.encode_create_account(create); let ca = await ng.encode_create_account(create);
@ -338,14 +352,14 @@
const enterINVITE = (event) => {}; const enterINVITE = (event) => {};
const enterQRcode = (event) => {}; const enterQRcode = (event) => {};
const displayNGbox = async (event) => { const displayNGbox = async (event) => {
if (!tauri_platform) { if (!tauri_platform || tauri_platform == "android") {
window.open(LINK_NG_BOX, "_blank").focus(); window.open(LINK_NG_BOX, "_blank").focus();
} else { } else {
await ng.open_window(LINK_NG_BOX, "viewer", "Own your NG-Box"); await ng.open_window(LINK_NG_BOX, "viewer", "Own your NG-Box");
} }
}; };
const displaySelfHost = async (event) => { const displaySelfHost = async (event) => {
if (!tauri_platform) { if (!tauri_platform || tauri_platform == "android") {
window.open(LINK_SELF_HOST, "_blank").focus(); window.open(LINK_SELF_HOST, "_blank").focus();
} else { } else {
await ng.open_window(LINK_SELF_HOST, "viewer", "Self-host a broker"); await ng.open_window(LINK_SELF_HOST, "viewer", "Self-host a broker");
@ -1030,7 +1044,8 @@
{:else if pin_confirm.length < 4} {:else if pin_confirm.length < 4}
<div class=" max-w-6xl lg:px-8 mx-auto px-4"> <div class=" max-w-6xl lg:px-8 mx-auto px-4">
<p class="max-w-xl md:mx-auto lg:max-w-2xl"> <p class="max-w-xl md:mx-auto lg:max-w-2xl">
<span class="text-xl">Please confirm your PIN code.</span> <span class="animate-bounce text-xl">Please confirm your PIN code.</span
>
Enter the same PIN again Enter the same PIN again
</p> </p>
<Alert color="blue" class="mt-5"> <Alert color="blue" class="mt-5">
@ -1045,7 +1060,7 @@
<button <button
tabindex="0" tabindex="0"
class="m-1 select-none align-bottom text-7xl w-[100px] h-[100px] p-0" class="m-1 select-none align-bottom text-7xl w-[100px] h-[100px] p-0"
on:click={async () => confirm_pin(num + row * 3)} on:click={async () => await confirm_pin(num + row * 3)}
> >
<span>{num + row * 3}</span> <span>{num + row * 3}</span>
</button> </button>
@ -1055,7 +1070,7 @@
<button <button
tabindex="0" tabindex="0"
class="m-1 select-none mx-auto align-bottom text-7xl w-[100px] h-[100px] p-0" class="m-1 select-none mx-auto align-bottom text-7xl w-[100px] h-[100px] p-0"
on:click={async () => confirm_pin(0)} on:click={async () => await confirm_pin(0)}
> >
<span>0</span> <span>0</span>
</button> </button>

@ -272,7 +272,7 @@ async fn main() -> anyhow::Result<()> {
} }
log::info!("Starting server on http://localhost:3031"); log::info!("Starting server on http://localhost:3031");
warp::serve(api_v1.or(static_files).with(cors)) warp::serve(api_v1.or(static_files).with(cors))
.run(([127, 0, 0, 1], 3031)) .run(([192, 168, 192, 2], 3031))
.await; .await;
Ok(()) Ok(())

@ -10,7 +10,7 @@
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "2.0.0-alpha.4", "@tauri-apps/api": "2.0.0-alpha.5",
"@tauri-apps/plugin-window": "2.0.0-alpha.0", "@tauri-apps/plugin-window": "2.0.0-alpha.0",
"flowbite": "^1.6.5", "flowbite": "^1.6.5",
"flowbite-svelte": "^0.37.1", "flowbite-svelte": "^0.37.1",

@ -2,7 +2,7 @@ lockfileVersion: 5.4
specifiers: specifiers:
'@sveltejs/vite-plugin-svelte': ^2.0.4 '@sveltejs/vite-plugin-svelte': ^2.0.4
'@tauri-apps/api': 2.0.0-alpha.4 '@tauri-apps/api': 2.0.0-alpha.5
'@tauri-apps/plugin-window': 2.0.0-alpha.0 '@tauri-apps/plugin-window': 2.0.0-alpha.0
autoprefixer: ^10.4.14 autoprefixer: ^10.4.14
cross-env: ^7.0.3 cross-env: ^7.0.3
@ -18,7 +18,7 @@ specifiers:
vite-plugin-svelte-svg: ^2.2.1 vite-plugin-svelte-svg: ^2.2.1
dependencies: dependencies:
'@tauri-apps/api': 2.0.0-alpha.4 '@tauri-apps/api': 2.0.0-alpha.5
'@tauri-apps/plugin-window': 2.0.0-alpha.0 '@tauri-apps/plugin-window': 2.0.0-alpha.0
flowbite: 1.6.6 flowbite: 1.6.6
flowbite-svelte: 0.37.5_svelte@3.59.1 flowbite-svelte: 0.37.5_svelte@3.59.1
@ -341,6 +341,11 @@ packages:
engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'} engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'}
dev: false dev: false
/@tauri-apps/api/2.0.0-alpha.5:
resolution: {integrity: sha512-OqysC4c819itGxic50RoDMrmd+ofX+MMNkXKeRS0BV2rkKqrnuV17o3TrQXFI1xs/kXRmmPC+3Y42P9Y5uNvRg==}
engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'}
dev: false
/@tauri-apps/plugin-window/2.0.0-alpha.0: /@tauri-apps/plugin-window/2.0.0-alpha.0:
resolution: {integrity: sha512-ZXFXOu9m8QiDB8d8LFFgwcfxIAbr0bhzj06YvmZDB3isuVtlFP9EyU4D+zmumWEWvNN2XP7xgpn68ivOVhmNNQ==} resolution: {integrity: sha512-ZXFXOu9m8QiDB8d8LFFgwcfxIAbr0bhzj06YvmZDB3isuVtlFP9EyU4D+zmumWEWvNN2XP7xgpn68ivOVhmNNQ==}
dependencies: dependencies:

@ -27,7 +27,7 @@
let top; let top;
const api_url = import.meta.env.PROD const api_url = import.meta.env.PROD
? "api/v1/" ? "api/v1/"
: "http://localhost:3031/api/v1/"; : "http://192.168.192.2:3031/api/v1/";
async function register() { async function register() {
const opts = { const opts = {

@ -27,7 +27,7 @@
let top; let top;
const api_url = import.meta.env.PROD const api_url = import.meta.env.PROD
? "api/v1/" ? "api/v1/"
: "http://localhost:3031/api/v1/"; : "http://192.168.192.2:3031/api/v1/";
async function bootstrap() {} async function bootstrap() {}
let error; let error;

@ -15,13 +15,13 @@
import { onMount } from "svelte"; import { onMount } from "svelte";
const api_url = import.meta.env.PROD // const api_url = import.meta.env.PROD
? "api/v1/" // ? "api/v1/"
: "http://localhost:3031/api/v1/"; // : "http://localhost:3031/api/v1/";
async function bootstrap() {} // async function bootstrap() {}
onMount(() => bootstrap()); // onMount(() => bootstrap());
</script> </script>
<div /> <div />

@ -55,7 +55,7 @@ impl<'a> DynPeer<'a> {
if acc.exists() { if acc.exists() {
return Err(StorageError::BackendError); return Err(StorageError::BackendError);
} }
store.write_transaction(&|tx| { store.write_transaction(&mut |tx| {
tx.put( tx.put(
Self::PREFIX, Self::PREFIX,
&to_vec(&id)?, &to_vec(&id)?,

@ -55,7 +55,7 @@ impl<'a> WalletRecord<'a> {
if wallet.exists() { if wallet.exists() {
return Err(StorageError::BackendError); return Err(StorageError::BackendError);
} }
store.write_transaction(&|tx| { store.write_transaction(&mut |tx| {
tx.put( tx.put(
Self::PREFIX, Self::PREFIX,
&to_vec(&id)?, &to_vec(&id)?,

@ -76,7 +76,7 @@ impl<'a> Wallet<'a> {
} }
pub fn get_or_create_overlay_key(&self, overlay: &OverlayId) -> Result<SymKey, StorageError> { pub fn get_or_create_overlay_key(&self, overlay: &OverlayId) -> Result<SymKey, StorageError> {
self.get_or_create_single_key(Self::PREFIX_USER, &to_vec(overlay)?) self.get_or_create_single_key(Self::PREFIX_OVERLAY, &to_vec(overlay)?)
} }
pub fn create_single_key( pub fn create_single_key(

@ -9,7 +9,7 @@ importers:
specifiers: specifiers:
'@popperjs/core': ^2.11.8 '@popperjs/core': ^2.11.8
'@sveltejs/vite-plugin-svelte': ^2.0.0 '@sveltejs/vite-plugin-svelte': ^2.0.0
'@tauri-apps/api': 2.0.0-alpha.4 '@tauri-apps/api': 2.0.0-alpha.5
'@tauri-apps/cli': 2.0.0-alpha.9 '@tauri-apps/cli': 2.0.0-alpha.9
'@tauri-apps/plugin-window': 2.0.0-alpha.0 '@tauri-apps/plugin-window': 2.0.0-alpha.0
'@tsconfig/svelte': ^3.0.0 '@tsconfig/svelte': ^3.0.0
@ -39,7 +39,7 @@ importers:
vite-plugin-wasm: ^3.2.2 vite-plugin-wasm: ^3.2.2
dependencies: dependencies:
'@popperjs/core': 2.11.8 '@popperjs/core': 2.11.8
'@tauri-apps/api': 2.0.0-alpha.4 '@tauri-apps/api': 2.0.0-alpha.5
'@tauri-apps/plugin-window': 2.0.0-alpha.0 '@tauri-apps/plugin-window': 2.0.0-alpha.0
async-proxy: 0.4.1 async-proxy: 0.4.1
classnames: 2.3.2 classnames: 2.3.2
@ -507,6 +507,11 @@ packages:
engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'} engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'}
dev: false dev: false
/@tauri-apps/api/2.0.0-alpha.5:
resolution: {integrity: sha512-OqysC4c819itGxic50RoDMrmd+ofX+MMNkXKeRS0BV2rkKqrnuV17o3TrQXFI1xs/kXRmmPC+3Y42P9Y5uNvRg==}
engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'}
dev: false
/@tauri-apps/cli-darwin-arm64/2.0.0-alpha.9: /@tauri-apps/cli-darwin-arm64/2.0.0-alpha.9:
resolution: {integrity: sha512-h7AQY4MbHyy7CLANfoegJyaypKQ3fYPlBA3mnhtF+zntrMxVTv+HO9sgn98jGnwlOak8y0NPPKJ6gZFu5GYiNg==} resolution: {integrity: sha512-h7AQY4MbHyy7CLANfoegJyaypKQ3fYPlBA3mnhtF+zntrMxVTv+HO9sgn98jGnwlOak8y0NPPKJ6gZFu5GYiNg==}
engines: {node: '>= 10'} engines: {node: '>= 10'}

Loading…
Cancel
Save