Skip to content

Install

View on GitHub

The Rust SDK licenses native apps, CLIs, and daemons with online activation and offline Ed25519 lease verification. It’s synchronous and runtime-free — no async/Tokio — and verifies licenses identically to the Swift and JavaScript SDKs (proven by cross-SDK conformance vectors).

Terminal window
cargo add keylight

Fetch the tenant’s trusted keyset so leases verify offline, then build the client. The third argument to builder is your tenant SDK key (sdk_live_…, from the Keylight dashboard) — it’s required and sent as the X-Keylight-SDK-Key header on every call.

use keylight::{Keylight, KeylightConfig};
let mut cfg = KeylightConfig::builder("your-tenant", "your-product", "sdk_live_…")
.key_prefix("PROD") // optional client-side key-format check
.max_offline_days(7) // optional offline grace window
.app_version(env!("CARGO_PKG_VERSION")) // report app version on every call + beacon
.build();
// Pull the tenant's trusted Ed25519 keyset (or pin keys with .trusted_key(...)).
if let Some((_, keys)) = keylight::keyset::fetch_keyset(
&keylight::http::ureq_transport::UreqTransport::default(),
&cfg.base_url,
&cfg.tenant_id,
) {
cfg.trusted_keys.extend(keys);
}
let kl = Keylight::new(cfg)?;
// Activate a license key (online). The returned lease is Ed25519-verified
// before anything is persisted.
let res = kl.activate("USER-LICENSE-KEY")?;
println!("activated: {}", res.activated);
// Gate features on entitlements — works offline from the cached lease.
if kl.has_entitlement("pro") {
// unlock pro features
}
// Release the seat when uninstalling / switching devices.
kl.deactivate()?;

The API is synchronous — no .await, no async runtime to set up. You drive checks on launch and on events with kl.check_on_launch() and kl.refresh_if_needed().

The SDK ships a first-party Tauri v2 plugin (Rust side) plus typed JS bindings:

Terminal window
cargo add tauri-plugin-keylight # Rust side
npm add tauri-plugin-keylight-api # JavaScript side

Register it with a prebuilt KeylightConfig:

src-tauri/src/main.rs
use keylight::KeylightConfig;
fn main() {
let cfg = KeylightConfig::builder("your-tenant", "your-product", "sdk_live_…")
.app_version(env!("CARGO_PKG_VERSION"))
.build();
tauri::Builder::default()
.plugin(tauri_plugin_keylight::init(cfg))
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

Grant the plugin’s default permissions in your capability file:

src-tauri/capabilities/default.json
{
"permissions": ["keylight:default"]
}

keylight:default allows activate, validate, and has_entitlement.