@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazyneoaz/testfca",
3
- "version": "1.0.1",
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": ">=22.12.0"
87
+ "node": ">=20.18.1"
88
88
  },
89
89
  "scripts": {
90
90
  "prepack": "echo 'Preparing package for npm...'",
@@ -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: { ...process.env, CGO_ENABLED: "1" },
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
- const repo = defaultRepoSlug();
23
- const versionTag = latestTag();
24
- const baseURL = `https://github.com/${repo}/releases/download/${versionTag}`;
25
- return baseURL.replace(/\/$/, "");
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) {
@@ -1,6 +1,5 @@
1
- import { spawnSync } from "node:child_process";
2
1
  import { existsSync } from "node:fs";
3
- import { copyFile, mkdir, rm } from "node:fs/promises";
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
- if (process.env.MESSAGIX_KEEP_PREBUILT !== "true") {
53
- try {
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
- // 3) No prebuilt available. Try local build if allowed
81
- if (process.env.MESSAGIX_BUILD_FROM_SOURCE === "true") {
82
- console.log(`[${pkg.name}] No prebuilt found. Attempting local build...`);
83
- try {
84
- const res = spawnSync(process.platform === "win32" ? "npm.cmd" : "npm", ["run", "build:go"], {
85
- cwd: join(__dirname, ".."),
86
- stdio: "inherit",
87
- env: process.env,
88
- });
89
- if (res.status === 0 && existsSync(buildOut)) {
90
- console.log(`[${pkg.name}] postinstall completed in ${Date.now() - startTime}ms`);
91
- return;
92
- }
93
- console.warn(`[${pkg.name}] Local build did not produce the native library.`);
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()
@@ -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;
@@ -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";
@@ -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