add whole app LOL

Co-authored-by: Alpisc <Alpisc@users.noreply.github.com>
This commit is contained in:
Mystikfluu 2023-01-14 21:20:37 +01:00
parent 981a2641c0
commit ddf53e5908
13 changed files with 695 additions and 146 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/src-tauri/target /src-tauri/target
*_backup *_backup
*ignore* *ignore*
msi/

@ -1 +1 @@
Subproject commit 380ae204378be877fffb7ee7f9167748defc2156 Subproject commit 31b8e5bf0ab8b561ffeafb07432a382000323f7a

223
src-tauri/Cargo.lock generated
View File

@ -161,6 +161,12 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "bumpalo"
version = "3.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.12.3" version = "1.12.3"
@ -818,7 +824,7 @@ dependencies = [
"libc", "libc",
"log", "log",
"rustversion", "rustversion",
"windows", "windows 0.39.0",
] ]
[[package]] [[package]]
@ -1194,20 +1200,19 @@ dependencies = [
[[package]] [[package]]
name = "ip_lib" name = "ip_lib"
version = "0.1.0" version = "1.0.0"
dependencies = [ dependencies = [
"aes-gcm", "aes-gcm",
"brotli", "brotli",
"hex", "hex",
"home", "home",
"rand 0.8.5", "rand 0.8.5",
"rpassword",
"sha2", "sha2",
] ]
[[package]] [[package]]
name = "ipass-gui" name = "ipass-gui"
version = "0.0.1" version = "0.1.0"
dependencies = [ dependencies = [
"ip_lib", "ip_lib",
"serde", "serde",
@ -1271,6 +1276,15 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
[[package]]
name = "js-sys"
version = "0.3.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47"
dependencies = [
"wasm-bindgen",
]
[[package]] [[package]]
name = "json-patch" name = "json-patch"
version = "0.2.7" version = "0.2.7"
@ -1538,6 +1552,17 @@ dependencies = [
"objc_exception", "objc_exception",
] ]
[[package]]
name = "objc-foundation"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
dependencies = [
"block",
"objc",
"objc_id",
]
[[package]] [[package]]
name = "objc_exception" name = "objc_exception"
version = "0.1.2" version = "0.1.2"
@ -1568,16 +1593,6 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "open"
version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2078c0039e6a54a0c42c28faa984e115fb4c2d5bf2208f77d1961002df8576f8"
dependencies = [
"pathdiff",
"windows-sys",
]
[[package]] [[package]]
name = "overload" name = "overload"
version = "0.1.1" version = "0.1.1"
@ -1638,12 +1653,6 @@ version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba"
[[package]]
name = "pathdiff"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.2.0" version = "2.2.0"
@ -2031,24 +2040,27 @@ dependencies = [
] ]
[[package]] [[package]]
name = "rpassword" name = "rfd"
version = "7.2.0" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322" checksum = "0149778bd99b6959285b0933288206090c50e2327f47a9c463bfdbf45c8823ea"
dependencies = [ dependencies = [
"libc", "block",
"rtoolbox", "dispatch",
"winapi", "glib-sys",
] "gobject-sys",
"gtk-sys",
[[package]] "js-sys",
name = "rtoolbox" "lazy_static",
version = "0.0.1" "log",
source = "registry+https://github.com/rust-lang/crates.io-index" "objc",
checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a" "objc-foundation",
dependencies = [ "objc_id",
"libc", "raw-window-handle",
"winapi", "wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"windows 0.37.0",
] ]
[[package]] [[package]]
@ -2451,7 +2463,7 @@ dependencies = [
"serde", "serde",
"unicode-segmentation", "unicode-segmentation",
"uuid 1.2.2", "uuid 1.2.2",
"windows", "windows 0.39.0",
"windows-implement", "windows-implement",
"x11-dl", "x11-dl",
] ]
@ -2488,11 +2500,10 @@ dependencies = [
"ignore", "ignore",
"objc", "objc",
"once_cell", "once_cell",
"open",
"percent-encoding", "percent-encoding",
"rand 0.8.5", "rand 0.8.5",
"raw-window-handle", "raw-window-handle",
"regex", "rfd",
"semver 1.0.16", "semver 1.0.16",
"serde", "serde",
"serde_json", "serde_json",
@ -2511,7 +2522,7 @@ dependencies = [
"uuid 1.2.2", "uuid 1.2.2",
"webkit2gtk", "webkit2gtk",
"webview2-com", "webview2-com",
"windows", "windows 0.39.0",
] ]
[[package]] [[package]]
@ -2544,7 +2555,6 @@ dependencies = [
"png", "png",
"proc-macro2", "proc-macro2",
"quote", "quote",
"regex",
"semver 1.0.16", "semver 1.0.16",
"serde", "serde",
"serde_json", "serde_json",
@ -2587,7 +2597,7 @@ dependencies = [
"thiserror", "thiserror",
"uuid 1.2.2", "uuid 1.2.2",
"webview2-com", "webview2-com",
"windows", "windows 0.39.0",
] ]
[[package]] [[package]]
@ -2606,7 +2616,7 @@ dependencies = [
"uuid 1.2.2", "uuid 1.2.2",
"webkit2gtk", "webkit2gtk",
"webview2-com", "webview2-com",
"windows", "windows 0.39.0",
"wry", "wry",
] ]
@ -2635,7 +2645,7 @@ dependencies = [
"thiserror", "thiserror",
"url", "url",
"walkdir", "walkdir",
"windows", "windows 0.39.0",
] ]
[[package]] [[package]]
@ -2963,6 +2973,82 @@ version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d"
dependencies = [
"cfg-if",
"js-sys",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
[[package]]
name = "web-sys"
version = "0.3.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]] [[package]]
name = "webkit2gtk" name = "webkit2gtk"
version = "0.18.2" version = "0.18.2"
@ -3018,7 +3104,7 @@ checksum = "b4a769c9f1a64a8734bde70caafac2b96cada12cd4aefa49196b3a386b8b4178"
dependencies = [ dependencies = [
"webview2-com-macros", "webview2-com-macros",
"webview2-com-sys", "webview2-com-sys",
"windows", "windows 0.39.0",
"windows-implement", "windows-implement",
] ]
@ -3043,7 +3129,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"thiserror", "thiserror",
"windows", "windows 0.39.0",
"windows-bindgen", "windows-bindgen",
"windows-metadata", "windows-metadata",
] ]
@ -3079,6 +3165,19 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57b543186b344cc61c85b5aab0d2e3adf4e0f99bc076eff9aa5927bcc0b8a647"
dependencies = [
"windows_aarch64_msvc 0.37.0",
"windows_i686_gnu 0.37.0",
"windows_i686_msvc 0.37.0",
"windows_x86_64_gnu 0.37.0",
"windows_x86_64_msvc 0.37.0",
]
[[package]] [[package]]
name = "windows" name = "windows"
version = "0.39.0" version = "0.39.0"
@ -3146,6 +3245,12 @@ version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e"
[[package]]
name = "windows_aarch64_msvc"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.39.0" version = "0.39.0"
@ -3158,6 +3263,12 @@ version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4"
[[package]]
name = "windows_i686_gnu"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.39.0" version = "0.39.0"
@ -3170,6 +3281,12 @@ version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7"
[[package]]
name = "windows_i686_msvc"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.39.0" version = "0.39.0"
@ -3182,6 +3299,12 @@ version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246"
[[package]]
name = "windows_x86_64_gnu"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.39.0" version = "0.39.0"
@ -3200,6 +3323,12 @@ version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028"
[[package]]
name = "windows_x86_64_msvc"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.39.0" version = "0.39.0"
@ -3255,7 +3384,7 @@ dependencies = [
"webkit2gtk", "webkit2gtk",
"webkit2gtk-sys", "webkit2gtk-sys",
"webview2-com", "webview2-com",
"windows", "windows 0.39.0",
"windows-implement", "windows-implement",
] ]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ipass-gui" name = "ipass-gui"
version = "0.0.1" version = "0.1.0"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -11,7 +11,7 @@ tauri-build = { version = "1.2", features = [] }
[dependencies] [dependencies]
serde_json = "1.0" serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2", features = ["shell-open"] } tauri = { version = "1.2", features = ["dialog-confirm"] }
ip_lib = { path = "../library/" } ip_lib = { path = "../library/" }
[features] [features]
@ -27,4 +27,4 @@ opt-level = 'z' # Optimize for size
lto = true # Enable link-time optimization lto = true # Enable link-time optimization
codegen-units = 1 # Reduce number of codegen units to increase optimizations codegen-units = 1 # Reduce number of codegen units to increase optimizations
panic = 'abort' # Abort on panic panic = 'abort' # Abort on panic
# strip = true # Strip symbols from binary; remove pdb strip = true # Strip symbols from binary; remove pdb

