fca-nx 6.8.6 → 6.8.8
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/func/checkUpdate.js +1 -1
- package/func/logAdapter.js +0 -2
- package/index.js +0 -3
- package/module/config.js +2 -7
- package/module/login.js +10 -38
- package/module/loginHelper.js +94 -163
- package/module/options.js +1 -7
- package/package.json +2 -2
- package/src/api/action/addfriend.js +3 -9
- package/src/api/action/changeAvatar.js +0 -1
- package/src/api/action/changeCover.js +1 -3
- package/src/api/action/enableAutoSaveAppState.js +5 -18
- package/src/api/action/refreshFb_dtsg.js +2 -2
- package/src/api/http/httpGet.js +2 -6
- package/src/api/http/httpPost.js +2 -7
- package/src/api/messaging/createNewGroup.js +1 -1
- package/src/api/messaging/deleteMessage.js +1 -1
- package/src/api/messaging/forwardMessage.js +1 -9
- package/src/api/messaging/getEmojiUrl.js +1 -5
- package/src/api/messaging/getMessage.js +2 -4
- package/src/api/messaging/getThemePictures.js +0 -7
- package/src/api/messaging/markAsRead.js +0 -1
- package/src/api/messaging/muteThread.js +1 -1
- package/src/api/messaging/pinMessage.js +1 -10
- package/src/api/messaging/scheduler.js +4 -71
- package/src/api/messaging/sendBroadcast.js +0 -15
- package/src/api/messaging/sendMessage.js +1 -10
- package/src/api/messaging/sendTypingIndicator.js +2 -2
- package/src/api/messaging/sessionGuard.js +9 -45
- package/src/api/messaging/setMessageReaction.js +1 -2
- package/src/api/messaging/threadColors.js +12 -45
- package/src/api/messaging/uploadAttachment.js +3 -37
- package/src/api/socket/core/connectMqtt.js +17 -60
- package/src/api/socket/core/emitAuth.js +2 -14
- package/src/api/socket/core/getSeqID.js +23 -29
- package/src/api/socket/core/getTaskResponseData.js +1 -3
- package/src/api/socket/core/parseDelta.js +1 -1
- package/src/api/socket/detail/buildStream.js +1 -4
- package/src/api/socket/detail/constants.js +1 -4
- package/src/api/socket/e2ee/crypto.js +2 -40
- package/src/api/socket/e2ee/index.js +10 -123
- package/src/api/socket/e2ee/protocol.js +1 -32
- package/src/api/socket/e2ee/ratchet.js +10 -44
- package/src/api/socket/e2ee/store.js +1 -13
- package/src/api/socket/listenE2EE.js +1 -25
- package/src/api/socket/listenMqtt.js +13 -29
- package/src/api/socket/middleware/index.js +7 -61
- package/src/api/socket/sendMessage.js +2 -19
- package/src/api/threads/getThreadHistory.js +38 -68
- package/src/api/threads/getThreadInfo.js +3 -4
- package/src/api/threads/getThreadList.js +31 -34
- package/src/api/threads/getThreadPictures.js +1 -1
- package/src/api/users/getUserInfo.js +2 -5
- package/src/api/users/getUserInfoV2.js +3 -9
- package/src/core/sendReqMqtt.js +1 -2
- package/src/database/helpers.js +0 -12
- package/src/database/models/index.js +1 -3
- package/src/utils/broadcast.js +1 -1
- package/src/utils/clientIdentity.js +3 -50
- package/src/utils/cookies.js +2 -4
- package/src/utils/format/utils.js +0 -10
- package/src/utils/headers.js +12 -26
- package/src/utils/instanceLock.js +3 -9
- package/src/utils/ipGuard.js +1 -15
- package/src/utils/loginParser/autoLogin.js +0 -12
- package/src/utils/loginParser/parseAndCheckLogin.js +0 -7
- package/src/utils/loginParser/textUtils.js +0 -6
- package/src/utils/request/config.js +1 -4
- package/src/utils/request/methods.js +1 -4
- package/src/utils/request/proxy.js +0 -13
- package/src/utils/request/retry.js +0 -1
- package/src/utils/request/sanitize.js +1 -1
- package/src/utils/sendThrottle.js +1 -14
- package/src/utils/utils.js +3 -17
package/func/checkUpdate.js
CHANGED
package/func/logAdapter.js
CHANGED
|
@@ -3,7 +3,6 @@ const logger = require("./logger");
|
|
|
3
3
|
function formatArgs(args) {
|
|
4
4
|
const [prefix, msg] = args;
|
|
5
5
|
|
|
6
|
-
// Single argument: log as-is
|
|
7
6
|
if (msg === undefined) {
|
|
8
7
|
if (prefix instanceof Error) {
|
|
9
8
|
return prefix.stack || prefix.message || String(prefix);
|
|
@@ -11,7 +10,6 @@ function formatArgs(args) {
|
|
|
11
10
|
return String(prefix);
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
// Two arguments: mimic npmlog("tag", message)
|
|
15
13
|
const tag = prefix == null ? "" : String(prefix);
|
|
16
14
|
if (msg instanceof Error) {
|
|
17
15
|
const base = msg.message || String(msg);
|
package/index.js
CHANGED
|
@@ -6,14 +6,11 @@ const { MessengerBot, createMessengerBot } = require("./src/app/MessengerBot");
|
|
|
6
6
|
const { MessengerContext } = require("./src/app/MessengerContext");
|
|
7
7
|
const { attachThreadInfoRealtimeSync, applyThreadInfoRealtimeEvent } = require("./src/app/threadInfoRealtimeSync");
|
|
8
8
|
|
|
9
|
-
// CommonJS default export — the login function (classic FCA / GoatBot compatible)
|
|
10
9
|
module.exports = login;
|
|
11
10
|
|
|
12
|
-
// Named exports
|
|
13
11
|
module.exports.login = login;
|
|
14
12
|
module.exports.default = login;
|
|
15
13
|
|
|
16
|
-
// New features from dongdev
|
|
17
14
|
module.exports.createFcaClient = createFcaClient;
|
|
18
15
|
module.exports.MessengerBot = MessengerBot;
|
|
19
16
|
module.exports.createMessengerBot = createMessengerBot;
|
package/module/config.js
CHANGED
|
@@ -5,16 +5,11 @@ const defaultConfig = {
|
|
|
5
5
|
autoUpdate: true,
|
|
6
6
|
mqtt: { enabled: true, reconnectInterval: 3600 },
|
|
7
7
|
autoLogin: true,
|
|
8
|
-
|
|
9
|
-
// credentials to a third-party server should be an explicit,
|
|
10
|
-
// operator-chosen opt-in (see module/loginHelper.js#loginViaAPI), never a
|
|
11
|
-
// silent default. Set this in fca-config.json only if you trust the
|
|
12
|
-
// server you're pointing it at.
|
|
8
|
+
|
|
13
9
|
apiServer: "",
|
|
14
10
|
apiKey: "",
|
|
15
11
|
credentials: { email: "", password: "", twofactor: "" },
|
|
16
|
-
|
|
17
|
-
// is a separate login-like call and is left off by default.
|
|
12
|
+
|
|
18
13
|
e2ee: false,
|
|
19
14
|
antiGetInfo: {
|
|
20
15
|
AntiGetThreadInfo: false,
|
package/module/login.js
CHANGED
|
@@ -9,95 +9,72 @@ const { DEFAULT_IDENTITY } = require("../src/utils/clientIdentity");
|
|
|
9
9
|
const { config } = loadConfig();
|
|
10
10
|
global.fca = { config };
|
|
11
11
|
|
|
12
|
-
// Global error handlers to prevent bot crashes
|
|
13
|
-
// Handle unhandled promise rejections (e.g., fetch timeouts, network errors)
|
|
14
12
|
if (!global.fca._errorHandlersInstalled) {
|
|
15
13
|
global.fca._errorHandlersInstalled = true;
|
|
16
14
|
|
|
17
15
|
process.on("unhandledRejection", (reason, promise) => {
|
|
18
16
|
try {
|
|
19
|
-
|
|
17
|
+
|
|
20
18
|
if (reason && typeof reason === "object") {
|
|
21
19
|
const errorCode = reason.code || reason.cause?.code;
|
|
22
20
|
const errorMessage = reason.message || String(reason);
|
|
23
21
|
|
|
24
|
-
// Suppress Sequelize instance errors (handled gracefully in getBackupModel)
|
|
25
22
|
if (errorMessage.includes("No Sequelize instance passed")) {
|
|
26
|
-
return;
|
|
23
|
+
return;
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
// Handle fetch timeout errors gracefully
|
|
30
26
|
if (errorCode === "UND_ERR_CONNECT_TIMEOUT" ||
|
|
31
27
|
errorCode === "ETIMEDOUT" ||
|
|
32
28
|
errorMessage.includes("Connect Timeout") ||
|
|
33
29
|
errorMessage.includes("fetch failed")) {
|
|
34
30
|
logger(`Network timeout error caught (non-fatal): ${errorMessage}`, "warn");
|
|
35
|
-
return;
|
|
31
|
+
return;
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
// Handle other network errors
|
|
39
34
|
if (errorCode === "ECONNREFUSED" ||
|
|
40
35
|
errorCode === "ENOTFOUND" ||
|
|
41
36
|
errorCode === "ECONNRESET" ||
|
|
42
37
|
errorMessage.includes("ECONNREFUSED") ||
|
|
43
38
|
errorMessage.includes("ENOTFOUND")) {
|
|
44
39
|
logger(`Network connection error caught (non-fatal): ${errorMessage}`, "warn");
|
|
45
|
-
return;
|
|
40
|
+
return;
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
43
|
|
|
49
|
-
// [Fixed by xalman] For other unhandled rejections, log but don't crash.
|
|
50
|
-
// Include the stack (when available) - logging only `.message` made
|
|
51
|
-
// real bugs impossible to trace back to where they were thrown.
|
|
52
44
|
const errorDetail = reason && reason.stack ? reason.stack : (reason && reason.message ? reason.message : String(reason));
|
|
53
45
|
logger(`Unhandled promise rejection (non-fatal): ${errorDetail}`, "error");
|
|
54
46
|
} catch (e) {
|
|
55
|
-
|
|
47
|
+
|
|
56
48
|
try { console.error("[fca-nx] logger failed while handling unhandledRejection:", e, reason); } catch { }
|
|
57
49
|
}
|
|
58
50
|
});
|
|
59
51
|
|
|
60
|
-
// Handle uncaught exceptions (last resort)
|
|
61
52
|
process.on("uncaughtException", (error) => {
|
|
62
53
|
try {
|
|
63
54
|
const errorMessage = error.message || String(error);
|
|
64
55
|
const errorCode = error.code;
|
|
65
56
|
|
|
66
|
-
// Suppress Sequelize instance errors (handled gracefully in getBackupModel)
|
|
67
57
|
if (errorMessage.includes("No Sequelize instance passed")) {
|
|
68
|
-
return;
|
|
58
|
+
return;
|
|
69
59
|
}
|
|
70
60
|
|
|
71
|
-
// Handle fetch/network errors
|
|
72
61
|
if (errorCode === "UND_ERR_CONNECT_TIMEOUT" ||
|
|
73
62
|
errorCode === "ETIMEDOUT" ||
|
|
74
63
|
errorMessage.includes("Connect Timeout") ||
|
|
75
64
|
errorMessage.includes("fetch failed")) {
|
|
76
65
|
logger(`Uncaught network timeout error (non-fatal): ${errorMessage}`, "warn");
|
|
77
|
-
return;
|
|
66
|
+
return;
|
|
78
67
|
}
|
|
79
68
|
|
|
80
|
-
// [Fixed by xalman] For other uncaught exceptions, log but try to continue.
|
|
81
|
-
// Include the stack trace - without it these were undebuggable in production.
|
|
82
69
|
logger(`Uncaught exception (attempting to continue): ${error && error.stack ? error.stack : errorMessage}`, "error");
|
|
83
|
-
|
|
84
|
-
// This trades crash-safety for the (small) risk of continuing in a
|
|
85
|
-
// partially-inconsistent process state. If you run this under a process
|
|
86
|
-
// manager (pm2/systemd) that auto-restarts on crash, consider calling
|
|
87
|
-
// process.exit(1) here instead for a clean restart on truly unknown errors.
|
|
70
|
+
|
|
88
71
|
} catch (e) {
|
|
89
|
-
|
|
72
|
+
|
|
90
73
|
try { console.error("[fca-nx] logger failed while handling uncaughtException:", e, error); } catch { }
|
|
91
74
|
}
|
|
92
75
|
});
|
|
93
76
|
}
|
|
94
77
|
|
|
95
|
-
// Prevent multiple simultaneous login attempts for the same account.
|
|
96
|
-
// Keyed by whatever identifies the account in loginData (email, or the
|
|
97
|
-
// c_user/i_user value pulled out of an appstate/cookie string) so that
|
|
98
|
-
// calling login() twice in a row for the same account before the first
|
|
99
|
-
// call resolves can't race and produce two half-initialized sessions
|
|
100
|
-
// fighting over the same cookies.
|
|
101
78
|
if (!global.fca._activeLogins) global.fca._activeLogins = new Set();
|
|
102
79
|
|
|
103
80
|
function extractLoginKey(loginData) {
|
|
@@ -137,12 +114,7 @@ function login(loginData, options, callback) {
|
|
|
137
114
|
autoReconnect: true,
|
|
138
115
|
online: true,
|
|
139
116
|
emitReady: false,
|
|
140
|
-
|
|
141
|
-
// This used to be hard-coded independently here (Chrome/121), in
|
|
142
|
-
// module/options.js (Chrome/125), src/utils/headers.js (Chrome/139) and
|
|
143
|
-
// src/api/messaging/uploadAttachment.js (Chrome/143), which meant a single
|
|
144
|
-
// session could send contradictory browser-version fingerprints between
|
|
145
|
-
// different requests. All four now derive from the same identity module.
|
|
117
|
+
|
|
146
118
|
userAgent: DEFAULT_IDENTITY.userAgent
|
|
147
119
|
};
|
|
148
120
|
setOptions(globalOptions, options);
|