hridoy-ultimate 0.0.0-stage → 8.0.1

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.
Files changed (121) hide show
  1. package/ANALYSIS.md +31 -0
  2. package/AUDIT_REPORT.md +57 -0
  3. package/CHANGELOG.md +43 -0
  4. package/README.md +133 -2
  5. package/advancedSystem.js +95 -0
  6. package/checkUpdate.js +47 -0
  7. package/config.json +51 -0
  8. package/e2ee.js +738 -0
  9. package/examples/basic-bot.js +122 -0
  10. package/examples/e2ee-bot.js +141 -0
  11. package/fca-config.example.json +73 -0
  12. package/index.js +829 -0
  13. package/lib/index.mjs +1412 -0
  14. package/package.json +42 -4
  15. package/scripts/check.js +38 -0
  16. package/src/OldMessage.js +357 -0
  17. package/src/addExternalModule.js +25 -0
  18. package/src/addUserToGroup.js +117 -0
  19. package/src/changeAdminStatus.js +105 -0
  20. package/src/changeArchivedStatus.js +57 -0
  21. package/src/changeAvatar.js +138 -0
  22. package/src/changeAvatarV2.js +86 -0
  23. package/src/changeAvt.js +85 -0
  24. package/src/changeBio.js +78 -0
  25. package/src/changeBlockedStatus.js +51 -0
  26. package/src/changeBlockedStatusMqtt.js +75 -0
  27. package/src/changeCover.js +73 -0
  28. package/src/changeGroupImage.js +137 -0
  29. package/src/changeName.js +79 -0
  30. package/src/changeNickname.js +61 -0
  31. package/src/changeThreadColor.js +67 -0
  32. package/src/changeThreadEmoji.js +57 -0
  33. package/src/changeUsername.js +59 -0
  34. package/src/createCommentPost.js +232 -0
  35. package/src/createNewGroup.js +90 -0
  36. package/src/createPoll.js +73 -0
  37. package/src/createPost.js +276 -0
  38. package/src/deleteMessage.js +58 -0
  39. package/src/deleteThread.js +58 -0
  40. package/src/editMessage.js +76 -0
  41. package/src/editMessageOld.js +62 -0
  42. package/src/follow.js +74 -0
  43. package/src/forwardAttachment.js +62 -0
  44. package/src/friendList.js +104 -0
  45. package/src/getAccess.js +112 -0
  46. package/src/getAvatarUser.js +78 -0
  47. package/src/getBotInitialData.js +42 -0
  48. package/src/getCtx.js +5 -0
  49. package/src/getCurrentUserID.js +7 -0
  50. package/src/getEmojiUrl.js +29 -0
  51. package/src/getFriendsList.js +85 -0
  52. package/src/getMessage.js +849 -0
  53. package/src/getOptions.js +5 -0
  54. package/src/getRegion.js +7 -0
  55. package/src/getThreadHistory.js +682 -0
  56. package/src/getThreadHistoryDeprecated.js +71 -0
  57. package/src/getThreadInfo.js +232 -0
  58. package/src/getThreadInfoDeprecated.js +56 -0
  59. package/src/getThreadList.js +213 -0
  60. package/src/getThreadListDeprecated.js +46 -0
  61. package/src/getThreadPictures.js +59 -0
  62. package/src/getThreadTheme.js +81 -0
  63. package/src/getUID.js +119 -0
  64. package/src/getUserID.js +61 -0
  65. package/src/getUserInfo.js +66 -0
  66. package/src/handleFriendRequest.js +46 -0
  67. package/src/handleMessageRequest.js +47 -0
  68. package/src/httpGet.js +49 -0
  69. package/src/httpPost.js +48 -0
  70. package/src/httpPostFormData.js +70 -0
  71. package/src/listenMqtt.js +1081 -0
  72. package/src/listenNotification.js +85 -0
  73. package/src/logout.js +18 -0
  74. package/src/markAsDelivered.js +47 -0
  75. package/src/markAsRead.js +72 -0
  76. package/src/markAsReadAll.js +40 -0
  77. package/src/markAsSeen.js +48 -0
  78. package/src/metaTheme.js +189 -0
  79. package/src/muteThread.js +45 -0
  80. package/src/note.js +228 -0
  81. package/src/pinMessage.js +54 -0
  82. package/src/refreshFb_dtsg.js +49 -0
  83. package/src/removeSuspiciousAccount.js +78 -0
  84. package/src/removeUserFromGroup.js +81 -0
  85. package/src/reply.js +442 -0
  86. package/src/resolvePhotoUrl.js +47 -0
  87. package/src/searchForThread.js +53 -0
  88. package/src/searchFriends.js +140 -0
  89. package/src/searchStickers.js +53 -0
  90. package/src/send.js +46 -0
  91. package/src/sendButtons.js +163 -0
  92. package/src/sendComment.js +159 -0
  93. package/src/sendFriendRequest.js +112 -0
  94. package/src/sendMessage.js +441 -0
  95. package/src/sendMessageMqtt.js +323 -0
  96. package/src/sendTypingIndicator.js +68 -0
  97. package/src/sendTypingIndicatorV2.js +22 -0
  98. package/src/setActiveStatus.js +92 -0
  99. package/src/setMessageReaction.js +150 -0
  100. package/src/setMessageReactionMqtt.js +104 -0
  101. package/src/setMessageReactionSafe.js +44 -0
  102. package/src/setPostReaction.js +114 -0
  103. package/src/setProfileGuard.js +44 -0
  104. package/src/setProfileLock.js +97 -0
  105. package/src/setStoryReaction.js +133 -0
  106. package/src/setStorySeen.js +108 -0
  107. package/src/setThreadTheme.js +102 -0
  108. package/src/setTitle.js +92 -0
  109. package/src/shareContact.js +110 -0
  110. package/src/shareLink.js +59 -0
  111. package/src/stopListenMqtt.js +60 -0
  112. package/src/storyManager.js +357 -0
  113. package/src/suggestFriend.js +132 -0
  114. package/src/threadColors.js +131 -0
  115. package/src/unfriend.js +54 -0
  116. package/src/unsendMessage.js +68 -0
  117. package/src/uploadAttachment.js +115 -0
  118. package/test/fixes-1_2_4.test.js +118 -0
  119. package/test/mqtt-stop.test.js +32 -0
  120. package/test/reaction-mqtt.test.js +57 -0
  121. package/utils.js +3056 -0
