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,277 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const log = require("../../../func/logAdapter");
|
|
4
|
+
const { isReadableStream } = require("../../utils/constants");
|
|
5
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
|
6
|
+
const { getType } = require("../../utils/format");
|
|
7
|
+
|
|
8
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
|
9
|
+
|
|
10
|
+
function handleUpload(image, callback) {
|
|
11
|
+
const form = {
|
|
12
|
+
profile_id: ctx.i_userID || ctx.userID,
|
|
13
|
+
photo_source: 57,
|
|
14
|
+
av: ctx.i_userID || ctx.userID,
|
|
15
|
+
file: image
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
defaultFuncs
|
|
19
|
+
.postFormData(
|
|
20
|
+
"https://www.facebook.com/profile/picture/upload/",
|
|
21
|
+
ctx.jar,
|
|
22
|
+
form,
|
|
23
|
+
{}
|
|
24
|
+
)
|
|
25
|
+
.then(
|
|
26
|
+
parseAndCheckLogin(ctx, defaultFuncs)
|
|
27
|
+
)
|
|
28
|
+
.then(function(resData) {
|
|
29
|
+
if (
|
|
30
|
+
!resData ||
|
|
31
|
+
resData.error ||
|
|
32
|
+
resData.errors ||
|
|
33
|
+
!resData.payload
|
|
34
|
+
) {
|
|
35
|
+
throw resData || new Error(
|
|
36
|
+
"Cover image upload failed"
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!resData.payload.fbid) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
"Facebook did not return photo ID"
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
callback(null, resData);
|
|
47
|
+
})
|
|
48
|
+
.catch(function(err) {
|
|
49
|
+
log.error("handleCoverUpload", err);
|
|
50
|
+
callback(err);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return function changeCover(
|
|
55
|
+
image,
|
|
56
|
+
callback
|
|
57
|
+
) {
|
|
58
|
+
|
|
59
|
+
let resolveFunc = function() {};
|
|
60
|
+
let rejectFunc = function() {};
|
|
61
|
+
|
|
62
|
+
const returnPromise = new Promise(
|
|
63
|
+
function(resolve, reject) {
|
|
64
|
+
resolveFunc = resolve;
|
|
65
|
+
rejectFunc = reject;
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
* Callback handling
|
|
71
|
+
*/
|
|
72
|
+
if (
|
|
73
|
+
!callback &&
|
|
74
|
+
(
|
|
75
|
+
getType(image) === "Function" ||
|
|
76
|
+
getType(image) === "AsyncFunction"
|
|
77
|
+
)
|
|
78
|
+
) {
|
|
79
|
+
callback = image;
|
|
80
|
+
image = null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!callback) {
|
|
84
|
+
callback = function(err, data) {
|
|
85
|
+
if (err) {
|
|
86
|
+
return rejectFunc(err);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
resolveFunc(data);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/*
|
|
94
|
+
* Validate image
|
|
95
|
+
*/
|
|
96
|
+
if (!isReadableStream(image)) {
|
|
97
|
+
return callback(
|
|
98
|
+
new Error(
|
|
99
|
+
"Image is not a readable stream"
|
|
100
|
+
)
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/*
|
|
105
|
+
* Upload cover image
|
|
106
|
+
*/
|
|
107
|
+
handleUpload(
|
|
108
|
+
image,
|
|
109
|
+
function(err, payload) {
|
|
110
|
+
|
|
111
|
+
if (err) {
|
|
112
|
+
return callback(err);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const userID =
|
|
116
|
+
ctx.i_userID ||
|
|
117
|
+
ctx.userID;
|
|
118
|
+
|
|
119
|
+
const photoID =
|
|
120
|
+
payload?.payload?.fbid;
|
|
121
|
+
|
|
122
|
+
if (!photoID) {
|
|
123
|
+
return callback(
|
|
124
|
+
new Error(
|
|
125
|
+
"Cover photo ID not found"
|
|
126
|
+
)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/*
|
|
131
|
+
* ProfileCometCoverPhotoUpdateMutation
|
|
132
|
+
*/
|
|
133
|
+
const variables = {
|
|
134
|
+
input: {
|
|
135
|
+
attribution_id_v2:
|
|
136
|
+
`ProfileCometCollectionRoot.react,` +
|
|
137
|
+
`comet.profile.collection.photos_by,unexpected,` +
|
|
138
|
+
`${Date.now()},770083,,;` +
|
|
139
|
+
|
|
140
|
+
`ProfileCometCollectionRoot.react,` +
|
|
141
|
+
`comet.profile.collection.photos_albums,unexpected,` +
|
|
142
|
+
`${Date.now()},470774,,;` +
|
|
143
|
+
|
|
144
|
+
`ProfileCometCollectionRoot.react,` +
|
|
145
|
+
`comet.profile.collection.photos,unexpected,` +
|
|
146
|
+
`${Date.now()},94740,,;` +
|
|
147
|
+
|
|
148
|
+
`ProfileCometCollectionRoot.react,` +
|
|
149
|
+
`comet.profile.collection.saved_reels_on_profile,unexpected,` +
|
|
150
|
+
`${Date.now()},89669,,;` +
|
|
151
|
+
|
|
152
|
+
`ProfileCometCollectionRoot.react,` +
|
|
153
|
+
`comet.profile.collection.reels_tab,unexpected,` +
|
|
154
|
+
`${Date.now()},152201,,`,
|
|
155
|
+
|
|
156
|
+
cover_photo_id: String(photoID),
|
|
157
|
+
|
|
158
|
+
focus: {
|
|
159
|
+
x: 0.5,
|
|
160
|
+
y: 1
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
target_user_id: String(userID),
|
|
164
|
+
actor_id: String(userID),
|
|
165
|
+
|
|
166
|
+
client_mutation_id:
|
|
167
|
+
Math.round(
|
|
168
|
+
Math.random() * 19
|
|
169
|
+
).toString()
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
scale: 1,
|
|
173
|
+
contextualProfileContext: null
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const form = {
|
|
177
|
+
av: String(userID),
|
|
178
|
+
|
|
179
|
+
fb_api_req_friendly_name:
|
|
180
|
+
"ProfileCometCoverPhotoUpdateMutation",
|
|
181
|
+
|
|
182
|
+
fb_api_caller_class:
|
|
183
|
+
"RelayModern",
|
|
184
|
+
|
|
185
|
+
doc_id:
|
|
186
|
+
"8247793861913071",
|
|
187
|
+
|
|
188
|
+
server_timestamps: true,
|
|
189
|
+
|
|
190
|
+
variables:
|
|
191
|
+
JSON.stringify(variables)
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
defaultFuncs
|
|
195
|
+
.post(
|
|
196
|
+
"https://www.facebook.com/api/graphql/",
|
|
197
|
+
ctx.jar,
|
|
198
|
+
form
|
|
199
|
+
)
|
|
200
|
+
.then(
|
|
201
|
+
parseAndCheckLogin(
|
|
202
|
+
ctx,
|
|
203
|
+
defaultFuncs
|
|
204
|
+
)
|
|
205
|
+
)
|
|
206
|
+
.then(function(resData) {
|
|
207
|
+
|
|
208
|
+
if (
|
|
209
|
+
!resData ||
|
|
210
|
+
resData.error ||
|
|
211
|
+
resData.errors
|
|
212
|
+
) {
|
|
213
|
+
throw resData || new Error(
|
|
214
|
+
"Cover photo update failed"
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/*
|
|
219
|
+
* Facebook response
|
|
220
|
+
*/
|
|
221
|
+
const coverURL =
|
|
222
|
+
resData
|
|
223
|
+
?.data
|
|
224
|
+
?.user_update_cover_photo
|
|
225
|
+
?.user
|
|
226
|
+
?.cover_photo
|
|
227
|
+
?.photo
|
|
228
|
+
?.url;
|
|
229
|
+
|
|
230
|
+
/*
|
|
231
|
+
* কিছু response array আকারে আসতে পারে
|
|
232
|
+
*/
|
|
233
|
+
const finalData =
|
|
234
|
+
Array.isArray(resData)
|
|
235
|
+
? resData[0]
|
|
236
|
+
: resData;
|
|
237
|
+
|
|
238
|
+
const url =
|
|
239
|
+
coverURL ||
|
|
240
|
+
finalData
|
|
241
|
+
?.data
|
|
242
|
+
?.user_update_cover_photo
|
|
243
|
+
?.user
|
|
244
|
+
?.cover_photo
|
|
245
|
+
?.photo
|
|
246
|
+
?.url;
|
|
247
|
+
|
|
248
|
+
if (!url) {
|
|
249
|
+
/*
|
|
250
|
+
* Mutation সফল হলেও URL না দিলে
|
|
251
|
+
* পুরো response return করছি।
|
|
252
|
+
*/
|
|
253
|
+
return callback(
|
|
254
|
+
null,
|
|
255
|
+
finalData
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return callback(
|
|
260
|
+
null,
|
|
261
|
+
url
|
|
262
|
+
);
|
|
263
|
+
})
|
|
264
|
+
.catch(function(err) {
|
|
265
|
+
log.error(
|
|
266
|
+
"changeCover",
|
|
267
|
+
err
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
return callback(err);
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
return returnPromise;
|
|
276
|
+
};
|
|
277
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const logger = require("../../../func/logger");
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Enable automatic AppState saving
|
|
8
|
+
* @param {Object} options - Options for auto-save
|
|
9
|
+
* @param {string} [options.filePath] - Path to save AppState (default: "appstate.json")
|
|
10
|
+
* @param {number} [options.interval] - Save interval in milliseconds (default: 10 minutes)
|
|
11
|
+
* @param {boolean} [options.saveOnLogin] - Save immediately on login (default: true)
|
|
12
|
+
* @returns {Function} Function to disable auto-save
|
|
13
|
+
*/
|
|
14
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
15
|
+
return function enableAutoSaveAppState(options = {}) {
|
|
16
|
+
const filePath = options.filePath || path.join(process.cwd(), "appstate.json");
|
|
17
|
+
const interval = options.interval || 10 * 60 * 1000; // 10 minutes default
|
|
18
|
+
const saveOnLogin = options.saveOnLogin !== false; // default true
|
|
19
|
+
|
|
20
|
+
// Save function
|
|
21
|
+
function saveAppState() {
|
|
22
|
+
try {
|
|
23
|
+
const appState = api.getAppState();
|
|
24
|
+
if (!appState || !appState.appState || appState.appState.length === 0) {
|
|
25
|
+
logger("AppState is empty, skipping save", "warn");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const data = JSON.stringify(appState, null, 2);
|
|
30
|
+
fs.writeFileSync(filePath, data, "utf8");
|
|
31
|
+
logger(`AppState saved to ${filePath}`, "info");
|
|
32
|
+
} catch (error) {
|
|
33
|
+
logger(`Error saving AppState: ${error && error.message ? error.message : String(error)}`, "error");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Save immediately if requested
|
|
38
|
+
let immediateSaveTimer = null;
|
|
39
|
+
if (saveOnLogin) {
|
|
40
|
+
// Delay a bit to ensure login is complete
|
|
41
|
+
immediateSaveTimer = setTimeout(() => {
|
|
42
|
+
saveAppState();
|
|
43
|
+
immediateSaveTimer = null;
|
|
44
|
+
}, 2000);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Set up interval
|
|
48
|
+
const intervalId = setInterval(saveAppState, interval);
|
|
49
|
+
logger(`Auto-save AppState enabled: ${filePath} (every ${Math.round(interval / 1000 / 60)} minutes)`, "info");
|
|
50
|
+
|
|
51
|
+
// Store interval ID for cleanup
|
|
52
|
+
if (!ctx._autoSaveInterval) {
|
|
53
|
+
ctx._autoSaveInterval = [];
|
|
54
|
+
}
|
|
55
|
+
ctx._autoSaveInterval.push(intervalId);
|
|
56
|
+
|
|
57
|
+
// Return disable function
|
|
58
|
+
return function disableAutoSaveAppState() {
|
|
59
|
+
// Clear immediate save timer if still pending
|
|
60
|
+
if (immediateSaveTimer) {
|
|
61
|
+
clearTimeout(immediateSaveTimer);
|
|
62
|
+
immediateSaveTimer = null;
|
|
63
|
+
}
|
|
64
|
+
// Clear interval
|
|
65
|
+
clearInterval(intervalId);
|
|
66
|
+
const index = ctx._autoSaveInterval ? ctx._autoSaveInterval.indexOf(intervalId) : -1;
|
|
67
|
+
if (index !== -1) {
|
|
68
|
+
ctx._autoSaveInterval.splice(index, 1);
|
|
69
|
+
}
|
|
70
|
+
logger("Auto-save AppState disabled", "info");
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const log = require("../../../func/logAdapter");
|
|
4
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
|
5
|
+
const { getType } = require("../../utils/format");
|
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
|
7
|
+
return function handleFriendRequest(userID, accept, callback) {
|
|
8
|
+
if (getType(accept) !== "Boolean") {
|
|
9
|
+
throw {
|
|
10
|
+
error: "Please pass a boolean as a second argument."
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let resolveFunc = function() {};
|
|
15
|
+
let rejectFunc = function() {};
|
|
16
|
+
const returnPromise = new Promise(function(resolve, reject) {
|
|
17
|
+
resolveFunc = resolve;
|
|
18
|
+
rejectFunc = reject;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
if (!callback) {
|
|
22
|
+
callback = function(err, friendList) {
|
|
23
|
+
if (err) {
|
|
24
|
+
return rejectFunc(err);
|
|
25
|
+
}
|
|
26
|
+
resolveFunc(friendList);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const form = {
|
|
31
|
+
viewer_id: ctx.userID,
|
|
32
|
+
"frefs[0]": "jwl",
|
|
33
|
+
floc: "friend_center_requests",
|
|
34
|
+
ref: "/reqs.php",
|
|
35
|
+
action: accept ? "confirm" : "reject"
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
defaultFuncs
|
|
39
|
+
.post("https://www.facebook.com/requests/friends/ajax/", ctx.jar, form)
|
|
40
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
|
41
|
+
.then(function(resData) {
|
|
42
|
+
if (resData.payload.err) {
|
|
43
|
+
throw {
|
|
44
|
+
err: resData.payload.err
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return callback();
|
|
49
|
+
})
|
|
50
|
+
.catch(function(err) {
|
|
51
|
+
log.error("handleFriendRequest", err);
|
|
52
|
+
return callback(err);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return returnPromise;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const log = require("../../../func/logAdapter");
|
|
4
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
|
5
|
+
const { getFrom } = require("../../utils/constants");
|
|
6
|
+
const { saveCookies } = require("../../utils/client");
|
|
7
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
|
8
|
+
return function logout(callback) {
|
|
9
|
+
let resolveFunc = function() {};
|
|
10
|
+
let rejectFunc = function() {};
|
|
11
|
+
const returnPromise = new Promise(function(resolve, reject) {
|
|
12
|
+
resolveFunc = resolve;
|
|
13
|
+
rejectFunc = reject;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
if (!callback) {
|
|
17
|
+
callback = function(err, friendList) {
|
|
18
|
+
if (err) {
|
|
19
|
+
return rejectFunc(err);
|
|
20
|
+
}
|
|
21
|
+
resolveFunc(friendList);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const form = {
|
|
26
|
+
pmid: "0"
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
defaultFuncs
|
|
30
|
+
.post(
|
|
31
|
+
"https://www.facebook.com/bluebar/modern_settings_menu/?help_type=364455653583099&show_contextual_help=1",
|
|
32
|
+
ctx.jar,
|
|
33
|
+
form
|
|
34
|
+
)
|
|
35
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
|
36
|
+
.then(function(resData) {
|
|
37
|
+
const elem = resData.jsmods.instances[0][2][0].filter(function(v) {
|
|
38
|
+
return v.value === "logout";
|
|
39
|
+
})[0];
|
|
40
|
+
|
|
41
|
+
const html = resData.jsmods.markup.filter(function(v) {
|
|
42
|
+
return v[0] === elem.markup.__m;
|
|
43
|
+
})[0][1].__html;
|
|
44
|
+
|
|
45
|
+
const form = {
|
|
46
|
+
fb_dtsg: getFrom(html, '"fb_dtsg" value="', '"'),
|
|
47
|
+
ref: getFrom(html, '"ref" value="', '"'),
|
|
48
|
+
h: getFrom(html, '"h" value="', '"')
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return defaultFuncs
|
|
52
|
+
.post("https://www.facebook.com/logout.php", ctx.jar, form)
|
|
53
|
+
.then(saveCookies(ctx.jar));
|
|
54
|
+
})
|
|
55
|
+
.then(function(res) {
|
|
56
|
+
if (!res.headers) {
|
|
57
|
+
throw { error: "An error occurred when logging out." };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return defaultFuncs
|
|
61
|
+
.get(res.headers.location, ctx.jar)
|
|
62
|
+
.then(saveCookies(ctx.jar));
|
|
63
|
+
})
|
|
64
|
+
.then(function() {
|
|
65
|
+
ctx.loggedIn = false;
|
|
66
|
+
log.info("logout", "Logged out successfully.");
|
|
67
|
+
callback();
|
|
68
|
+
})
|
|
69
|
+
.catch(function(err) {
|
|
70
|
+
log.error("logout", err);
|
|
71
|
+
return callback(err);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return returnPromise;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const log = require("../../../func/logAdapter");
|
|
4
|
+
const { getFrom } = require("../../utils/constants");
|
|
5
|
+
const { get } = require("../../utils/request")
|
|
6
|
+
const { getType } = require("../../utils/format");
|
|
7
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
8
|
+
return function refreshFb_dtsg(obj, callback) {
|
|
9
|
+
if (typeof obj === "function") {
|
|
10
|
+
callback = obj;
|
|
11
|
+
obj = {};
|
|
12
|
+
}
|
|
13
|
+
if (!obj) obj = {};
|
|
14
|
+
if (getType(obj) !== "Object") {
|
|
15
|
+
throw new CustomError("The first parameter must be an object or a callback function");
|
|
16
|
+
}
|
|
17
|
+
let resolveFunc, rejectFunc;
|
|
18
|
+
const returnPromise = new Promise((resolve, reject) => {
|
|
19
|
+
resolveFunc = resolve;
|
|
20
|
+
rejectFunc = reject;
|
|
21
|
+
});
|
|
22
|
+
if (!callback) {
|
|
23
|
+
callback = (err, data) => err ? rejectFunc(err) : resolveFunc(data);
|
|
24
|
+
}
|
|
25
|
+
if (Object.keys(obj).length === 0) {
|
|
26
|
+
get("https://www.facebook.com/", ctx.jar, null, ctx.globalOptions, { noRef: true }).then(({ data }) => {
|
|
27
|
+
const fb_dtsg = getFrom(data, '["DTSGInitData",[],{"token":"', '","');
|
|
28
|
+
const jazoest = getFrom(data, "jazoest=", '",');
|
|
29
|
+
if (!fb_dtsg) throw new Error("Could not find fb_dtsg in HTML after requesting Facebook.");
|
|
30
|
+
Object.assign(ctx, { fb_dtsg, jazoest });
|
|
31
|
+
callback(null, {
|
|
32
|
+
data: { fb_dtsg, jazoest },
|
|
33
|
+
message: "Refreshed fb_dtsg and jazoest",
|
|
34
|
+
});
|
|
35
|
+
}).catch(err => {
|
|
36
|
+
console.error("refreshFb_dtsg", err);
|
|
37
|
+
callback(err);
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
Object.assign(ctx, obj);
|
|
41
|
+
callback(null, {
|
|
42
|
+
data: obj,
|
|
43
|
+
message: `Refreshed ${Object.keys(obj).join(", ")}`,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return returnPromise;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const log = require("../../../func/logAdapter");
|
|
4
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
|
5
|
+
const { getType } = require("../../utils/format");
|
|
6
|
+
function formatData(resData) {
|
|
7
|
+
return {
|
|
8
|
+
viewer_feedback_reaction_info:
|
|
9
|
+
resData.feedback_react.feedback.viewer_feedback_reaction_info,
|
|
10
|
+
supported_reactions: resData.feedback_react.feedback.supported_reactions,
|
|
11
|
+
top_reactions: resData.feedback_react.feedback.top_reactions.edges,
|
|
12
|
+
reaction_count: resData.feedback_react.feedback.reaction_count
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
|
17
|
+
return function setPostReaction(postID, type, callback) {
|
|
18
|
+
let resolveFunc = function() {};
|
|
19
|
+
let rejectFunc = function() {};
|
|
20
|
+
const returnPromise = new Promise(function(resolve, reject) {
|
|
21
|
+
resolveFunc = resolve;
|
|
22
|
+
rejectFunc = reject;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (!callback) {
|
|
26
|
+
if (
|
|
27
|
+
getType(type) === "Function" ||
|
|
28
|
+
getType(type) === "AsyncFunction"
|
|
29
|
+
) {
|
|
30
|
+
callback = type;
|
|
31
|
+
type = 0;
|
|
32
|
+
} else {
|
|
33
|
+
callback = function(err, data) {
|
|
34
|
+
if (err) {
|
|
35
|
+
return rejectFunc(err);
|
|
36
|
+
}
|
|
37
|
+
resolveFunc(data);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const map = {
|
|
43
|
+
unlike: 0,
|
|
44
|
+
like: 1,
|
|
45
|
+
heart: 2,
|
|
46
|
+
love: 16,
|
|
47
|
+
haha: 4,
|
|
48
|
+
wow: 3,
|
|
49
|
+
sad: 7,
|
|
50
|
+
angry: 8
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
if (getType(type) !== "Number" && getType(type) === "String") {
|
|
54
|
+
type = map[type.toLowerCase()];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (getType(type) !== "Number" && getType(type) !== "String") {
|
|
58
|
+
throw {
|
|
59
|
+
error: "setPostReaction: Invalid reaction type"
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (type != 0 && !type) {
|
|
64
|
+
throw {
|
|
65
|
+
error: "setPostReaction: Invalid reaction type"
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const form = {
|
|
70
|
+
av: ctx.userID,
|
|
71
|
+
fb_api_caller_class: "RelayModern",
|
|
72
|
+
fb_api_req_friendly_name: "CometUFIFeedbackReactMutation",
|
|
73
|
+
doc_id: "4769042373179384",
|
|
74
|
+
variables: JSON.stringify({
|
|
75
|
+
input: {
|
|
76
|
+
actor_id: ctx.userID,
|
|
77
|
+
feedback_id: Buffer.from("feedback:" + postID).toString("base64"),
|
|
78
|
+
feedback_reaction: type,
|
|
79
|
+
feedback_source: "OBJECT",
|
|
80
|
+
is_tracking_encrypted: true,
|
|
81
|
+
tracking: [],
|
|
82
|
+
session_id: "f7dd50dd-db6e-4598-8cd9-561d5002b423",
|
|
83
|
+
client_mutation_id: Math.round(Math.random() * 19).toString()
|
|
84
|
+
},
|
|
85
|
+
useDefaultActor: false,
|
|
86
|
+
scale: 3
|
|
87
|
+
})
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
defaultFuncs
|
|
91
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
92
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
|
93
|
+
.then(function(resData) {
|
|
94
|
+
if (resData.errors) {
|
|
95
|
+
throw resData;
|
|
96
|
+
}
|
|
97
|
+
return callback(null, formatData(resData.data));
|
|
98
|
+
})
|
|
99
|
+
.catch(function(err) {
|
|
100
|
+
log.error("setPostReaction", err);
|
|
101
|
+
return callback(err);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
return returnPromise;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const log = require("../../../func/logAdapter");
|
|
4
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
|
5
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
|
6
|
+
return function unfriend(userID, callback) {
|
|
7
|
+
let resolveFunc = function() {};
|
|
8
|
+
let rejectFunc = function() {};
|
|
9
|
+
const returnPromise = new Promise(function(resolve, reject) {
|
|
10
|
+
resolveFunc = resolve;
|
|
11
|
+
rejectFunc = reject;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
if (!callback) {
|
|
15
|
+
callback = function(err, friendList) {
|
|
16
|
+
if (err) {
|
|
17
|
+
return rejectFunc(err);
|
|
18
|
+
}
|
|
19
|
+
resolveFunc(friendList);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const form = {
|
|
24
|
+
uid: userID,
|
|
25
|
+
unref: "bd_friends_tab",
|
|
26
|
+
floc: "friends_tab",
|
|
27
|
+
"nctr[_mod]":
|
|
28
|
+
"pagelet_timeline_app_collection_" +
|
|
29
|
+
ctx.userID +
|
|
30
|
+
":2356318349:2"
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
defaultFuncs
|
|
34
|
+
.post(
|
|
35
|
+
"https://www.facebook.com/ajax/profile/removefriendconfirm.php",
|
|
36
|
+
ctx.jar,
|
|
37
|
+
form
|
|
38
|
+
)
|
|
39
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
|
40
|
+
.then(function(resData) {
|
|
41
|
+
if (resData.error) {
|
|
42
|
+
throw resData;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return callback(null, true);
|
|
46
|
+
})
|
|
47
|
+
.catch(function(err) {
|
|
48
|
+
log.error("unfriend", err);
|
|
49
|
+
return callback(err);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return returnPromise;
|
|
53
|
+
};
|
|
54
|
+
};
|