View File

@ -6,19 +6,60 @@
extern crate ip_lib; extern crate ip_lib;
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
#[tauri::command] #[tauri::command]
fn get_version() -> String { fn get_version() -> String {
return option_env!("CARGO_PKG_VERSION").unwrap_or("x.x.x").to_string(); return option_env!("CARGO_PKG_VERSION").unwrap_or("x.x.x").to_string();
} }
#[tauri::command]
fn create_entry(name: String, username: String, pw: &str, mpw: String) -> bool {
ip_lib::create_entry(&name, username+";"+pw, mpw)
}
#[tauri::command]
fn random_password() -> String {
ip_lib::random_password()
}
#[tauri::command]
fn get_entry(name: String, mpw: String) -> Result<(String,String),String> {
let binding = ip_lib::get_entry(&name, mpw);
if let Ok(data) = binding {
let mut split = data.split(";");
return Ok((split.next().unwrap().to_string(),split.next().unwrap().to_string()));
} else {
return Err(binding.expect_err("expected error"));
}
}
#[tauri::command]
fn get_entries() -> Vec<String> {
let mut vector: Vec<String> = Vec::default();
for entry in ip_lib::get_entries() {
let entry_filename = entry.unwrap().file_name();
let ent =entry_filename.to_str().unwrap();
vector.insert(0, ent[..ent.len()-6].to_string());
}
vector.sort();
return vector;
}
#[tauri::command]
fn remove_entry(name: &str) -> bool {
let filepath = &(ip_lib::get_ipass_folder()+name+".ipass");
if std::path::Path::new(filepath).exists() {
std::fs::remove_file(filepath).unwrap();
return true;
}
return false;
}
fn main() { fn main() {
tauri::Builder::default() tauri::Builder::default()
.invoke_handler(tauri::generate_handler![greet,get_version]) .invoke_handler(tauri::generate_handler![get_version,create_entry,random_password,get_entry,get_entries,remove_entry])
.run(tauri::generate_context!()) .run(tauri::generate_context!())
.expect("error while running tauri application"); .expect("error while running tauri application");
} }

