Guides
Let activated devices keep working without an internet connection for a period you choose.
While online, your app requests an offline lease: a signed note saying “this device may use this license until a certain time”. Your app saves it, and while there's no connection it checks the saved lease instead of calling Atlas.
import { verifyOfflineLease } from "@atlas/sdk";
// Online: get a lease and save the whole response.
const lease = await atlas.lease({
license_key: storedKey,
product_id: PRODUCT_ID,
device: { id: machineId },
});
await storage.save("lease", JSON.stringify(lease));
// Offline: check the saved lease before unlocking.
const check = await verifyOfflineLease(JSON.parse(await storage.load("lease")), {
publicKey: BUNDLED_PUBLIC_KEY, // from atlas.signingKey(), bundled with your app
deviceId: machineId,
productId: PRODUCT_ID,
});
if (check.valid) enableFeatures(check.lease.entitlements);
else showMessage("Connect to the internet to keep using the app.");verifyOfflineLease checks the signature, the expiry, and that the lease belongs to this device and product. Save the full response, not just data, or the signature can't be checked.
A lease never outlives the license. Atlas uses the shortest of: the length you ask for (ttl_seconds, optional), the policy's maximum, and the time left before the license expires plus its grace period.
Pick a length you're comfortable with
A lease request fails if the device isn't activated (not_activated), the license doesn't allow offline use (offline_not_allowed), or the license is no longer active. Keep using the previous lease until it expires, then ask the user to go online.