zai-fca 1.0.8
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.
Potentially problematic release.
This version of zai-fca might be problematic. Click here for more details.
- package/.cache/replit/env/latest +56 -0
- package/.cache/replit/env/latest.json +1 -0
- package/.cache/replit/modules/nodejs-20.res +1 -0
- package/.cache/replit/modules/replit.res +1 -0
- package/.cache/replit/modules.stamp +0 -0
- package/.cache/typescript/5.6/node_modules/.package-lock.json +178 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/index.d.ts +1365 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/package.json +25 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/README.md +48 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/index.d.ts +29 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/package.json +35 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/index.d.ts +2929 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/package.json +56 -0
- package/.cache/typescript/5.6/node_modules/@types/node/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/.cache/typescript/5.6/node_modules/@types/node/assert.d.ts +1040 -0
- package/.cache/typescript/5.6/node_modules/@types/node/async_hooks.d.ts +541 -0
- package/.cache/typescript/5.6/node_modules/@types/node/buffer.buffer.d.ts +385 -0
- package/.cache/typescript/5.6/node_modules/@types/node/buffer.d.ts +1933 -0
- package/.cache/typescript/5.6/node_modules/@types/node/child_process.d.ts +1549 -0
- package/.cache/typescript/5.6/node_modules/@types/node/cluster.d.ts +579 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/indexable.d.ts +23 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node/console.d.ts +452 -0
- package/.cache/typescript/5.6/node_modules/@types/node/constants.d.ts +19 -0
- package/.cache/typescript/5.6/node_modules/@types/node/crypto.d.ts +4475 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dgram.d.ts +596 -0
- package/.cache/typescript/5.6/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dns/promises.d.ts +476 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dns.d.ts +865 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dom-events.d.ts +124 -0
- package/.cache/typescript/5.6/node_modules/@types/node/domain.d.ts +170 -0
- package/.cache/typescript/5.6/node_modules/@types/node/events.d.ts +931 -0
- package/.cache/typescript/5.6/node_modules/@types/node/fs/promises.d.ts +1275 -0
- package/.cache/typescript/5.6/node_modules/@types/node/fs.d.ts +4396 -0
- package/.cache/typescript/5.6/node_modules/@types/node/globals.d.ts +566 -0
- package/.cache/typescript/5.6/node_modules/@types/node/globals.typedarray.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node/http.d.ts +1958 -0
- package/.cache/typescript/5.6/node_modules/@types/node/http2.d.ts +2558 -0
- package/.cache/typescript/5.6/node_modules/@types/node/https.d.ts +543 -0
- package/.cache/typescript/5.6/node_modules/@types/node/index.d.ts +92 -0
- package/.cache/typescript/5.6/node_modules/@types/node/inspector.d.ts +3966 -0
- package/.cache/typescript/5.6/node_modules/@types/node/module.d.ts +402 -0
- package/.cache/typescript/5.6/node_modules/@types/node/net.d.ts +1001 -0
- package/.cache/typescript/5.6/node_modules/@types/node/os.d.ts +495 -0
- package/.cache/typescript/5.6/node_modules/@types/node/package.json +220 -0
- package/.cache/typescript/5.6/node_modules/@types/node/path.d.ts +200 -0
- package/.cache/typescript/5.6/node_modules/@types/node/perf_hooks.d.ts +965 -0
- package/.cache/typescript/5.6/node_modules/@types/node/process.d.ts +1963 -0
- package/.cache/typescript/5.6/node_modules/@types/node/punycode.d.ts +117 -0
- package/.cache/typescript/5.6/node_modules/@types/node/querystring.d.ts +153 -0
- package/.cache/typescript/5.6/node_modules/@types/node/readline/promises.d.ts +162 -0
- package/.cache/typescript/5.6/node_modules/@types/node/readline.d.ts +589 -0
- package/.cache/typescript/5.6/node_modules/@types/node/repl.d.ts +430 -0
- package/.cache/typescript/5.6/node_modules/@types/node/sea.d.ts +153 -0
- package/.cache/typescript/5.6/node_modules/@types/node/sqlite.d.ts +213 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream/web.d.ts +609 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream.d.ts +1726 -0
- package/.cache/typescript/5.6/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/.cache/typescript/5.6/node_modules/@types/node/test.d.ts +2248 -0
- package/.cache/typescript/5.6/node_modules/@types/node/timers/promises.d.ts +97 -0
- package/.cache/typescript/5.6/node_modules/@types/node/timers.d.ts +240 -0
- package/.cache/typescript/5.6/node_modules/@types/node/tls.d.ts +1226 -0
- package/.cache/typescript/5.6/node_modules/@types/node/trace_events.d.ts +197 -0
- package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +385 -0
- package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +19 -0
- package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/index.d.ts +92 -0
- package/.cache/typescript/5.6/node_modules/@types/node/tty.d.ts +208 -0
- package/.cache/typescript/5.6/node_modules/@types/node/url.d.ts +972 -0
- package/.cache/typescript/5.6/node_modules/@types/node/util.d.ts +2371 -0
- package/.cache/typescript/5.6/node_modules/@types/node/v8.d.ts +808 -0
- package/.cache/typescript/5.6/node_modules/@types/node/vm.d.ts +976 -0
- package/.cache/typescript/5.6/node_modules/@types/node/wasi.d.ts +181 -0
- package/.cache/typescript/5.6/node_modules/@types/node/worker_threads.d.ts +745 -0
- package/.cache/typescript/5.6/node_modules/@types/node/zlib.d.ts +539 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/README.md +76 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/index.d.ts +57 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/package.json +50 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/index.d.ts +84 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/package.json +32 -0
- package/.cache/typescript/5.6/node_modules/@types/request/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/request/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/request/index.d.ts +395 -0
- package/.cache/typescript/5.6/node_modules/@types/request/package.json +70 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/index.d.ts +321 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/package.json +35 -0
- package/.cache/typescript/5.6/node_modules/asynckit/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/asynckit/README.md +233 -0
- package/.cache/typescript/5.6/node_modules/asynckit/bench.js +76 -0
- package/.cache/typescript/5.6/node_modules/asynckit/index.js +6 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/abort.js +29 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/async.js +34 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/defer.js +26 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/iterate.js +75 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/state.js +37 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/streamify.js +141 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/terminator.js +29 -0
- package/.cache/typescript/5.6/node_modules/asynckit/package.json +63 -0
- package/.cache/typescript/5.6/node_modules/asynckit/parallel.js +43 -0
- package/.cache/typescript/5.6/node_modules/asynckit/serial.js +17 -0
- package/.cache/typescript/5.6/node_modules/asynckit/serialOrdered.js +75 -0
- package/.cache/typescript/5.6/node_modules/asynckit/stream.js +21 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/License +19 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/Readme.md +138 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/package.json +25 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/yarn.lock +17 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/License +19 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/Makefile +7 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/Readme.md +141 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/package.json +27 -0
- package/.cache/typescript/5.6/node_modules/form-data/License +19 -0
- package/.cache/typescript/5.6/node_modules/form-data/Readme.md +350 -0
- package/.cache/typescript/5.6/node_modules/form-data/index.d.ts +51 -0
- package/.cache/typescript/5.6/node_modules/form-data/lib/browser.js +2 -0
- package/.cache/typescript/5.6/node_modules/form-data/lib/form_data.js +484 -0
- package/.cache/typescript/5.6/node_modules/form-data/lib/populate.js +10 -0
- package/.cache/typescript/5.6/node_modules/form-data/package.json +72 -0
- package/.cache/typescript/5.6/node_modules/mime-db/HISTORY.md +507 -0
- package/.cache/typescript/5.6/node_modules/mime-db/LICENSE +23 -0
- package/.cache/typescript/5.6/node_modules/mime-db/README.md +100 -0
- package/.cache/typescript/5.6/node_modules/mime-db/db.json +8519 -0
- package/.cache/typescript/5.6/node_modules/mime-db/index.js +12 -0
- package/.cache/typescript/5.6/node_modules/mime-db/package.json +60 -0
- package/.cache/typescript/5.6/node_modules/mime-types/HISTORY.md +397 -0
- package/.cache/typescript/5.6/node_modules/mime-types/LICENSE +23 -0
- package/.cache/typescript/5.6/node_modules/mime-types/README.md +113 -0
- package/.cache/typescript/5.6/node_modules/mime-types/index.js +188 -0
- package/.cache/typescript/5.6/node_modules/mime-types/package.json +44 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/README.md +584 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/index.d.ts +187 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/index.js +65 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/package.json +51 -0
- package/.cache/typescript/5.6/node_modules/types-registry/README.md +2 -0
- package/.cache/typescript/5.6/node_modules/types-registry/index.json +1 -0
- package/.cache/typescript/5.6/node_modules/types-registry/package.json +20 -0
- package/.cache/typescript/5.6/node_modules/undici-types/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/undici-types/README.md +6 -0
- package/.cache/typescript/5.6/node_modules/undici-types/agent.d.ts +31 -0
- package/.cache/typescript/5.6/node_modules/undici-types/api.d.ts +43 -0
- package/.cache/typescript/5.6/node_modules/undici-types/balanced-pool.d.ts +29 -0
- package/.cache/typescript/5.6/node_modules/undici-types/cache.d.ts +36 -0
- package/.cache/typescript/5.6/node_modules/undici-types/client.d.ts +108 -0
- package/.cache/typescript/5.6/node_modules/undici-types/connector.d.ts +34 -0
- package/.cache/typescript/5.6/node_modules/undici-types/content-type.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/undici-types/cookies.d.ts +28 -0
- package/.cache/typescript/5.6/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
- package/.cache/typescript/5.6/node_modules/undici-types/dispatcher.d.ts +255 -0
- package/.cache/typescript/5.6/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/undici-types/errors.d.ts +149 -0
- package/.cache/typescript/5.6/node_modules/undici-types/eventsource.d.ts +61 -0
- package/.cache/typescript/5.6/node_modules/undici-types/fetch.d.ts +209 -0
- package/.cache/typescript/5.6/node_modules/undici-types/file.d.ts +39 -0
- package/.cache/typescript/5.6/node_modules/undici-types/filereader.d.ts +54 -0
- package/.cache/typescript/5.6/node_modules/undici-types/formdata.d.ts +108 -0
- package/.cache/typescript/5.6/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/.cache/typescript/5.6/node_modules/undici-types/global-origin.d.ts +7 -0
- package/.cache/typescript/5.6/node_modules/undici-types/handlers.d.ts +15 -0
- package/.cache/typescript/5.6/node_modules/undici-types/header.d.ts +4 -0
- package/.cache/typescript/5.6/node_modules/undici-types/index.d.ts +71 -0
- package/.cache/typescript/5.6/node_modules/undici-types/interceptors.d.ts +17 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-client.d.ts +25 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/.cache/typescript/5.6/node_modules/undici-types/package.json +55 -0
- package/.cache/typescript/5.6/node_modules/undici-types/patch.d.ts +33 -0
- package/.cache/typescript/5.6/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/.cache/typescript/5.6/node_modules/undici-types/pool.d.ts +39 -0
- package/.cache/typescript/5.6/node_modules/undici-types/proxy-agent.d.ts +28 -0
- package/.cache/typescript/5.6/node_modules/undici-types/readable.d.ts +60 -0
- package/.cache/typescript/5.6/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/.cache/typescript/5.6/node_modules/undici-types/retry-handler.d.ts +116 -0
- package/.cache/typescript/5.6/node_modules/undici-types/util.d.ts +18 -0
- package/.cache/typescript/5.6/node_modules/undici-types/webidl.d.ts +222 -0
- package/.cache/typescript/5.6/node_modules/undici-types/websocket.d.ts +150 -0
- package/.cache/typescript/5.6/package-lock.json +190 -0
- package/.cache/typescript/5.6/package.json +1 -0
- package/.replit +4 -0
- package/.upm/store.json +1 -0
- package/LICENSE +21 -0
- package/README.md +289 -0
- package/index.js +460 -0
- package/package.json +45 -0
- package/src/Screenshot.js +83 -0
- package/src/addExternalModule.js +25 -0
- package/src/addUserToGroup.js +115 -0
- package/src/changeAdminStatus.js +103 -0
- package/src/changeArchivedStatus.js +55 -0
- package/src/changeAvatar.js +136 -0
- package/src/changeAvatarV2.js +86 -0
- package/src/changeAvt.js +85 -0
- package/src/changeBio.js +76 -0
- package/src/changeBlockedStatus.js +49 -0
- package/src/changeBlockedStatusMqtt.js +80 -0
- package/src/changeCover.js +72 -0
- package/src/changeGroupImage.js +135 -0
- package/src/changeName.js +79 -0
- package/src/changeNickname.js +59 -0
- package/src/changeThreadColor.js +65 -0
- package/src/changeThreadEmoji.js +55 -0
- package/src/changeUsername.js +59 -0
- package/src/createCommentPost.js +230 -0
- package/src/createNewGroup.js +88 -0
- package/src/createPoll.js +71 -0
- package/src/createPost.js +276 -0
- package/src/deleteMessage.js +56 -0
- package/src/deleteThread.js +56 -0
- package/src/editMessage.js +59 -0
- package/src/editMessageOld.js +67 -0
- package/src/follow.js +74 -0
- package/src/forwardAttachment.js +60 -0
- package/src/getAccess.js +112 -0
- package/src/getAvatarUser.js +78 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +29 -0
- package/src/getFriendsList.js +83 -0
- package/src/getMessage.js +835 -0
- package/src/getRegion.js +7 -0
- package/src/getThreadHistory.js +680 -0
- package/src/getThreadHistoryDeprecated.js +71 -0
- package/src/getThreadInfo.js +232 -0
- package/src/getThreadInfoDeprecated.js +56 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadListDeprecated.js +46 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getUID.js +119 -0
- package/src/getUserID.js +61 -0
- package/src/getUserInfo.js +66 -0
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +47 -0
- package/src/httpGet.js +49 -0
- package/src/httpPost.js +48 -0
- package/src/listenMqtt.js +827 -0
- package/src/listenMqtt.txt +827 -0
- package/src/logout.js +75 -0
- package/src/markAsDelivered.js +47 -0
- package/src/markAsRead.js +70 -0
- package/src/markAsReadAll.js +40 -0
- package/src/markAsSeen.js +48 -0
- package/src/muteThread.js +45 -0
- package/src/postFormData.txt +46 -0
- package/src/refreshFb_dtsg.js +89 -0
- package/src/removeUserFromGroup.js +79 -0
- package/src/resolvePhotoUrl.js +45 -0
- package/src/searchForThread.js +53 -0
- package/src/searchStickers.js +53 -0
- package/src/sendMessage.js +329 -0
- package/src/sendMessageMqtt.js +322 -0
- package/src/sendTypingIndicator.js +101 -0
- package/src/sendTypingIndicatorV2.js +28 -0
- package/src/setMessageReaction.js +122 -0
- package/src/setMessageReactionMqtt.js +62 -0
- package/src/setPostReaction.js +112 -0
- package/src/setProfileGuard.js +45 -0
- package/src/setStoryReaction.js +64 -0
- package/src/setTitle.js +90 -0
- package/src/shareContact.js +110 -0
- package/src/shareLink.js +59 -0
- package/src/stopListenMqtt.js +23 -0
- package/src/threadColors.js +131 -0
- package/src/unfriend.js +52 -0
- package/src/unsendMessage.js +45 -0
- package/src/uploadAttachment.js +94 -0
- package/test/example-config.json +18 -0
- package/test/test-page.js +140 -0
- package/test/test.js +385 -0
- package/utils.js +2876 -0
    
        package/index.js
    ADDED
    
    | @@ -0,0 +1,460 @@ | |
