@lazyneoaz/testfca 1.0.1 → 1.0.3
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/package.json +2 -2
- package/prebuilt/linux-x64-gnu/messagix.so +0 -0
- package/scripts/build-go.mjs +8 -1
- package/scripts/download-prebuilt.mjs +6 -13
- package/scripts/postinstall.mjs +17 -35
- package/src/utils/axios.js +3 -0
- package/src/utils/clients.js +8 -0
- package/src/utils/formatters.js +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lazyneoaz/testfca",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "Advanced Facebook Chat API client for building Messenger bots — supports real-time messaging, thread management, MQTT, session stability, anti-automation protection, and real E2EE via Signal Protocol.",
|
|
6
6
|
"main": "index.js",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"typescript": "^5.8.3"
|
|
85
85
|
},
|
|
86
86
|
"engines": {
|
|
87
|
-
"node": ">=
|
|
87
|
+
"node": ">=20.18.1"
|
|
88
88
|
},
|
|
89
89
|
"scripts": {
|
|
90
90
|
"prepack": "echo 'Preparing package for npm...'",
|
|
Binary file
|
package/scripts/build-go.mjs
CHANGED
|
@@ -17,7 +17,14 @@ function runGo(args) {
|
|
|
17
17
|
const res = spawnSync(process.env.GO_BIN || "go", args, {
|
|
18
18
|
cwd: bridgeDir,
|
|
19
19
|
stdio: "inherit",
|
|
20
|
-
env: {
|
|
20
|
+
env: {
|
|
21
|
+
...process.env,
|
|
22
|
+
CGO_ENABLED: "1",
|
|
23
|
+
// Prevent Go from downloading a newer toolchain when go.mod specifies
|
|
24
|
+
// a version higher than what is locally installed. The local compiler
|
|
25
|
+
// should always be used in sandboxed / offline environments.
|
|
26
|
+
GOTOOLCHAIN: "local",
|
|
27
|
+
},
|
|
21
28
|
});
|
|
22
29
|
if (res.error) {
|
|
23
30
|
console.error(`[${name}] Failed to spawn Go: ${res.error.message}`);
|
|
@@ -9,20 +9,13 @@ import { packageJson as pkg } from "./package.mjs";
|
|
|
9
9
|
|
|
10
10
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
11
|
|
|
12
|
-
function defaultRepoSlug() {
|
|
13
|
-
// Use yumi-team/meta-messenger.js which hosts prebuilt messagix binaries
|
|
14
|
-
return "yumi-team/meta-messenger.js";
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function latestTag() {
|
|
18
|
-
return "v1.1.3";
|
|
19
|
-
}
|
|
20
|
-
|
|
21
12
|
function buildBaseURL() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
// yumi-team/meta-messenger.js hosts prebuilt messagix binaries for all
|
|
14
|
+
// platforms except linux-x64-gnu, which ships directly in this package's
|
|
15
|
+
// prebuilt/ directory and is therefore never fetched from here.
|
|
16
|
+
const repo = "yumi-team/meta-messenger.js";
|
|
17
|
+
const tag = "v1.1.3";
|
|
18
|
+
return `https://github.com/${repo}/releases/download/${tag}`;
|
|
26
19
|
}
|
|
27
20
|
|
|
28
21
|
function httpGet(url, redirectCount = 0) {
|
package/scripts/postinstall.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { spawnSync } from "node:child_process";
|
|
2
1
|
import { existsSync } from "node:fs";
|
|
3
|
-
import { copyFile, mkdir
|
|
2
|
+
import { copyFile, mkdir } from "node:fs/promises";
|
|
4
3
|
import { dirname, join } from "node:path";
|
|
5
4
|
import { fileURLToPath } from "node:url";
|
|
6
5
|
|
|
@@ -49,13 +48,8 @@ async function run() {
|
|
|
49
48
|
console.log(`[${pkg.name}] Checking local prebuilt at: ${prebuilt}`);
|
|
50
49
|
if (await copyIfExists(prebuilt, buildOut)) {
|
|
51
50
|
console.log(`[${pkg.name}] Using local prebuilt for ${triplet}`);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
await rm(prebuiltDir, { recursive: true, force: true });
|
|
55
|
-
} catch {
|
|
56
|
-
//
|
|
57
|
-
}
|
|
58
|
-
}
|
|
51
|
+
// Keep the prebuilt copy so reinstalls (e.g. npm rebuild, CI caches) don't
|
|
52
|
+
// lose the patched binary and fall back to downloading an unpatched one.
|
|
59
53
|
console.log(`[${pkg.name}] postinstall completed in ${Date.now() - startTime}ms`);
|
|
60
54
|
return;
|
|
61
55
|
}
|
|
@@ -77,32 +71,20 @@ async function run() {
|
|
|
77
71
|
);
|
|
78
72
|
}
|
|
79
73
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
} catch (err) {
|
|
95
|
-
console.warn(`[${pkg.name}] Local build failed:`, err?.message || String(err));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
console.warn(`[${pkg.name}] No prebuilt found (local/remote) and no local build completed.`);
|
|
100
|
-
console.warn(`[${pkg.name}] Expected triplet: ${triplet}, file: messagix-${triplet}.${ext}`);
|
|
101
|
-
console.warn(
|
|
102
|
-
`[${pkg.name}] You can:\n` +
|
|
103
|
-
" - set MESSAGIX_BUILD_FROM_SOURCE=true and re-run install\n" +
|
|
104
|
-
" - or build manually with: npm run build:go",
|
|
105
|
-
);
|
|
74
|
+
console.warn(`[${pkg.name}] ──────────────────────────────────────────────────────────`);
|
|
75
|
+
console.warn(`[${pkg.name}] No prebuilt E2EE bridge found for your platform.`);
|
|
76
|
+
console.warn(`[${pkg.name}] Platform detected: ${triplet}`);
|
|
77
|
+
console.warn(`[${pkg.name}]`);
|
|
78
|
+
console.warn(`[${pkg.name}] Supported out-of-the-box:`);
|
|
79
|
+
console.warn(`[${pkg.name}] linux-x64-gnu (ships inside the npm package)`);
|
|
80
|
+
console.warn(`[${pkg.name}] linux-x64-musl / darwin-x64 / darwin-arm64 / win32-x64`);
|
|
81
|
+
console.warn(`[${pkg.name}] (downloaded automatically from yumi-team/meta-messenger.js)`);
|
|
82
|
+
console.warn(`[${pkg.name}]`);
|
|
83
|
+
console.warn(`[${pkg.name}] If the download failed, check your internet connection and retry:`);
|
|
84
|
+
console.warn(`[${pkg.name}] npm install`);
|
|
85
|
+
console.warn(`[${pkg.name}]`);
|
|
86
|
+
console.warn(`[${pkg.name}] Non-E2EE features (sendMessage, listen, etc.) work without the bridge.`);
|
|
87
|
+
console.warn(`[${pkg.name}] ──────────────────────────────────────────────────────────`);
|
|
106
88
|
}
|
|
107
89
|
|
|
108
90
|
run()
|
package/src/utils/axios.js
CHANGED
|
@@ -8,6 +8,7 @@ const FormData = require("form-data");
|
|
|
8
8
|
const { getHeaders } = require("./headers");
|
|
9
9
|
const { getType } = require("./constants");
|
|
10
10
|
const { globalRateLimiter } = require("./rateLimiter");
|
|
11
|
+
const { globalAntiSuspension } = require("./antiSuspension");
|
|
11
12
|
|
|
12
13
|
const jar = new CookieJar();
|
|
13
14
|
const client = wrapper(axios.create({ jar }));
|
|
@@ -112,6 +113,8 @@ async function inspectResponseForSessionIssues(adapted, ctx) {
|
|
|
112
113
|
typeof body === 'object' && body !== null && body.error === 1357001;
|
|
113
114
|
|
|
114
115
|
if (isLoginBlocked) {
|
|
116
|
+
// Trip the circuit breaker to stop retries while the account is flagged.
|
|
117
|
+
globalAntiSuspension.tripCircuitBreaker('login_blocked (1357001)', 45 * 60 * 1000);
|
|
115
118
|
const err = new Error('Facebook blocked the login.');
|
|
116
119
|
err.error = 'login_blocked';
|
|
117
120
|
err.res = body;
|
package/src/utils/clients.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { makeParsable, log, warn } = require("./constants");
|
|
4
4
|
const { globalRateLimiter, configureRateLimiter } = require("./rateLimiter");
|
|
5
|
+
const { globalAntiSuspension } = require("./antiSuspension");
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Formats a cookie array into a string for use in a cookie jar.
|
|
@@ -151,10 +152,17 @@ function parseAndCheckLogin(ctx, http, retryCount = 0) {
|
|
|
151
152
|
err.errorType = res.error === 1357004 ? "CHECKPOINT" : res.error === 1357031 ? "LOCKED" : "BLOCKED";
|
|
152
153
|
err.requiresReLogin = res.error === 1357004 || res.error === 1357031;
|
|
153
154
|
warn("Account Status", `${ACCOUNT_ERROR_CODES[res.error]} (Code: ${res.error})`);
|
|
155
|
+
// Trip the anti-suspension circuit breaker immediately for blocking errors.
|
|
156
|
+
// This prevents the bot from hammering Facebook while the account is flagged.
|
|
157
|
+
if (res.error === 1357001 || res.error === 1357033 || res.error === 2056003) {
|
|
158
|
+
const cooldownMs = res.error === 1357001 ? 45 * 60 * 1000 : 20 * 60 * 1000;
|
|
159
|
+
globalAntiSuspension.tripCircuitBreaker(ACCOUNT_ERROR_CODES[res.error], cooldownMs);
|
|
160
|
+
}
|
|
154
161
|
throw err;
|
|
155
162
|
}
|
|
156
163
|
|
|
157
164
|
if (res.error === 1357001 || (res.errorSummary && res.errorSummary.includes("blocked"))) {
|
|
165
|
+
globalAntiSuspension.tripCircuitBreaker("Facebook blocked the login (errorSummary)", 45 * 60 * 1000);
|
|
158
166
|
const err = new Error("Facebook blocked the login");
|
|
159
167
|
err.error = "Not logged in.";
|
|
160
168
|
err.errorType = "BLOCKED";
|
package/src/utils/formatters.js
CHANGED
|
@@ -1196,6 +1196,13 @@ function formatID(id) {
|
|
|
1196
1196
|
err.error = "Not logged in.";
|
|
1197
1197
|
err.requiresReLogin = true;
|
|
1198
1198
|
err.loginBlocked = res.error === 1357004;
|
|
1199
|
+
// Trip circuit breaker on blocking/locking to stop retries.
|
|
1200
|
+
if (res.error === 1357001) {
|
|
1201
|
+
try {
|
|
1202
|
+
const { globalAntiSuspension } = require('./antiSuspension');
|
|
1203
|
+
globalAntiSuspension.tripCircuitBreaker('login_blocked (1357001 via formatters)', 45 * 60 * 1000);
|
|
1204
|
+
} catch (_) {}
|
|
1205
|
+
}
|
|
1199
1206
|
throw err;
|
|
1200
1207
|
}
|
|
1201
1208
|
|