package/ANALYSIS.md ADDED
@@ -0,0 +1,31 @@
1
+ # Analysis of the packages reviewed for toru-fca v1.2.1
2
+
3
+ ## Lineages
4
+ | Group | Packages | Notes |
5
+ |---|---|---|
6
+ | A (toru line) | HRIDOY-FCA 2.0.0, ST-FCA 1.2.29, toru-fca 1.1.0 / 1.2.0 | ST ≈ HRIDOY (only index/config/checkUpdate differ). toru 1.2.0 rewrote listenMqtt, refreshFb_dtsg, logout, sendMessage, stopListenMqtt, sendTypingIndicator, index. **Used as base.** |
7
+ | B (eryxenx line) | @eryxenx/fca 1.0.0 / 1.0.4 / 1.1.9, fca-eryxenx-merged, fca-abalcdiokay | ~75% identical files. TypeScript-free but different architecture (src/api/*, E2EE via Signal/koffi). |
8
+ | C (native line) | fca-native 5.0.0, Metachat 1.2.2 | Nearly the same code; adds ErrorHandler, SessionRecovery, rate limiter, etc. |
9
+ | D | shadowx-fca 10.8.0 | B-like plus extra helpers (unsendOnReaction, listenSpeed, reaction v2...). |
10
+ | E | xtreme-fca 1.0.2 | Single bundled dist (TS source not included). No anti-logout, no E2EE. |
11
+
12
+ ## Security findings (NOT merged)
13
+ - **Third-party login API:** group B (`module/loginHelper.js`, default `apiServer: https://minhdong.site`) and the fca-native example config (`https://donixdev.com`) can POST **email, password and the 2FA secret** to that server (`loginViaAPI` / `tokensViaAPI`). It only runs when `autoLogin:true`, but it is a credential-leak risk. Not included. toru-fca logs in only directly to facebook.com.
14
+ - **ST-FCA / HRIDOY `checkUpdate.js`** runs `npm install` automatically. Not included (toru's version only prints a notice).
15
+ - **remoteClient.js** (group B) opens a WebSocket to an arbitrary configured URL and accepts remote commands. Opt-in, but not included.
16
+ - **fca-abalcdiokay and fca-eryxenx-merged ship `Fca_Database/database.sqlite` containing `app_state_backups` rows** — most likely a saved Facebook session (cookies). I did not read it. If it is your account, treat it as exposed and log that session out / change the password. It is NOT in toru-fca.
17
+ - ST/HRIDOY `getUID` uses id.traodoisub.com / api.findids.net (username → uid). Present in toru base already; sends only a public username/URL.
18
+
19
+ ## Ideas ported into 1.2.1
20
+ - shadowx `setMessageReactionv2` → `setMessageReactionSafe` (MQTT first, HTTP retry fallback).
21
+ - Stale-MQTT-client guard (eryxenx `isActiveClient` idea) → `ctx.mqttClient !== mqttClient` guards.
22
+ - Reconnect backoff + old-client teardown (eryxenx/native CriticalBugFixes idea).
23
+
24
+ ## Not ported (and why)
25
+ - E2EE native binaries (messagix .so/.dll, ~17 MB each) — platform-specific, unverified; toru keeps its optional bridge, off by default.
26
+ - fca-native resilience classes (ConnectionPool, RateLimit, Monitoring...) — large, overlapping with what toru already has; would add risk.
27
+ - Theme/AI-theme, broadcast, scheduler, spy, bypassScrap modules — not needed for your goals; "spy/bypassScrap" are scraping-oriented.
28
+ - xtreme — compiled bundle only, cannot be reviewed line by line.
29
+
30
+ ## Limits of this review
31
+ No network, no real Facebook cookie: nothing was run against Facebook. Code was syntax-checked and key functions stub-tested.
@@ -0,0 +1,57 @@
1
+ # TORU-FCA 1.2.4 — Defect Fix Addendum
2
+
3
+ Found by a static review of the 1.2.3 archive (syntax check, require-resolution, TypeScript `checkJs` undefined-name scan, manual reading) and fixed in 1.2.4:
4
+
5
+ | # | File | Defect | Status |
6
+ |---|---|---|---|
7
+ | 1 | src/listenMqtt.js | `getSeqID` not in scope inside `scheduleReconnect` -> ReferenceError, auto-reconnect dead | Fixed + regression test |
8
+ | 2 | src/changeCover.js | `log` never required | Fixed + test |
9
+ | 3 | src/createCommentPost.js | `calback` typo; `image` undefined; errors resolved as success | Fixed + tests |
10
+ | 4 | package.json | `form-data`, `https-proxy-agent` undeclared; 3 unused deps | Fixed |
11
+ | 5 | checkUpdate.js | version hard-coded 1.2.1 | Fixed + test |
12
+ | 6 | fca-config.example.json | stale version 1.1.0 | Fixed |
13
+ | 7 | 5 src files | CRLF line endings | Normalised |
14
+
15
+ Not changed / still open: `yumi-json-bigint` is pinned to `*` (could not look up a safe version offline); no live Facebook/MQTT test was possible; the 1.2.3 limitations below still apply.
16
+
17
+ ---
18
+
19
+ # (previous) TORU-FCA 1.2.3 — Comparative Audit and Second-Stage Patch Report
20
+
21
+ ## Scope
22
+ This is a static source review and local unit-test run using the supplied TORU-FCA and HRIDOY-FCA archives. No Facebook account, live session, or production Messenger traffic was used. Other FCA archives were used as comparison references, not as proof of runtime correctness.
23
+
24
+ ## Changes carried into 1.2.3
25
+
26
+ ### MQTT lifecycle
27
+ - Clear an existing reconnect timer and dead-connection watchdog when `listenMqtt()` replaces/restarts the listener.
28
+ - Reject and remove pending `ctx.reqCallbacks` on current MQTT transport errors and close events, instead of leaving callbacks waiting until their individual timeout.
29
+ - On explicit `stopListenMqtt()`, clear pending request callbacks with an error and empty the callback map, including when no client is currently present.
30
+ - Added a unit test for pending callback cleanup on explicit stop.
31
+
32
+ ### E2EE bridge lifecycle
33
+ - Track the E2EE reconnect timer in bridge state and ensure repeated `disconnected` events do not create multiple reconnect timers.
34
+ - Use bounded exponential backoff with jitter and `unref()` the timer so it does not keep the Node process alive by itself.
35
+ - Clear reconnect timers on successful connect and explicit disconnect.
36
+ - Disable the native client's own auto-reconnect option and let TORU's wrapper manage retries, avoiding two competing retry managers.
37
+
38
+ ## Local verification
39
+ - `node --check` passed for `index.js`, `e2ee.js`, all `src/*.js` and all `test/*.js` files.
40
+ - `npm test`: 3 tests passed, 0 failed.
41
+ - `npm run check`: passed.
42
+ - `npm pack --dry-run`: package contents validated for `toru-fca@1.2.3`.
43
+ - The publishable source archive excludes obvious session filenames (`cookie.txt`, `appstate.json`, `*.session`). This does not prove every file is free of secrets; review before publishing.
44
+
45
+ ## Important limitations / not verified
46
+ 1. No live MQTT integration test was run. Reconnect timing, subscription restoration, sequence ID refresh, and callback cleanup still need a controlled integration test.
47
+ 2. No E2EE native bridge was loaded. The package archive does not bundle the required native `build/messagix` runtime binary, so E2EE connection, key persistence, and message delivery remain unverified.
48
+ 3. No multi-hour memory/listener soak test was run.
49
+ 4. `api.logout()` intentionally blocks logout and invokes its callback as success in the existing design. This remains misleading API behavior and should be redesigned in a separately documented breaking-change-safe patch.
50
+ 5. Reaction MQTT acknowledgment may confirm a transport/task response rather than proving the final reaction is visible to recipients. Timeout delivery remains unknown.
51
+ 6. No patch can guarantee Facebook session persistence or prevent server-side account restrictions.
52
+
53
+ ## Recommended next steps
54
+ - Test MQTT disconnect/reconnect and manual stop in a sandbox using mocked sockets before using a live account.
55
+ - Confirm that the native E2EE client supports repeated `connect()` calls on the same instance after a disconnect; if not, recreate the client safely during retries and detach old listeners.
56
+ - Add GoatBot API compatibility tests and run a controlled 2–6 hour heap/RSS/listener soak test.
57
+ - Inspect all archive contents for credentials/session data before publishing.
package/CHANGELOG.md ADDED
@@ -0,0 +1,43 @@
1
+ # Changelog
2
+
3
+ ## 8.0.1
4
+ - Rename: package/branding is now `hridoy-ultimate` (was `toru-fca`) in banner, logs, update check, README, examples and config comments.
5
+ - Update check env var `HRIDOY_ULTIMATE_NO_UPDATE_CHECK` added (old `TORU_FCA_NO_UPDATE_CHECK` still honoured).
6
+ - Internal globals (`global._toruFcaConfig`, `_toruFcaInitDone`) intentionally unchanged for backward compatibility.
7
+
8
+ ## 1.2.4
9
+ - Fix (critical): `scheduleReconnect()` called `getSeqID()` which is only defined inside the module factory, so every MQTT reconnect threw `ReferenceError` in a timer. Now exposed as `ctx._getSeqID` and called with a try/catch.
10
+ - Fix: `changeCover` used `log` without requiring `npmlog`.
11
+ - Fix: `createCommentPost` typo `calback`, undefined `image` in attachment error, and `cb(null, err)` resolving errors as success (now rejects).
12
+ - Fix: `package.json` declares `form-data` and `https-proxy-agent` (were required but undeclared); removed unused `chalk`, `tough-cookie`, `protobufjs`.
13
+ - Fix: `checkUpdate.js` hard-coded version 1.2.1; now read from `package.json`.
14
+ - Chore: example config version synced; CRLF -> LF in `reply.js`, `getUID.js`, `httpGet.js`, `httpPost.js`, `changeAvt.js`.
15
+ - Add: `scripts/check.js` (`npm run check`) and `test/fixes-1_2_4.test.js` (6 regression tests, incl. a reconnect test verified to fail on the old code).
16
+
17
+ ## 1.2.3
18
+ - Fix: E2EE reconnect timers are tracked, deduplicated, bounded with exponential backoff, and cleared on explicit disconnect.
19
+ - Fix: TORU owns E2EE reconnect scheduling to avoid competing reconnect managers.
20
+ - Fix: MQTT listener replacement clears stale reconnect/watchdog timers.
21
+ - Fix: pending MQTT request callbacks are failed and cleaned up on transport error/close or explicit stop.
22
+ - Add: regression test for pending MQTT callback cleanup on stop.
23
+
24
+ ## 1.2.2
25
+ - Fix: reaction MQTT requests now reject on missing acknowledgement instead of assuming success.
26
+ - Fix: reaction MQTT callback and Promise settle once and share the same result.
27
+ - Fix: forward explicit MQTT response errors to request callbacks.
28
+ - Fix: callback type checks no longer execute user callbacks as a test (pin/edit/block helpers).
29
+ - Fix: atomic session writes use unique temporary names and restrictive file permissions.
30
+ - Add: Node.js syntax-check script and focused MQTT reaction tests.
31
+
32
+
33
+ ## 1.2.1
34
+ - Fix: setMessageReactionMqtt invoked the user callback prematurely / threw synchronously; now Promise+callback, real ack.
35
+ - Add: `/ls_resp` dispatch to `ctx.reqCallbacks` (reaction/pin/block helpers finally get acks).
36
+ - Add: richer `message_reaction` event (off, action, isGroup, isSingleUser, null-safe).
37
+ - Fix: stale MQTT client events caused duplicate reconnects; old client is now torn down first.
38
+ - Fix: getSeqID transient failure during reconnect no longer kills the listener (backoff retry).
39
+ - Fix: cookie expiry extension edited a copy; now updates the live jar.
40
+ - Fix: login callback double-fire guard.
41
+ - Change: uncaughtException logs stack for non-network errors.
42
+ - Change: e2ee disabled by default; spinner TTY-only; update check opt-out.
43
+
package/README.md CHANGED
@@ -1,3 +1,134 @@
1
- # Temporary Holding Version
1
+ # hridoy-ultimate v8.0.1
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Ultimate Merged, Fixed & Advanced Facebook Chat API**
4
+
5
+ > Cookie-based login, session persistence, and MQTT reconnection are best-effort. Server-side logout, checkpoints, and platform restrictions cannot be prevented or guaranteed against by this library.
6
+
7
+ ---
8
+
9
+ ## ✅ Features
10
+
11
+ | Feature | Status |
12
+ |---|---|
13
+ | Session refresh helper (best-effort) | ⚠️ Best-effort only |
14
+ | Conservative presence/delay options | ⚠️ No guarantee |
15
+ | Inbox Smooth (bot inbox reply) | ✅ Active |
16
+ | GoatBot Compatible | ✅ Ready |
17
+ | Session Guard (auto-save) | ✅ Every 3min |
18
+ | fb_dtsg Auto-Refresh | ✅ Every 20min |
19
+ | MQTT Stable Reconnect | ✅ Active |
20
+ | Error reporting | ✅ Host process handlers preserved |
21
+ | E2EE Labyrinth Bridge | ✅ Active |
22
+ | Facebook Protection | ✅ New in v1.0.6 |
23
+ | Human-like Delay | ✅ New in v1.0.6 |
24
+
25
+ ---
26
+
27
+ ## 📦 Install
28
+
29
+ ```bash
30
+ npm install
31
+ ```
32
+
33
+ ---
34
+
35
+ ## 🚀 Usage (GoatBot / Goat-Bot)
36
+
37
+ ```js
38
+ const login = require("hridoy-ultimate");
39
+ const fs = require("fs");
40
+
41
+ login({ appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) }, {
42
+ listenEvents: true,
43
+ selfListen: false,
44
+ autoReconnect: true,
45
+ online: false
46
+ }, (err, api) => {
47
+ if (err) return console.error(err);
48
+
49
+ // Session guard — auto-save appstate
50
+ api.sessionGuard("appstate.json");
51
+
52
+ api.listenMqtt((err, event) => {
53
+ if (event.type === "message") {
54
+ api.sendMessage("Hello!", event.threadID);
55
+ }
56
+ });
57
+ });
58
+ ```
59
+
60
+ ---
61
+
62
+ ## ⚙️ config.json Options
63
+
64
+ ```json
65
+ {
66
+ "antiLogout": { "enabled": true, "refreshIntervalMs": 1200000 },
67
+ "sessionGuard": { "enabled": true, "intervalMs": 180000 },
68
+ "automation": { "enabled": false },
69
+ "smooth": { "enabled": true, "messageDelay": 300 },
70
+ "facebookProtection": { "enabled": true, "blockAutomationDetection": true, "humanLikeDelay": true },
71
+ "inbox": { "enabled": true, "replyToInbox": true }
72
+ }
73
+ ```
74
+
75
+ ---
76
+
77
+ ## 🔐 Anti-Logout System
78
+
79
+ Cookie login করলে `api.logout()` automatically blocked হয়।
80
+ - Session refresh does not guarantee that Facebook will preserve a login session
81
+ - `api.logout()` is currently overridden; use `api.forceLogout()` only when you explicitly intend to terminate the session
82
+ - Force logout দরকার হলে: `api.forceLogout()`
83
+ - Anti-logout বন্ধ করতে: `api.stopAntiLogout()`
84
+
85
+ ---
86
+
87
+ ## 📊 API Methods
88
+
89
+ | Method | Description |
90
+ |---|---|
91
+ | `api.sendMessage(msg, threadID)` | Message পাঠাও |
92
+ | `api.listenMqtt(callback)` | Message শোনো |
93
+ | `api.sessionGuard(path, opts)` | Appstate auto-save |
94
+ | `api.saveSession(path)` | Manual session save |
95
+ | `api.getHealth()` | MQTT + session health |
96
+ | `api.forceLogout()` | Force logout (opt-in) |
97
+ | `api.stopAntiLogout()` | Anti-logout timer বন্ধ |
98
+ | `api.refreshFb_dtsg()` | Manual fb_dtsg refresh |
99
+ | `api.sendTypingIndicatorV2(typing, threadID)` | MQTT typing indicator |
100
+
101
+ ---
102
+
103
+ ## 🛡️ Facebook Protection (v1.0.6)
104
+
105
+ - `humanLikeDelay: true` — প্রতিটি message এ random 50-200ms delay, bot traffic pattern unpredictable
106
+ - `blockAutomationDetection: true` — online=false, presence update বন্ধ
107
+ - ফলে Facebook account এ restriction বা ban আসে না
108
+
109
+ ---
110
+
111
+ **hridoy-ultimate v8.0.1** — Built on toru-fca 1.2.0 (itself derived from HRIDOY-FCA / ST-FCA). Other packages were analysed and only selected ideas were ported — see ANALYSIS.md
112
+
113
+
114
+ ## What's new in v1.2.4
115
+ - **Critical fix:** MQTT auto-reconnect crashed with `ReferenceError: getSeqID is not defined` (the reconnect timer called a function that lives in another scope). The factory now exposes it as `ctx._getSeqID` and the timer uses that, guarded by try/catch.
116
+ - `changeCover`: missing `npmlog` import (ReferenceError on every error path) fixed.
117
+ - `createCommentPost`: fixed `calback` typo (crash whenever a callback was passed), undefined `image` in the attachment error, and failures that *resolved* with the error object instead of rejecting.
118
+ - `package.json`: declared `form-data` and `https-proxy-agent` (both were required but missing); removed unused `chalk`, `tough-cookie`, `protobufjs`.
119
+ - `checkUpdate` now reads its version from `package.json` (was hard-coded 1.2.1). Example config version synced. CRLF line endings normalised to LF.
120
+ - New `npm run check` (syntax + relative/undeclared require check on every file) and regression tests in `test/fixes-1_2_4.test.js`.
121
+
122
+ ## Earlier: v1.2.3
123
+ - **Reactions:** `message_reaction` events now carry `off`, `action` ("add"/"remove"), `userID` (reactor), `isGroup`, `isSingleUser` (inbox vs group) and are null-safe. `selfListen:false` also ignores the bot's own reactions.
124
+ - **api.setMessageReactionSafe(reaction, messageID, threadID, opts):** MQTT first, HTTP fallback with retry (idea from shadowx `setMessageReactionv2`). `setMessageReaction` now accepts any real emoji and no longer crashes on retry/redirect (it passed `ctx.jar` instead of `ctx` to `parseAndCheckLogin`; same bug fixed in `forwardAttachment`).
125
+ - **api.setMessageReactionMqtt:** the old `isCallable()` helper *called* your callback with no arguments and the call could throw synchronously. Fixed; supports callbacks and Promises; real ack via `/ls_resp`.
126
+ - **MQTT stability:** events from replaced clients are ignored (no double-reconnect loops), a failed `getSeqID` during reconnect now retries with backoff instead of silently killing the listener, spinner only draws on a TTY.
127
+ - **Session safety:** cookie-expiry extension now really works (v1.2.0 edited a throw-away copy). Login callback can no longer fire twice.
128
+ - **Errors:** uncaught exceptions are still non-fatal but now print the stack instead of hiding it.
129
+ - E2EE is off by default (needs the native `messagix` binary which is not bundled).
130
+ - Update check never installs anything; disable with `HRIDOY_ULTIMATE_NO_UPDATE_CHECK=1` (old `TORU_FCA_NO_UPDATE_CHECK` still works).
131
+
132
+ ## Honest notes
133
+ - Login: use `appState` (cookie array / cookie string). `api.logout()` is blocked on purpose; use `api.forceLogout()` if you really want to log out.
134
+ - "Facebook protection" (online=false, small delays) only lowers noise. No library can guarantee Facebook will not flag or checkpoint an account that is driven by a bot.
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * AdvancedSystem — minimal queue + health monitor for alpha-fca.
5
+ * Automation is OFF by default. No background polling, no aggressive requests.
6
+ * Only runs tasks you explicitly enqueue.
7
+ */
8
+
9
+ const EventEmitter = require("events");
10
+
11
+ class AdvancedSystem extends EventEmitter {
12
+ constructor(options) {
13
+ super();
14
+ options = options || {};
15
+ this.options = Object.assign({
16
+ automationEnabled: false,
17
+ minDelayMs: 1000,
18
+ maxDelayMs: 30000,
19
+ maxQueue: 50
20
+ }, options);
21
+ this.startedAt = Date.now();
22
+ this._queue = [];
23
+ this._running = false;
24
+ this._stats = { enqueued: 0, completed: 0, failed: 0 };
25
+ }
26
+
27
+ /** @returns {boolean} */
28
+ isAutomationEnabled() {
29
+ return this.options.automationEnabled === true;
30
+ }
31
+
32
+ /** Explicit opt-in only — no background automation started automatically. */
33
+ setAutomationEnabled(enabled) {
34
+ this.options.automationEnabled = Boolean(enabled);
35
+ this.emit("automation", this.options.automationEnabled);
36
+ return this.options.automationEnabled;
37
+ }
38
+
39
+ /** Health snapshot — safe to call anytime. */
40
+ health(api) {
41
+ const mqttClient = api && (api.mqttClient || (api.ctx && api.ctx.mqttClient));
42
+ return {
43
+ version: "1.0.0",
44
+ uptimeMs: Date.now() - this.startedAt,
45
+ automationEnabled: this.isAutomationEnabled(),
46
+ inboxEnabled: true,
47
+ mqtt: mqttClient ? {
48
+ connected: Boolean(mqttClient.connected),
49
+ reconnecting: Boolean(mqttClient.reconnecting)
50
+ } : null,
51
+ queue: { size: this._queue.length, running: this._running },
52
+ stats: Object.assign({}, this._stats)
53
+ };
54
+ }
55
+
56
+ /**
57
+ * Enqueue a task function. Runs sequentially.
58
+ * @param {Function} task async () => result
59
+ * @returns {Promise<any>}
60
+ */
61
+ enqueue(task) {
62
+ if (typeof task !== "function") return Promise.reject(new TypeError("task must be a function"));
63
+ if (this._queue.length >= this.options.maxQueue) {
64
+ return Promise.reject(new Error("AdvancedSystem queue is full (" + this.options.maxQueue + ")"));
65
+ }
66
+ this._stats.enqueued++;
67
+ return new Promise((resolve, reject) => {
68
+ this._queue.push({ task, resolve, reject });
69
+ this._drain();
70
+ });
71
+ }
72
+
73
+ async _drain() {
74
+ if (this._running || this._queue.length === 0) return;
75
+ this._running = true;
76
+ while (this._queue.length > 0) {
77
+ const { task, resolve, reject } = this._queue.shift();
78
+ try {
79
+ const result = await task();
80
+ this._stats.completed++;
81
+ resolve(result);
82
+ } catch (err) {
83
+ this._stats.failed++;
84
+ reject(err);
85
+ }
86
+ // Small throttle between tasks to avoid burst requests
87
+ if (this._queue.length > 0) {
88
+ await new Promise(r => setTimeout(r, this.options.minDelayMs));
89
+ }
90
+ }
91
+ this._running = false;
92
+ }
93
+ }
94
+
95
+ module.exports = AdvancedSystem;
package/checkUpdate.js ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ // v1.2.4: read from package.json so the notice can never drift from the real version.
4
+ const CURRENT_VERSION = (function () {
5
+ try { return require("./package.json").version; } catch (_) { return "0.0.0"; }
6
+ })();
7
+
8
+ async function checkForFCAUpdate() {
9
+ try {
10
+ if (process.env.HRIDOY_ULTIMATE_NO_UPDATE_CHECK || process.env.TORU_FCA_NO_UPDATE_CHECK) return; // v1.2.1: opt-out, never auto-installs anything
11
+ const https = require("https");
12
+
13
+ const data = await new Promise(function(resolve) {
14
+ var req = https.get(
15
+ "https://registry.npmjs.org/hridoy-ultimate/latest",
16
+ { timeout: 5000 },
17
+ function(res) {
18
+ var body = "";
19
+ res.on("data", function(c) { body += c; });
20
+ res.on("end", function() {
21
+ try { resolve(JSON.parse(body)); } catch (_) { resolve(null); }
22
+ });
23
+ res.on("error", function() { resolve(null); });
24
+ }
25
+ );
26
+ req.on("error", function() { resolve(null); });
27
+ // Destroy on timeout to avoid hanging socket
28
+ req.on("timeout", function() { req.destroy(); resolve(null); });
29
+ // Hard abort after 8s as a belt-and-suspenders guard
30
+ var hard = setTimeout(function() { try { req.destroy(); } catch (_) {} resolve(null); }, 8000);
31
+ if (hard.unref) hard.unref();
32
+ });
33
+
34
+ if (data && data.version && data.version !== CURRENT_VERSION) {
35
+ var log = require("npmlog");
36
+ log.warn(
37
+ "hridoy-ultimate",
38
+ "Update available: v" + CURRENT_VERSION + " \u2192 v" + data.version +
39
+ " \u2014 npm update hridoy-ultimate"
40
+ );
41
+ }
42
+ } catch (_) {
43
+ // Non-fatal; version check is best-effort only
44
+ }
45
+ }
46
+
47
+ module.exports = { checkForFCAUpdate, CURRENT_VERSION };
package/config.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "_info": "hridoy-ultimate v8.0.1 \u2014 Main Config",
3
+ "version": "1.2.4",
4
+ "antiLogout": {
5
+ "enabled": true,
6
+ "refreshIntervalMs": 1200000,
7
+ "_note": "Periodically refreshes fb_dtsg when supported; this cannot guarantee session persistence or prevent server-side logout."
8
+ },
9
+ "sessionGuard": {
10
+ "enabled": true,
11
+ "intervalMs": 180000,
12
+ "debounceMs": 20000,
13
+ "backupEnabled": true,
14
+ "_note": "Periodically saves valid appstate and a backup. Cookie expiry changes cannot override server-side session expiry."
15
+ },
16
+ "automation": {
17
+ "enabled": false,
18
+ "_note": "KEEP FALSE. Disables background automation. Protects against Facebook restrictions."
19
+ },
20
+ "smooth": {
21
+ "enabled": true,
22
+ "messageDelay": 300,
23
+ "_note": "Shows typing indicator before sending. 300ms delay for human-like behavior."
24
+ },
25
+ "connection": {
26
+ "minDelayMs": 3000,
27
+ "maxDelayMs": 60000,
28
+ "_note": "MQTT reconnect exponential backoff range."
29
+ },
30
+ "e2ee": {
31
+ "enable": false,
32
+ "saveType": "memory",
33
+ "devicePath": "./data/e2ee-device.json",
34
+ "autoReconnect": true,
35
+ "logLevel": "none",
36
+ "_note": "E2EE Labyrinth bridge. Needs the native build/messagix binary (not bundled). Keep false unless you add it."
37
+ },
38
+ "facebookProtection": {
39
+ "enabled": true,
40
+ "blockAutomationDetection": true,
41
+ "humanLikeDelay": true,
42
+ "_note": "Optional request delays and conservative presence settings; no method can guarantee avoidance of platform restrictions."
43
+ },
44
+ "inbox": {
45
+ "enabled": true,
46
+ "replyToInbox": true,
47
+ "_note": "Bot replies in both inbox/DM and group threads."
48
+ },
49
+ "enableTypingIndicator": false,
50
+ "typingDuration": 4000
51
+ }