Integrate the client SDKs
In this guide
An installation keeps its identity and seat across launches. The publisher selects the product, environment and trusted public keys when building the app. The buyer enters a licence key.
Prepare two trust profiles
In a controlled build preparation step, fetch the public keys for your publisher account and product. For example, for the studio product of the atelier organisation, save each response as a separate build resource.
curl --fail --silent --show-error 'https://keyseal.io/v1/keys/atelier/studio?environment=test' -o studio-test.json
curl --fail --silent --show-error 'https://keyseal.io/v1/keys/atelier/studio?environment=live' -o studio-live.json
The keys field maps each kid to 32 Ed25519 public key bytes encoded in standard base64. Decode these values and construct a Profile with the HTTPS origin, organisation, product, environment and key map. Ship the selected resource with your signed app build. A v1 certificate carries the product slug. The pinned key set establishes the organisation and environment. Private signing keys and management credentials stay with the publisher.
For a major-limited licence, activating or refreshing with a different major returns 403 version_not_covered. Prompt the user to reopen a covered release. Its stored certificate can still verify entitlements offline in that release.
Persist the device and its entitlements
The SDK sources live in clients/rust (the keyseal-client crate), clients/swift (the KeysealClient Swift package), clients/dotnet/Keyseal.Client (a .NET 8 project reference) and clients/python (the local keyseal-client distribution for Python 3.11 or newer). Integrate a version identified by commit. Test profiles allow HTTP on loopback for local acceptance runs.
Give the client a private store that atomically replaces the entire entry only when its revision still matches. Separate entries by origin, organisation, environment and product. Use a keychain or a protected file on a desktop. A replicated service needs a shared, protected database row. The in-memory SDK store is intended for single-process tests. The device operation generates and persists a random identity before the first POST. Keep it through upgrades and after releasing a seat. Users can rename a machine.
Call the functions below from your activation handler, passing its configured client and the key the buyer just entered. Supply the UTC release day of the build. Each function reads the verified certificate and returns a boolean suitable for the UI.
Rust and Tauri
use chrono::NaiveDate;
use keyseal_client::{ApiError, Client};
pub fn activate_build(client: &Client, key: &str, day: NaiveDate) -> Result<bool, ApiError> {
let device = client.device("Studio", "desktop", "1.0", Some(day))?;
client.activate(key, &device)?;
let state = client.snapshot(&device)?;
Ok(state.licensed() && state.activation.is_some_and(|a| a.claims.covers_release(day, Some(1))))
}
Run this synchronous function on a worker, for example with tauri::async_runtime::spawn_blocking. The Rust backend owns the client and store.
Swift
import KeysealClient
func activateBuild(client: Client, key: String, day: ReleaseDay) async throws -> Bool {
let device = try await client.device(machineName: "Studio", appVersion: "1.0", buildDate: day)
_ = try await client.activate(key: key, device: device)
let state = try await client.snapshot(device: device)
return state.licensed && state.activation?.claims.coversBuild(day, major: 1) == true
}
.NET
using System;
using System.Threading.Tasks;
using Keyseal.Client;
public static class Licensing
{
public static async Task<bool> ActivateBuildAsync(Client client, string key, DateOnly day)
{
var device = await client.DeviceAsync("Studio", "windows", "1.0", day);
await client.ActivateAsync(key, device);
var state = await client.SnapshotAsync(device);
return state.Licensed && state.Activation?.Claims.CoversBuild(day, major: 1) == true;
}
}
Python
from datetime import date
from keyseal_client import KeysealClient
async def activate_build(client: KeysealClient, key: str, day: date) -> bool:
device = await client.device("Studio", "desktop", "1.0", day)
await client.activate(key, device)
state = await client.snapshot(device)
return state.licensed and state.activation is not None and state.activation.claims.covers_build(day, major=1)
Start offline, refresh and return a seat
On startup, create a client over the same store. Call device, then snapshot, before contacting the network. Evaluate the licence verdict and coverage of the build’s release day separately. When online, call refresh_if_due (Swift refreshIfDue, .NET RefreshIfDueAsync) in the background. The SDK checks the signature, product, fingerprint and activation ID before replacing the certificate. Its retry schedule honours Retry-After.
| Situation | Application behaviour |
|---|---|
| Lease expired, service unreachable | The signed open policy retains verified rights. closed requires the device to reconnect. The latest covered build is still limited by updates_until. |
revoked, suspended, expired on refresh |
The denial persists across an offline restart. A later successful refresh can restore access after reinstatement. |
released, unknown_activation, wrong_machine |
Offer to activate again after the local activation is cleared. |
seats_exhausted |
Show the machines from the SDK’s public error projection and the customer area for this scope, such as /c/atelier?environment=test. The buyer chooses a machine to release and retries. |
Timeout, 429, 5xx or an invalid incoming certificate |
The last authenticated state still follows its lease. Show the SDK’s safe error code. |
An explicit release action calls deactivate with the same device. A 204 releases the seat. Retain the local activation for retry if the network fails. After losing local storage or replacing a machine, release the previous device in the customer area. An imported Lemon Squeezy installation validates its existing seat through the compatibility API with its historical instance ID and expected catalogue IDs. At full capacity, obtain the buyer’s consent to release that instance before activating natively.
Rotate pinned public keys
Create the new active key. Its predecessor becomes retiring and remains in keys. Release an app update containing both keys. It can read the old cached certificate and accept a newly signed certificate on refresh. Older builds shipped with only the previous key need an update to accept the new signature. Once supported builds have migrated, retire the previous key and distribute a resource containing just the active key. Offline installations still trust the keys shipped in their last installed build. An unknown kid never authorises adding a new key.
Electron
Keep the client and store in the main process or a private utility process that loads one of the four SDKs. Expose narrow preload actions for activation, reading the verdict and release. The main process checks the window and origin of every message. Enable context isolation and disable Node integration in the renderer. Return only an access verdict, a safe error code or the SDK’s public machine list. Keep certificates, fingerprints, the entered key, tokens and signed download URLs out of logs, crash reports, process arguments and renderer state after input.