@cexy/hoonfca 1.0.0 → 1.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 (188) hide show
  1. package/LICENSE +3 -0
  2. package/README.md +451 -43
  3. package/examples/login-with-cookies.js +102 -0
  4. package/examples/verify.js +70 -0
  5. package/index.js +1 -466
  6. package/package.json +98 -6
  7. package/src/apis/addExternalModule.js +24 -0
  8. package/src/apis/addUserToGroup.js +108 -0
  9. package/src/apis/changeAdminStatus.js +148 -0
  10. package/src/apis/changeArchivedStatus.js +61 -0
  11. package/src/apis/changeAvatar.js +103 -0
  12. package/src/apis/changeBio.js +69 -0
  13. package/src/apis/changeBlockedStatus.js +54 -0
  14. package/src/apis/changeGroupImage.js +136 -0
  15. package/src/apis/changeThreadColor.js +116 -0
  16. package/src/{changeThreadEmoji.js → apis/changeThreadEmoji.js} +7 -8
  17. package/src/apis/comment.js +207 -0
  18. package/src/apis/createAITheme.js +129 -0
  19. package/src/apis/createNewGroup.js +79 -0
  20. package/src/apis/createPoll.js +73 -0
  21. package/src/apis/deleteMessage.js +44 -0
  22. package/src/apis/deleteThread.js +52 -0
  23. package/src/apis/e2ee.js +17 -0
  24. package/src/apis/editMessage.js +70 -0
  25. package/src/apis/emoji.js +124 -0
  26. package/src/apis/fetchThemeData.js +82 -0
  27. package/src/apis/follow.js +81 -0
  28. package/src/apis/forwardMessage.js +52 -0
  29. package/src/apis/friend.js +243 -0
  30. package/src/apis/gcmember.js +122 -0
  31. package/src/apis/gcname.js +123 -0
  32. package/src/apis/gcrule.js +119 -0
  33. package/src/apis/getAccess.js +111 -0
  34. package/src/apis/getBotInfo.js +88 -0
  35. package/src/apis/getBotInitialData.js +43 -0
  36. package/src/apis/getFriendsList.js +79 -0
  37. package/src/apis/getMessage.js +423 -0
  38. package/src/apis/getTheme.js +95 -0
  39. package/src/apis/getThemeInfo.js +116 -0
  40. package/src/apis/getThreadHistory.js +239 -0
  41. package/src/apis/getThreadInfo.js +267 -0
  42. package/src/apis/getThreadList.js +232 -0
  43. package/src/apis/getThreadPictures.js +58 -0
  44. package/src/apis/getUserID.js +117 -0
  45. package/src/apis/getUserInfo.js +513 -0
  46. package/src/apis/getUserInfoV2.js +146 -0
  47. package/src/apis/handleMessageRequest.js +50 -0
  48. package/src/apis/httpGet.js +63 -0
  49. package/src/apis/httpPost.js +89 -0
  50. package/src/apis/httpPostFormData.js +69 -0
  51. package/src/apis/listenMqtt.js +1236 -0
  52. package/src/apis/listenSpeed.js +179 -0
  53. package/src/apis/logout.js +87 -0
  54. package/src/apis/markAsDelivered.js +47 -0
  55. package/src/apis/markAsRead.js +99 -0
  56. package/src/apis/markAsReadAll.js +40 -0
  57. package/src/apis/markAsSeen.js +70 -0
  58. package/src/apis/mqttDeltaValue.js +278 -0
  59. package/src/apis/muteThread.js +45 -0
  60. package/src/apis/nickname.js +132 -0
  61. package/src/apis/notes.js +163 -0
  62. package/src/apis/pinMessage.js +150 -0
  63. package/src/apis/produceMetaTheme.js +180 -0
  64. package/src/apis/realtime.js +182 -0
  65. package/src/apis/removeUserFromGroup.js +117 -0
  66. package/src/apis/resolvePhotoUrl.js +58 -0
  67. package/src/apis/searchForThread.js +154 -0
  68. package/src/apis/sendMessage.js +354 -0
  69. package/src/apis/sendMessageMqtt.js +249 -0
  70. package/src/apis/sendTypingIndicator.js +91 -0
  71. package/src/apis/setMessageReaction.js +27 -0
  72. package/src/apis/setMessageReactionMqtt.js +61 -0
  73. package/src/apis/setThreadTheme.js +260 -0
  74. package/src/apis/setThreadThemeMqtt.js +94 -0
  75. package/src/apis/share.js +107 -0
  76. package/src/apis/shareContact.js +66 -0
  77. package/src/apis/stickers.js +257 -0
  78. package/src/apis/story.js +181 -0
  79. package/src/apis/theme.js +233 -0
  80. package/src/apis/unfriend.js +47 -0
  81. package/src/apis/unsendMessage.js +17 -0
  82. package/src/engine/client.js +92 -0
  83. package/src/engine/models/buildAPI.js +152 -0
  84. package/src/engine/models/loginHelper.js +519 -0
  85. package/src/engine/models/setOptions.js +88 -0
  86. package/src/security/e2ee.js +109 -0
  87. package/src/types/index.d.ts +498 -0
  88. package/src/utils/antiSuspension.js +506 -0
  89. package/src/utils/auth-helpers.js +149 -0
  90. package/src/utils/autoReLogin.js +336 -0
  91. package/src/utils/axios.js +436 -0
  92. package/src/utils/cache.js +54 -0
  93. package/src/utils/clients.js +282 -0
  94. package/src/utils/constants.js +410 -0
  95. package/src/utils/formatters/data/formatAttachment.js +370 -0
  96. package/src/utils/formatters/data/formatDelta.js +109 -0
  97. package/src/utils/formatters/index.js +159 -0
  98. package/src/utils/formatters/value/formatCookie.js +91 -0
  99. package/src/utils/formatters/value/formatDate.js +36 -0
  100. package/src/utils/formatters/value/formatID.js +16 -0
  101. package/src/utils/formatters.js +1373 -0
  102. package/src/utils/headers.js +230 -0
  103. package/src/utils/index.js +153 -0
  104. package/src/utils/monitoring.js +333 -0
  105. package/src/utils/rateLimiter.js +319 -0
  106. package/src/utils/tokenRefresh.js +657 -0
  107. package/src/utils/user-agents.js +238 -0
  108. package/src/utils/validation.js +157 -0
  109. package/replit.nix +0 -3
  110. package/src/addExternalModule.js +0 -25
  111. package/src/addUserToGroup.js +0 -98
  112. package/src/changeAdminStatus.js +0 -98
  113. package/src/changeArchivedStatus.js +0 -51
  114. package/src/changeAvatar.js +0 -89
  115. package/src/changeBio.js +0 -74
  116. package/src/changeBlockedStatus.js +0 -45
  117. package/src/changeBlockedStatusMqtt.js +0 -65
  118. package/src/changeCover.js +0 -92
  119. package/src/changeGroupImage.js +0 -110
  120. package/src/changeName.js +0 -106
  121. package/src/changeNickname.js +0 -58
  122. package/src/changeThreadColor.js +0 -62
  123. package/src/changeUsername.js +0 -80
  124. package/src/createCommentPost.js +0 -196
  125. package/src/createNewGroup.js +0 -81
  126. package/src/createPoll.js +0 -64
  127. package/src/createPost.js +0 -285
  128. package/src/data/getThreadInfo.json +0 -1
  129. package/src/deleteMessage.js +0 -55
  130. package/src/deleteThread.js +0 -55
  131. package/src/editMessage.js +0 -66
  132. package/src/follow.js +0 -71
  133. package/src/forwardAttachment.js +0 -57
  134. package/src/getAccess.js +0 -130
  135. package/src/getAvatarUser.js +0 -88
  136. package/src/getBotInitialData.js +0 -59
  137. package/src/getCtx.js +0 -5
  138. package/src/getCurrentUserID.js +0 -5
  139. package/src/getEmojiUrl.js +0 -18
  140. package/src/getFriendsList.js +0 -81
  141. package/src/getMessage.js +0 -827
  142. package/src/getOptions.js +0 -5
  143. package/src/getRegion.js +0 -7
  144. package/src/getThreadHistory.js +0 -496
  145. package/src/getThreadHistoryDeprecated.js +0 -95
  146. package/src/getThreadInfo.js +0 -194
  147. package/src/getThreadInfoDeprecated.js +0 -77
  148. package/src/getThreadList.js +0 -219
  149. package/src/getThreadListDeprecated.js +0 -86
  150. package/src/getThreadPictures.js +0 -85
  151. package/src/getUserID.js +0 -67
  152. package/src/getUserInfo.js +0 -89
  153. package/src/handleFriendRequest.js +0 -56
  154. package/src/handleMessageRequest.js +0 -65
  155. package/src/httpGet.js +0 -53
  156. package/src/httpPost.js +0 -53
  157. package/src/httpPostFormData.js +0 -58
  158. package/src/listenMqtt.js +0 -683
  159. package/src/listenNotification.js +0 -96
  160. package/src/logout.js +0 -77
  161. package/src/markAsDelivered.js +0 -53
  162. package/src/markAsRead.js +0 -74
  163. package/src/markAsReadAll.js +0 -46
  164. package/src/markAsSeen.js +0 -57
  165. package/src/muteThread.js +0 -49
  166. package/src/pinMessage.js +0 -60
  167. package/src/refreshFb_dtsg.js +0 -75
  168. package/src/removeUserFromGroup.js +0 -59
  169. package/src/resolvePhotoUrl.js +0 -47
  170. package/src/searchForThread.js +0 -55
  171. package/src/searchStickers.js +0 -59
  172. package/src/sendMessage.js +0 -444
  173. package/src/sendMessageMqtt.js +0 -326
  174. package/src/sendTypingIndicator.js +0 -54
  175. package/src/setMessageReaction.js +0 -126
  176. package/src/setMessageReactionMqtt.js +0 -74
  177. package/src/setPostReaction.js +0 -103
  178. package/src/setProfileGuard.js +0 -66
  179. package/src/setStoryReaction.js +0 -97
  180. package/src/setTitle.js +0 -100
  181. package/src/shareContact.js +0 -101
  182. package/src/shareLink.js +0 -105
  183. package/src/stopListenMqtt.js +0 -47
  184. package/src/threadColors.js +0 -119
  185. package/src/unfriend.js +0 -58
  186. package/src/unsendMessage.js +0 -51
  187. package/src/uploadAttachment.js +0 -98
  188. package/utils.js +0 -919
