fase(17): licensing module with RSA validation
This commit is contained in:
37
dist/modules/licensing/application/LicenseService.js
vendored
Normal file
37
dist/modules/licensing/application/LicenseService.js
vendored
Normal 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;
|
||||
Reference in New Issue
Block a user