Skip to content

chore: update header files #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 111 additions & 6 deletions examples/LexActivator.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ typedef void (LA_CC *ReleaseCallbackType)(int, Release*, void*);
This function must be called on every start of your program
before any other functions are called.

NOTE: This function is deprecated. Use SetProductData() instead.

PARAMETERS:
* filePath - absolute path of the product file (Product.dat)

Expand Down Expand Up @@ -138,11 +140,11 @@ LEXACTIVATOR_API int LA_CC SetProductData(CSTRTYPE productData);
re-activation on every start of the application and should only be used in floating
licenses.

- LA_ALL_USERS: This flag is specifically designed for Windows and should be used
- LA_ALL_USERS: This flag is specifically designed for Windows and macOS and should be used
for system-wide activations.

RETURN CODES: LA_OK, LA_E_WMIC, LA_E_PRODUCT_FILE, LA_E_PRODUCT_DATA, LA_E_PRODUCT_ID,
LA_E_SYSTEM_PERMISSION
LA_E_SYSTEM_PERMISSION, LA_E_FILE_PERMISSION

NOTE: If this function fails to set the product id, none of the other
functions will work.
Expand Down Expand Up @@ -247,6 +249,8 @@ LEXACTIVATOR_API int LA_CC SetLicenseKey(CSTRTYPE licenseKey);
This function must be called before ActivateLicense() or IsLicenseGenuine()
function if 'requireAuthentication' property of the license is set to true.

NOTE: This function is deprecated. Use AuthenticateUser() instead.

