runbeam_sdk/lib.rs
1//! Runbeam SDK
2//!
3//! A Rust library for integrating with the Runbeam Cloud API.
4//!
5//! This SDK provides:
6//! - JWT token validation with RS256 and JWKS caching
7//! - Runbeam Cloud API client for gateway authorization
8//! - Secure token storage via OS keychain (macOS Keychain, Linux Secret Service, Windows Credential Manager)
9//! - Type definitions for API requests/responses and error handling
10//!
11//! # Example
12//!
13//! ```no_run
14//! use runbeam_sdk::{
15//! RunbeamClient,
16//! validate_jwt_token,
17//! save_token,
18//! load_token,
19//! MachineToken,
20//! storage::{KeyringStorage, StorageBackend},
21//! };
22//!
23//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
24//! // Validate a user JWT token
25//! let claims = validate_jwt_token("eyJhbGci...", 24).await?;
26//!
27//! // Create API client from JWT issuer
28//! let client = RunbeamClient::new(claims.api_base_url());
29//!
30//! // Authorize a gateway and get machine token
31//! let response = client.authorize_gateway(
32//! "eyJhbGci...",
33//! "gateway-123",
34//! None,
35//! None
36//! ).await?;
37//!
38//! // Save machine token securely
39//! let storage = KeyringStorage::new("runbeam");
40//! let machine_token = MachineToken::new(
41//! response.machine_token,
42//! response.expires_at,
43//! response.gateway.id,
44//! response.gateway.code,
45//! response.abilities,
46//! );
47//! save_token(&storage, &machine_token).await?;
48//! # Ok(())
49//! # }
50//! ```
51
52pub mod runbeam_api;
53pub mod storage;
54
55// Re-export commonly used types and functions
56pub use runbeam_api::{
57 client::RunbeamClient,
58 jwt::{validate_jwt_token, extract_bearer_token, JwtClaims},
59 resources::{
60 Gateway, Service, Endpoint, Backend, Pipeline, Middleware, Transform,
61 Policy, Network, Authentication, GatewayConfiguration,
62 PaginatedResponse, ResourceResponse, PaginationLinks, PaginationMeta,
63 },
64 token_storage::{save_token, load_token, clear_token, MachineToken},
65 types::{ApiError, RunbeamError, AuthorizeResponse, GatewayInfo, UserInfo, TeamInfo},
66};