fca-phantom 1.0.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.
- package/LICENSE +58 -0
- package/README.md +534 -0
- package/index.js +35 -0
- package/package.json +101 -0
- package/phantom/core/builder/bootstrap.js +334 -0
- package/phantom/core/builder/config.js +78 -0
- package/phantom/core/builder/forge.js +113 -0
- package/phantom/core/builder/ignite.js +386 -0
- package/phantom/core/builder/options.js +61 -0
- package/phantom/core/engine.js +71 -0
- package/phantom/core/reactor.js +2 -0
- package/phantom/datastore/appState.js +2 -0
- package/phantom/datastore/appStateBackup.js +34 -0
- package/phantom/datastore/models/cipher/e2ee.js +48 -0
- package/phantom/datastore/models/cipher/vault.js +153 -0
- package/phantom/datastore/models/index.js +3 -0
- package/phantom/datastore/models/matrix/auth.js +151 -0
- package/phantom/datastore/models/matrix/cache.js +3 -0
- package/phantom/datastore/models/matrix/checker.js +2 -0
- package/phantom/datastore/models/matrix/clients.js +2 -0
- package/phantom/datastore/models/matrix/constants.js +2 -0
- package/phantom/datastore/models/matrix/credentials.js +2 -0
- package/phantom/datastore/models/matrix/cycle.js +2 -0
- package/phantom/datastore/models/matrix/gate.js +282 -0
- package/phantom/datastore/models/matrix/ghost.js +332 -0
- package/phantom/datastore/models/matrix/headers.js +193 -0
- package/phantom/datastore/models/matrix/heartbeat.js +298 -0
- package/phantom/datastore/models/matrix/identity.js +235 -0
- package/phantom/datastore/models/matrix/logger.js +271 -0
- package/phantom/datastore/models/matrix/monitor.js +2 -0
- package/phantom/datastore/models/matrix/net.js +316 -0
- package/phantom/datastore/models/matrix/response.js +193 -0
- package/phantom/datastore/models/matrix/revive.js +255 -0
- package/phantom/datastore/models/matrix/signals.js +2 -0
- package/phantom/datastore/models/matrix/store.js +263 -0
- package/phantom/datastore/models/matrix/telemetry.js +272 -0
- package/phantom/datastore/models/matrix/tools.js +93 -0
- package/phantom/datastore/models/matrix/transform/cookieParser.js +2 -0
- package/phantom/datastore/models/matrix/transform/cookies.js +114 -0
- package/phantom/datastore/models/matrix/transform/index.js +203 -0
- package/phantom/datastore/models/matrix/validator.js +157 -0
- package/phantom/datastore/models/types/index.d.ts +498 -0
- package/phantom/datastore/schema.js +167 -0
- package/phantom/datastore/session.js +129 -0
- package/phantom/datastore/threads.js +22 -0
- package/phantom/datastore/users.js +26 -0
- package/phantom/dispatch/addExternalModule.js +239 -0
- package/phantom/dispatch/addUserToGroup.js +161 -0
- package/phantom/dispatch/changeAdminStatus.js +142 -0
- package/phantom/dispatch/changeArchivedStatus.js +135 -0
- package/phantom/dispatch/changeAvatar.js +123 -0
- package/phantom/dispatch/changeBio.js +86 -0
- package/phantom/dispatch/changeBlockedStatus.js +86 -0
- package/phantom/dispatch/changeGroupImage.js +145 -0
- package/phantom/dispatch/changeThreadColor.js +172 -0
- package/phantom/dispatch/changeThreadEmoji.js +130 -0
- package/phantom/dispatch/comment.js +136 -0
- package/phantom/dispatch/createAITheme.js +333 -0
- package/phantom/dispatch/createNewGroup.js +99 -0
- package/phantom/dispatch/createPoll.js +148 -0
- package/phantom/dispatch/deleteMessage.js +131 -0
- package/phantom/dispatch/deleteThread.js +155 -0
- package/phantom/dispatch/e2ee.js +101 -0
- package/phantom/dispatch/editMessage.js +158 -0
- package/phantom/dispatch/emoji.js +143 -0
- package/phantom/dispatch/fetchThemeData.js +233 -0
- package/phantom/dispatch/follow.js +111 -0
- package/phantom/dispatch/forwardMessage.js +110 -0
- package/phantom/dispatch/friend.js +189 -0
- package/phantom/dispatch/gcmember.js +138 -0
- package/phantom/dispatch/gcname.js +131 -0
- package/phantom/dispatch/gcrule.js +111 -0
- package/phantom/dispatch/getAccess.js +109 -0
- package/phantom/dispatch/getBotInfo.js +81 -0
- package/phantom/dispatch/getBotInitialData.js +110 -0
- package/phantom/dispatch/getFriendsList.js +118 -0
- package/phantom/dispatch/getMessage.js +199 -0
- package/phantom/dispatch/getTheme.js +199 -0
- package/phantom/dispatch/getThemeInfo.js +160 -0
- package/phantom/dispatch/getThreadHistory.js +139 -0
- package/phantom/dispatch/getThreadInfo.js +153 -0
- package/phantom/dispatch/getThreadList.js +132 -0
- package/phantom/dispatch/getThreadPictures.js +93 -0
- package/phantom/dispatch/getUserID.js +147 -0
- package/phantom/dispatch/getUserInfo.js +513 -0
- package/phantom/dispatch/getUserInfoV2.js +146 -0
- package/phantom/dispatch/handleMessageRequest.js +50 -0
- package/phantom/dispatch/httpGet.js +63 -0
- package/phantom/dispatch/httpPost.js +89 -0
- package/phantom/dispatch/httpPostFormData.js +69 -0
- package/phantom/dispatch/listenMqtt.js +1236 -0
- package/phantom/dispatch/listenSpeed.js +179 -0
- package/phantom/dispatch/logout.js +93 -0
- package/phantom/dispatch/markAsDelivered.js +92 -0
- package/phantom/dispatch/markAsRead.js +119 -0
- package/phantom/dispatch/markAsReadAll.js +215 -0
- package/phantom/dispatch/markAsSeen.js +70 -0
- package/phantom/dispatch/mqttDeltaValue.js +278 -0
- package/phantom/dispatch/muteThread.js +253 -0
- package/phantom/dispatch/nickname.js +132 -0
- package/phantom/dispatch/notes.js +263 -0
- package/phantom/dispatch/pinMessage.js +238 -0
- package/phantom/dispatch/produceMetaTheme.js +335 -0
- package/phantom/dispatch/realtime.js +291 -0
- package/phantom/dispatch/removeUserFromGroup.js +248 -0
- package/phantom/dispatch/resolvePhotoUrl.js +217 -0
- package/phantom/dispatch/searchForThread.js +258 -0
- package/phantom/dispatch/sendMessage.js +354 -0
- package/phantom/dispatch/sendMessageMqtt.js +249 -0
- package/phantom/dispatch/sendTypingIndicator.js +206 -0
- package/phantom/dispatch/setMessageReaction.js +188 -0
- package/phantom/dispatch/setMessageReactionMqtt.js +248 -0
- package/phantom/dispatch/setThreadTheme.js +330 -0
- package/phantom/dispatch/setThreadThemeMqtt.js +207 -0
- package/phantom/dispatch/share.js +200 -0
- package/phantom/dispatch/shareContact.js +216 -0
- package/phantom/dispatch/stickers.js +395 -0
- package/phantom/dispatch/story.js +240 -0
- package/phantom/dispatch/theme.js +296 -0
- package/phantom/dispatch/unfriend.js +199 -0
- package/phantom/dispatch/unsendMessage.js +124 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024–2026 phantom-fca (github.com/ewr-sifu/phantom-fca)
|
|
4
|
+
Original Author: SIFAT (github.com/Ewr-Sifu)
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
|
|
24
|
+
-------------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
ADDITIONAL TERMS — ATTRIBUTION & FAIR USE
|
|
27
|
+
|
|
28
|
+
While this software is provided under the MIT License, the following terms
|
|
29
|
+
apply as a matter of good faith and community respect:
|
|
30
|
+
|
|
31
|
+
1. Attribution Required
|
|
32
|
+
Any public distribution, fork, or derivative work must clearly credit the
|
|
33
|
+
original author (SIFAT / github.com/Ewr-Sifu) and the phantom-fca project
|
|
34
|
+
in its documentation, README, or about section.
|
|
35
|
+
|
|
36
|
+
2. No Misrepresentation
|
|
37
|
+
You may not claim original authorship of this software or any substantial
|
|
38
|
+
portion of it. Presenting this work as entirely your own creation without
|
|
39
|
+
attribution is a violation of these terms.
|
|
40
|
+
|
|
41
|
+
3. Forks & Derivatives
|
|
42
|
+
You are free to fork, modify, and build upon this project. Derivative
|
|
43
|
+
works must be distributed under the same MIT License and must include a
|
|
44
|
+
notice stating that changes were made.
|
|
45
|
+
|
|
46
|
+
4. Commercial Use
|
|
47
|
+
Commercial use is permitted under the MIT License. However, selling this
|
|
48
|
+
software as-is (without substantial modification) as a paid product is
|
|
49
|
+
discouraged without explicit written permission from the original author.
|
|
50
|
+
|
|
51
|
+
5. No Warranty
|
|
52
|
+
This software is provided for educational and automation purposes. The
|
|
53
|
+
authors are not responsible for misuse, account bans, data loss, or any
|
|
54
|
+
damages arising from the use of this software.
|
|
55
|
+
|
|
56
|
+
-------------------------------------------------------------------------------
|
|
57
|
+
|
|
58
|
+
By using, copying, or distributing this software, you agree to these terms.
|
package/README.md
ADDED
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="https://img.shields.io/badge/PHANTOM--FCA-v1.0.0-blueviolet?style=for-the-badge&logo=ghost&logoColor=white" />
|
|
4
|
+
<img src="https://img.shields.io/npm/v/fca-phantom?style=for-the-badge&color=blueviolet&label=npm" />
|
|
5
|
+
<img src="https://img.shields.io/badge/Node.js-%3E%3D22.0.0-brightgreen?style=for-the-badge&logo=nodedotjs&logoColor=white" />
|
|
6
|
+
<img src="https://img.shields.io/badge/License-MIT-blue?style=for-the-badge" />
|
|
7
|
+
<img src="https://img.shields.io/badge/Platform-Facebook%20Messenger-1877F2?style=for-the-badge&logo=messenger&logoColor=white" />
|
|
8
|
+
<img src="https://img.shields.io/badge/Author-SIFAT-ff69b4?style=for-the-badge&logo=github&logoColor=white" />
|
|
9
|
+
|
|
10
|
+
<br /><br />
|
|
11
|
+
|
|
12
|
+
# 👻 PHANTOM-FCA
|
|
13
|
+
|
|
14
|
+
### *A powerful Facebook Chat API for Node.js*
|
|
15
|
+
### *by **SIFAT***
|
|
16
|
+
|
|
17
|
+
> *Session Revival · E2EE Encryption · Real-time MQTT · Smart Rate Control · TypeScript Ready*
|
|
18
|
+
|
|
19
|
+
<br />
|
|
20
|
+
|
|
21
|
+
[](https://www.npmjs.com/package/fca-phantom)
|
|
22
|
+
[](https://github.com/ewr-sifu/phantom-fca)
|
|
23
|
+
[](https://github.com/ewr-sifu/phantom-fca/issues)
|
|
24
|
+
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 👤 Author
|
|
30
|
+
|
|
31
|
+
<div align="center">
|
|
32
|
+
|
|
33
|
+
**SIFAT** — Creator & Lead Developer of PHANTOM-FCA
|
|
34
|
+
|
|
35
|
+
[](https://github.com/Ewr-Sifu)
|
|
36
|
+
|
|
37
|
+
> *"Every message matters. Every session deserves to survive."*
|
|
38
|
+
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 📑 Table of Contents
|
|
44
|
+
|
|
45
|
+
- [What is PHANTOM-FCA?](#-what-is-phantom-fca)
|
|
46
|
+
- [Installation](#-installation)
|
|
47
|
+
- [Quick Start](#-quick-start)
|
|
48
|
+
- [Configuration Options](#️-configuration-options)
|
|
49
|
+
- [API Reference](#-api-reference)
|
|
50
|
+
- [Global Subsystems](#️-global-subsystems)
|
|
51
|
+
- [End-to-End Encryption](#-end-to-end-encryption)
|
|
52
|
+
- [Session Revival](#-session-revival--auto-reconnect)
|
|
53
|
+
- [Message Types & Formats](#-message-types)
|
|
54
|
+
- [Data Persistence](#️-data-persistence)
|
|
55
|
+
- [TypeScript Support](#-typescript-support)
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 🔍 What is PHANTOM-FCA?
|
|
60
|
+
|
|
61
|
+
**PHANTOM-FCA** is a next-generation Facebook Chat API (FCA) built for Node.js. It lets you build bots and automation tools for Facebook Messenger with a focus on **reliability**, **security**, and **long-term stability**.
|
|
62
|
+
|
|
63
|
+
| Feature | Description |
|
|
64
|
+
|---------|-------------|
|
|
65
|
+
| 👻 **Smart Shield** | Session protection, browser fingerprinting, and circuit breaker |
|
|
66
|
+
| ⚡ **Real-time MQTT** | Fast real-time event listener via Facebook's MQTT protocol |
|
|
67
|
+
| 🔐 **E2EE Built-in** | End-to-end encryption between bots and trusted peers |
|
|
68
|
+
| 🔄 **Auto Revival** | Automatic session revival, re-login, and reconnect |
|
|
69
|
+
| 🗄️ **SQLite Persistence** | Local session storage for fast cold starts |
|
|
70
|
+
| 📦 **75+ API Methods** | Full coverage of the Facebook Messenger API |
|
|
71
|
+
| 🧩 **TypeScript Ready** | Full `.d.ts` type definitions included |
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 📦 Installation
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npm install fca-phantom
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
> Requires **Node.js >= 22.0.0**
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## ⚡ Quick Start
|
|
86
|
+
|
|
87
|
+
### Cookie Login (Recommended)
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
const phantom = require("fca-phantom");
|
|
91
|
+
|
|
92
|
+
const cookies = [
|
|
93
|
+
{ key: "c_user", value: "YOUR_USER_ID" },
|
|
94
|
+
{ key: "xs", value: "YOUR_XS_TOKEN" },
|
|
95
|
+
{ key: "fr", value: "YOUR_FR_TOKEN" },
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
phantom.connect(cookies, { selfListen: false }, (err, api) => {
|
|
99
|
+
if (err) return console.error("Login failed:", err);
|
|
100
|
+
|
|
101
|
+
console.log("Connected as:", api.getCurrentUserID());
|
|
102
|
+
|
|
103
|
+
api.listen((err, message) => {
|
|
104
|
+
if (err) return console.error(err);
|
|
105
|
+
|
|
106
|
+
if (message.type === "message") {
|
|
107
|
+
api.sendMessage("👻 PHANTOM-FCA is alive!", message.threadID);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Async / Await
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
const phantom = require("fca-phantom");
|
|
117
|
+
|
|
118
|
+
async function main() {
|
|
119
|
+
const api = await phantom.connect(cookies, {
|
|
120
|
+
selfListen: false,
|
|
121
|
+
listenEvents: true,
|
|
122
|
+
autoMarkRead: true,
|
|
123
|
+
autoReconnect: true,
|
|
124
|
+
sessionPersist: true,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
api.listen(async (err, event) => {
|
|
128
|
+
if (err) throw err;
|
|
129
|
+
|
|
130
|
+
if (event.type === "message") {
|
|
131
|
+
const thread = await api.getThreadInfo(event.threadID);
|
|
132
|
+
await api.sendMessage(`Hello from ${thread.name}!`, event.threadID);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
main().catch(console.error);
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## ⚙️ Configuration Options
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
phantom.connect(credentials, {
|
|
146
|
+
selfListen: false, // Receive your own sent messages
|
|
147
|
+
listenEvents: true, // Enable group/thread events
|
|
148
|
+
listenTyping: false, // Listen to typing indicators
|
|
149
|
+
simulateTyping: true, // Add human-like typing delay
|
|
150
|
+
updatePresence: false, // Update online presence status
|
|
151
|
+
forceLogin: false, // Force re-login even if session exists
|
|
152
|
+
autoMarkDelivery: false, // Auto-mark as delivered
|
|
153
|
+
autoMarkRead: true, // Auto-mark messages as read
|
|
154
|
+
autoReconnect: true, // Auto-reconnect on MQTT disconnect
|
|
155
|
+
online: true, // Appear online to contacts
|
|
156
|
+
emitReady: false, // Emit a "ready" event on connect
|
|
157
|
+
persona: "desktop", // Browser persona: "desktop" | "mobile"
|
|
158
|
+
autoReLogin: true, // Auto re-login on session expiry
|
|
159
|
+
sessionPersist: true, // Persist session to local SQLite DB
|
|
160
|
+
}, callback);
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## 📡 API Reference
|
|
166
|
+
|
|
167
|
+
### 💬 Messaging
|
|
168
|
+
|
|
169
|
+
| Method | Description |
|
|
170
|
+
|--------|-------------|
|
|
171
|
+
| `sendMessage(msg, threadID)` | Send text, attachment, sticker, or rich message |
|
|
172
|
+
| `sendTypingIndicator(threadID)` | Send a typing indicator |
|
|
173
|
+
| `editMessage(messageID, newMessage)` | Edit a previously sent message |
|
|
174
|
+
| `deleteMessage(messageID)` | Delete a message locally |
|
|
175
|
+
| `unsendMessage(messageID)` | Retract/unsend a message for everyone |
|
|
176
|
+
| `forwardMessage(messageID, threadID)` | Forward a message to another thread |
|
|
177
|
+
| `pinMessage(messageID, threadID)` | Pin a message in a thread |
|
|
178
|
+
| `setMessageReaction(reaction, messageID)` | Add an emoji reaction |
|
|
179
|
+
| `shareContact(userID, threadID)` | Share a contact card |
|
|
180
|
+
| `comment(postID, message)` | Comment on a Facebook post |
|
|
181
|
+
|
|
182
|
+
### 🧵 Thread Management
|
|
183
|
+
|
|
184
|
+
| Method | Description |
|
|
185
|
+
|--------|-------------|
|
|
186
|
+
| `getThreadInfo(threadID)` | Fetch thread metadata |
|
|
187
|
+
| `getThreadList(limit, cursor, tags)` | List threads with pagination |
|
|
188
|
+
| `getThreadHistory(threadID, amount, ts)` | Fetch message history |
|
|
189
|
+
| `getThreadPictures(threadID, offset, limit)` | Get thread media/photos |
|
|
190
|
+
| `searchForThread(query)` | Search threads by keyword |
|
|
191
|
+
| `createNewGroup(name, participantIDs)` | Create a new group |
|
|
192
|
+
| `changeThreadColor(color, threadID)` | Set thread accent color |
|
|
193
|
+
| `changeThreadEmoji(emoji, threadID)` | Set thread emoji |
|
|
194
|
+
| `changeGroupImage(image, threadID)` | Update group photo |
|
|
195
|
+
| `muteThread(threadID, muteSeconds)` | Mute a thread |
|
|
196
|
+
| `deleteThread(threadID)` | Delete a thread |
|
|
197
|
+
| `changeArchivedStatus(threadID, archive)` | Archive or unarchive thread |
|
|
198
|
+
| `markAsRead(threadID)` | Mark thread as read |
|
|
199
|
+
| `markAsDelivered(threadID, messageID)` | Mark message as delivered |
|
|
200
|
+
| `markAsSeen(threadList)` | Mark multiple threads as seen |
|
|
201
|
+
| `markAsReadAll()` | Mark all threads as read |
|
|
202
|
+
|
|
203
|
+
### 👥 Group Administration
|
|
204
|
+
|
|
205
|
+
| Method | Description |
|
|
206
|
+
|--------|-------------|
|
|
207
|
+
| `addUserToGroup(userID, threadID)` | Add a member to a group |
|
|
208
|
+
| `removeUserFromGroup(userID, threadID)` | Remove a member |
|
|
209
|
+
| `changeAdminStatus(threadID, userID, isAdmin)` | Promote or demote admin |
|
|
210
|
+
| `gcname(threadID, name)` | Rename a group |
|
|
211
|
+
| `gcmember(threadID)` | List group members |
|
|
212
|
+
| `gcrule(threadID, rule)` | Manage group rules |
|
|
213
|
+
| `nickname(threadID, userID, nickname)` | Set a member's nickname |
|
|
214
|
+
| `handleMessageRequest(threadID, accept)` | Accept or decline a message request |
|
|
215
|
+
|
|
216
|
+
### 🙍 User & Friend Operations
|
|
217
|
+
|
|
218
|
+
| Method | Description |
|
|
219
|
+
|--------|-------------|
|
|
220
|
+
| `getUserInfo(userIDs)` | Fetch user profile info |
|
|
221
|
+
| `getUserInfoV2(userID)` | Fetch extended user info |
|
|
222
|
+
| `getUserID(name)` | Search for a user by name |
|
|
223
|
+
| `getFriendsList()` | Get full friends list |
|
|
224
|
+
| `friend(userID)` | Send a friend request |
|
|
225
|
+
| `unfriend(userID)` | Remove a friend |
|
|
226
|
+
| `follow(userID)` | Follow a user |
|
|
227
|
+
| `changeBlockedStatus(userID, block)` | Block or unblock a user |
|
|
228
|
+
| `changeBio(bio)` | Update the bot's bio |
|
|
229
|
+
| `changeAvatar(avatar)` | Update profile picture |
|
|
230
|
+
| `getBotInfo()` | Get bot account information |
|
|
231
|
+
| `getBotInitialData()` | Get bot bootstrap/session data |
|
|
232
|
+
|
|
233
|
+
### 🎨 Themes & Stickers
|
|
234
|
+
|
|
235
|
+
| Method | Description |
|
|
236
|
+
|--------|-------------|
|
|
237
|
+
| `setThreadTheme(threadID, themeID)` | Apply a Messenger theme |
|
|
238
|
+
| `getTheme(threadID)` | Get current thread theme |
|
|
239
|
+
| `getThemeInfo(themeID)` | Get theme metadata |
|
|
240
|
+
| `fetchThemeData(url)` | Download theme assets |
|
|
241
|
+
| `createAITheme(prompt)` | Generate an AI-powered theme |
|
|
242
|
+
| `produceMetaTheme(config)` | Build a custom Meta theme |
|
|
243
|
+
| `emoji(threadID, emoji)` | Set thread quick-reaction emoji |
|
|
244
|
+
| `stickers(query)` | Search for stickers |
|
|
245
|
+
|
|
246
|
+
### 📊 Polls, Stories & Notes
|
|
247
|
+
|
|
248
|
+
| Method | Description |
|
|
249
|
+
|--------|-------------|
|
|
250
|
+
| `createPoll(title, threadID, options)` | Create a poll |
|
|
251
|
+
| `story(action)` | Interact with stories |
|
|
252
|
+
| `notes(action)` | Interact with notes |
|
|
253
|
+
|
|
254
|
+
### 🌐 HTTP & Media
|
|
255
|
+
|
|
256
|
+
| Method | Description |
|
|
257
|
+
|--------|-------------|
|
|
258
|
+
| `resolvePhotoUrl(photoID)` | Resolve a photo to a URL |
|
|
259
|
+
| `getMessage(messageID)` | Fetch a specific message |
|
|
260
|
+
| `getAccess(url)` | Get access to a resource |
|
|
261
|
+
| `share(url, threadID)` | Share a link |
|
|
262
|
+
| `httpGet(url, opts)` | Make an authenticated GET request |
|
|
263
|
+
| `httpPost(url, body)` | Make an authenticated POST request |
|
|
264
|
+
| `httpPostFormData(url, form)` | POST with form-data payload |
|
|
265
|
+
|
|
266
|
+
### 📡 Real-time & MQTT
|
|
267
|
+
|
|
268
|
+
| Method | Description |
|
|
269
|
+
|--------|-------------|
|
|
270
|
+
| `listen(callback)` | Listen to all events via MQTT |
|
|
271
|
+
| `listenMqtt(callback)` | Raw MQTT listener |
|
|
272
|
+
| `listenSpeed(callback)` | High-speed optimized listener |
|
|
273
|
+
| `realtime(action)` | Perform realtime actions |
|
|
274
|
+
| `mqttDeltaValue(key)` | Read an MQTT delta value |
|
|
275
|
+
|
|
276
|
+
### 🔒 End-to-End Encryption (E2EE)
|
|
277
|
+
|
|
278
|
+
| Method | Description |
|
|
279
|
+
|--------|-------------|
|
|
280
|
+
| `e2ee.enable()` | Enable end-to-end encryption |
|
|
281
|
+
| `e2ee.disable()` | Disable encryption |
|
|
282
|
+
| `e2ee.isEnabled()` | Check if encryption is active |
|
|
283
|
+
| `e2ee.getPublicKey()` | Get own public key |
|
|
284
|
+
| `e2ee.setPeerKey(threadID, pubKey)` | Register a peer's public key |
|
|
285
|
+
| `e2ee.clearPeerKey(threadID)` | Remove a peer key |
|
|
286
|
+
| `e2ee.hasPeer(threadID)` | Check if a peer key exists |
|
|
287
|
+
| `e2ee.encrypt(threadID, text)` | Encrypt a message |
|
|
288
|
+
| `e2ee.decrypt(threadID, armored)` | Decrypt a message |
|
|
289
|
+
| `e2ee.encryptBatch(entries)` | Batch encrypt multiple messages |
|
|
290
|
+
| `e2ee.decryptBatch(entries)` | Batch decrypt multiple messages |
|
|
291
|
+
| `e2ee.exportKeyring()` | Export the full key bundle |
|
|
292
|
+
| `e2ee.importKeyring(keyring)` | Import a key bundle |
|
|
293
|
+
| `e2ee.rotatePeerKey(threadID, newKey)` | Rotate a peer's key |
|
|
294
|
+
| `e2ee.clearAllPeers()` | Remove all registered peer keys |
|
|
295
|
+
| `e2ee.getStats()` | Get encryption statistics |
|
|
296
|
+
|
|
297
|
+
### 🔌 Session & Extensions
|
|
298
|
+
|
|
299
|
+
| Method | Description |
|
|
300
|
+
|--------|-------------|
|
|
301
|
+
| `logout()` | Logout and clean up session |
|
|
302
|
+
| `addExternalModule(module)` | Extend the FCA with a custom module |
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## 🛡️ Global Subsystems
|
|
307
|
+
|
|
308
|
+
Advanced programmatic control over the FCA internals:
|
|
309
|
+
|
|
310
|
+
```javascript
|
|
311
|
+
const {
|
|
312
|
+
globalShield, // Smart shield & circuit breaker
|
|
313
|
+
globalAntiSuspension, // Suspension prevention system
|
|
314
|
+
globalReviveManager, // Automatic session revival
|
|
315
|
+
globalAutoReLoginManager, // Auto re-login on session expiry
|
|
316
|
+
globalGate, // Request gate controller
|
|
317
|
+
globalRateLimiter, // Rate limiter (token bucket)
|
|
318
|
+
configureRateLimiter, // Configure rate limits
|
|
319
|
+
getRateLimiterStats, // Get current rate limit stats
|
|
320
|
+
globalMonitor, // System health monitor
|
|
321
|
+
Telemetry, // Telemetry class
|
|
322
|
+
globalCache, // In-memory data cache
|
|
323
|
+
DataCache, // Cache class constructor
|
|
324
|
+
CycleManager, // Session cycle manager
|
|
325
|
+
TokenRefreshManager, // Token refresh manager
|
|
326
|
+
globalCipher, // AES-256-GCM cipher instance
|
|
327
|
+
PhantomCipher, // Cipher class constructor
|
|
328
|
+
} = require("fca-phantom");
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### `globalShield` — Smart Protection Shield
|
|
332
|
+
|
|
333
|
+
Detects threat patterns (checkpoint, rate limits, bans) and trips a circuit breaker to pause operations before permanent damage occurs.
|
|
334
|
+
|
|
335
|
+
```javascript
|
|
336
|
+
if (!globalShield.isHealthy()) {
|
|
337
|
+
console.warn("Threat detected — holding back requests");
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
globalShield.tripCircuitBreaker("checkpoint_detected", 3_600_000); // 1 hour
|
|
341
|
+
globalShield.resetCircuitBreaker();
|
|
342
|
+
globalShield.enableWarmup();
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### `globalRateLimiter` — Request Rate Control
|
|
346
|
+
|
|
347
|
+
```javascript
|
|
348
|
+
const { configureRateLimiter, getRateLimiterStats } = require("fca-phantom");
|
|
349
|
+
|
|
350
|
+
configureRateLimiter({
|
|
351
|
+
maxRequestsPerSecond: 5,
|
|
352
|
+
burstCapacity: 10,
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
const stats = getRateLimiterStats();
|
|
356
|
+
console.log(`Remaining: ${stats.remaining} / ${stats.total}`);
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### `globalCache` — In-Memory Data Cache
|
|
360
|
+
|
|
361
|
+
```javascript
|
|
362
|
+
const { globalCache } = require("fca-phantom");
|
|
363
|
+
|
|
364
|
+
globalCache.set("myKey", { payload: 42 }, 60_000); // TTL: 60 seconds
|
|
365
|
+
const val = globalCache.get("myKey");
|
|
366
|
+
globalCache.delete("myKey");
|
|
367
|
+
globalCache.flush();
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### `globalCipher` — AES-256-GCM Vault
|
|
371
|
+
|
|
372
|
+
```javascript
|
|
373
|
+
const { globalCipher } = require("fca-phantom");
|
|
374
|
+
|
|
375
|
+
const key = globalCipher.generateKey();
|
|
376
|
+
const { encrypted, iv, tag } = globalCipher.encrypt("secret", key);
|
|
377
|
+
const decrypted = globalCipher.decrypt({ encrypted, iv, tag }, key);
|
|
378
|
+
|
|
379
|
+
const token = globalCipher.sign({ userID: "123" }, "my-secret");
|
|
380
|
+
const result = globalCipher.verify(token, "my-secret", 300_000);
|
|
381
|
+
|
|
382
|
+
const hex = globalCipher.randomHex(32);
|
|
383
|
+
const equal = globalCipher.secureCompare(tokenA, tokenB);
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
## 🔐 End-to-End Encryption
|
|
389
|
+
|
|
390
|
+
PHANTOM-FCA has a built-in E2EE layer for encrypted messaging between bots or trusted peers.
|
|
391
|
+
|
|
392
|
+
```javascript
|
|
393
|
+
phantom.connect(cookies, {}, async (err, api) => {
|
|
394
|
+
api.e2ee.enable();
|
|
395
|
+
console.log("Public Key:", api.e2ee.getPublicKey());
|
|
396
|
+
|
|
397
|
+
api.e2ee.setPeerKey(threadID, peerPublicKeyBase64);
|
|
398
|
+
|
|
399
|
+
const encrypted = api.e2ee.encrypt(threadID, "Top secret message");
|
|
400
|
+
await api.sendMessage(encrypted, threadID);
|
|
401
|
+
|
|
402
|
+
api.listen((err, msg) => {
|
|
403
|
+
if (api.e2ee.hasPeer(msg.threadID)) {
|
|
404
|
+
const plain = api.e2ee.decrypt(msg.threadID, msg.body);
|
|
405
|
+
console.log("Decrypted:", plain);
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
});
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
## 🔄 Session Revival & Auto-Reconnect
|
|
414
|
+
|
|
415
|
+
PHANTOM-FCA automatically manages session health with multiple safety layers:
|
|
416
|
+
|
|
417
|
+
| Layer | Description |
|
|
418
|
+
|-------|-------------|
|
|
419
|
+
| **Auto-reconnect** | Reconnects MQTT on disconnect |
|
|
420
|
+
| **Session revival** | `globalReviveManager` restores expired sessions |
|
|
421
|
+
| **Auto re-login** | Logs in again using saved credentials |
|
|
422
|
+
| **Circuit breaker** | Pauses all requests on checkpoint/ban detection |
|
|
423
|
+
| **SQLite persistence** | Stores session locally for fast cold starts |
|
|
424
|
+
|
|
425
|
+
```javascript
|
|
426
|
+
const { globalReviveManager } = require("fca-phantom");
|
|
427
|
+
|
|
428
|
+
globalReviveManager.on("revived", (ctx) => {
|
|
429
|
+
console.log(`Session revived for user: ${ctx.userID}`);
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
globalReviveManager.on("failed", (err) => {
|
|
433
|
+
console.error("Revival failed:", err.message);
|
|
434
|
+
});
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
## 📨 Message Types
|
|
440
|
+
|
|
441
|
+
```javascript
|
|
442
|
+
api.listen((err, event) => {
|
|
443
|
+
switch (event.type) {
|
|
444
|
+
case "message": // Incoming message
|
|
445
|
+
case "event": // Group/thread event
|
|
446
|
+
case "typ": // Typing indicator
|
|
447
|
+
case "read_receipt": // Read receipt
|
|
448
|
+
case "presence": // Online/offline change
|
|
449
|
+
case "message_reaction": // Emoji reaction
|
|
450
|
+
case "message_unsend": // Message retracted
|
|
451
|
+
case "message_reply": // Reply to a message
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
## 📤 Rich Message Formats
|
|
459
|
+
|
|
460
|
+
```javascript
|
|
461
|
+
// Plain text
|
|
462
|
+
api.sendMessage("Hello!", threadID);
|
|
463
|
+
|
|
464
|
+
// With @mentions
|
|
465
|
+
api.sendMessage({
|
|
466
|
+
body: "@Alice check this!",
|
|
467
|
+
mentions: [{ tag: "@Alice", id: "USER_ID", fromIndex: 0 }],
|
|
468
|
+
}, threadID);
|
|
469
|
+
|
|
470
|
+
// With attachment
|
|
471
|
+
const fs = require("fs");
|
|
472
|
+
api.sendMessage({
|
|
473
|
+
body: "Here's a file!",
|
|
474
|
+
attachment: fs.createReadStream("./photo.jpg"),
|
|
475
|
+
}, threadID);
|
|
476
|
+
|
|
477
|
+
// Poll
|
|
478
|
+
api.createPoll("Favorite language?", threadID, ["JavaScript", "Python", "Rust"]);
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
---
|
|
482
|
+
|
|
483
|
+
## 🗃️ Data Persistence
|
|
484
|
+
|
|
485
|
+
When `sessionPersist: true`, PHANTOM-FCA stores all session data in a local **SQLite database**:
|
|
486
|
+
|
|
487
|
+
| Store | Contents |
|
|
488
|
+
|-------|----------|
|
|
489
|
+
| **App State** | Encrypted cookie & session tokens |
|
|
490
|
+
| **Threads** | Cached thread metadata |
|
|
491
|
+
| **Users** | Cached user profiles |
|
|
492
|
+
| **Schema** | Auto-migrated on each connect |
|
|
493
|
+
|
|
494
|
+
---
|
|
495
|
+
|
|
496
|
+
## 🔧 TypeScript Support
|
|
497
|
+
|
|
498
|
+
```typescript
|
|
499
|
+
import * as phantom from "fca-phantom";
|
|
500
|
+
|
|
501
|
+
async function run() {
|
|
502
|
+
const api = await phantom.connect(cookies, { selfListen: false });
|
|
503
|
+
|
|
504
|
+
api.listen((err: Error | null, event: phantom.MessageEvent) => {
|
|
505
|
+
if (err) throw err;
|
|
506
|
+
if (event.type === "message") {
|
|
507
|
+
api.sendMessage("TypeScript reply!", event.threadID);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
run().catch(console.error);
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
## 📄 License
|
|
518
|
+
|
|
519
|
+
**MIT** © [PHANTOM-FCA](https://github.com/ewr-sifu/phantom-fca)
|
|
520
|
+
|
|
521
|
+
Original Author: **SIFAT** — [github.com/Ewr-Sifu](https://github.com/Ewr-Sifu)
|
|
522
|
+
|
|
523
|
+
---
|
|
524
|
+
|
|
525
|
+
<div align="center">
|
|
526
|
+
|
|
527
|
+
*👻 PHANTOM-FCA — Because every message matters.*
|
|
528
|
+
|
|
529
|
+
*Crafted with passion by **SIFAT**.*
|
|
530
|
+
|
|
531
|
+
[](https://www.npmjs.com/package/fca-phantom)
|
|
532
|
+
[](https://github.com/ewr-sifu/phantom-fca)
|
|
533
|
+
|
|
534
|
+
</div>
|
package/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { connect } = require("./phantom/core/engine");
|
|
4
|
+
const { globalShield, globalAntiSuspension } = require("./phantom/datastore/models/matrix/ghost");
|
|
5
|
+
const { globalReviveManager, globalAutoReLoginManager } = require("./phantom/datastore/models/matrix/revive");
|
|
6
|
+
const { globalGate, globalRateLimiter, configureRateLimiter, getRateLimiterStats } = require("./phantom/datastore/models/matrix/gate");
|
|
7
|
+
const { globalMonitor, Telemetry } = require("./phantom/datastore/models/matrix/telemetry");
|
|
8
|
+
const { globalCache, DataCache } = require("./phantom/datastore/models/matrix/store");
|
|
9
|
+
const { CycleManager, TokenRefreshManager } = require("./phantom/datastore/models/matrix/heartbeat");
|
|
10
|
+
const { globalCipher, PhantomCipher } = require("./phantom/datastore/models/cipher/vault");
|
|
11
|
+
const tools = require("./phantom/datastore/models/matrix/tools");
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
connect,
|
|
15
|
+
|
|
16
|
+
globalShield,
|
|
17
|
+
globalAntiSuspension,
|
|
18
|
+
globalReviveManager,
|
|
19
|
+
globalAutoReLoginManager,
|
|
20
|
+
globalGate,
|
|
21
|
+
globalRateLimiter,
|
|
22
|
+
configureRateLimiter,
|
|
23
|
+
getRateLimiterStats,
|
|
24
|
+
globalMonitor,
|
|
25
|
+
Telemetry,
|
|
26
|
+
globalCache,
|
|
27
|
+
DataCache,
|
|
28
|
+
CycleManager,
|
|
29
|
+
TokenRefreshManager,
|
|
30
|
+
globalCipher,
|
|
31
|
+
PhantomCipher,
|
|
32
|
+
|
|
33
|
+
...tools,
|
|
34
|
+
default: { connect },
|
|
35
|
+
};
|