The Node binding ships prebuilt natives, so npm install does not drag node-gyp, Python and a C++ toolchain onto your build machines.
npm install @keynub/licdongleCode language: Bash (bash)
import { Dongle } from '@keynub/licdongle';
const dongle = await Dongle.open(); // first dongle found
if (!(await dongle.isGenuine())) throw new Error('no genuine KeyNub');
await dongle.sessionOpen();
const license = await dongle.recordRead('license');
await dongle.close();Code language: JavaScript (javascript)
Electron: check in the main process
This is the one Electron-specific thing worth saying. Do the dongle work in the main process, not the renderer. A renderer is a browser context: its JavaScript is shipped as readable source inside your app bundle, and anyone can open devtools against it. Anything you decide in the renderer, the user can re-decide.
Better still, decrypt the data your application needs in the main process and pass the result over IPC, rather than passing a boolean the renderer is trusted to honour.
And the rule that matters in every language: do not branch on a boolean. Encrypt data your program genuinely needs with appEncrypt at build time and decrypt it through the dongle at run time, so removing the check leaves the program with nothing to compute rather than a working unlicensed copy.