Activate a licence in Electron
In this guide
Accept the typed key through a narrow preload method, then handle licensing in the main process. Return state and enabled features to the window. Keep the key and certificate out of the renderer’s localStorage.
To use the SDK, follow the client SDK integration guide.
Prepare the app
The example uses the main Node process’s fetch and node:crypto. Store a stable installation identifier and the last verified state in private application storage. Keep the product, API origin and pinned keys under main-process control. The functions below call the public API directly. Download electron.mjs.
Pin your product slug (here dropsmith) and your organisation’s test public keys in the build. Obtain those keys at build time as described in the verification protocol. Keep management credentials and privileged calls on the publisher’s server.
Activate the first machine
Pass the key the buyer just typed and the local fingerprint to this function. Replace the sample machine name, platform, version and build date with your app’s values. A successful POST /v1/activate returns 200 with activation_id and certificate.
export function activate(key, fingerprint) {
return post('activate', {
key, product, fingerprint, machine_name: 'Studio', platform: process.platform,
app_version: '1.0.0', build_date: '2026-11-17',
});
}
If every seat is taken (seats_exhausted), let the buyer release a machine. You can discard the entered key. Refresh sends activation_id, the original fingerprint and the current app_version.
Verify before granting access
Require two canonical base64url segments after keyseal:v1:. Read the kid from the UTF-8 JSON to select its pinned public key. Pass that key, the original payload segment as received and the 64 signature bytes to the function below. Pass the raw public key as a Buffer. The main process constructs an Ed25519 JWK in memory and passes null to verify for pure Ed25519. A false result means bad_signature.
export function validSignature(publicKey, segment, signature) {
if (publicKey.length !== 32 || signature.length !== 64) return false;
const key = createPublicKey({
key: { kty: 'OKP', crv: 'Ed25519', x: publicKey.toString('base64url') },
format: 'jwk',
});
return verify(null, Buffer.from(segment, 'ascii'), key, signature);
}
The signature is one step in the complete verification procedure. Check every signed claim, the expected product and the fingerprint’s SHA-256. Match act to the ID in the response, then replace the stored ID and certificate together. Run the protocol’s 19 vectors, including modified signatures and retired keys.
Start offline, refresh and release
Verify the stored certificate on every launch. When the network is unavailable, an active lease allows use. At or beyond lease_until, open preserves the last verified entitlements and closed blocks use until a successful refresh. Check the build’s date against updates_until as well.
export function refresh(id, fingerprint) {
return post('refresh', { activation_id: id, fingerprint, app_version: '1.0.0' });
}
export function deactivate(id, fingerprint) {
return post('deactivate', { activation_id: id, fingerprint });
}
Call POST /v1/refresh in the background once a day when online. Verify a new certificate before replacing the previous one. Immediately persist a blocked state on revoked, suspended or expired, retain the ID and continue refreshing. For released, unknown_activation or wrong_machine, clear the activation and offer to activate again. A network failure or 429 preserves the previous state according to its lease.
The “Release this machine” action calls POST /v1/deactivate. On 204, clear the certificate and ID without reading a JSON body. An unknown activation or one belonging to a different machine can also be forgotten. On network failure, leave the release pending.