nexus-fca 3.0.3 → 3.0.5

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.
@@ -14,7 +14,8 @@ NEXUS_PERSISTENT_DEVICE=true # Enable consistent device fingerprinting (defau
14
14
  NEXUS_DEVICE_FILE=./device.json # Custom path to device profile file
15
15
 
16
16
  # Single-session guard (built-in)
17
- # Uses SingleSessionGuard with NEXUS_SESSION_LOCK_PATH and NEXUS_FORCE_LOCK
17
+ # Toggle and configure SingleSessionGuard (default OFF)
18
+ NEXUS_SESSION_LOCK_ENABLED=false # Enable with true/1 to turn lock ON
18
19
  NEXUS_SESSION_LOCK_PATH=./lock # Path to session lock file used by SingleSessionGuard
19
20
  NEXUS_FORCE_LOCK=false # Force acquire lock even if lock exists
20
21
 
@@ -62,8 +63,8 @@ const api = await login({
62
63
  // Session stability options
63
64
  persistentDevice: true, // Use consistent device fingerprinting
64
65
  deviceFilePath: './device.json', // Custom device profile path
65
- // Single-session guard is enabled by default internally
66
- // Configure via env: NEXUS_SESSION_LOCK_PATH, NEXUS_FORCE_LOCK
66
+ // Single-session guard (optional toggle)
67
+ sessionLockEnabled: true, // default is OFF; set true or env NEXUS_SESSION_LOCK_ENABLED=true
67
68
 
68
69
  // Connection options
69
70
  region: 'NA', // Set fixed region
package/index.js CHANGED
@@ -1371,12 +1371,19 @@ async function login(loginData, options = {}, callback) {
1371
1371
  mainLogger.info('✅ Session generated successfully');
1372
1372
  mainLogger.info('🔄 Starting bot with generated session (old system)');
1373
1373
 
1374
- // STEP 2: Single session guard before starting bot
1374
+ // STEP 2: Single session guard before starting bot (configurable)
1375
1375
  try {
1376
- const ssg = new SingleSessionGuard({ dataDir: process.env.NEXUS_DATA_DIR });
1377
- ssg.acquire();
1378
- // keep guard reference to release on exit
1379
- global.__NEXUS_SSG__ = ssg;
1376
+ const envLockFlag = process.env.NEXUS_SESSION_LOCK_ENABLED;
1377
+ const lockEnabled = (typeof options.sessionLockEnabled !== 'undefined')
1378
+ ? !!options.sessionLockEnabled
1379
+ : (envLockFlag === '1' || (envLockFlag || '').toLowerCase() === 'true');
1380
+
1381
+ if (lockEnabled) {
1382
+ const ssg = new SingleSessionGuard({ dataDir: process.env.NEXUS_DATA_DIR });
1383
+ ssg.acquire();
1384
+ // keep guard reference to release on exit
1385
+ global.__NEXUS_SSG__ = ssg;
1386
+ }
1380
1387
  } catch (e) {
1381
1388
  mainLogger.error('⚠️ Single session guard blocked start', e.message);
1382
1389
  if (callback) callback(e);
@@ -1426,9 +1433,16 @@ async function login(loginData, options = {}, callback) {
1426
1433
 
1427
1434
  // Direct session authentication using appstate (with single session guard)
1428
1435
  try {
1429
- const ssg = new SingleSessionGuard({ dataDir: process.env.NEXUS_DATA_DIR });
1430
- ssg.acquire();
1431
- global.__NEXUS_SSG__ = ssg;
1436
+ const envLockFlag = process.env.NEXUS_SESSION_LOCK_ENABLED;
1437
+ const lockEnabled = (typeof options.sessionLockEnabled !== 'undefined')
1438
+ ? !!options.sessionLockEnabled
1439
+ : (envLockFlag === '1' || (envLockFlag || '').toLowerCase() === 'true');
1440
+
1441
+ if (lockEnabled) {
1442
+ const ssg = new SingleSessionGuard({ dataDir: process.env.NEXUS_DATA_DIR });
1443
+ ssg.acquire();
1444
+ global.__NEXUS_SSG__ = ssg;
1445
+ }
1432
1446
  } catch (e) {
1433
1447
  mainLogger.error('⚠️ Single session guard blocked start', e.message);
1434
1448
  if (callback) callback(e);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexus-fca",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "Nexus-FCA 3.0 – stable, low-risk Facebook Messenger automation API with integrated secure login (ID / Password / 2FA), adaptive MQTT core, safety orchestration, metrics, and TypeScript support.",
5
5
  "main": "index.js",
6
6
  "repository": {