nexus-fca 2.0.6 → 2.0.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.
package/index.js CHANGED
@@ -987,28 +987,55 @@ async function login(loginData, options = {}, callback) {
987
987
 
988
988
  // Enhanced login flow for ID/password authentication
989
989
  if (loginData.email || loginData.username || loginData.password) {
990
- mainLogger.info(' Starting secure authentication');
991
- mainLogger.info('�️ Using advanced security protocols');
990
+ mainLogger.info('🔐 Starting secure authentication');
991
+ mainLogger.info('🛡️ Generating secure session with new system');
992
992
 
993
993
  try {
994
+ // STEP 1: Use NEW system ONLY to generate appstate/cookies
994
995
  const result = await integratedNexusLogin({
995
996
  username: loginData.email || loginData.username,
996
997
  password: loginData.password,
997
998
  twofactor: loginData.twofactor || loginData.otp || undefined,
998
999
  _2fa: loginData._2fa || undefined,
999
1000
  appstate: loginData.appState || loginData.appstate || undefined
1000
- }, options);
1001
+ }, { autoStartBot: false }); // ONLY generate cookies, NO bot startup
1001
1002
 
1002
- if (result.success && result.api) {
1003
- // Bot startup completed successfully
1004
- mainLogger.info('✅ Login successful - Bot ready for use');
1005
- if (callback) return callback(null, result.api);
1006
- return result.api;
1007
- } else {
1008
- mainLogger.error('❌ Authentication failed', result.message || result.botError);
1009
- if (callback) return callback(new Error(result.message || result.botError || 'Login failed'));
1010
- throw new Error(result.message || result.botError || 'Login failed');
1003
+ if (!result.success || !result.appstate) {
1004
+ mainLogger.error('❌ Authentication failed', result.message);
1005
+ if (callback) return callback(new Error(result.message || 'Login failed'));
1006
+ throw new Error(result.message || 'Login failed');
1011
1007
  }
1008
+
1009
+ mainLogger.info('✅ Session generated successfully');
1010
+ mainLogger.info('🔄 Starting bot with generated session (old system)');
1011
+
1012
+ // STEP 2: ALWAYS use OLD system for actual login/session/bot
1013
+ const globalOptions = {
1014
+ selfListen: false,
1015
+ selfListenEvent: false,
1016
+ listenEvents: false,
1017
+ listenTyping: false,
1018
+ updatePresence: false,
1019
+ forceLogin: false,
1020
+ autoMarkDelivery: true,
1021
+ autoMarkRead: false,
1022
+ autoReconnect: true,
1023
+ logRecordSize: defaultLogRecordSize,
1024
+ online: true,
1025
+ emitReady: false,
1026
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
1027
+ ...options
1028
+ };
1029
+
1030
+ return loginHelper(
1031
+ result.appstate, // Use generated appstate
1032
+ null, // No email for old system
1033
+ null, // No password for old system
1034
+ globalOptions,
1035
+ callback,
1036
+ null
1037
+ );
1038
+
1012
1039
  } catch (error) {
1013
1040
  mainLogger.error('💥 Login error', error.message);
1014
1041
  if (callback) return callback(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexus-fca",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "A modern, safe, and advanced Facebook Chat API for Node.js with fully integrated Nexus Login System. NPM-ready with ID/password/2FA support, ultra-low ban rate protection, and zero external dependencies.",
5
5
  "main": "index.js",
6
6
  "repository": {
package/src/listenMqtt.js CHANGED
@@ -197,8 +197,12 @@ function listenMqtt(defaultFuncs, api, ctx, globalCallback) {
197
197
  connectTimeout: 5000,
198
198
  };
199
199
  if (ctx.globalOptions.proxy !== undefined) {
200
- const agent = new HttpsProxyAgent(ctx.globalOptions.proxy);
201
- options.wsOptions.agent = agent;
200
+ try {
201
+ const agent = new HttpsProxyAgent(ctx.globalOptions.proxy);
202
+ options.wsOptions.agent = agent;
203
+ } catch (error) {
204
+ log.error("listenMqtt", `Failed to create proxy agent: ${error.message}`);
205
+ }
202
206
  }
203
207
  ctx.mqttClient = new mqtt.Client(
204
208
  () =>