Compare commits
No commits in common. "c4101ec375ccaad35d3344e0eb995b222bad96d7" and "a1559e3a2c386d528725b114ada2597cedf20cf4" have entirely different histories.
c4101ec375
...
a1559e3a2c
78
src-tauri/Cargo.lock
generated
78
src-tauri/Cargo.lock
generated
@ -93,9 +93,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.80"
|
version = "1.0.79"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1"
|
checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "as-raw-xcb-connection"
|
name = "as-raw-xcb-connection"
|
||||||
@ -2273,9 +2273,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "muda"
|
name = "muda"
|
||||||
version = "0.11.5"
|
version = "0.11.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4c47e7625990fc1af2226ea4f34fb2412b03c12639fcb91868581eb3a6893453"
|
checksum = "e406691fa7749604bbc7964bde28a300572d52621bb84540f6907c0f8fe08737"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cocoa",
|
"cocoa",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
@ -2478,9 +2478,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl"
|
name = "openssl"
|
||||||
version = "0.10.64"
|
version = "0.10.63"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f"
|
checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.2",
|
"bitflags 2.4.2",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
@ -2510,9 +2510,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl-sys"
|
name = "openssl-sys"
|
||||||
version = "0.9.100"
|
version = "0.9.99"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ae94056a791d0e1217d18b6cbdccb02c61e3054fc69893607f4067e3bb0b1fd1"
|
checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
@ -2781,9 +2781,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "png"
|
name = "png"
|
||||||
version = "0.17.13"
|
version = "0.17.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1"
|
checksum = "78c2378060fb13acff3ba0325b83442c1d2c44fbb76df481160ddc1687cce160"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
@ -3187,9 +3187,9 @@ checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.17"
|
version = "1.0.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
|
checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "safemem"
|
name = "safemem"
|
||||||
@ -3298,9 +3298,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "semver"
|
name = "semver"
|
||||||
version = "1.0.22"
|
version = "1.0.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca"
|
checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
@ -3746,6 +3746,7 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"png",
|
"png",
|
||||||
|
"raw-window-handle 0.5.2",
|
||||||
"raw-window-handle 0.6.0",
|
"raw-window-handle 0.6.0",
|
||||||
"scopeguard",
|
"scopeguard",
|
||||||
"tao-macros",
|
"tao-macros",
|
||||||
@ -3777,9 +3778,9 @@ checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri"
|
name = "tauri"
|
||||||
version = "2.0.0-beta.3"
|
version = "2.0.0-beta.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "66497d130e3fb9889d738a3cffe1134a42ac1ce2177eca7fa0574a411000afde"
|
checksum = "a584d146c38bf174398dee0ec2cdd8f8fce142daee0306c370cf78f050304c60"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
@ -3797,9 +3798,10 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"mime",
|
"mime",
|
||||||
"muda",
|
"muda",
|
||||||
|
"nix",
|
||||||
"objc",
|
"objc",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"raw-window-handle 0.6.0",
|
"raw-window-handle 0.5.2",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@ -3825,9 +3827,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-build"
|
name = "tauri-build"
|
||||||
version = "2.0.0-beta.2"
|
version = "2.0.0-beta.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2932ca516808980f551fae4eb54009fd743648966ba4ce06a54f231cedefa2a0"
|
checksum = "314089a25d92a62f33f60d2a19c277f465e9088ee3ea251032ae914d6f2b1ce0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cargo_toml",
|
"cargo_toml",
|
||||||
@ -3847,9 +3849,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-codegen"
|
name = "tauri-codegen"
|
||||||
version = "2.0.0-beta.2"
|
version = "2.0.0-beta.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2f02a9d089133557849d11dfc30ad4be675ee05a4c191b7321da1e8d8dabd634"
|
checksum = "1e6ff13874390499976f01decf75103f28e7609abc5c155c6bfb56cf574a5628"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"brotli",
|
"brotli",
|
||||||
@ -3863,7 +3865,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2",
|
"sha2",
|
||||||
"syn 2.0.49",
|
|
||||||
"tauri-utils",
|
"tauri-utils",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"time",
|
"time",
|
||||||
@ -3874,9 +3875,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-macros"
|
name = "tauri-macros"
|
||||||
version = "2.0.0-beta.2"
|
version = "2.0.0-beta.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "115afb62760852e70cd25633008c761999527d8e38352f335761dfb9c8f735dc"
|
checksum = "18707774f70a8ec20dbf653f07d12af1e0d7c1e3a625b7bd5a2cfe72c2b2549b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck",
|
"heck",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@ -3888,14 +3889,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-runtime"
|
name = "tauri-runtime"
|
||||||
version = "2.0.0-beta.2"
|
version = "2.0.0-beta.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "014f1f9253ceaa503f5e07c1ca5d06271241090517b545c00cc6afb96a3d218e"
|
checksum = "1d72194de56e885dbd9fd8c493ccf95012e584c928900188da248f9ea4223b23"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gtk",
|
"gtk",
|
||||||
"http",
|
"http",
|
||||||
"jni",
|
"jni",
|
||||||
"raw-window-handle 0.6.0",
|
"raw-window-handle 0.5.2",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tauri-utils",
|
"tauri-utils",
|
||||||
@ -3906,16 +3907,17 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-runtime-wry"
|
name = "tauri-runtime-wry"
|
||||||
version = "2.0.0-beta.2"
|
version = "2.0.0-beta.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e117db5f0f3b2f233063805d71459b096711fe803cabd32f19c6f5cf15b6d7ab"
|
checksum = "74a71bd248a7ce857835b1f65845a9de22171e30d8129e018b42961502565efb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cocoa",
|
"cocoa",
|
||||||
"gtk",
|
"gtk",
|
||||||
"http",
|
"http",
|
||||||
"jni",
|
"jni",
|
||||||
|
"nix",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"raw-window-handle 0.6.0",
|
"raw-window-handle 0.5.2",
|
||||||
"softbuffer",
|
"softbuffer",
|
||||||
"tao",
|
"tao",
|
||||||
"tauri-runtime",
|
"tauri-runtime",
|
||||||
@ -3928,9 +3930,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-utils"
|
name = "tauri-utils"
|
||||||
version = "2.0.0-beta.2"
|
version = "2.0.0-beta.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6bbd83e66dab28c32a35e44ea71c02da16aca2259731b8b25d4c9476613f1681"
|
checksum = "e7104f0639a1f3a7ebd7aac793be47d7924f569e7c10c6853083529bf9bb3fe6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"brotli",
|
"brotli",
|
||||||
"cargo_metadata",
|
"cargo_metadata",
|
||||||
@ -4700,13 +4702,13 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "window-vibrancy"
|
name = "window-vibrancy"
|
||||||
version = "0.5.0"
|
version = "0.4.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "33082acd404763b315866e14a0d5193f3422c81086657583937a750cdd3ec340"
|
checksum = "af6abc2b9c56bd95887825a1ce56cde49a2a97c07e28db465d541f5098a2656c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cocoa",
|
"cocoa",
|
||||||
"objc",
|
"objc",
|
||||||
"raw-window-handle 0.6.0",
|
"raw-window-handle 0.5.2",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
"windows-version",
|
"windows-version",
|
||||||
]
|
]
|
||||||
@ -5001,9 +5003,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wry"
|
name = "wry"
|
||||||
version = "0.36.0"
|
version = "0.35.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3a9e7b81968555303086ef882a0c213896a76099de4ed0b86a798775c2d54304"
|
checksum = "d3016c47c9b6f7029a9da7cd48af8352327226bba0e955f3c92e2966651365a9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"block",
|
"block",
|
||||||
@ -5027,7 +5029,7 @@ dependencies = [
|
|||||||
"objc",
|
"objc",
|
||||||
"objc_id",
|
"objc_id",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"raw-window-handle 0.6.0",
|
"raw-window-handle 0.5.2",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2",
|
"sha2",
|
||||||
|
@ -6,17 +6,15 @@ license = "GNU GPLv3"
|
|||||||
description = "A Password manager"
|
description = "A Password manager"
|
||||||
repository = "https://git.ipost.rocks/Code002Lover/IPass-GUI"
|
repository = "https://git.ipost.rocks/Code002Lover/IPass-GUI"
|
||||||
|
|
||||||
[lib]
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
name = "ipass_gui_lib"
|
|
||||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2.0.0-beta", features = [] }
|
tauri-build = { version = "2.0.0-beta.1", 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 = "2.0.0-beta", features = [] }
|
tauri = { version = "2.0.0-beta.2", features = [] }
|
||||||
ip_lib = { path = "../library/" }
|
ip_lib = { path = "../library/" }
|
||||||
rand="0.8.5"
|
rand="0.8.5"
|
||||||
open="5.0.0"
|
open="5.0.0"
|
||||||
|
@ -1,146 +0,0 @@
|
|||||||
#![cfg_attr(
|
|
||||||
all(not(debug_assertions), target_os = "windows"),
|
|
||||||
windows_subsystem = "windows"
|
|
||||||
)]
|
|
||||||
|
|
||||||
use std::fs::File;
|
|
||||||
use std::io::Write;
|
|
||||||
use tauri::State;
|
|
||||||
use tokio::runtime::Runtime;
|
|
||||||
|
|
||||||
extern crate ip_lib;
|
|
||||||
extern crate open;
|
|
||||||
extern crate rand;
|
|
||||||
|
|
||||||
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
|
|
||||||
|
|
||||||
#[tauri::command]
|
|
||||||
fn get_version() -> String {
|
|
||||||
option_env!("CARGO_PKG_VERSION")
|
|
||||||
.unwrap_or("x.x.x")
|
|
||||||
.to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command]
|
|
||||||
fn create_entry(name: &str, username: String, pw: &str, mpw: &str) -> bool {
|
|
||||||
let username_and_pw = username + ";" + pw;
|
|
||||||
let return_value = ip_lib::create_entry(name, &username_and_pw, mpw);
|
|
||||||
if return_value {
|
|
||||||
isync_save();
|
|
||||||
}
|
|
||||||
return_value
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command]
|
|
||||||
fn random_password() -> String {
|
|
||||||
ip_lib::random_password()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command]
|
|
||||||
fn get_entry(name: &str, mpw: &str) -> Result<(String, String), String> {
|
|
||||||
let binding = ip_lib::get_entry(name, mpw);
|
|
||||||
if let Ok(data) = binding {
|
|
||||||
let mut split = data.split(';');
|
|
||||||
Ok((
|
|
||||||
split.next().unwrap().to_string(),
|
|
||||||
split.next().unwrap().to_string(),
|
|
||||||
))
|
|
||||||
} else {
|
|
||||||
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();
|
|
||||||
if ent != "token.ipasst" && ent.len() > 6 {
|
|
||||||
vector.insert(0, ent[..ent.len() - 6].to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vector.sort();
|
|
||||||
|
|
||||||
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();
|
|
||||||
isync_save();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command]
|
|
||||||
fn open_authorize() -> u32 {
|
|
||||||
let code: u32 = rand::random();
|
|
||||||
open::that(format!("https://ipost.rocks/authorize?id=1&extra={}", code)).unwrap();
|
|
||||||
//the IPass app id is 1
|
|
||||||
code
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command]
|
|
||||||
fn store_token(token: String) {
|
|
||||||
let filepath = &(ip_lib::get_ipass_folder() + "token.ipasst");
|
|
||||||
let mut file = File::create(filepath).unwrap();
|
|
||||||
file.write_all(token.as_bytes()).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command]
|
|
||||||
fn remove_token() {
|
|
||||||
let filepath = &(ip_lib::get_ipass_folder() + "token.ipasst");
|
|
||||||
std::fs::remove_file(filepath).unwrap();
|
|
||||||
//TODO: cleaner solution via IPass api call to unauthorize
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command]
|
|
||||||
fn get_isync_status() -> bool {
|
|
||||||
let filepath = &(ip_lib::get_ipass_folder() + "token.ipasst");
|
|
||||||
std::path::Path::new(filepath).exists()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn isync_save() {
|
|
||||||
let isync_save_future = ip_lib::isync_save();
|
|
||||||
|
|
||||||
let rt = Runtime::new().unwrap();
|
|
||||||
let _save_output = rt.block_on(isync_save_future);
|
|
||||||
//println!("isync_save: {}",save_output);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command]
|
|
||||||
fn sync_isync(rt: State<Runtime>) {
|
|
||||||
//println!("going to sync");
|
|
||||||
rt.spawn(async {
|
|
||||||
let _get_output = ip_lib::isync_get().await;
|
|
||||||
//println!("isync_get: {}",_get_output);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
|
||||||
pub fn run() {
|
|
||||||
let rt = Runtime::new().unwrap();
|
|
||||||
|
|
||||||
tauri::Builder::default()
|
|
||||||
.invoke_handler(tauri::generate_handler![
|
|
||||||
get_version,
|
|
||||||
create_entry,
|
|
||||||
random_password,
|
|
||||||
get_entry,
|
|
||||||
get_entries,
|
|
||||||
remove_entry,
|
|
||||||
open_authorize,
|
|
||||||
store_token,
|
|
||||||
get_isync_status,
|
|
||||||
sync_isync,
|
|
||||||
remove_token
|
|
||||||
])
|
|
||||||
.manage(rt)
|
|
||||||
.run(tauri::generate_context!())
|
|
||||||
.expect("error while running tauri application");
|
|
||||||
}
|
|
@ -1,5 +1,145 @@
|
|||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(
|
||||||
|
all(not(debug_assertions), target_os = "windows"),
|
||||||
|
windows_subsystem = "windows"
|
||||||
|
)]
|
||||||
|
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::Write;
|
||||||
|
use tauri::State;
|
||||||
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
|
extern crate ip_lib;
|
||||||
|
extern crate open;
|
||||||
|
extern crate rand;
|
||||||
|
|
||||||
|
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn get_version() -> String {
|
||||||
|
option_env!("CARGO_PKG_VERSION")
|
||||||
|
.unwrap_or("x.x.x")
|
||||||
|
.to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn create_entry(name: &str, username: String, pw: &str, mpw: &str) -> bool {
|
||||||
|
let username_and_pw = username + ";" + pw;
|
||||||
|
let return_value = ip_lib::create_entry(name, &username_and_pw, mpw);
|
||||||
|
if return_value {
|
||||||
|
isync_save();
|
||||||
|
}
|
||||||
|
return_value
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn random_password() -> String {
|
||||||
|
ip_lib::random_password()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn get_entry(name: &str, mpw: &str) -> Result<(String, String), String> {
|
||||||
|
let binding = ip_lib::get_entry(name, mpw);
|
||||||
|
if let Ok(data) = binding {
|
||||||
|
let mut split = data.split(';');
|
||||||
|
Ok((
|
||||||
|
split.next().unwrap().to_string(),
|
||||||
|
split.next().unwrap().to_string(),
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
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();
|
||||||
|
if ent != "token.ipasst" && ent.len() > 6 {
|
||||||
|
vector.insert(0, ent[..ent.len() - 6].to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vector.sort();
|
||||||
|
|
||||||
|
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();
|
||||||
|
isync_save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn open_authorize() -> u32 {
|
||||||
|
let code: u32 = rand::random();
|
||||||
|
open::that(format!("https://ipost.rocks/authorize?id=1&extra={}", code)).unwrap();
|
||||||
|
//the IPass app id is 1
|
||||||
|
code
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn store_token(token: String) {
|
||||||
|
let filepath = &(ip_lib::get_ipass_folder() + "token.ipasst");
|
||||||
|
let mut file = File::create(filepath).unwrap();
|
||||||
|
file.write_all(token.as_bytes()).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn remove_token() {
|
||||||
|
let filepath = &(ip_lib::get_ipass_folder() + "token.ipasst");
|
||||||
|
std::fs::remove_file(filepath).unwrap();
|
||||||
|
//TODO: cleaner solution via IPass api call to unauthorize
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn get_isync_status() -> bool {
|
||||||
|
let filepath = &(ip_lib::get_ipass_folder() + "token.ipasst");
|
||||||
|
std::path::Path::new(filepath).exists()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn isync_save() {
|
||||||
|
let isync_save_future = ip_lib::isync_save();
|
||||||
|
|
||||||
|
let rt = Runtime::new().unwrap();
|
||||||
|
let _save_output = rt.block_on(isync_save_future);
|
||||||
|
//println!("isync_save: {}",save_output);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn sync_isync(rt: State<Runtime>) {
|
||||||
|
//println!("going to sync");
|
||||||
|
rt.spawn(async {
|
||||||
|
let _get_output = ip_lib::isync_get().await;
|
||||||
|
//println!("isync_get: {}",_get_output);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
ipass_gui_lib::run();
|
let rt = Runtime::new().unwrap();
|
||||||
|
|
||||||
|
tauri::Builder::default()
|
||||||
|
.invoke_handler(tauri::generate_handler![
|
||||||
|
get_version,
|
||||||
|
create_entry,
|
||||||
|
random_password,
|
||||||
|
get_entry,
|
||||||
|
get_entries,
|
||||||
|
remove_entry,
|
||||||
|
open_authorize,
|
||||||
|
store_token,
|
||||||
|
get_isync_status,
|
||||||
|
sync_isync,
|
||||||
|
remove_token
|
||||||
|
])
|
||||||
|
.manage(rt)
|
||||||
|
.run(tauri::generate_context!())
|
||||||
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,11 @@
|
|||||||
{
|
{
|
||||||
"app": {
|
|
||||||
"windows": [
|
|
||||||
{
|
|
||||||
"fullscreen": false,
|
|
||||||
"height": 600,
|
|
||||||
"resizable": true,
|
|
||||||
"theme": "Dark",
|
|
||||||
"title": "IPass",
|
|
||||||
"width": 880
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"withGlobalTauri": true
|
|
||||||
},
|
|
||||||
"build": {
|
"build": {
|
||||||
"beforeBuildCommand": "",
|
|
||||||
"beforeDevCommand": "",
|
"beforeDevCommand": "",
|
||||||
|
"beforeBuildCommand": "",
|
||||||
"frontendDist": "../src"
|
"frontendDist": "../src"
|
||||||
},
|
},
|
||||||
|
"productName": "ipass",
|
||||||
|
"version": "1.0.0",
|
||||||
"bundle": {
|
"bundle": {
|
||||||
"active": true,
|
"active": true,
|
||||||
"category": "DeveloperTool",
|
"category": "DeveloperTool",
|
||||||
@ -43,7 +32,14 @@
|
|||||||
"timestampUrl": ""
|
"timestampUrl": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"plugins": {},
|
"app": {
|
||||||
"productName": "ipass",
|
"windows": [{
|
||||||
"version": "1.0.0"
|
"fullscreen": false,
|
||||||
|
"height": 600,
|
||||||
|
"resizable": true,
|
||||||
|
"title": "IPass",
|
||||||
|
"width": 880,
|
||||||
|
"theme": "Dark"
|
||||||
|
}]
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
const { invoke } = window.__TAURI__.core;
|
const { invoke } = window.__TAURI__.tauri;
|
||||||
|
|
||||||
let master_pw;
|
let master_pw;
|
||||||
let lock_status = true;
|
let lock_status = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user