View File

@ -8,14 +8,18 @@
}, },
"package": { "package": {
"productName": "ipass", "productName": "ipass",
"version": "0.0.1" "version": "0.1.0"
}, },
"tauri": { "tauri": {
"allowlist": { "allowlist": {
"all": false, "all": false,
"shell": { "dialog": {
"all": false, "all": false,
"open": true "open": false,
"save": false,
"ask": false,
"message": false,
"confirm": true
} }
}, },
"bundle": { "bundle": {
@ -58,9 +62,10 @@
{ {
"fullscreen": false, "fullscreen": false,
"height": 600, "height": 600,
"resizable": true, "resizable": false,
"title": "ipass-gui", "title": "IPass",
"width": 800 "width": 880,
"theme": "Dark"
} }
] ]
} }

BIN
src/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -6,32 +6,32 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title id="pageTitle">IPass - x.x.x</title> <title id="pageTitle">IPass - x.x.x</title>
<script type="module" src="/main.js"></script> <script type="module" src="/main.js"></script>
<script type="module" src="/pwprompt.js"></script>
</head> </head>
<body> <body>
<h1>IPass</h1> <h1>IPass</h1>
<div class="container"> <p id="lockLabel">Locked</p>
<table> <img alt="Lock" id="lockImg" src="/images/security_lock_locked.png" height=50 width=50></img>
<thead> <br>
<tr> <div id="table_div">
<td>Entry name</td> <div id="table_entries">
<td>Username</td> <div>Entry name</div>
<td>Password</td> <div class="entry_name" id="createEntry_name"><input type="text" placeholder="New Entry Name"></div>
</tr>
<tr>
<td class="entry_name">
ENTRY-NAME-HERE
</td>
<td class="hidden entry_user">
<input type="text" name="" id="" value="ENTRY-USERNAME-HERE">
</td>
<td class="hidden entry_pass">
<input type="text" name="" id="" value="ENTRY-PASSWORD-HERE">
</td>
</tr>
</thead>
</table>
</div> </div>
<div id="table_users">
<div>Username</div>
<div class="entry_user" id="createEntry_user"><input type="text" placeholder="New Username"></div>
</div>
<div id="table_pwds">
<div>Password</div>
<div class="entry_pass" id="createEntry_pass"><input type="password" placeholder="New Password"></div>
</div>
<div id="table_actions">
<div>Action</div>
<div class="button" id="createEntry_actions"><button>Create</button></div>
</div>
</div>
</body> </body>
</html> </html>

