nexus-fca 2.0.5 → 2.0.6
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 +123 -34
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -25,7 +25,7 @@ const { User } = require('./lib/message/User');
|
|
|
25
25
|
// Advanced Safety Module - Minimizes ban/lock/checkpoint rates
|
|
26
26
|
const FacebookSafety = require('./lib/safety/FacebookSafety');
|
|
27
27
|
|
|
28
|
-
//
|
|
28
|
+
// Core compatibility imports
|
|
29
29
|
const MqttManager = require('./lib/mqtt/MqttManager');
|
|
30
30
|
const { DatabaseManager, getInstance } = require('./lib/database/DatabaseManager');
|
|
31
31
|
const { PerformanceOptimizer, getInstance: getPerformanceOptimizerInstance } = require('./lib/performance/PerformanceOptimizer');
|
|
@@ -256,7 +256,7 @@ function buildAPI(globalOptions, html, jar) {
|
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
//
|
|
259
|
+
// Appstate login helper function
|
|
260
260
|
function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
|
|
261
261
|
let mainPromise = null;
|
|
262
262
|
const jar = utils.getJar();
|
|
@@ -295,7 +295,7 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
|
|
|
295
295
|
return callback(new Error("Invalid appState format"));
|
|
296
296
|
}
|
|
297
297
|
} else {
|
|
298
|
-
return callback(new Error("AppState is required for
|
|
298
|
+
return callback(new Error("AppState is required for session authentication"));
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
function handleRedirect(res) {
|
|
@@ -345,7 +345,7 @@ function loginHelper(appState, email, password, globalOptions, callback, prCallb
|
|
|
345
345
|
logger(`⚠️ Login safety warning: ${safetyStatus.reason}`, 'warn');
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
-
logger('
|
|
348
|
+
logger('✅ Session authenticated successfully', 'info');
|
|
349
349
|
|
|
350
350
|
// Initialize safety monitoring
|
|
351
351
|
globalSafety.startMonitoring(ctx, api);
|
|
@@ -388,7 +388,7 @@ class IntegratedNexusLoginSystem {
|
|
|
388
388
|
this.lastLoginTime = 0;
|
|
389
389
|
|
|
390
390
|
this.ensureDirectories();
|
|
391
|
-
this.logger('
|
|
391
|
+
this.logger('Login system ready', '🚀');
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
logger(message, emoji = '📝') {
|
|
@@ -606,7 +606,7 @@ class IntegratedNexusLoginSystem {
|
|
|
606
606
|
timeout: 30000
|
|
607
607
|
};
|
|
608
608
|
|
|
609
|
-
this.logger('
|
|
609
|
+
this.logger('Connecting to Facebook servers...', '🔐');
|
|
610
610
|
|
|
611
611
|
return new Promise((resolve) => {
|
|
612
612
|
axios.request(options).then(async (response) => {
|
|
@@ -646,7 +646,7 @@ class IntegratedNexusLoginSystem {
|
|
|
646
646
|
};
|
|
647
647
|
|
|
648
648
|
this.saveAppstate(appstate, result);
|
|
649
|
-
this.logger('Login successful
|
|
649
|
+
this.logger('✅ Login successful - Session established', '🎉');
|
|
650
650
|
|
|
651
651
|
resolve(result);
|
|
652
652
|
}
|
|
@@ -672,11 +672,11 @@ class IntegratedNexusLoginSystem {
|
|
|
672
672
|
twoFactorCode = credentials._2fa;
|
|
673
673
|
} else if (credentials.twofactor && credentials.twofactor !== "0") {
|
|
674
674
|
try {
|
|
675
|
-
this.logger('
|
|
675
|
+
this.logger('Generating 2FA code...', '🔐');
|
|
676
676
|
const cleanSecret = decodeURI(credentials.twofactor).replace(/\s+/g, '').toUpperCase();
|
|
677
677
|
const { otp } = TOTP.generate(cleanSecret);
|
|
678
678
|
twoFactorCode = otp;
|
|
679
|
-
this.logger(
|
|
679
|
+
this.logger(`✅ 2FA code generated: ${otp}`, '🔑');
|
|
680
680
|
} catch (e) {
|
|
681
681
|
return resolve({
|
|
682
682
|
success: false,
|
|
@@ -705,7 +705,7 @@ class IntegratedNexusLoginSystem {
|
|
|
705
705
|
twoFactorForm.sig = this.encodesig(this.sort(twoFactorForm));
|
|
706
706
|
options.data = twoFactorForm;
|
|
707
707
|
|
|
708
|
-
this.logger('
|
|
708
|
+
this.logger('Verifying 2FA code...', '🔐');
|
|
709
709
|
|
|
710
710
|
try {
|
|
711
711
|
const twoFactorResponse = await axios.request(options);
|
|
@@ -742,7 +742,7 @@ class IntegratedNexusLoginSystem {
|
|
|
742
742
|
};
|
|
743
743
|
|
|
744
744
|
this.saveAppstate(appstate, result);
|
|
745
|
-
this.logger('2FA
|
|
745
|
+
this.logger('✅ 2FA verification successful', '🎉');
|
|
746
746
|
|
|
747
747
|
resolve(result);
|
|
748
748
|
|
|
@@ -775,19 +775,19 @@ class IntegratedNexusLoginSystem {
|
|
|
775
775
|
|
|
776
776
|
async login(credentials = null) {
|
|
777
777
|
try {
|
|
778
|
-
this.logger('
|
|
778
|
+
this.logger('Initializing authentication...', '🚀');
|
|
779
779
|
|
|
780
780
|
// Check for existing valid appstate first
|
|
781
781
|
if (this.options.autoLogin && this.hasValidAppstate()) {
|
|
782
|
-
this.logger('
|
|
782
|
+
this.logger('Existing session found', '✅');
|
|
783
783
|
const appstate = this.loadAppstate();
|
|
784
784
|
|
|
785
785
|
if (appstate) {
|
|
786
786
|
return {
|
|
787
787
|
success: true,
|
|
788
788
|
appstate: appstate,
|
|
789
|
-
method: '
|
|
790
|
-
message: 'Login successful using existing
|
|
789
|
+
method: 'existing_session',
|
|
790
|
+
message: 'Login successful using existing session'
|
|
791
791
|
};
|
|
792
792
|
}
|
|
793
793
|
}
|
|
@@ -807,7 +807,7 @@ class IntegratedNexusLoginSystem {
|
|
|
807
807
|
if (!credentials) {
|
|
808
808
|
return {
|
|
809
809
|
success: false,
|
|
810
|
-
message: 'No valid
|
|
810
|
+
message: 'No valid session found and no credentials provided'
|
|
811
811
|
};
|
|
812
812
|
}
|
|
813
813
|
}
|
|
@@ -820,7 +820,7 @@ class IntegratedNexusLoginSystem {
|
|
|
820
820
|
};
|
|
821
821
|
}
|
|
822
822
|
|
|
823
|
-
this.logger('
|
|
823
|
+
this.logger('Creating new session...', '🔄');
|
|
824
824
|
|
|
825
825
|
// Generate new appstate
|
|
826
826
|
const result = await this.generateAppstate(credentials);
|
|
@@ -841,10 +841,10 @@ class IntegratedNexusLoginSystem {
|
|
|
841
841
|
return result;
|
|
842
842
|
|
|
843
843
|
} catch (error) {
|
|
844
|
-
this.logger(`
|
|
844
|
+
this.logger(`Authentication error: ${error.message}`, '💥');
|
|
845
845
|
return {
|
|
846
846
|
success: false,
|
|
847
|
-
message: `
|
|
847
|
+
message: `Authentication error: ${error.message}`
|
|
848
848
|
};
|
|
849
849
|
}
|
|
850
850
|
}
|
|
@@ -853,43 +853,107 @@ class IntegratedNexusLoginSystem {
|
|
|
853
853
|
// Integrated Nexus Login wrapper for easy usage
|
|
854
854
|
async function integratedNexusLogin(credentials = null, options = {}) {
|
|
855
855
|
const loginSystem = new IntegratedNexusLoginSystem(options);
|
|
856
|
+
|
|
857
|
+
// Professional logging system
|
|
858
|
+
const Logger = {
|
|
859
|
+
info: (stage, message, details = null) => {
|
|
860
|
+
console.log(`\x1b[36m[INFO]\x1b[0m \x1b[32m[${stage}]\x1b[0m ${message}`);
|
|
861
|
+
if (details && options.verbose) console.log(`\x1b[90m → ${details}\x1b[0m`);
|
|
862
|
+
},
|
|
863
|
+
success: (stage, message, details = null) => {
|
|
864
|
+
console.log(`\x1b[32m[SUCCESS]\x1b[0m \x1b[32m[${stage}]\x1b[0m ${message}`);
|
|
865
|
+
if (details && options.verbose) console.log(`\x1b[90m → ${details}\x1b[0m`);
|
|
866
|
+
},
|
|
867
|
+
warn: (stage, message, details = null) => {
|
|
868
|
+
console.log(`\x1b[33m[WARN]\x1b[0m \x1b[33m[${stage}]\x1b[0m ${message}`);
|
|
869
|
+
if (details) console.log(`\x1b[90m → ${details}\x1b[0m`);
|
|
870
|
+
},
|
|
871
|
+
error: (stage, message, details = null) => {
|
|
872
|
+
console.log(`\x1b[31m[ERROR]\x1b[0m \x1b[31m[${stage}]\x1b[0m ${message}`);
|
|
873
|
+
if (details) console.log(`\x1b[90m → ${details}\x1b[0m`);
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
// Phase 1: Secure authentication and session generation
|
|
878
|
+
Logger.info('AUTH', 'Initializing secure authentication');
|
|
879
|
+
Logger.info('SECURE-LOGIN', 'Establishing secure connection to Facebook');
|
|
880
|
+
|
|
856
881
|
const result = await loginSystem.login(credentials);
|
|
857
882
|
|
|
858
|
-
if (result.success
|
|
859
|
-
|
|
883
|
+
if (!result.success) {
|
|
884
|
+
Logger.error('AUTH', 'Authentication failed', result.message);
|
|
885
|
+
return result;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
Logger.success('AUTH', 'Authentication completed successfully');
|
|
889
|
+
Logger.info('SESSION', `Login method: ${result.method} | Status: Active`);
|
|
890
|
+
|
|
891
|
+
if (options.autoStartBot !== false && result.appstate) {
|
|
892
|
+
// Phase 2: Start Nexus-FCA bot with authenticated session
|
|
893
|
+
Logger.info('BOT-INIT', 'Initializing bot with secure session');
|
|
894
|
+
|
|
860
895
|
try {
|
|
896
|
+
// Prepare global options for bot system
|
|
897
|
+
const globalOptions = {
|
|
898
|
+
selfListen: false,
|
|
899
|
+
selfListenEvent: false,
|
|
900
|
+
listenEvents: false,
|
|
901
|
+
listenTyping: false,
|
|
902
|
+
updatePresence: false,
|
|
903
|
+
forceLogin: false,
|
|
904
|
+
autoMarkDelivery: true,
|
|
905
|
+
autoMarkRead: false,
|
|
906
|
+
autoReconnect: true,
|
|
907
|
+
logRecordSize: defaultLogRecordSize,
|
|
908
|
+
online: true,
|
|
909
|
+
emitReady: false,
|
|
910
|
+
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
|
|
911
|
+
...options
|
|
912
|
+
};
|
|
913
|
+
|
|
861
914
|
return new Promise((resolve) => {
|
|
862
|
-
|
|
915
|
+
// Initialize Nexus-FCA bot with authenticated session
|
|
916
|
+
Logger.info('BOT-INIT', 'Loading bot API systems');
|
|
917
|
+
|
|
918
|
+
loginHelper(result.appstate, null, null, globalOptions, (err, api) => {
|
|
863
919
|
if (err) {
|
|
920
|
+
Logger.error('BOT-INIT', 'Failed to initialize bot API', err.message);
|
|
864
921
|
resolve({
|
|
865
922
|
success: true,
|
|
866
923
|
appstate: result.appstate,
|
|
867
924
|
method: result.method,
|
|
868
|
-
warning: '
|
|
925
|
+
warning: 'Session ready but bot initialization failed',
|
|
869
926
|
botError: err.message
|
|
870
927
|
});
|
|
871
928
|
} else {
|
|
929
|
+
Logger.success('BOT-INIT', 'Bot initialized successfully');
|
|
930
|
+
Logger.success('READY', '🚀 Nexus-FCA is now ready for use');
|
|
931
|
+
Logger.info('STATUS', `Bot online | User ID: ${api.getCurrentUserID()}`);
|
|
932
|
+
|
|
872
933
|
resolve({
|
|
873
934
|
success: true,
|
|
874
935
|
api: api,
|
|
875
936
|
appstate: result.appstate,
|
|
876
937
|
method: result.method,
|
|
877
|
-
message: 'Nexus-FCA
|
|
938
|
+
message: 'Nexus-FCA login successful'
|
|
878
939
|
});
|
|
879
940
|
}
|
|
880
|
-
});
|
|
941
|
+
}, null);
|
|
881
942
|
});
|
|
882
943
|
} catch (error) {
|
|
944
|
+
Logger.error('BOT-INIT', 'Exception during bot initialization', error.message);
|
|
883
945
|
return {
|
|
884
946
|
success: true,
|
|
885
947
|
appstate: result.appstate,
|
|
886
948
|
method: result.method,
|
|
887
|
-
warning: '
|
|
949
|
+
warning: 'Session ready but bot initialization failed',
|
|
888
950
|
botError: error.message
|
|
889
951
|
};
|
|
890
952
|
}
|
|
891
953
|
}
|
|
892
954
|
|
|
955
|
+
// Return session-only result (no bot startup)
|
|
956
|
+
Logger.success('SESSION-ONLY', 'Authentication completed successfully');
|
|
893
957
|
return result;
|
|
894
958
|
}
|
|
895
959
|
|
|
@@ -897,16 +961,35 @@ async function integratedNexusLogin(credentials = null, options = {}) {
|
|
|
897
961
|
* Modern login entry point using Integrated Nexus Login System
|
|
898
962
|
* Supports: username/password/2FA, auto appstate, ultra-safe mode
|
|
899
963
|
* Usage: login({ email, password, twofactor }, options, callback)
|
|
964
|
+
*
|
|
965
|
+
* FLOW:
|
|
966
|
+
* - ID/password: Generates secure session → Starts bot
|
|
967
|
+
* - Appstate only: Uses existing session directly
|
|
900
968
|
*/
|
|
901
969
|
async function login(loginData, options = {}, callback) {
|
|
902
|
-
// Support
|
|
970
|
+
// Support multiple callback signatures
|
|
903
971
|
if (typeof options === 'function') {
|
|
904
972
|
callback = options;
|
|
905
973
|
options = {};
|
|
906
974
|
}
|
|
907
975
|
|
|
908
|
-
//
|
|
976
|
+
// Professional logging
|
|
977
|
+
const mainLogger = {
|
|
978
|
+
info: (message, details = null) => {
|
|
979
|
+
console.log(`\x1b[36m[NEXUS-FCA]\x1b[0m ${message}`);
|
|
980
|
+
if (details && options.verbose) console.log(`\x1b[90m → ${details}\x1b[0m`);
|
|
981
|
+
},
|
|
982
|
+
error: (message, details = null) => {
|
|
983
|
+
console.log(`\x1b[31m[NEXUS-FCA]\x1b[0m \x1b[31m${message}\x1b[0m`);
|
|
984
|
+
if (details) console.log(`\x1b[90m → ${details}\x1b[0m`);
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
// Enhanced login flow for ID/password authentication
|
|
909
989
|
if (loginData.email || loginData.username || loginData.password) {
|
|
990
|
+
mainLogger.info('� Starting secure authentication');
|
|
991
|
+
mainLogger.info('�️ Using advanced security protocols');
|
|
992
|
+
|
|
910
993
|
try {
|
|
911
994
|
const result = await integratedNexusLogin({
|
|
912
995
|
username: loginData.email || loginData.username,
|
|
@@ -917,26 +1000,32 @@ async function login(loginData, options = {}, callback) {
|
|
|
917
1000
|
}, options);
|
|
918
1001
|
|
|
919
1002
|
if (result.success && result.api) {
|
|
1003
|
+
// Bot startup completed successfully
|
|
1004
|
+
mainLogger.info('✅ Login successful - Bot ready for use');
|
|
920
1005
|
if (callback) return callback(null, result.api);
|
|
921
1006
|
return result.api;
|
|
922
1007
|
} else {
|
|
923
|
-
|
|
924
|
-
|
|
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');
|
|
925
1011
|
}
|
|
926
1012
|
} catch (error) {
|
|
927
|
-
|
|
1013
|
+
mainLogger.error('💥 Login error', error.message);
|
|
928
1014
|
if (callback) return callback(error);
|
|
929
1015
|
throw error;
|
|
930
1016
|
}
|
|
931
1017
|
} else {
|
|
932
|
-
//
|
|
1018
|
+
// Appstate-only authentication (direct session authentication)
|
|
933
1019
|
if (!loginData.appState && !loginData.appstate) {
|
|
934
|
-
const error = new Error('Username and password are required for login, or provide appState for
|
|
1020
|
+
const error = new Error('Username and password are required for login, or provide appState for session authentication.');
|
|
1021
|
+
mainLogger.error('❌ No credentials provided', 'Either provide ID/password or appstate');
|
|
935
1022
|
if (callback) return callback(error);
|
|
936
1023
|
throw error;
|
|
937
1024
|
}
|
|
938
1025
|
|
|
939
|
-
//
|
|
1026
|
+
// Direct session authentication using appstate
|
|
1027
|
+
mainLogger.info('� Starting session authentication');
|
|
1028
|
+
|
|
940
1029
|
const globalOptions = {
|
|
941
1030
|
selfListen: false,
|
|
942
1031
|
selfListenEvent: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nexus-fca",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
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": {
|