Skip to Content
TauriAPI reference

Tauri SDK API reference

JavaScript

import { getFingerprint, getLatestAllowedVersion, getLicense, getLicenseKey, getLicenseKeyHint, getOfflineState, getPortalUrl, getState, isClockTampered, LicenseError, onStateChange, ready, refresh, setLicenseKey, watchLicense, type LicenseErrorCode, type LicenseSnapshot, type LicenseState, type OfflineState, type UnlistenFn, } from "@licenseman/tauri";

Every function calls the plugin over Tauri’s IPC, and needs its permission.

ready(): Promise<LicenseState>

Resolves with the state on startup. With a valid stored token, right away with ACTIVE, and the online validation runs in the background. Otherwise, once the startup validation is done. Never rejects because of LicenseManager.

getState(): Promise<LicenseState>

The current state. See license states.

getLicense(): Promise<LicenseSnapshot>

The state, the offline state and the latest allowed version, in one call.

watchLicense(listener): Promise<UnlistenFn>

Subscribes to the state event, then calls listener(snapshot) with the current snapshot, then on every change. Resolves with a function that stops listening. See rendering the license.

onStateChange(listener): Promise<UnlistenFn>

Calls listener(state, snapshot) on every change of state, not with the current state. Resolves with a function that stops listening.

setLicenseKey(key: string): Promise<LicenseState>

Validates the key online, trimmed, case kept, retrying transient failures for up to 30 seconds. On success, stores it with its token, and resolves with ACTIVE. On any failure, rejects with a LicenseError and changes nothing. See activating a license.

refresh(): Promise<LicenseState>

Waits for ready(), then validates the stored key now, retrying transient failures for up to 30 seconds. Resolves with the new state. Never rejects because of LicenseManager. Without a stored key, resolves with the current state. See refresh().

getOfflineState(): Promise<OfflineState>

Whether the last validation reached LicenseManager, and how long the stored token remains valid. See offline state.

getLatestAllowedVersion(): Promise<string | null | undefined>

In VERSION_NOT_ALLOWED, refused by LicenseManager: the latest version the license allows, or null when it allows none. undefined in every other state, and when the refusal comes from the stored token offline.

getPortalUrl(): Promise<string>

The link to your product’s customer portal, like https://app.licensemanager.dev/portal/x7Kp2QaZ.

isClockTampered(): Promise<boolean>

The result of the latest clock check. See clock tampering.

getLicenseKeyHint(): Promise<string | null>

The last 5 characters of the stored key, or null when none was activated.

getLicenseKey(): Promise<string | null>

The stored key, or null. Needs licensemanager:allow-get-license-key, not in licensemanager:default.

getFingerprint(): Promise<string>

This computer’s fingerprint for your product. Needs licensemanager:allow-get-fingerprint, not in licensemanager:default. See machine fingerprint.

Types

type LicenseState = | "LOADING" | "MISSING_KEY" | "ACTIVE" | "INVALID_KEY" | "EXPIRED" | "VERSION_NOT_ALLOWED" | "MACHINE_LIMIT_REACHED" | "OFFLINE_EXPIRED" | "CLOCK_TAMPERED"; type OfflineState = | { mode: "online" } | { mode: "offline"; /** Expiration of the stored token, or null without a valid token. */ validUntil: Date | null; /** Time left before validUntil, in milliseconds. 0 without a valid token. */ remainingMs: number; }; interface LicenseSnapshot { state: LicenseState; offline: OfflineState; latestAllowedVersion: string | null | undefined; }

LicenseError

Extends Error, with name set to "LicenseError".

PropertyType
codeLicenseErrorCodeWhat failed. Branch on it, not on message.
messagestringFor logs.
statusnumber | undefinedThe HTTP status, when LicenseManager answered.
latestAllowedVersionstring | null | undefinedFor version_not_allowed only.
isLockingbooleantrue when the license itself was refused.

Rust

use tauri_plugin_licensemanager::{ Builder, LatestAllowedVersion, LicenseError, LicenseErrorCode, LicenseManager, LicenseState, LicensemanagerExt, MachineFingerprint, OfflineState, Subscription, };

The full documentation of each item is on docs.rs .

Builder

