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
| SDK | Package | Needs | Platforms | Get it from |
|---|---|---|---|---|
| Electron / TypeScript | @keygrant/ 0.9.0 | Node.js 20 | Windows, macOS, Linux | npm |
| .NET | KeyGrant. 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
kidnames, 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:
- Keys only their buyer can activate: activation takes the buyer's email and the emailed code, with the same seven refusals (see Who can activate).
- Key pickup: restoring a license by the buyer's email, for an App Store build.
- License files (
.kglicense), the files a customer is sent. They are not the file an SDK stores its state in. - Metered uses: a key's meter is spent before the work it counts, and what is left is read from the status offline (Metered uses).
Which version of each SDK has them is in Which version has what.
The calls in each language
| Electron | .NET | Rust | Swift | C++ | Dart |
|---|---|---|---|---|---|
activate( | Activate | activate( | activate( | activate( | activate( |
status() | Status | status( | status() | status() | status() |
refresh() | Refresh | refresh() | refresh() | refresh() | refresh() |
startTrial() | StartTrial | start_trial() | startTrial() | startTrial() | startTrial() |
deactivate() | Deactivate | deactivate() | deactivate() | deactivate() | deactivate() |
has( | Has | has( | has( | has( | has( |
require( | Require | require( | require( | require( | require( |
upgradeUrl( | UpgradeUrl | upgrade_url( | upgradeURL( | upgradeUrl( | upgradeUrl( |
activate( | Activate | activate_ | activate( | activate( | activate( |
import | Import | import_ | import | import | import, import |
remove | Remove | remove_ | remove | remove | remove |
use( | Use | use_meter( | use( | use( | use( |
pickUp( | PickUp | pick_up( | pickUp( | pickUp( | pickUp( |
pickUp( | PickUp | pick_up_ | pickUp( | pickUp( | confirm |
restore | Restore | restore_ | restore | restore | restore |
- 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 twopickUpasks, which only read and run beside any call. Create one instance per process.