fca-nx 6.8.3 → 6.8.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.
package/module/login.js
CHANGED
|
@@ -135,7 +135,7 @@ function login(loginData, options, callback) {
|
|
|
135
135
|
forceLogin: false,
|
|
136
136
|
autoMarkRead: false,
|
|
137
137
|
autoReconnect: true,
|
|
138
|
-
online:
|
|
138
|
+
online: true,
|
|
139
139
|
emitReady: false,
|
|
140
140
|
// Single source of truth for the default identity - see src/utils/clientIdentity.js.
|
|
141
141
|
// This used to be hard-coded independently here (Chrome/121), in
|
|
@@ -175,6 +175,9 @@ function login(loginData, options, callback) {
|
|
|
175
175
|
callback(error, api);
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
+
if (loginData && (loginData.twofactor || loginData.twoFactor)) {
|
|
179
|
+
globalOptions.twofactor = String(loginData.twofactor || loginData.twoFactor);
|
|
180
|
+
}
|
|
178
181
|
const proceed = () => loginHelper(loginData.appState, loginData.Cookie, loginData.email, loginData.password, globalOptions, wrappedCallback, prCallback);
|
|
179
182
|
if (config && config.autoUpdate) {
|
|
180
183
|
const p = checkAndUpdateVersion();
|
package/module/loginHelper.js
CHANGED
|
@@ -591,7 +591,7 @@ async function tryAutoLoginIfNeeded(currentHtml, currentCookies, globalOptions,
|
|
|
591
591
|
// Try API login
|
|
592
592
|
const u = config.credentials?.email || config.email;
|
|
593
593
|
const p = config.credentials?.password || config.password;
|
|
594
|
-
const tf = config.credentials?.twofactor || config.twofactor || null;
|
|
594
|
+
const tf = (globalOptions && globalOptions.twofactor) || config.credentials?.twofactor || config.twofactor || null;
|
|
595
595
|
|
|
596
596
|
if (!u || !p) {
|
|
597
597
|
logger("tryAutoLoginIfNeeded: No credentials configured for auto-login!", "error");
|
|
@@ -738,7 +738,7 @@ function makeLogin(j, email, password, globalOptions) {
|
|
|
738
738
|
return async function () {
|
|
739
739
|
const u = email || config.credentials?.email;
|
|
740
740
|
const p = password || config.credentials?.password;
|
|
741
|
-
const tf = config.credentials?.twofactor || null;
|
|
741
|
+
const tf = (globalOptions && globalOptions.twofactor) || config.credentials?.twofactor || null;
|
|
742
742
|
if (!u || !p) return;
|
|
743
743
|
const r = await tokens(u, p, tf);
|
|
744
744
|
if (r && r.status && Array.isArray(r.cookies)) {
|
|
@@ -1225,7 +1225,7 @@ function loginHelper(appState, Cookie, email, password, globalOptions, callback)
|
|
|
1225
1225
|
|
|
1226
1226
|
const u = config.credentials?.email || email;
|
|
1227
1227
|
const p = config.credentials?.password || password;
|
|
1228
|
-
const tf = config.credentials?.twofactor || null;
|
|
1228
|
+
const tf = globalOptions.twofactor || config.credentials?.twofactor || null;
|
|
1229
1229
|
if (!u || !p) return false;
|
|
1230
1230
|
// [Hardened4] Repeated credential logins are a classic trigger for "automated
|
|
1231
1231
|
// behaviour"/"multiple sessions" restrictions. At most one per cooldown window
|
package/package.json
CHANGED
|
@@ -127,8 +127,9 @@ module.exports = function createListenMqtt(deps) {
|
|
|
127
127
|
if (!ctx.clientId || ctx.clientId === "") {
|
|
128
128
|
ctx.clientId = ctx.clientID || ((""+Math.random()).slice(2) + Date.now()).slice(0, 16);
|
|
129
129
|
}
|
|
130
|
-
//
|
|
131
|
-
|
|
130
|
+
// Online while this session is actually connected. Offline only if the
|
|
131
|
+
// caller set online:false. A running Messenger tab is online.
|
|
132
|
+
const chatOn = ctx.globalOptions.online !== false;
|
|
132
133
|
// Same browser tab for the life of the process. A new sid on every
|
|
133
134
|
// reconnect looks like a new login and is a common suspend trigger.
|
|
134
135
|
if (!ctx._edgeSid) {
|
|
@@ -296,48 +296,18 @@ module.exports = function createGetSeqID(deps) {
|
|
|
296
296
|
if (isAuthError) {
|
|
297
297
|
if (retryCount < MAX_RETRIES) {
|
|
298
298
|
const delay = RETRY_DELAY * (retryCount + 1);
|
|
299
|
-
logger(`getSeqID: retry ${retryCount + 1}/${MAX_RETRIES} after ${delay}ms
|
|
299
|
+
logger(`getSeqID: retry ${retryCount + 1}/${MAX_RETRIES} after ${delay}ms, same cookie (error: ${msg})`, "warn");
|
|
300
300
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
301
|
-
|
|
302
|
-
// [Hardened] Always refresh cookies + fb_dtsg before each auth retry
|
|
303
|
-
try {
|
|
304
|
-
logger("getSeqID: refreshing session (cookies + fb_dtsg) before retry...", "info");
|
|
305
|
-
const { get } = require("../../../utils/request");
|
|
306
|
-
const { saveCookies } = require("../../../utils/client");
|
|
307
|
-
await get("https://www.facebook.com/", ctx.jar, null, ctx.globalOptions, ctx).then(saveCookies(ctx.jar));
|
|
308
|
-
if (api && typeof api.refreshFb_dtsg === "function") {
|
|
309
|
-
try { await api.refreshFb_dtsg(); } catch (_) {}
|
|
310
|
-
}
|
|
311
|
-
// Keep form tokens in sync with refreshed ctx
|
|
312
|
-
if (form) {
|
|
313
|
-
if (ctx.fb_dtsg) form.fb_dtsg = ctx.fb_dtsg;
|
|
314
|
-
if (ctx.jazoest) form.jazoest = ctx.jazoest;
|
|
315
|
-
}
|
|
316
|
-
} catch (refreshErr) {
|
|
317
|
-
logger(`getSeqID: session refresh failed: ${refreshErr && refreshErr.message ? refreshErr.message : String(refreshErr)}`, "warn");
|
|
318
|
-
}
|
|
319
|
-
|
|
320
301
|
return getSeqID(defaultFuncs, api, ctx, globalCallback, form, retryCount + 1);
|
|
321
302
|
}
|
|
322
303
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
const loginResult = await tryAutoLogin(logger, config, ctx, defaultFuncs);
|
|
326
|
-
|
|
327
|
-
if (loginResult) {
|
|
328
|
-
logger("getSeqID: retrying with new session...", "info");
|
|
329
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
330
|
-
return getSeqID(defaultFuncs, api, ctx, globalCallback, form, 0);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// [Hardened] Only permanent-logout on CLEAR blocked signal.
|
|
334
|
-
// Plain "Not logged in" after retries is often a transient cookie race —
|
|
335
|
-
// schedule a long soft-reconnect instead of killing the session forever.
|
|
304
|
+
// A new email/password login here kills the cookie the bot is
|
|
305
|
+
// already using and Facebook treats it as a second device.
|
|
336
306
|
if (/blocked the login|login_blocked|checkpoint_282|checkpoint_956/i.test(msg)) {
|
|
337
307
|
return emitAuth(ctx, api, globalCallback, "login_blocked", msg);
|
|
338
308
|
}
|
|
339
309
|
|
|
340
|
-
logger(`getSeqID: auth still failing
|
|
310
|
+
logger(`getSeqID: auth still failing - keeping this cookie, no new login: ${msg}`, "error");
|
|
341
311
|
// Soft recovery: do NOT set ctx._ending. Notify listener, then retry later.
|
|
342
312
|
try {
|
|
343
313
|
if (typeof globalCallback === "function") {
|
|
@@ -358,6 +358,9 @@ module.exports = function (defaultFuncs, api, ctx, opts) {
|
|
|
358
358
|
try {
|
|
359
359
|
if (ctx.mqttClient) {
|
|
360
360
|
if (!soft && isConnected()) {
|
|
361
|
+
try {
|
|
362
|
+
ctx.mqttClient.publish("/foreground_state", JSON.stringify({ foreground: false }), { qos: 0 });
|
|
363
|
+
} catch (_) { }
|
|
361
364
|
try {
|
|
362
365
|
ctx.mqttClient.publish("/browser_close", "{}", { qos: 0 });
|
|
363
366
|
} catch (_) { }
|
|
@@ -528,6 +531,17 @@ module.exports = function (defaultFuncs, api, ctx, opts) {
|
|
|
528
531
|
|
|
529
532
|
installPostGuard();
|
|
530
533
|
|
|
534
|
+
if (ctx.mqttClient && ctx.mqttClient.connected) {
|
|
535
|
+
logger("mqtt already connected - not opening a second session", "info");
|
|
536
|
+
attachClientListeners();
|
|
537
|
+
startHeartbeat();
|
|
538
|
+
api.stopListening = msgEmitter.stopListening;
|
|
539
|
+
api.stopListeningAsync = msgEmitter.stopListeningAsync;
|
|
540
|
+
api.forceReconnect = forceCycle;
|
|
541
|
+
api.isMqttConnected = isConnected;
|
|
542
|
+
return msgEmitter;
|
|
543
|
+
}
|
|
544
|
+
|
|
531
545
|
if (!ctx.firstListen) ctx.lastSeqId = null;
|
|
532
546
|
ctx.syncToken = undefined;
|
|
533
547
|
ctx.t_mqttCalled = false;
|