MethodDefault
Builder::new(product_id, public_key)RequiredYour product’s id, and your organization’s Ed25519 public key, as PEM, from the Security page.
.version(impl Into<String>)The app’s versionYour app’s version, from tauri.conf.json or Cargo.toml.
.machine_name(impl Into<String>)The hostnameThe machine’s name on LicenseManager.
.platform(impl Into<String>)macOS, Windows or LinuxThe machine’s platform on LicenseManager.
.fingerprint(impl Into<MachineFingerprint>)The system’s machine idThe machine part of the fingerprint.
.min_offline_duration(Duration)ZeroThe minimum validity left after a renewal. See min_offline_duration.
.api_base_url(impl Into<String>)https://api.licensemanager.devFor tests.
.build()The TauriPlugin, for tauri::Builder::plugin.

The app’s setup fails when the product id is empty, the public key isn’t a valid Ed25519 public key, or the app runs on iOS or Android. See setup.

LicensemanagerExt

license(&self) -> &LicenseManager, on any App, AppHandle, Window or Webview. Panics when the plugin isn’t registered.

LicenseManager

Cheap to clone: clones share the same state.

Method
state(&self) -> LicenseStateThe current state.
async ready(&self) -> LicenseStateLike ready() above.
async set_license_key(&self, input: &str) -> Result<LicenseState, LicenseError>Like setLicenseKey() above.
async refresh(&self) -> LicenseStateLike refresh() above.
license_key(&self) -> Option<String>The stored key.
portal_url(&self) -> StringThe link to the customer portal.
latest_allowed_version(&self) -> LatestAllowedVersionLike getLatestAllowedVersion() above.
offline_state(&self) -> OfflineStateLike getOfflineState() above.
async fingerprint(&self) -> StringThis computer’s fingerprint.
is_clock_tampered(&self) -> boolThe result of the latest clock check.
on_state_change(&self, F) -> SubscriptionCalls F(LicenseState) on every change. Removed when the Subscription is dropped.
subscribe(&self) -> tokio::sync::watch::Receiver<LicenseState>The current state, and every change.
dispose(&self)Stops the renewals, the pending retries and the clock check. Called by the plugin when the app exits.

LicenseState

Loading, MissingKey, Active, InvalidKey, Expired, VersionNotAllowed, MachineLimitReached, OfflineExpired, ClockTampered. Serialized like in JavaScript, like "MISSING_KEY". as_str() returns the same string.

OfflineState

Online, or Offline { valid_until: Option<SystemTime>, remaining: Duration }.

LatestAllowedVersion

NotApplicable (undefined in JavaScript), NoneAllowed (null), or Version(String).

MachineFingerprint

Static(String), from a String or &str, or a function, with MachineFingerprint::from_sync_fn(|| -> String) or MachineFingerprint::from_fn(|| async -> String).

LicenseError

FieldType
codeLicenseErrorCode
messageString
statusOption<u16>
latest_allowed_versionLatestAllowedVersion

is_locking() is true when the license itself was refused.

Commands and event

@licenseman/tauri calls these commands, as plugin:licensemanager|<command>: get_state, ready, get_license, set_license_key, refresh, get_offline_state, get_latest_allowed_version, get_portal_url, is_clock_tampered, get_license_key_hint, get_license_key, get_fingerprint. Each has an allow- and a deny- permission, like licensemanager:allow-get-state.

On every change of state, the plugin emits licensemanager://state-changed to every window, with the snapshot: { state, offline, latestAllowedVersion }, validUntil as milliseconds since 1970.

LicenseErrorCode

CodeRustLockingSource
not_foundNotFoundYesLicenseManager, 404.
license_expiredLicenseExpiredYesLicenseManager, 403.
version_not_allowedVersionNotAllowedYesLicenseManager, 403.
machine_limit_reachedMachineLimitReachedYesLicenseManager, 403.
plan_limit_exceededPlanLimitExceededNoLicenseManager, 402.
validation_errorValidationErrorNoLicenseManager, 422, or an empty key.
internal_errorInternalErrorNoLicenseManager, 500.
network_errorNetworkErrorNoThe SDK: no answer, a timeout after 10 seconds, or an unknown error code, after the retries.
invalid_responseInvalidResponseNoThe SDK: no token in the answer, or a token that failed verification.

See the errors for what to show for each one.