toru-fca 1.0.6 → 1.0.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/CHANGELOG.md CHANGED
@@ -1,54 +1,42 @@
1
1
  # CHANGELOG — toru-fca
2
2
 
3
- ## v1.0.6 (2026-09-03) — Ultimate Fixed, Advanced & Updated Release
4
-
5
- ### Bug Fixes
6
- - **sendTypingIndicatorV2.js** — `mqttClient` undefined bug patched (ctx.mqttClient এখন সঠিকভাবে reference হয়)
7
- - **logout.js** — Anti-logout message updated, v1.0.6 version reflect করে
8
- - **listenMqtt.js** — Banner updated: alpha-fca → toru-fca
9
-
10
- ### Improvements (v1.0.6)
11
- - **Anti-Logout** — fb_dtsg refresh interval 30min → 20min (আরো দ্রুত session alive রাখে)
12
- - **Session Guard** — Auto-save interval 5min → 3min, debounce 30s → 20s (দ্রুত appstate save)
13
- - **Facebook Protection** (NEW) — Anti-restriction, anti-ban, human-like delay system
14
- - `humanLikeDelay: true` — random 50-200ms micro-delay, bot traffic pattern unpredictable
15
- - `blockAutomationDetection: true` — online=false, updatePresence=false force করে
16
- - **config.json** — `facebookProtection`, `replyToInbox` option added
17
- - **checkUpdate.js** — Version 1.0.6 এ updated
18
- - **package.json** — Version 1.0.6, description updated
19
- - **examples/basic-bot.js** — Bengali comments, stopAntiLogout() on shutdown added
20
-
21
- ### What v1.0.6 Guarantees
22
- - ✅ Cookie দিয়ে login করলে browser থেকে logout হবে না
23
- - ✅ Bot run করলে Facebook account এ automation restriction আসবে না
24
- - ✅ Bot ID এর inbox এ reply যাবে (group এ নয়)
25
- - ✅ GoatBot এবং Facebook উভয়ের জন্য comfortable
26
- - ✅ কোনো system error crash করবে না
27
- - ✅ MQTT smooth এবং stable থাকবে
28
-
29
- ## v1.0.2 (2026-09-02) — Previous Stable Release
30
-
31
- ### Core Fixes
32
- - Anti-Logout: `api.logout()` blocked — Facebook cookie session never destroyed
33
- - fb_dtsg Auto-Refresh: every 30 min
34
- - Session Guard: backup, corruption check, debounce auto-save
35
- - Inbox Smooth: MQTT stable, no duplicate listeners, exponential backoff (3s–60s)
36
- - GoatBot Compatible: `selfListen`, `listenEvents`, `autoReconnect` defaults correct
37
- - Error-Free: global unhandledRejection + uncaughtException handled
38
- - E2EE Bridge: Labyrinth, auto-reconnect, DM + group support
39
-
40
- ### APIs Added in v1.0.2
41
- - `api.forceLogout()`, `api.stopAntiLogout()`, `api.saveSession(path)`
42
- - `api.sessionGuard(path, opts)`, `api.getHealth()`, `api.sendTypingIndicatorV2()`
43
-
44
- ### Merged From
45
- - toru-fca (base): MQTT spinner, E2EE, smooth mode
46
- - alpha-fca: refreshFb_dtsg, pinMessage, unsendMessage, setMessageReaction
47
- - mahmud-fca: sendTypingIndicatorV2, getMessage improvements
48
- - hridoy-fca: sessionGuard (backup + corruption guard)
49
-
50
- ## v1.0.1
51
- - Initial merged release
52
-
53
- ## v1.0.0
54
- - Base alpha-fca release
3
+ ## v1.0.6 — Ultimate Fixed, Advanced & Merged Release
4
+
5
+ ### 🔴 BROWSER LOGOUT FIX (ROOT CAUSE — FULLY FIXED)
6
+
7
+ **কারণ:** `forceLogin: true` ছিল।
8
+ - Facebook checkpoint এ "This was me" auto-submit করত
9
+ - Facebook নতুন session তৈরি করত → পুরনো browser session invalidate → **browser logout**
10
+
11
+ **Fix (3 স্তরে):**
12
+ 1. `forceLogin: false` — checkpoint auto-submit বন্ধ → browser session অক্ষুণ্ণ
13
+ 2. Cookie expiry minimum **1 বছর** — expire হলে session drop থেকে সুরক্ষা
14
+ 3. SessionGuard হর 3 মিনিটে **cookie expiry extend** — bot চলার সময় কখনো expire হবে না
15
+
16
+ ### ✅ সব Fix একসাথে
17
+
18
+ | File | Fix |
19
+ |---|---|
20
+ | `index.js` | forceLogin=false, cookie expiry 1yr, clean rewrite |
21
+ | `src/logout.js` | Cleaner no-op with better message |
22
+ | `src/refreshFb_dtsg.js` | Better pattern matching, error handling |
23
+ | `src/sendTypingIndicatorV2.js` | ctx.mqttClient undefined bug fixed |
24
+ | `src/listenMqtt.js` | ForcedFetch DM bug fixed, reaction off+timestamp added |
25
+ | `config.json` | facebookProtection added, 3min sessionGuard, 300ms smooth |
26
+ | `package.json` | Version 1.0.6 |
27
+ | `checkUpdate.js` | Version 1.0.6 |
28
+ | `examples/basic-bot.js` | Full rewrite, GoatBot compatible |
29
+
30
+ ### Features Active in v1.0.6
31
+
32
+ - ✅ Browser logout হবে না (cookie login)
33
+ - ✅ Automation restriction আসবে না
34
+ - ✅ Inbox/DM এবং Group — উভয়তেই bot reply করবে
35
+ - ✅ Reaction detect (off field + timestamp)
36
+ - ✅ GoatBot compatible
37
+ - ✅ MQTT stable, auto-reconnect
38
+ - ✅ E2EE bridge
39
+ - ✅ Error-free (no crash)
40
+
41
+ ## v1.0.2 — Previous Stable
42
+ - Anti-logout, session guard, inbox fix, GoatBot defaults, MQTT patch stream
package/checkUpdate.js CHANGED
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
-
3
2
  const CURRENT_VERSION = "1.0.6";
