Skip to content

Commit

Permalink
chore(deps): ➖ Simplify dependencies and features.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jisu-Woniu committed Nov 24, 2023
1 parent 9fa716a commit c29bc68
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 28 deletions.
5 changes: 3 additions & 2 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ futures = "0.3.29"
rayon = "1.8.0"
serde = { version = "1.0.193", features = ["derive"] }
serde_json = "1.0.108"
tokio = { version = "1.34.0", features = ["fs", "macros", "rt", "rt-multi-thread"] }
tokio = { version = "1.34.0", features = ["fs"] }

[dependencies.digital-signature-crypto]
version = "0.1.0"
path = "crypto"
version = "0.1.0"

[dependencies.tauri]
version = "1.5.2"
features = [
"config-toml",
"dialog-ask",
Expand All @@ -44,6 +43,7 @@ features = [
"icon-ico",
"icon-png",
]
version = "1.5.2"

[features]
# this feature is used for production builds or when `devPath` points to the filesystem
Expand All @@ -55,3 +55,6 @@ codegen-units = 1
lto = true
panic = "abort"
strip = true

[dev-dependencies]
tokio = { version = "1.34.0", features = ["rt-multi-thread"] }
9 changes: 7 additions & 2 deletions src-tauri/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ version.workspace = true
[dependencies]
async-trait = "0.1.74"
chrono = "0.4.31"
futures = "0.3.29"
hex = "0.4.3"
pgp = "0.10.2"
serde = { version = "1.0.193", features = ["derive"] }
smallvec = "1.11.2"
thiserror = "1.0.50"
zeroize = "1.7.0"
tokio-util = { version = "0.7.10", features = ["io-util"] }
zeroize = "1.7.0"

[dependencies.tokio]
features = ["fs", "io-util", "macros", "rt-multi-thread"]
features = ["fs", "io-util"]
version = "1.34.0"

[dev-dependencies]
temp-dir = "0.1.11"

[dev-dependencies.tokio]
features = ["macros", "rt-multi-thread"]
version = "1.34.0"
13 changes: 6 additions & 7 deletions src-tauri/crypto/src/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
use std::path::{Path, PathBuf};

use futures::future::try_join;
use pgp::types::KeyTrait;
use serde::Serialize;
use tokio::{
fs::{self, DirBuilder},
try_join,
};
use tokio::fs::{write, DirBuilder};
use zeroize::Zeroizing;

use crate::{key_pair::KeyPair, secret_file::write_secret_file, Result};
Expand Down Expand Up @@ -57,10 +55,11 @@ where
let secret_key_armored = Zeroizing::new(signed_secret_key.to_armored_bytes(None)?);
let public_key_armored = signed_public_key.to_armored_bytes(None)?;

try_join!(
try_join(
write_secret_file(&secret_key_path, &secret_key_armored),
fs::write(&public_key_path, &public_key_armored)
)?;
write(&public_key_path, &public_key_armored),
)
.await?;

Ok(KeyPairPaths {
secret_key_path,
Expand Down
8 changes: 4 additions & 4 deletions src-tauri/crypto/src/secret_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use std::{io::Result, path::Path};

#[cfg(unix)]
pub(crate) async fn write_secret_file(path: impl AsRef<Path>, data: &[u8]) -> Result<()> {
use tokio::{fs, io::AsyncWriteExt};
use tokio::{fs::OpenOptions, io::AsyncWriteExt};

/// File permissions for secret data
#[cfg(unix)]
const SECRET_FILE_PERMS: u32 = 0o600;

let mut file = fs::OpenOptions::new()
let mut file = OpenOptions::new()
.create(true)
.write(true)
.truncate(true)
Expand All @@ -23,8 +23,8 @@ pub(crate) async fn write_secret_file(path: impl AsRef<Path>, data: &[u8]) -> Re

#[cfg(not(unix))]
pub(crate) async fn write_secret_file(path: impl AsRef<Path>, data: &[u8]) -> Result<()> {
use tokio::fs;
use tokio::fs::write;

fs::write(path, data).await?;
write(path, data).await?;
Ok(())
}
4 changes: 2 additions & 2 deletions src-tauri/src/fs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{ffi::OsStr, path::Path};

use serde::Serialize;
use tokio::fs;
use tokio::fs::metadata;

use crate::error::Result;

Expand All @@ -25,7 +25,7 @@ impl Serialize for FileType {

#[tauri::command]
pub async fn detect_file_type(path: &Path) -> Result<FileType> {
Ok(match fs::metadata(path).await {
Ok(match metadata(path).await {
Ok(metadata) => {
if metadata.is_dir() {
FileType::Dir
Expand Down
11 changes: 4 additions & 7 deletions src/views/KeygenView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ const valid = ref<boolean | null>(null);
const file = ref<string>();
const rules = {
required: (value: string | undefined) => !!value?.trim() || "必填",
email: (value: string) => {
const regex =
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
console.log(`Email: ${value}`);
return regex.test(value) || "非法邮件地址";
},
email: (value: string) =>
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(
value,
) || "非法邮件地址",
};
const generate = async () => {
Expand Down
1 change: 0 additions & 1 deletion src/views/SignView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const back = () => {
};
const submit = async () => {
console.log("Received submit.");
if (valid.value) {
if (step.value === items.value.length) {
await signFiles(data.filePaths, data.keyPath, data.passwd);
Expand Down

0 comments on commit c29bc68

Please sign in to comment.