···11+- in src-tauri/src/lib.rs, we directly create the webpage with home-page as it's starting point so that "logging in" (seeing if the user id is set) is checked before the webview window is even created. This is fine since we are only checking a single value
-14
app/index.html
···11-<script type="module">
22- import { Store } from "/src/utils/store.ts";
33-44- // For testing (to easily go to home or signup page). You only need to uncomment the right line, run it once, and comment it out again right after
55- await Store.reset();
66- // await Store.set("user_id", "adummyuserid");
77-88- // await alert(appLocalDataDirPath); // ~/.local/share/dev.azom.privacypin
99- if (await Store.isLoggedIn()) {
1010- window.location.href = "/src/home-page/home.html";
1111- } else {
1212- window.location.href = "/src/signup-page/signup.html";
1313- }
1414-</script>
+26-1
app/src-tauri/src/lib.rs
···11+use std::path::PathBuf;
22+use tauri::{WebviewUrl, WebviewWindowBuilder};
33+use tauri_plugin_store::StoreBuilder;
44+15// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
26#[tauri::command]
37fn greet(name: &str) -> String {
···711#[cfg_attr(mobile, tauri::mobile_entry_point)]
812pub fn run() {
913 tauri::Builder::default()
1010- .plugin(tauri_plugin_opener::init())
1414+ .setup(|app| {
1515+ let app_handle = app.handle();
1616+ let store_path = PathBuf::from("settings.json");
1717+ let store = StoreBuilder::new(app_handle, store_path).build()?;
1818+1919+ let user_id = store.get("user_id");
2020+2121+ let page = if user_id.is_some() {
2222+ "/src/home-page/home.html"
2323+ } else {
2424+ "/src/signup-page/signup.html"
2525+ };
2626+2727+ // create and open window directly at the correct page
2828+ WebviewWindowBuilder::new(app_handle, "main", WebviewUrl::App(page.into()))
2929+ .title("privacypin")
3030+ .inner_size(412.0, 715.0)
3131+ .resizable(false)
3232+ .build()?;
3333+3434+ Ok(())
3535+ })
1136 .plugin(tauri_plugin_store::Builder::default().build())
1237 .invoke_handler(tauri::generate_handler![greet])
1338 .run(tauri::generate_context!())
···11+// we need 2 paths for the users to take or we could add a bit of complexity code wise and make both the same...
22+//
33+// later it will be qr codes, but for now:
44+// for a given user:
55+// - show their own user id
66+// - show a cryptographically random number
77+// - have a text input to enter the friend's user id
88+// - have a text input to enter the friend's cryprgraphic number
99+//
1010+// we thus need the random numbers to have a symmetric operation that gives something we can use to generate a base friend key
1111+// xor works probably very well here actually
1212+//
1313+// to start, we'll have a static AES-GCM friend key that never rotates
1414+1515+// we first need to merge ui with auth tho