4
3
 
5
4
  async function checkForFCAUpdate() {
@@ -16,7 +15,7 @@ async function checkForFCAUpdate() {
16
15
  });
17
16
  if (data && data.version && data.version !== CURRENT_VERSION) {
18
17
  const log = require("npmlog");
19
- log.warn("toru-fca", "Update available: v" + CURRENT_VERSION + " → v" + data.version + " — run: npm update toru-fca");
18
+ log.warn("toru-fca", "Update available: v" + CURRENT_VERSION + " → v" + data.version + " — npm update toru-fca");
20
19
  }
21
20
  } catch (_) {}
22
21
  }
package/config.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
- "_info": "toru-fca v1.0.6 — Main Config. Edit values below as needed.",
3
-
4
- "version": "1.0.6",
2
+ "_info": "toru-fca v1.0.8 — Main Config",
3
+ "version": "1.0.8",
5
4
 
6
5
  "antiLogout": {
7
6
  "enabled": true,
8
7
  "refreshIntervalMs": 1200000,
9
- "_note": "Auto-refreshes fb_dtsg every 20 min (was 30). Keeps session alive. Prevents browser/automation logout. NEVER set to false."
8
+ "_note": "fb_dtsg হর 20 মিনিটে refresh — session alive রাখে। Browser logout হবে না।"
10
9
  },
11
10
 
12
11
  "sessionGuard": {
@@ -14,24 +13,24 @@
14
13
  "intervalMs": 180000,
15
14
  "debounceMs": 20000,
16
15
  "backupEnabled": true,
17
- "_note": "Saves appstate every 3 min (was 5). backupEnabled=true saves .bak before overwrite. Corruption check included."
16
+ "_note": "Appstate হর 3 মিনিটে auto-save। .bak backup রাখে। Cookie expiry extend করে।"
18
17
  },
19
18
 
20
19
  "automation": {
21
20
  "enabled": false,
22
- "_note": "KEEP FALSE. Background automation detection prevention. Enabling this risks Facebook account restriction."
21
+ "_note": "KEEP FALSE। Background automation বন্ধ রাখে।"
23
22
  },
24
23
 
25
24
  "smooth": {
26
25
  "enabled": true,
27
26
  "messageDelay": 300,
28
- "_note": "Shows typing indicator before sending. Human-like behavior. Reduces rate-limiting. messageDelay optimized to 300ms."
27
+ "_note": "Send করার আগে typing indicator দেখাবে। 300ms delay — human-like behavior।"
29
28
  },
30
29
 
31
30
  "connection": {
32
31
  "minDelayMs": 3000,
33
32
  "maxDelayMs": 60000,
34
- "_note": "MQTT reconnect backoff range in milliseconds."
33
+ "_note": "MQTT reconnect backoff range।"
35
34
  },
36
35
 
37
36
  "e2ee": {
@@ -40,20 +39,20 @@
40
39
  "devicePath": "./data/e2ee-device.json",
41
40
  "autoReconnect": true,
42
41
  "logLevel": "none",
43
- "_note": "E2EE Labyrinth bridge. saveType: memory (default) or path (persistent)."
44
- },
45
-
46
- "inbox": {
47
- "enabled": true,
48
- "replyToInbox": true,
49
- "_note": "Inbox always active. replyToInbox=true routes bot reply to bot inbox (not group). Required for bot message listening."
42
+ "_note": "E2EE Labyrinth bridge। DM + group support।"
50
43
  },
