Compare commits

...

2 Commits

Author SHA1 Message Date
c4101ec375 update lockfile 2024-02-19 23:43:09 +01:00
065c1bf4c9 fix tauri error 2024-02-19 23:42:51 +01:00
6 changed files with 243 additions and 233 deletions

78
src-tauri/Cargo.lock generated
View File

@ -93,9 +93,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.79"
version = "1.0.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1"
[[package]]
name = "as-raw-xcb-connection"
@ -2273,9 +2273,9 @@ dependencies = [
[[package]]
name = "muda"
version = "0.11.4"
version = "0.11.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e406691fa7749604bbc7964bde28a300572d52621bb84540f6907c0f8fe08737"
checksum = "4c47e7625990fc1af2226ea4f34fb2412b03c12639fcb91868581eb3a6893453"
dependencies = [
"cocoa",
"crossbeam-channel",
@ -2478,9 +2478,9 @@ dependencies = [
[[package]]
name = "openssl"
version = "0.10.63"
version = "0.10.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8"
checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f"
dependencies = [
"bitflags 2.4.2",
"cfg-if",
@ -2510,9 +2510,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.99"
version = "0.9.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae"
checksum = "ae94056a791d0e1217d18b6cbdccb02c61e3054fc69893607f4067e3bb0b1fd1"
dependencies = [
"cc",
"libc",
@ -2781,9 +2781,9 @@ dependencies = [
[[package]]
name = "png"
version = "0.17.12"
version = "0.17.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78c2378060fb13acff3ba0325b83442c1d2c44fbb76df481160ddc1687cce160"
checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1"
dependencies = [
"bitflags 1.3.2",
"crc32fast",
@ -3187,9 +3187,9 @@ checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
[[package]]
name = "ryu"
version = "1.0.16"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
[[package]]
name = "safemem"
@ -3298,9 +3298,9 @@ dependencies = [
[[package]]
name = "semver"
version = "1.0.21"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0"
checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca"
dependencies = [
"serde",
]
@ -3746,7 +3746,6 @@ dependencies = [
"once_cell",
"parking_lot",
"png",
"raw-window-handle 0.5.2",
"raw-window-handle 0.6.0",
"scopeguard",
"tao-macros",
@ -3778,9 +3777,9 @@ checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae"
[[package]]
name = "tauri"
version = "2.0.0-beta.2"
version = "2.0.0-beta.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a584d146c38bf174398dee0ec2cdd8f8fce142daee0306c370cf78f050304c60"
checksum = "66497d130e3fb9889d738a3cffe1134a42ac1ce2177eca7fa0574a411000afde"
dependencies = [
"anyhow",
"bytes",
@ -3798,10 +3797,9 @@ dependencies = [
"log",
"mime",
"muda",
"nix",
"objc",
"percent-encoding",
"raw-window-handle 0.5.2",
"raw-window-handle 0.6.0",
"reqwest",
"serde",
"serde_json",
@ -3827,9 +3825,9 @@ dependencies = [
[[package]]
name = "tauri-build"
version = "2.0.0-beta.1"
version = "2.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "314089a25d92a62f33f60d2a19c277f465e9088ee3ea251032ae914d6f2b1ce0"
checksum = "2932ca516808980f551fae4eb54009fd743648966ba4ce06a54f231cedefa2a0"
dependencies = [
"anyhow",
"cargo_toml",
@ -3849,9 +3847,9 @@ dependencies = [
[[package]]
name = "tauri-codegen"
version = "2.0.0-beta.1"
version = "2.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e6ff13874390499976f01decf75103f28e7609abc5c155c6bfb56cf574a5628"
checksum = "2f02a9d089133557849d11dfc30ad4be675ee05a4c191b7321da1e8d8dabd634"
dependencies = [
"base64",
"brotli",
@ -3865,6 +3863,7 @@ dependencies = [
"serde",
"serde_json",
"sha2",
"syn 2.0.49",
"tauri-utils",
"thiserror",
"time",
@ -3875,9 +3874,9 @@ dependencies = [
[[package]]
name = "tauri-macros"
version = "2.0.0-beta.1"
version = "2.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18707774f70a8ec20dbf653f07d12af1e0d7c1e3a625b7bd5a2cfe72c2b2549b"
checksum = "115afb62760852e70cd25633008c761999527d8e38352f335761dfb9c8f735dc"
dependencies = [
"heck",
"proc-macro2",
@ -3889,14 +3888,14 @@ dependencies = [
[[package]]
name = "tauri-runtime"
version = "2.0.0-beta.1"
version = "2.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d72194de56e885dbd9fd8c493ccf95012e584c928900188da248f9ea4223b23"
checksum = "014f1f9253ceaa503f5e07c1ca5d06271241090517b545c00cc6afb96a3d218e"
dependencies = [
"gtk",
"http",
"jni",
"raw-window-handle 0.5.2",
"raw-window-handle 0.6.0",
"serde",
"serde_json",
"tauri-utils",
@ -3907,17 +3906,16 @@ dependencies = [
[[package]]
name = "tauri-runtime-wry"
version = "2.0.0-beta.1"
version = "2.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74a71bd248a7ce857835b1f65845a9de22171e30d8129e018b42961502565efb"
checksum = "e117db5f0f3b2f233063805d71459b096711fe803cabd32f19c6f5cf15b6d7ab"
dependencies = [
"cocoa",
"gtk",
"http",
"jni",
"nix",
"percent-encoding",
"raw-window-handle 0.5.2",
"raw-window-handle 0.6.0",
"softbuffer",
"tao",
"tauri-runtime",
@ -3930,9 +3928,9 @@ dependencies = [
[[package]]
name = "tauri-utils"
version = "2.0.0-beta.1"
version = "2.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7104f0639a1f3a7ebd7aac793be47d7924f569e7c10c6853083529bf9bb3fe6"
checksum = "6bbd83e66dab28c32a35e44ea71c02da16aca2259731b8b25d4c9476613f1681"
dependencies = [
"brotli",
"cargo_metadata",
@ -4702,13 +4700,13 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "window-vibrancy"
version = "0.4.3"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af6abc2b9c56bd95887825a1ce56cde49a2a97c07e28db465d541f5098a2656c"
checksum = "33082acd404763b315866e14a0d5193f3422c81086657583937a750cdd3ec340"
dependencies = [
"cocoa",
"objc",
"raw-window-handle 0.5.2",
"raw-window-handle 0.6.0",
"windows-sys 0.52.0",
"windows-version",
]
@ -5003,9 +5001,9 @@ dependencies = [
[[package]]
name = "wry"
version = "0.35.2"
version = "0.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3016c47c9b6f7029a9da7cd48af8352327226bba0e955f3c92e2966651365a9"
checksum = "3a9e7b81968555303086ef882a0c213896a76099de4ed0b86a798775c2d54304"
dependencies = [
"base64",
"block",
@ -5029,7 +5027,7 @@ dependencies = [
"objc",
"objc_id",
"once_cell",
"raw-window-handle 0.5.2",
"raw-window-handle 0.6.0",
"serde",
"serde_json",
"sha2",

View File

@ -6,15 +6,17 @@ license = "GNU GPLv3"
description = "A Password manager"
repository = "https://git.ipost.rocks/Code002Lover/IPass-GUI"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "ipass_gui_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2.0.0-beta.1", features = [] }
tauri-build = { version = "2.0.0-beta", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "2.0.0-beta.2", features = [] }
tauri = { version = "2.0.0-beta", features = [] }
ip_lib = { path = "../library/" }
rand="0.8.5"
open="5.0.0"

146
src-tauri/src/lib.rs Normal file
View File

@ -0,0 +1,146 @@
#![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");
}

View File

@ -1,145 +1,5 @@
#![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() {
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");
}
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
ipass_gui_lib::run();
}

View File

@ -1,45 +1,49 @@
{
"build": {
"beforeDevCommand": "",
"beforeBuildCommand": "",
"frontendDist": "../src"
},
"productName": "ipass",
"version": "1.0.0",
"bundle": {
"active": true,
"category": "DeveloperTool",
"copyright": "",
"externalBin": [],
"icon": [
"icons/icon.ico",
"icons/icon.png"
],
"longDescription": "",
"macOS": {
"entitlements": null,
"exceptionDomain": "",
"frameworks": [],
"providerShortName": null,
"signingIdentity": null
},
"resources": [],
"shortDescription": "",
"targets": "all",
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": ""
}
},
"app": {
"windows": [{
"fullscreen": false,
"height": 600,
"resizable": true,
"title": "IPass",
"width": 880,
"theme": "Dark"
}]
}
{
"app": {
"windows": [
{
"fullscreen": false,
"height": 600,
"resizable": true,
"theme": "Dark",
"title": "IPass",
"width": 880
}
],
"withGlobalTauri": true
},
"build": {
"beforeBuildCommand": "",
"beforeDevCommand": "",
"frontendDist": "../src"
},
"bundle": {
"active": true,
"category": "DeveloperTool",
"copyright": "",
"externalBin": [],
"icon": [
"icons/icon.ico",
"icons/icon.png"
],
"longDescription": "",
"macOS": {
"entitlements": null,
"exceptionDomain": "",
"frameworks": [],
"providerShortName": null,
"signingIdentity": null
},
"resources": [],
"shortDescription": "",
"targets": "all",
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": ""
}
},
"plugins": {},
"productName": "ipass",
"version": "1.0.0"
}

View File

@ -1,4 +1,4 @@
const { invoke } = window.__TAURI__.tauri;
const { invoke } = window.__TAURI__.core;
let master_pw;
let lock_status = true;