Documentation menuAPI
API
All exports of @sweberdev/integral and @sweberdev/integral-react.
@sweberdev/integral
| Export | Description |
|---|---|
generateKeyPair({ alg? }) | New key pair as strings { publicKey, privateKey }; alg is "EdDSA" (default) or "ES256" |
upgradeLicense(license, privateKey, { publicKey? }) | Signs an int1 license again as int2 with the same id and data, see Migrating to 2.0 |
ecdsaDerToRaw(der) | Converts a DER ECDSA signature (AWS KMS, Azure, Vault) to the raw form ES256 uses |
publicKeyAlgorithm(key) | "EdDSA" or "ES256" for a public key string |
signLicense(input, privateKey) | Signs a license, returns the license key. id and iat are added if missing; dates may be Date or ISO strings |
verifyLicense(license, options) | { valid: true, license } or { valid: false, reason, license? }. Options: publicKey (string or array), product, now, clockTolerance, revocations, machine |
decodeLicense(license) | Content without checking the signature, or null |
coversRelease(license, releasedAt) | false if the release is after updatesUntil |
definePlans(plans) | Validates and returns plan definitions |
createEntitlements({ plans, license?, fallbackPlan? }) | Entitlements object, see Plans |
resolvePlan(plans, name) | A plan with inherited features and limits |
planFor(plans, feature) | First plan that includes a feature, or null |
EntitlementError | Thrown by require(); has feature and plan |
withOfflineGrace(check, options) | Cache and grace period for online checks, see Offline grace |
memoryStorage(), browserStorage(prefix?) | Storage for withOfflineGrace |
signRevocationList({ ids, product?, iat? }, privateKey) | Signed list of revoked license ids (intr2.…, intr1.… is still read), see Revocation |
verifyRevocationList(token, { publicKey, product? }) | Content of a revocation list, or null if invalid |
machineId(...values) | Anonymous SHA-256 device id for machine |
licenseStatus(license, { now?, warnDays? }) | { state, trial, daysLeft, updatesEnded, updatesDaysLeft } |
bindLicense(license, machine, privateKey, { product?, now? }) | { ok: true, license, payload } with a copy bound to the device, or { ok: false, reason }. See Device activation |
createActivationRequest({ license, machine, label? }), readActivationRequest(token) | Activation request (intq1.…) for offline activation |
publicKeyFromPrivateKey(privateKey) | The public key that belongs to a private key |
LICENSE_PREFIX, REVOCATION_PREFIX, ACTIVATION_PREFIX | "int2", "intr2", "intq1" (LEGACY_LICENSE_PREFIX, LEGACY_REVOCATION_PREFIX: "int1", "intr1") |
Types: LicensePayload, RevocationList, ActivationRequest, BindResult, LicenseStatus, LicenseState, LicenseInput, LicenseVerification, LicenseInvalidReason, Plans, PlanDefinition, ResolvedPlan, Entitlements, LimitCheck, LimitValue, LicenseStorage, CheckOutcome, CachedOutcome.
@sweberdev/integral/polar
| Export | Description |
|---|---|
createPolarClient({ organizationId, benefitId?, sandbox?, baseUrl?, fetch? }) | Client with validate(key, { activationId?, incrementUsage?, conditions? }), activate(key, { label, conditions?, meta? }) and deactivate(key, activationId) |
PolarError | Thrown for server errors; has status |
Types: PolarClient, PolarLicenseKey, PolarActivation, PolarResult, PolarReason.
@sweberdev/integral-react
| Export | Description |
|---|---|
IntegralProvider | Provides an entitlements object |
Feature | name, fallback |
Limit | name, used, amount, fallback; children may be render functions |
useEntitlements(), useFeature(name), useLimit(name, used, amount?) | Hooks |
useLicenseCheck(check, key) | Async check state with refresh() |