package/LICENSE ADDED
@@ -0,0 +1,3 @@
1
+ All rights reserved to NeoKEX(github.com/NeoKEX)
2
+ ❌ PLEASE DO NOT STOLE MY SOURCE CODES AND CLAIM AS YOURS
3
+ Thanks for supporting ^_^
package/README.md CHANGED
@@ -1,83 +1,491 @@
1
- @cexy/hoonfca
1
+ # nkxfca
2
2
 
3
- A modern, fast, and actively maintained Facebook Chat API for Node.js.
4
- Built for Messenger bots with improved stability, performance, and compatibility.
3
+ [![npm version](https://img.shields.io/npm/v/@neoaz07/nkxfca.svg)](https://www.npmjs.com/package/@neoaz07/nkxfca)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@neoaz07/nkxfca.svg)](https://www.npmjs.com/package/@neoaz07/nkxfca)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Node.js Version](https://img.shields.io/node/v/@neoaz07/nkxfca.svg)](https://nodejs.org)
7
+
8
+ **nkxfca** is an advanced Facebook Chat API (FCA) client built for **reliable**, **real-time**, and **modular** interaction with Facebook Messenger.
9
+
10
+ Developed and maintained by **[NeoKEX](https://github.com/NeoKEX)**.
11
+ Inspired by **ws3-fca** and **@dongdev/fca-unofficial**
12
+
13
+ ---
14
+
15
+ ## Documentation
16
+
17
+ - **[Cookie Login Guide](COOKIE_LOGIN.md)** — Authenticate using browser cookies
18
+ - **[Changelog](CHANGELOG.md)** — Version history and updates
19
+ - **[Examples](examples/)** — Code examples and usage patterns
20
+
21
+ ### Support & Issues
22
+
23
+ - GitHub: [https://github.com/NeoKEX](https://github.com/NeoKEX)
24
+ - Issues: [https://github.com/NeoKEX/nkxfca/issues](https://github.com/NeoKEX/nkxfca/issues)
25
+
26
+ ---
27
+
28
+ ## Features
29
+
30
+ **Authentication**
31
+ - Cookie array login (`appState`) — the safest method for long-running bots
32
+ - Email/password login with TOTP/2FA support
33
+ - Session fingerprint locking — User-Agent, Sec-Ch-Ua, locale, timezone locked per session to prevent detection
34
+ - AppState auto-backup and restore on restart
35
+
36
+ **Real-time Messaging**
37
+ - MQTT and HTTP messaging with automatic protocol fallback
38
+ - Send text, attachments, stickers, emoji, mentions, and location
39
+ - Message editing, unsend, forward, and delete
40
+ - Message reactions via HTTP and MQTT
41
+ - Pin/unpin messages, list pinned messages
42
+
43
+ **Anti-Suspension System**
44
+ - Circuit breaker — halts activity after repeated suspension signals, resumes after cooldown
45
+ - 60+ suspension signal patterns: checkpoints, spam flags, rate limits, identity verification, policy violations, session expiry, and more
46
+ - Adaptive per-thread delay that increases with session volume
47
+ - Hourly and daily message volume limits with automatic warning pauses
48
+ - Warmup mode for fresh sessions — gradually increases allowed message rate
49
+ - Humanized typing simulation before every send
50
+ - Randomized request intervals and jitter to avoid periodicity detection
51
+ - Session fingerprint locking to maintain consistent browser identity
52
+ - PostSafe guard: detects auth failures and checkpoint responses in real-time
53
+ - MQTT watchdog: detects stale connections and forces clean reconnect
54
+
55
+ **Stability & Reliability**
56
+ - MQTT auto-reconnect with exponential backoff and jitter
57
+ - Auto re-login using refreshed AppState when session expires
58
+ - TokenRefreshManager with randomized intervals to keep sessions alive
59
+ - Sliding-window rate limiter with per-endpoint tracking and accurate concurrency control
60
+
61
+ **Thread & Group Management**
62
+ - Get thread info, history, pictures, and lists
63
+ - Create groups, add/remove members, change admin status
64
+ - Update group image, name, color, emoji
65
+ - Archive, mute, delete threads
66
+ - Create polls, manage notes and rules
67
+ - Search threads by name, handle message requests
68
+
69
+ **User & Friends**
70
+ - Get user info (basic and extended), resolve user IDs
71
+ - Get full friends list, send/cancel friend requests, unfriend, block/unblock
72
+
73
+ **Social**
74
+ - Comment on posts, share posts, follow/unfollow users
75
+
76
+ **Themes & Stickers**
77
+ - Browse 90+ Messenger themes, apply themes via MQTT
78
+ - Generate AI-powered themes with text prompts
79
+ - Search stickers, browse packs, add packs, get AI stickers
80
+
81
+ **E2EE (Opt-In)**
82
+ - Application-layer end-to-end encryption for DMs using X25519 + HKDF + AES-256-GCM
83
+
84
+ **Monitoring**
85
+ - `api.getHealthStatus()` — MQTT status, token refresh stats, rate limiter metrics
86
+ - Built-in `ProductionMonitor` for request/error/performance telemetry
87
+
88
+ **Proxy Support**
89
+ - Full proxy support via the `proxy` login option
90
+
91
+ ---
92
+
93
+ ## Installation
94
+
95
+ > **Requirements:** Node.js v20.0.0 or higher
96
+
97
+ ```bash
98
+ npm install @neoaz07/nkxfca
99
+ ```
100
+
101
+ ---
102
+
103
+ ## Quick Start
104
+
105
+ ```js
106
+ const fs = require("fs");
107
+ const { login } = require("@neoaz07/nkxfca");
108
+
109
+ const appState = JSON.parse(fs.readFileSync("appstate.json", "utf8"));
110
+
111
+ login({ appState }, {
112
+ online: true,
113
+ listenEvents: true,
114
+ autoMarkRead: true,
115
+ autoReconnect: true,
116
+ simulateTyping: true
117
+ }, (err, api) => {
118
+ if (err) return console.error("Login error:", err);
119
+
120
+ console.log("Logged in as:", api.getCurrentUserID());
121
+
122
+ api.listenMqtt((err, event) => {
123
+ if (err || event.type !== "message" || !event.body) return;
124
+
125
+ if (event.body === "/ping") {
126
+ api.sendMessage("pong!", event.threadID);
127
+ }
128
+ });
129
+ });
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Anti-Suspension Configuration
135
+
136
+ The anti-suspension system is active by default. You can tune it through login options:
137
+
138
+ ```js
139
+ login({ appState }, {
140
+ autoReconnect: true,
141
+ listenEvents: true,
142
+ autoMarkRead: true,
143
+ simulateTyping: true, // humanized typing delays before send
144
+ randomUserAgent: true, // rotate user agent on each session
145
+ persona: "desktop", // "desktop" or "android"
146
+ maxConcurrentRequests: 5, // max parallel HTTP requests
147
+ maxRequestsPerMinute: 50, // sliding-window rate cap
148
+ requestCooldownMs: 60000, // per-endpoint cooldown duration
149
+ errorCacheTtlMs: 300000 // how long to suppress repeated errors
150
+ }, (err, api) => {
151
+ if (err) throw err;
152
+
153
+ // Check anti-suspension and rate limiter status
154
+ console.log(api.getHealthStatus());
155
+ });
156
+ ```
157
+
158
+ ### Circuit Breaker
159
+
160
+ The circuit breaker trips automatically after detecting 2 or more suspension signals (checkpoints, spam flags, rate limits, etc.). It pauses all activity for 45 minutes by default.
161
+
162
+ You can also trip or reset it manually:
163
+
164
+ ```js
165
+ const { globalAntiSuspension } = require("@neoaz07/nkxfca/src/utils/antiSuspension");
166
+
167
+ // Manually trip (e.g. after you detect a warning in a response)
168
+ globalAntiSuspension.tripCircuitBreaker("manual_pause", 30 * 60 * 1000); // 30 min
169
+
170
+ // Reset after you've resolved the issue
171
+ globalAntiSuspension.resetCircuitBreaker();
172
+
173
+ // Check status
174
+ console.log(globalAntiSuspension.getConfig());
175
+ ```
176
+
177
+ ### Warmup Mode
178
+
179
+ Use warmup mode when starting a fresh or recovered session:
180
+
181
+ ```js
182
+ const { globalAntiSuspension } = require("@neoaz07/nkxfca/src/utils/antiSuspension");
183
+ globalAntiSuspension.enableWarmup(); // limits to 25 msg/hour for 20 minutes
184
+ ```
5
185
 
6
186
  ---
7
187
 
8
- 📦 Installation
188
+ ## End-to-End Encryption for DMs (Opt-In)
189
+
190
+ Encrypt and decrypt message bodies in direct chats using X25519 + HKDF + AES-256-GCM.
191
+
192
+ ```js
193
+ api.e2ee.enable();
194
+
195
+ // Share your bot's public key with the peer
196
+ const botPubKey = api.e2ee.getPublicKey();
197
+
198
+ // Register the peer's public key for a DM thread
199
+ api.e2ee.setPeerKey(threadID, peerPublicKeyBase64);
200
+
201
+ // Messages to that thread are now auto-encrypted on send
202
+ // and auto-decrypted on receive
203
+ api.sendMessage("Top secret message", threadID);
204
+ ```
205
+
206
+ ---
207
+
208
+ ## Security Warning
209
+
210
+ `appstate.json` contains your Facebook session and must be treated like a password:
211
+
212
+ - **Never commit `appstate.json` to version control**
213
+ - **Never share your `appstate.json` publicly**
214
+ - Add it to `.gitignore`
215
+ - Use environment variables or a secrets manager in production
216
+
217
+ ---
218
+
219
+ ## Getting Started — Generate `appstate.json`
220
+
221
+ 1. Install a cookie export extension:
222
+ - Chrome/Edge: **C3C FbState** or **CookieEditor**
223
+ - Firefox: **Cookie-Editor**
224
+
225
+ 2. Log in to Facebook in your browser
226
+
227
+ 3. Export cookies as JSON and save as `appstate.json`:
228
+
229
+ ```json
230
+ [
231
+ { "key": "c_user", "value": "your-user-id" },
232
+ { "key": "xs", "value": "your-xs-value" }
233
+ ]
234
+ ```
9
235
 
10
- Install the package using npm:
236
+ 4. Use in your bot:
11
237
 
12
- npm install @cexy/rakibfca
238
+ ```js
239
+ const { login } = require("@neoaz07/nkxfca");
240
+ const appState = require("./appstate.json");
241
+ login({ appState }, {}, (err, api) => { ... });
242
+ ```
243
+
244
+ See **[COOKIE_LOGIN.md](COOKIE_LOGIN.md)** for more formats and troubleshooting.
13
245
 
14
246
  ---
15
247
 
16
- 🚀 Usage
248
+ ## Bot Example with Commands
249
+
250
+ ```js
251
+ const fs = require("fs");
252
+ const path = require("path");
253
+ const { login } = require("@neoaz07/nkxfca");
17
254
 
18
- const login = require("@cexy/rakibfca");
255
+ const appState = JSON.parse(fs.readFileSync("appstate.json", "utf8"));
19
256
 
20
- login(
21
- {
22
- appState: require("./appstate.json")
23
- },
24
- (err, api) => {
25
- if (err) return console.error(err);
257
+ login({ appState }, {
258
+ online: true,
259
+ selfListen: false,
260
+ simulateTyping: true,
261
+ autoReconnect: true
262
+ }, async (err, api) => {
263
+ if (err) return console.error("Login error:", err);
26
264
 
27
- console.log("Logged in as:", api.getCurrentUserID());
265
+ console.log("Logged in as:", api.getCurrentUserID());
28
266
 
29
- api.listenMqtt((err, event) => {
30
- if (err) return console.error(err);
267
+ const commandsDir = path.join(__dirname, "commands");
268
+ const commands = new Map();
31
269
 
32
- console.log(event);
33
- });
270
+ if (fs.existsSync(commandsDir)) {
271
+ for (const file of fs.readdirSync(commandsDir).filter(f => f.endsWith(".js"))) {
272
+ const cmd = require(path.join(commandsDir, file));
273
+ if (cmd.name && typeof cmd.execute === "function") {
274
+ commands.set(cmd.name, cmd);
275
+ }
276
+ }
34
277
  }
35
- );
278
+
279
+ api.listenMqtt(async (err, event) => {
280
+ if (err || event.type !== "message" || !event.body) return;
281
+
282
+ const prefix = "/";
283
+ if (!event.body.startsWith(prefix)) return;
284
+
285
+ const args = event.body.slice(prefix.length).trim().split(/ +/);
286
+ const name = args.shift().toLowerCase();
287
+ const cmd = commands.get(name);
288
+ if (!cmd) return;
289
+
290
+ try {
291
+ await cmd.execute({ api, event, args });
292
+ } catch (e) {
293
+ console.error(`Error in /${name}:`, e.message);
294
+ api.sendMessage("An error occurred.", event.threadID);
295
+ }
296
+ });
297
+ });
298
+ ```
36
299
 
37
300
  ---
38
301
 
39
- Features
302
+ ## AI Themes
40
303
 
41
- - ⚡ Fast and lightweight
42
- - 🔒 AppState login support
43
- - 💬 Messenger API support
44
- - 📩 MQTT listener
45
- - 🛠️ Regular bug fixes
46
- - 🚀 Performance improvements
47
- - 📦 Easy integration with Node.js projects
304
+ ```js
305
+ // Generate an AI theme from a text prompt
306
+ const aiThemes = await api.createAITheme("vibrant ocean sunset purple");
307
+ if (aiThemes && aiThemes.length > 0) {
308
+ await api.setThreadThemeMqtt(threadID, aiThemes[0].id);
309
+ }
310
+
311
+ // Browse standard themes
312
+ const themes = await api.getTheme(threadID);
313
+ await api.setThreadThemeMqtt(threadID, themes[0].id);
314
+
315
+ // Check current theme
316
+ const info = await api.getThemeInfo(threadID);
317
+ console.log(info.color, info.emoji);
318
+ ```
48
319
 
49
320
  ---
50
321
 
51
- 📋 Requirements
322
+ ## API Reference
323
+
324
+ ### Authentication
325
+ | Method | Description |
326
+ |---|---|
327
+ | `login(credentials, options, callback)` | Log in and receive the API object |
328
+ | `api.logout()` | End the session |
329
+ | `api.getAppState()` | Get current session cookies |
330
+ | `api.getCurrentUserID()` | Get logged-in user ID |
331
+
332
+ ### Messaging
333
+ | Method | Description |
334
+ |---|---|
335
+ | `api.sendMessage(msg, threadID)` | Send (HTTP + MQTT fallback) |
336
+ | `api.sendMessageMqtt(msg, threadID)` | Send over MQTT |
337
+ | `api.editMessage(text, messageID)` | Edit a message |
338
+ | `api.unsendMessage(messageID, threadID)` | Retract a message |
339
+ | `api.forwardMessage(messageID, threadID)` | Forward a message |
340
+ | `api.deleteMessage(messageIDs)` | Delete locally |
341
+ | `api.shareContact(senderID, threadID)` | Share a contact card |
342
+
343
+ ### Reactions & Status
344
+ | Method | Description |
345
+ |---|---|
346
+ | `api.setMessageReaction(reaction, messageID)` | React via HTTP |
347
+ | `api.setMessageReactionMqtt(reaction, messageID, threadID)` | React via MQTT |
348
+ | `api.sendTypingIndicator(isTyping, threadID)` | Show/hide typing |
349
+ | `api.markAsRead(threadID)` | Mark thread as read |
350
+ | `api.markAsReadAll()` | Mark all threads as read |
351
+ | `api.markAsSeen()` | Mark as seen |
352
+ | `api.markAsDelivered(threadID, messageID)` | Mark as delivered |
353
+
354
+ ### Threads
355
+ | Method | Description |
356
+ |---|---|
357
+ | `api.getThreadInfo(threadID)` | Thread metadata |
358
+ | `api.getThreadList(limit, timestamp, tags)` | List threads |
359
+ | `api.getThreadHistory(threadID, amount, timestamp)` | Message history |
360
+ | `api.getThreadPictures(threadID, offset, limit)` | Thread images |
361
+ | `api.searchForThread(name)` | Search by name |
362
+ | `api.createNewGroup(participantIDs, name?)` | Create group |
363
+ | `api.deleteThread(threadID)` | Delete thread |
364
+ | `api.muteThread(threadID, muteSeconds)` | Mute thread |
365
+ | `api.changeArchivedStatus(threadID, archive)` | Archive/unarchive |
366
+ | `api.pinMessage(action, threadID, messageID?)` | Pin/unpin/list |
367
+ | `api.createPoll(title, threadID, options?)` | Create poll |
368
+ | `api.handleMessageRequest(threadID, accept)` | Accept/decline |
52
369
 
53
- - Node.js 20+
54
- - npm 10+
370
+ ### Group Admin
371
+ | Method | Description |
372
+ |---|---|
373
+ | `api.addUserToGroup(userID, threadID)` | Add member |
374
+ | `api.removeUserFromGroup(userID, threadID)` | Remove member |
375
+ | `api.changeAdminStatus(threadID, userID, isAdmin)` | Promote/demote |
376
+ | `api.changeGroupImage(image, threadID)` | Group photo |
377
+ | `api.gcname(name, threadID)` | Rename group |
378
+
379
+ ### Users
380
+ | Method | Description |
381
+ |---|---|
382
+ | `api.getUserInfo(id)` | Basic user info |
383
+ | `api.getUserInfoV2(id)` | Extended user info |
384
+ | `api.getUserID(name)` | Resolve name to ID |
385
+ | `api.getFriendsList()` | Friends list |
386
+ | `api.getBotInfo()` | Bot account info |
387
+
388
+ ### Themes & Customization
389
+ | Method | Description |
390
+ |---|---|
391
+ | `api.getTheme(threadID)` | List available themes |
392
+ | `api.getThemeInfo(threadID)` | Current theme |
393
+ | `api.setThreadThemeMqtt(threadID, themeID)` | Apply theme |
394
+ | `api.createAITheme(prompt)` | AI theme |
395
+ | `api.changeThreadColor(color, threadID)` | Thread color |
396
+ | `api.changeThreadEmoji(emoji, threadID)` | Thread emoji |
397
+ | `api.nickname(nickname, threadID, participantID)` | Set nickname |
398
+ | `api.emoji(emoji, threadID)` | Thread emoji shorthand |
399
+
400
+ ### Stickers
401
+ | Method | Description |
402
+ |---|---|
403
+ | `api.stickers.search(query)` | Search stickers |
404
+ | `api.stickers.listPacks()` | Installed packs |
405
+ | `api.stickers.getStorePacks()` | Sticker store |
406
+ | `api.stickers.addPack(packID)` | Add pack |
407
+ | `api.stickers.getStickersInPack(packID)` | Stickers in pack |
408
+ | `api.stickers.getAiStickers(options?)` | AI stickers |
409
+
410
+ ### E2EE
411
+ | Method | Description |
412
+ |---|---|
413
+ | `api.e2ee.enable()` | Enable E2EE |
414
+ | `api.e2ee.disable()` | Disable E2EE |
415
+ | `api.e2ee.getPublicKey()` | Get public key |
416
+ | `api.e2ee.setPeerKey(threadID, key)` | Set peer key |
417
+ | `api.e2ee.hasPeer(threadID)` | Has peer key |
418
+ | `api.e2ee.clearPeerKey(threadID)` | Remove peer key |
419
+
420
+ ### Social
421
+ | Method | Description |
422
+ |---|---|
423
+ | `api.comment(msg, postID)` | Comment on post |
424
+ | `api.share(postID)` | Share post |
425
+ | `api.follow(userID, follow)` | Follow/unfollow |
426
+ | `api.unfriend(userID)` | Unfriend |
427
+ | `api.changeBlockedStatus(userID, block)` | Block/unblock |
428
+
429
+ ### Health
430
+ | Method | Description |
431
+ |---|---|
432
+ | `api.getHealthStatus()` | MQTT, token, rate limiter stats |
55
433
 
56
434
  ---
57
435
 
58
- 📖 Installation Example
436
+ ## Login Options
59
437
 
60
- mkdir my-bot
61
- cd my-bot
62
- npm init -y
63
- npm install @cexy/rakibfca
438
+ | Option | Type | Default | Description |
439
+ |---|---|---|---|
440
+ | `online` | `boolean` | `true` | Appear online |
441
+ | `selfListen` | `boolean` | `false` | Receive own messages |
442
+ | `listenEvents` | `boolean` | `true` | Receive thread events |
443
+ | `listenTyping` | `boolean` | `false` | Receive typing events |
444
+ | `updatePresence` | `boolean` | `false` | Broadcast presence |
445
+ | `autoMarkDelivery` | `boolean` | `false` | Auto-mark delivered |
446
+ | `autoMarkRead` | `boolean` | `true` | Auto-mark read |
447
+ | `autoReconnect` | `boolean` | `true` | MQTT auto-reconnect |
448
+ | `simulateTyping` | `boolean` | `true` | Humanized typing delays |
449
+ | `randomUserAgent` | `boolean` | `false` | Random User-Agent |
450
+ | `persona` | `"desktop"\|"android"` | `"desktop"` | Browser persona |
451
+ | `proxy` | `string` | — | Proxy URL |
452
+ | `forceLogin` | `boolean` | `false` | Force fresh login |
453
+ | `maxConcurrentRequests` | `number` | `5` | Max parallel requests |
454
+ | `maxRequestsPerMinute` | `number` | `50` | Rate cap per minute |
455
+ | `requestCooldownMs` | `number` | `60000` | Endpoint cooldown |
456
+ | `errorCacheTtlMs` | `number` | `300000` | Error suppression TTL |
457
+ | `stealthMode` | `boolean` | `false` | Extra stealth headers |
64
458
 
65
459
  ---
66
460
 
67
- 🤝 Contributing
461
+ ## Examples
68
462
 
69
- Contributions, bug reports, and feature requests are always welcome.
463
+ See the **[examples/](examples/)** directory:
464
+ - `login-with-cookies.js` — Cookie-based authentication guide
465
+ - `verify.js` — Verify the library loads correctly
70
466
 
71
467
  ---
72
468
 
73
- 📄 License
469
+ ## Credits
74
470
 
75
- MIT License
471
+ - **Developed and maintained by [NeoKEX](https://github.com/NeoKEX)**
472
+ - **NeoKEX Team** — development, maintenance, and feature contributions
473
+ - **Inspired by ws3-fca** — by @NethWs3Dev and @CommunityExocore
474
+
475
+ > Copyright (c) 2026 NeoKEX
76
476
 
77
477
  ---
78
478
 
79
- 👨‍💻 Author
479
+ ## License
480
+
481
+ **MIT** — Free to use, modify, and distribute. Attribution appreciated.
482
+
483
+ See [LICENSE](LICENSE) for full license text.
484
+
485
+ ---
80
486
 
81
- Rakib Hasan
487
+ ## Links
82
488
 
83
- NPM: @cexy/hoonfca
489
+ - **npm:** [https://www.npmjs.com/package/@neoaz07/nkxfca](https://www.npmjs.com/package/@neoaz07/nkxfca)
490
+ - **GitHub:** [https://github.com/NeoKEX](https://github.com/NeoKEX)
491
+ - **Issues:** [https://github.com/NeoKEX/nkxfca/issues](https://github.com/NeoKEX/nkxfca/issues)
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ /**
5
+ * Example: Login with Cookie Array
6
+ *
7
+ * This demonstrates how to login to Facebook Chat API using a cookie array
8
+ * instead of email/password credentials.
9
+ *
10
+ * Cookie Format:
11
+ * - Array of objects with 'name' (or 'key') and 'value' properties
12
+ * - Extracted from browser cookies or previous session
13
+ */
14
+
15
+ const login = require('../index.js');
16
+
17
+ // Method 1: Cookie Array with 'name' property
18
+ const cookieArray = [
19
+ {
20
+ name: 'c_user',
21
+ value: 'YOUR_USER_ID_HERE'
22
+ },
23
+ {
24
+ name: 'xs',
25
+ value: 'YOUR_XS_TOKEN_HERE'
26
+ },
27
+ {
28
+ name: 'fr',
29
+ value: 'YOUR_FR_TOKEN_HERE'
30
+ },
31
+ {
32
+ name: 'datr',
33
+ value: 'YOUR_DATR_TOKEN_HERE'
34
+ }
35
+ ];
36
+
37
+ // Method 2: Cookie Array with 'key' property (alternative)
38
+ const cookieArrayAlt = [
39
+ {
40
+ key: 'c_user',
41
+ value: 'YOUR_USER_ID_HERE'
42
+ },
43
+ {
44
+ key: 'xs',
45
+ value: 'YOUR_XS_TOKEN_HERE'
46
+ }
47
+ ];
48
+
49
+ // Method 3: Cookie String format (semicolon-separated)
50
+ const cookieString = 'c_user=YOUR_USER_ID_HERE; xs=YOUR_XS_TOKEN_HERE; fr=YOUR_FR_TOKEN_HERE; datr=YOUR_DATR_TOKEN_HERE';
51
+
52
+ /**
53
+ * Login using cookie array
54
+ */
55
+ async function loginWithCookies() {
56
+ try {
57
+ const api = await login.login({
58
+ appState: cookieArray // Pass the cookie array here
59
+ }, {
60
+ logging: true,
61
+ listenEvents: true,
62
+ autoMarkRead: true,
63
+ selfListen: false
64
+ });
65
+
66
+ console.log('✓ Successfully logged in using cookies!');
67
+ console.log('✓ User ID:', api.getCurrentUserID());
68
+
69
+ // Now you can use the API normally
70
+ // Example: Send a message
71
+ // api.sendMessage("Hello World!", threadID);
72
+
73
+ // Clean up
74
+ api.stopListening();
75
+ process.exit(0);
76
+
77
+ } catch (error) {
78
+ console.error('✗ Login failed:', error.message);
79
+ process.exit(1);
80
+ }
81
+ }
82
+
83
+ /**
84
+ * How to extract cookies from your browser:
85
+ *
86
+ * 1. Open Facebook in your browser
87
+ * 2. Open Developer Tools (F12)
88
+ * 3. Go to Application → Cookies → facebook.com
89
+ * 4. Copy the critical cookies:
90
+ * - c_user: Your user ID
91
+ * - xs: Session token
92
+ * - fr: Fraud detection
93
+ * - datr: Device fingerprint
94
+ *
95
+ * 5. Replace the values in cookieArray above
96
+ * 6. Run: node examples/login-with-cookies.js
97
+ */
98
+
99
+ // Uncomment to run:
100
+ // loginWithCookies();
101
+
102
+ module.exports = { loginWithCookies, cookieArray };