Expand description
§Moonbase licensing for Tauri
License activation for a Tauri 2 app, built on the moonbase SDK. Register
the plugin with your store’s details and it validates the stored license at
startup, runs browser and offline activation, trials and deactivation, watches
for expiry, and tells your frontend about every change:
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.plugin(
tauri_plugin_moonbase::Builder::new("https://your-tenant.moonbase.sh", "your-product", PUBLIC_KEY)
.build(),
)From the frontend, with "withGlobalTauri": true:
const { moonbase } = window.__TAURI__;
moonbase.onStateChanged((state) => render(state));
render(await moonbase.state());
await moonbase.activate(); // opens the browser, then pollsOr invoke the commands directly: invoke('plugin:moonbase|state'). Grant them
with the moonbase:default permission in your capability file.
Gate features, and add-ons, in Rust with MoonbaseExt:
use tauri_plugin_moonbase::MoonbaseExt;
if !app.moonbase().is_licensed() {
return;
}
if app.moonbase().has_sub_product("gradients") {
// the add-on is unlocked on this device
}Re-exports§
pub use moonbase;
Structs§
- AddOns
State - The product’s add-ons the customer can do something with, as Moonbase lists
them for this device, and the add-on an activation or trial is running for.
Loaded by
loadAddOns. - Builder
- Configures and builds the plugin.
- Device
Info - This device, for an about box or a “copy diagnostics” button.
- Failure
- The last operation that failed, worded for the customer, with the SDK’s own message for logs and support.
- License
State - A snapshot of everything the UI needs, sent with every
moonbase://state-changedevent and returned by every command that changes it. - License
View - A license as the frontend sees it: everything the SDK’s
Licensecarries but the raw token, which the webview has no use for and is better off never holding, plusdays_remaining. Serializes as the SDK’s license JSON does. - Moonbase
- The plugin’s license controller, managed as Tauri state. Reach it from Rust
with
MoonbaseExt::moonbaseto gate features or drive activation without the webview. - NotCovered
- A license that is valid, but doesn’t cover the version of the app that runs.
- Pending
Activation - The browser activation in progress.
- Trial
Feature - A line on the trial screen: something the trial includes, or does not.
- UiConfig
- Branding and behaviour for the built-in activation window.
- UiStrings
- Copy overrides. Leave a field
Nonefor the built-in text, several of which name your product and manufacturer. - Update
Hint - A newer release than the running app, from the license’s
p:relclaim. No network involved; callcheckUpdatefor the notes. - Update
Info - The release behind an available update.
Enums§
- AddOns
Phase - Where the add-on list is.
- Error
- What a plugin command can fail with. Serialized for the frontend as
{ kind, message }, wherekindis the SDK’s error type ("apiError","licenseInvalid", …) or one of the plugin’s own ("notLicensed","busy","internal"). - Lock
Reason - Why the app lost its license, so the UI can say so.
- Presentation
- Where the activation UI appears.
- Screen
- A screen of the built-in UI to open on, with
Moonbase::present. Without one it shows whatever the license state calls for. In the frontend, the same names as strings:"license","update","offline","addons". - Status
- Where the license stands. Drive your UI off this.
Constants§
- STATE_
CHANGED_ EVENT - Emitted with a
LicenseStatepayload whenever anything in it changes. - VERSION
- The plugin’s version, as reported in the
User-Agent. - WINDOW_
LABEL - The window’s label. Capabilities, events and
get_webview_windowuse it.
Traits§
- Moonbase
Ext - Access the plugin’s
Moonbasecontroller from anApp,AppHandle,Windowor anything else that implementsManager.