mmaietta / example-electron-license-activation

An example of how to implement software licensing and device activation in an Electron application

Home Page:https://keygen.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example Electron License Manager

A minimal Electron v12 + React v17 app built with Parcel, showcasing how to implement an in-app software licensing portal with the following functionality:

  1. License key validation
  2. Device fingerprinting and activation
  3. Device management and deactivation
  4. Signature verification
  5. Auto-updates

image

Running the example

First up, configure a couple application variables. The values below, embedded within the app, are for our demo account. Feel free to find/replace to your own account's values.

# Your Keygen account's DER encoded Ed25519 verify key
KEYGEN_VERIFY_KEY="MCowBQYDK2VwAyEA6GAeSLaTg7pSAkX9B5cemD0G0ixCV8/YIwRgFHnO54g="

# Your Keygen account ID
KEYGEN_ACCOUNT_ID="1fddcec8-8dd3-4d8d-9b16-215cac0f9b52"

# Your Keygen product ID
KEYGEN_PRODUCT_ID="7071feff-b5f3-434a-83c1-3ab3f3592325"

Next, install dependencies with yarn:

yarn

Then start the app in dev mode:

yarn dev

Configuring a license policy

Visit your dashboard and create a new policy with the following attributes:

{
  "requireFingerprintScope": true,
  "maxMachines": 5,
  "concurrent": false,
  "floating": true,
  "strict": true
}

The maxMachines value can be whatever you prefer. The example should also work for a non-floating policy.

Creating an activation token

In order to allow a license to perform machine activations and deactivations, you will need to create a new activation token. Activation tokens allow a limited number of machine activations for a single license, which make them ideal for performing activations from a client-side environment.

⚠️ This example assumes that, once created, the activation token be added into the license's metadata attribute under the token key: ⚠️

{
  "metadata": {
    "token": "activ-abc8f8323c680b93082fc5fdb3abcb31v3"
  }
}

We're doing this so that the end-user does not need to worry about entering the activation token, or that it even exists. Alternatively, you could adjust the code to prompt the user for this value, similary to how we're already prompting for their license key.

Building and packaging

To build the app:

yarn build

To run the latest build:

yarn start

To package the app:

yarn dist

Questions?

Reach out at support@keygen.sh if you have any questions or concerns!

About

An example of how to implement software licensing and device activation in an Electron application

https://keygen.sh

License:MIT License


Languages

Language:JavaScript 78.7%Language:SCSS 19.0%Language:HTML 2.3%