51
44
 
52
45
  "facebookProtection": {
53
46
  "enabled": true,
54
47
  "blockAutomationDetection": true,
55
48
  "humanLikeDelay": true,
56
- "_note": "v1.0.6 new. Blocks Facebook automation detection. humanLikeDelay adds random micro-delays to avoid pattern detection."
49
+ "_note": "online=false, updatePresence=false। Human-like 50-200ms micro-delay। Account restriction থেকে সুরক্ষা।"
50
+ },
51
+
52
+ "inbox": {
53
+ "enabled": true,
54
+ "replyToInbox": true,
55
+ "_note": "Bot inbox/DM এবং group উভয়তেই reply করবে।"
57
56
  },
58
57
 
59
58
  "enableTypingIndicator": false,
@@ -1,117 +1,88 @@
1
1
  /**
2
- * toru-fca v1.0.6 — Basic Bot Example (Updated)
2
+ * toru-fca v1.0.6 — basic-bot.js (GoatBot compatible example)
3
3
  *
4
- * Features demonstrated:
5
- * - Login with appState/Cookie (browser logout হবে না)
6
- * - Bot inbox e reply (group এ নয়, bot ID এর inbox এ)
7
- * - Session guard (auto-save appstate হর 3 মিনিটে)
8
- * - Anti-logout system (fb_dtsg 20 মিনিটে auto-refresh)
9
- * - Facebook Protection (automation detection বন্ধ)
10
- * - E2EE bridge (optional)
11
- * - Graceful shutdown
12
- * - GoatBot compatible
4
+ * Features:
5
+ * ✅ Cookie login — browser logout হবে না
6
+ * ✅ Inbox + Group — উভয়তেই bot reply করবে
7
+ * ✅ Session guard — appstate হর 3 মিনিটে auto-save
8
+ * ✅ Anti-logout — fb_dtsg 20 মিনিটে refresh
9
+ * ✅ Facebook protection — automation detection bypass
10
+ * ✅ Graceful shutdown
13
11
  */
14
12
 
15
13
  "use strict";
16
14
 
17
- const login = require("../index.js"); // or: require("toru-fca")
15
+ const login = require("../index.js");
18
16
  const fs = require("fs");
19
17
  const path = require("path");
20
18
 
21
- // ─── Config ──────────────────────────────────────────────────────────────────
22
19
  const APPSTATE_FILE = path.join(__dirname, "..", "appstate.json");
23
20
 
24
- // ─── Load appState (Cookie) ──────────────────────────────────────────────────
21
+ // ── Load appState (Cookie) ────────────────────────────────────────────────────
25
22
  let appState;
26
23
  try {
27
24
  appState = JSON.parse(fs.readFileSync(APPSTATE_FILE, "utf8"));
28
25
  } catch (err) {
29
- console.error("[toru-fca] Could not load appstate.json:", err.message);
30
- console.error(" Place your Facebook cookie appstate in: " + APPSTATE_FILE);
26
+ console.error("[toru-fca] ❌ Could not load appstate.json:", err.message);
31
27
  process.exit(1);
32
28
  }
33
29
 
34
- // ─── Login options (GoatBot compatible) ──────────────────────────────────────
30
+ // ── Login options (GoatBot compatible) ───────────────────────────────────────
35
31
  const options = {
36
- listenEvents : true,
37
- selfListen : false, // bot নিজের message শুনবে না
38
- listenTyping : false,
39
- updatePresence: false, // presence update বন্ধ (automation protection)
40
- autoMarkRead : false,
32
+ listenEvents : true,
33
+ selfListen : false, // bot নিজের message শুনবে না
34
+ autoReconnect : true,
35
+ online : false, // automation detection bypass
36
+ updatePresence : false,
37
+ forceLogin : false, // browser logout fix
38
+ autoMarkRead : false,
41
39
  autoMarkDelivery: false,
42
- autoReconnect : true,
43
- online : false, // offline mode — automation detection এড়ায়
44
- logLevel : "verbose"
40
+ logLevel : "verbose"
45
41
  };
46
42
 
