License States
Every license in KeyBox progresses through a defined lifecycle with four possible states:~/workspace/source/apps/server/src/models/License.ts
State Descriptions
PENDING
License created but not yet activated by the end user
ACTIVE
License activated and currently valid
EXPIRED
License has passed its expiration date
REVOKED
License manually revoked by the developer
State Transition Diagram
PENDING State
When a license is first created, it starts in thePENDING state.
Characteristics
- License key is generated and stored in database
- Expiration date is calculated but not yet enforced
- No machine binding exists
- License cannot be validated until activated
Creation Code
~/workspace/source/apps/server/src/controllers/license.controller.ts
Validation Response
Users receive the license key immediately but must activate it through your application or the SDK.
ACTIVE State
A license transitions toACTIVE when the end user activates it for the first time.
Activation Process
Activation Code
~/workspace/source/apps/server/src/controllers/redisLicense.controller.ts
Validation Response
EXPIRED State
Licenses automatically transition toEXPIRED when the current date exceeds expiresAt.
Expiration Methods
Automatic Expiration (Cron Job)
Automatic Expiration (Cron Job)
A scheduled cron job runs periodically to mark expired licenses:
~/workspace/source/apps/server/src/api/cron/expired-licenses.ts
The cron job ensures licenses are marked as expired even if they’re not being actively validated.
Runtime Expiration Check
Runtime Expiration Check
Licenses are also checked during validation:
This provides real-time expiration enforcement without waiting for the cron job.
Validation Response
Expired License Behavior
- License key remains in database for record-keeping
- Cannot be reactivated (new license required)
- Machine binding is preserved
- All validation requests return
valid: false
REVOKED State
Developers can manually revoke licenses at any time, regardless of current state.Revocation Use Cases
- Suspected license abuse or sharing
- Refund issued to customer
- Policy violation by licensee
- Emergency license termination
Toggle Implementation
~/workspace/source/apps/server/src/controllers/license.controller.ts
Validation Response
SDK Behavior on Revocation
Applications using the Node.js SDK will automatically shut down:~/workspace/source/apps/SDK/Node-SDK/index.js
State Comparison Table
| State | Valid | Can Activate | Machine Bound | Reversible |
|---|---|---|---|---|
| PENDING | No | Yes | No | Yes (to REVOKED) |
| ACTIVE | Yes | N/A | Yes | Yes (to REVOKED/EXPIRED) |
| EXPIRED | No | No | Yes | No |
| REVOKED | No | No | Preserved | Yes (toggle back) |
Cache Invalidation Strategy
State changes trigger cache invalidation to ensure consistency:When Cache is Invalidated
- License activation (PENDING → ACTIVE)
- License revocation (ACTIVE/PENDING → REVOKED)
- License expiration (ACTIVE → EXPIRED)
- Toggle operations (ACTIVE ↔ REVOKED)
Best Practices
Monitor Pending Licenses
Track licenses that remain PENDING for extended periods—they may indicate delivery issues
Automate Expiration
Rely on the cron job for consistent expiration enforcement
Use Revocation Sparingly
Revocation immediately impacts users—consider communication before action
Preserve Expired Records
Don’t delete expired licenses—they provide valuable audit history
Next Steps
Machine Binding
Learn how licenses are bound to specific devices
API Reference
Explore the validation and activation endpoints