| 1 | 
            +
            "use strict";
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            var utils = require("./utils");
         | 
| 4 | 
            +
            var cheerio = require("cheerio");
         | 
| 5 | 
            +
            var log = require("npmlog");
         | 
| 6 | 
            +
            /*var { getThemeColors } = require("../../func/utils/log.js");
         | 
| 7 | 
            +
            var logger = require("../../func/utils/log.js");
         | 
| 8 | 
            +
            var { cra, cv, cb, co } = getThemeColors();*/
         | 
| 9 | 
            +
            log.maxRecordSize = 100;
         | 
| 10 | 
            +
            var checkVerified = null;
         | 
| 11 | 
            +
            const Boolean_Option = ['online', 'selfListen', 'listenEvents', 'updatePresence', 'forceLogin', 'autoMarkDelivery', 'autoMarkRead', 'listenTyping', 'autoReconnect', 'emitReady'];
         | 
| 12 | 
            +
            global.ditconmemay = false;
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            function setOptions(globalOptions, options) {
         | 
| 15 | 
            +
                Object.keys(options).map(function (key) {
         | 
| 16 | 
            +
                    switch (Boolean_Option.includes(key)) {
         | 
| 17 | 
            +
                        case true: {
         | 
| 18 | 
            +
                            globalOptions[key] = Boolean(options[key]);
         | 
| 19 | 
            +
                            break;
         | 
| 20 | 
            +
                        }
         | 
| 21 | 
            +
                        case false: {
         | 
| 22 | 
            +
                            switch (key) {
         | 
| 23 | 
            +
                                case 'pauseLog': {
         | 
| 24 | 
            +
                                    if (options.pauseLog) log.pause();
         | 
| 25 | 
            +
                                    else log.resume();
         | 
| 26 | 
            +
                                    break;
         | 
| 27 | 
            +
                                }
         | 
| 28 | 
            +
                                case 'logLevel': {
         | 
| 29 | 
            +
                                    log.level = options.logLevel;
         | 
| 30 | 
            +
                                    globalOptions.logLevel = options.logLevel;
         | 
| 31 | 
            +
                                    break;
         | 
| 32 | 
            +
                                }
         | 
| 33 | 
            +
                                case 'logRecordSize': {
         | 
| 34 | 
            +
                                    log.maxRecordSize = options.logRecordSize;
         | 
| 35 | 
            +
                                    globalOptions.logRecordSize = options.logRecordSize;
         | 
| 36 | 
            +
                                    break;
         | 
| 37 | 
            +
                                }
         | 
| 38 | 
            +
                                case 'pageID': {
         | 
| 39 | 
            +
                                    globalOptions.pageID = options.pageID.toString();
         | 
| 40 | 
            +
                                    break;
         | 
| 41 | 
            +
                                }
         | 
| 42 | 
            +
                                case 'userAgent': {
         | 
| 43 | 
            +
                                    globalOptions.userAgent = (options.userAgent || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36');
         | 
| 44 | 
            +
                                    break;
         | 
| 45 | 
            +
                                }
         | 
| 46 | 
            +
                                case 'proxy': {
         | 
| 47 | 
            +
                                    if (typeof options.proxy != "string") {
         | 
| 48 | 
            +
                                        delete globalOptions.proxy;
         | 
| 49 | 
            +
                                        utils.setProxy();
         | 
| 50 | 
            +
                                    } else {
         | 
| 51 | 
            +
                                        globalOptions.proxy = options.proxy;
         | 
| 52 | 
            +
                                        utils.setProxy(globalOptions.proxy);
         | 
| 53 | 
            +
                                    }
         | 
| 54 | 
            +
                                    break;
         | 
| 55 | 
            +
                                }
         | 
| 56 | 
            +
                                default: {
         | 
| 57 | 
            +
                                    log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
         | 
| 58 | 
            +
                                    break;
         | 
| 59 | 
            +
                                }
         | 
| 60 | 
            +
                            }
         | 
| 61 | 
            +
                            break;
         | 
| 62 | 
            +
                        }
         | 
| 63 | 
            +
                    }
         | 
| 64 | 
            +
                });
         | 
| 65 | 
            +
            }
         | 
| 66 | 
            +
             | 
| 67 | 
            +
            function buildAPI(globalOptions, html, jar) {
         | 
| 68 | 
            +
                let fb_dtsg = null;
         | 
| 69 | 
            +
                let irisSeqID = null;
         | 
| 70 | 
            +
                function extractFromHTML() {
         | 
| 71 | 
            +
                    try {
         | 
| 72 | 
            +
                        const $ = cheerio.load(html);
         | 
| 73 | 
            +
                        $('script').each((i, script) => {
         | 
| 74 | 
            +
                            if (!fb_dtsg) {
         | 
| 75 | 
            +
                                const scriptText = $(script).html() || '';
         | 
| 76 | 
            +
                                const patterns = [
         | 
| 77 | 
            +
                                    /\["DTSGInitialData",\[\],{"token":"([^"]+)"}]/,
         | 
| 78 | 
            +
                                    /\["DTSGInitData",\[\],{"token":"([^"]+)"/,
         | 
| 79 | 
            +
                                    /"token":"([^"]+)"/,
         | 
| 80 | 
            +
                                    /{\\"token\\":\\"([^\\]+)\\"/,
         | 
| 81 | 
            +
                                    /,\{"token":"([^"]+)"\},\d+\]/,
         | 
| 82 | 
            +
                                    /"async_get_token":"([^"]+)"/,
         | 
| 83 | 
            +
                                    /"dtsg":\{"token":"([^"]+)"/,
         | 
| 84 | 
            +
                                    /DTSGInitialData[^>]+>([^<]+)/
         | 
| 85 | 
            +
                                ];
         | 
| 86 | 
            +
                                for (const pattern of patterns) {
         | 
| 87 | 
            +
                                    const match = scriptText.match(pattern);
         | 
| 88 | 
            +
                                    if (match && match[1]) {
         | 
| 89 | 
            +
                                        try {
         | 
| 90 | 
            +
                                            const possibleJson = match[1].replace(/\\"/g, '"');
         | 
| 91 | 
            +
                                            const parsed = JSON.parse(possibleJson);
         | 
| 92 | 
            +
                                            fb_dtsg = parsed.token || parsed;
         | 
| 93 | 
            +
                                        } catch {
         | 
| 94 | 
            +
                                            fb_dtsg = match[1];
         | 
| 95 | 
            +
                                        }
         | 
| 96 | 
            +
                                        if (fb_dtsg) break;
         | 
| 97 | 
            +
                                    }
         | 
| 98 | 
            +
                                }
         | 
| 99 | 
            +
                            }
         | 
| 100 | 
            +
                        });
         | 
