@cexy/hoonfca 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.
Files changed (170) hide show
  1. package/.travis.yml +6 -0
  2. package/LICENSE-MIT +21 -0
  3. package/index.d.ts +620 -0
  4. package/index.js +778 -1
  5. package/package.json +31 -84
  6. package/src/{apis/addExternalModule.js → addExternalModule.js} +4 -5
  7. package/src/addUserToGroup.js +113 -0
  8. package/src/changeAdminStatus.js +95 -0
  9. package/src/changeApprovalMode.js +79 -0
  10. package/src/changeArchivedStatus.js +55 -0
  11. package/src/changeBio.js +76 -0
  12. package/src/changeBlockedStatus.js +47 -0
  13. package/src/changeBlockedStatusMqtt.js +86 -0
  14. package/src/changeGroupImage.js +133 -0
  15. package/src/changeNickname.js +59 -0
  16. package/src/changeThreadColor.js +71 -0
  17. package/src/{apis/changeThreadEmoji.js → changeThreadEmoji.js} +8 -6
  18. package/src/createNewGroup.js +88 -0
  19. package/src/createPoll.js +130 -0
  20. package/src/deleteMessage.js +56 -0
  21. package/src/deleteThread.js +56 -0
  22. package/src/editMessage.js +63 -0
  23. package/src/forwardAttachment.js +60 -0
  24. package/src/forwardMessage.js +63 -0
  25. package/src/getCurrentUserID.js +7 -0
  26. package/src/getEmojiUrl.js +29 -0
  27. package/src/getFriendsList.js +84 -0
  28. package/src/getGroupsList.js +83 -0
  29. package/src/getMarketplace.js +84 -0
  30. package/src/getNotifications.js +86 -0
  31. package/src/getPagesList.js +83 -0
  32. package/src/getStories.js +88 -0
  33. package/src/getThreadHistory.js +647 -0
  34. package/src/getThreadInfo.js +222 -0
  35. package/src/getThreadList.js +292 -0
  36. package/src/getThreadPictures.js +79 -0
  37. package/src/getUserID.js +66 -0
  38. package/src/getUserInfo.js +128 -0
  39. package/src/handleFriendRequest.js +57 -0
  40. package/src/handleMessageRequest.js +65 -0
  41. package/src/{apis/httpGet.js → httpGet.js} +15 -20
  42. package/src/httpPost.js +58 -0
  43. package/src/listenMqtt.js +1018 -0
  44. package/src/logout.js +75 -0
  45. package/src/markAsDelivered.js +58 -0
  46. package/src/{apis/markAsRead.js → markAsRead.js} +19 -30
  47. package/src/markAsReadAll.js +50 -0
  48. package/src/markAsSeen.js +61 -0
  49. package/src/muteThread.js +52 -0
  50. package/src/pinMessage.js +61 -0
  51. package/src/removeUserFromGroup.js +79 -0
  52. package/src/resolvePhotoUrl.js +45 -0
  53. package/src/searchForThread.js +53 -0
  54. package/src/searchUsers.js +89 -0
  55. package/src/sendComment.js +161 -0
  56. package/src/sendMessage.js +457 -0
  57. package/src/sendTypingIndicator.js +179 -0
  58. package/src/setBio.js +86 -0
  59. package/src/setMessageReaction.js +186 -0
  60. package/src/setPostReaction.js +71 -0
  61. package/src/setTheme.js +313 -0
  62. package/src/setTitle.js +90 -0
  63. package/src/shareContact.js +53 -0
  64. package/src/shareLink.js +62 -0
  65. package/src/threadColors.js +57 -0
  66. package/src/unfriend.js +53 -0
  67. package/src/unsendMessage.js +104 -0
  68. package/utils.js +1447 -0
  69. package/LICENSE +0 -3
  70. package/README.md +0 -491
  71. package/examples/login-with-cookies.js +0 -102
  72. package/examples/verify.js +0 -70
  73. package/src/apis/addUserToGroup.js +0 -108
  74. package/src/apis/changeAdminStatus.js +0 -148
  75. package/src/apis/changeArchivedStatus.js +0 -61
  76. package/src/apis/changeAvatar.js +0 -103
  77. package/src/apis/changeBio.js +0 -69
  78. package/src/apis/changeBlockedStatus.js +0 -54
  79. package/src/apis/changeGroupImage.js +0 -136
  80. package/src/apis/changeThreadColor.js +0 -116
  81. package/src/apis/comment.js +0 -207
  82. package/src/apis/createAITheme.js +0 -129
  83. package/src/apis/createNewGroup.js +0 -79
  84. package/src/apis/createPoll.js +0 -73
  85. package/src/apis/deleteMessage.js +0 -44
  86. package/src/apis/deleteThread.js +0 -52
  87. package/src/apis/e2ee.js +0 -17
  88. package/src/apis/editMessage.js +0 -70
  89. package/src/apis/emoji.js +0 -124
  90. package/src/apis/fetchThemeData.js +0 -82
  91. package/src/apis/follow.js +0 -81
  92. package/src/apis/forwardMessage.js +0 -52
  93. package/src/apis/friend.js +0 -243
  94. package/src/apis/gcmember.js +0 -122
  95. package/src/apis/gcname.js +0 -123
  96. package/src/apis/gcrule.js +0 -119
  97. package/src/apis/getAccess.js +0 -111
  98. package/src/apis/getBotInfo.js +0 -88
  99. package/src/apis/getBotInitialData.js +0 -43
  100. package/src/apis/getFriendsList.js +0 -79
  101. package/src/apis/getMessage.js +0 -423
  102. package/src/apis/getTheme.js +0 -95
  103. package/src/apis/getThemeInfo.js +0 -116
  104. package/src/apis/getThreadHistory.js +0 -239
  105. package/src/apis/getThreadInfo.js +0 -267
  106. package/src/apis/getThreadList.js +0 -232
  107. package/src/apis/getThreadPictures.js +0 -58
  108. package/src/apis/getUserID.js +0 -117
  109. package/src/apis/getUserInfo.js +0 -513
  110. package/src/apis/getUserInfoV2.js +0 -146
  111. package/src/apis/handleMessageRequest.js +0 -50
  112. package/src/apis/httpPost.js +0 -89
  113. package/src/apis/httpPostFormData.js +0 -69
  114. package/src/apis/listenMqtt.js +0 -1236
  115. package/src/apis/listenSpeed.js +0 -179
  116. package/src/apis/logout.js +0 -87
  117. package/src/apis/markAsDelivered.js +0 -47
  118. package/src/apis/markAsReadAll.js +0 -40
  119. package/src/apis/markAsSeen.js +0 -70
  120. package/src/apis/mqttDeltaValue.js +0 -278
  121. package/src/apis/muteThread.js +0 -45
  122. package/src/apis/nickname.js +0 -132
  123. package/src/apis/notes.js +0 -163
  124. package/src/apis/pinMessage.js +0 -150
  125. package/src/apis/produceMetaTheme.js +0 -180
  126. package/src/apis/realtime.js +0 -182
  127. package/src/apis/removeUserFromGroup.js +0 -117
  128. package/src/apis/resolvePhotoUrl.js +0 -58
  129. package/src/apis/searchForThread.js +0 -154
  130. package/src/apis/sendMessage.js +0 -354
  131. package/src/apis/sendMessageMqtt.js +0 -249
  132. package/src/apis/sendTypingIndicator.js +0 -91
  133. package/src/apis/setMessageReaction.js +0 -27
  134. package/src/apis/setMessageReactionMqtt.js +0 -61
  135. package/src/apis/setThreadTheme.js +0 -260
  136. package/src/apis/setThreadThemeMqtt.js +0 -94
  137. package/src/apis/share.js +0 -107
  138. package/src/apis/shareContact.js +0 -66
  139. package/src/apis/stickers.js +0 -257
  140. package/src/apis/story.js +0 -181
  141. package/src/apis/theme.js +0 -233
  142. package/src/apis/unfriend.js +0 -47
  143. package/src/apis/unsendMessage.js +0 -17
  144. package/src/engine/client.js +0 -92
  145. package/src/engine/models/buildAPI.js +0 -152
  146. package/src/engine/models/loginHelper.js +0 -519
  147. package/src/engine/models/setOptions.js +0 -88
  148. package/src/security/e2ee.js +0 -109
  149. package/src/types/index.d.ts +0 -498
  150. package/src/utils/antiSuspension.js +0 -506
  151. package/src/utils/auth-helpers.js +0 -149
  152. package/src/utils/autoReLogin.js +0 -336
  153. package/src/utils/axios.js +0 -436
  154. package/src/utils/cache.js +0 -54
  155. package/src/utils/clients.js +0 -282
  156. package/src/utils/constants.js +0 -410
  157. package/src/utils/formatters/data/formatAttachment.js +0 -370
  158. package/src/utils/formatters/data/formatDelta.js +0 -109
  159. package/src/utils/formatters/index.js +0 -159
  160. package/src/utils/formatters/value/formatCookie.js +0 -91
  161. package/src/utils/formatters/value/formatDate.js +0 -36
  162. package/src/utils/formatters/value/formatID.js +0 -16
  163. package/src/utils/formatters.js +0 -1373
  164. package/src/utils/headers.js +0 -230
  165. package/src/utils/index.js +0 -153
  166. package/src/utils/monitoring.js +0 -333
  167. package/src/utils/rateLimiter.js +0 -319
  168. package/src/utils/tokenRefresh.js +0 -657
  169. package/src/utils/user-agents.js +0 -238
  170. package/src/utils/validation.js +0 -157
