shadowx-fca 2.0.0 โ†’ 2.2.0

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 (4) hide show
  1. package/README.md +457 -0
  2. package/index.js +110 -68
  3. package/package.json +1 -1
  4. package/utils.js +230 -298
package/README.md ADDED
@@ -0,0 +1,457 @@
1
+ Here's a comprehensive README.md for your shadowx-fca package:
2
+
3
+ ```markdown
4
+ # shadowx-fca
5
+
6
+ <div align="center">
7
+ <img src="https://img.shields.io/npm/v/shadowx-fca.svg?style=for-the-badge" alt="NPM Version">
8
+ <img src="https://img.shields.io/npm/dt/shadowx-fca.svg?style=for-the-badge" alt="NPM Downloads">
9
+ <img src="https://img.shields.io/github/license/mueidmursalinrifat/shadowx-fca.svg?style=for-the-badge" alt="License">
10
+ <img src="https://img.shields.io/badge/node-%3E%3D14.0.0-brightgreen.svg?style=for-the-badge" alt="Node Version">
11
+ </div>
12
+
13
+ <p align="center">
14
+ <strong>Unofficial Facebook Chat API for Node.js with Auto-Update System</strong><br>
15
+ Modified by Mueid Mursalin Rifat | Original by shadowX
16
+ </p>
17
+
18
+ ## ๐Ÿ“‹ Table of Contents
19
+
20
+ - [Features](#-features)
21
+ - [Installation](#-installation)
22
+ - [Quick Start](#-quick-start)
23
+ - [Authentication Methods](#-authentication-methods)
24
+ - [API Documentation](#-api-documentation)
25
+ - [Configuration](#-configuration)
26
+ - [Anti-Detection Features](#-anti-detection-features)
27
+ - [Troubleshooting](#-troubleshooting)
28
+ - [Examples](#-examples)
29
+ - [Changelog](#-changelog)
30
+ - [License](#-license)
31
+
32
+ ## โœจ Features
33
+
34
+ - โœ… **Multiple Authentication Methods** - Support for both appState and email/password login
35
+ - โœ… **Real-time Messaging** - MQTT/WebSocket based real-time message listening
36
+ - โœ… **Auto-Update System** - Automatically checks and updates to latest version
37
+ - โœ… **Anti-Detection** - Rotating user agents, rate limiting, and stealth headers
38
+ - โœ… **2FA Support** - Two-factor authentication handling
39
+ - โœ… **Message Attachments** - Support for images, videos, files, stickers, and more
40
+ - โœ… **Typing Indicators** - Send and receive typing status
41
+ - โœ… **Read Receipts** - Message read confirmation
42
+ - โœ… **Thread Management** - Create, delete, rename threads
43
+ - โœ… **Mention Support** - Tag users in messages (both legacy and new formats)
44
+ - โœ… **Configurable Options** - Extensive customization options
45
+
46
+ ## ๐Ÿ“ฆ Installation
47
+
48
+ ```bash
49
+ npm install shadowx-fca
50
+ ```
51
+
52
+ Requirements
53
+
54
+ ยท Node.js >= 14.0.0
55
+ ยท npm >= 6.0.0
56
+
57
+ ๐Ÿš€ Quick Start
58
+
59
+ Method 1: Using AppState (Recommended)
60
+
61
+ ```javascript
62
+ const login = require('shadowx-fca');
63
+ const fs = require('fs');
64
+
65
+ // Load saved appState
66
+ const appState = JSON.parse(fs.readFileSync('appstate.json', 'utf8'));
67
+
68
+ login({ appState: appState }, (err, api) => {
69
+ if (err) return console.error('Login failed:', err);
70
+
71
+ console.log('โœ… Logged in successfully!');
72
+
73
+ // Listen for incoming messages
74
+ api.listenMqtt((err, message) => {
75
+ if (err) return console.error('Listen error:', err);
76
+
77
+ if (message.type === 'message') {
78
+ console.log(`[${message.senderID}] ${message.body}`);
79
+
80
+ // Reply to message
81
+ api.sendMessage('Hello! I\'m a bot!', message.threadID);
82
+ }
83
+ });
84
+ });
85
+ ```
86
+
87
+ Method 2: Email & Password
88
+
89
+ ```javascript
90
+ const login = require('shadowx-fca');
91
+
92
+ login({
93
+ email: 'your_email@example.com',
94
+ password: 'your_password'
95
+ }, (err, api) => {
96
+ if (err) return console.error('Login failed:', err);
97
+
98
+ console.log('โœ… Logged in successfully!');
99
+
100
+ // Save appState for future use
101
+ const appState = api.getAppState();
102
+ fs.writeFileSync('appstate.json', JSON.stringify(appState, null, 2));
103
+
104
+ // Your bot logic here
105
+ });
106
+ ```
107
+
108
+ ๐Ÿ” Authentication Methods
109
+
110
+ 1. AppState (Recommended)
111
+
112
+ Most secure method - uses saved cookies instead of credentials.
113
+
114
+ Get your appState:
115
+
116
+ ```javascript
117
+ const login = require('shadowx-fca');
118
+ const fs = require('fs');
119
+
120
+ login({ email: 'your_email', password: 'your_password' }, (err, api) => {
121
+ if (err) return console.error(err);
122
+
123
+ const appState = api.getAppState();
124
+ fs.writeFileSync('appstate.json', JSON.stringify(appState, null, 2));
125
+ console.log('โœ… AppState saved! You can now use this file to login.');
126
+ process.exit(0);
127
+ });
128
+ ```
129
+
130
+ 2. Email & Password
131
+
132
+ Traditional method with 2FA support.
133
+
134
+ With 2FA:
135
+
136
+ ```javascript
137
+ login({ email: 'email@example.com', password: 'password' }, (err, api) => {
138
+ if (err && err.error === 'login-approval') {
139
+ console.log('Enter 2FA code:');
140
+ // Get code from user input
141
+ const twoFACode = '123456';
142
+ err.continue(twoFACode);
143
+ }
144
+ });
145
+ ```
146
+
147
+ ๐Ÿ“š API Documentation
148
+
149
+ Core Methods
150
+
151
+ login(loginData, [options], callback)
152
+
153
+ Main login function.
154
+
155
+ Parameters:
156
+
157
+ ยท loginData - Object containing either appState or email/password
158
+ ยท options - Optional configuration object
159
+ ยท callback - Function called after login
160
+
161
+ api.sendMessage(message, threadID, [callback], [replyToMessage], [isSingleUser])
162
+
163
+ Send a message to a thread.
164
+
165
+ ```javascript
166
+ // Simple message
167
+ api.sendMessage('Hello world!', 'thread_id_here');
168
+
169
+ // With reply
170
+ api.sendMessage('Replying to you!', 'thread_id_here', null, 'message_id_here');
171
+
172
+ // With mention
173
+ api.sendMessage('Hello @John Doe', 'thread_id_here');
174
+ ```
175
+
176
+ api.listenMqtt(callback)
177
+
178
+ Listen for incoming events (messages, typing, presence).
179
+
180
+ ```javascript
181
+ api.listenMqtt((err, event) => {
182
+ if (err) return console.error(err);
183
+
184
+ switch(event.type) {
185
+ case 'message':
186
+ console.log('New message:', event.body);
187
+ break;
188
+ case 'event':
189
+ console.log('Thread event:', event.logMessageType);
190
+ break;
191
+ case 'typ':
192
+ console.log(event.isTyping ? 'Typing...' : 'Stopped typing');
193
+ break;
194
+ }
195
+ });
196
+ ```
197
+
198
+ api.getThreadInfo(threadID, callback)
199
+
200
+ Get information about a thread.
201
+
202
+ ```javascript
203
+ api.getThreadInfo('thread_id_here', (err, info) => {
204
+ if (err) return console.error(err);
205
+ console.log('Thread name:', info.name);
206
+ console.log('Participants:', info.participants);
207
+ console.log('Unread count:', info.unreadCount);
208
+ });
209
+ ```
210
+
211
+ api.getUserInfo(userID, callback)
212
+
213
+ Get user information.
214
+
215
+ ```javascript
216
+ api.getUserInfo('user_id_here', (err, info) => {
217
+ if (err) return console.error(err);
218
+ console.log('Name:', info.name);
219
+ console.log('Gender:', info.gender);
220
+ });
221
+ ```
222
+
223
+ api.setOptions(options)
224
+
225
+ Update API options at runtime.
226
+
227
+ ```javascript
228
+ api.setOptions({
229
+ listenEvents: true,
230
+ autoMarkRead: false,
231
+ delayBetweenRequests: 2000
232
+ });
233
+ ```
234
+
235
+ Additional Methods
236
+
237
+ Method Description
238
+ api.getAppState() Get current appState (cookies)
239
+ api.markAsRead(threadID, callback) Mark thread as read
240
+ api.markAsDelivered(threadID, messageID, callback) Mark message as delivered
241
+ api.sendTypingIndicator(threadID, callback) Send typing indicator
242
+ api.changeNickname(nickname, threadID, userID, callback) Change user nickname
243
+ api.addUserToGroup(userID, threadID, callback) Add user to group
244
+ api.removeUserFromGroup(userID, threadID, callback) Remove user from group
245
+ api.createNewGroup(participantIDs, groupName, callback) Create new group
246
+ api.deleteThread(threadID, callback) Delete/leave thread
247
+ api.getThreadList(limit, timestamp, tags, callback) Get thread list
248
+
249
+ โš™๏ธ Configuration
250
+
251
+ Global Configuration (config.json)
252
+
253
+ Create config.json in your project root:
254
+
255
+ ```json
256
+ {
257
+ "enableTypingIndicator": false,
258
+ "typingDuration": 4000,
259
+ "delayBetweenRequests": 1500,
260
+ "autoMarkDelivery": false,
261
+ "autoMarkRead": false,
262
+ "listenEvents": true,
263
+ "selfListen": false,
264
+ "autoReconnect": true,
265
+ "logLevel": "info",
266
+ "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
267
+ }
268
+ ```
269
+
270
+ Options Reference
271
+
272
+ Option Type Default Description
273
+ selfListen Boolean false Listen to own messages
274
+ listenEvents Boolean true Listen to thread events
275
+ listenTyping Boolean false Listen to typing indicators
276
+ updatePresence Boolean false Update online status
277
+ forceLogin Boolean false Force login even if suspicious
278
+ autoMarkDelivery Boolean false Auto-mark messages as delivered
279
+ autoMarkRead Boolean false Auto-mark messages as read
280
+ autoReconnect Boolean true Auto-reconnect on disconnect
281
+ delayBetweenRequests Number 1000 Delay between API requests (ms)
282
+ logLevel String "info" Log level (silent/error/warn/info/verbose)
283
+
284
+ ๐Ÿ›ก๏ธ Anti-Detection Features
285
+
286
+ shadowx-fca includes several features to avoid Facebook's anti-bot detection:
287
+
288
+ 1. Rate Limiting
289
+
290
+ ```javascript
291
+ // Set custom delay between requests
292
+ api.setOptions({ delayBetweenRequests: 2000 });
293
+ ```
294
+
295
+ 2. Rotating User Agents
296
+
297
+ Automatically rotates between different user agents to avoid fingerprinting.
298
+
299
+ 3. Stealth Headers
300
+
301
+ Includes realistic browser headers (Sec-Ch-Ua, Accept-Language, etc.)
302
+
303
+ 4. Request Queue
304
+
305
+ Automatically queues and spaces out requests to prevent rate limiting.
306
+
307
+ ๐Ÿ”ง Troubleshooting
308
+
309
+ Common Issues & Solutions
310
+
311
+ 1. "Error! Your cookiestate is not valid!"
312
+
313
+ Solution: Refresh your appState
314
+
315
+ ```javascript
316
+ // Get new appState
317
+ login({ email: 'your_email', password: 'your_password' }, (err, api) => {
318
+ const newAppState = api.getAppState();
319
+ fs.writeFileSync('appstate.json', JSON.stringify(newAppState, null, 2));
320
+ });
321
+ ```
322
+
323
+ 2. Account Suspension
324
+
325
+ Solutions:
326
+
327
+ ยท Increase delay between requests
328
+ ยท Don't spam messages (add 2-3 second delays)
329
+ ยท Use appState instead of email/password
330
+ ยท Avoid running 24/7
331
+ ยท Use a proxy if running multiple bots
332
+
333
+ 3. Login Timeout
334
+
335
+ Solution: Increase timeout in options
336
+
337
+ ```javascript
338
+ login({ appState: appState }, { timeout: 120000 }, callback);
339
+ ```
340
+
341
+ 4. MQTT Connection Issues
342
+
343
+ Solution: Enable auto-reconnect
344
+
345
+ ```javascript
346
+ api.setOptions({ autoReconnect: true });
347
+ ```
348
+
349
+ ๐Ÿ’ก Examples
350
+
351
+ Simple Echo Bot
352
+
353
+ ```javascript
354
+ const login = require('shadowx-fca');
355
+
356
+ login({ appState: require('./appstate.json') }, (err, api) => {
357
+ if (err) return console.error(err);
358
+
359
+ api.listenMqtt((err, message) => {
360
+ if (err) return console.error(err);
361
+
362
+ if (message.type === 'message' && message.body) {
363
+ // Echo the message back
364
+ api.sendMessage(message.body, message.threadID);
365
+ }
366
+ });
367
+ });
368
+ ```
369
+
370
+ Command Handler
371
+
372
+ ```javascript
373
+ const commands = {
374
+ '!help': (api, message) => {
375
+ api.sendMessage('Available commands: !help, !time, !ping', message.threadID);
376
+ },
377
+ '!time': (api, message) => {
378
+ api.sendMessage(`Current time: ${new Date().toLocaleString()}`, message.threadID);
379
+ },
380
+ '!ping': (api, message) => {
381
+ api.sendMessage('Pong!', message.threadID);
382
+ }
383
+ };
384
+
385
+ login({ appState: require('./appstate.json') }, (err, api) => {
386
+ if (err) return console.error(err);
387
+
388
+ api.listenMqtt((err, message) => {
389
+ if (err) return console.error(err);
390
+
391
+ if (message.type === 'message' && message.body) {
392
+ const cmd = message.body.split(' ')[0];
393
+ if (commands[cmd]) commands[cmd](api, message);
394
+ }
395
+ });
396
+ });
397
+ ```
398
+
399
+ Auto-Reply with Delay
400
+
401
+ ```javascript
402
+ login({ appState: require('./appstate.json') }, (err, api) => {
403
+ if (err) return console.error(err);
404
+
405
+ api.listenMqtt((err, message) => {
406
+ if (err) return console.error(err);
407
+
408
+ if (message.type === 'message' && !message.isGroup) {
409
+ // Add delay to avoid rate limiting
410
+ setTimeout(() => {
411
+ api.sendMessage('Thanks for your message! I\'ll reply soon.', message.threadID);
412
+ }, 3000);
413
+ }
414
+ });
415
+ });
416
+ ```
417
+
418
+ ๐Ÿ“ Changelog
419
+
420
+ v2.1.0 (Latest)
421
+
422
+ ยท โœจ Added rotating user agents for anti-detection
423
+ ยท ๐Ÿš€ Implemented request queue with rate limiting
424
+ ยท ๐Ÿ”ง Fixed email/password login issues
425
+ ยท ๐Ÿ›ก๏ธ Enhanced security headers
426
+ ยท ๐Ÿ“š Improved documentation
427
+
428
+ v2.0.0
429
+
430
+ ยท Added auto-update system
431
+ ยท Improved MQTT connection stability
432
+ ยท Added support for new mention format
433
+ ยท Fixed 2FA handling
434
+
435
+ ๐Ÿ“„ License
436
+
437
+ This project is licensed under the MIT License - see the LICENSE file for details.
438
+
439
+ โš ๏ธ Disclaimer
440
+
441
+ This project is for educational purposes only. Use at your own risk. The authors are not responsible for any consequences that may arise from using this software, including but not limited to account suspension or legal action from Facebook.
442
+
443
+ ๐Ÿค Contributing
444
+
445
+ Contributions are welcome! Please feel free to submit a Pull Request.
446
+
447
+ ๐Ÿ“ž Support
448
+
449
+ ยท Issues: t.me/mueidmursalinrifat
450
+ ยท Author: Mueid Mursalin Rifat
451
+
452
+ ---
453
+
454
+ <div align="center">
455
+ Made with โค๏ธ by Mueid Mursalin Rifat
456
+ </div>
457
+ ```