Skip to main content

wavekat_platform_client/
lib.rs

1//! Rust client for the WaveKat platform.
2//!
3//! Reusable across consumers (the [`wavekat-cli`] binary `wk`, the
4//! WaveKat desktop daemon, future WaveKat tools) so platform auth and
5//! HTTP plumbing have one implementation, not many.
6//!
7//! ## Quick start
8//!
9//! ```no_run
10//! use wavekat_platform_client::{loopback_handshake, Client, HandshakeOptions};
11//!
12//! # async fn run() -> wavekat_platform_client::Result<()> {
13//! let pending = loopback_handshake(
14//!     "https://platform.wavekat.com",
15//!     HandshakeOptions::default(),
16//! )?;
17//! println!("Open: {}", pending.url());
18//! let outcome = pending.wait().await?;
19//!
20//! let client = Client::new("https://platform.wavekat.com", outcome.token)?;
21//! let me = client.whoami().await?;
22//! println!("signed in as {}", me.login);
23//! # Ok(()) }
24//! ```
25//!
26//! ## What this crate is (and isn't)
27//!
28//! - **Storage-agnostic.** `Client::new(base_url, token)` is the contract.
29//!   The crate never reads or writes disk; consumers pick where the token
30//!   lives (config file, OS keychain, env var, in-memory test fixture).
31//! - **Browser-agnostic.** [`loopback_handshake`] returns the sign-in URL;
32//!   the caller decides how to open it (`webbrowser::open`,
33//!   `shell.openExternal`, `println!`, …).
34//! - **Runtime-light.** Async surface uses `reqwest`; consumers bring
35//!   their own tokio runtime.
36//!
37//! [`wavekat-cli`]: https://github.com/wavekat/wavekat-cli
38
39mod client;
40mod error;
41mod me;
42mod oauth;
43mod sign;
44mod sync;
45mod token;
46mod voice;
47
48pub use client::Client;
49pub use error::{Error, Result};
50pub use me::Me;
51pub use oauth::{loopback_handshake, HandshakeOptions, HandshakeOutcome, PendingHandshake};
52pub use sign::{
53    cert_payload, generate_keypair, generate_master, issue_release_credential, verify_cert,
54    verify_request, ReleaseCredential, RequestSignature,
55};
56pub use sync::{HasSyncEnvelope, Page, SyncEndpoint, SyncEnvelope, SyncRequest, SyncResponse};
57pub use token::Token;
58pub use voice::{
59    InstallHeartbeatRequest, InstallHeartbeatResponse, SystemInfo, VoiceAccountRecord,
60    VoiceAccounts, VoiceAccountsQuery, VoiceCallDirection, VoiceCallDisposition,
61    VoiceCallEndReason, VoiceCallRecord, VoiceCalls, VoiceCallsQuery, VoiceRecordingRecord,
62    VoiceRecordingSyncItem, VoiceRecordings, VoiceRecordingsQuery, VoiceRecordingsSyncResponse,
63    VoiceTranscriptChannel, VoiceTranscriptRecord, VoiceTranscripts, VoiceTranscriptsQuery,
64    VoiceTransport,
65};