pub struct AuthClient { /* private fields */ }Expand description
The auth service’s client.
Implementations§
Source§impl AuthClient
impl AuthClient
Sourcepub fn new(base_url: impl Into<String>) -> Self
pub fn new(base_url: impl Into<String>) -> Self
A client for the auth service at base_url, without a token.
Sourcepub fn with_token(self, token: &str) -> Self
pub fn with_token(self, token: &str) -> Self
For the calls that need a logged-in device (see Session::token).
Sourcepub async fn server_key(&self) -> Result<PublicKey, ClientError>
pub async fn server_key(&self) -> Result<PublicKey, ClientError>
The key the server signs tokens with. Clients remember it the first time and check it on every login after.
Sourcepub async fn wait_for_server_key(
&self,
patience: Duration,
) -> Result<PublicKey, ClientError>
pub async fn wait_for_server_key( &self, patience: Duration, ) -> Result<PublicKey, ClientError>
AuthClient::server_key, retrying while the auth service can’t be
reached (e.g. it’s still starting), for up to patience.
Sourcepub async fn setup(
&self,
code: &str,
key: &DeviceKey,
name: &str,
) -> Result<Campaign, ClientError>
pub async fn setup( &self, code: &str, key: &DeviceKey, name: &str, ) -> Result<Campaign, ClientError>
Makes key the DM of the campaign a one-time setup code is for.
Sourcepub async fn login(
&self,
campaign: Uuid,
key: &DeviceKey,
expected_server: Option<PublicKey>,
) -> Result<Session, ClientError>
pub async fn login( &self, campaign: Uuid, key: &DeviceKey, expected_server: Option<PublicKey>, ) -> Result<Session, ClientError>
Answers a login challenge with key, returning a short-lived token.
With expected_server, refuses to sign for any other server.
Sourcepub async fn campaign(&self) -> Result<Campaign, ClientError>
pub async fn campaign(&self) -> Result<Campaign, ClientError>
The token’s campaign.
Sourcepub async fn devices(&self) -> Result<Vec<Device>, ClientError>
pub async fn devices(&self) -> Result<Vec<Device>, ClientError>
The campaign’s devices, revoked ones too.
Sourcepub async fn add_device(&self, cert: &SignedCert) -> Result<Device, ClientError>
pub async fn add_device(&self, cert: &SignedCert) -> Result<Device, ClientError>
Adds a device, vouched for by a certificate signed with the DM key this client is logged in with.
Source§impl AuthClient
impl AuthClient
Sourcepub async fn invite(&self, role: Role) -> Result<Invitation, ClientError>
pub async fn invite(&self, role: Role) -> Result<Invitation, ClientError>
Opens a pairing (DM devices only) and makes up its code. The words are made here and never sent anywhere.
Sourcepub async fn cancel_pairing(&self, slot: u16) -> Result<(), ClientError>
pub async fn cancel_pairing(&self, slot: u16) -> Result<(), ClientError>
Cancels a pairing this DM device opened.
Trait Implementations§
Source§impl Clone for AuthClient
impl Clone for AuthClient
Source§fn clone(&self) -> AuthClient
fn clone(&self) -> AuthClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more