fase(17): licensing module with RSA validation

This commit is contained in:
debian
2026-03-08 05:20:54 -04:00
parent 1f1678af17
commit 5a28270dc9
45 changed files with 1789 additions and 48 deletions

View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LicenseService = void 0;
const Result_1 = require("../../../shared/domain/Result");
const License_1 = require("../domain/entities/License");
class LicenseService {
constructor(validator) {
this.validator = validator;
this.currentLicense = License_1.License.createFree();
}
getCurrentLicense() {
return this.currentLicense;
}
async activate(licenseKey) {
const result = await this.validator.validate(licenseKey);
if ((0, Result_1.isErr)(result))
return result;
this.currentLicense = result.value;
return result;
}
hasFeature(feature) {
return this.currentLicense.hasFeature(feature);
}
getStatus() {
const license = this.currentLicense;
return {
plan: license.plan.toString(),
organizationName: license.organizationName,
email: license.email,
issuedAt: license.issuedAt.toISOString(),
expiresAt: license.expiresAt?.toISOString() ?? null,
isValid: license.isValid,
features: license.getEntitlements().toArray(),
};
}
}
exports.LicenseService = LicenseService;