| 101 | 
            +
                        if (!fb_dtsg) {
         | 
| 102 | 
            +
                            const dtsgInput = $('input[name="fb_dtsg"]').val();
         | 
| 103 | 
            +
                            if (dtsgInput) fb_dtsg = dtsgInput;
         | 
| 104 | 
            +
                        }
         | 
| 105 | 
            +
                        const seqMatches = html.match(/irisSeqID":"([^"]+)"/);
         | 
| 106 | 
            +
                        if (seqMatches && seqMatches[1]) {
         | 
| 107 | 
            +
                            irisSeqID = seqMatches[1];
         | 
| 108 | 
            +
                        }
         | 
| 109 | 
            +
                        try {
         | 
| 110 | 
            +
                            const jsonMatches = html.match(/\{"dtsg":({[^}]+})/);
         | 
| 111 | 
            +
                            if (jsonMatches && jsonMatches[1]) {
         | 
| 112 | 
            +
                                const dtsgData = JSON.parse(jsonMatches[1]);
         | 
| 113 | 
            +
                                if (dtsgData.token) fb_dtsg = dtsgData.token;
         | 
| 114 | 
            +
                            }
         | 
| 115 | 
            +
                        } catch { }
         | 
| 116 | 
            +
                        if (fb_dtsg) {
         | 
| 117 | 
            +
                            console.log("Đã tìm thấy fb_dtsg");
         | 
| 118 | 
            +
                        }
         | 
| 119 | 
            +
                    } catch (e) {
         | 
| 120 | 
            +
                        console.log("Lỗi khi tìm fb_dtsg:", e);
         | 
| 121 | 
            +
                    }
         | 
| 122 | 
            +
                }
         | 
