@yobytechautomation/config-lib 0.2.5 → 0.2.7

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.
@@ -40,6 +40,7 @@ exports.BASE_CONFIG_SERVICE = exports.BaseConfigServiceImpl = void 0;
40
40
  const axios_1 = __importDefault(require("axios"));
41
41
  const fs = __importStar(require("fs"));
42
42
  const path = __importStar(require("path"));
43
+ const os = __importStar(require("os"));
43
44
  class BaseConfigServiceImpl {
44
45
  constructor() {
45
46
  this.env = process.env;
@@ -83,7 +84,7 @@ class BaseConfigServiceImpl {
83
84
  const part2 = 'd2F0ZXJhdXRvLnlvYnl0ZWNo';
84
85
  const part3 = 'LmluL2xpY2Vuc2UvY2hlY2s=';
85
86
  const url = Buffer.from(part1 + part2 + part3, 'base64').toString('utf-8');
86
- const secret = 'my_super_secret_123';
87
+ const secret = process.env.LICENSE_SECRET;
87
88
  const res = await axios_1.default.get(url, {
88
89
  headers: {
89
90
  'x-api-key': apiKey,
@@ -95,9 +96,10 @@ class BaseConfigServiceImpl {
95
96
  if (status !== 'active') {
96
97
  throw new Error(`License ${status}. Please contact vendor.`);
97
98
  }
98
- // SAVE CACHE
99
+ const machineId = os.hostname();
99
100
  fs.writeFileSync(cachePath, JSON.stringify({
100
101
  lastValidated: new Date().toISOString(),
102
+ machineId,
101
103
  }));
102
104
  console.log('✅ License validated (online)');
103
105
  }
@@ -105,6 +107,9 @@ class BaseConfigServiceImpl {
105
107
  console.log('⚠️ Server not reachable, checking cache...');
106
108
  if (fs.existsSync(cachePath)) {
107
109
  const data = JSON.parse(fs.readFileSync(cachePath, 'utf-8'));
110
+ if (data.machineId !== os.hostname()) {
111
+ throw new Error('License cache copied from another machine');
112
+ }
108
113
  const last = new Date(data.lastValidated);
109
114
  const now = new Date();
110
115
  const diffHours = (now.getTime() - last.getTime()) / (1000 * 60 * 60);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yobytechautomation/config-lib",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
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",