View File

@ -1,23 +1,283 @@
const { invoke } = window.__TAURI__.tauri; const { invoke } = window.__TAURI__.tauri;
let greetInputEl; let master_pw;
let greetMsgEl; let lock_status = true;
async function greet() { // async function greet() {
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command // // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
greetMsgEl.textContent = await invoke("greet", { name: greetInputEl.value }); // greetMsgEl.textContent = await invoke("greet", { name: greetInputEl.value });
} // }
async function updateTitle() {
document.getElementById("pageTitle").innerText = `IPass - ${await invoke("get_version")}`;
}
window.addEventListener("DOMContentLoaded", () => { window.addEventListener("DOMContentLoaded", () => {
updateTitle() document.getElementById("lockImg").addEventListener("click",toggleLock);
startup();
greetInputEl = document.querySelector("#greet-input");
greetMsgEl = document.querySelector("#greet-msg");
document
.querySelector("#greet-button")
.addEventListener("click", () => greet());
}); });
async function startup() {
document.querySelector("#createEntry_actions > button").addEventListener("click",createEntry);
let entries = await invoke("get_entries");
console.log(entries);
for(let i = 0; i < entries.length; i++) {
buildEntry(entries[i]);
}
for (let input of document.querySelectorAll('input[readonly]')) {
input.addEventListener('click', async function() {
if(!input.hasAttribute("readonly"))return
if(input.getAttribute("type")!="text" && lock_status)return
let to_copy = input.value
if(!lock_status) {
let isUsername = input.parentElement.classList.contains("entry_user")
let entry_name = input.parentElement.id.slice(0,input.parentElement.id.length-5)
console.log(entry_name,input.parentElement.id)
let info = await invoke("get_entry",{
name: entry_name,
mpw: await get_pw()
})
if(isUsername) {
to_copy = info[0]
} else {
if(input.parentElement.classList.contains("entry_name")) {
to_copy = entry_name
} else {
to_copy = info[1]
}
}
}
navigator.clipboard.writeText(to_copy).then(function() {
let originalColor = input.style.borderColor;
input.style.borderColor = "lightgreen";
setTimeout(function(){
input.style.borderColor = originalColor;
},250)
console.log('Text copied to clipboard');
}, function(err) {
let originalColor = input.style.borderColor;
input.style.borderColor = "red";
setTimeout(function(){
input.style.borderColor = originalColor;
},500)
console.error('Failed to copy text: ', err);
});
});
}
}
function buildEntry(entry) {
let nameDiv = document.createElement("div");
nameDiv.setAttribute("class", "entry_name");
nameDiv.setAttribute("id",`${entry.replaceAll(" ","-")}_name`)
let nameInput = document.createElement("input");
nameInput.setAttribute("type", "text");
nameInput.setAttribute("placeholder", "New Entry Name");
nameInput.setAttribute("value", entry);
nameInput.setAttribute("readonly", true);
nameInput.setAttribute("unselectable", "on")
nameDiv.appendChild(nameInput);
let userDiv = document.createElement("div");
userDiv.setAttribute("class", "entry_user");
userDiv.setAttribute("id",`${entry.replaceAll(" ","-")}_user`)
let userInput = document.createElement("input");
userInput.setAttribute("type", "password");
userInput.setAttribute("placeholder", "New Username");
userInput.setAttribute("value", "PLACEHOLDER");
userInput.setAttribute("readonly", true);
userInput.setAttribute("unselectable", "on")
userDiv.appendChild(userInput);
let passDiv = document.createElement("div");
passDiv.setAttribute("class", "entry_pass");
passDiv.setAttribute("id",`${entry.replaceAll(" ","-")}_pass`)
let passInput = document.createElement("input");
passInput.setAttribute("type", "password");
passInput.setAttribute("placeholder", "New Password");
passInput.setAttribute("value", "PLACEHOLDER!");
passInput.setAttribute("readonly", true);
passInput.setAttribute("unselectable", "on")
passDiv.appendChild(passInput);
let showButton = document.createElement("button");
showButton.innerText = "Show";
showButton.addEventListener("click",showEntry.bind(showButton, entry),false);
showButton.setAttribute("class", "showbutton");
let editButton = document.createElement("button");
editButton.innerText = "Edit";
editButton.addEventListener("click", editEntry.bind(editButton, entry), false);
editButton.setAttribute("class", "editbutton");
let actionDiv = document.createElement("div")
actionDiv.appendChild(showButton)
actionDiv.appendChild(editButton)
actionDiv.setAttribute("id",`${entry.replaceAll(" ","-")}_actions`)
document.getElementById("table_entries").appendChild(nameDiv)
document.getElementById("table_users").appendChild(userDiv)
document.getElementById("table_pwds").appendChild(passDiv)
document.getElementById("table_actions").appendChild(actionDiv)
}
async function editEntry(entry) {
let entry_user = document.querySelector(`#${entry.replaceAll(" ","-")}_user > input`);
let entry_pass = document.querySelector(`#${entry.replaceAll(" ","-")}_pass > input`);
let entry_name = document.querySelector(`#${entry.replaceAll(" ","-")}_name > input`);
let show_button = document.querySelector(`#${entry.replaceAll(" ","-")}_actions > .showbutton`);
if(this.innerText == "Edit") {
let info = await invoke("get_entry",{
name: entry_name.value,
mpw: await get_pw()
})
entry_user.value = info[0];
entry_pass.value = info[1];
entry_user.removeAttribute("readonly");
entry_user.setAttribute("unselectable", "off")
entry_user.type = "text";
entry_pass.removeAttribute("readonly");
entry_pass.setAttribute("unselectable", "off")
entry_pass.type = "text";
entry_name.removeAttribute("readonly");
entry_name.setAttribute("unselectable", "off")
show_button.disabled = true;
this.innerText = "Save";
this.Name = entry_name.value
} else {
//To Delete: this.Name
let isDeleted = await invoke("remove_entry", {name: this.Name})
if(!isDeleted) {
alert("Could not edit entry!")
return;
}
let success = await invoke("create_entry", {name: entry_name.value, username: entry_user.value, pw: entry_pass.value, mpw: await get_pw()});
if(!success) {
alert("Could not edit entry!")
return;
}
entry_user.setAttribute("readonly", true);
entry_user.setAttribute("unselectable", "off")
entry_user.type = "password"
entry_user.value = "PLACEHOLDER"
entry_pass.setAttribute("readonly", true);
entry_pass.setAttribute("unselectable", "off")
entry_pass.type = "password"
entry_pass.value = "PLACEHOLDER!"
entry_name.setAttribute("readonly", true);
entry_name.setAttribute("unselectable", "off")
show_button.disabled = false;
this.innerText = "Edit";
}
}
async function ask_pw() {
return await password_prompt("Enter your master password to proceed");
}
async function get_pw() {
let mpw = master_pw;
if(lock_status){
mpw = await ask_pw();
}
return mpw;
}
async function showEntry(entry_name) {
let entry_user = document.querySelector(`#${entry_name.replaceAll(" ","-")}_user > input`);
let entry_pass = document.querySelector(`#${entry_name.replaceAll(" ","-")}_pass > input`);
if(this.innerText == "Show"){
let info = await invoke("get_entry",{
name: entry_name,
mpw: await get_pw()
})
entry_user.value = info[0];
entry_pass.value = info[1];
entry_user.type = "text";
entry_pass.type = "text";
this.innerText = "Hide";
} else {
entry_user.value = "PLACEHOLDER";
entry_pass.value = "PLACEHOLDER!";
entry_user.type = "password";
entry_pass.type = "password";
this.innerText = "Show";
}
}
async function createEntry() {
let entryNameField = document.querySelector("#createEntry_name > input");
let entryUserField = document.querySelector("#createEntry_user > input");
let entryPassField = document.querySelector("#createEntry_pass > input");
if(entryNameField.value == "" || entryUserField.value == "") {
alert("Not all needed fields filled out!");
return;
}
if(entryPassField.value == "") {
if(!(confirm("No password provided, do you want to generate a secure password?"))) {
alert("Cant create entry without password!");
return;
}
entryPassField.value = await invoke("random_password");
}
let mpw = await get_pw()
let success = await invoke("create_entry", {name: entryNameField.value, username: entryNameField.value, pw: entryPassField.value, mpw: mpw});
if(success) {
alert("Successfully created entry!");
buildEntry(entryNameField.value)
entryNameField.value = ""
entryUserField.value = ""
entryPassField.value = ""
} else {
alert("A critical error occured during entry creation");
}
}
async function toggleLock() {
let txt = (lock_status && "Unlocked") || "Locked";
let src = (lock_status && "/images/security_lock_unlocked.png") || "/images/security_lock_locked.png";
if(lock_status){
master_pw = await ask_pw();
console.log(master_pw)
if(master_pw == "" || master_pw == null)return;
}
document.getElementById("lockLabel").innerText = txt;
document.getElementById("lockImg").src = src;
lock_status = !lock_status;
}

