Expand description
§ashwit-license
Rust client for Ashwit trial and perpetual desktop licenses. It verifies Ed25519-signed grants, binds them to a device key, and caches them for offline use. It is independent of Tauri and requires a compatible Ashwit licensing API.
§Installation
[dependencies]
ashwit-license = { version = "=0.2.3", features = ["keyring-store"] }Commit the application’s Cargo.lock and use --locked for CI tests and release builds. This is a proprietary crate. Consumption requires a written license or an authorized Ashwit product integration; publication on crates.io does not grant permission to copy, modify, redistribute, sublicense, or reverse engineer it.
§Features and storage
http(default): providesReqwestTransportwith rustls. Disable default features to supply your ownTransport.keyring-store: stores the device private key and a separate security checkpoint in macOS Keychain, Windows Credential Manager, or Linux Secret Service. Only the signed grant lives in the supplied cache file.
Linux requires a running, unlocked Secret Service. Storage failures do not fall back to plaintext. FileStore deliberately keeps all state in a JSON file for isolated development/tests and provides no tamper resistance.
§Application integration
Use KeyringStore with the keyring-store feature in production. Construct ClientConfig with the API URL, product slug, app version, and embedded Ed25519 public keys. Manage the resulting LicenseClient through Tauri state and expose thin async commands for start_trial, activate, refresh, deactivate, and cached_state.
Call cached_state at startup and before protected operations. Retain the client to cache signature/device checks. trusted_now_ms supplies the time used by authorization; do not override it with a frontend wall clock. Trial grants last at most 72 hours, capped by the fixed trialEndsAt; paid grants retain the 30-day offline window. Refresh both kinds after 12 hours, with bounded retry/backoff. A network failure alone preserves a valid offline grant.
All network operations use /license-sessions/challenge followed by /license-sessions/verify. The device signs a domain-separated, short-lived challenge; the signed result binds the client nonce, action, product, and device. Server-side challenge consumption is atomic. Fresh responses can recover clock errors without passing the old offline clock check. Invalid or missing security state requires online verification. Unknown or corrupt grant files can be recovered using the activation reference in secure storage; activation with a license key does not require a readable old grant.
The client serializes in-process state and rejects overlapping network actions. The application must retain an OS-level lock around shared storage for its lifetime. The default HTTP transport has a 15-second request timeout, 5-second connect timeout, no redirects, and a 64 KiB response bound. Signed refresh denials are persisted separately from the grant, preventing an old grant file from restoring access. Storage write failures block the running client until recovery succeeds.
Offline time uses a protected checkpoint plus elapsed wall time across restarts, and monotonic elapsed time within a process. A wall/monotonic discrepancy above five minutes (including suspend on platforms whose monotonic clock pauses) requires online recovery. Checkpoints are written at most every five minutes during use. Crashes may lose that much recent progress. Secure storage and short leases resist casual file edits; they cannot prevent full OS snapshots, extracted keys, or patched executables. Offline wall-clock reconstruction is not hardware-backed trusted time.
This pre-release state format stays at version 1. Old plaintext time fields are not imported into secure storage. Existing signed grants may identify the activation for a fresh online exchange, but never authorize offline use without a matching protected checkpoint. Deploy the new API and migration before distributing SDK 0.2 clients.
Use separate API URLs, public-key maps, cache paths, and keyring service names for staging and production. Embed only grant verification public keys. Never include API signing private keys, payment credentials, or license encryption keys in the desktop application. Enforce paid features in native application operations as well as the UI.
See examples/tauri_state.rs for construction and tests/client.rs for a mock transport/store setup. The example uses development file storage and an empty public-key map; replace both before integrating it into an application.
Structs§
- Client
Config - Device
- File
Store - Grant
Payload - Http
Request - Http
Response - License
Client - Callers retain this client for the application session. Concurrent network actions are rejected; status checks may continue using the previous valid offline lease.
- Reqwest
Transport - Security
State - Signed
Grant - System
Clock - System
Device Identity - Verified
Grant