fca-nx 6.6.6
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/LICENCE +21 -0
- package/README.md +446 -0
- package/e2ee/config.json +0 -0
- package/e2ee/crypto.js +173 -0
- package/e2ee/index.js +1032 -0
- package/e2ee/proto/ArmadilloApplication.proto +281 -0
- package/e2ee/proto/ArmadilloICDC.proto +14 -0
- package/e2ee/proto/ConsumerApplication.proto +232 -0
- package/e2ee/proto/MessageApplication.proto +82 -0
- package/e2ee/proto/MessageTransport.proto +77 -0
- package/e2ee/proto/WACommon.proto +66 -0
- package/e2ee/proto/WAMediaTransport.proto +176 -0
- package/e2ee/protocol.js +196 -0
- package/e2ee/ratchet.js +219 -0
- package/e2ee/store.js +182 -0
- package/e2ee/vendor/fb-e2ee.cjs +9159 -0
- package/e2ee/vendor/proto/ArmadilloApplication.proto +281 -0
- package/e2ee/vendor/proto/ArmadilloICDC.proto +14 -0
- package/e2ee/vendor/proto/ConsumerApplication.proto +232 -0
- package/e2ee/vendor/proto/MessageApplication.proto +82 -0
- package/e2ee/vendor/proto/MessageTransport.proto +77 -0
- package/e2ee/vendor/proto/WACommon.proto +66 -0
- package/e2ee/vendor/proto/WAMediaTransport.proto +176 -0
- package/func/checkUpdate.js +7 -0
- package/func/logAdapter.js +33 -0
- package/func/logger.js +134 -0
- package/index.js +22 -0
- package/module/config.js +45 -0
- package/module/login.js +183 -0
- package/module/loginHelper.js +1382 -0
- package/module/options.js +52 -0
- package/package.json +101 -0
- package/src/api/action/addExternalModule.js +25 -0
- package/src/api/action/addFriend.js +145 -0
- package/src/api/action/changeAvatar.js +137 -0
- package/src/api/action/changeBio.js +75 -0
- package/src/api/action/changeCover.js +277 -0
- package/src/api/action/enableAutoSaveAppState.js +73 -0
- package/src/api/action/getCurrentUserID.js +7 -0
- package/src/api/action/handleFriendRequest.js +57 -0
- package/src/api/action/logout.js +76 -0
- package/src/api/action/refreshFb_dtsg.js +48 -0
- package/src/api/action/setPostReaction.js +106 -0
- package/src/api/action/unfriend.js +54 -0
- package/src/api/http/httpGet.js +46 -0
- package/src/api/http/httpPost.js +52 -0
- package/src/api/http/postFormData.js +47 -0
- package/src/api/messaging/addUserToGroup.js +68 -0
- package/src/api/messaging/changeAdminStatus.js +126 -0
- package/src/api/messaging/changeArchivedStatus.js +55 -0
- package/src/api/messaging/changeBlockedStatus.js +48 -0
- package/src/api/messaging/changeGroupImage.js +91 -0
- package/src/api/messaging/changeNickname.js +70 -0
- package/src/api/messaging/changeThreadColor.js +79 -0
- package/src/api/messaging/changeThreadEmoji.js +111 -0
- package/src/api/messaging/createNewGroup.js +88 -0
- package/src/api/messaging/createPoll.js +46 -0
- package/src/api/messaging/createThemeAI.js +98 -0
- package/src/api/messaging/deleteMessage.js +136 -0
- package/src/api/messaging/deleteThread.js +56 -0
- package/src/api/messaging/editMessage.js +90 -0
- package/src/api/messaging/forwardAttachment.js +57 -0
- package/src/api/messaging/forwardMessage.js +134 -0
- package/src/api/messaging/getEmojiUrl.js +29 -0
- package/src/api/messaging/getFriendsList.js +82 -0
- package/src/api/messaging/getMessage.js +829 -0
- package/src/api/messaging/getThemePictures.js +62 -0
- package/src/api/messaging/handleMessageRequest.js +65 -0
- package/src/api/messaging/markAsDelivered.js +57 -0
- package/src/api/messaging/markAsRead.js +88 -0
- package/src/api/messaging/markAsReadAll.js +49 -0
- package/src/api/messaging/markAsSeen.js +61 -0
- package/src/api/messaging/muteThread.js +50 -0
- package/src/api/messaging/pinMessage.js +115 -0
- package/src/api/messaging/removeUserFromGroup.js +62 -0
- package/src/api/messaging/resolvePhotoUrl.js +43 -0
- package/src/api/messaging/scheduler.js +264 -0
- package/src/api/messaging/searchForThread.js +53 -0
- package/src/api/messaging/sendBroadcast.js +93 -0
- package/src/api/messaging/sendMessage.js +269 -0
- package/src/api/messaging/sendTypingIndicator.js +74 -0
- package/src/api/messaging/sessionGuard.js +208 -0
- package/src/api/messaging/setMessageReaction.js +95 -0
- package/src/api/messaging/setTitle.js +124 -0
- package/src/api/messaging/shareContact.js +49 -0
- package/src/api/messaging/threadColors.js +128 -0
- package/src/api/messaging/unsendMessage.js +81 -0
- package/src/api/messaging/uploadAttachment.js +523 -0
- package/src/api/socket/OldMessage.js +186 -0
- package/src/api/socket/core/connectMqtt.js +320 -0
- package/src/api/socket/core/emitAuth.js +103 -0
- package/src/api/socket/core/getSeqID.js +338 -0
- package/src/api/socket/core/getTaskResponseData.js +25 -0
- package/src/api/socket/core/parseDelta.js +387 -0
- package/src/api/socket/detail/buildStream.js +215 -0
- package/src/api/socket/detail/constants.js +28 -0
- package/src/api/socket/e2ee/crypto.js +173 -0
- package/src/api/socket/e2ee/e2ee/crypto.js +173 -0
- package/src/api/socket/e2ee/e2ee/index.js +421 -0
- package/src/api/socket/e2ee/e2ee/proto/ArmadilloApplication.proto +281 -0
- package/src/api/socket/e2ee/e2ee/proto/ArmadilloICDC.proto +14 -0
- package/src/api/socket/e2ee/e2ee/proto/ConsumerApplication.proto +232 -0
- package/src/api/socket/e2ee/e2ee/proto/MessageApplication.proto +82 -0
- package/src/api/socket/e2ee/e2ee/proto/MessageTransport.proto +77 -0
- package/src/api/socket/e2ee/e2ee/proto/WACommon.proto +66 -0
- package/src/api/socket/e2ee/e2ee/proto/WAMediaTransport.proto +176 -0
- package/src/api/socket/e2ee/e2ee/protocol.js +196 -0
- package/src/api/socket/e2ee/e2ee/ratchet.js +219 -0
- package/src/api/socket/e2ee/e2ee/store.js +182 -0
- package/src/api/socket/e2ee/e2ee/vendor/fb-e2ee.cjs +9162 -0
- package/src/api/socket/e2ee/e2ee/vendor/proto/ArmadilloApplication.proto +281 -0
- package/src/api/socket/e2ee/e2ee/vendor/proto/ArmadilloICDC.proto +14 -0
- package/src/api/socket/e2ee/e2ee/vendor/proto/ConsumerApplication.proto +232 -0
- package/src/api/socket/e2ee/e2ee/vendor/proto/MessageApplication.proto +82 -0
- package/src/api/socket/e2ee/e2ee/vendor/proto/MessageTransport.proto +77 -0
- package/src/api/socket/e2ee/e2ee/vendor/proto/WACommon.proto +66 -0
- package/src/api/socket/e2ee/e2ee/vendor/proto/WAMediaTransport.proto +176 -0
- package/src/api/socket/e2ee/index.js +437 -0
- package/src/api/socket/e2ee/proto/ArmadilloApplication.proto +281 -0
- package/src/api/socket/e2ee/proto/ArmadilloICDC.proto +14 -0
- package/src/api/socket/e2ee/proto/ConsumerApplication.proto +232 -0
- package/src/api/socket/e2ee/proto/MessageApplication.proto +82 -0
- package/src/api/socket/e2ee/proto/MessageTransport.proto +77 -0
- package/src/api/socket/e2ee/proto/WACommon.proto +66 -0
- package/src/api/socket/e2ee/proto/WAMediaTransport.proto +176 -0
- package/src/api/socket/e2ee/protocol.js +196 -0
- package/src/api/socket/e2ee/ratchet.js +219 -0
- package/src/api/socket/e2ee/store.js +182 -0
- package/src/api/socket/e2ee/vendor/fb-e2ee.cjs +9162 -0
- package/src/api/socket/e2ee/vendor/proto/ArmadilloApplication.proto +281 -0
- package/src/api/socket/e2ee/vendor/proto/ArmadilloICDC.proto +14 -0
- package/src/api/socket/e2ee/vendor/proto/ConsumerApplication.proto +232 -0
- package/src/api/socket/e2ee/vendor/proto/MessageApplication.proto +82 -0
- package/src/api/socket/e2ee/vendor/proto/MessageTransport.proto +77 -0
- package/src/api/socket/e2ee/vendor/proto/WACommon.proto +66 -0
- package/src/api/socket/e2ee/vendor/proto/WAMediaTransport.proto +176 -0
- package/src/api/socket/listenE2EE.js +75 -0
- package/src/api/socket/listenMqtt.js +551 -0
- package/src/api/socket/middleware/index.js +216 -0
- package/src/api/socket/sendMessage.js +309 -0
- package/src/api/socket/sendMessageMqtt.js +69 -0
- package/src/api/threads/getThreadHistory.js +664 -0
- package/src/api/threads/getThreadInfo.js +296 -0
- package/src/api/threads/getThreadList.js +293 -0
- package/src/api/threads/getThreadPictures.js +78 -0
- package/src/api/users/getUserID.js +65 -0
- package/src/api/users/getUserInfo.js +402 -0
- package/src/api/users/getUserInfoV2.js +911 -0
- package/src/app/MessengerBot.js +209 -0
- package/src/app/MessengerContext.js +32 -0
- package/src/app/createFcaClient.js +139 -0
- package/src/app/threadInfoRealtimeSync.js +284 -0
- package/src/core/sendReqMqtt.js +96 -0
- package/src/database/helpers.js +53 -0
- package/src/database/models/index.js +88 -0
- package/src/database/models/thread.js +50 -0
- package/src/database/models/user.js +46 -0
- package/src/database/threadData.js +94 -0
- package/src/database/userData.js +98 -0
- package/src/remote/remoteClient.js +123 -0
- package/src/utils/broadcast.js +51 -0
- package/src/utils/client.js +10 -0
- package/src/utils/clientIdentity.js +118 -0
- package/src/utils/constants.js +23 -0
- package/src/utils/cookies.js +68 -0
- package/src/utils/format/attachment.js +357 -0
- package/src/utils/format/cookie.js +9 -0
- package/src/utils/format/date.js +50 -0
- package/src/utils/format/decode.js +44 -0
- package/src/utils/format/delta.js +194 -0
- package/src/utils/format/ids.js +64 -0
- package/src/utils/format/index.js +64 -0
- package/src/utils/format/message.js +88 -0
- package/src/utils/format/presence.js +132 -0
- package/src/utils/format/readTyp.js +44 -0
- package/src/utils/format/thread.js +42 -0
- package/src/utils/format/utils.js +141 -0
- package/src/utils/headers.js +124 -0
- package/src/utils/logger.js +144 -0
- package/src/utils/loginParser/autoLogin.js +125 -0
- package/src/utils/loginParser/helpers.js +43 -0
- package/src/utils/loginParser/index.js +10 -0
- package/src/utils/loginParser/parseAndCheckLogin.js +220 -0
- package/src/utils/loginParser/textUtils.js +28 -0
- package/src/utils/request/client.js +26 -0
- package/src/utils/request/config.js +29 -0
- package/src/utils/request/defaults.js +46 -0
- package/src/utils/request/helpers.js +46 -0
- package/src/utils/request/index.js +17 -0
- package/src/utils/request/methods.js +163 -0
- package/src/utils/request/proxy.js +46 -0
- package/src/utils/request/retry.js +77 -0
- package/src/utils/request/sanitize.js +49 -0
- package/src/utils/utils.js +686 -0
- package/src/utils/versionCheck.js +47 -0
- package/src/vendor/fca-unofficial/index.js +11 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
syntax = "proto2";
|
|
2
|
+
package WACommon;
|
|
3
|
+
|
|
4
|
+
enum FutureProofBehavior {
|
|
5
|
+
PLACEHOLDER = 0;
|
|
6
|
+
NO_PLACEHOLDER = 1;
|
|
7
|
+
IGNORE = 2;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
message MessageKey {
|
|
11
|
+
optional string remoteJID = 1;
|
|
12
|
+
optional bool fromMe = 2;
|
|
13
|
+
optional string ID = 3;
|
|
14
|
+
optional string participant = 4;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
message Command {
|
|
18
|
+
enum CommandType {
|
|
19
|
+
EVERYONE = 1;
|
|
20
|
+
SILENT = 2;
|
|
21
|
+
AI = 3;
|
|
22
|
+
AI_IMAGINE = 4;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
optional CommandType commandType = 1;
|
|
26
|
+
optional uint32 offset = 2;
|
|
27
|
+
optional uint32 length = 3;
|
|
28
|
+
optional string validationToken = 4;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
message Mention {
|
|
32
|
+
enum MentionType {
|
|
33
|
+
PROFILE = 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
optional MentionType mentionType = 1;
|
|
37
|
+
optional string mentionedJID = 2;
|
|
38
|
+
optional uint32 offset = 3;
|
|
39
|
+
optional uint32 length = 4;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
message MessageText {
|
|
43
|
+
optional string text = 1;
|
|
44
|
+
repeated string mentionedJID = 2;
|
|
45
|
+
repeated Command commands = 3;
|
|
46
|
+
repeated Mention mentions = 4;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
message SubProtocol {
|
|
50
|
+
optional bytes payload = 1;
|
|
51
|
+
optional int32 version = 2;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
message LimitSharing {
|
|
55
|
+
enum Trigger {
|
|
56
|
+
UNKNOWN = 0;
|
|
57
|
+
CHAT_SETTING = 1;
|
|
58
|
+
BIZ_SUPPORTS_FB_HOSTING = 2;
|
|
59
|
+
UNKNOWN_GROUP = 3;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
optional bool sharingLimited = 1;
|
|
63
|
+
optional Trigger trigger = 2;
|
|
64
|
+
optional int64 limitSharingSettingTimestamp = 3;
|
|
65
|
+
optional bool initiatedByMe = 4;
|
|
66
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
syntax = "proto2";
|
|
2
|
+
package WAMediaTransport;
|
|
3
|
+
|
|
4
|
+
import "WACommon.proto";
|
|
5
|
+
|
|
6
|
+
message WAMediaTransport {
|
|
7
|
+
message Ancillary {
|
|
8
|
+
message Thumbnail {
|
|
9
|
+
message DownloadableThumbnail {
|
|
10
|
+
optional bytes fileSHA256 = 1;
|
|
11
|
+
optional bytes fileEncSHA256 = 2;
|
|
12
|
+
optional string directPath = 3;
|
|
13
|
+
optional bytes mediaKey = 4;
|
|
14
|
+
optional int64 mediaKeyTimestamp = 5;
|
|
15
|
+
optional string objectID = 6;
|
|
16
|
+
optional bytes thumbnailScansSidecar = 7;
|
|
17
|
+
repeated uint32 thumbnailScanLengths = 8;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
optional bytes JPEGThumbnail = 1;
|
|
21
|
+
optional DownloadableThumbnail downloadableThumbnail = 2;
|
|
22
|
+
optional uint32 thumbnailWidth = 3;
|
|
23
|
+
optional uint32 thumbnailHeight = 4;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
optional uint64 fileLength = 1;
|
|
27
|
+
optional string mimetype = 2;
|
|
28
|
+
optional Thumbnail thumbnail = 3;
|
|
29
|
+
optional string objectID = 4;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
message Integral {
|
|
33
|
+
optional bytes fileSHA256 = 1;
|
|
34
|
+
optional bytes mediaKey = 2;
|
|
35
|
+
optional bytes fileEncSHA256 = 3;
|
|
36
|
+
optional string directPath = 4;
|
|
37
|
+
optional int64 mediaKeyTimestamp = 5;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
optional Integral integral = 1;
|
|
41
|
+
optional Ancillary ancillary = 2;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
message ImageTransport {
|
|
45
|
+
message Ancillary {
|
|
46
|
+
enum HdType {
|
|
47
|
+
NONE = 0;
|
|
48
|
+
LQ_4K = 1;
|
|
49
|
+
HQ_4K = 2;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
optional uint32 height = 1;
|
|
53
|
+
optional uint32 width = 2;
|
|
54
|
+
optional bytes scansSidecar = 3;
|
|
55
|
+
repeated uint32 scanLengths = 4;
|
|
56
|
+
optional bytes midQualityFileSHA256 = 5;
|
|
57
|
+
optional HdType hdType = 6;
|
|
58
|
+
repeated float memoriesConceptScores = 7 [packed=true];
|
|
59
|
+
repeated uint32 memoriesConceptIDs = 8 [packed=true];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
message Integral {
|
|
63
|
+
optional WAMediaTransport transport = 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
optional Integral integral = 1;
|
|
67
|
+
optional Ancillary ancillary = 2;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
message VideoTransport {
|
|
71
|
+
message Ancillary {
|
|
72
|
+
enum Attribution {
|
|
73
|
+
NONE = 0;
|
|
74
|
+
GIPHY = 1;
|
|
75
|
+
TENOR = 2;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
optional uint32 seconds = 1;
|
|
79
|
+
optional WACommon.MessageText caption = 2;
|
|
80
|
+
optional bool gifPlayback = 3;
|
|
81
|
+
optional uint32 height = 4;
|
|
82
|
+
optional uint32 width = 5;
|
|
83
|
+
optional bytes sidecar = 6;
|
|
84
|
+
optional Attribution gifAttribution = 7;
|
|
85
|
+
optional string accessibilityLabel = 8;
|
|
86
|
+
optional bool isHd = 9;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
message Integral {
|
|
90
|
+
optional WAMediaTransport transport = 1;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
optional Integral integral = 1;
|
|
94
|
+
optional Ancillary ancillary = 2;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
message AudioTransport {
|
|
98
|
+
message Ancillary {
|
|
99
|
+
message AvatarAudio {
|
|
100
|
+
enum AnimationsType {
|
|
101
|
+
TALKING_A = 0;
|
|
102
|
+
IDLE_A = 1;
|
|
103
|
+
TALKING_B = 2;
|
|
104
|
+
IDLE_B = 3;
|
|
105
|
+
BACKGROUND = 4;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
message DownloadableAvatarAnimations {
|
|
109
|
+
optional bytes fileSHA256 = 1;
|
|
110
|
+
optional bytes fileEncSHA256 = 2;
|
|
111
|
+
optional string directPath = 3;
|
|
112
|
+
optional bytes mediaKey = 4;
|
|
113
|
+
optional int64 mediaKeyTimestamp = 5;
|
|
114
|
+
optional string objectID = 6;
|
|
115
|
+
optional AnimationsType animationsType = 7;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
optional uint32 poseID = 1;
|
|
119
|
+
repeated DownloadableAvatarAnimations avatarAnimations = 2;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
optional uint32 seconds = 1;
|
|
123
|
+
optional AvatarAudio avatarAudio = 2;
|
|
124
|
+
optional string waveformData = 3;
|
|
125
|
+
optional bytes waveform = 4;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
message Integral {
|
|
129
|
+
enum AudioFormat {
|
|
130
|
+
UNKNOWN = 0;
|
|
131
|
+
OPUS = 1;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
optional WAMediaTransport transport = 1;
|
|
135
|
+
optional AudioFormat audioFormat = 2;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
optional Integral integral = 1;
|
|
139
|
+
optional Ancillary ancillary = 2;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
message DocumentTransport {
|
|
143
|
+
message Ancillary {
|
|
144
|
+
optional uint32 pageCount = 1;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
message Integral {
|
|
148
|
+
optional WAMediaTransport transport = 1;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
optional Integral integral = 1;
|
|
152
|
+
optional Ancillary ancillary = 2;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
message StickerTransport {
|
|
156
|
+
message Ancillary {
|
|
157
|
+
optional uint32 pageCount = 1;
|
|
158
|
+
optional uint32 height = 2;
|
|
159
|
+
optional uint32 width = 3;
|
|
160
|
+
optional uint32 firstFrameLength = 4;
|
|
161
|
+
optional bytes firstFrameSidecar = 5;
|
|
162
|
+
optional string mustacheText = 6;
|
|
163
|
+
optional bool isThirdParty = 7;
|
|
164
|
+
optional string receiverFetchID = 8;
|
|
165
|
+
optional string accessibilityLabel = 9;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
message Integral {
|
|
169
|
+
optional WAMediaTransport transport = 1;
|
|
170
|
+
optional bool isAnimated = 2;
|
|
171
|
+
optional string receiverFetchID = 3;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
optional Integral integral = 1;
|
|
175
|
+
optional Ancillary ancillary = 2;
|
|
176
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const logger = require("./logger");
|
|
2
|
+
|
|
3
|
+
function formatArgs(args) {
|
|
4
|
+
const [prefix, msg] = args;
|
|
5
|
+
|
|
6
|
+
// Single argument: log as-is
|
|
7
|
+
if (msg === undefined) {
|
|
8
|
+
if (prefix instanceof Error) {
|
|
9
|
+
return prefix.stack || prefix.message || String(prefix);
|
|
10
|
+
}
|
|
11
|
+
return String(prefix);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Two arguments: mimic npmlog("tag", message)
|
|
15
|
+
const tag = prefix == null ? "" : String(prefix);
|
|
16
|
+
if (msg instanceof Error) {
|
|
17
|
+
const base = msg.message || String(msg);
|
|
18
|
+
return tag ? `${tag}: ${base}` : base;
|
|
19
|
+
}
|
|
20
|
+
const text = msg == null ? "" : String(msg);
|
|
21
|
+
return tag ? `${tag}: ${text}` : text;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const log = {
|
|
25
|
+
info: (...args) => logger(formatArgs(args), "info"),
|
|
26
|
+
warn: (...args) => logger(formatArgs(args), "warn"),
|
|
27
|
+
error: (...args) => logger(formatArgs(args), "error"),
|
|
28
|
+
verbose: (...args) => logger(formatArgs(args), "info"),
|
|
29
|
+
silly: (...args) => logger(formatArgs(args), "info")
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
module.exports = log;
|
|
33
|
+
|
package/func/logger.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const chalk = require("chalk");
|
|
4
|
+
const gradient = require("gradient-string");
|
|
5
|
+
|
|
6
|
+
const themes = [
|
|
7
|
+
"blue",
|
|
8
|
+
"dream2",
|
|
9
|
+
"dream",
|
|
10
|
+
"fiery",
|
|
11
|
+
"rainbow",
|
|
12
|
+
"pastel",
|
|
13
|
+
"cristal",
|
|
14
|
+
"red",
|
|
15
|
+
"aqua",
|
|
16
|
+
"pink",
|
|
17
|
+
"retro",
|
|
18
|
+
"sunlight",
|
|
19
|
+
"teen",
|
|
20
|
+
"summer",
|
|
21
|
+
"flower",
|
|
22
|
+
"ghost",
|
|
23
|
+
"hacker"
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
function buildGradient(name) {
|
|
27
|
+
const t = String(name || "").toLowerCase();
|
|
28
|
+
|
|
29
|
+
switch (t) {
|
|
30
|
+
case "blue":
|
|
31
|
+
return gradient([
|
|
32
|
+
{ color: "#1affa3", pos: 0 },
|
|
33
|
+
{ color: "#00d9ff", pos: 0.25 },
|
|
34
|
+
{ color: "#7b61ff", pos: 0.5 },
|
|
35
|
+
{ color: "#ff4fd8", pos: 0.75 },
|
|
36
|
+
{ color: "#1affa3", pos: 1 }
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
case "dream2":
|
|
40
|
+
return gradient("#00c6ff", "#7b2cff", "#ff4fd8");
|
|
41
|
+
|
|
42
|
+
case "dream":
|
|
43
|
+
return gradient([
|
|
44
|
+
{ color: "#00c6ff", pos: 0 },
|
|
45
|
+
{ color: "#7b2cff", pos: 0.3 },
|
|
46
|
+
{ color: "#ffcc00", pos: 0.55 },
|
|
47
|
+
{ color: "#ff4fd8", pos: 0.8 },
|
|
48
|
+
{ color: "#00c6ff", pos: 1 }
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
case "fiery":
|
|
52
|
+
return gradient("#ff2100", "#ff6a00", "#ffd000");
|
|
53
|
+
|
|
54
|
+
case "rainbow":
|
|
55
|
+
return gradient.rainbow;
|
|
56
|
+
|
|
57
|
+
case "pastel":
|
|
58
|
+
return gradient.pastel;
|
|
59
|
+
|
|
60
|
+
case "cristal":
|
|
61
|
+
return gradient.cristal;
|
|
62
|
+
|
|
63
|
+
case "red":
|
|
64
|
+
return gradient("#ff003c", "#ff7b00");
|
|
65
|
+
|
|
66
|
+
case "aqua":
|
|
67
|
+
return gradient("#0066ff", "#00eaff");
|
|
68
|
+
|
|
69
|
+
case "pink":
|
|
70
|
+
return gradient("#ff4fd8", "#8b00ff");
|
|
71
|
+
|
|
72
|
+
case "retro":
|
|
73
|
+
return gradient.retro;
|
|
74
|
+
|
|
75
|
+
case "sunlight":
|
|
76
|
+
return gradient("#ff8c00", "#ffe600");
|
|
77
|
+
|
|
78
|
+
case "teen":
|
|
79
|
+
return gradient.teen;
|
|
80
|
+
|
|
81
|
+
case "summer":
|
|
82
|
+
return gradient.summer;
|
|
83
|
+
|
|
84
|
+
case "flower":
|
|
85
|
+
return gradient("#00c6ff", "#8b00ff", "#ffe600", "#55ff77");
|
|
86
|
+
|
|
87
|
+
case "ghost":
|
|
88
|
+
return gradient.mind;
|
|
89
|
+
|
|
90
|
+
case "hacker":
|
|
91
|
+
return gradient("#39ff14", "#00c853", "#00ff88");
|
|
92
|
+
|
|
93
|
+
default:
|
|
94
|
+
return gradient("#243aff", "#4687f0", "#8a2be2");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const themeName = themes[Math.floor(Math.random() * themes.length)];
|
|
99
|
+
const co = buildGradient(themeName);
|
|
100
|
+
|
|
101
|
+
function formatPrefix(type) {
|
|
102
|
+
const name = String(type || "INFO").toUpperCase();
|
|
103
|
+
|
|
104
|
+
if (name === "WARN") {
|
|
105
|
+
return chalk.bold.hex("#ffb000")("[ FCA-NX⚡ ]");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (name === "ERROR") {
|
|
109
|
+
return chalk.bold.hex("#ff3b30")("[ FCA-NX⚡ ]");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (name === "SUCCESS") {
|
|
113
|
+
return chalk.bold.hex("#00ff88")("[ FCA-NX⚡ ]");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (name === "DEBUG") {
|
|
117
|
+
return chalk.bold.hex("#8888ff")("[ FCA-NX⚡ ]");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return chalk.bold(co("[ FCA-NX⚡ ]"));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function formatMessage(text) {
|
|
124
|
+
return String(text ?? "")
|
|
125
|
+
.replace(/\r/g, "")
|
|
126
|
+
.replace(/\n+/g, "\n");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
module.exports = (text, type = "info") => {
|
|
130
|
+
const message = formatMessage(text);
|
|
131
|
+
const prefix = formatPrefix(type);
|
|
132
|
+
|
|
133
|
+
process.stderr.write(`${prefix} ${co(">")} ${message}\n`);
|
|
134
|
+
};
|
package/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const login = require("./module/login");
|
|
4
|
+
const { createFcaClient } = require("./src/app/createFcaClient");
|
|
5
|
+
const { MessengerBot, createMessengerBot } = require("./src/app/MessengerBot");
|
|
6
|
+
const { MessengerContext } = require("./src/app/MessengerContext");
|
|
7
|
+
const { attachThreadInfoRealtimeSync, applyThreadInfoRealtimeEvent } = require("./src/app/threadInfoRealtimeSync");
|
|
8
|
+
|
|
9
|
+
// CommonJS default export — the login function (classic FCA / GoatBot compatible)
|
|
10
|
+
module.exports = login;
|
|
11
|
+
|
|
12
|
+
// Named exports
|
|
13
|
+
module.exports.login = login;
|
|
14
|
+
module.exports.default = login;
|
|
15
|
+
|
|
16
|
+
// New features from dongdev
|
|
17
|
+
module.exports.createFcaClient = createFcaClient;
|
|
18
|
+
module.exports.MessengerBot = MessengerBot;
|
|
19
|
+
module.exports.createMessengerBot = createMessengerBot;
|
|
20
|
+
module.exports.MessengerContext = MessengerContext;
|
|
21
|
+
module.exports.attachThreadInfoRealtimeSync = attachThreadInfoRealtimeSync;
|
|
22
|
+
module.exports.applyThreadInfoRealtimeEvent = applyThreadInfoRealtimeEvent;
|
package/module/config.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const logger = require("../func/logger");
|
|
4
|
+
const defaultConfig = {
|
|
5
|
+
autoUpdate: true,
|
|
6
|
+
mqtt: { enabled: true, reconnectInterval: 3600 },
|
|
7
|
+
autoLogin: true,
|
|
8
|
+
// SECURITY: intentionally no default value here. Sending Facebook
|
|
9
|
+
// credentials to a third-party server should be an explicit,
|
|
10
|
+
// operator-chosen opt-in (see module/loginHelper.js#loginViaAPI), never a
|
|
11
|
+
// silent default. Set this in fca-config.json only if you trust the
|
|
12
|
+
// server you're pointing it at.
|
|
13
|
+
apiServer: "",
|
|
14
|
+
apiKey: "",
|
|
15
|
+
credentials: { email: "", password: "", twofactor: "" },
|
|
16
|
+
antiGetInfo: {
|
|
17
|
+
AntiGetThreadInfo: false,
|
|
18
|
+
AntiGetUserInfo: false
|
|
19
|
+
},
|
|
20
|
+
remoteControl: {
|
|
21
|
+
enabled: false,
|
|
22
|
+
url: "",
|
|
23
|
+
token: "",
|
|
24
|
+
autoReconnect: true
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function loadConfig() {
|
|
29
|
+
const configPath = path.join(process.cwd(), "fca-config.json");
|
|
30
|
+
let config;
|
|
31
|
+
if (!fs.existsSync(configPath)) {
|
|
32
|
+
config = defaultConfig;
|
|
33
|
+
} else {
|
|
34
|
+
try {
|
|
35
|
+
const fileContent = fs.readFileSync(configPath, "utf8");
|
|
36
|
+
config = Object.assign({}, defaultConfig, JSON.parse(fileContent));
|
|
37
|
+
} catch (err) {
|
|
38
|
+
logger(`Error reading config file: ${err.message}`, "error");
|
|
39
|
+
config = defaultConfig;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return { config, configPath };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = { loadConfig, defaultConfig };
|
package/module/login.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
const { getType } = require("../src/utils/format");
|
|
2
|
+
const { setOptions } = require("./options");
|
|
3
|
+
const { loadConfig } = require("./config");
|
|
4
|
+
const { checkAndUpdateVersion } = require("../func/checkUpdate");
|
|
5
|
+
const loginHelper = require("./loginHelper");
|
|
6
|
+
const logger = require("../func/logger");
|
|
7
|
+
const { DEFAULT_IDENTITY } = require("../src/utils/clientIdentity");
|
|
8
|
+
|
|
9
|
+
const { config } = loadConfig();
|
|
10
|
+
global.fca = { config };
|
|
11
|
+
|
|
12
|
+
// Global error handlers to prevent bot crashes
|
|
13
|
+
// Handle unhandled promise rejections (e.g., fetch timeouts, network errors)
|
|
14
|
+
if (!global.fca._errorHandlersInstalled) {
|
|
15
|
+
global.fca._errorHandlersInstalled = true;
|
|
16
|
+
|
|
17
|
+
process.on("unhandledRejection", (reason, promise) => {
|
|
18
|
+
try {
|
|
19
|
+
// Check if it's a fetch/network timeout error
|
|
20
|
+
if (reason && typeof reason === "object") {
|
|
21
|
+
const errorCode = reason.code || reason.cause?.code;
|
|
22
|
+
const errorMessage = reason.message || String(reason);
|
|
23
|
+
|
|
24
|
+
// Suppress Sequelize instance errors (handled gracefully in getBackupModel)
|
|
25
|
+
if (errorMessage.includes("No Sequelize instance passed")) {
|
|
26
|
+
return; // Silently ignore - already handled
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Handle fetch timeout errors gracefully
|
|
30
|
+
if (errorCode === "UND_ERR_CONNECT_TIMEOUT" ||
|
|
31
|
+
errorCode === "ETIMEDOUT" ||
|
|
32
|
+
errorMessage.includes("Connect Timeout") ||
|
|
33
|
+
errorMessage.includes("fetch failed")) {
|
|
34
|
+
logger(`Network timeout error caught (non-fatal): ${errorMessage}`, "warn");
|
|
35
|
+
return; // Don't crash, just log
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Handle other network errors
|
|
39
|
+
if (errorCode === "ECONNREFUSED" ||
|
|
40
|
+
errorCode === "ENOTFOUND" ||
|
|
41
|
+
errorCode === "ECONNRESET" ||
|
|
42
|
+
errorMessage.includes("ECONNREFUSED") ||
|
|
43
|
+
errorMessage.includes("ENOTFOUND")) {
|
|
44
|
+
logger(`Network connection error caught (non-fatal): ${errorMessage}`, "warn");
|
|
45
|
+
return; // Don't crash, just log
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// For other unhandled rejections, log but don't crash
|
|
50
|
+
logger(`Unhandled promise rejection (non-fatal): ${reason && reason.message ? reason.message : String(reason)}`, "error");
|
|
51
|
+
} catch (e) {
|
|
52
|
+
// Fallback if logger fails - silent
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Handle uncaught exceptions (last resort)
|
|
57
|
+
process.on("uncaughtException", (error) => {
|
|
58
|
+
try {
|
|
59
|
+
const errorMessage = error.message || String(error);
|
|
60
|
+
const errorCode = error.code;
|
|
61
|
+
|
|
62
|
+
// Suppress Sequelize instance errors (handled gracefully in getBackupModel)
|
|
63
|
+
if (errorMessage.includes("No Sequelize instance passed")) {
|
|
64
|
+
return; // Silently ignore - already handled
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Handle fetch/network errors
|
|
68
|
+
if (errorCode === "UND_ERR_CONNECT_TIMEOUT" ||
|
|
69
|
+
errorCode === "ETIMEDOUT" ||
|
|
70
|
+
errorMessage.includes("Connect Timeout") ||
|
|
71
|
+
errorMessage.includes("fetch failed")) {
|
|
72
|
+
logger(`Uncaught network timeout error (non-fatal): ${errorMessage}`, "warn");
|
|
73
|
+
return; // Don't crash
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// For other uncaught exceptions, log but try to continue
|
|
77
|
+
logger(`Uncaught exception (attempting to continue): ${errorMessage}`, "error");
|
|
78
|
+
// Note: We don't exit here to allow bot to continue running
|
|
79
|
+
// In production, you might want to restart the process instead
|
|
80
|
+
} catch (e) {
|
|
81
|
+
// Fallback if logger fails - silent
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Prevent multiple simultaneous login attempts for the same account.
|
|
87
|
+
// Keyed by whatever identifies the account in loginData (email, or the
|
|
88
|
+
// c_user/i_user value pulled out of an appstate/cookie string) so that
|
|
89
|
+
// calling login() twice in a row for the same account before the first
|
|
90
|
+
// call resolves can't race and produce two half-initialized sessions
|
|
91
|
+
// fighting over the same cookies.
|
|
92
|
+
if (!global.fca._activeLogins) global.fca._activeLogins = new Set();
|
|
93
|
+
|
|
94
|
+
function extractLoginKey(loginData) {
|
|
95
|
+
if (!loginData) return null;
|
|
96
|
+
if (loginData.email) return `email:${String(loginData.email).toLowerCase()}`;
|
|
97
|
+
const findUid = (str) => {
|
|
98
|
+
const m = String(str || "").match(/(?:c_user|i_user)=(\d+)/);
|
|
99
|
+
return m ? m[1] : null;
|
|
100
|
+
};
|
|
101
|
+
if (Array.isArray(loginData.appState)) {
|
|
102
|
+
const c = loginData.appState.find(c => c && (c.key === "c_user" || c.key === "i_user" || c.name === "c_user" || c.name === "i_user"));
|
|
103
|
+
if (c) return `uid:${c.value}`;
|
|
104
|
+
} else if (typeof loginData.appState === "string") {
|
|
105
|
+
const uid = findUid(loginData.appState);
|
|
106
|
+
if (uid) return `uid:${uid}`;
|
|
107
|
+
}
|
|
108
|
+
if (loginData.Cookie) {
|
|
109
|
+
const uid = findUid(loginData.Cookie);
|
|
110
|
+
if (uid) return `uid:${uid}`;
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function login(loginData, options, callback) {
|
|
116
|
+
if (getType(options) === "Function" || getType(options) === "AsyncFunction") {
|
|
117
|
+
callback = options;
|
|
118
|
+
options = {};
|
|
119
|
+
}
|
|
120
|
+
const globalOptions = {
|
|
121
|
+
selfListen: false,
|
|
122
|
+
selfListenEvent: false,
|
|
123
|
+
listenEvents: false,
|
|
124
|
+
listenTyping: false,
|
|
125
|
+
updatePresence: false,
|
|
126
|
+
forceLogin: false,
|
|
127
|
+
autoMarkRead: false,
|
|
128
|
+
autoReconnect: true,
|
|
129
|
+
online: true,
|
|
130
|
+
emitReady: false,
|
|
131
|
+
// Single source of truth for the default identity - see src/utils/clientIdentity.js.
|
|
132
|
+
// This used to be hard-coded independently here (Chrome/121), in
|
|
133
|
+
// module/options.js (Chrome/125), src/utils/headers.js (Chrome/139) and
|
|
134
|
+
// src/api/messaging/uploadAttachment.js (Chrome/143), which meant a single
|
|
135
|
+
// session could send contradictory browser-version fingerprints between
|
|
136
|
+
// different requests. All four now derive from the same identity module.
|
|
137
|
+
userAgent: DEFAULT_IDENTITY.userAgent
|
|
138
|
+
};
|
|
139
|
+
setOptions(globalOptions, options);
|
|
140
|
+
let prCallback = null;
|
|
141
|
+
let rejectFunc = null;
|
|
142
|
+
let resolveFunc = null;
|
|
143
|
+
let returnPromise = null;
|
|
144
|
+
if (getType(callback) !== "Function" && getType(callback) !== "AsyncFunction") {
|
|
145
|
+
returnPromise = new Promise(function (resolve, reject) {
|
|
146
|
+
resolveFunc = resolve;
|
|
147
|
+
rejectFunc = reject;
|
|
148
|
+
});
|
|
149
|
+
prCallback = function (error, api) {
|
|
150
|
+
if (error) return rejectFunc(error);
|
|
151
|
+
return resolveFunc(api);
|
|
152
|
+
};
|
|
153
|
+
callback = prCallback;
|
|
154
|
+
}
|
|
155
|
+
const loginKey = extractLoginKey(loginData);
|
|
156
|
+
if (loginKey && global.fca._activeLogins.has(loginKey)) {
|
|
157
|
+
const err = new Error("A login attempt for this account is already in progress.");
|
|
158
|
+
err.error = "login_in_progress";
|
|
159
|
+
callback(err);
|
|
160
|
+
return returnPromise;
|
|
161
|
+
}
|
|
162
|
+
if (loginKey) global.fca._activeLogins.add(loginKey);
|
|
163
|
+
const releaseLoginKey = () => { if (loginKey) global.fca._activeLogins.delete(loginKey); };
|
|
164
|
+
const wrappedCallback = (error, api) => {
|
|
165
|
+
releaseLoginKey();
|
|
166
|
+
callback(error, api);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const proceed = () => loginHelper(loginData.appState, loginData.Cookie, loginData.email, loginData.password, globalOptions, wrappedCallback, prCallback);
|
|
170
|
+
if (config && config.autoUpdate) {
|
|
171
|
+
const p = checkAndUpdateVersion();
|
|
172
|
+
if (p && typeof p.then === "function") {
|
|
173
|
+
p.then(proceed).catch(err => { releaseLoginKey(); callback(err); });
|
|
174
|
+
} else {
|
|
175
|
+
proceed();
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
proceed();
|
|
179
|
+
}
|
|
180
|
+
return returnPromise;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
module.exports = login;
|