59
src/pwprompt.js Normal file
View File

@ -0,0 +1,59 @@
window.password_prompt = async function(label_message, button_message, arg3, arg4, arg5) {
return new Promise((res,rej) => {
let callback,width,height;
if (typeof label_message !== "string") label_message = "Password:";
if (typeof button_message !== "string") button_message = "Submit";
if (typeof arg3 === "function") {
callback = arg3;
}
else if (typeof arg3 === "number" && typeof arg4 === "number" && typeof arg5 === "function") {
width = arg3;
height = arg4;
callback = arg5;
}
if (typeof width !== "number") width = 200;
if (typeof height !== "number") height = 100;
if (typeof callback !== "function") callback = function(){};
let submit = function() {
callback(input.value);
document.body.removeChild(div);
window.removeEventListener("resize", resize, false);
res(input.value)
};
let resize = function() {
div.style.left = ((window.innerWidth / 2) - (width / 2)) + "px";
div.style.top = ((window.innerHeight / 2) - (height / 2)) + "px";
};
let div = document.createElement("div");
div.id = "password_prompt";
let label = document.createElement("label");
label.id = "password_prompt_label";
label.innerHTML = label_message;
label.for = "password_prompt_input";
div.appendChild(label);
div.appendChild(document.createElement("br"));
let input = document.createElement("input");
input.id = "password_prompt_input";
input.type = "password";
input.addEventListener("keyup", function(event) {
if (event.key == "Enter") submit();
}, false);
div.appendChild(input);
div.appendChild(document.createElement("br"));
let button = document.createElement("button");
button.innerHTML = button_message;
button.addEventListener("click", submit, false);
div.appendChild(button);
document.body.appendChild(div);
window.addEventListener("resize", resize, false);
})
};

