@huzalabs/licence-sdk
v0.1.3
Published
SDK for activating, validating, and enforcing Huzalabs product licenses in JavaScript and TypeScript apps.
Maintainers
Readme
@huzalabs/licence-sdk
JavaScript and TypeScript SDK for activating, validating, and enforcing Huzalabs licenses in client applications.
Install
pnpm add @huzalabs/licence-sdk
npm install @huzalabs/licence-sdk
yarn add @huzalabs/licence-sdkUsage
import { HuzalabsLicenceClient } from "@huzalabs/licence-sdk";
const licence = new HuzalabsLicenceClient({
productId: "inventory-system",
apiUrl: "https://licence.example.com",
publicKey: "-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----",
});
await licence.activate({
licenseKey: "HUZA-A91K-7FQ2-MP8Z-X4LD",
deviceName: "Didier Laptop",
userId: "didier",
email: "[email protected]",
deviceType: "desktop",
});
const validation = await licence.validate({
userId: "didier",
email: "[email protected]",
deviceType: "desktop",
});
const allowed = await licence.hasFeature("reports");API
activate()validate()hasFeature()canUse()incrementUsage()getLicense()clearLicense()
Key Notes
publicKeymust be the real RSA public key used by your licensing API. Do not use placeholder values in production.- Identity-aware policies can send
userId,email,platformId, anddeviceTypeduring activation and validation. - Browser storage is user-controlled. Treat the backend as the final authority for valuable actions, usage enforcement, and entitlement decisions.
- Offline grace mode relies on a signed token. The SDK verifies that token locally before allowing offline access.
- If your product has paid or sensitive features, re-check entitlement on the server for protected operations.
Typical Flow
- Activate a device with a license key.
- Validate online and cache the signed token.
- Check features with
hasFeature(). - Track usage with
incrementUsage(). - Fall back to offline grace only when the signed token remains valid.