| 123 | 
            +
                extractFromHTML();
         | 
| 124 | 
            +
                var userID;
         | 
| 125 | 
            +
                var cookies = jar.getCookies("https://www.facebook.com");
         | 
| 126 | 
            +
                var userCookie = cookies.find(cookie => cookie.cookieString().startsWith("c_user="));
         | 
| 127 | 
            +
                var tiktikCookie = cookies.find(cookie => cookie.cookieString().startsWith("i_user="));
         | 
| 128 | 
            +
                if (!userCookie && !tiktikCookie) {
         | 
| 129 | 
            +
                    return log.error('login', "Không tìm thấy cookie cho người dùng, vui lòng kiểm tra lại thông tin đăng nhập");
         | 
| 130 | 
            +
                }
         | 
| 131 | 
            +
                if (html.includes("/checkpoint/block/?next")) {
         | 
| 132 | 
            +
                    return log.error('login', "Appstate die, vui lòng thay cái mới!", 'error');
         | 
| 133 | 
            +
                }
         | 
| 134 | 
            +
                userID = (tiktikCookie || userCookie).cookieString().split("=")[1];
         | 
| 135 | 
            +
                //logger.log(`${cra(`[ CONNECT ]`)} Logged in as ${userID}`, "DATABASE");
         | 
| 136 | 
            +
                try { clearInterval(checkVerified); } catch (_) { }
         | 
| 137 | 
            +
                const clientID = (Math.random() * 2147483648 | 0).toString(16);
         | 
| 138 | 
            +
                let mqttEndpoint = `wss://edge-chat.facebook.com/chat?region=prn&sid=${userID}`;
         | 
| 139 | 
            +
                let region = "PRN";
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                try {
         | 
| 142 | 
            +
                    const endpointMatch = html.match(/"endpoint":"([^"]+)"/);
         | 
| 143 | 
            +
                    if (endpointMatch.input.includes("601051028565049")) {
         | 
| 144 | 
            +
                      console.log(`lỗi login vì dính tài khoản tự động`);
         | 
| 145 | 
            +
                      ditconmemay = true;
         | 
| 146 | 
            +
                    }
         | 
| 147 | 
            +
                    if (endpointMatch) {
         | 
| 148 | 
            +
                        mqttEndpoint = endpointMatch[1].replace(/\\\//g, '/');
         | 
| 149 | 
            +
                        const url = new URL(mqttEndpoint);
         | 
| 150 | 
            +
                        region = url.searchParams.get('region')?.toUpperCase() || "PRN";
         | 
| 151 | 
            +
                    }
         | 
| 152 | 
            +
                } catch (e) {
         | 
| 153 | 
            +
                    console.log('Using default MQTT endpoint');
         | 
| 154 | 
            +
                }
         | 
| 155 | 
            +
                log.info('login', 'Fix fca by DongDev x Satoru');
         | 
| 156 | 
            +
                var ctx = {
         | 
| 157 | 
            +
                    userID: userID,
         | 
| 158 | 
            +
                    jar: jar,
         | 
| 159 | 
            +
                    clientID: clientID,
         | 
| 160 | 
            +
                    globalOptions: globalOptions,
         | 
| 161 | 
            +
                    loggedIn: true,
         | 
| 162 | 
            +
                    access_token: 'NONE',
         | 
| 163 | 
            +
                    clientMutationId: 0,
         | 
| 164 | 
            +
                    mqttClient: undefined,
         | 
| 165 | 
            +
                    lastSeqId: irisSeqID,
         | 
| 166 | 
            +
                    syncToken: undefined,
         | 
| 167 | 
            +
                    mqttEndpoint: mqttEndpoint,
         | 
| 168 | 
            +
                    region: region,
         | 
| 169 | 
            +
                    firstListen: true,
         | 
| 170 | 
            +
                    fb_dtsg: fb_dtsg,
         | 
| 171 | 
            +
                    req_ID: 0,
         | 
| 172 | 
            +
                    callback_Task: {},
         | 
| 173 | 
            +
                    wsReqNumber: 0,
         | 
| 174 | 
            +
                    wsTaskNumber: 0,
         | 
| 175 | 
            +
                    reqCallbacks: {}
         | 
| 176 | 
            +
                };
         | 
| 177 | 
            +
                var api = {
         | 
| 178 | 
            +
                    setOptions: setOptions.bind(null, globalOptions),
         | 
| 179 | 
            +
                    getAppState: () => utils.getAppState(jar),
         | 
| 180 | 
            +
                    postFormData: (url, body) => utils.makeDefaults(html, userID, ctx).postFormData(url, ctx.jar, body)
         | 
| 181 | 
            +
                };
         | 
