cntm_nucleus/lib.rs
1//! # nucleus-rs
2//!
3//! Rust backend SDK for [Nucleus](https://nucleus.dev) authentication.
4//!
5//! Provides JWT verification with JWKS caching, an admin API client for managing
6//! users and organisations, and optional middleware for Axum and Actix-web.
7//!
8//! ## Quick start
9//!
10//! ```rust,no_run
11//! use nucleus_rs::{NucleusClient, NucleusConfig};
12//!
13//! #[tokio::main]
14//! async fn main() {
15//! let client = NucleusClient::new(NucleusConfig {
16//! secret_key: "sk_live_...".into(),
17//! base_url: None,
18//! jwks_cache_ttl_secs: None,
19//! });
20//!
21//! let claims = client.verify_token("eyJ...").await.unwrap();
22//! println!("user id: {}", claims.user_id());
23//! }
24//! ```
25//!
26//! ## Features
27//!
28//! | Feature | Description |
29//! |---------|-------------|
30//! | `axum` | Adds [`axum::NucleusLayer`] and [`axum::NucleusClaims`] extractor |
31//! | `actix` | Adds [`actix::NucleusClaims`] extractor for Actix-web |
32
33pub const VERSION: &str = env!("CARGO_PKG_VERSION");
34
35pub fn init() {
36 if VERSION.contains("dev") {
37 eprintln!("[Nucleus] WARNING: You are using a dev preview ({VERSION}). Do not use in production.");
38 }
39}
40
41pub mod admin;
42pub mod claims;
43pub mod client;
44pub mod verify;
45
46#[cfg(feature = "axum")]
47pub mod axum;
48
49#[cfg(feature = "actix")]
50pub mod actix;
51
52// Re-exports for convenience.
53pub use claims::NucleusClaims;
54pub use client::{NucleusClient, NucleusConfig};
55pub use verify::NucleusError;