SDKs

KeyGrant has six SDKs, and all of them share one set of calls and one set of rules. Pick the one for your app's language; How every SDK behaves has the rules they share.

An SDK is optional. A lease is a standard JWT that any language can verify with the product's public key (Lease format), and every call an SDK makes is a plain HTTPS request (Client endpoints). An SDK adds everything around those calls:

  • activation, storing the license and identifying the device;
  • renewing the lease before it runs out, and trials;
  • failing in favor of the customer when KeyGrant cannot be reached.

The SDKs

SDKPackageNeedsPlatformsGet it from
Electron / TypeScript @keygrant/electron 0.9.0 Node.js 20 Windows, macOS, Linux npm
.NET KeyGrant.Licensing 0.8.0 .NET 8 Windows, macOS, Linux NuGet
Rust keygrant 0.8.0 Rust 1.86 Windows, macOS, Linux crates.io
Swift KeyGrant 0.8.0 Swift 6 macOS 12, Linux GitHub, keygrantdev/keygrant-swift
C++ keygrant 0.8.0 C++17, CMake 3.20 Windows, macOS, Linux GitHub, keygrantdev/keygrant-cpp
Dart / Flutter keygrant 0.1.0 Flutter 3.47 iOS, iPadOS, Android, Windows, macOS, Linux pub.dev
  • License: all six are MIT licensed. Each SDK's page shows how to add it.
  • What changed: the changelog says what changed and when, and each SDK's page links to its own release notes.

What every SDK shares

  • The same calls, named in each language's own way (below).
  • The same status: six states and ten reasons, with the same flags and fields (States and reasons).
  • The same words: states, reasons and errors are the server's. The Electron SDK uses them as its names.
  • The same defaults: major version 1 (0 reads as 1), device hold on, a 15-second request timeout.
  • The same key set: a lease verifies with the key its kid names, or else with each (Rotating the signing key).
  • The same rules for going online, and the same waits after a failed check-in (Offline validation & grace).
  • The same storage: every SDK reads the stored license another SDK wrote (Where the license is stored).
  • The same device identity on a computer: the machine ID, hashed, or else the host name. Phones have their own (Dart / Flutter).

And the same optional features, each explained once in How every SDK behaves:

Which version of each SDK has them is in Which version has what.

The calls in each language

Electron.NETRustSwiftC++Dart
activate(key)ActivateAsync(key)activate(&key)activate(key)activate(key)activate(key)
status()StatusAsync()status(false)status()status()status()
refresh()RefreshAsync()refresh()refresh()refresh()refresh()
startTrial()StartTrialAsync()start_trial()startTrial()startTrial()startTrial()
deactivate()DeactivateAsync()deactivate()deactivate()deactivate()deactivate()
has(code)HasAsync(code)has(code)has(_:)has(code)has(code)
require(code)RequireAsync(code)require(code)require(_:)require(code)require(code)
upgradeUrl(link)UpgradeUrlAsync(link)upgrade_url(link)upgradeURL(paymentLink:)upgradeUrl(link)upgradeUrl(paymentLink)
activate(key, options)ActivateAsync(key, options)activate_with(&key, &options)activate(key, email:code:)activate(key, options)activate(key, email:, code:)
importLicenseFile(content)ImportLicenseFileAsync(content)import_license_file(content)importLicenseFile(_:)importLicenseFile(content)importLicenseFile(text), importLicenseFileBytes(bytes)
removeLicenseFile()RemoveLicenseFileAsync()remove_license_file()removeLicenseFile()removeLicenseFile()removeLicenseFile()
use(meter, n)UseAsync(meter, n)use_meter(meter, n)use(_:_:)use(meter, n)use(meter, [n])
pickUp(email)PickUpAsync(email)pick_up(email)pickUp(email:)pickUp(email)pickUp(email)
pickUp(email, code)PickUpAsync(email, code)pick_up_with_code(email, code)pickUp(email:code:)pickUp(email, code)confirmPickUp(email, code)
restoreByEmail(email, code)RestoreByEmailAsync(email, code)restore_by_email(email, code)restoreByEmail(email:code:)restoreByEmail(email, code)restoreByEmail(email, code)
  • Asynchronous: the Electron, .NET, Swift and Dart SDKs. Blocking: the Rust and C++ SDKs, so call them off the UI thread.
  • One call at a time: in every SDK, calls on one instance run one at a time, except has, require, the upgrade link and the two pickUp asks, which only read and run beside any call. Create one instance per process.