package/LICENSE DELETED
@@ -1,3 +0,0 @@
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 DELETED
@@ -1,491 +0,0 @@
1
- # nkxfca
2
-
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
- ```
185
-
186
- ---
187
-
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
- ```
235
-
236
- 4. Use in your bot:
237
-
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.
245
-
246
- ---
247
-
248
- ## Bot Example with Commands
249
-
250
- ```js
251
- const fs = require("fs");
252
- const path = require("path");
253
- const { login } = require("@neoaz07/nkxfca");
254
-
255
- const appState = JSON.parse(fs.readFileSync("appstate.json", "utf8"));
256
-
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);
264
-
265
- console.log("Logged in as:", api.getCurrentUserID());
266
-
267
- const commandsDir = path.join(__dirname, "commands");
268
- const commands = new Map();
269
-
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
- }
277
- }
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
- ```
299
-
300
- ---
301
-
302
- ## AI Themes
303
-
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
- ```
319
-
320
- ---
321
-
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 |
369
-
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 |
433
-
434
- ---
435
-
436
- ## Login Options
437
-
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 |
458
-
459
- ---
460
-
461
- ## Examples
462
-
463
- See the **[examples/](examples/)** directory:
464
- - `login-with-cookies.js` — Cookie-based authentication guide
465
- - `verify.js` — Verify the library loads correctly
466
-
467
- ---
468
-
469
- ## Credits
470
-
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
476
-
477
- ---
478
-
479
- ## License
480
-
481
- **MIT** — Free to use, modify, and distribute. Attribution appreciated.
482
-
483
- See [LICENSE](LICENSE) for full license text.
484
-
485
- ---
486
-
487
- ## Links
488
-
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)
@@ -1,102 +0,0 @@
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 };
@@ -1,70 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- /**
5
- * Quick sanity check — verifies the library loads correctly and
6
- * prints the anti-suspension configuration. Run with:
7
- * node examples/verify.js
8
- */
9
-
10
- const fca = require('../index.js');
11
- const { globalAntiSuspension } = require('../src/utils/antiSuspension');
12
- const { globalRateLimiter } = require('../src/utils/rateLimiter');
13
-
14
- console.log('nkxfca Library Verification');
15
- console.log('================================\n');
16
-
17
- console.log('Library entry point:', typeof fca.login === 'function' ? 'OK' : 'FAIL');
18
-
19
- const config = globalAntiSuspension.getConfig();
20
- console.log('\nAnti-Suspension Configuration:');
21
- console.log(` Message Delay : ${config.messageDelayMs}ms`);
22
- console.log(` Thread Delay : ${config.threadDelayMs}ms`);
23
- console.log(` Max Login Tries : ${config.maxLoginAttempts}`);
24
- console.log(` Login Cooldown : ${config.loginCooldownMs}ms`);
25
- console.log(` Daily Msg Limit : ${config.dailyStats.maxDailyMessages}`);
26
- console.log(` Hourly Msg Limit : ${config.hourlyStats.maxPerHour}`);
27
-
28
- console.log('\nEnabled Features:');
29
- Object.entries(config.features).forEach(([feature, enabled]) => {
30
- console.log(` ${enabled ? '[x]' : '[ ]'} ${feature}`);
31
- });
32
-
33
- const activityPattern = globalAntiSuspension.getRealisticActivityPattern();
34
- console.log('\nActivity Pattern:');
35
- console.log(` Current activity : ${activityPattern.messageFrequency}`);
36
- console.log(` Next action delay : ${activityPattern.nextActionDelayMs.toFixed(0)}ms`);
37
- console.log(` Is active hours : ${activityPattern.isActiveHours}`);
38
-
39
- console.log('\nCircuit Breaker:');
40
- console.log(` Tripped : ${globalAntiSuspension.isCircuitBreakerTripped()}`);
41
- console.log(` Signal count : ${globalAntiSuspension.suspensionCircuitBreaker.signalCount}`);
42
-
43
- const rateLimiterStats = globalRateLimiter.getStats();
44
- console.log('\nRate Limiter:');
45
- console.log(` Max concurrent : ${rateLimiterStats.maxConcurrentRequests}`);
46
- console.log(` Max per minute : ${rateLimiterStats.maxRequestsPerMinute}`);
47
- console.log(` Requests (1 min) : ${rateLimiterStats.requestsInLastMinute}`);
48
-
49
- // Test suspension signal detection
50
- const testSignals = [
51
- { text: 'Everything is fine, message sent', expectSuspicion: false },
52
- { text: 'Your account has been suspended due to policy violation', expectSuspicion: true },
53
- { text: 'checkpoint required to verify identity', expectSuspicion: true },
54
- { text: 'Too many requests - rate limited', expectSuspicion: true },
55
- { text: 'Unusual activity detected on your account', expectSuspicion: true },
56
- ];
57
- console.log('\nSuspension Signal Detection:');
58
- testSignals.forEach(({ text, expectSuspicion }) => {
59
- globalAntiSuspension.resetCircuitBreaker();
60
- const detected = globalAntiSuspension.detectSuspensionSignal(text);
61
- const passed = detected === expectSuspicion;
62
- globalAntiSuspension.resetCircuitBreaker();
63
- console.log(` ${passed ? '[x]' : '[!]'} "${text.substring(0, 40)}" → ${detected ? 'SUSPICIOUS' : 'CLEAN'}`);
64
- });
65
- globalAntiSuspension.resetCircuitBreaker();
66
-
67
- console.log('\nAll checks passed. Library is ready to use.');
68
- console.log('============================\n');
69
-
70
- process.exit(0);