| 182 | 
            +
                var defaultFuncs = utils.makeDefaults(html, userID, ctx);
         | 
| 183 | 
            +
                api.postFormData = function (url, body) {
         | 
| 184 | 
            +
                    return defaultFuncs.postFormData(url, ctx.jar, body);
         | 
| 185 | 
            +
                };
         | 
| 186 | 
            +
                api.getFreshDtsg = async function () {
         | 
| 187 | 
            +
                    try {
         | 
| 188 | 
            +
                        const res = await defaultFuncs.get('https://www.facebook.com/', jar, null, globalOptions);
         | 
| 189 | 
            +
                        const $ = cheerio.load(res.body);
         | 
| 190 | 
            +
                        let newDtsg;
         | 
| 191 | 
            +
                        const patterns = [
         | 
| 192 | 
            +
                            /\["DTSGInitialData",\[\],{"token":"([^"]+)"}]/,
         | 
| 193 | 
            +
                            /\["DTSGInitData",\[\],{"token":"([^"]+)"/,
         | 
| 194 | 
            +
                            /"token":"([^"]+)"/,
         | 
| 195 | 
            +
                            /name="fb_dtsg" value="([^"]+)"/
         | 
| 196 | 
            +
                        ];
         | 
| 197 | 
            +
             | 
| 198 | 
            +
                        $('script').each((i, script) => {
         | 
| 199 | 
            +
                            if (!newDtsg) {
         | 
| 200 | 
            +
                                const scriptText = $(script).html() || '';
         | 
| 201 | 
            +
                                for (const pattern of patterns) {
         | 
| 202 | 
            +
                                    const match = scriptText.match(pattern);
         | 
| 203 | 
            +
                                    if (match && match[1]) {
         | 
| 204 | 
            +
                                        newDtsg = match[1];
         | 
| 205 | 
            +
                                        break;
         | 
| 206 | 
            +
                                    }
         | 
| 207 | 
            +
                                }
         | 
| 208 | 
            +
                            }
         | 
| 209 | 
            +
                        });
         | 
| 210 | 
            +
             | 
| 211 | 
            +
                        if (!newDtsg) {
         | 
| 212 | 
            +
                            newDtsg = $('input[name="fb_dtsg"]').val();
         | 
| 213 | 
            +
                        }
         | 
| 214 | 
            +
             | 
| 215 | 
            +
                        return newDtsg;
         | 
| 216 | 
            +
                    } catch (e) {
         | 
| 217 | 
            +
                        console.log("Error getting fresh dtsg:", e);
         | 
| 218 | 
            +
                        return null;
         | 
| 219 | 
            +
                    }
         | 
| 220 | 
            +
                };
         | 
| 221 | 
            +
                //if (noMqttData) api.htmlData = noMqttData;
         | 
| 222 | 
            +
                require('fs').readdirSync(__dirname + '/src/').filter(v => v.endsWith('.js')).forEach(v => { api[v.replace('.js', '')] = require(`./src/${v}`)(utils.makeDefaults(html, userID, ctx), api, ctx); });
         | 
| 223 | 
            +
                api.listen = api.listenMqtt;
         | 
| 224 | 
            +
                return {
         | 
| 225 | 
            +
                    ctx,
         | 
| 226 | 
            +
                    defaultFuncs,
         | 
| 227 | 
            +
                    api
         | 
| 228 | 
            +
                };
         | 
| 229 | 
            +
            }
         | 
| 230 | 
            +
             | 
| 231 | 
            +
            function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
         | 
| 232 | 
            +
                return async function (res) {
         | 
| 233 | 
            +
                    try {
         | 
| 234 | 
            +
                        const html = res.body;
         | 
| 235 | 
            +
                        const $ = cheerio.load(html);
         | 
| 236 | 
            +
                        let arr = [];
         | 
| 237 | 
            +
                        $("#login_form input").each((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
         | 
| 238 | 
            +
                        arr = arr.filter(v => v.val && v.val.length);
         | 
| 239 | 
            +
                        let form = utils.arrToForm(arr);
         | 
| 240 | 
            +
                        form.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
         | 
| 241 | 
            +
                        form.lgndim = Buffer.from(JSON.stringify({ w: 1440, h: 900, aw: 1440, ah: 834, c: 24 })).toString('base64');
         | 
| 242 | 
            +
                        form.email = email;
         | 
| 243 | 
            +
                        form.pass = password;
         | 
| 244 | 
            +
                        form.default_persistent = '0';
         | 
| 245 | 
            +
                        form.lgnrnd = utils.getFrom(html, "name=\"lgnrnd\" value=\"", "\"");
         | 
| 246 | 
            +
                        form.locale = 'en_US';
         | 
| 247 | 
            +
                        form.timezone = '240';
         | 
| 248 | 
            +
                        form.lgnjs = Math.floor(Date.now() / 1000);
         | 
| 249 | 
            +
                        const willBeCookies = html.split("\"_js_");
         | 
| 250 | 
            +
                        willBeCookies.slice(1).forEach(val => {
         | 
| 251 | 
            +
                            const cookieData = JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]");
         | 
| 252 | 
            +
                            jar.setCookie(utils.formatCookie(cookieData, "facebook"), "https://www.facebook.com");
         | 
| 253 | 
            +
                        });
         | 
| 254 | 
            +
                        log.info("login", "Logging in...");
         | 
| 255 | 
            +
                        const loginRes = await utils.post(
         | 
| 256 | 
            +
                            "https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110",
         | 
| 257 | 
            +
                            jar,
         | 
| 258 | 
            +
                            form,
         | 
| 259 | 
            +
                            loginOptions
         | 
| 260 | 
            +
                        );
         | 
| 261 | 
            +
                        await utils.saveCookies(jar)(loginRes);
         | 
| 262 | 
            +
                        const headers = loginRes.headers;
         | 
| 263 | 
            +
                        if (!headers.location) throw new Error("Wrong username/password.");
         | 
| 264 | 
            +
                        if (headers.location.includes('https://www.facebook.com/checkpoint/')) {
         | 
| 265 | 
            +
                            log.info("login", "You have login approvals turned on.");
         | 
| 266 | 
            +
                            const checkpointRes = await utils.get(headers.location, jar, null, loginOptions);
         | 
| 267 | 
            +
                            await utils.saveCookies(jar)(checkpointRes);
         | 
| 268 | 
            +
                            const checkpointHtml = checkpointRes.body;
         | 
| 269 | 
            +
                            const $ = cheerio.load(checkpointHtml);
         | 
| 270 | 
            +
                            let checkpointForm = [];
         | 
| 271 | 
            +
                            $("form input").each((i, v) => checkpointForm.push({ val: $(v).val(), name: $(v).attr("name") }));
         | 
| 272 | 
            +
                            checkpointForm = checkpointForm.filter(v => v.val && v.val.length);
         | 
| 273 | 
            +
                            const form = utils.arrToForm(checkpointForm);
         | 
| 274 | 
            +
                            if (checkpointHtml.includes("checkpoint/?next")) {
         | 
| 275 | 
            +
                                return new Promise((resolve, reject) => {
         | 
| 276 | 
            +
                                    const submit2FA = async (code) => {
         | 
| 277 | 
            +
                                        try {
         | 
| 278 | 
            +
                                            form.approvals_code = code;
         | 
| 279 | 
            +
                                            form['submit[Continue]'] = $("#checkpointSubmitButton").html();
         | 
| 280 | 
            +
                                            const approvalRes = await utils.post(
         | 
| 281 | 
            +
                                                "https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php",
         | 
| 282 | 
            +
                                                jar,
         | 
| 283 | 
            +
                                                form,
         | 
| 284 | 
            +
                                                loginOptions
         | 
| 285 | 
            +
                                            );
         | 
| 286 | 
            +
                                            await utils.saveCookies(jar)(approvalRes);
         | 
| 287 | 
            +
                                            const approvalError = $("#approvals_code").parent().attr("data-xui-error");
         | 
| 288 | 
            +
                                            if (approvalError) throw new Error("Invalid 2FA code.");
         | 
| 289 | 
            +
                                            form.name_action_selected = 'dont_save';
         | 
| 290 | 
            +
                                            const finalRes = await utils.post(
         | 
| 291 | 
            +
                                                "https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php",
         | 
| 292 | 
            +
                                                jar,
         | 
| 293 | 
            +
                                                form,
         | 
| 294 | 
            +
                                                loginOptions
         | 
| 295 | 
            +
                                            );
         | 
| 296 | 
            +
                                            await utils.saveCookies(jar)(finalRes);
         | 
| 297 | 
            +
                                            const appState = utils.getAppState(jar);
         | 
| 298 | 
            +
                                            resolve(await loginHelper(appState, email, password, loginOptions, callback));
         | 
| 299 | 
            +
                                        } catch (error) {
         | 
| 300 | 
            +
                                            reject(error);
         | 
| 301 | 
            +
                                        }
         | 
| 302 | 
            +
                                    };
         | 
| 303 | 
            +
                                    throw {
         | 
| 304 | 
            +
                                        error: 'login-approval',
         | 
| 305 | 
            +
                                        continue: submit2FA
         | 
| 306 | 
            +
                                    };
         | 
| 307 | 
            +
                                });
         | 
| 308 | 
            +
                            }
         | 
| 309 | 
            +
                            if (!loginOptions.forceLogin) throw new Error("Couldn't login. Facebook might have blocked this account.");
         | 
| 310 | 
            +
                            form['submit[This was me]'] = checkpointHtml.includes("Suspicious Login Attempt") ? "This was me" : "This Is Okay";
         | 
| 311 | 
            +
                            await utils.post("https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php", jar, form, loginOptions);
         | 
| 312 | 
            +
                            form.name_action_selected = 'save_device';
         | 
| 313 | 
            +
                            const reviewRes = await utils.post("https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php", jar, form, loginOptions);
         | 
| 314 | 
            +
                            const appState = utils.getAppState(jar);
         | 
| 315 | 
            +
                            return await loginHelper(appState, email, password, loginOptions, callback);
         | 
| 316 | 
            +
                        }
         | 
| 317 | 
            +
                        await utils.get('https://www.facebook.com/', jar, null, loginOptions);
         | 
| 318 | 
            +
                        return await utils.saveCookies(jar);
         | 
| 319 | 
            +
                    } catch (error) {
         | 
| 320 | 
            +
                        callback(error);
         | 
| 321 | 
            +
                    }
         | 
| 322 | 
            +
                };
         | 
| 323 | 
            +
            }
         | 
