Compare commits
No commits in common. "98baaed81c8ba624adadbf9b12d21c0844ab1de2" and "067de52e4be66153701eb7b99a9a920f15d9cd1d" have entirely different histories.
98baaed81c
...
067de52e4b
|
@ -41,15 +41,6 @@ dependencies = [
|
|||
"rustc-demangle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bincode"
|
||||
version = "1.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bip39"
|
||||
version = "2.0.0"
|
||||
|
@ -253,13 +244,6 @@ version = "1.0.9"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
|
||||
|
||||
[[package]]
|
||||
name = "keyfork-derive-util"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "keyfork-frame"
|
||||
version = "0.1.0"
|
||||
|
@ -292,12 +276,10 @@ dependencies = [
|
|||
name = "keyforkd"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"dirs",
|
||||
"keyfork-derive-util",
|
||||
"keyfork-frame",
|
||||
"keyfork-mnemonic-util",
|
||||
"serde",
|
||||
"minicbor",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tower",
|
||||
|
@ -345,6 +327,26 @@ version = "2.5.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "minicbor"
|
||||
version = "0.19.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7005aaf257a59ff4de471a9d5538ec868a21586534fff7f85dd97d4043a6139"
|
||||
dependencies = [
|
||||
"minicbor-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minicbor-derive"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1154809406efdb7982841adb6311b3d095b46f78342dd646736122fe6b19e267"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.7.1"
|
||||
|
@ -429,7 +431,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.29",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -540,23 +542,9 @@ checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.186"
|
||||
version = "1.0.183"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f5db24220c009de9bd45e69fb2938f4b6d2df856aa9304ce377b3180f83b7c1"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.186"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ad697f7e0b65af4983a4ce8f56ed5b357e8d3c36651bf6a7e13639c17b8e670"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c"
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
|
@ -620,6 +608,17 @@ dependencies = [
|
|||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.29"
|
||||
|
@ -648,7 +647,7 @@ checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.29",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -703,7 +702,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.29",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -755,7 +754,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.29",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
members = [
|
||||
"keyfork-mnemonic-generate",
|
||||
"keyfork-mnemonic-util",
|
||||
"keyfork-derive-util",
|
||||
"keyforkd",
|
||||
"keyfork-frame"
|
||||
]
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
[package]
|
||||
name = "keyfork-derive-util"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.186", features = ["derive"] }
|
|
@ -1,23 +0,0 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct DerivablePath {
|
||||
pub(crate) path: Vec<u32>,
|
||||
}
|
||||
|
||||
// TODO: move DerivablePath into a models crate for clients to produce?
|
||||
/*
|
||||
impl DerivablePath {
|
||||
pub fn new(input: &[&[u8]]) -> DerivablePath {
|
||||
DerivablePath {
|
||||
path: input
|
||||
.iter()
|
||||
.map(|&word| {
|
||||
// perform path validation
|
||||
word.to_vec()
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -116,7 +116,7 @@ pub fn try_decode(data: &[u8]) -> Result<Vec<u8>, DecodeError> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{try_decode, try_encode, DecodeError};
|
||||
use super::{try_encode, try_decode, DecodeError};
|
||||
|
||||
#[test]
|
||||
fn stable_interface() {
|
||||
|
|
|
@ -11,12 +11,10 @@ tracing = ["tower/tracing", "tokio/tracing", "dep:tracing", "dep:tracing-subscri
|
|||
multithread = ["tokio/rt-multi-thread"]
|
||||
|
||||
[dependencies]
|
||||
bincode = "1.3.3"
|
||||
dirs = "5.0.1"
|
||||
keyfork-derive-util = { version = "0.1.0", path = "../keyfork-derive-util" }
|
||||
keyfork-frame = { version = "0.1.0", path = "../keyfork-frame" }
|
||||
keyfork-mnemonic-util = { version = "0.1.0", path = "../keyfork-mnemonic-util" }
|
||||
serde = { version = "1.0.186", features = ["derive"] }
|
||||
minicbor = { version = "0.19.1", features = ["derive", "std"] }
|
||||
thiserror = "1.0.47"
|
||||
tokio = { version = "1.32.0", features = ["io-util", "macros", "rt", "io-std", "net", "fs", "signal"] }
|
||||
tower = { version = "0.4.13", features = ["tokio", "util"] }
|
||||
|
|
|
@ -13,11 +13,11 @@ use tracing_subscriber::{
|
|||
};
|
||||
|
||||
mod error;
|
||||
mod server;
|
||||
mod service;
|
||||
mod server;
|
||||
use error::KeycloakdError;
|
||||
use server::UnixServer;
|
||||
use service::Keyforkd;
|
||||
use server::UnixServer;
|
||||
|
||||
type Result<T, E = Box<dyn std::error::Error>> = std::result::Result<T, E>;
|
||||
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
use crate::service::{DerivationError, Keyforkd};
|
||||
use keyfork_derive_util::DerivablePath;
|
||||
use crate::service::{DerivablePath, DerivationError, Keyforkd};
|
||||
use keyfork_frame::asyncext::{try_decode_from, try_encode_to};
|
||||
use std::{
|
||||
io::Error,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
use std::{io::Error, path::{Path, PathBuf}};
|
||||
use tokio::net::{UnixListener, UnixStream};
|
||||
use tower::{Service, ServiceExt};
|
||||
|
||||
|
@ -15,7 +11,7 @@ async fn read_path_from_socket(
|
|||
socket: &mut UnixStream,
|
||||
) -> Result<DerivablePath, Box<dyn std::error::Error + Send>> {
|
||||
let data = try_decode_from(socket).await.unwrap();
|
||||
let path: DerivablePath = bincode::deserialize(&data[..]).unwrap();
|
||||
let path: DerivablePath = minicbor::decode(&data[..]).unwrap();
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
|
@ -35,10 +31,7 @@ impl UnixServer {
|
|||
tokio::spawn(async move {
|
||||
let result = tokio::signal::ctrl_c().await;
|
||||
#[cfg(feature = "tracing")]
|
||||
debug!(
|
||||
?result,
|
||||
"encountered ctrl-c, performing cleanup and exiting"
|
||||
);
|
||||
debug!(?result, "encountered ctrl-c, performing cleanup and exiting");
|
||||
let result = tokio::fs::remove_file(&path).await;
|
||||
#[cfg(feature = "tracing")]
|
||||
if let Err(error) = result {
|
||||
|
@ -93,6 +86,7 @@ impl UnixServer {
|
|||
#[cfg(feature = "tracing")]
|
||||
debug!(%e, "Error sending response to client");
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,32 @@
|
|||
use std::{future::Future, pin::Pin, sync::Arc, task::Poll};
|
||||
use std::{future::Future, pin::Pin, task::Poll, sync::Arc};
|
||||
|
||||
use keyfork_derive_util::DerivablePath;
|
||||
use keyfork_mnemonic_util::Mnemonic;
|
||||
use thiserror::Error;
|
||||
use minicbor::{Decode, Encode};
|
||||
use tower::Service;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Encode, Decode, Clone, Debug)]
|
||||
pub struct DerivablePath {
|
||||
#[n(0)]
|
||||
path: Vec<Vec<u8>>,
|
||||
}
|
||||
|
||||
// TODO: move DerivablePath into a models crate for clients to produce?
|
||||
/*
|
||||
impl DerivablePath {
|
||||
pub fn new(input: &[&[u8]]) -> DerivablePath {
|
||||
DerivablePath {
|
||||
path: input
|
||||
.iter()
|
||||
.map(|&word| {
|
||||
// perform path validation
|
||||
word.to_vec()
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Keyforkd {
|
||||
|
@ -12,13 +35,12 @@ pub struct Keyforkd {
|
|||
|
||||
// Currently, this can't be instantiated, therefore it is a never-type
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DerivationError {}
|
||||
pub enum DerivationError {
|
||||
}
|
||||
|
||||
impl Keyforkd {
|
||||
pub fn new(mnemonic: Mnemonic) -> Self {
|
||||
Self {
|
||||
mnemonic: Arc::new(mnemonic),
|
||||
}
|
||||
Self { mnemonic: Arc::new(mnemonic) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue