Skip to main content

License check

Check whether a grantee is licensed to perform actions in your system.

Features, capabilities, and plans that belong to your user are checkable.

Salable API V2 update

The publicHash and capsHashed properties have been removed and the capabilities and capabilitiesEndDates properties have been consolidated into a single capabilities property. The capabilities contains an array of objects containing the name and expiration date of each capability / feature / plan

import { getGrantee } from '@salable/js';

const { hasCapability } = await getGrantee({
apiKey: 'your-salable-api-key',
productUuid: 'your-products-uuid',
granteeId: 'your-grantees-id',
});

// Check for a capability
const isUserLicensedToPerformAction = hasCapability('acme-inc-whitelabelling');
// or a feature
const isUserLicensedToPerformAction = hasCapability('csv-export');
// or a plan
const isUserLicensedToPerformAction = hasCapability('pro');
Grace Period

If the customer's payment fails, and you would like to give them a grace period to rectify this — you can use the optional grace parameter to extend the license capability check by a specified number of days.

This is not currently supported on @salable/js.

Verifying Signatures

Signatures can be verified using the signature and capabilities from the license check and your organisations public key

ECDSA Encryption and Signatures

We use ECDSA cryptography to generate signatures for license checks. Signatures are signed with a private key (which we keep encrypted on our end) and can be verified using your organisations public key

NOTE: You can request license-check signatures to be encoded in the P1363 encoding using the "sigEncode=P1363" query string in the request

  • The P1363 encoding allows for signature verification on web browsers

Signature verification examples:


import { verifyLicenseCheck } from '@salable/js';

var isValid = await verifyLicenseCheck({
publicKey: 'your_public_key',
signature: 'license_check_signature',
payload: 'license_check_payload'
});