ante-erp-cli 1.11.42 → 1.11.43

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ante-erp-cli",
3
- "version": "1.11.42",
3
+ "version": "1.11.43",
4
4
  "description": "Comprehensive CLI tool for managing ANTE ERP self-hosted installations",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,6 +8,7 @@ import { pullImagesSilent, stopServicesSilent, startServicesSilent, waitForServi
8
8
  import { backup } from './backup.js';
9
9
  import { getCurrentVersion, getLatestVersion } from './update-cli.js';
10
10
  import { generateDockerCompose } from '../templates/docker-compose.yml.js';
11
+ import { generateSecurePassword } from '../utils/password.js';
11
12
 
12
13
  /**
13
14
  * Check if gate-app, guardian-app, facial-web, or pos-app is installed by checking docker-compose.yml
@@ -236,6 +237,83 @@ COMPANY_ID=1
236
237
  writeFileSync(envFile, envContent);
237
238
  }
238
239
 
240
+ /**
241
+ * Ensure customer app JWT configuration exists in .env file
242
+ * @param {string} envFile - Path to .env file
243
+ */
244
+ function ensureCustomerAppJwtConfig(envFile) {
245
+ let envContent = readFileSync(envFile, 'utf8');
246
+ let modified = false;
247
+
248
+ // Check if CUSTOMER_APP_JWT_SECRET exists
249
+ if (!envContent.includes('CUSTOMER_APP_JWT_SECRET=')) {
250
+ console.log('⚙️ Adding missing CUSTOMER_APP_JWT_SECRET...');
251
+
252
+ // Generate new secret
253
+ const customerAppJwtSecret = generateSecurePassword(64);
254
+
255
+ // Find the ENCRYPTION_KEY line and add after it
256
+ if (envContent.includes('ENCRYPTION_KEY=')) {
257
+ envContent = envContent.replace(
258
+ /(ENCRYPTION_KEY=.*\n)/,
259
+ `$1\n# Customer App JWT Configuration\nCUSTOMER_APP_JWT_SECRET=${customerAppJwtSecret}\n`
260
+ );
261
+ } else {
262
+ // Fallback: add to security keys section or end of file
263
+ envContent += `\n# Customer App JWT Configuration\nCUSTOMER_APP_JWT_SECRET=${customerAppJwtSecret}\n`;
264
+ }
265
+ modified = true;
266
+ }
267
+
268
+ // Check if CUSTOMER_APP_JWT_EXPIRY exists
269
+ if (!envContent.includes('CUSTOMER_APP_JWT_EXPIRY=')) {
270
+ console.log('⚙️ Adding CUSTOMER_APP_JWT_EXPIRY...');
271
+ envContent = envContent.replace(
272
+ /(CUSTOMER_APP_JWT_SECRET=.*\n)/,
273
+ `$1CUSTOMER_APP_JWT_EXPIRY=1y\n`
274
+ );
275
+ modified = true;
276
+ } else {
277
+ // Update old expiry value (15m -> 1y)
278
+ if (envContent.includes('CUSTOMER_APP_JWT_EXPIRY=15m')) {
279
+ console.log('⚙️ Updating CUSTOMER_APP_JWT_EXPIRY from 15m to 1y...');
280
+ envContent = envContent.replace(
281
+ /CUSTOMER_APP_JWT_EXPIRY=15m/,
282
+ 'CUSTOMER_APP_JWT_EXPIRY=1y'
283
+ );
284
+ modified = true;
285
+ }
286
+ }
287
+
288
+ // Check if CUSTOMER_APP_REFRESH_TOKEN_EXPIRY exists
289
+ if (!envContent.includes('CUSTOMER_APP_REFRESH_TOKEN_EXPIRY=')) {
290
+ console.log('⚙️ Adding CUSTOMER_APP_REFRESH_TOKEN_EXPIRY...');
291
+ envContent = envContent.replace(
292
+ /(CUSTOMER_APP_JWT_EXPIRY=.*\n)/,
293
+ `$1CUSTOMER_APP_REFRESH_TOKEN_EXPIRY=1y\n`
294
+ );
295
+ modified = true;
296
+ } else {
297
+ // Update old expiry value (30d -> 1y)
298
+ if (envContent.includes('CUSTOMER_APP_REFRESH_TOKEN_EXPIRY=30d')) {
299
+ console.log('⚙️ Updating CUSTOMER_APP_REFRESH_TOKEN_EXPIRY from 30d to 1y...');
300
+ envContent = envContent.replace(
301
+ /CUSTOMER_APP_REFRESH_TOKEN_EXPIRY=30d/,
302
+ 'CUSTOMER_APP_REFRESH_TOKEN_EXPIRY=1y'
303
+ );
304
+ modified = true;
305
+ }
306
+ }
307
+
308
+ // Write back if modified
309
+ if (modified) {
310
+ writeFileSync(envFile, envContent);
311
+ console.log('✅ Customer app JWT configuration updated');
312
+ }
313
+
314
+ return modified;
315
+ }
316
+
239
317
  /**
240
318
  * Format step title with numbering
241
319
  * @param {number} step - Current step number
@@ -298,6 +376,10 @@ export async function update(options) {
298
376
  // POS App health check removed - not required
299
377
  if (!options.skipCleanup) totalSteps++; // Cleanup step
300
378
 
379
+ // Ensure customer app JWT configuration exists (run before tasks)
380
+ console.log(chalk.gray('Checking customer app JWT configuration...'));
381
+ ensureCustomerAppJwtConfig(envFile);
382
+
301
383
  // Pre-calculate step numbers for each task (fixes step numbering bug)
302
384
  let currentStep = 0;
303
385
  const stepPreStart = !options.skipBackup ? ++currentStep : null;
@@ -134,6 +134,9 @@ services:
134
134
  JWT_EXPIRATION: \${JWT_EXPIRATION:-24h}
135
135
  DEVELOPER_KEY: \${DEVELOPER_KEY}
136
136
  ENCRYPTION_KEY: \${ENCRYPTION_KEY}
137
+ CUSTOMER_APP_JWT_SECRET: \${CUSTOMER_APP_JWT_SECRET}
138
+ CUSTOMER_APP_JWT_EXPIRY: \${CUSTOMER_APP_JWT_EXPIRY:-1y}
139
+ CUSTOMER_APP_REFRESH_TOKEN_EXPIRY: \${CUSTOMER_APP_REFRESH_TOKEN_EXPIRY:-1y}
137
140
  FRONTEND_URL: \${FRONTEND_URL:-http://localhost:${frontendPort}}
138
141
  API_URL: \${API_URL:-http://localhost:${backendPort}}
139
142
  SOCKET_URL: \${SOCKET_URL:-http://localhost:${backendPort}}
@@ -55,6 +55,11 @@ JWT_EXPIRATION=24h
55
55
  DEVELOPER_KEY=${credentials.developerKey}
56
56
  ENCRYPTION_KEY=${credentials.encryptionKey}
57
57
 
58
+ # Customer App JWT Configuration
59
+ CUSTOMER_APP_JWT_SECRET=${credentials.customerAppJwtSecret}
60
+ CUSTOMER_APP_JWT_EXPIRY=1y
61
+ CUSTOMER_APP_REFRESH_TOKEN_EXPIRY=1y
62
+
58
63
  # ------------------------------------------------------------------------------
59
64
  # APPLICATION URLs
60
65
  # ------------------------------------------------------------------------------
@@ -36,6 +36,7 @@ export function generateCredentials() {
36
36
  jwtSecret: generateSecurePassword(64),
37
37
  developerKey: generateRandomHex(16),
38
38
  encryptionKey: generateRandomHex(16),
39
+ customerAppJwtSecret: generateSecurePassword(64),
39
40
  };
40
41
  }
41
42