| 324 | 
            +
             | 
| 325 | 
            +
             | 
| 326 | 
            +
            function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
         | 
| 327 | 
            +
                let mainPromise = null;
         | 
| 328 | 
            +
                const jar = utils.getJar();
         | 
| 329 | 
            +
                if (appState) {
         | 
| 330 | 
            +
                    try {
         | 
| 331 | 
            +
                        appState = JSON.parse(appState);
         | 
| 332 | 
            +
                    } catch (e) {
         | 
| 333 | 
            +
                        try {
         | 
| 334 | 
            +
                            appState = appState;
         | 
| 335 | 
            +
                        } catch (e) {
         | 
| 336 | 
            +
                            return callback(new Error("Failed to parse appState"));
         | 
| 337 | 
            +
                        }
         | 
| 338 | 
            +
                    }
         | 
| 339 | 
            +
             | 
| 340 | 
            +
                    try {
         | 
| 341 | 
            +
                        appState.forEach(c => {
         | 
| 342 | 
            +
                            const str = `${c.key}=${c.value}; expires=${c.expires}; domain=${c.domain}; path=${c.path};`;
         | 
| 343 | 
            +
                            jar.setCookie(str, "http://" + c.domain);
         | 
| 344 | 
            +
                        });
         | 
| 345 | 
            +
             | 
| 346 | 
            +
                        mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true })
         | 
| 347 | 
            +
                            .then(utils.saveCookies(jar));
         | 
| 348 | 
            +
                    } catch (e) {
         | 
| 349 | 
            +
                        process.exit(0);
         | 
| 350 | 
            +
                    }
         | 
| 351 | 
            +
                } else {
         | 
| 352 | 
            +
                    mainPromise = utils
         | 
| 353 | 
            +
                        .get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
         | 
| 354 | 
            +
                        .then(utils.saveCookies(jar))
         | 
| 355 | 
            +
                        .then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
         | 
| 356 | 
            +
                        .then(() => utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar)));
         | 
| 357 | 
            +
                }
         | 
| 358 | 
            +
             | 
| 359 | 
            +
                function handleRedirect(res) {
         | 
| 360 | 
            +
                    const reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
         | 
| 361 | 
            +
                    const redirect = reg.exec(res.body);
         | 
| 362 | 
            +
                    if (redirect && redirect[1]) {
         | 
| 363 | 
            +
                        return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
         | 
| 364 | 
            +
                    }
         | 
| 365 | 
            +
                    return res;
         | 
| 366 | 
            +
                }
         | 
| 367 | 
            +
             | 
| 368 | 
            +
                let ctx, api;
         | 
| 369 | 
            +
                mainPromise = mainPromise
         | 
| 370 | 
            +
                    .then(handleRedirect)
         | 
| 371 | 
            +
                    .then(res => {
         | 
| 372 | 
            +
                        const mobileAgentRegex = /MPageLoadClientMetrics/gs;
         | 
| 373 | 
            +
                        if (!mobileAgentRegex.test(res.body)) {
         | 
| 374 | 
            +
                            globalOptions.userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36";
         | 
| 375 | 
            +
                            return utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
         | 
| 376 | 
            +
                        }
         | 
| 377 | 
            +
                        return res;
         | 
| 378 | 
            +
                    })
         | 
| 379 | 
            +
                    .then(handleRedirect)
         | 
| 380 | 
            +
                    .then(res => {
         | 
| 381 | 
            +
                        const html = res.body;
         | 
| 382 | 
            +
                        const Obj = buildAPI(globalOptions, html, jar);
         | 
| 383 | 
            +
                        ctx = Obj.ctx;
         | 
| 384 | 
            +
                        api = Obj.api;
         | 
| 385 | 
            +
                        return res;
         | 
| 386 | 
            +
                    });
         | 
