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