fca-smart-shankar 12.0.0 → 13.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/.replit +12 -3
- package/.upm/store.json +1 -0
- package/CHANGELOG.md +2 -0
- package/README.md +0 -1
- package/generated-icon.png +0 -0
- package/index.js +507 -437
- package/package.json +378 -42
- package/replit.nix +3 -1
- package/shankar-fca.json +4 -0
- package/src/addUserToGroup.js +3 -3
- package/src/changeAdminStatus.js +2 -2
- package/src/changeArchivedStatus.js +2 -2
- package/src/changeAvatar.js +8 -8
- package/src/changeAvatarV2.js +1 -1
- package/src/changeBio.js +4 -4
- package/src/changeBlockedStatus.js +2 -2
- package/src/changeCover.js +2 -2
- package/src/changeGroupImage.js +4 -4
- package/src/changeName.js +2 -2
- package/src/changeNickname.js +2 -2
- package/src/changeThreadColor.js +3 -3
- package/src/changeThreadEmoji.js +2 -2
- package/src/changeUsername.js +3 -3
- package/src/createCommentPost.js +5 -5
- package/src/createNewGroup.js +5 -5
- package/src/createPoll.js +2 -2
- package/src/createPost.js +6 -5
- package/src/deleteMessage.js +2 -2
- package/src/deleteThread.js +2 -2
- package/src/editMessage.js +30 -18
- package/src/follow.js +8 -8
- package/src/forwardAttachment.js +2 -2
- package/src/getAccess.js +2 -2
- package/src/getAvatarUser.js +2 -2
- package/src/getCurrentUserID.js +4 -4
- package/src/getFriendsList.js +3 -3
- package/src/getMessage.js +2 -2
- package/src/getThreadHistory.js +2 -2
- package/src/getThreadHistoryDeprecated.js +2 -2
- package/src/getThreadInfo.js +1 -1
- package/src/getThreadInfoDeprecated.js +2 -2
- package/src/getThreadList.js +3 -3
- package/src/getThreadListDeprecated.js +3 -3
- package/src/getThreadPictures.js +2 -2
- package/src/getUID.js +4 -4
- package/src/getUserID.js +3 -3
- package/src/getUserInfo.js +52 -18
- package/src/handleFriendRequest.js +5 -5
- package/src/handleMessageRequest.js +2 -2
- package/src/httpGet.js +3 -3
- package/src/httpPost.js +3 -3
- package/src/httpPostFormData.js +3 -3
- package/src/listenMqtt.js +648 -659
- package/src/listenNotification.js +1 -1
- package/src/logout.js +3 -3
- package/src/markAsDelivered.js +5 -2
- package/src/markAsRead.js +5 -2
- package/src/markAsReadAll.js +2 -2
- package/src/markAsSeen.js +2 -2
- package/src/muteThread.js +2 -2
- package/src/refreshFb_dtsg.js +3 -3
- package/src/removeUserFromGroup.js +2 -2
- package/src/resolvePhotoUrl.js +2 -2
- package/src/searchStickers.js +1 -1
- package/src/sendMessage.js +11 -8
- package/src/sendMessageMqtt.js +4 -4
- package/src/sendTypingIndicator.js +14 -5
- package/src/sendTypingIndicatorV2.js +1 -1
- package/src/setMessageReaction.js +3 -3
- package/src/setPostReaction.js +4 -4
- package/src/setProfileGuard.js +3 -3
- package/src/setStoryReaction.js +1 -1
- package/src/setTitle.js +3 -3
- package/src/shareContact.js +1 -1
- package/src/shareLink.js +1 -1
- package/src/stopListenMqtt.js +5 -2
- package/src/unfriend.js +2 -2
- package/src/unsendMessage.js +2 -2
- package/src/uploadAttachment.js +2 -2
- package/test/data/shareAttach.js +146 -0
- package/test/data/something.mov +0 -0
- package/test/data/test.png +0 -0
- package/test/data/test.txt +7 -0
- package/test/test-page.js +1 -1
- package/utils.js +564 -391
- package/.cache/nix/binary-cache-v6.sqlite +0 -0
- package/.cache/nix/binary-cache-v6.sqlite-journal +0 -0
- package/.cache/replit/env/latest +0 -125
- package/.cache/replit/env/latest.json +0 -1
- package/.cache/replit/modules/nix.res +0 -1
- package/.cache/replit/modules/nodejs-20.res +0 -1
- package/.cache/replit/modules/replit.res +0 -1
- package/.cache/replit/modules.stamp +0 -0
- package/.cache/replit/nix/env.json +0 -1
- package/.cache/typescript/5.6/node_modules/.package-lock.json +0 -171
- package/.cache/typescript/5.6/node_modules/@types/bluebird/LICENSE +0 -21
- package/.cache/typescript/5.6/node_modules/@types/bluebird/README.md +0 -15
- package/.cache/typescript/5.6/node_modules/@types/bluebird/index.d.ts +0 -1365
- package/.cache/typescript/5.6/node_modules/@types/bluebird/package.json +0 -25
- package/.cache/typescript/5.6/node_modules/@types/caseless/LICENSE +0 -21
- package/.cache/typescript/5.6/node_modules/@types/caseless/README.md +0 -48
- package/.cache/typescript/5.6/node_modules/@types/caseless/index.d.ts +0 -29
- package/.cache/typescript/5.6/node_modules/@types/caseless/package.json +0 -35
- package/.cache/typescript/5.6/node_modules/@types/cheerio/LICENSE +0 -21
- package/.cache/typescript/5.6/node_modules/@types/cheerio/README.md +0 -15
- package/.cache/typescript/5.6/node_modules/@types/cheerio/index.d.ts +0 -318
- package/.cache/typescript/5.6/node_modules/@types/cheerio/package.json +0 -71
- package/.cache/typescript/5.6/node_modules/@types/mocha/LICENSE +0 -21
- package/.cache/typescript/5.6/node_modules/@types/mocha/README.md +0 -15
- package/.cache/typescript/5.6/node_modules/@types/mocha/index.d.ts +0 -2929
- package/.cache/typescript/5.6/node_modules/@types/mocha/package.json +0 -56
- package/.cache/typescript/5.6/node_modules/@types/node/LICENSE +0 -21
- package/.cache/typescript/5.6/node_modules/@types/node/README.md +0 -15
- package/.cache/typescript/5.6/node_modules/@types/node/assert/strict.d.ts +0 -8
- package/.cache/typescript/5.6/node_modules/@types/node/assert.d.ts +0 -1040
- package/.cache/typescript/5.6/node_modules/@types/node/async_hooks.d.ts +0 -541
- package/.cache/typescript/5.6/node_modules/@types/node/buffer.buffer.d.ts +0 -385
- package/.cache/typescript/5.6/node_modules/@types/node/buffer.d.ts +0 -1933
- package/.cache/typescript/5.6/node_modules/@types/node/child_process.d.ts +0 -1549
- package/.cache/typescript/5.6/node_modules/@types/node/cluster.d.ts +0 -579
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/disposable.d.ts +0 -16
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/index.d.ts +0 -9
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/indexable.d.ts +0 -23
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/iterators.d.ts +0 -21
- package/.cache/typescript/5.6/node_modules/@types/node/console.d.ts +0 -452
- package/.cache/typescript/5.6/node_modules/@types/node/constants.d.ts +0 -19
- package/.cache/typescript/5.6/node_modules/@types/node/crypto.d.ts +0 -4475
- package/.cache/typescript/5.6/node_modules/@types/node/dgram.d.ts +0 -596
- package/.cache/typescript/5.6/node_modules/@types/node/diagnostics_channel.d.ts +0 -554
- package/.cache/typescript/5.6/node_modules/@types/node/dns/promises.d.ts +0 -476
- package/.cache/typescript/5.6/node_modules/@types/node/dns.d.ts +0 -865
- package/.cache/typescript/5.6/node_modules/@types/node/dom-events.d.ts +0 -124
- package/.cache/typescript/5.6/node_modules/@types/node/domain.d.ts +0 -170
- package/.cache/typescript/5.6/node_modules/@types/node/events.d.ts +0 -931
- package/.cache/typescript/5.6/node_modules/@types/node/fs/promises.d.ts +0 -1275
- package/.cache/typescript/5.6/node_modules/@types/node/fs.d.ts +0 -4396
- package/.cache/typescript/5.6/node_modules/@types/node/globals.d.ts +0 -566
- package/.cache/typescript/5.6/node_modules/@types/node/globals.typedarray.d.ts +0 -21
- package/.cache/typescript/5.6/node_modules/@types/node/http.d.ts +0 -1958
- package/.cache/typescript/5.6/node_modules/@types/node/http2.d.ts +0 -2558
- package/.cache/typescript/5.6/node_modules/@types/node/https.d.ts +0 -543
- package/.cache/typescript/5.6/node_modules/@types/node/index.d.ts +0 -92
- package/.cache/typescript/5.6/node_modules/@types/node/inspector.d.ts +0 -3966
- package/.cache/typescript/5.6/node_modules/@types/node/module.d.ts +0 -402
- package/.cache/typescript/5.6/node_modules/@types/node/net.d.ts +0 -1001
- package/.cache/typescript/5.6/node_modules/@types/node/os.d.ts +0 -495
- package/.cache/typescript/5.6/node_modules/@types/node/package.json +0 -220
- package/.cache/typescript/5.6/node_modules/@types/node/path.d.ts +0 -200
- package/.cache/typescript/5.6/node_modules/@types/node/perf_hooks.d.ts +0 -965
- package/.cache/typescript/5.6/node_modules/@types/node/process.d.ts +0 -1963
- package/.cache/typescript/5.6/node_modules/@types/node/punycode.d.ts +0 -117
- package/.cache/typescript/5.6/node_modules/@types/node/querystring.d.ts +0 -153
- package/.cache/typescript/5.6/node_modules/@types/node/readline/promises.d.ts +0 -162
- package/.cache/typescript/5.6/node_modules/@types/node/readline.d.ts +0 -589
- package/.cache/typescript/5.6/node_modules/@types/node/repl.d.ts +0 -430
- package/.cache/typescript/5.6/node_modules/@types/node/sea.d.ts +0 -153
- package/.cache/typescript/5.6/node_modules/@types/node/sqlite.d.ts +0 -213
- package/.cache/typescript/5.6/node_modules/@types/node/stream/consumers.d.ts +0 -12
- package/.cache/typescript/5.6/node_modules/@types/node/stream/promises.d.ts +0 -90
- package/.cache/typescript/5.6/node_modules/@types/node/stream/web.d.ts +0 -609
- package/.cache/typescript/5.6/node_modules/@types/node/stream.d.ts +0 -1726
- package/.cache/typescript/5.6/node_modules/@types/node/string_decoder.d.ts +0 -67
- package/.cache/typescript/5.6/node_modules/@types/node/test.d.ts +0 -2248
- package/.cache/typescript/5.6/node_modules/@types/node/timers/promises.d.ts +0 -97
- package/.cache/typescript/5.6/node_modules/@types/node/timers.d.ts +0 -240
- package/.cache/typescript/5.6/node_modules/@types/node/tls.d.ts +0 -1226
- package/.cache/typescript/5.6/node_modules/@types/node/trace_events.d.ts +0 -197
- package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +0 -385
- package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +0 -19
- package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/index.d.ts +0 -92
- package/.cache/typescript/5.6/node_modules/@types/node/tty.d.ts +0 -208
- package/.cache/typescript/5.6/node_modules/@types/node/url.d.ts +0 -972
- package/.cache/typescript/5.6/node_modules/@types/node/util.d.ts +0 -2371
- package/.cache/typescript/5.6/node_modules/@types/node/v8.d.ts +0 -808
- package/.cache/typescript/5.6/node_modules/@types/node/vm.d.ts +0 -976
- package/.cache/typescript/5.6/node_modules/@types/node/wasi.d.ts +0 -181
- package/.cache/typescript/5.6/node_modules/@types/node/worker_threads.d.ts +0 -745
- package/.cache/typescript/5.6/node_modules/@types/node/zlib.d.ts +0 -539
- package/.cache/typescript/5.6/node_modules/@types/request/LICENSE +0 -21
- package/.cache/typescript/5.6/node_modules/@types/request/README.md +0 -15
- package/.cache/typescript/5.6/node_modules/@types/request/index.d.ts +0 -395
- package/.cache/typescript/5.6/node_modules/@types/request/package.json +0 -70
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/LICENSE +0 -21
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/README.md +0 -15
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/index.d.ts +0 -321
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/package.json +0 -35
- package/.cache/typescript/5.6/node_modules/asynckit/LICENSE +0 -21
- package/.cache/typescript/5.6/node_modules/asynckit/README.md +0 -233
- package/.cache/typescript/5.6/node_modules/asynckit/bench.js +0 -76
- package/.cache/typescript/5.6/node_modules/asynckit/index.js +0 -6
- package/.cache/typescript/5.6/node_modules/asynckit/lib/abort.js +0 -29
- package/.cache/typescript/5.6/node_modules/asynckit/lib/async.js +0 -34
- package/.cache/typescript/5.6/node_modules/asynckit/lib/defer.js +0 -26
- package/.cache/typescript/5.6/node_modules/asynckit/lib/iterate.js +0 -75
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_asynckit.js +0 -91
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_parallel.js +0 -25
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial.js +0 -25
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial_ordered.js +0 -29
- package/.cache/typescript/5.6/node_modules/asynckit/lib/state.js +0 -37
- package/.cache/typescript/5.6/node_modules/asynckit/lib/streamify.js +0 -141
- package/.cache/typescript/5.6/node_modules/asynckit/lib/terminator.js +0 -29
- package/.cache/typescript/5.6/node_modules/asynckit/package.json +0 -63
- package/.cache/typescript/5.6/node_modules/asynckit/parallel.js +0 -43
- package/.cache/typescript/5.6/node_modules/asynckit/serial.js +0 -17
- package/.cache/typescript/5.6/node_modules/asynckit/serialOrdered.js +0 -75
- package/.cache/typescript/5.6/node_modules/asynckit/stream.js +0 -21
- package/.cache/typescript/5.6/node_modules/combined-stream/License +0 -19
- package/.cache/typescript/5.6/node_modules/combined-stream/Readme.md +0 -138
- package/.cache/typescript/5.6/node_modules/combined-stream/lib/combined_stream.js +0 -208
- package/.cache/typescript/5.6/node_modules/combined-stream/package.json +0 -25
- package/.cache/typescript/5.6/node_modules/combined-stream/yarn.lock +0 -17
- package/.cache/typescript/5.6/node_modules/delayed-stream/License +0 -19
- package/.cache/typescript/5.6/node_modules/delayed-stream/Makefile +0 -7
- package/.cache/typescript/5.6/node_modules/delayed-stream/Readme.md +0 -141
- package/.cache/typescript/5.6/node_modules/delayed-stream/lib/delayed_stream.js +0 -107
- package/.cache/typescript/5.6/node_modules/delayed-stream/package.json +0 -27
- package/.cache/typescript/5.6/node_modules/form-data/License +0 -19
- package/.cache/typescript/5.6/node_modules/form-data/Readme.md +0 -350
- package/.cache/typescript/5.6/node_modules/form-data/index.d.ts +0 -51
- package/.cache/typescript/5.6/node_modules/form-data/lib/browser.js +0 -2
- package/.cache/typescript/5.6/node_modules/form-data/lib/form_data.js +0 -484
- package/.cache/typescript/5.6/node_modules/form-data/lib/populate.js +0 -10
- package/.cache/typescript/5.6/node_modules/form-data/package.json +0 -72
- package/.cache/typescript/5.6/node_modules/mime-db/HISTORY.md +0 -507
- package/.cache/typescript/5.6/node_modules/mime-db/LICENSE +0 -23
- package/.cache/typescript/5.6/node_modules/mime-db/README.md +0 -100
- package/.cache/typescript/5.6/node_modules/mime-db/db.json +0 -8519
- package/.cache/typescript/5.6/node_modules/mime-db/index.js +0 -12
- package/.cache/typescript/5.6/node_modules/mime-db/package.json +0 -60
- package/.cache/typescript/5.6/node_modules/mime-types/HISTORY.md +0 -397
- package/.cache/typescript/5.6/node_modules/mime-types/LICENSE +0 -23
- package/.cache/typescript/5.6/node_modules/mime-types/README.md +0 -113
- package/.cache/typescript/5.6/node_modules/mime-types/index.js +0 -188
- package/.cache/typescript/5.6/node_modules/mime-types/package.json +0 -44
- package/.cache/typescript/5.6/node_modules/safe-buffer/LICENSE +0 -21
- package/.cache/typescript/5.6/node_modules/safe-buffer/README.md +0 -584
- package/.cache/typescript/5.6/node_modules/safe-buffer/index.d.ts +0 -187
- package/.cache/typescript/5.6/node_modules/safe-buffer/index.js +0 -65
- package/.cache/typescript/5.6/node_modules/safe-buffer/package.json +0 -51
- package/.cache/typescript/5.6/node_modules/types-registry/README.md +0 -2
- package/.cache/typescript/5.6/node_modules/types-registry/index.json +0 -1
- package/.cache/typescript/5.6/node_modules/types-registry/package.json +0 -20
- package/.cache/typescript/5.6/node_modules/undici-types/LICENSE +0 -21
- package/.cache/typescript/5.6/node_modules/undici-types/README.md +0 -6
- package/.cache/typescript/5.6/node_modules/undici-types/agent.d.ts +0 -31
- package/.cache/typescript/5.6/node_modules/undici-types/api.d.ts +0 -43
- package/.cache/typescript/5.6/node_modules/undici-types/balanced-pool.d.ts +0 -29
- package/.cache/typescript/5.6/node_modules/undici-types/cache.d.ts +0 -36
- package/.cache/typescript/5.6/node_modules/undici-types/client.d.ts +0 -108
- package/.cache/typescript/5.6/node_modules/undici-types/connector.d.ts +0 -34
- package/.cache/typescript/5.6/node_modules/undici-types/content-type.d.ts +0 -21
- package/.cache/typescript/5.6/node_modules/undici-types/cookies.d.ts +0 -28
- package/.cache/typescript/5.6/node_modules/undici-types/diagnostics-channel.d.ts +0 -66
- package/.cache/typescript/5.6/node_modules/undici-types/dispatcher.d.ts +0 -255
- package/.cache/typescript/5.6/node_modules/undici-types/env-http-proxy-agent.d.ts +0 -21
- package/.cache/typescript/5.6/node_modules/undici-types/errors.d.ts +0 -149
- package/.cache/typescript/5.6/node_modules/undici-types/eventsource.d.ts +0 -61
- package/.cache/typescript/5.6/node_modules/undici-types/fetch.d.ts +0 -209
- package/.cache/typescript/5.6/node_modules/undici-types/file.d.ts +0 -39
- package/.cache/typescript/5.6/node_modules/undici-types/filereader.d.ts +0 -54
- package/.cache/typescript/5.6/node_modules/undici-types/formdata.d.ts +0 -108
- package/.cache/typescript/5.6/node_modules/undici-types/global-dispatcher.d.ts +0 -9
- package/.cache/typescript/5.6/node_modules/undici-types/global-origin.d.ts +0 -7
- package/.cache/typescript/5.6/node_modules/undici-types/handlers.d.ts +0 -15
- package/.cache/typescript/5.6/node_modules/undici-types/header.d.ts +0 -4
- package/.cache/typescript/5.6/node_modules/undici-types/index.d.ts +0 -71
- package/.cache/typescript/5.6/node_modules/undici-types/interceptors.d.ts +0 -17
- package/.cache/typescript/5.6/node_modules/undici-types/mock-agent.d.ts +0 -50
- package/.cache/typescript/5.6/node_modules/undici-types/mock-client.d.ts +0 -25
- package/.cache/typescript/5.6/node_modules/undici-types/mock-errors.d.ts +0 -12
- package/.cache/typescript/5.6/node_modules/undici-types/mock-interceptor.d.ts +0 -93
- package/.cache/typescript/5.6/node_modules/undici-types/mock-pool.d.ts +0 -25
- package/.cache/typescript/5.6/node_modules/undici-types/package.json +0 -55
- package/.cache/typescript/5.6/node_modules/undici-types/patch.d.ts +0 -33
- package/.cache/typescript/5.6/node_modules/undici-types/pool-stats.d.ts +0 -19
- package/.cache/typescript/5.6/node_modules/undici-types/pool.d.ts +0 -39
- package/.cache/typescript/5.6/node_modules/undici-types/proxy-agent.d.ts +0 -28
- package/.cache/typescript/5.6/node_modules/undici-types/readable.d.ts +0 -60
- package/.cache/typescript/5.6/node_modules/undici-types/retry-agent.d.ts +0 -8
- package/.cache/typescript/5.6/node_modules/undici-types/retry-handler.d.ts +0 -116
- package/.cache/typescript/5.6/node_modules/undici-types/util.d.ts +0 -18
- package/.cache/typescript/5.6/node_modules/undici-types/webidl.d.ts +0 -222
- package/.cache/typescript/5.6/node_modules/undici-types/websocket.d.ts +0 -150
- package/.cache/typescript/5.6/package-lock.json +0 -183
- package/.cache/typescript/5.6/package.json +0 -1
package/index.js
CHANGED
@@ -1,475 +1,545 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
const utils = require("./utils");
|
4
|
-
const
|
4
|
+
const log = require("npmlog");
|
5
|
+
const fs = require('fs');
|
6
|
+
const path = require('path');
|
7
|
+
|
5
8
|
let checkVerified = null;
|
6
|
-
let ctx = null;
|
7
|
-
let _defaultFuncs = null;
|
8
|
-
let api = null;
|
9
|
-
let region;
|
10
|
-
|
11
|
-
const errorRetrieving = "Error retrieving userID. This can be caused by a lot of things, including getting blocked by Facebook for logging in from an unknown location. Try logging in with a browser to verify.";
|
12
|
-
|
13
|
-
async function setOptions(globalOptions, options = {}) {
|
14
|
-
Object.keys(options).map((key) => {
|
15
|
-
switch (key) {
|
16
|
-
case 'online':
|
17
|
-
globalOptions.online = Boolean(options.online);
|
18
|
-
break;
|
19
|
-
case 'selfListen':
|
20
|
-
globalOptions.selfListen = Boolean(options.selfListen);
|
21
|
-
break;
|
22
|
-
case 'selfListenEvent':
|
23
|
-
globalOptions.selfListenEvent = options.selfListenEvent;
|
24
|
-
break;
|
25
|
-
case 'listenEvents':
|
26
|
-
globalOptions.listenEvents = Boolean(options.listenEvents);
|
27
|
-
break;
|
28
|
-
case 'pageID':
|
29
|
-
globalOptions.pageID = options.pageID.toString();
|
30
|
-
break;
|
31
|
-
case 'updatePresence':
|
32
|
-
globalOptions.updatePresence = Boolean(options.updatePresence);
|
33
|
-
break;
|
34
|
-
case 'forceLogin':
|
35
|
-
globalOptions.forceLogin = Boolean(options.forceLogin);
|
36
|
-
break;
|
37
|
-
case 'userAgent':
|
38
|
-
globalOptions.userAgent = options.userAgent;
|
39
|
-
break;
|
40
|
-
case 'autoMarkDelivery':
|
41
|
-
globalOptions.autoMarkDelivery = Boolean(options.autoMarkDelivery);
|
42
|
-
break;
|
43
|
-
case 'autoMarkRead':
|
44
|
-
globalOptions.autoMarkRead = Boolean(options.autoMarkRead);
|
45
|
-
break;
|
46
|
-
case 'listenTyping':
|
47
|
-
globalOptions.listenTyping = Boolean(options.listenTyping);
|
48
|
-
break;
|
49
|
-
case 'proxy':
|
50
|
-
if (typeof options.proxy != "string") {
|
51
|
-
delete globalOptions.proxy;
|
52
|
-
utils.setProxy();
|
53
|
-
} else {
|
54
|
-
globalOptions.proxy = options.proxy;
|
55
|
-
utils.setProxy(globalOptions.proxy);
|
56
|
-
}
|
57
|
-
break;
|
58
|
-
case 'autoReconnect':
|
59
|
-
globalOptions.autoReconnect = Boolean(options.autoReconnect);
|
60
|
-
break;
|
61
|
-
case 'emitReady':
|
62
|
-
globalOptions.emitReady = Boolean(options.emitReady);
|
63
|
-
break;
|
64
|
-
case 'randomUserAgent':
|
65
|
-
globalOptions.randomUserAgent = Boolean(options.randomUserAgent);
|
66
|
-
break;
|
67
|
-
default:
|
68
|
-
break;
|
69
|
-
}
|
70
|
-
});
|
71
|
-
}
|
72
9
|
|
73
|
-
|
74
|
-
|
75
|
-
try {
|
76
|
-
const appstateCUser = (appstate.find(i => i.key == 'c_user') || appstate.find(i => i.key == 'i_user'))
|
77
|
-
const UID = ID || appstateCUser.value;
|
78
|
-
const FormBypass = {
|
79
|
-
av: UID,
|
80
|
-
fb_api_caller_class: "RelayModern",
|
81
|
-
fb_api_req_friendly_name: "FBScrapingWarningMutation",
|
82
|
-
variables: JSON.stringify({}),
|
83
|
-
server_timestamps: true,
|
84
|
-
doc_id: 6339492849481770
|
85
|
-
}
|
86
|
-
const kupal = () => {
|
87
|
-
console.warn(`login | ${UID}`, "We suspect automated behavior on your account.");
|
88
|
-
if (!isBehavior) isBehavior = true;
|
89
|
-
};
|
90
|
-
if (resp) {
|
91
|
-
if (resp.request.uri && resp.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
|
92
|
-
if (resp.request.uri.href.includes('601051028565049')) {
|
93
|
-
const fb_dtsg = utils.getFrom(resp.body, '["DTSGInitData",[],{"token":"', '","');
|
94
|
-
const jazoest = utils.getFrom(resp.body, 'jazoest=', '",');
|
95
|
-
const lsd = utils.getFrom(resp.body, "[\"LSD\",[],{\"token\":\"", "\"}");
|
96
|
-
return utils.post("https://www.facebook.com/api/graphql/", jar, {
|
97
|
-
...FormBypass,
|
98
|
-
fb_dtsg,
|
99
|
-
jazoest,
|
100
|
-
lsd
|
101
|
-
}, globalOptions).then(utils.saveCookies(jar)).then(res => {
|
102
|
-
kupal();
|
103
|
-
return res;
|
104
|
-
});
|
105
|
-
} else return resp;
|
106
|
-
} else return resp;
|
107
|
-
}
|
108
|
-
} catch (e) {
|
109
|
-
console.error("error", e);
|
110
|
-
}
|
111
|
-
}
|
10
|
+
const defaultLogRecordSize = 100;
|
11
|
+
log.maxRecordSize = defaultLogRecordSize;
|
112
12
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
13
|
+
function setOptions(globalOptions, options) {
|
14
|
+
Object.keys(options).map(function (key) {
|
15
|
+
switch (key) {
|
16
|
+
case 'online':
|
17
|
+
globalOptions.online = Boolean(options.online);
|
18
|
+
break;
|
19
|
+
case 'logLevel':
|
20
|
+
log.level = options.logLevel;
|
21
|
+
globalOptions.logLevel = options.logLevel;
|
22
|
+
break;
|
23
|
+
case 'logRecordSize':
|
24
|
+
log.maxRecordSize = options.logRecordSize;
|
25
|
+
globalOptions.logRecordSize = options.logRecordSize;
|
26
|
+
break;
|
27
|
+
case 'selfListen':
|
28
|
+
globalOptions.selfListen = Boolean(options.selfListen);
|
29
|
+
break;
|
30
|
+
case 'selfListenEvent':
|
31
|
+
globalOptions.selfListenEvent = options.selfListenEvent;
|
32
|
+
break;
|
33
|
+
case 'listenEvents':
|
34
|
+
globalOptions.listenEvents = Boolean(options.listenEvents);
|
35
|
+
break;
|
36
|
+
case 'pageID':
|
37
|
+
globalOptions.pageID = options.pageID.toString();
|
38
|
+
break;
|
39
|
+
case 'updatePresence':
|
40
|
+
globalOptions.updatePresence = Boolean(options.updatePresence);
|
41
|
+
break;
|
42
|
+
case 'forceLogin':
|
43
|
+
globalOptions.forceLogin = Boolean(options.forceLogin);
|
44
|
+
break;
|
45
|
+
case 'userAgent':
|
46
|
+
globalOptions.userAgent = options.userAgent;
|
47
|
+
break;
|
48
|
+
case 'autoMarkDelivery':
|
49
|
+
globalOptions.autoMarkDelivery = Boolean(options.autoMarkDelivery);
|
50
|
+
break;
|
51
|
+
case 'autoMarkRead':
|
52
|
+
globalOptions.autoMarkRead = Boolean(options.autoMarkRead);
|
53
|
+
break;
|
54
|
+
case 'listenTyping':
|
55
|
+
globalOptions.listenTyping = Boolean(options.listenTyping);
|
56
|
+
break;
|
57
|
+
case 'proxy':
|
58
|
+
if (typeof options.proxy != "string") {
|
59
|
+
delete globalOptions.proxy;
|
60
|
+
utils.setProxy();
|
61
|
+
} else {
|
62
|
+
globalOptions.proxy = options.proxy;
|
63
|
+
utils.setProxy(globalOptions.proxy);
|
64
|
+
}
|
65
|
+
break;
|
66
|
+
case 'autoReconnect':
|
67
|
+
globalOptions.autoReconnect = Boolean(options.autoReconnect);
|
68
|
+
break;
|
69
|
+
case 'emitReady':
|
70
|
+
globalOptions.emitReady = Boolean(options.emitReady);
|
71
|
+
break;
|
72
|
+
default:
|
73
|
+
log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
|
74
|
+
break;
|
75
|
+
}
|
76
|
+
});
|
146
77
|
}
|
147
78
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
console.error(`Alert on ${UID}:`, lockedReasons.reason);
|
160
|
-
}
|
161
|
-
ctx = null;
|
162
|
-
return {
|
163
|
-
locked: true,
|
164
|
-
lockedReasons
|
165
|
-
}
|
166
|
-
}
|
167
|
-
} else return;
|
168
|
-
}
|
169
|
-
} catch (e) {
|
170
|
-
console.error("error", e);
|
171
|
-
}
|
79
|
+
//new update...
|
80
|
+
const configPath = process.cwd() + "/shankar-fca.json";
|
81
|
+
let bypassEnabled = false;
|
82
|
+
let autoRefreshEnabled = false;
|
83
|
+
|
84
|
+
if (!fs.existsSync(configPath)) {
|
85
|
+
const defaultConfig = {
|
86
|
+
BypassAutomationBehavior: true,
|
87
|
+
AutoRefreshFbDtsg: true,
|
88
|
+
};
|
89
|
+
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 4), "utf8");
|
172
90
|
}
|
173
91
|
|
92
|
+
try {
|
93
|
+
const config = require(configPath);
|
94
|
+
bypassEnabled = config.BypassAutomationBehavior || false;
|
95
|
+
autoRefreshEnabled = config.AutoRefreshFbDtsg || false;
|
96
|
+
} catch (error) {
|
97
|
+
bypassEnabled = false;
|
98
|
+
autoRefreshEnabled = false;
|
99
|
+
}
|
174
100
|
|
175
|
-
function
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
if (tokenMatch) {
|
180
|
-
fb_dtsg = tokenMatch[1];
|
181
|
-
}
|
182
|
-
//hajime pogi
|
183
|
-
//@Kenneth Panio: i fixed the cookie do not change or remove this line what it does? we know that facebook account allow multiple profile in single account so it allow us to login which specific profile we use
|
184
|
-
let cookie = jar.getCookies("https://www.facebook.com");
|
185
|
-
let primary_profile = cookie.filter(function(val) {
|
186
|
-
return val.cookieString().split("=")[0] === "c_user";
|
187
|
-
});
|
188
|
-
let secondary_profile = cookie.filter(function(val) {
|
189
|
-
return val.cookieString().split("=")[0] === "i_user";
|
190
|
-
});
|
191
|
-
if (primary_profile.length === 0 && secondary_profile.length === 0) {
|
192
|
-
throw {
|
193
|
-
error: errorRetrieving,
|
194
|
-
};
|
195
|
-
} else {
|
196
|
-
if (html.indexOf("/checkpoint/block/?next") > -1) {
|
197
|
-
return console.warn(
|
198
|
-
"login",
|
199
|
-
"Checkpoint detected. Please log in with a browser to verify."
|
200
|
-
);
|
201
|
-
}
|
202
|
-
if (secondary_profile[0] && secondary_profile[0].cookieString().includes('i_user')) {
|
203
|
-
userID = secondary_profile[0].cookieString().split("=")[1].toString();
|
101
|
+
function BypassAutomationBehavior(resp, jar, globalOptions, appstate, ID) {
|
102
|
+
if (!bypassEnabled) {
|
103
|
+
log.info("login", "Bypass Currently Disabled.");
|
104
|
+
return resp;
|
204
105
|
} else {
|
205
|
-
|
106
|
+
log.info("login", "Bypass Currently Enabled.");
|
206
107
|
}
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
legacyFBMQTTMatch: html.match(/\["MqttWebConfig",\[\],{"fbid":"(.*?)","appID":219994525426954,"endpoint":"(.*?)","pollingEndpoint":"(.*?)"/)
|
215
|
-
}
|
216
|
-
let Slot = Object.keys(CHECK_MQTT);
|
217
|
-
let mqttEndpoint, irisSeqID;
|
218
|
-
Object.keys(CHECK_MQTT).map((MQTT) => {
|
219
|
-
if (CHECK_MQTT[MQTT] && !region) {
|
220
|
-
switch (Slot.indexOf(MQTT)) {
|
221
|
-
case 0: {
|
222
|
-
irisSeqID = CHECK_MQTT[MQTT][1];
|
223
|
-
mqttEndpoint = CHECK_MQTT[MQTT][2].replace(/\\\//g, "/");
|
224
|
-
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
225
|
-
break;
|
108
|
+
|
109
|
+
try {
|
110
|
+
let UID;
|
111
|
+
if (ID) UID = ID
|
112
|
+
else {
|
113
|
+
UID = (appstate.find(i => i.key == 'c_user') || appstate.find(i => i.key == 'i_user'))
|
114
|
+
UID = UID.value;
|
226
115
|
}
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
116
|
+
if (resp !== undefined) {
|
117
|
+
if (resp.request.uri && resp.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
|
118
|
+
if (resp.request.uri.href.includes('601051028565049')) {
|
119
|
+
const fb_dtsg = utils.getFrom(resp.body, '["DTSGInitData",[],{"token":"', '","');
|
120
|
+
const jazoest = utils.getFrom(resp.body, 'jazoest=', '",');
|
121
|
+
const lsd = utils.getFrom(resp.body, "[\"LSD\",[],{\"token\":\"", "\"}");
|
122
|
+
|
123
|
+
const FormBypass = {
|
124
|
+
av: UID,
|
125
|
+
fb_dtsg, jazoest, lsd,
|
126
|
+
fb_api_caller_class: "RelayModern",
|
127
|
+
fb_api_req_friendly_name: "FBScrapingWarningMutation",
|
128
|
+
variables: JSON.stringify({}),
|
129
|
+
server_timestamps: true,
|
130
|
+
doc_id: 6339492849481770
|
131
|
+
}
|
132
|
+
return utils.post("https://www.facebook.com/api/graphql/", jar, FormBypass, globalOptions)
|
133
|
+
.then(utils.saveCookies(jar)).then(function(res) {
|
134
|
+
log.warn("login", "Checkpoint detected. Bypass done...");
|
135
|
+
return process.exit(1);
|
136
|
+
});
|
137
|
+
}
|
138
|
+
else {
|
139
|
+
return resp;
|
140
|
+
}
|
141
|
+
}
|
142
|
+
else {
|
143
|
+
return resp
|
144
|
+
}
|
232
145
|
}
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
146
|
+
else {
|
147
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(function(res) {
|
148
|
+
if (res.request.uri && res.request.uri.href.includes("https://www.facebook.com/checkpoint/")) {
|
149
|
+
if (res.request.uri.href.includes('601051028565049')) return { Status: true, Body: res.body }
|
150
|
+
else return { Status: false, Body: res.body }
|
151
|
+
}
|
152
|
+
else return { Status: false, Body: res.body }
|
153
|
+
}).then(function(res) {
|
154
|
+
if (res.Status === true) {
|
155
|
+
const fb_dtsg = utils.getFrom(res.Body, '["DTSGInitData",[],{"token":"', '","');
|
156
|
+
const jazoest = utils.getFrom(res.Body, 'jazoest=', '",');
|
157
|
+
const lsd = utils.getFrom(res.Body, "[\"LSD\",[],{\"token\":\"", "\"}");
|
158
|
+
|
159
|
+
const FormBypass = {
|
160
|
+
av: UID,
|
161
|
+
fb_dtsg, jazoest, lsd,
|
162
|
+
fb_api_caller_class: "RelayModern",
|
163
|
+
fb_api_req_friendly_name: "FBScrapingWarningMutation",
|
164
|
+
variables: JSON.stringify({}),
|
165
|
+
server_timestamps: true,
|
166
|
+
doc_id: 6339492849481770
|
167
|
+
}
|
168
|
+
return utils.post("https://www.facebook.com/api/graphql/", jar, FormBypass, globalOptions).then(utils.saveCookies(jar))
|
169
|
+
.then(res => {
|
170
|
+
log.warn("login", "Checkpoint detected. Bypass done.....");
|
171
|
+
return res
|
172
|
+
})
|
173
|
+
}
|
174
|
+
else return res;
|
175
|
+
|
176
|
+
})
|
177
|
+
.then(function(res) {
|
178
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar))
|
179
|
+
})
|
180
|
+
.then(function(res) {
|
181
|
+
return process.exit(1)
|
182
|
+
})
|
237
183
|
}
|
238
|
-
}
|
239
|
-
return;
|
240
184
|
}
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
console.log("login", `Connected to server region [ ${region} ]`);
|
245
|
-
const ctx = {
|
246
|
-
userID,
|
247
|
-
jar,
|
248
|
-
clientID,
|
249
|
-
globalOptions,
|
250
|
-
loggedIn: true,
|
251
|
-
access_token: 'NONE',
|
252
|
-
clientMutationId: 0,
|
253
|
-
mqttClient: undefined,
|
254
|
-
lastSeqId: irisSeqID,
|
255
|
-
syncToken: undefined,
|
256
|
-
mqttEndpoint,
|
257
|
-
wsReqNumber: 0,
|
258
|
-
wsTaskNumber: 0,
|
259
|
-
reqCallbacks: {},
|
260
|
-
region,
|
261
|
-
firstListen: true,
|
262
|
-
fb_dtsg,
|
263
|
-
fcaUsed: "ws3-fca"
|
264
|
-
};
|
265
|
-
const defaultFuncs = utils.makeDefaults(html, userID, ctx);
|
266
|
-
return [ctx, defaultFuncs];
|
185
|
+
catch (e) {
|
186
|
+
console.log(e)
|
187
|
+
}
|
267
188
|
}
|
268
189
|
|
269
|
-
|
270
|
-
|
271
|
-
const jar = utils.getJar();
|
272
|
-
console.log("login", 'Logging in...');
|
273
|
-
if (appState) {
|
274
|
-
if (utils.getType(appState) === 'Array' && appState.some(c => c.name)) {
|
275
|
-
appState = appState.map(c => {
|
276
|
-
c.key = c.name;
|
277
|
-
delete c.name;
|
278
|
-
return c;
|
279
|
-
})
|
280
|
-
}
|
281
|
-
else if (utils.getType(appState) === 'String') {
|
282
|
-
const arrayAppState = [];
|
283
|
-
appState.split(';').forEach(c => {
|
284
|
-
const [key, value] = c.split('=');
|
285
|
-
arrayAppState.push({
|
286
|
-
key: (key || "").trim(),
|
287
|
-
value: (value || "").trim(),
|
288
|
-
domain: ".facebook.com",
|
289
|
-
path: "/",
|
290
|
-
expires: new Date().getTime() + 1000 * 60 * 60 * 24 * 365
|
291
|
-
});
|
292
|
-
});
|
293
|
-
appState = arrayAppState;
|
294
|
-
}
|
190
|
+
function buildAPI(globalOptions, html, jar) {
|
191
|
+
const fb_dtsg = utils.getFroms(html, '["DTSGInitData",[],{"token":"', '","')[0]; //my brain is not braining on here.
|
295
192
|
|
296
|
-
|
297
|
-
|
298
|
-
jar.setCookie(str, "http://" + c.domain);
|
193
|
+
const maybeCookie = jar.getCookies("https://www.facebook.com").filter(function(val) {
|
194
|
+
return val.cookieString().split("=")[0] === "c_user";
|
299
195
|
});
|
300
196
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
197
|
+
if (maybeCookie.length === 0) throw { error: "Error retrieving userID. This can be caused by a lot of things, including getting blocked by Facebook for logging in from an unknown location. Try logging in with a browser to verify." };
|
198
|
+
|
199
|
+
if (html.indexOf("/checkpoint/block/?next") > -1) log.warn("login", "Checkpoint detected. Please log in with a browser to verify.");
|
200
|
+
|
201
|
+
const userID = maybeCookie[0].cookieString().split("=")[1].toString();
|
202
|
+
log.info("login", `Logged in as ${userID}`);
|
203
|
+
|
204
|
+
try {
|
205
|
+
clearInterval(checkVerified);
|
206
|
+
} catch (_) { }
|
207
|
+
|
208
|
+
const clientID = (Math.random() * 2147483648 | 0).toString(16);
|
209
|
+
|
210
|
+
const CHECK_MQTT = {
|
211
|
+
oldFBMQTTMatch: html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/),
|
212
|
+
newFBMQTTMatch: html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/),
|
213
|
+
legacyFBMQTTMatch: html.match(/\["MqttWebConfig",\[\],{"fbid":"(.*?)","appID":219994525426954,"endpoint":"(.*?)","pollingEndpoint":"(.*?)"/)
|
214
|
+
}
|
215
|
+
|
216
|
+
// all available regions =))
|
217
|
+
/**
|
218
|
+
* PRN = Pacific Northwest Region
|
219
|
+
* VLL = Valley Region
|
220
|
+
* ASH = Ashburn Region
|
221
|
+
* DFW = Dallas/Fort Worth Region
|
222
|
+
* LLA = Los Angeles Region
|
223
|
+
* FRA = Frankfurt
|
224
|
+
* SIN = Singapore
|
225
|
+
* NRT = Tokyo (Japan)
|
226
|
+
* HKG = Hong Kong
|
227
|
+
* SYD = Sydney
|
228
|
+
*/
|
229
|
+
|
230
|
+
let Slot = Object.keys(CHECK_MQTT);
|
231
|
+
var mqttEndpoint,region,irisSeqID;
|
232
|
+
Object.keys(CHECK_MQTT).map(function(MQTT) {
|
233
|
+
if (CHECK_MQTT[MQTT] && !region) {
|
234
|
+
switch (Slot.indexOf(MQTT)) {
|
235
|
+
case 0: {
|
236
|
+
irisSeqID = CHECK_MQTT[MQTT][1];
|
237
|
+
mqttEndpoint = CHECK_MQTT[MQTT][2].replace(/\\\//g, "/");
|
238
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
239
|
+
return;
|
240
|
+
}
|
241
|
+
case 1: {
|
242
|
+
irisSeqID = CHECK_MQTT[MQTT][2];
|
243
|
+
mqttEndpoint = CHECK_MQTT[MQTT][1].replace(/\\\//g, "/");
|
244
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
245
|
+
return;
|
246
|
+
}
|
247
|
+
case 2: {
|
248
|
+
mqttEndpoint = CHECK_MQTT[MQTT][2].replace(/\\\//g, "/"); //this really important.
|
249
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
250
|
+
return;
|
251
|
+
}
|
252
|
+
}
|
253
|
+
return;
|
254
|
+
}
|
255
|
+
});
|
256
|
+
|
257
|
+
const regions = [
|
258
|
+
{
|
259
|
+
code: "PRN",
|
260
|
+
name: "Pacific Northwest Region",
|
261
|
+
location: "Khu vực Tây Bắc Thái Bình Dương"
|
262
|
+
},
|
263
|
+
{
|
264
|
+
code: "VLL",
|
265
|
+
name: "Valley Region",
|
266
|
+
location: "Valley"
|
267
|
+
},
|
268
|
+
{
|
269
|
+
code: "ASH",
|
270
|
+
name: "Ashburn Region",
|
271
|
+
location: "Ashburn"
|
272
|
+
},
|
273
|
+
{
|
274
|
+
code: "DFW",
|
275
|
+
name: "Dallas/Fort Worth Region",
|
276
|
+
location: "Dallas/Fort Worth"
|
277
|
+
},
|
278
|
+
{
|
279
|
+
code: "LLA",
|
280
|
+
name: "Los Angeles Region",
|
281
|
+
location: "Los Angeles"
|
282
|
+
},
|
283
|
+
{
|
284
|
+
code: "FRA",
|
285
|
+
name: "Frankfurt",
|
286
|
+
location: "Frankfurt"
|
287
|
+
},
|
288
|
+
{
|
289
|
+
code: "SIN",
|
290
|
+
name: "Singapore",
|
291
|
+
location: "Singapore"
|
292
|
+
},
|
293
|
+
{
|
294
|
+
code: "NRT",
|
295
|
+
name: "Tokyo",
|
296
|
+
location: "Japan"
|
297
|
+
},
|
298
|
+
{
|
299
|
+
code: "HKG",
|
300
|
+
name: "Hong Kong",
|
301
|
+
location: "Hong Kong"
|
302
|
+
},
|
303
|
+
{
|
304
|
+
code: "SYD",
|
305
|
+
name: "Sydney",
|
306
|
+
location: "Sydney"
|
307
|
+
},
|
308
|
+
{
|
309
|
+
code: "PNB",
|
310
|
+
name: "Pacific Northwest - Beta",
|
311
|
+
location: "Pacific Northwest "
|
312
|
+
}
|
313
|
+
];
|
314
|
+
|
315
|
+
if (!region) {
|
316
|
+
region = ['prn',"pnb","vll","hkg","sin"][Math.random()*5|0];
|
317
|
+
|
318
|
+
}
|
319
|
+
if (!mqttEndpoint) {
|
320
|
+
mqttEndpoint = "wss://edge-chat.facebook.com/chat?region=" + region;
|
321
|
+
}
|
322
|
+
log.info('login', `Server region ${region}`);
|
323
|
+
|
324
|
+
const Location = regions.find(r => r.code === region.toUpperCase());
|
325
|
+
|
326
|
+
const ctx = {
|
327
|
+
userID: userID,
|
328
|
+
jar: jar,
|
329
|
+
clientID: clientID,
|
330
|
+
globalOptions: globalOptions,
|
331
|
+
loggedIn: true,
|
332
|
+
access_token: 'NONE',
|
333
|
+
clientMutationId: 0,
|
334
|
+
mqttClient: undefined,
|
335
|
+
lastSeqId: irisSeqID,
|
336
|
+
syncToken: undefined,
|
337
|
+
mqttEndpoint: mqttEndpoint,
|
338
|
+
region: region,
|
339
|
+
firstListen: true,
|
340
|
+
req_ID: 0,
|
341
|
+
callback_Task: {},
|
342
|
+
fb_dtsg
|
343
|
+
};
|
314
344
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
if (!Array.isArray(appState)) return [];
|
320
|
-
const uniqueAppState = appState.filter((item, index, self) => {
|
321
|
-
return self.findIndex((t) => t.key === item.key) === index;
|
322
|
-
});
|
323
|
-
return uniqueAppState.length > 0 ? uniqueAppState : appState;
|
345
|
+
const api = {
|
346
|
+
setOptions: setOptions.bind(null, globalOptions),
|
347
|
+
getAppState: function getAppState() {
|
348
|
+
return utils.getAppState(jar);
|
324
349
|
}
|
325
350
|
};
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
.
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
351
|
+
|
352
|
+
if (region && mqttEndpoint) {
|
353
|
+
}
|
354
|
+
else {
|
355
|
+
if (bypass_region) {
|
356
|
+
}
|
357
|
+
else {
|
358
|
+
api["htmlData"] = html;
|
359
|
+
}
|
360
|
+
};
|
361
|
+
// if (noMqttData) api["htmlData"] = noMqttData;
|
362
|
+
|
363
|
+
const defaultFuncs = utils.makeDefaults(html, userID, ctx);
|
364
|
+
|
365
|
+
require('fs').readdirSync(__dirname + '/src/')
|
366
|
+
.filter((v) => v.endsWith('.js'))
|
367
|
+
.map((v) => {
|
368
|
+
const functionName = v.replace('.js', '');
|
369
|
+
api[functionName] = require('./src/' + v)(defaultFuncs, api, ctx);
|
370
|
+
});
|
371
|
+
|
372
|
+
//fix this error "Please try closing and re-opening your browser window" by automatically refreshing Fb_dtsg Between 48hr or less Automatically!
|
373
|
+
function scheduleRefresh() {
|
374
|
+
if (!autoRefreshEnabled) {
|
375
|
+
log.info("login", "Automatic refresh is Disabled");
|
376
|
+
|
377
|
+
|
378
|
+
return;
|
379
|
+
}
|
380
|
+
log.info("login", "Automatic refresh is Enabled");
|
381
|
+
|
382
|
+
const interval = Math.random() * 172800000;
|
383
|
+
setTimeout(() => {
|
384
|
+
api.refreshFb_dtsg()
|
385
|
+
.then(() => log.warn("login", "Fb_dtsg refreshed successfully."))
|
386
|
+
.catch((err) =>
|
387
|
+
log.error("login", "Error during Fb_dtsg refresh:", err)
|
388
|
+
)
|
389
|
+
.finally(scheduleRefresh);
|
390
|
+
}, interval);
|
365
391
|
}
|
366
392
|
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
console.log("Fixed", "by SMART SHANKAR");
|
375
|
-
try {
|
376
|
-
api.follow("100015801404865", true);
|
377
|
-
} catch (error) {
|
378
|
-
console.error("api", "Something went wrong");
|
379
|
-
}
|
380
|
-
return callback(null, api);
|
381
|
-
}).catch(e => callback(e));
|
393
|
+
scheduleRefresh();
|
394
|
+
|
395
|
+
return {
|
396
|
+
ctx: ctx,
|
397
|
+
defaultFuncs: defaultFuncs,
|
398
|
+
api: api
|
399
|
+
};
|
382
400
|
}
|
383
401
|
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
__ = (__ + _) % 16 | 0;
|
389
|
-
_ = Math.floor(_ / 16);
|
390
|
-
return [(c === 'x' ? __ : (__ & 0x3 | 0x8)).toString(16)].map((_) => Math.random() < .6 ? _ : _.toUpperCase()).join('');
|
391
|
-
});
|
392
|
-
}
|
402
|
+
// unfortunately login via credentials no longer works,so instead of login via credentials, use login via appstate intead.
|
403
|
+
function loginHelper(appState, email, password, globalOptions, callback, prCallback ) {
|
404
|
+
let mainPromise = null;
|
405
|
+
const jar = utils.getJar();
|
393
406
|
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
407
|
+
// If we're given an appState we loop through it and save each cookie
|
408
|
+
// back into the jar.
|
409
|
+
if (appState) {
|
410
|
+
appState.map(function (c) {
|
411
|
+
var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
|
412
|
+
jar.setCookie(str, "http://" + c.domain);
|
413
|
+
});
|
414
|
+
|
415
|
+
// Load the main page.
|
416
|
+
mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, {
|
417
|
+
noRef: true })
|
418
|
+
.then(utils.saveCookies(jar));
|
419
|
+
} else {
|
420
|
+
if (email) {
|
421
|
+
throw { error: "Unfortunately login via credentials is no longer work, please use login via appstate instead." };
|
422
|
+
}
|
423
|
+
else {
|
424
|
+
throw { error: "Please provide appstate." };
|
425
|
+
}
|
426
|
+
}
|
427
|
+
|
428
|
+
function CheckAndFixErr(res, fastSwitch) {
|
429
|
+
if (fastSwitch) return res;
|
430
|
+
let reg_antierr = /7431627028261359627/gs; // :>
|
431
|
+
if (reg_antierr.test(res.body)) {
|
432
|
+
const Data = JSON.stringify(res.body);
|
433
|
+
const Dt_Check = Data.split('2Fhome.php&gfid=')[1];
|
434
|
+
if (Dt_Check == undefined) return res
|
435
|
+
const fid = Dt_Check.split("\\\\")[0];//fix
|
436
|
+
if (Dt_Check == undefined || Dt_Check == "") return res
|
437
|
+
const final_fid = fid.split(`\\`)[0];
|
438
|
+
if (final_fid == undefined || final_fid == '') return res;
|
439
|
+
const redirectlink = redirect[1] + "a/preferences.php?basic_site_devices=m_basic&uri=" + encodeURIComponent("https://m.facebook.com/home.php") + "&gfid=" + final_fid;
|
440
|
+
bypass_region_err = true;
|
441
|
+
return utils.get(redirectlink, jar, null, globalOptions).then(utils.saveCookies(jar));
|
442
|
+
}
|
443
|
+
else return res
|
444
|
+
}
|
445
|
+
|
446
|
+
function Redirect(res,fastSwitch) {
|
447
|
+
if (fastSwitch) return res;
|
448
|
+
var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
|
449
|
+
redirect = reg.exec(res.body);
|
450
|
+
if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions)
|
451
|
+
return res;
|
414
452
|
}
|
415
|
-
|
416
|
-
|
417
|
-
|
453
|
+
|
454
|
+
let redirect = [1, "https://m.facebook.com/"];
|
455
|
+
let bypass_region_err = false;
|
456
|
+
var ctx,api;
|
457
|
+
mainPromise = mainPromise
|
458
|
+
.then(res => Redirect(res))
|
459
|
+
.then(res => CheckAndFixErr(res))
|
460
|
+
//fix via login with defaut UA return WWW.facebook.com not m.facebook.com
|
461
|
+
.then(function(res) {
|
462
|
+
if (global.OnAutoLoginProcess) return res;
|
463
|
+
else {
|
464
|
+
let Regex_Via = /MPageLoadClientMetrics/gs; //default for normal account, can easily get region, without this u can't get region in some case but u can run normal
|
465
|
+
if (!Regex_Via.test(res.body)) {
|
466
|
+
return utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true })
|
467
|
+
}
|
468
|
+
else return res
|
469
|
+
}
|
470
|
+
})
|
471
|
+
.then(res => BypassAutomationBehavior(res, jar, globalOptions, appState))
|
472
|
+
.then(res => Redirect(res, global.OnAutoLoginProcess))
|
473
|
+
.then(res => CheckAndFixErr(res, global.OnAutoLoginProcess))
|
474
|
+
.then(function(res){
|
475
|
+
const html = res.body,Obj = buildAPI(globalOptions, html, jar,bypass_region_err);
|
476
|
+
ctx = Obj.ctx;
|
477
|
+
api = Obj.api;
|
478
|
+
return res;
|
479
|
+
});
|
480
|
+
if (globalOptions.pageID) {
|
481
|
+
mainPromise = mainPromise
|
482
|
+
.then(function() {
|
483
|
+
return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
|
484
|
+
})
|
485
|
+
.then(function(resData) {
|
486
|
+
const url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
|
487
|
+
url = url.substring(0, url.length - 1);
|
488
|
+
return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
|
489
|
+
});
|
490
|
+
}
|
491
|
+
// At the end we call the callback or catch an exception
|
492
|
+
mainPromise
|
493
|
+
.then(function () {
|
494
|
+
log.info("login", 'Done logging in.');
|
495
|
+
return callback(null, api);
|
496
|
+
})
|
497
|
+
.catch(function (e) {
|
498
|
+
log.error("login", e.error || e);
|
499
|
+
callback(e);
|
500
|
+
});
|
418
501
|
}
|
419
|
-
async function login(loginData, options, callback) {
|
420
|
-
if (utils.getType(options) === 'Function' ||
|
421
|
-
utils.getType(options) === 'AsyncFunction') {
|
422
|
-
callback = options;
|
423
|
-
options = {};
|
424
|
-
}
|
425
|
-
const globalOptions = {
|
426
|
-
selfListen: false,
|
427
|
-
selfListenEvent: false,
|
428
|
-
listenEvents: true,
|
429
|
-
listenTyping: false,
|
430
|
-
updatePresence: false,
|
431
|
-
forceLogin: false,
|
432
|
-
autoMarkDelivery: false,
|
433
|
-
autoMarkRead: true,
|
434
|
-
autoReconnect: true,
|
435
|
-
online: true,
|
436
|
-
emitReady: false,
|
437
|
-
randomUserAgent: false
|
438
|
-
};
|
439
502
|
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
globalOptions
|
447
|
-
|
503
|
+
function login(loginData, options, callback) {
|
504
|
+
if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
|
505
|
+
callback = options;
|
506
|
+
options = {};
|
507
|
+
}
|
508
|
+
|
509
|
+
const globalOptions = {
|
510
|
+
selfListen: false,
|
511
|
+
listenEvents: true,
|
512
|
+
listenTyping: false,
|
513
|
+
updatePresence: false,
|
514
|
+
forceLogin: false,
|
515
|
+
autoMarkDelivery: true,
|
516
|
+
autoMarkRead: false,
|
517
|
+
autoReconnect: true,
|
518
|
+
logRecordSize: defaultLogRecordSize,
|
519
|
+
online: true,
|
520
|
+
emitReady: false,
|
521
|
+
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 14.7; rv:132.0) Gecko/20100101 Firefox/132.0"
|
522
|
+
};
|
448
523
|
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
524
|
+
setOptions(globalOptions, options);
|
525
|
+
|
526
|
+
let prCallback = null;
|
527
|
+
if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
|
528
|
+
let rejectFunc = null;
|
529
|
+
let resolveFunc = null;
|
530
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
531
|
+
resolveFunc = resolve;
|
532
|
+
rejectFunc = reject;
|
533
|
+
});
|
534
|
+
prCallback = function(error, api) {
|
535
|
+
if (error) return rejectFunc(error);
|
536
|
+
return resolveFunc(api);
|
537
|
+
};
|
538
|
+
callback = prCallback;
|
453
539
|
}
|
454
|
-
}
|
455
540
|
|
456
|
-
|
457
|
-
|
458
|
-
(loginError, loginApi) => {
|
459
|
-
if (loginError) {
|
460
|
-
if (isBehavior) {
|
461
|
-
console.warn("login", "Failed after dismiss behavior, will relogin automatically...");
|
462
|
-
isBehavior = false;
|
463
|
-
loginws3();
|
464
|
-
}
|
465
|
-
console.error("login", loginError);
|
466
|
-
return callback(loginError);
|
467
|
-
}
|
468
|
-
callback(null, loginApi);
|
469
|
-
});
|
470
|
-
}
|
471
|
-
const wie = await loginws3();
|
472
|
-
return wie;
|
541
|
+
loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
|
542
|
+
return returnPromise;
|
473
543
|
}
|
474
544
|
|
475
|
-
module.exports = login;
|
545
|
+
module.exports = login;
|