PARAMETERS:
* email - user email address.
* password - user password.
Expand Down Expand Up @@ -331,6 +335,8 @@ LEXACTIVATOR_API int LA_CC SetTrialActivationMetadata(CSTRTYPE key, CSTRTYPE val
The app version appears along with the activation details in dashboard. It
is also used to generate app analytics.

NOTE: This function is deprecated. Use SetReleaseVersion() instead.

PARAMETERS:
* appVersion - string of maximum length 256 characters.

Expand Down Expand Up @@ -492,6 +498,8 @@ LEXACTIVATOR_API int LA_CC GetProductMetadata(CSTRTYPE key, STRTYPE value, uint3

PURPOSE: Gets the product version name.

NOTE: This function is deprecated. Use GetLicenseEntitlementSetName() instead.

PARAMETERS:
* name - pointer to a buffer that receives the value of the string
* length - size of the buffer pointed to by the name parameter
Expand All @@ -506,10 +514,12 @@ LEXACTIVATOR_API int LA_CC GetProductVersionName(STRTYPE name, uint32_t length);

PURPOSE: Gets the product version display name.

NOTE: This function is deprecated. Use GetLicenseEntitlementSetDisplayName() instead.

PARAMETERS:
* displayName - pointer to a buffer that receives the value of the string
* length - size of the buffer pointed to by the displayName parameter

RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED, LA_E_PRODUCT_VERSION_NOT_LINKED,
LA_E_BUFFER_SIZE
*/
Expand All @@ -520,6 +530,8 @@ LEXACTIVATOR_API int LA_CC GetProductVersionDisplayName(STRTYPE displayName, uin

PURPOSE: Gets the product version feature flag.

NOTE: This function is deprecated. Use GetFeatureEntitlement() instead.

PARAMETERS:
* name - name of the feature flag
* enabled - pointer to the integer that receives the value - 0 or 1
Expand All @@ -531,6 +543,70 @@ LEXACTIVATOR_API int LA_CC GetProductVersionDisplayName(STRTYPE displayName, uin
*/
LEXACTIVATOR_API int LA_CC GetProductVersionFeatureFlag(CSTRTYPE name, uint32_t *enabled, STRTYPE data, uint32_t length);

/*
FUNCTION: GetLicenseEntitlementSetName()

PURPOSE: Gets the license entitlement set name.

PARAMETERS:
* name - pointer to a buffer that receives the value of the string
* length - size of the buffer pointed to by the name parameter

RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED, LA_E_BUFFER_SIZE,
LA_E_ENTITLEMENT_SET_NOT_LINKED
*/
LEXACTIVATOR_API int LA_CC GetLicenseEntitlementSetName(STRTYPE name, uint32_t length);

/*
FUNCTION: GetLicenseEntitlementSetDisplayName()

PURPOSE: Gets the license entitlement set display name.

PARAMETERS:
* displayName - pointer to a buffer that receives the value of the string
* length - size of the buffer pointed to by the displayName parameter

RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED, LA_E_BUFFER_SIZE,
LA_E_ENTITLEMENT_SET_NOT_LINKED
*/
LEXACTIVATOR_API int LA_CC GetLicenseEntitlementSetDisplayName(STRTYPE displayName, uint32_t length);

/*
FUNCTION: GetFeatureEntitlements()

PURPOSE: Gets the feature entitlements associated with the license.

Feature entitlements can be linked directly to a license (license feature entitlements)
or via entitlement sets. If a feature entitlement is defined in both, the value from
the license feature entitlement takes precedence, overriding the entitlement set value.

PARAMETERS:
* featureEntitlements - pointer to the struct that receives the values of the feature entitlements.
* length - size of the featureEntitlements array.

RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED,
LA_E_BUFFER_SIZE, LA_E_FEATURE_ENTITLEMENTS_INVALID
*/
LEXACTIVATOR_API int LA_CC GetFeatureEntitlements(FeatureEntitlement* featureEntitlements, uint32_t length);

/*
FUNCTION: GetFeatureEntitlement()

PURPOSE: Gets the feature entitlement associated with the license.

Feature entitlements can be linked directly to a license (license feature entitlements)
or via entitlement sets. If a feature entitlement is defined in both, the value from
the license feature entitlement takes precedence, overriding the entitlement set value.

PARAMETERS:
* featureName - name of the feature
* featureEntitlement - pointer to the struct that receives the values of the feature entitlement

RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_TIME, LA_E_TIME_MODIFIED,
LA_E_BUFFER_SIZE, LA_E_FEATURE_ENTITLEMENT_NOT_FOUND, LA_E_FEATURE_ENTITLEMENTS_INVALID
*/
LEXACTIVATOR_API int LA_CC GetFeatureEntitlement(CSTRTYPE featureName, FeatureEntitlement* featureEntitlement);

/*
FUNCTION: GetLicenseMetadata()

Expand Down Expand Up @@ -647,6 +723,33 @@ LEXACTIVATOR_API int LA_CC GetLicenseCreationDate(uint32_t *creationDate);
*/
LEXACTIVATOR_API int LA_CC GetLicenseActivationDate(uint32_t *activationDate);

/*
FUNCTION: GetActivationCreationDate()

PURPOSE: Gets the activation creation date timestamp for the current activation.

PARAMETERS:
* activationCreationDate - pointer to the integer that receives the value

RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_LICENSE_KEY, LA_E_TIME, LA_E_TIME_MODIFIED
*/

LEXACTIVATOR_API int LA_CC GetActivationCreationDate(uint32_t *activationCreationDate);

/*
FUNCTION: GetActivationLastSyncedDate()

PURPOSE: Gets the activation last synced date timestamp.

Initially, this timestamp matches the activation creation date, and then updates with each successful server sync.

PARAMETERS:
* activationLastSyncedDate - pointer to the integer that receives the value

RETURN CODES: LA_OK, LA_FAIL, LA_E_PRODUCT_ID, LA_E_LICENSE_KEY, LA_E_TIME, LA_E_TIME_MODIFIED
*/
LEXACTIVATOR_API int LA_CC GetActivationLastSyncedDate(uint32_t *activationLastSyncedDate);

/*
FUNCTION: GetLicenseExpiryDate()

Expand Down Expand Up @@ -946,6 +1049,8 @@ LEXACTIVATOR_API int LA_CC GetLibraryVersion(STRTYPE libraryVersion, uint32_t le
This function should only be used if you manage your releases through
Cryptlex release management API.

NOTE: This function is deprecated. Use CheckReleaseUpdate() instead.

PARAMETERS:
* platform - release platform e.g. windows, macos, linux
* version - current release version
Expand Down Expand Up @@ -1033,7 +1138,7 @@ LEXACTIVATOR_API int LA_CC AuthenticateUserWithIdToken(CSTRTYPE idToken);
RETURN CODES: LA_OK, LA_EXPIRED, LA_SUSPENDED, LA_E_REVOKED, LA_FAIL, LA_E_PRODUCT_ID,
LA_E_INET, LA_E_VM, LA_E_TIME, LA_E_ACTIVATION_LIMIT, LA_E_FREE_PLAN_ACTIVATION_LIMIT_REACHED, LA_E_SERVER, LA_E_CLIENT,
LA_E_AUTHENTICATION_FAILED, LA_E_LICENSE_TYPE, LA_E_COUNTRY, LA_E_IP, LA_E_RATE_LIMIT, LA_E_LICENSE_KEY,
LA_E_RELEASE_VERSION_NOT_ALLOWED, LA_E_RELEASE_VERSION_FORMAT
LA_E_RELEASE_VERSION_NOT_ALLOWED, LA_E_RELEASE_VERSION_FORMAT, LA_E_LICENSE_NOT_EFFECTIVE

*/
LEXACTIVATOR_API int LA_CC ActivateLicense();
Expand Down Expand Up @@ -1114,7 +1219,7 @@ LEXACTIVATOR_API int LA_CC GenerateOfflineDeactivationRequest(CSTRTYPE filePath)

RETURN CODES: LA_OK, LA_EXPIRED, LA_SUSPENDED, LA_GRACE_PERIOD_OVER, LA_FAIL,
LA_E_PRODUCT_ID, LA_E_LICENSE_KEY, LA_E_TIME, LA_E_TIME_MODIFIED, LA_E_MACHINE_FINGERPRINT,
LA_E_RELEASE_VERSION_NOT_ALLOWED, LA_E_OS_USER
LA_E_RELEASE_VERSION_NOT_ALLOWED, LA_E_OS_USER, LA_E_FEATURE_ENTITLEMENTS_INVALID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahmad-kemsan what is this error code

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adnan-kamili In case the feature entitlement token is invalid (maybe does not belong to that license or activation or maybe tampered. JWT can be valid but the activationId may not match), we return this error. We even allow server sync on so that sync can make sure the correct feature entitlement is placed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


NOTE: If application was activated offline using ActivateLicenseOffline() function, you
may want to set grace period to 0 to ignore grace period.
Expand All @@ -1133,7 +1238,7 @@ LEXACTIVATOR_API int LA_CC IsLicenseGenuine();

RETURN CODES: LA_OK, LA_EXPIRED, LA_SUSPENDED, LA_GRACE_PERIOD_OVER, LA_FAIL,
LA_E_PRODUCT_ID, LA_E_LICENSE_KEY, LA_E_TIME, LA_E_TIME_MODIFIED, LA_E_MACHINE_FINGERPRINT,
LA_E_RELEASE_VERSION_NOT_ALLOWED, LA_E_OS_USER
LA_E_RELEASE_VERSION_NOT_ALLOWED, LA_E_OS_USER, LA_E_FEATURE_ENTITLEMENTS_INVALID

NOTE: You may want to set grace period to 0 to ignore grace period.
*/
Expand Down
39 changes: 37 additions & 2 deletions examples/LexStatusCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ enum LexStatusCodes
/*
CODE: LA_E_METADATA_VALUE_LENGTH

MESSAGE: Metadata value length is more than 256 characters.
MESSAGE: Metadata value length is more than 4096 characters.
*/
LA_E_METADATA_VALUE_LENGTH = 65,

Expand Down Expand Up @@ -464,6 +464,13 @@ enum LexStatusCodes
*/
LA_E_CLIENT = 92,

/*
CODE: LA_E_ACCOUNT_ID

MESSAGE: Invalid account ID.
*/
LA_E_ACCOUNT_ID = 93,

/*
CODE: LA_E_LOGIN_TEMPORARILY_LOCKED

Expand Down Expand Up @@ -509,9 +516,37 @@ enum LexStatusCodes
/*
CODE: LA_E_FREE_PLAN_ACTIVATION_LIMIT_REACHED

MESSAGE: The free plan has reached its activation limit.
MESSAGE: The free plan has reached it's activation limit.
*/
LA_E_FREE_PLAN_ACTIVATION_LIMIT_REACHED = 106,

/*
CODE: LA_E_FEATURE_ENTITLEMENTS_INVALID

MESSAGE: Invalid feature entitlements.
*/
LA_E_FEATURE_ENTITLEMENTS_INVALID = 107,

/*
CODE: LA_E_FEATURE_ENTITLEMENT_NOT_FOUND

MESSAGE: The feature entitlement does not exist.
*/
LA_E_FEATURE_ENTITLEMENT_NOT_FOUND = 108,

/*
CODE: LA_E_ENTITLEMENT_SET_NOT_LINKED

MESSAGE: No entitlement set is linked to the license.
*/
LA_E_ENTITLEMENT_SET_NOT_LINKED = 109,

/*
CODE: LA_E_LICENSE_NOT_EFFECTIVE

MESSAGE: The license cannot be activated before its effective date.
*/
LA_E_LICENSE_NOT_EFFECTIVE = 110,
};

#endif // LEX_STATUS_CODES_H
79 changes: 79 additions & 0 deletions examples/LexTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,30 @@
#define MAX_RELEASE_PLATFORMS 10
#define MAX_LICENSE_KEYS 100
#define MAX_RELEASE_FILES 10
#define MAX_FEATURE_ENTITLEMENTS 200

#ifdef _WIN32
typedef wchar_t CHARTYPE;
#else
typedef char CHARTYPE;
#endif

/*
STRUCT: ReleaseFile

MEMBERS:
* size - Size of the file in bytes.
* downloads - Number of times this file has been downloaded.
* secured - Whether the file is secured (1) or not (0).
* id - Unique identifier for the release file.
* name - Name of the file.
* url - Download URL of the file.
* extension - File extension.
* checksum - Checksum of the file for integrity verification.
* releaseId - Unique identifier of the release this file belongs to.
* createdAt - Timestamp when the file was created.
* updatedAt - Timestamp when the file was last updated.
*/
typedef struct
{
int size;
Expand All @@ -31,6 +48,25 @@ typedef struct
CHARTYPE updatedAt[BUFFER_SIZE_256];
} ReleaseFile;

/*
STRUCT: Release

MEMBERS:
* totalFiles - Number of files in this release.
* isPrivate - Whether the release is private (1) or public (0).
* published - Whether the release is published (1) or not (0).
* id - Unique identifier of the release.
* createdAt - Timestamp when the release was created.
* updatedAt - Timestamp when the release was last updated.
* name - Name of the release.
* channel - Release channel (e.g., stable, beta).
* version - Version of the release (e.g., 1.0.0).
* notes - Release notes.
* publishedAt - Timestamp when the release was published.
* productId - Unique identifier of the associated product.
* platforms - Supported platforms (e.g., windows, linux).
* files - Array of release files included in the release.
*/
typedef struct
{
int totalFiles;
Expand All @@ -49,6 +85,17 @@ typedef struct
ReleaseFile files[MAX_RELEASE_FILES];
} Release;

/*
STRUCT: OrganizationAddress

MEMBERS:
* addressLine1 - First line of the address.
* addressLine2 - Second line of the address.
* city - City name.
* state - State.
* country - Country name.
* postalCode - Postal or ZIP code.
*/
typedef struct
{
CHARTYPE addressLine1[BUFFER_SIZE_256];
Expand All @@ -59,12 +106,44 @@ typedef struct
CHARTYPE postalCode[BUFFER_SIZE_256];
} OrganizationAddress;

/*
STRUCT: FeatureEntitlement

MEMBERS:
* featureName - Name of the feature.
* featureDisplayName - Display name of the feature.
* value - Value associated with the feature.
*/
typedef struct
{
CHARTYPE featureName[BUFFER_SIZE_256];
CHARTYPE featureDisplayName[BUFFER_SIZE_256];
CHARTYPE value[BUFFER_SIZE_256];
} FeatureEntitlement;

/*
STRUCT: Metadata

MEMBERS:
* key - Key of the metadata.
* value - Value of the metadata.
*/
typedef struct
{
CHARTYPE key[BUFFER_SIZE_256];
CHARTYPE value[BUFFER_SIZE_4096];
} Metadata;

/*
STRUCT: UserLicense

MEMBERS:
* allowedActivations - Maximum number of activations allowed.
* allowedDeactivations - Maximum number of deactivations allowed.
* key - License key.
* type - Type of the license (e.g., "node-locked", "floating").
* metadata - Array of metadata associated with the user's license.
*/
typedef struct
{
int64_t allowedActivations;
Expand Down