View File

@ -1,5 +1,5 @@
:root { :root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif; font-family: MonoLisa, Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px; font-size: 16px;
line-height: 24px; line-height: 24px;
font-weight: 400; font-weight: 400;
@ -16,7 +16,6 @@
--fg-color: #303034; /* post background */ --fg-color: #303034; /* post background */
--bg-color: #1B1B1E; /* page background etc */ --bg-color: #1B1B1E; /* page background etc */
--text-color: #ECEAF1; /* text */ --text-color: #ECEAF1; /* text */
--blue-ish: #587291; /* buttons etc */
color: var(--text-color); color: var(--text-color);
background-color: var(--bg-color); background-color: var(--bg-color);
@ -28,48 +27,55 @@ a:hover {
input, input,
button { button {
color: #ffffff; color: var(--text-color);
background-color: #0f0f0f98; background-color: var(--fg-color);
}
.container { border-radius: 8px;
margin: 0; border: 1px solid transparent;
padding-top: 10vh;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
}
.row {
display: flex;
justify-content: center;
}
a {
font-weight: 500; font-weight: 500;
color: #646cff; font-family: inherit;
text-decoration: inherit; transition: border-color 0.25s;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}
@media only screen and (max-width: 600px) {
input,
button {
padding: 4px 8px;
font-size: 0.8em;
}
}
@media only screen and (min-width: 600px) and (max-width: 900px) {
input,
button {
padding: 5px 10px;
font-size: 0.9em;
}
}
@media only screen and (min-width: 900px) {
input,
button {
padding: 6.4px 12.8px;
font-size: 1em;
}
}
tr {
width: 50%;
}
input:not([readonly]){
color: var(--fg-color);
background-color: var(--text-color);
} }
h1 { h1 {
text-align: center; text-align: center;
} }
input,
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
color: #0f0f0f;
background-color: #ffffff;
transition: border-color 0.25s;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}
button { button {
cursor: pointer; cursor: pointer;
} }
@ -83,6 +89,54 @@ button {
outline: none; outline: none;
} }
#greet-input { #lockImg {
margin-right: 5px; position: absolute;
top: 1em;
right: 1em;
}
#lockLabel {
position: absolute;
top: 1em;
right: 4em;
}
#table_div {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: center;
}
.entry_name,.entry_user,.entry_pass {
width: 70%;
}
.entry_name > input,.entry_user > input,.entry_pass > input {
width: 100%;
}
.table_actions>div>button {
height: 40%;
}
input[type="password"] {
user-select: none;
}
#password_prompt {
background: white;
color: black;
border: 1px solid black;
width: 50%;
height: 25%;
position: fixed;
left: 25%;
top: 25%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
border: 3px double var(--fg-color);
border-radius: 5%;
} }