Expand description
Tauri v2 plugin for licensemanager.dev: license key activation, offline tokens, background renewal, clock tampering detection and machine fingerprinting.
Register the plugin with a Builder, then reach the LicenseManager
with LicensemanagerExt::license:
use std::time::Duration;
use tauri_plugin_licensemanager::{LicenseState, LicensemanagerExt};
const PUBLIC_KEY: &str = "-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----";
#[tauri::command]
fn export_pdf(app: tauri::AppHandle) -> Result<(), String> {
if app.license().state() != LicenseState::Active {
return Err("A license is required".into());
}
Ok(())
}
// `context` is `tauri::generate_context!()` in an app.
fn run(context: tauri::Context) {
tauri::Builder::default()
.plugin(
tauri_plugin_licensemanager::Builder::new("x7Kp2QaZ", PUBLIC_KEY)
.min_offline_duration(Duration::from_secs(14 * 86_400))
.build(),
)
.invoke_handler(tauri::generate_handler![export_pdf])
.run(context)
.expect("error while running tauri application");
}Structs§
- Builder
- Configures and builds the plugin.
- License
Error - A failed license validation. Branch on
code, never onmessage. - License
Error Dto - A
LicenseErroras JSON:{ code, message, status?, latestAllowedVersion? }. - License
Manager - The license state machine: one per app, created by the plugin and reached
with
LicensemanagerExt::license. - Snapshot
- Everything the webview needs to render the license, in one call. Also the
payload of the
licensemanager://state-changedevent. - Subscription
- Keeps a listener registered by
LicenseManager::on_state_changeuntil dropped.
Enums§
- Config
Error - Invalid plugin configuration: a developer error, reported at startup.
- Latest
Allowed Version - In state
VERSION_NOT_ALLOWED, the latest version the license allows. - License
Error Code - Error codes returned by the validate-key endpoint, plus SDK-side codes for failures that never reached a definitive server answer.
- License
State - The license state of the app.
- Machine
Fingerprint - User-supplied machine fingerprint source, replacing the native machine id. The value is still hashed before use.
- Offline
State - Whether the last validation reached the server.
- Offline
State Dto OfflineStateas JSON:{ mode: "online" }or{ mode: "offline", validUntil: number | null, remainingMs: number }, times in ms since the epoch.
Constants§
- SDK_
NAME - Name of this SDK.
- STATE_
CHANGED_ EVENT - Event emitted to every webview on each state change, with a
Snapshot.
Traits§
- Licensemanager
Ext - Access to the
LicenseManagerfrom anApp,AppHandle,Window…