hridoy-ultimate 8.0.2 → 9.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 +68 -40
- package/LICENSE +23 -0
- package/MERGE_REPORT.md +54 -0
- package/README.md +158 -113
- package/THIRD_PARTY_NOTICES.md +36 -0
- package/docs/TEST_RESULTS.md +68 -0
- package/docs/UPSTREAM_API_DOCS.md +2712 -0
- package/func/checkUpdate.js +6 -0
- package/func/logAdapter.js +33 -0
- package/func/logger.js +48 -0
- package/index.d.ts +812 -0
- package/index.js +30 -824
- package/module/config.js +46 -0
- package/module/login.js +136 -0
- package/module/loginHelper.js +1413 -0
- package/module/options.js +55 -0
- package/package.json +75 -22
- package/scripts/run-tests.js +19 -0
- package/scripts/syntax-check.js +22 -0
- package/src/{addExternalModule.js → api/action/addExternalModule.js} +8 -8
- package/src/{changeAvatar.js → api/action/changeAvatar.js} +32 -33
- package/src/{changeBio.js → api/action/changeBio.js} +19 -22
- package/src/api/action/dismissScrapingWarning.js +50 -0
- package/src/api/action/enableAutoSaveAppState.js +73 -0
- package/src/{getCurrentUserID.js → api/action/getCurrentUserID.js} +1 -1
- package/src/api/action/handleFriendRequest.js +57 -0
- package/src/api/action/logout.js +95 -0
- package/src/api/action/refreshFb_dtsg.js +47 -0
- package/src/{setPostReaction.js → api/action/setPostReaction.js} +23 -31
- package/src/{unfriend.js → api/action/unfriend.js} +14 -14
- 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/{changeArchivedStatus.js → api/messaging/changeArchivedStatus.js} +15 -17
- package/src/{changeBlockedStatus.js → api/messaging/changeBlockedStatus.js} +13 -16
- 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/{createNewGroup.js → api/messaging/createNewGroup.js} +24 -26
- 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/{deleteThread.js → api/messaging/deleteThread.js} +14 -16
- package/src/api/messaging/editMessage.js +105 -0
- package/src/api/messaging/forwardAttachment.js +57 -0
- package/src/api/messaging/forwardMessage.js +134 -0
- package/src/{getEmojiUrl.js → api/messaging/getEmojiUrl.js} +2 -2
- package/src/{getFriendsList.js → api/messaging/getFriendsList.js} +16 -19
- package/src/{getMessage.js → api/messaging/getMessage.js} +160 -180
- package/src/api/messaging/getThemePictures.js +62 -0
- package/src/api/messaging/handleMessageRequest.js +65 -0
- package/src/api/messaging/markAsDelivered.js +69 -0
- package/src/api/messaging/markAsRead.js +110 -0
- package/src/api/messaging/markAsReadAll.js +56 -0
- package/src/api/messaging/markAsSeen.js +68 -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/{resolvePhotoUrl.js → api/messaging/resolvePhotoUrl.js} +11 -15
- package/src/api/messaging/scheduler.js +264 -0
- package/src/{searchForThread.js → api/messaging/searchForThread.js} +12 -12
- package/src/api/messaging/sendBroadcast.js +93 -0
- package/src/api/messaging/sendMessage.js +269 -0
- package/src/api/messaging/sendTypingIndicator.js +90 -0
- package/src/api/messaging/sessionGuard.js +130 -0
- package/src/api/messaging/setMessageReaction.js +114 -0
- package/src/api/messaging/setTitle.js +124 -0
- package/src/api/messaging/shareContact.js +98 -0
- package/src/{threadColors.js → api/messaging/threadColors.js} +2 -5
- package/src/api/messaging/unsendMessage.js +105 -0
- package/src/api/messaging/uploadAttachment.js +493 -0
- package/src/api/socket/OldMessage.js +199 -0
- package/src/api/socket/core/connectMqtt.js +304 -0
- package/src/api/socket/core/emitAuth.js +95 -0
- package/src/api/socket/core/getSeqID.js +331 -0
- package/src/api/socket/core/getTaskResponseData.js +25 -0
- package/src/api/socket/core/lifecycle.js +117 -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/index.js +977 -0
- package/src/api/socket/e2ee/localMediaServer.js +59 -0
- package/src/api/socket/e2ee/mediaDecode.js +155 -0
- package/src/api/socket/e2ee/native/NOTICE.md +29 -0
- package/{lib → src/api/socket/e2ee/native/lib}/index.mjs +109 -66
- package/src/api/socket/e2ee/native/nativeMediaBridge.js +273 -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/fme/dist/index.cjs +6477 -0
- package/src/api/socket/e2ee/vendor/fme/proto/ArmadilloApplication.proto +281 -0
- package/src/api/socket/e2ee/vendor/fme/proto/ArmadilloICDC.proto +14 -0
- package/src/api/socket/e2ee/vendor/fme/proto/ConsumerApplication.proto +232 -0
- package/src/api/socket/e2ee/vendor/fme/proto/MessageApplication.proto +82 -0
- package/src/api/socket/e2ee/vendor/fme/proto/MessageTransport.proto +77 -0
- package/src/api/socket/e2ee/vendor/fme/proto/WACommon.proto +66 -0
- package/src/api/socket/e2ee/vendor/fme/proto/WAMediaTransport.proto +176 -0
- package/src/api/socket/listenE2EE.js +87 -0
- package/src/api/socket/listenMqtt.js +499 -0
- package/src/api/socket/middleware/index.js +216 -0
- package/src/api/socket/sendMessage.js +331 -0
- package/src/api/socket/sendMessageMqtt.js +69 -0
- package/src/{getThreadHistory.js → api/threads/getThreadHistory.js} +114 -132
- package/src/api/threads/getThreadInfo.js +329 -0
- package/src/api/threads/getThreadList.js +293 -0
- package/src/api/threads/getThreadPictures.js +78 -0
- package/src/{getUserID.js → api/users/getUserID.js} +22 -18
- 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/antiSuspension.js +219 -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 +85 -0
- package/src/utils/fingerprint.js +110 -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 +195 -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 +125 -0
- package/src/utils/humanizer.js +256 -0
- package/src/utils/loginParser/autoLogin.js +125 -0
- package/src/utils/loginParser/extractDtsg.js +44 -0
- package/src/utils/loginParser/helpers.js +43 -0
- package/src/utils/loginParser/index.js +10 -0
- package/src/utils/loginParser/parseAndCheckLogin.js +241 -0
- package/src/utils/loginParser/textUtils.js +28 -0
- package/src/utils/nexca-logger.js +144 -0
- package/src/utils/nexca-utils.js +687 -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/typingIndicator.js +202 -0
- package/test/helpers/stub-modules.js +122 -0
- package/test/integration/logout.test.js +69 -0
- package/test/integration/mqtt-lifecycle.test.js +195 -0
- package/test/integration/package.test.js +116 -0
- package/test/integration/typing-wiring.test.js +71 -0
- package/test/unit/fingerprint.test.js +19 -0
- package/test/unit/humanizer.test.js +32 -0
- package/test/unit/lifecycle.test.js +92 -0
- package/test/unit/parsers.test.js +43 -0
- package/test/unit/typing.test.js +136 -0
- package/ANALYSIS.md +0 -31
- package/AUDIT_REPORT.md +0 -57
- package/advancedSystem.js +0 -95
- package/checkUpdate.js +0 -47
- package/config.json +0 -51
- package/e2ee.js +0 -738
- package/examples/basic-bot.js +0 -122
- package/examples/e2ee-bot.js +0 -141
- package/fca-config.example.json +0 -73
- package/scripts/check.js +0 -38
- package/src/OldMessage.js +0 -357
- package/src/addUserToGroup.js +0 -117
- package/src/changeAdminStatus.js +0 -105
- package/src/changeAvatarV2.js +0 -86
- package/src/changeAvt.js +0 -85
- package/src/changeBlockedStatusMqtt.js +0 -75
- package/src/changeCover.js +0 -73
- package/src/changeGroupImage.js +0 -137
- package/src/changeName.js +0 -79
- package/src/changeNickname.js +0 -61
- package/src/changeThreadColor.js +0 -67
- package/src/changeThreadEmoji.js +0 -57
- package/src/changeUsername.js +0 -59
- package/src/createCommentPost.js +0 -232
- package/src/createPoll.js +0 -73
- package/src/createPost.js +0 -276
- package/src/deleteMessage.js +0 -58
- package/src/editMessage.js +0 -76
- package/src/editMessageOld.js +0 -62
- package/src/follow.js +0 -74
- package/src/forwardAttachment.js +0 -62
- package/src/friendList.js +0 -104
- package/src/getAccess.js +0 -112
- package/src/getAvatarUser.js +0 -78
- package/src/getBotInitialData.js +0 -42
- package/src/getCtx.js +0 -5
- package/src/getOptions.js +0 -5
- package/src/getRegion.js +0 -7
- package/src/getThreadHistoryDeprecated.js +0 -71
- package/src/getThreadInfo.js +0 -232
- package/src/getThreadInfoDeprecated.js +0 -56
- package/src/getThreadList.js +0 -213
- package/src/getThreadListDeprecated.js +0 -46
- package/src/getThreadPictures.js +0 -59
- package/src/getThreadTheme.js +0 -81
- package/src/getUID.js +0 -119
- package/src/getUserInfo.js +0 -66
- package/src/handleFriendRequest.js +0 -46
- package/src/handleMessageRequest.js +0 -47
- package/src/httpGet.js +0 -49
- package/src/httpPost.js +0 -48
- package/src/httpPostFormData.js +0 -70
- package/src/listenMqtt.js +0 -1081
- package/src/listenNotification.js +0 -85
- package/src/logout.js +0 -18
- package/src/markAsDelivered.js +0 -47
- package/src/markAsRead.js +0 -72
- package/src/markAsReadAll.js +0 -40
- package/src/markAsSeen.js +0 -48
- package/src/metaTheme.js +0 -189
- package/src/muteThread.js +0 -45
- package/src/note.js +0 -228
- package/src/pinMessage.js +0 -54
- package/src/refreshFb_dtsg.js +0 -49
- package/src/removeSuspiciousAccount.js +0 -78
- package/src/removeUserFromGroup.js +0 -81
- package/src/reply.js +0 -442
- package/src/searchFriends.js +0 -140
- package/src/searchStickers.js +0 -53
- package/src/send.js +0 -46
- package/src/sendButtons.js +0 -163
- package/src/sendComment.js +0 -159
- package/src/sendFriendRequest.js +0 -112
- package/src/sendMessage.js +0 -441
- package/src/sendMessageMqtt.js +0 -323
- package/src/sendTypingIndicator.js +0 -68
- package/src/sendTypingIndicatorV2.js +0 -22
- package/src/setActiveStatus.js +0 -92
- package/src/setMessageReaction.js +0 -150
- package/src/setMessageReactionMqtt.js +0 -104
- package/src/setMessageReactionSafe.js +0 -44
- package/src/setProfileGuard.js +0 -44
- package/src/setProfileLock.js +0 -97
- package/src/setStoryReaction.js +0 -133
- package/src/setStorySeen.js +0 -108
- package/src/setThreadTheme.js +0 -102
- package/src/setTitle.js +0 -92
- package/src/shareContact.js +0 -110
- package/src/shareLink.js +0 -59
- package/src/stopListenMqtt.js +0 -60
- package/src/storyManager.js +0 -357
- package/src/suggestFriend.js +0 -132
- package/src/unsendMessage.js +0 -68
- package/src/uploadAttachment.js +0 -115
- package/test/fixes-1_2_4.test.js +0 -118
- package/test/mqtt-stop.test.js +0 -32
- package/test/reaction-mqtt.test.js +0 -57
- package/utils.js +0 -3056
- /package/{build → src/api/socket/e2ee/native/build}/messagix.dll +0 -0
- /package/{build → src/api/socket/e2ee/native/build}/messagix.so +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const { getType } = require("../src/utils/format");
|
|
2
|
+
const { setProxy } = require("../src/utils/request");
|
|
3
|
+
const logger = require("../func/logger");
|
|
4
|
+
const { getDefaultUserAgent } = require("../src/utils/fingerprint");
|
|
5
|
+
const Boolean_Option = [
|
|
6
|
+
"online",
|
|
7
|
+
"selfListen",
|
|
8
|
+
"listenEvents",
|
|
9
|
+
"updatePresence",
|
|
10
|
+
"forceLogin",
|
|
11
|
+
"autoMarkRead",
|
|
12
|
+
"listenTyping",
|
|
13
|
+
"autoReconnect",
|
|
14
|
+
"emitReady",
|
|
15
|
+
"selfListenEvent"
|
|
16
|
+
];
|
|
17
|
+
function setOptions(globalOptions, options) {
|
|
18
|
+
for (const key of Object.keys(options || {})) {
|
|
19
|
+
if (Boolean_Option.includes(key)) {
|
|
20
|
+
globalOptions[key] = Boolean(options[key]);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
switch (key) {
|
|
24
|
+
case "userAgent": {
|
|
25
|
+
globalOptions.userAgent = options.userAgent || getDefaultUserAgent();
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
case "humanize": {
|
|
29
|
+
globalOptions.humanize = options.humanize;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
case "typingIndicator": {
|
|
33
|
+
// true/undefined = default (on), false = off, object = fine tuning
|
|
34
|
+
// (see src/utils/typingIndicator.js DEFAULTS)
|
|
35
|
+
globalOptions.typingIndicator = options.typingIndicator;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
case "proxy": {
|
|
39
|
+
if (typeof options.proxy !== "string") {
|
|
40
|
+
delete globalOptions.proxy;
|
|
41
|
+
setProxy();
|
|
42
|
+
} else {
|
|
43
|
+
globalOptions.proxy = options.proxy;
|
|
44
|
+
setProxy(globalOptions.proxy);
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
default: {
|
|
49
|
+
logger("setOptions Unrecognized option given to setOptions: " + key, "warn");
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
module.exports = { setOptions, Boolean_Option };
|
package/package.json
CHANGED
|
@@ -1,44 +1,97 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hridoy-ultimate",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
|
+
"description": "Unified Facebook Chat API (FCA) for Messenger bots - hardened MQTT lifecycle, default-on typing indicator, bundled (opt-in) native E2EE engine.",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./index.d.ts",
|
|
10
|
+
"require": "./index.js",
|
|
11
|
+
"default": "./index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"index.js",
|
|
17
|
+
"index.d.ts",
|
|
18
|
+
"module/",
|
|
19
|
+
"func/",
|
|
20
|
+
"src/",
|
|
21
|
+
"scripts/",
|
|
22
|
+
"test/",
|
|
23
|
+
"docs/",
|
|
24
|
+
"README.md",
|
|
25
|
+
"CHANGELOG.md",
|
|
26
|
+
"MERGE_REPORT.md",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"THIRD_PARTY_NOTICES.md"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"test": "node scripts/run-tests.js all",
|
|
32
|
+
"test:unit": "node scripts/run-tests.js unit",
|
|
33
|
+
"lint": "node scripts/syntax-check.js",
|
|
34
|
+
"pack": "npm pack",
|
|
35
|
+
"test:integration": "node scripts/run-tests.js integration"
|
|
36
|
+
},
|
|
6
37
|
"keywords": [
|
|
7
38
|
"facebook",
|
|
39
|
+
"messenger",
|
|
8
40
|
"chat",
|
|
9
41
|
"api",
|
|
10
|
-
"messenger",
|
|
11
|
-
"bot",
|
|
12
42
|
"fca",
|
|
43
|
+
"mqtt",
|
|
44
|
+
"bot",
|
|
45
|
+
"unofficial",
|
|
13
46
|
"hridoy-ultimate",
|
|
14
|
-
"
|
|
15
|
-
"anti-logout",
|
|
16
|
-
"cookie-login",
|
|
17
|
-
"inbox-bot",
|
|
47
|
+
"typing-indicator",
|
|
18
48
|
"e2ee"
|
|
19
49
|
],
|
|
20
|
-
"author":
|
|
50
|
+
"author": {
|
|
51
|
+
"name": "HR ID OY"
|
|
52
|
+
},
|
|
53
|
+
"maintainers": [
|
|
54
|
+
{
|
|
55
|
+
"name": "HR ID OY"
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"contributors": [
|
|
59
|
+
{
|
|
60
|
+
"name": "hridoyhossen48360",
|
|
61
|
+
"url": "https://github.com/hridoyhossen48360"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "DongDev (original)",
|
|
65
|
+
"url": "https://github.com/dongp06"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
21
68
|
"license": "MIT",
|
|
22
69
|
"engines": {
|
|
23
|
-
"node": ">=18
|
|
70
|
+
"node": ">=18"
|
|
24
71
|
},
|
|
25
72
|
"dependencies": {
|
|
26
|
-
"axios": "^1.
|
|
73
|
+
"axios": "^1.13.5",
|
|
74
|
+
"axios-cookiejar-support": "^5.0.5",
|
|
27
75
|
"bluebird": "^3.7.2",
|
|
28
|
-
"
|
|
76
|
+
"chalk": "^4.1.2",
|
|
29
77
|
"form-data": "^4.0.0",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
78
|
+
"duplexify": "^4.1.3",
|
|
79
|
+
"gradient-string": "^2.0.2",
|
|
80
|
+
"https-proxy-agent": "^4.0.0",
|
|
33
81
|
"mqtt": "^5.10.1",
|
|
34
|
-
"npmlog": "^6.0.2",
|
|
35
82
|
"request": "^2.88.2",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
83
|
+
"sequelize": "^6.37.6",
|
|
84
|
+
"sqlite3": "^5.1.7",
|
|
85
|
+
"tough-cookie": "^5.0.0",
|
|
86
|
+
"ws": "^8.18.0"
|
|
39
87
|
},
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
88
|
+
"optionalDependencies": {
|
|
89
|
+
"@signalapp/libsignal-client": "0.70.0",
|
|
90
|
+
"protobufjs": "^8.4.0",
|
|
91
|
+
"mime": "^3.0.0",
|
|
92
|
+
"koffi": "^3.0.2",
|
|
93
|
+
"yumi-json-bigint": "^1.0.0",
|
|
94
|
+
"undici": "^6.0.0",
|
|
95
|
+
"fca-unofficial": "github:VangBanLaNhat/fca-unofficial"
|
|
43
96
|
}
|
|
44
97
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Portable test runner (node --test needs explicit files on Node 18/20).
|
|
3
|
+
// Usage: node scripts/run-tests.js [unit|integration|all]
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const { spawnSync } = require("child_process");
|
|
7
|
+
|
|
8
|
+
const which = process.argv[2] || "all";
|
|
9
|
+
const base = path.join(__dirname, "..", "test");
|
|
10
|
+
const dirs = which === "all" ? ["unit", "integration"] : [which];
|
|
11
|
+
const files = [];
|
|
12
|
+
for (const d of dirs) {
|
|
13
|
+
const full = path.join(base, d);
|
|
14
|
+
if (!fs.existsSync(full)) continue;
|
|
15
|
+
for (const f of fs.readdirSync(full).sort()) if (f.endsWith(".test.js")) files.push(path.join(full, f));
|
|
16
|
+
}
|
|
17
|
+
if (!files.length) { console.error("no test files found"); process.exit(2); }
|
|
18
|
+
const r = spawnSync(process.execPath, ["--test", ...files], { stdio: "inherit" });
|
|
19
|
+
process.exit(r.status === null ? 1 : r.status);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Dependency-free "lint": every .js/.cjs file in the package must parse.
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { spawnSync } = require("child_process");
|
|
6
|
+
const root = path.join(__dirname, "..");
|
|
7
|
+
const skip = new Set(["node_modules", "Fca_Database", ".git"]);
|
|
8
|
+
let bad = 0, n = 0;
|
|
9
|
+
(function walk(dir) {
|
|
10
|
+
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
11
|
+
if (skip.has(e.name)) continue;
|
|
12
|
+
const p = path.join(dir, e.name);
|
|
13
|
+
if (e.isDirectory()) walk(p);
|
|
14
|
+
else if (/\.(js|cjs)$/.test(e.name)) {
|
|
15
|
+
n++;
|
|
16
|
+
const r = spawnSync(process.execPath, ["--check", p], { encoding: "utf8" });
|
|
17
|
+
if (r.status !== 0) { bad++; console.error("SYNTAX ERROR:", path.relative(root, p), "\n" + r.stderr); }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
})(root);
|
|
21
|
+
console.log(`checked ${n} files, ${bad} with syntax errors`);
|
|
22
|
+
process.exit(bad ? 1 : 0);
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const { getType } = require("../../utils/format");
|
|
4
4
|
|
|
5
|
-
module.exports = function
|
|
5
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
|
6
6
|
return function addExternalModule(moduleObj) {
|
|
7
|
-
if (
|
|
7
|
+
if (getType(moduleObj) == "Object") {
|
|
8
8
|
for (const apiName in moduleObj) {
|
|
9
|
-
if (
|
|
9
|
+
if (getType(moduleObj[apiName]) == "Function") {
|
|
10
10
|
api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
|
|
11
11
|
} else {
|
|
12
12
|
throw new Error(
|
|
13
|
-
`Item "${apiName}" in moduleObj must be a function, not ${
|
|
14
|
-
moduleObj[apiName]
|
|
15
|
-
)}
|
|
13
|
+
`Item "${apiName}" in moduleObj must be a function, not ${getType(
|
|
14
|
+
moduleObj[apiName]
|
|
15
|
+
)}!`
|
|
16
16
|
);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
} else {
|
|
20
20
|
throw new Error(
|
|
21
|
-
`moduleObj must be an object, not ${
|
|
21
|
+
`moduleObj must be an object, not ${getType(moduleObj)}!`
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
24
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
|
3
|
+
const log = require("../../../func/logAdapter");
|
|
4
|
+
const { isReadableStream } = require("../../utils/constants");
|
|
5
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
|
6
|
+
const { formatID, getType } = require("../../utils/format");
|
|
7
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
|
9
8
|
function handleUpload(image, callback) {
|
|
10
9
|
const uploads = [];
|
|
11
10
|
|
|
@@ -13,7 +12,7 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
13
12
|
profile_id: ctx.userID,
|
|
14
13
|
photo_source: 57,
|
|
15
14
|
av: ctx.userID,
|
|
16
|
-
file: image
|
|
15
|
+
file: image
|
|
17
16
|
};
|
|
18
17
|
|
|
19
18
|
uploads.push(
|
|
@@ -22,23 +21,23 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
22
21
|
"https://www.facebook.com/profile/picture/upload/",
|
|
23
22
|
ctx.jar,
|
|
24
23
|
form,
|
|
25
|
-
{}
|
|
24
|
+
{}
|
|
26
25
|
)
|
|
27
|
-
.then(
|
|
28
|
-
.then(function
|
|
26
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
|
27
|
+
.then(function(resData) {
|
|
29
28
|
if (resData.error) {
|
|
30
29
|
throw resData;
|
|
31
30
|
}
|
|
32
31
|
return resData;
|
|
33
|
-
})
|
|
32
|
+
})
|
|
34
33
|
);
|
|
35
34
|
|
|
36
35
|
// resolve all promises
|
|
37
36
|
Promise.all(uploads)
|
|
38
|
-
.then(function
|
|
37
|
+
.then(function(resData) {
|
|
39
38
|
callback(null, resData);
|
|
40
39
|
})
|
|
41
|
-
.catch(function
|
|
40
|
+
.catch(function(err) {
|
|
42
41
|
log.error("handleUpload", err);
|
|
43
42
|
return callback(err);
|
|
44
43
|
});
|
|
@@ -48,16 +47,16 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
48
47
|
image,
|
|
49
48
|
caption = "",
|
|
50
49
|
timestamp = null,
|
|
51
|
-
callback
|
|
50
|
+
callback
|
|
52
51
|
) {
|
|
53
|
-
let resolveFunc = function
|
|
54
|
-
let rejectFunc = function
|
|
55
|
-
const returnPromise = new Promise(function
|
|
52
|
+
let resolveFunc = function() {};
|
|
53
|
+
let rejectFunc = function() {};
|
|
54
|
+
const returnPromise = new Promise(function(resolve, reject) {
|
|
56
55
|
resolveFunc = resolve;
|
|
57
56
|
rejectFunc = reject;
|
|
58
57
|
});
|
|
59
58
|
|
|
60
|
-
if (!timestamp &&
|
|
59
|
+
if (!timestamp && getType(caption) === "Number") {
|
|
61
60
|
timestamp = caption;
|
|
62
61
|
caption = "";
|
|
63
62
|
}
|
|
@@ -65,8 +64,8 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
65
64
|
if (
|
|
66
65
|
!timestamp &&
|
|
67
66
|
!callback &&
|
|
68
|
-
(
|
|
69
|
-
|
|
67
|
+
(getType(caption) == "Function" ||
|
|
68
|
+
getType(caption) == "AsyncFunction")
|
|
70
69
|
) {
|
|
71
70
|
callback = caption;
|
|
72
71
|
caption = "";
|
|
@@ -74,23 +73,23 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
if (!callback)
|
|
77
|
-
callback = function
|
|
76
|
+
callback = function(err, data) {
|
|
78
77
|
if (err) {
|
|
79
78
|
return rejectFunc(err);
|
|
80
79
|
}
|
|
81
80
|
resolveFunc(data);
|
|
82
81
|
};
|
|
83
82
|
|
|
84
|
-
if (!
|
|
83
|
+
if (!isReadableStream(image))
|
|
85
84
|
return callback("Image is not a readable stream");
|
|
86
85
|
|
|
87
|
-
handleUpload(image, function
|
|
86
|
+
handleUpload(image, function(err, payload) {
|
|
88
87
|
if (err) {
|
|
89
88
|
return callback(err);
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
const form = {
|
|
93
|
-
av: ctx.userID,
|
|
92
|
+
av: ctx.i_userID || ctx.userID,
|
|
94
93
|
fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
|
|
95
94
|
fb_api_caller_class: "RelayModern",
|
|
96
95
|
doc_id: "5066134240065849",
|
|
@@ -99,35 +98,35 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
99
98
|
caption,
|
|
100
99
|
existing_photo_id: payload[0].payload.fbid,
|
|
101
100
|
expiration_time: timestamp,
|
|
102
|
-
profile_id: ctx.userID,
|
|
101
|
+
profile_id: ctx.i_userID || ctx.userID,
|
|
103
102
|
profile_pic_method: "EXISTING",
|
|
104
103
|
profile_pic_source: "TIMELINE",
|
|
105
104
|
scaled_crop_rect: {
|
|
106
105
|
height: 1,
|
|
107
106
|
width: 1,
|
|
108
107
|
x: 0,
|
|
109
|
-
y: 0
|
|
108
|
+
y: 0
|
|
110
109
|
},
|
|
111
110
|
skip_cropping: true,
|
|
112
|
-
actor_id: ctx.userID,
|
|
113
|
-
client_mutation_id: Math.round(Math.random() * 19).toString()
|
|
111
|
+
actor_id: ctx.i_userID || ctx.userID,
|
|
112
|
+
client_mutation_id: Math.round(Math.random() * 19).toString()
|
|
114
113
|
},
|
|
115
114
|
isPage: false,
|
|
116
115
|
isProfile: true,
|
|
117
|
-
scale: 3
|
|
118
|
-
})
|
|
116
|
+
scale: 3
|
|
117
|
+
})
|
|
119
118
|
};
|
|
120
119
|
|
|
121
120
|
defaultFuncs
|
|
122
121
|
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
123
|
-
.then(
|
|
124
|
-
.then(function
|
|
122
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
|
123
|
+
.then(function(resData) {
|
|
125
124
|
if (resData.errors) {
|
|
126
125
|
throw resData;
|
|
127
126
|
}
|
|
128
127
|
return callback(null, resData[0].data.profile_picture_set);
|
|
129
128
|
})
|
|
130
|
-
.catch(function
|
|
129
|
+
.catch(function(err) {
|
|
131
130
|
log.error("changeAvatar", err);
|
|
132
131
|
return callback(err);
|
|
133
132
|
});
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
|
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) {
|
|
9
7
|
return function changeBio(bio, publish, callback) {
|
|
10
|
-
let resolveFunc = function
|
|
11
|
-
let rejectFunc = function
|
|
12
|
-
const returnPromise = new Promise(function
|
|
8
|
+
let resolveFunc = function() {};
|
|
9
|
+
let rejectFunc = function() {};
|
|
10
|
+
const returnPromise = new Promise(function(resolve, reject) {
|
|
13
11
|
resolveFunc = resolve;
|
|
14
12
|
rejectFunc = reject;
|
|
15
13
|
});
|
|
16
14
|
|
|
17
15
|
if (!callback) {
|
|
18
16
|
if (
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
getType(publish) == "Function" ||
|
|
18
|
+
getType(publish) == "AsyncFunction"
|
|
21
19
|
) {
|
|
22
20
|
callback = publish;
|
|
23
21
|
} else {
|
|
24
|
-
callback = function
|
|
22
|
+
callback = function(err) {
|
|
25
23
|
if (err) {
|
|
26
24
|
return rejectFunc(err);
|
|
27
25
|
}
|
|
@@ -30,11 +28,11 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
if (
|
|
31
|
+
if (getType(publish) != "Boolean") {
|
|
34
32
|
publish = false;
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
if (
|
|
35
|
+
if (getType(bio) != "String") {
|
|
38
36
|
bio = "";
|
|
39
37
|
publish = false;
|
|
40
38
|
}
|
|
@@ -42,33 +40,32 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
42
40
|
const form = {
|
|
43
41
|
fb_api_caller_class: "RelayModern",
|
|
44
42
|
fb_api_req_friendly_name: "ProfileCometSetBioMutation",
|
|
45
|
-
// This doc_is is valid as of May 23, 2020
|
|
46
43
|
doc_id: "2725043627607610",
|
|
47
44
|
variables: JSON.stringify({
|
|
48
45
|
input: {
|
|
49
46
|
bio: bio,
|
|
50
47
|
publish_bio_feed_story: publish,
|
|
51
|
-
actor_id: ctx.userID,
|
|
52
|
-
client_mutation_id: Math.round(Math.random() * 1024).toString()
|
|
48
|
+
actor_id: ctx.i_userID || ctx.userID,
|
|
49
|
+
client_mutation_id: Math.round(Math.random() * 1024).toString()
|
|
53
50
|
},
|
|
54
51
|
hasProfileTileViewID: false,
|
|
55
52
|
profileTileViewID: null,
|
|
56
|
-
scale: 1
|
|
53
|
+
scale: 1
|
|
57
54
|
}),
|
|
58
|
-
av: ctx.userID
|
|
55
|
+
av: ctx.i_userID || ctx.userID
|
|
59
56
|
};
|
|
60
57
|
|
|
61
58
|
defaultFuncs
|
|
62
59
|
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
63
|
-
.then(
|
|
64
|
-
.then(function
|
|
60
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
|
61
|
+
.then(function(resData) {
|
|
65
62
|
if (resData.errors) {
|
|
66
63
|
throw resData;
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
return callback();
|
|
70
67
|
})
|
|
71
|
-
.catch(function
|
|
68
|
+
.catch(function(err) {
|
|
72
69
|
log.error("changeBio", err);
|
|
73
70
|
return callback(err);
|
|
74
71
|
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const log = require("../../../func/logAdapter");
|
|
4
|
+
const { parseAndCheckLogin } = require("../../utils/client");
|
|
5
|
+
|
|
6
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
7
|
+
return function dismissScrapingWarning(callback) {
|
|
8
|
+
let resolveFunc = function () {};
|
|
9
|
+
let rejectFunc = function () {};
|
|
10
|
+
const returnPromise = new Promise(function (resolve, reject) {
|
|
11
|
+
resolveFunc = resolve;
|
|
12
|
+
rejectFunc = reject;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (!callback) {
|
|
16
|
+
callback = function (err, data) {
|
|
17
|
+
if (err) return rejectFunc(err);
|
|
18
|
+
resolveFunc(data);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const form = {
|
|
23
|
+
av: ctx.userID,
|
|
24
|
+
__user: ctx.userID,
|
|
25
|
+
fb_dtsg: ctx.fb_dtsg || "",
|
|
26
|
+
fb_api_caller_class: "RelayModern",
|
|
27
|
+
fb_api_req_friendly_name: "FBScrapingWarningMutation",
|
|
28
|
+
server_timestamps: "true",
|
|
29
|
+
doc_id: "6339492849481770",
|
|
30
|
+
variables: "{}"
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
defaultFuncs
|
|
34
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
35
|
+
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
|
36
|
+
.then(function (resData) {
|
|
37
|
+
if (resData && resData.errors) throw resData;
|
|
38
|
+
log.info("dismissScrapingWarning", "Dismissed automated-behavior warning");
|
|
39
|
+
return callback(null, { success: true });
|
|
40
|
+
})
|
|
41
|
+
.catch(function (err) {
|
|
42
|
+
// Non-fatal: worst case the warning just stays on-screen, same as
|
|
43
|
+
// if a human never tapped Dismiss.
|
|
44
|
+
log.warn("dismissScrapingWarning", err && err.message ? err.message : String(err));
|
|
45
|
+
return callback(err);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return returnPromise;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -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
|
+
};
|