@yobytechautomation/config-lib 0.2.7 → 0.2.9

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.');
@@ -85,10 +105,12 @@ class BaseConfigServiceImpl {
85
105
  const part3 = 'LmluL2xpY2Vuc2UvY2hlY2s=';
86
106
  const url = Buffer.from(part1 + part2 + part3, 'base64').toString('utf-8');
87
107
  const secret = process.env.LICENSE_SECRET;
108
+ const machineId = os.hostname();
88
109
  const res = await axios_1.default.get(url, {
89
110
  headers: {
90
111
  'x-api-key': apiKey,
91
112
  'x-license-secret': secret,
113
+ 'x-machine-id': machineId,
92
114
  },
93
115
  timeout: 5000,
94
116
  });
@@ -96,10 +118,10 @@ class BaseConfigServiceImpl {
96
118
  if (status !== 'active') {
97
119
  throw new Error(`License ${status}. Please contact vendor.`);
98
120
  }
99
- const machineId = os.hostname();
121
+ const machineId2 = os.hostname();
100
122
  fs.writeFileSync(cachePath, JSON.stringify({
101
123
  lastValidated: new Date().toISOString(),
102
- machineId,
124
+ machineId: machineId2,
103
125
  }));
104
126
  console.log('✅ License validated (online)');
105
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yobytechautomation/config-lib",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "Shared multi-environment configuration helpers for SDC NestJS services",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",