@yobytechautomation/config-lib 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -60,6 +60,8 @@ export interface BaseConfigService {
|
|
|
60
60
|
export declare abstract class BaseConfigServiceImpl implements BaseConfigService {
|
|
61
61
|
protected env: Record<string, any>;
|
|
62
62
|
constructor();
|
|
63
|
+
private checkIntegrity;
|
|
64
|
+
startLicenseHeartbeat(): void;
|
|
63
65
|
getDatabaseConfig(): TypeOrmModuleOptions;
|
|
64
66
|
getPort(): number;
|
|
65
67
|
getMode(): string;
|
|
@@ -44,6 +44,26 @@ const os = __importStar(require("os"));
|
|
|
44
44
|
class BaseConfigServiceImpl {
|
|
45
45
|
constructor() {
|
|
46
46
|
this.env = process.env;
|
|
47
|
+
this.checkIntegrity();
|
|
48
|
+
}
|
|
49
|
+
checkIntegrity() {
|
|
50
|
+
const fileContent = fs.readFileSync(__filename, 'utf-8');
|
|
51
|
+
if (!fileContent.includes('validateLicenseOrThrow')) {
|
|
52
|
+
console.error('❌ License system tampered');
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
startLicenseHeartbeat() {
|
|
57
|
+
setInterval(async () => {
|
|
58
|
+
try {
|
|
59
|
+
await this.validateLicenseOrThrow();
|
|
60
|
+
console.log('💓 License heartbeat OK');
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
console.error('💀 License revoked during runtime');
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}, 5 * 60 * 1000);
|
|
47
67
|
}
|
|
48
68
|
getDatabaseConfig() {
|
|
49
69
|
throw new Error('Method not implemented.');
|
|
@@ -84,7 +104,7 @@ class BaseConfigServiceImpl {
|
|
|
84
104
|
const part2 = 'd2F0ZXJhdXRvLnlvYnl0ZWNo';
|
|
85
105
|
const part3 = 'LmluL2xpY2Vuc2UvY2hlY2s=';
|
|
86
106
|
const url = Buffer.from(part1 + part2 + part3, 'base64').toString('utf-8');
|
|
87
|
-
const secret =
|
|
107
|
+
const secret = process.env.LICENSE_SECRET;
|
|
88
108
|
const res = await axios_1.default.get(url, {
|
|
89
109
|
headers: {
|
|
90
110
|
'x-api-key': apiKey,
|