| 387 | 
            +
             | 
| 388 | 
            +
                if (globalOptions.pageID) {
         | 
| 389 | 
            +
                    mainPromise = mainPromise
         | 
| 390 | 
            +
                        .then(() => utils.get(`https://www.facebook.com/${globalOptions.pageID}/messages/?section=messages&subsection=inbox`, jar, null, globalOptions))
         | 
| 391 | 
            +
                        .then(resData => {
         | 
| 392 | 
            +
                            let url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
         | 
| 393 | 
            +
                            url = url.substring(0, url.length - 1);
         | 
| 394 | 
            +
                            return utils.get('https://www.facebook.com' + url, jar, null, globalOptions);
         | 
| 395 | 
            +
                        });
         | 
| 396 | 
            +
                }
         | 
| 397 | 
            +
             | 
| 398 | 
            +
                mainPromise
         | 
| 399 | 
            +
                    .then(async () => {
         | 
| 400 | 
            +
                        log.info('Đăng nhập thành công');
         | 
| 401 | 
            +
                        callback(null, api);
         | 
| 402 | 
            +
                    })
         | 
| 403 | 
            +
                    .catch(e => {
         | 
| 404 | 
            +
                        callback(e);
         | 
| 405 | 
            +
                    });
         | 
| 406 | 
            +
            }
         | 
| 407 | 
            +
             | 
| 408 | 
            +
             | 
| 409 | 
            +
            function login(loginData, options, callback) {
         | 
| 410 | 
            +
                if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
         | 
| 411 | 
            +
                    callback = options;
         | 
| 412 | 
            +
                    options = {};
         | 
| 413 | 
            +
                }
         | 
| 414 | 
            +
             | 
| 415 | 
            +
                var globalOptions = {
         | 
| 416 | 
            +
                    selfListen: false,
         | 
| 417 | 
            +
                    listenEvents: true,
         | 
| 418 | 
            +
                    listenTyping: false,
         | 
| 419 | 
            +
                    updatePresence: false,
         | 
| 420 | 
            +
                    forceLogin: false,
         | 
| 421 | 
            +
                    autoMarkDelivery: false,
         | 
| 422 | 
            +
                    autoMarkRead: false,
         | 
| 423 | 
            +
                    autoReconnect: true,
         | 
| 424 | 
            +
                    logRecordSize: 100,
         | 
| 425 | 
            +
                    online: false,
         | 
| 426 | 
            +
                    emitReady: false,
         | 
| 427 | 
            +
                    userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
         | 
| 428 | 
            +
                };
         | 
| 429 | 
            +
             | 
| 430 | 
            +
                var prCallback = null;
         | 
| 431 | 
            +
                if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
         | 
| 432 | 
            +
                    var rejectFunc = null;
         | 
| 433 | 
            +
                    var resolveFunc = null;
         | 
| 434 | 
            +
                    var returnPromise = new Promise(function (resolve, reject) {
         | 
| 435 | 
            +
                        resolveFunc = resolve;
         | 
| 436 | 
            +
                        rejectFunc = reject;
         | 
| 437 | 
            +
                    });
         | 
| 438 | 
            +
                    prCallback = function (error, api) {
         | 
| 439 | 
            +
                        if (error) return rejectFunc(error);
         | 
| 440 | 
            +
                        return resolveFunc(api);
         | 
| 441 | 
            +
                    };
         | 
| 442 | 
            +
                    callback = prCallback;
         | 
| 443 | 
            +
                }
         | 
| 444 | 
            +
             | 
| 445 | 
            +
                if (loginData.email && loginData.password) {
         | 
| 446 | 
            +
                    setOptions(globalOptions, {
         | 
| 447 | 
            +
                        logLevel: "silent",
         | 
| 448 | 
            +
                        forceLogin: true,
         | 
| 449 | 
            +
                        userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
         | 
| 450 | 
            +
                    });
         | 
| 451 | 
            +
                    loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
         | 
| 452 | 
            +
                } else if (loginData.appState) {
         | 
| 453 | 
            +
                    setOptions(globalOptions, options);
         | 
| 454 | 
            +
                    return loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
         | 
| 455 | 
            +
                }
         | 
| 456 | 
            +
                return returnPromise;
         | 
| 457 | 
            +
            }
         | 
| 458 | 
            +
             | 
| 459 | 
            +
             | 
| 460 | 
            +
            module.exports = login;
         | 
    
        package/package.json
    ADDED
    
    | @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            {
         | 
| 2 | 
            +
                "name": "zai-fca",
         | 
| 3 | 
            +
                "version": "1.0.8",
         | 
| 4 | 
            +
                "description": "Facebook Fca unofficial",
         | 
| 5 | 
            +
                "main": "index.js",
         | 
| 6 | 
            +
                "scripts": {
         | 
| 7 | 
            +
                    "start": "node index.js"
         | 
| 8 | 
            +
                },
         | 
| 9 | 
            +
                "repository": {
         | 
| 10 | 
            +
                    "type": "git",
         | 
| 11 | 
            +
                    "url": "https://github.com/skibidisigmariz1/xxx-fca"
         | 
| 12 | 
            +
                },
         | 
| 13 | 
            +
                "author": "Mark",
         | 
| 14 | 
            +
                "license": "MIT",
         | 
| 15 | 
            +
                "bugs": {
         | 
| 16 | 
            +
                    "url": ""
         | 
| 17 | 
            +
                },
         | 
| 18 | 
            +
                "homepage": "",
         | 
| 19 | 
            +
                "keywords": [
         | 
| 20 | 
            +
                    "facebook",
         | 
| 21 | 
            +
                    "chat",
         | 
| 22 | 
            +
                    "api",
         | 
| 23 | 
            +
                    "fca",
         | 
| 24 | 
            +
                    "messenger",
         | 
| 25 | 
            +
                    "chatbot"
         | 
| 26 | 
            +
                ],
         | 
| 27 | 
            +
                "dependencies": {
         | 
| 28 | 
            +
                    "axios": "^1.6.5",
         | 
| 29 | 
            +
                    "bluebird": "^3.7.2",
         | 
| 30 | 
            +
                    "cheerio": "^0.22.0",
         | 
| 31 | 
            +
                    "https-proxy-agent": "^4.0.0",
         | 
| 32 | 
            +
                    "mqtt": "^3.0.0",
         | 
| 33 | 
            +
                    "request": "^2.88.2",
         | 
| 34 | 
            +
                    "websocket-stream": "^5.5.0",
         | 
| 35 | 
            +
                    "node-cron": "^3.0.3"
         | 
| 36 | 
            +
                },
         | 
| 37 | 
            +
                "devDependencies": {
         | 
| 38 | 
            +
                    "eslint": "^7.5.0",
         | 
| 39 | 
            +
                    "mocha": "^7.0.1",
         | 
| 40 | 
            +
                    "prettier": "^1.11.1"
         | 
| 41 | 
            +
                },
         | 
| 42 | 
            +
                "engines": {
         | 
| 43 | 
            +
                    "node": ">=10.x"
         | 
| 44 | 
            +
                }
         | 
| 45 | 
            +
            }
         | 
| @@ -0,0 +1,83 @@ | |
| 1 | 
            +
            /* eslint-disable linebreak-style */
         | 
