fca-riyad 37.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/CHANGELOG.md +325 -0
- package/DOCS.md +2712 -0
- package/README.md +410 -0
- package/func/checkUpdate.js +7 -0
- package/func/logAdapter.js +33 -0
- package/func/logger.js +48 -0
- package/index.d.ts +751 -0
- package/index.js +22 -0
- package/module/config.js +40 -0
- package/module/login.js +133 -0
- package/module/loginHelper.js +1359 -0
- package/module/options.js +44 -0
- package/package.json +95 -0
- package/src/api/action/addExternalModule.js +25 -0
- package/src/api/action/changeAvatar.js +137 -0
- package/src/api/action/changeBio.js +75 -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 +130 -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 +492 -0
- package/src/api/socket/OldMessage.js +186 -0
- package/src/api/socket/core/connectMqtt.js +269 -0
- package/src/api/socket/core/emitAuth.js +103 -0
- package/src/api/socket/core/getSeqID.js +321 -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/proto/proto-writer.ts +76 -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/e2ee/vendor/proto/proto-writer.ts +76 -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/proto/proto-writer.ts +76 -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/e2ee/vendor/proto/proto-writer.ts +76 -0
- package/src/api/socket/listenE2EE.js +75 -0
- package/src/api/socket/listenMqtt.js +388 -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 +134 -0
- package/src/app/MessengerBot.js +209 -0
- package/src/app/MessengerContext.js +32 -0
- package/src/app/createFcaClient.js +136 -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/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 +115 -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/nexca-logger.js +144 -0
- package/src/utils/nexca-utils.js +686 -0
- package/src/utils/request/client.js +26 -0
- package/src/utils/request/config.js +23 -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 +21 -0
- package/src/utils/request/retry.js +77 -0
- package/src/utils/request/sanitize.js +49 -0
- package/src/utils/versionCheck.js +47 -0
- package/src/vendor/fca-unofficial/.github/workflows/nodejs.yml +26 -0
- package/src/vendor/fca-unofficial/.github/workflows/npmpublish.yml +30 -0
- package/src/vendor/fca-unofficial/.travis.yml +6 -0
- package/src/vendor/fca-unofficial/DOCS.md +1731 -0
- package/src/vendor/fca-unofficial/LICENSE-MIT +21 -0
- package/src/vendor/fca-unofficial/README.md +225 -0
- package/src/vendor/fca-unofficial/index.js +619 -0
- package/src/vendor/fca-unofficial/package.json +76 -0
- package/src/vendor/fca-unofficial/src/addExternalModule.js +19 -0
- package/src/vendor/fca-unofficial/src/addUserToGroup.js +113 -0
- package/src/vendor/fca-unofficial/src/changeAdminStatus.js +79 -0
- package/src/vendor/fca-unofficial/src/changeArchivedStatus.js +55 -0
- package/src/vendor/fca-unofficial/src/changeBio.js +77 -0
- package/src/vendor/fca-unofficial/src/changeBlockedStatus.js +47 -0
- package/src/vendor/fca-unofficial/src/changeGroupImage.js +129 -0
- package/src/vendor/fca-unofficial/src/changeNickname.js +59 -0
- package/src/vendor/fca-unofficial/src/changeThreadColor.js +71 -0
- package/src/vendor/fca-unofficial/src/changeThreadEmoji.js +55 -0
- package/src/vendor/fca-unofficial/src/createNewGroup.js +86 -0
- package/src/vendor/fca-unofficial/src/createPoll.js +71 -0
- package/src/vendor/fca-unofficial/src/deleteMessage.js +56 -0
- package/src/vendor/fca-unofficial/src/deleteThread.js +56 -0
- package/src/vendor/fca-unofficial/src/forwardAttachment.js +60 -0
- package/src/vendor/fca-unofficial/src/getCurrentUserID.js +7 -0
- package/src/vendor/fca-unofficial/src/getEmojiUrl.js +29 -0
- package/src/vendor/fca-unofficial/src/getFriendsList.js +84 -0
- package/src/vendor/fca-unofficial/src/getThreadHistory.js +645 -0
- package/src/vendor/fca-unofficial/src/getThreadHistoryDeprecated.js +93 -0
- package/src/vendor/fca-unofficial/src/getThreadInfo.js +201 -0
- package/src/vendor/fca-unofficial/src/getThreadInfoDeprecated.js +80 -0
- package/src/vendor/fca-unofficial/src/getThreadList.js +238 -0
- package/src/vendor/fca-unofficial/src/getThreadListDeprecated.js +75 -0
- package/src/vendor/fca-unofficial/src/getThreadPictures.js +79 -0
- package/src/vendor/fca-unofficial/src/getUserID.js +66 -0
- package/src/vendor/fca-unofficial/src/getUserInfo.js +72 -0
- package/src/vendor/fca-unofficial/src/handleFriendRequest.js +61 -0
- package/src/vendor/fca-unofficial/src/handleMessageRequest.js +65 -0
- package/src/vendor/fca-unofficial/src/httpGet.js +52 -0
- package/src/vendor/fca-unofficial/src/httpPost.js +52 -0
- package/src/vendor/fca-unofficial/src/listenMqtt.js +788 -0
- package/src/vendor/fca-unofficial/src/logout.js +75 -0
- package/src/vendor/fca-unofficial/src/markAsDelivered.js +58 -0
- package/src/vendor/fca-unofficial/src/markAsRead.js +80 -0
- package/src/vendor/fca-unofficial/src/markAsReadAll.js +50 -0
- package/src/vendor/fca-unofficial/src/markAsSeen.js +59 -0
- package/src/vendor/fca-unofficial/src/muteThread.js +52 -0
- package/src/vendor/fca-unofficial/src/removeUserFromGroup.js +79 -0
- package/src/vendor/fca-unofficial/src/resolvePhotoUrl.js +45 -0
- package/src/vendor/fca-unofficial/src/searchForThread.js +53 -0
- package/src/vendor/fca-unofficial/src/sendMessage.js +459 -0
- package/src/vendor/fca-unofficial/src/sendTypingIndicator.js +103 -0
- package/src/vendor/fca-unofficial/src/setMessageReaction.js +117 -0
- package/src/vendor/fca-unofficial/src/setPostReaction.js +76 -0
- package/src/vendor/fca-unofficial/src/setTitle.js +86 -0
- package/src/vendor/fca-unofficial/src/threadColors.js +57 -0
- package/src/vendor/fca-unofficial/src/unfriend.js +52 -0
- package/src/vendor/fca-unofficial/src/unsendMessage.js +49 -0
- package/src/vendor/fca-unofficial/test/data/shareAttach.js +146 -0
- package/src/vendor/fca-unofficial/test/data/something.mov +0 -0
- package/src/vendor/fca-unofficial/test/data/test.png +0 -0
- package/src/vendor/fca-unofficial/test/data/test.txt +7 -0
- package/src/vendor/fca-unofficial/test/example-config.json +18 -0
- package/src/vendor/fca-unofficial/test/test-page.js +140 -0
- package/src/vendor/fca-unofficial/test/test.js +385 -0
- package/src/vendor/fca-unofficial/utils.js +1358 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { getType } = require("./format");
|
|
3
|
+
const stream = require("stream");
|
|
4
|
+
function getFrom(html, a, b) {
|
|
5
|
+
const i = html.indexOf(a);
|
|
6
|
+
if (i < 0) return;
|
|
7
|
+
const start = i + a.length;
|
|
8
|
+
const j = html.indexOf(b, start);
|
|
9
|
+
return j < 0 ? undefined : html.slice(start, j);
|
|
10
|
+
}
|
|
11
|
+
function isReadableStream(obj) {
|
|
12
|
+
return (
|
|
13
|
+
obj instanceof stream.Stream &&
|
|
14
|
+
(getType(obj._read) === "Function" ||
|
|
15
|
+
getType(obj._read) === "AsyncFunction") &&
|
|
16
|
+
getType(obj._readableState) === "Object"
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = {
|
|
21
|
+
getFrom,
|
|
22
|
+
isReadableStream
|
|
23
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Cookie helpers extracted from client.js
|
|
4
|
+
|
|
5
|
+
function saveCookies(jar) {
|
|
6
|
+
return res => {
|
|
7
|
+
try {
|
|
8
|
+
const setCookie = res?.headers?.["set-cookie"];
|
|
9
|
+
if (Array.isArray(setCookie) && setCookie.length) {
|
|
10
|
+
const url =
|
|
11
|
+
res?.request?.res?.responseUrl ||
|
|
12
|
+
(res?.config?.baseURL
|
|
13
|
+
? new URL(res.config.url || "/", res.config.baseURL).toString()
|
|
14
|
+
: res?.config?.url || "https://www.facebook.com");
|
|
15
|
+
for (const c of setCookie) {
|
|
16
|
+
try {
|
|
17
|
+
jar.setCookieSync(c, url);
|
|
18
|
+
} catch {
|
|
19
|
+
// ignore per-cookie errors
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
} catch {
|
|
24
|
+
// ignore unexpected cookie parsing errors
|
|
25
|
+
}
|
|
26
|
+
return res;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getAppState(jar) {
|
|
31
|
+
if (!jar || typeof jar.getCookiesSync !== "function") return [];
|
|
32
|
+
const urls = ["https://www.facebook.com"];
|
|
33
|
+
const all = urls.flatMap(u => {
|
|
34
|
+
try {
|
|
35
|
+
return jar.getCookiesSync(u) || [];
|
|
36
|
+
} catch {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const seen = new Set();
|
|
41
|
+
const out = [];
|
|
42
|
+
for (const c of all) {
|
|
43
|
+
const key = c.key || c.name;
|
|
44
|
+
if (!key) continue;
|
|
45
|
+
const id = key + "|" + (c.domain || "") + "|" + (c.path || "/");
|
|
46
|
+
if (seen.has(id)) continue;
|
|
47
|
+
seen.add(id);
|
|
48
|
+
out.push({
|
|
49
|
+
key,
|
|
50
|
+
value: c.value,
|
|
51
|
+
domain: c.domain || ".facebook.com",
|
|
52
|
+
path: c.path || "/",
|
|
53
|
+
hostOnly: !!c.hostOnly,
|
|
54
|
+
creation: c.creation || new Date(),
|
|
55
|
+
lastAccessed: c.lastAccessed || new Date(),
|
|
56
|
+
secure: !!c.secure,
|
|
57
|
+
httpOnly: !!c.httpOnly,
|
|
58
|
+
expires: c.expires && c.expires !== "Infinity" ? c.expires : "Infinity"
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
module.exports = {
|
|
65
|
+
saveCookies,
|
|
66
|
+
getAppState
|
|
67
|
+
};
|
|
68
|
+
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var url = require("url");
|
|
4
|
+
const querystring = require("querystring");
|
|
5
|
+
|
|
6
|
+
function _formatAttachment(attachment1, attachment2) {
|
|
7
|
+
attachment2 = attachment2 || { id: "", image_data: {} };
|
|
8
|
+
attachment1 = attachment1.mercury ? attachment1.mercury : attachment1;
|
|
9
|
+
var blob = attachment1.blob_attachment;
|
|
10
|
+
var type =
|
|
11
|
+
blob && blob.__typename ? blob.__typename : attachment1.attach_type;
|
|
12
|
+
if (!type && attachment1.sticker_attachment) {
|
|
13
|
+
type = "StickerAttachment";
|
|
14
|
+
blob = attachment1.sticker_attachment;
|
|
15
|
+
} else if (!type && attachment1.extensible_attachment) {
|
|
16
|
+
if (
|
|
17
|
+
attachment1.extensible_attachment.story_attachment &&
|
|
18
|
+
attachment1.extensible_attachment.story_attachment.target &&
|
|
19
|
+
attachment1.extensible_attachment.story_attachment.target.__typename &&
|
|
20
|
+
attachment1.extensible_attachment.story_attachment.target.__typename ===
|
|
21
|
+
"MessageLocation"
|
|
22
|
+
)
|
|
23
|
+
type = "MessageLocation";
|
|
24
|
+
else type = "ExtensibleAttachment";
|
|
25
|
+
|
|
26
|
+
blob = attachment1.extensible_attachment;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (blob && blob.real_metadata) {
|
|
30
|
+
const realMetadata = blob.real_metadata;
|
|
31
|
+
if (realMetadata.Src) {
|
|
32
|
+
attachment2.src = realMetadata.Src;
|
|
33
|
+
}
|
|
34
|
+
if (realMetadata.ThumbnailSrc) {
|
|
35
|
+
attachment2.thumbnailSrc = realMetadata.ThumbnailSrc;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
switch (type) {
|
|
40
|
+
case "sticker":
|
|
41
|
+
return {
|
|
42
|
+
type: "sticker",
|
|
43
|
+
ID: attachment1.metadata.stickerID.toString(),
|
|
44
|
+
url: attachment1.url,
|
|
45
|
+
packID: attachment1.metadata.packID.toString(),
|
|
46
|
+
spriteUrl: attachment1.metadata.spriteURI,
|
|
47
|
+
spriteUrl2x: attachment1.metadata.spriteURI2x,
|
|
48
|
+
width: attachment1.metadata.width,
|
|
49
|
+
height: attachment1.metadata.height,
|
|
50
|
+
caption: attachment2.caption,
|
|
51
|
+
description: attachment2.description,
|
|
52
|
+
frameCount: attachment1.metadata.frameCount,
|
|
53
|
+
frameRate: attachment1.metadata.frameRate,
|
|
54
|
+
framesPerRow: attachment1.metadata.framesPerRow,
|
|
55
|
+
framesPerCol: attachment1.metadata.framesPerCol,
|
|
56
|
+
stickerID: attachment1.metadata.stickerID.toString(),
|
|
57
|
+
spriteURI: attachment1.metadata.spriteURI,
|
|
58
|
+
spriteURI2x: attachment1.metadata.spriteURI2x,
|
|
59
|
+
};
|
|
60
|
+
case "file":
|
|
61
|
+
return {
|
|
62
|
+
type: "file",
|
|
63
|
+
filename: attachment1.name,
|
|
64
|
+
ID: attachment2.id.toString(),
|
|
65
|
+
url: attachment1.url,
|
|
66
|
+
isMalicious: attachment2.is_malicious,
|
|
67
|
+
contentType: attachment2.mime_type,
|
|
68
|
+
name: attachment1.name,
|
|
69
|
+
mimeType: attachment2.mime_type,
|
|
70
|
+
fileSize: attachment2.file_size,
|
|
71
|
+
};
|
|
72
|
+
case "photo":
|
|
73
|
+
return {
|
|
74
|
+
type: "photo",
|
|
75
|
+
ID: attachment1.metadata.fbid.toString(),
|
|
76
|
+
filename: attachment1.fileName,
|
|
77
|
+
thumbnailUrl: attachment1.thumbnail_url,
|
|
78
|
+
previewUrl: attachment1.preview_url,
|
|
79
|
+
previewWidth: attachment1.preview_width,
|
|
80
|
+
previewHeight: attachment1.preview_height,
|
|
81
|
+
largePreviewUrl: attachment1.large_preview_url,
|
|
82
|
+
largePreviewWidth: attachment1.large_preview_width,
|
|
83
|
+
largePreviewHeight: attachment1.large_preview_height,
|
|
84
|
+
url: attachment1.metadata.url,
|
|
85
|
+
width: attachment1.metadata.dimensions.split(",")[0],
|
|
86
|
+
height: attachment1.metadata.dimensions.split(",")[1],
|
|
87
|
+
name: attachment1.fileName,
|
|
88
|
+
};
|
|
89
|
+
case "animated_image":
|
|
90
|
+
return {
|
|
91
|
+
type: "animated_image",
|
|
92
|
+
ID: attachment2.id.toString(),
|
|
93
|
+
filename: attachment2.filename,
|
|
94
|
+
previewUrl: attachment1.preview_url,
|
|
95
|
+
previewWidth: attachment1.preview_width,
|
|
96
|
+
previewHeight: attachment1.preview_height,
|
|
97
|
+
url: attachment2.image_data.url,
|
|
98
|
+
width: attachment2.image_data.width,
|
|
99
|
+
height: attachment2.image_data.height,
|
|
100
|
+
name: attachment1.name,
|
|
101
|
+
facebookUrl: attachment1.url,
|
|
102
|
+
thumbnailUrl: attachment1.thumbnail_url,
|
|
103
|
+
mimeType: attachment2.mime_type,
|
|
104
|
+
rawGifImage: attachment2.image_data.raw_gif_image,
|
|
105
|
+
rawWebpImage: attachment2.image_data.raw_webp_image,
|
|
106
|
+
animatedGifUrl: attachment2.image_data.animated_gif_url,
|
|
107
|
+
animatedGifPreviewUrl: attachment2.image_data.animated_gif_preview_url,
|
|
108
|
+
animatedWebpUrl: attachment2.image_data.animated_webp_url,
|
|
109
|
+
animatedWebpPreviewUrl:
|
|
110
|
+
attachment2.image_data.animated_webp_preview_url,
|
|
111
|
+
};
|
|
112
|
+
case "share":
|
|
113
|
+
return {
|
|
114
|
+
type: "share",
|
|
115
|
+
ID: attachment1.share.share_id.toString(),
|
|
116
|
+
url: attachment2.href,
|
|
117
|
+
title: attachment1.share.title,
|
|
118
|
+
description: attachment1.share.description,
|
|
119
|
+
source: attachment1.share.source,
|
|
120
|
+
image: attachment1.share.media.image,
|
|
121
|
+
width: attachment1.share.media.image_size.width,
|
|
122
|
+
height: attachment1.share.media.image_size.height,
|
|
123
|
+
playable: attachment1.share.media.playable,
|
|
124
|
+
duration: attachment1.share.media.duration,
|
|
125
|
+
subattachments: attachment1.share.subattachments,
|
|
126
|
+
properties: {},
|
|
127
|
+
animatedImageSize: attachment1.share.media.animated_image_size,
|
|
128
|
+
facebookUrl: attachment1.share.uri,
|
|
129
|
+
target: attachment1.share.target,
|
|
130
|
+
styleList: attachment1.share.style_list,
|
|
131
|
+
};
|
|
132
|
+
case "video":
|
|
133
|
+
return {
|
|
134
|
+
type: "video",
|
|
135
|
+
ID: attachment1.metadata.fbid.toString(),
|
|
136
|
+
filename: attachment1.name,
|
|
137
|
+
previewUrl: attachment1.preview_url,
|
|
138
|
+
previewWidth: attachment1.preview_width,
|
|
139
|
+
previewHeight: attachment1.preview_height,
|
|
140
|
+
url: attachment1.url,
|
|
141
|
+
width: attachment1.metadata.dimensions.width,
|
|
142
|
+
height: attachment1.metadata.dimensions.height,
|
|
143
|
+
duration: attachment1.metadata.duration,
|
|
144
|
+
videoType: "unknown",
|
|
145
|
+
thumbnailUrl: attachment1.thumbnail_url,
|
|
146
|
+
};
|
|
147
|
+
case "error":
|
|
148
|
+
return {
|
|
149
|
+
type: "error",
|
|
150
|
+
attachment1: attachment1,
|
|
151
|
+
attachment2: attachment2,
|
|
152
|
+
};
|
|
153
|
+
case "MessageImage":
|
|
154
|
+
return {
|
|
155
|
+
type: "photo",
|
|
156
|
+
ID: blob.legacy_attachment_id,
|
|
157
|
+
filename: blob.filename,
|
|
158
|
+
thumbnailUrl: blob.thumbnail.uri,
|
|
159
|
+
previewUrl: blob.preview.uri,
|
|
160
|
+
previewWidth: blob.preview.width,
|
|
161
|
+
previewHeight: blob.preview.height,
|
|
162
|
+
largePreviewUrl: blob.large_preview.uri,
|
|
163
|
+
largePreviewWidth: blob.large_preview.width,
|
|
164
|
+
largePreviewHeight: blob.large_preview.height,
|
|
165
|
+
url: blob.large_preview.uri,
|
|
166
|
+
width: blob.original_dimensions.x,
|
|
167
|
+
height: blob.original_dimensions.y,
|
|
168
|
+
name: blob.filename,
|
|
169
|
+
};
|
|
170
|
+
case "MessageAnimatedImage":
|
|
171
|
+
return {
|
|
172
|
+
type: "animated_image",
|
|
173
|
+
ID: blob.legacy_attachment_id,
|
|
174
|
+
filename: blob.filename,
|
|
175
|
+
previewUrl: blob.preview_image.uri,
|
|
176
|
+
previewWidth: blob.preview_image.width,
|
|
177
|
+
previewHeight: blob.preview_image.height,
|
|
178
|
+
url: blob.animated_image.uri,
|
|
179
|
+
width: blob.animated_image.width,
|
|
180
|
+
height: blob.animated_image.height,
|
|
181
|
+
thumbnailUrl: blob.preview_image.uri,
|
|
182
|
+
name: blob.filename,
|
|
183
|
+
facebookUrl: blob.animated_image.uri,
|
|
184
|
+
rawGifImage: blob.animated_image.uri,
|
|
185
|
+
animatedGifUrl: blob.animated_image.uri,
|
|
186
|
+
animatedGifPreviewUrl: blob.preview_image.uri,
|
|
187
|
+
animatedWebpUrl: blob.animated_image.uri,
|
|
188
|
+
animatedWebpPreviewUrl: blob.preview_image.uri,
|
|
189
|
+
};
|
|
190
|
+
case "MessageVideo":
|
|
191
|
+
return {
|
|
192
|
+
type: "video",
|
|
193
|
+
filename: blob.filename,
|
|
194
|
+
ID: blob.legacy_attachment_id,
|
|
195
|
+
previewUrl: blob.large_image.uri,
|
|
196
|
+
previewWidth: blob.large_image.width,
|
|
197
|
+
previewHeight: blob.large_image.height,
|
|
198
|
+
url: blob.playable_url,
|
|
199
|
+
width: blob.original_dimensions.x,
|
|
200
|
+
height: blob.original_dimensions.y,
|
|
201
|
+
duration: blob.playable_duration_in_ms,
|
|
202
|
+
videoType: blob.video_type.toLowerCase(),
|
|
203
|
+
thumbnailUrl: blob.large_image.uri,
|
|
204
|
+
};
|
|
205
|
+
case "MessageAudio":
|
|
206
|
+
return {
|
|
207
|
+
type: "audio",
|
|
208
|
+
filename: blob.filename,
|
|
209
|
+
ID: blob.url_shimhash,
|
|
210
|
+
audioType: blob.audio_type,
|
|
211
|
+
duration: blob.playable_duration_in_ms,
|
|
212
|
+
url: blob.playable_url,
|
|
213
|
+
isVoiceMail: blob.is_voicemail,
|
|
214
|
+
};
|
|
215
|
+
case "StickerAttachment":
|
|
216
|
+
return {
|
|
217
|
+
type: "sticker",
|
|
218
|
+
ID: blob.id,
|
|
219
|
+
url: blob.url,
|
|
220
|
+
packID: blob.pack ? blob.pack.id : null,
|
|
221
|
+
spriteUrl: blob.sprite_image,
|
|
222
|
+
spriteUrl2x: blob.sprite_image_2x,
|
|
223
|
+
width: blob.width,
|
|
224
|
+
height: blob.height,
|
|
225
|
+
caption: blob.label,
|
|
226
|
+
description: blob.label,
|
|
227
|
+
frameCount: blob.frame_count,
|
|
228
|
+
frameRate: blob.frame_rate,
|
|
229
|
+
framesPerRow: blob.frames_per_row,
|
|
230
|
+
framesPerCol: blob.frames_per_column,
|
|
231
|
+
stickerID: blob.id,
|
|
232
|
+
spriteURI: blob.sprite_image,
|
|
233
|
+
spriteURI2x: blob.sprite_image_2x,
|
|
234
|
+
};
|
|
235
|
+
case "MessageLocation": {
|
|
236
|
+
var urlAttach = blob.story_attachment.url;
|
|
237
|
+
var mediaAttach = blob.story_attachment.media;
|
|
238
|
+
var u = querystring.parse(url.parse(urlAttach).query).u;
|
|
239
|
+
var where1 = querystring.parse(url.parse(u).query).where1;
|
|
240
|
+
var address = where1.split(", ");
|
|
241
|
+
var latitude;
|
|
242
|
+
var longitude;
|
|
243
|
+
try {
|
|
244
|
+
latitude = Number.parseFloat(address[0]);
|
|
245
|
+
longitude = Number.parseFloat(address[1]);
|
|
246
|
+
} catch (err) {}
|
|
247
|
+
var imageUrl;
|
|
248
|
+
var width;
|
|
249
|
+
var height;
|
|
250
|
+
if (mediaAttach && mediaAttach.image) {
|
|
251
|
+
imageUrl = mediaAttach.image.uri;
|
|
252
|
+
width = mediaAttach.image.width;
|
|
253
|
+
height = mediaAttach.image.height;
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
type: "location",
|
|
257
|
+
ID: blob.legacy_attachment_id,
|
|
258
|
+
latitude: latitude,
|
|
259
|
+
longitude: longitude,
|
|
260
|
+
image: imageUrl,
|
|
261
|
+
width: width,
|
|
262
|
+
height: height,
|
|
263
|
+
url: u || urlAttach,
|
|
264
|
+
address: where1,
|
|
265
|
+
facebookUrl: blob.story_attachment.url,
|
|
266
|
+
target: blob.story_attachment.target,
|
|
267
|
+
styleList: blob.story_attachment.style_list,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
case "ExtensibleAttachment":
|
|
271
|
+
return {
|
|
272
|
+
type: "share",
|
|
273
|
+
ID: blob.legacy_attachment_id,
|
|
274
|
+
url: blob.story_attachment.url,
|
|
275
|
+
title: blob.story_attachment.title_with_entities.text,
|
|
276
|
+
description:
|
|
277
|
+
blob.story_attachment.description &&
|
|
278
|
+
blob.story_attachment.description.text,
|
|
279
|
+
source: blob.story_attachment.source
|
|
280
|
+
? blob.story_attachment.source.text
|
|
281
|
+
: null,
|
|
282
|
+
image:
|
|
283
|
+
blob.story_attachment.media &&
|
|
284
|
+
blob.story_attachment.media.image &&
|
|
285
|
+
blob.story_attachment.media.image.uri,
|
|
286
|
+
width:
|
|
287
|
+
blob.story_attachment.media &&
|
|
288
|
+
blob.story_attachment.media.image &&
|
|
289
|
+
blob.story_attachment.media.image.width,
|
|
290
|
+
height:
|
|
291
|
+
blob.story_attachment.media &&
|
|
292
|
+
blob.story_attachment.media.image &&
|
|
293
|
+
blob.story_attachment.media.image.height,
|
|
294
|
+
playable:
|
|
295
|
+
blob.story_attachment.media &&
|
|
296
|
+
blob.story_attachment.media.is_playable,
|
|
297
|
+
duration:
|
|
298
|
+
blob.story_attachment.media &&
|
|
299
|
+
blob.story_attachment.media.playable_duration_in_ms,
|
|
300
|
+
playableUrl:
|
|
301
|
+
blob.story_attachment.media == null
|
|
302
|
+
? null
|
|
303
|
+
: blob.story_attachment.media.playable_url,
|
|
304
|
+
subattachments: blob.story_attachment.subattachments,
|
|
305
|
+
properties: blob.story_attachment.properties.reduce(function (obj, cur) {
|
|
306
|
+
obj[cur.key] = cur.value.text;
|
|
307
|
+
return obj;
|
|
308
|
+
}, {}),
|
|
309
|
+
facebookUrl: blob.story_attachment.url,
|
|
310
|
+
target: blob.story_attachment.target,
|
|
311
|
+
styleList: blob.story_attachment.style_list,
|
|
312
|
+
};
|
|
313
|
+
case "MessageFile":
|
|
314
|
+
return {
|
|
315
|
+
type: "file",
|
|
316
|
+
filename: blob.filename,
|
|
317
|
+
ID: blob.message_file_fbid,
|
|
318
|
+
url: blob.url,
|
|
319
|
+
isMalicious: blob.is_malicious,
|
|
320
|
+
contentType: blob.content_type,
|
|
321
|
+
name: blob.filename,
|
|
322
|
+
mimeType: "",
|
|
323
|
+
fileSize: -1,
|
|
324
|
+
};
|
|
325
|
+
default:
|
|
326
|
+
throw new Error(
|
|
327
|
+
"unrecognized attach_file of type " +
|
|
328
|
+
type +
|
|
329
|
+
"`" +
|
|
330
|
+
JSON.stringify(attachment1, null, 4) +
|
|
331
|
+
" attachment2: " +
|
|
332
|
+
JSON.stringify(attachment2, null, 4) +
|
|
333
|
+
"`",
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function formatAttachment(attachments, attachmentIds, attachmentMap, shareMap) {
|
|
339
|
+
attachmentMap = shareMap || attachmentMap;
|
|
340
|
+
return attachments
|
|
341
|
+
? attachments.map(function (att, idx) {
|
|
342
|
+
if (
|
|
343
|
+
!attachmentMap ||
|
|
344
|
+
!attachmentIds ||
|
|
345
|
+
!attachmentMap[attachmentIds[idx]]
|
|
346
|
+
) {
|
|
347
|
+
return _formatAttachment(att);
|
|
348
|
+
}
|
|
349
|
+
return _formatAttachment(att, attachmentMap[attachmentIds[idx]]);
|
|
350
|
+
})
|
|
351
|
+
: [];
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
module.exports = {
|
|
355
|
+
_formatAttachment,
|
|
356
|
+
formatAttachment,
|
|
357
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var NUM_TO_MONTH = [
|
|
4
|
+
"Jan",
|
|
5
|
+
"Feb",
|
|
6
|
+
"Mar",
|
|
7
|
+
"Apr",
|
|
8
|
+
"May",
|
|
9
|
+
"Jun",
|
|
10
|
+
"Jul",
|
|
11
|
+
"Aug",
|
|
12
|
+
"Sep",
|
|
13
|
+
"Oct",
|
|
14
|
+
"Nov",
|
|
15
|
+
"Dec",
|
|
16
|
+
];
|
|
17
|
+
var NUM_TO_DAY = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
18
|
+
|
|
19
|
+
function formatDate(date) {
|
|
20
|
+
var d = date.getUTCDate();
|
|
21
|
+
d = d >= 10 ? d : "0" + d;
|
|
22
|
+
var h = date.getUTCHours();
|
|
23
|
+
h = h >= 10 ? h : "0" + h;
|
|
24
|
+
var m = date.getUTCMinutes();
|
|
25
|
+
m = m >= 10 ? m : "0" + m;
|
|
26
|
+
var s = date.getUTCSeconds();
|
|
27
|
+
s = s >= 10 ? s : "0" + s;
|
|
28
|
+
return (
|
|
29
|
+
NUM_TO_DAY[date.getUTCDay()] +
|
|
30
|
+
", " +
|
|
31
|
+
d +
|
|
32
|
+
" " +
|
|
33
|
+
NUM_TO_MONTH[date.getUTCMonth()] +
|
|
34
|
+
" " +
|
|
35
|
+
date.getUTCFullYear() +
|
|
36
|
+
" " +
|
|
37
|
+
h +
|
|
38
|
+
":" +
|
|
39
|
+
m +
|
|
40
|
+
":" +
|
|
41
|
+
s +
|
|
42
|
+
" GMT"
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = {
|
|
47
|
+
NUM_TO_MONTH,
|
|
48
|
+
NUM_TO_DAY,
|
|
49
|
+
formatDate,
|
|
50
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function decodeClientPayload(payload) {
|
|
4
|
+
function Utf8ArrayToStr(array) {
|
|
5
|
+
var out, i, len, c;
|
|
6
|
+
var char2, char3;
|
|
7
|
+
out = "";
|
|
8
|
+
len = array.length;
|
|
9
|
+
i = 0;
|
|
10
|
+
while (i < len) {
|
|
11
|
+
c = array[i++];
|
|
12
|
+
switch (c >> 4) {
|
|
13
|
+
case 0:
|
|
14
|
+
case 1:
|
|
15
|
+
case 2:
|
|
16
|
+
case 3:
|
|
17
|
+
case 4:
|
|
18
|
+
case 5:
|
|
19
|
+
case 6:
|
|
20
|
+
case 7:
|
|
21
|
+
out += String.fromCharCode(c);
|
|
22
|
+
break;
|
|
23
|
+
case 12:
|
|
24
|
+
case 13:
|
|
25
|
+
char2 = array[i++];
|
|
26
|
+
out += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f));
|
|
27
|
+
break;
|
|
28
|
+
case 14:
|
|
29
|
+
char2 = array[i++];
|
|
30
|
+
char3 = array[i++];
|
|
31
|
+
out += String.fromCharCode(
|
|
32
|
+
((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0),
|
|
33
|
+
);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
return JSON.parse(Utf8ArrayToStr(payload));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = {
|
|
43
|
+
decodeClientPayload,
|
|
44
|
+
};
|