Skip to main content

Crate tauri_plugin_moonbase

Crate tauri_plugin_moonbase 

Source
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 polls

Or 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§

AddOnsState
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.
DeviceInfo
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.
LicenseState
A snapshot of everything the UI needs, sent with every moonbase://state-changed event and returned by every command that changes it.
LicenseView
A license as the frontend sees it: everything the SDK’s License carries but the raw token, which the webview has no use for and is better off never holding, plus days_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::moonbase to 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.
PendingActivation
The browser activation in progress.
TrialFeature
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 None for the built-in text, several of which name your product and manufacturer.
UpdateHint
A newer release than the running app, from the license’s p:rel claim. No network involved; call checkUpdate for the notes.
UpdateInfo
The release behind an available update.

Enums§

AddOnsPhase
Where the add-on list is.
Error
What a plugin command can fail with. Serialized for the frontend as { kind, message }, where kind is the SDK’s error type ("apiError", "licenseInvalid", …) or one of the plugin’s own ("notLicensed", "busy", "internal").
LockReason
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 LicenseState payload 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_window use it.

Traits§

MoonbaseExt
Access the plugin’s Moonbase controller from an App, AppHandle, Window or anything else that implements Manager.

Type Aliases§

Result