Daemon

Struct Daemon 

Source
pub struct Daemon { /* private fields */ }
Expand description

Connection to the user’s uniauth daemon, used for RPC Connection with the daemon will last as long as this struct exists. Should only be used by an application’s client, never a server.

Implementations§

Source§

impl Daemon

Source

pub async fn new(service: &str) -> Result<Self>

Connect to the default daemon path.

§Arguments
  • service - Name of this service
§Example
let daemon = Daemon::new("matrix").await?;
Source

pub async fn connect(service: &str, path: impl AsRef<Path>) -> Result<Self>

Connect to a custom daemon path

§Arguments
  • service - Name of this service
  • path - Path to the daemon’s unix socket
§Example
let daemon = Daemon::connect("test_thing", "/tmp/test.sock").await?;
Source

pub async fn authenticate( &mut self, name: &str, action: &str, nonce: &[u8], ) -> Result<AnySignature>

Authenticate an action for a given service login, returning its signature. All fields must be known by the server to authenticate with through communication or hardcoding.

§Arguments
  • name - Name of the service’s key to use
  • action - Action to authenticate. Must be human readable, but also completely deterministic
  • nonce - Unique random data or atomic counter that is unique to this challenge and never used again
§Example
let nonce = random_data_from_server();
let sig = daemon.authenticate("username", "login", &nonce).await?;
send_signature_to_server(sig);
Source

pub async fn pubkey(&mut self, name: &str) -> Result<AnyPubkey>

Get the public key for a given name

§Arguments
  • name - Name of the key as added with store
§Example
let pubkey = daemon.pubkey("username").await?;
send_server_pubkey(pubkey);
// have the server verify a regsiter action now
Source

pub async fn store(&mut self, name: &str, keypair: AnyKeypair) -> Result<()>

Store a keypair for a new service login. Will fail if a keypair already exists.

§Warning

Since the client provides the keypair, this gives it a requirement for extra security. Keys that are generated and immediately stored should use generate instead.

§Arguments
  • name - Name of the key to be retrieved by authenticate or pubkey
  • keypair - The keypair used for signing challenges
§Example
let keypair = import_keypair();
daemon.store("username", keypair).await?;
Source

pub async fn generate(&mut self, name: &str) -> Result<AnyPubkey>

Generate a new keypair and return its public half. Will fail if a keypair already exists

§Arguments
  • name - Name of the key to generate
§Example
let pubkey = daemon.generate("username").await?;
pubkey.verify(b"whatever", signature)?;

Auto Trait Implementations§

§

impl !Freeze for Daemon

§

impl RefUnwindSafe for Daemon

§

impl Send for Daemon

§

impl Sync for Daemon

§

impl Unpin for Daemon

§

impl UnwindSafe for Daemon

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V