#[cfg(feature = "any")]
pub mod any;
#[cfg(feature = "client")]
pub mod daemon;
#[cfg(feature = "error")]
pub mod error;
pub mod requests;
pub mod status;
pub mod util;
use std::io::Write;
#[cfg(feature = "daemon")]
use std::{
env,
path::PathBuf
};
#[cfg(feature = "daemon")]
pub fn daemon_path() -> PathBuf {
let runtime_dir = env::var("XDG_RUNTIME_DIR")
.expect("Missing XDG_RUNTIME_DIR environment variable");
let mut path = PathBuf::from(runtime_dir);
path.push("uniauth2.sock");
path
}
pub fn make_challenge(service: &str, name: &str, action: &str, nonce: &[u8]) -> Vec<u8> {
let len = 11 + service.len() + name.len() + action.len() + nonce.len();
util::make_packet(len, |p| {
p.write_all(b"UNIAUTH")?;
p.push(b'/');
p.write_all(service.as_bytes())?;
p.push(b'/');
p.write_all(name.as_bytes())?;
p.push(b'/');
p.write_all(action.as_bytes())?;
p.push(b'/');
p.write_all(nonce)
}).unwrap()
}