@ultrasoft.cm/license-checker
v1.0.1
Published
π README β @ultrasoft.cm/license-checker Overview
Readme
@ultrasoft.cm/license-checker
π README β @ultrasoft.cm/license-checker Overview
@ultrasoft.cm/license-checker is a lightweight TypeScript library that validates application licenses in Node.js environments. It is designed to work with remote license verification APIs and provides utilities for parsing, caching, and validating license information.
Key features:
π Machine-based license validation (using node-machine-id )
β‘ Lightweight and dependency-minimal
π§ͺ Fully tested with Vitest
π¦ Built with tsup for ESM & CJS support
Installation
Using Yarn
yarn add @ultrasoft.cm/license-checker
Or using npm
npm install @ultrasoft.cm/license-checker
Usage import { LicenseValidator } from "@ultrasoft.cm/license-checker";
async function main() { const licenseKey = "YOUR_LICENSE_KEY";
const validator = new LicenseValidator({ apiUrl: "https://your-license-server.com/verify", cacheDuration: "1h", // cache duration (e.g. 1m, 1h, 1d) });
const result = await validator.validate(licenseKey);
if (result.isValidLicense) { console.log("β License is valid:", result.details); } else { console.error("β Invalid license:", result.code); } }
main();
API LicenseValidator(options) Options Option Type Description apiUrl string The URL of the license verification server cacheDuration string Duration to cache results (e.g. 1m, 1h, 1d) validate(licenseKey: string): Promise
Validates a given license key. Returns an object like:
{ isValidLicense: boolean; details?: any; code?: string; }
Development
Clone the repository and install dependencies:
git clone https://github.com/your-org/license-checker.git cd license-checker yarn install
Build yarn build
This compiles TypeScript with tsup into dist/.
Test
Run once
yarn test
Watch mode
yarn test:watch
Vitest is used for unit testing.
Project Structure license-checker/ βββ src/ # Source TypeScript code βββ tests/ # Vitest test files βββ dist/ # Compiled output (generated) βββ package.json βββ tsconfig.json βββ vitest.config.ts βββ README.md
License
MIT Β© Ultrasoft.cm