| 2 | 
            +
            "use strict";
         | 
| 3 | 
            +
             | 
| 4 | 
            +
             | 
| 5 | 
            +
            module.exports = function (defaultFuncs, api, ctx) {
         | 
| 6 | 
            +
                var Coookie = JSON.parse(JSON.stringify(ctx.jar.getCookies("https://www.facebook.com").concat(ctx.jar.getCookies("https://facebook.com")).concat(ctx.jar.getCookies("https://www.messenger.com"))));
         | 
| 7 | 
            +
                for (let i of Coookie) {
         | 
| 8 | 
            +
                    i.name = i.key;
         | 
| 9 | 
            +
                    i.domain = 'www.facebook.com';
         | 
| 10 | 
            +
                    delete i.key;
         | 
| 11 | 
            +
                }
         | 
| 12 | 
            +
                return function(Link, callback) {
         | 
| 13 | 
            +
                    var logger = require('../logger');
         | 
| 14 | 
            +
                    if (process.platform != 'win32') return logger.Error('Not Supported Platform');
         | 
| 15 | 
            +
                    else try {
         | 
| 16 | 
            +
                        let i = require('puppeteer');
         | 
| 17 | 
            +
                    }   
         | 
| 18 | 
            +
                    catch (e) {
         | 
| 19 | 
            +
                        var { execSync } = require('child_process');
         | 
| 20 | 
            +
                        execSync('npm i puppeteer', { stdio: 'inherit' });
         | 
| 21 | 
            +
                    }
         | 
| 22 | 
            +
                        const Screenshot = require('../Extra/ExtraScreenShot');
         | 
| 23 | 
            +
                            var resolveFunc = function () { };
         | 
| 24 | 
            +
                            var rejectFunc = function () { };
         | 
| 25 | 
            +
                            var returnPromise = new Promise(function (resolve, reject) {
         | 
| 26 | 
            +
                            resolveFunc = resolve;
         | 
| 27 | 
            +
                            rejectFunc = reject;
         | 
| 28 | 
            +
                            });
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                            if (!callback) {
         | 
| 31 | 
            +
                                callback = function (err, data) {
         | 
| 32 | 
            +
                                    if (err) return rejectFunc(err);
         | 
| 33 | 
            +
                                    resolveFunc(data);
         | 
| 34 | 
            +
                                };
         | 
| 35 | 
            +
                            }
         | 
| 36 | 
            +
                    if (Link.includes('facebook.com') || Link.includes('Facebook.com') || Link.includes('fb')) {
         | 
| 37 | 
            +
                        let LinkSplit = Link.split('/');
         | 
| 38 | 
            +
                            if (LinkSplit.indexOf("https:") == 0) {
         | 
| 39 | 
            +
                                if (Link.includes('messages')) {
         | 
| 40 | 
            +
                                    Screenshot.buffer(Link, {
         | 
| 41 | 
            +
                                        cookies: Coookie
         | 
| 42 | 
            +
                                    }).then(data => {
         | 
| 43 | 
            +
                                        callback(null,data);
         | 
| 44 | 
            +
                                    });
         | 
| 45 | 
            +
                                }
         | 
| 46 | 
            +
                                else if (!isNaN(LinkSplit[3]) && !Link.split('=')[1]  && !isNaN(Link.split('=')[1])) {
         | 
| 47 | 
            +
                                    api.sendMessage('Invaild link, format link: facebook.com/Lazic.Kanzu',global.Fca.Data.event.threadID,global.Fca.Data.event.messageID);
         | 
| 48 | 
            +
                                    callback('Error Link', null);
         | 
| 49 | 
            +
                                }
         | 
| 50 | 
            +
                                else if (!isNaN(Link.split('=')[1]) && Link.split('=')[1]) {
         | 
| 51 | 
            +
                                    let Format = `https://www.facebook.com/profile.php?id=${Link.split('=')[1]}`;
         | 
| 52 | 
            +
                                    Screenshot.buffer(Format, {
         | 
| 53 | 
            +
                                        cookies: Coookie
         | 
| 54 | 
            +
                                    }).then(data => {
         | 
| 55 | 
            +
                                        callback(null,data);
         | 
| 56 | 
            +
                                    });
         | 
| 57 | 
            +
                                } 
         | 
| 58 | 
            +
                                else {
         | 
| 59 | 
            +
                                    let Format = `https://www.facebook.com/${LinkSplit[3]}`;
         | 
| 60 | 
            +
                                    Screenshot.buffer(Format, {
         | 
| 61 | 
            +
                                        cookies: Coookie
         | 
| 62 | 
            +
                                    }).then(data => {
         | 
| 63 | 
            +
                                        callback(null,data);
         | 
| 64 | 
            +
                                    });
         | 
| 65 | 
            +
                                }
         | 
| 66 | 
            +
                            }
         | 
| 67 | 
            +
                            else {
         | 
| 68 | 
            +
                                let Form = `https://www.facebook.com/${LinkSplit[1]}`;
         | 
| 69 | 
            +
                                Screenshot.buffer(Form, {
         | 
| 70 | 
            +
                                    cookies: Coookie
         | 
| 71 | 
            +
                                }).then(data => {
         | 
| 72 | 
            +
                                    callback(null,data);
         | 
| 73 | 
            +
                                });
         | 
| 74 | 
            +
                            }
         | 
| 75 | 
            +
                        }
         | 
| 76 | 
            +
                            else {
         | 
| 77 | 
            +
                                Screenshot.buffer(Link).then(data => {
         | 
| 78 | 
            +
                                    callback(null,data);
         | 
| 79 | 
            +
                                });
         | 
| 80 | 
            +
                            }
         | 
| 81 | 
            +
                        return returnPromise;
         | 
| 82 | 
            +
                };
         | 
| 83 | 
            +
            };
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            "use strict";
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            const utils = require("../utils");
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module.exports = function (defaultFuncs, api, ctx) {
         | 
| 6 | 
            +
              return function addExternalModule(moduleObj) {
         | 
| 7 | 
            +
                if (utils.getType(moduleObj) == "Object") {
         | 
| 8 | 
            +
                  for (const apiName in moduleObj) {
         | 
| 9 | 
            +
                    if (utils.getType(moduleObj[apiName]) == "Function") {
         | 
| 10 | 
            +
                      api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
         | 
| 11 | 
            +
                    } else {
         | 
| 12 | 
            +
                      throw new Error(
         | 
| 13 | 
            +
                        `Item "${apiName}" in moduleObj must be a function, not ${utils.getType(
         | 
| 14 | 
            +
                          moduleObj[apiName],
         | 
| 15 | 
            +
                        )}!`,
         | 
| 16 | 
            +
                      );
         | 
| 17 | 
            +
                    }
         | 
| 18 | 
            +
                  }
         | 
| 19 | 
            +
                } else {
         | 
| 20 | 
            +
                  throw new Error(
         | 
| 21 | 
            +
                    `moduleObj must be an object, not ${utils.getType(moduleObj)}!`,
         | 
| 22 | 
            +
                  );
         | 
| 23 | 
            +
                }
         | 
| 24 | 
            +
              };
         | 
| 25 | 
            +
            };
         |