47
- // ─── Login ───────────────────────────────────────────────────────────────────
43
+ // ── Login ─────────────────────────────────────────────────────────────────────
48
44
  login({ appState }, options, function (err, api) {
49
- if (err) {
50
- console.error("[toru-fca] ❌ Login failed:", err.message || err);
51
- process.exit(1);
52
- }
45
+ if (err) { console.error("[toru-fca] ❌ Login failed:", err.message || err); process.exit(1); }
53
46
 
54
- const userID = api.getCurrentUserID ? api.getCurrentUserID() : "unknown";
55
- console.log("[toru-fca] ✅ Logged in as:", userID);
47
+ const botID = api.getCurrentUserID ? api.getCurrentUserID() : "unknown";
48
+ console.log("[toru-fca] ✅ Bot running as:", botID);
56
49
 
57
- // ── Session guard: auto-save appstate হর 3 মিনিটে ─────────────────────
58
- api.sessionGuard(APPSTATE_FILE, {
59
- interval: 3 * 60 * 1000, // 3 min
60
- debounce: 20 * 1000, // 20 sec debounce
61
- backup: true // .bak file রাখে
62
- });
63
- console.log("[toru-fca] 🔒 Session guard active — auto-saving appstate.");
50
+ // Session guard — auto-save appstate হর 3 মিনিটে
51
+ api.sessionGuard(APPSTATE_FILE, { interval: 3 * 60 * 1000, backup: true });
64
52
 
65
- // ── E2EE Bridge (config.json e e2ee.enable:true থাকলে) ─────────────────
66
- if (api.connectE2EE) {
67
- api.connectE2EE(function (err, event) {
68
- if (err) { console.error("[E2EE]", err.message || err); return; }
69
- if (event && event.type) console.log("[E2EE]", event.type);
70
- }).catch(e => console.error("[E2EE] connect failed:", e.message));
71
- }
72
-
73
- // ── Main message listener ───────────────────────────────────────────────
53
+ // ── Main listener ─────────────────────────────────────────────────────────
74
54
  api.listenMqtt(function (err, event) {
75
- if (err) {
76
- console.error("[listen]", err);
77
- return;
78
- }
55
+ if (err) { console.error("[listen]", err); return; }
79
56
 
80
- // Handle normal inbox messages — bot inbox e reply করবে
57
+ // Group এবং Inbox/DM — উভয়তেই কাজ করবে
81
58
  if (event.type === "message") {
82
- const { threadID, senderID, body, isGroup, isE2EE } = event;
83
- const prefix = isE2EE ? "[E2EE]" : (isGroup ? "[Group]" : "[DM]");
84
- console.log(`${prefix} ${senderID}: ${body}`);
59
+ const { threadID, senderID, body, isGroup } = event;
60
+ const tag = isGroup ? "[Group]" : "[Inbox/DM]";
61
+ console.log(tag, senderID + ":", body);
85
62
 
86
- // Echo reply example — bot inbox e reply
63
+ // Echo bot
87
64
  if (body && body.toLowerCase() === "ping") {
88
- api.sendMessage("pong! 🏓 — toru-fca v1.0.6", threadID, function (err) {
89
- if (err) console.error("[sendMessage]", err);
90
- });
65
+ api.sendMessage("🏓 pong! — toru-fca v1.0.6", threadID);
91
66
  }
92
67
  }
93
68
 
94
- // Handle events (group joins, reactions, etc.)
95
- if (event.type === "event") {
96
- console.log("[event]", event.logMessageType || event.type);
69
+ // Reaction detect
70
+ if (event.type === "message_reaction") {
71
+ console.log("[Reaction]", event.senderID, event.off ? "removed reaction" : "reacted:", event.reaction);
97
72
  }
98
- });
99
73
 
100
- // ── Health check ────────────────────────────────────────────────────────
101
- setInterval(function () {
102
- const health = api.getHealth();
103
- if (!health.mqtt || !health.mqtt.connected) {
104
- console.warn("[health] MQTT not connected — autoReconnect will restore.");
74
+ // Events (group join, leave, etc.)
75
+ if (event.type === "event") {
76
+ console.log("[Event]", event.logMessageType || event.type);
105
77
  }
106
- }, 60 * 1000);
78
+ });
107
79
 
108
- // ── Graceful shutdown ───────────────────────────────────────────────────
80
+ // ── Graceful shutdown ─────────────────────────────────────────────────────
109
81
  function shutdown() {
110
82
  console.log("[toru-fca] Shutting down...");
111
83
  if (api.stopAntiLogout) api.stopAntiLogout();
112
84
  if (api.stopListenMqtt) api.stopListenMqtt();
113
- if (api.getE2EEBridge && api.getE2EEBridge()) api.getE2EEBridge().disconnect().catch(() => {});
114
- setTimeout(() => process.exit(0), 1500);
85
+ setTimeout(() => process.exit(0), 1000);
115
86
  }
116
87
  process.once("SIGINT", shutdown);
117
88
  process.once("SIGTERM", shutdown);