alicezetion 1.1.0 → 1.1.2
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/.cache/replit/__replit_disk_meta.json +1 -1
- package/.cache/replit/nix/env.json +1 -1
- package/index.js +556 -490
- package/leiamnash/addExternalModule.js +19 -0
- package/{src → leiamnash}/addUserToGroup.js +52 -16
- package/leiamnash/changeAdminStatus.js +79 -0
- package/leiamnash/changeArchivedStatus.js +55 -0
- package/{src → leiamnash}/changeBio.js +19 -6
- package/{src → leiamnash}/changeBlockedStatus.js +14 -3
- package/{src → leiamnash}/changeGroupImage.js +40 -16
- package/leiamnash/changeNickname.js +59 -0
- package/{src → leiamnash}/changeThreadColor.js +20 -10
- package/leiamnash/changeThreadEmoji.js +55 -0
- package/leiamnash/chat.js +459 -0
- package/{src → leiamnash}/createNewGroup.js +28 -12
- package/{src → leiamnash}/createPoll.js +25 -13
- package/leiamnash/deleteMessage.js +56 -0
- package/leiamnash/deleteThread.js +56 -0
- package/leiamnash/forwardAttachment.js +60 -0
- package/{src → leiamnash}/getCurrentUserID.js +1 -1
- package/{src → leiamnash}/getEmojiUrl.js +4 -2
- package/{src → leiamnash}/getFriendsList.js +21 -10
- package/{src → leiamnash}/getThreadHistory.js +166 -58
- package/{src → leiamnash}/getThreadHistoryDeprecated.js +42 -20
- package/{src → leiamnash}/getThreadInfo.js +60 -25
- package/leiamnash/getThreadInfoDeprecated.js +80 -0
- package/{src → leiamnash}/getThreadList.js +66 -41
- package/leiamnash/getThreadListDeprecated.js +75 -0
- package/leiamnash/getThreadPictures.js +79 -0
- package/{src → leiamnash}/getUserID.js +14 -9
- package/{src → leiamnash}/getUserInfo.js +1 -1
- package/leiamnash/handleFriendRequest.js +61 -0
- package/leiamnash/handleMessageRequest.js +65 -0
- package/{src → leiamnash}/httpGet.js +17 -12
- package/{src → leiamnash}/httpPost.js +17 -12
- package/leiamnash/listenMqtt.js +687 -0
- package/{src → leiamnash}/logout.js +20 -13
- package/{src → leiamnash}/markAsDelivered.js +22 -11
- package/{src → leiamnash}/markAsRead.js +21 -11
- package/{src → leiamnash}/markAsReadAll.js +20 -10
- package/{src → leiamnash}/markAsSeen.js +18 -7
- package/{src → leiamnash}/muteThread.js +18 -11
- package/leiamnash/removeUserFromGroup.js +79 -0
- package/{src → leiamnash}/resolvePhotoUrl.js +17 -8
- package/{src → leiamnash}/searchForThread.js +21 -10
- package/{src → leiamnash}/sendTypingIndicator.js +47 -14
- package/{src → leiamnash}/setMessageReaction.js +26 -12
- package/{src → leiamnash}/setPostReaction.js +26 -13
- package/{src → leiamnash}/setTitle.js +29 -13
- package/leiamnash/threadColors.js +57 -0
- package/{src → leiamnash}/unfriend.js +19 -9
- package/{src → leiamnash}/unsendMessage.js +19 -9
- package/package.json +9 -14
- package/replit.nix +0 -1
- package/utils.js +1193 -1023
- package/src/addExternalModule.js +0 -15
- package/src/changeAdminStatus.js +0 -47
- package/src/changeArchivedStatus.js +0 -41
- package/src/changeNickname.js +0 -43
- package/src/changeThreadEmoji.js +0 -41
- package/src/chat.js +0 -315
- package/src/deleteMessage.js +0 -44
- package/src/deleteThread.js +0 -42
- package/src/forwardAttachment.js +0 -47
- package/src/forwardMessage.js +0 -0
- package/src/getThreadInfoDeprecated.js +0 -56
- package/src/getThreadListDeprecated.js +0 -46
- package/src/getThreadPictures.js +0 -59
- package/src/handleFriendRequest.js +0 -46
- package/src/handleMessageRequest.js +0 -47
- package/src/listen.js +0 -553
- package/src/listenMqtt-Test.js +0 -687
- package/src/listenMqtt.js +0 -677
- package/src/removeUserFromGroup.js +0 -45
- package/src/threadColors.js +0 -41
package/index.js
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
-
/*
|
2
|
-
|
1
|
+
/*
|
2
|
+
|
3
|
+
A L I C E » this project recode by one
|
4
|
+
person LeiamNash
|
5
|
+
this will only work on
|
6
|
+
project alice
|
7
|
+
|
3
8
|
*/
|
4
9
|
|
5
10
|
"use strict";
|
@@ -14,523 +19,584 @@ var defaultLogRecordSize = 100;
|
|
14
19
|
log.maxRecordSize = defaultLogRecordSize;
|
15
20
|
|
16
21
|
function setOptions(globalOptions, options) {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
} else {
|
65
|
-
globalOptions.proxy = options.proxy;
|
66
|
-
utils.setProxy(globalOptions.proxy);
|
67
|
-
}
|
68
|
-
break;
|
69
|
-
case 'autoReconnect':
|
70
|
-
globalOptions.autoReconnect = Boolean(options.autoReconnect);
|
71
|
-
break;
|
72
|
-
case 'emitReady':
|
73
|
-
globalOptions.emitReady = Boolean(options.emitReady);
|
74
|
-
break;
|
75
|
-
default:
|
76
|
-
log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
|
77
|
-
break;
|
22
|
+
Object.keys(options).map(function (key) {
|
23
|
+
switch (key) {
|
24
|
+
case 'online':
|
25
|
+
globalOptions.online = Boolean(options.online);
|
26
|
+
break;
|
27
|
+
case 'logLevel':
|
28
|
+
log.level = options.logLevel;
|
29
|
+
globalOptions.logLevel = options.logLevel;
|
30
|
+
break;
|
31
|
+
case 'logRecordSize':
|
32
|
+
log.maxRecordSize = options.logRecordSize;
|
33
|
+
globalOptions.logRecordSize = options.logRecordSize;
|
34
|
+
break;
|
35
|
+
case 'selfListen':
|
36
|
+
globalOptions.selfListen = Boolean(options.selfListen);
|
37
|
+
break;
|
38
|
+
case 'listenEvents':
|
39
|
+
globalOptions.listenEvents = Boolean(options.listenEvents);
|
40
|
+
break;
|
41
|
+
case 'pageID':
|
42
|
+
globalOptions.pageID = options.pageID.toString();
|
43
|
+
break;
|
44
|
+
case 'updatePresence':
|
45
|
+
globalOptions.updatePresence = Boolean(options.updatePresence);
|
46
|
+
break;
|
47
|
+
case 'forceLogin':
|
48
|
+
globalOptions.forceLogin = Boolean(options.forceLogin);
|
49
|
+
break;
|
50
|
+
case 'userAgent':
|
51
|
+
globalOptions.userAgent = options.userAgent;
|
52
|
+
break;
|
53
|
+
case 'autoMarkDelivery':
|
54
|
+
globalOptions.autoMarkDelivery = Boolean(options.autoMarkDelivery);
|
55
|
+
break;
|
56
|
+
case 'autoMarkRead':
|
57
|
+
globalOptions.autoMarkRead = Boolean(options.autoMarkRead);
|
58
|
+
break;
|
59
|
+
case 'listenTyping':
|
60
|
+
globalOptions.listenTyping = Boolean(options.listenTyping);
|
61
|
+
break;
|
62
|
+
case 'proxy':
|
63
|
+
if (typeof options.proxy != "string") {
|
64
|
+
delete globalOptions.proxy;
|
65
|
+
utils.setProxy();
|
66
|
+
} else {
|
67
|
+
globalOptions.proxy = options.proxy;
|
68
|
+
utils.setProxy(globalOptions.proxy);
|
78
69
|
}
|
79
|
-
|
70
|
+
break;
|
71
|
+
case 'autoReconnect':
|
72
|
+
globalOptions.autoReconnect = Boolean(options.autoReconnect);
|
73
|
+
break;
|
74
|
+
case 'emitReady':
|
75
|
+
globalOptions.emitReady = Boolean(options.emitReady);
|
76
|
+
break;
|
77
|
+
default:
|
78
|
+
log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
|
79
|
+
break;
|
80
|
+
}
|
81
|
+
});
|
80
82
|
}
|
81
83
|
|
82
84
|
function buildAPI(globalOptions, html, jar) {
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
85
|
+
var maybeCookie = jar.getCookies("https://www.facebook.com").filter(function (val) {
|
86
|
+
return val.cookieString().split("=")[0] === "c_user";
|
87
|
+
});
|
88
|
+
|
89
|
+
if (maybeCookie.length === 0) {
|
90
|
+
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." };
|
91
|
+
}
|
92
|
+
|
93
|
+
if (html.indexOf("/checkpoint/block/?next") > -1) {
|
94
|
+
log.warn("login", "Checkpoint detected. Please log in with a browser to verify.");
|
95
|
+
}
|
96
|
+
|
97
|
+
var userID = maybeCookie[0].cookieString().split("=")[1].toString();
|
98
|
+
|
99
|
+
try {
|
100
|
+
clearInterval(checkVerified);
|
101
|
+
} catch (_) { }
|
102
|
+
|
103
|
+
var clientID = (Math.random() * 2147483648 | 0).toString(16);
|
104
|
+
|
105
|
+
|
106
|
+
let oldFBMQTTMatch = html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/);
|
107
|
+
let mqttEndpoint = null;
|
108
|
+
let region = null;
|
109
|
+
let irisSeqID = null;
|
110
|
+
var noMqttData = null;
|
111
|
+
|
112
|
+
if (oldFBMQTTMatch) {
|
113
|
+
irisSeqID = oldFBMQTTMatch[1];
|
114
|
+
mqttEndpoint = oldFBMQTTMatch[2];
|
115
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
116
|
+
} else {
|
117
|
+
let newFBMQTTMatch = html.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/);
|
118
|
+
if (newFBMQTTMatch) {
|
119
|
+
irisSeqID = newFBMQTTMatch[2];
|
120
|
+
mqttEndpoint = newFBMQTTMatch[1].replace(/\\\//g, "/");
|
121
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
111
122
|
} else {
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
123
|
+
let legacyFBMQTTMatch = html.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/);
|
124
|
+
if (legacyFBMQTTMatch) {
|
125
|
+
mqttEndpoint = legacyFBMQTTMatch[4];
|
126
|
+
region = new URL(mqttEndpoint).searchParams.get("region").toUpperCase();
|
127
|
+
} else {
|
128
|
+
noMqttData = html;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
// All data available to api functions
|
134
|
+
var ctx = {
|
135
|
+
userID: userID,
|
136
|
+
jar: jar,
|
137
|
+
clientID: clientID,
|
138
|
+
globalOptions: globalOptions,
|
139
|
+
loggedIn: true,
|
140
|
+
access_token: 'NONE',
|
141
|
+
clientMutationId: 0,
|
142
|
+
mqttClient: undefined,
|
143
|
+
lastSeqId: irisSeqID,
|
144
|
+
syncToken: undefined,
|
145
|
+
mqttEndpoint,
|
146
|
+
region,
|
147
|
+
firstListen: true
|
148
|
+
};
|
149
|
+
|
150
|
+
var api = {
|
151
|
+
setOptions: setOptions.bind(null, globalOptions),
|
152
|
+
getAppState: function getAppState() {
|
153
|
+
return utils.getAppState(jar);
|
133
154
|
}
|
155
|
+
};
|
156
|
+
|
157
|
+
if (noMqttData) {
|
158
|
+
api["htmlData"] = noMqttData;
|
159
|
+
}
|
160
|
+
|
161
|
+
const apiFuncNames = [
|
162
|
+
'addExternalModule',
|
163
|
+
'addUserToGroup',
|
164
|
+
'changeAdminStatus',
|
165
|
+
'changeArchivedStatus',
|
166
|
+
'changeBio',
|
167
|
+
'changeBlockedStatus',
|
168
|
+
'changeGroupImage',
|
169
|
+
'changeNickname',
|
170
|
+
'changeThreadColor',
|
171
|
+
'changeThreadEmoji',
|
172
|
+
'createNewGroup',
|
173
|
+
'createPoll',
|
174
|
+
'deleteMessage',
|
175
|
+
'deleteThread',
|
176
|
+
'forwardAttachment',
|
177
|
+
'getCurrentUserID',
|
178
|
+
'getEmojiUrl',
|
179
|
+
'getFriendsList',
|
180
|
+
'getThreadHistory',
|
181
|
+
'getThreadInfo',
|
182
|
+
'getThreadList',
|
183
|
+
'getThreadPictures',
|
184
|
+
'getUserID',
|
185
|
+
'getUserInfo',
|
186
|
+
'handleMessageRequest',
|
187
|
+
'listenMqtt',
|
188
|
+
'logout',
|
189
|
+
'markAsDelivered',
|
190
|
+
'markAsRead',
|
191
|
+
'markAsReadAll',
|
192
|
+
'markAsSeen',
|
193
|
+
'muteThread',
|
194
|
+
'removeUserFromGroup',
|
195
|
+
'resolvePhotoUrl',
|
196
|
+
'searchForThread',
|
197
|
+
'chat',
|
198
|
+
'sendTypingIndicator',
|
199
|
+
'setMessageReaction',
|
200
|
+
'setTitle',
|
201
|
+
'threadColors',
|
202
|
+
'unsendMessage',
|
203
|
+
|
204
|
+
// HTTP
|
205
|
+
'httpGet',
|
206
|
+
'httpPost',
|
207
|
+
|
208
|
+
// Deprecated features
|
209
|
+
"getThreadListDeprecated",
|
210
|
+
'getThreadHistoryDeprecated',
|
211
|
+
'getThreadInfoDeprecated',
|
212
|
+
];
|
213
|
+
|
214
|
+
var defaultFuncs = utils.makeDefaults(html, userID, ctx);
|
215
|
+
|
216
|
+
// Load all api functions in a loop
|
217
|
+
apiFuncNames.map(function (v) {
|
218
|
+
api[v] = require('./leiamnash/' + v)(defaultFuncs, api, ctx);
|
219
|
+
});
|
220
|
+
|
221
|
+
//Removing original `listen` that uses pull.
|
222
|
+
//Map it to listenMqtt instead for backward compatibly.
|
223
|
+
api.listen = api.listenMqtt;
|
224
|
+
|
225
|
+
return [ctx, defaultFuncs, api];
|
226
|
+
}
|
134
227
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
lastSeqId: irisSeqID,
|
146
|
-
syncToken: undefined,
|
147
|
-
mqttEndpoint,
|
148
|
-
region,
|
149
|
-
firstListen: true
|
150
|
-
};
|
228
|
+
function makeLogin(jar, email, password, loginOptions, callback, prCallback) {
|
229
|
+
return function (res) {
|
230
|
+
var html = res.body;
|
231
|
+
var $ = cheerio.load(html);
|
232
|
+
var arr = [];
|
233
|
+
|
234
|
+
// This will be empty, but just to be sure we leave it
|
235
|
+
$("#login_form input").map(function (i, v) {
|
236
|
+
arr.push({ val: $(v).val(), name: $(v).attr("name") });
|
237
|
+
});
|
151
238
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
239
|
+
arr = arr.filter(function (v) {
|
240
|
+
return v.val && v.val.length;
|
241
|
+
});
|
242
|
+
|
243
|
+
var form = utils.arrToForm(arr);
|
244
|
+
form.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
|
245
|
+
form.lgndim = Buffer.from("{\"w\":1440,\"h\":900,\"aw\":1440,\"ah\":834,\"c\":24}").toString('base64');
|
246
|
+
form.email = email;
|
247
|
+
form.pass = password;
|
248
|
+
form.default_persistent = '0';
|
249
|
+
form.lgnrnd = utils.getFrom(html, "name=\"lgnrnd\" value=\"", "\"");
|
250
|
+
form.locale = 'en_PH';
|
251
|
+
form.timezone = '240';
|
252
|
+
form.lgnjs = ~~(Date.now() / 1000);
|
253
|
+
|
254
|
+
|
255
|
+
// Getting cookies from the HTML page... (kill me now plz)
|
256
|
+
// we used to get a bunch of cookies in the headers of the response of the
|
257
|
+
// request, but FB changed and they now send those cookies inside the JS.
|
258
|
+
// They run the JS which then injects the cookies in the page.
|
259
|
+
// The "solution" is to parse through the html and find those cookies
|
260
|
+
// which happen to be conveniently indicated with a _js_ in front of their
|
261
|
+
// variable name.
|
262
|
+
//
|
263
|
+
// ---------- Very Hacky Part Starts -----------------
|
264
|
+
var willBeCookies = html.split("\"_js_");
|
265
|
+
willBeCookies.slice(1).map(function (val) {
|
266
|
+
var cookieData = JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]");
|
267
|
+
jar.setCookie(utils.formatCookie(cookieData, "facebook"), "https://www.facebook.com");
|
268
|
+
});
|
269
|
+
// ---------- Very Hacky Part Ends -----------------
|
270
|
+
return utils
|
271
|
+
.post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
|
272
|
+
.then(utils.saveCookies(jar))
|
273
|
+
.then(function (res) {
|
274
|
+
var headers = res.headers;
|
275
|
+
if (!headers.location) {
|
276
|
+
throw { error: "Wrong username/password." };
|
156
277
|
}
|
157
|
-
};
|
158
278
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
'addUserToGroup',
|
164
|
-
'changeAdminStatus',
|
165
|
-
'changeArchivedStatus',
|
166
|
-
'changeBio',
|
167
|
-
'changeBlockedStatus',
|
168
|
-
'changeGroupImage',
|
169
|
-
'changeNickname',
|
170
|
-
'changeThreadColor',
|
171
|
-
'changeThreadEmoji',
|
172
|
-
'chat',
|
173
|
-
'createNewGroup',
|
174
|
-
'createPoll',
|
175
|
-
'deleteMessage',
|
176
|
-
'deleteThread',
|
177
|
-
'forwardAttachment',
|
178
|
-
'getCurrentUserID',
|
179
|
-
'getEmojiUrl',
|
180
|
-
'getFriendsList',
|
181
|
-
'getThreadHistory',
|
182
|
-
'getThreadInfo',
|
183
|
-
'getThreadList',
|
184
|
-
'getThreadPictures',
|
185
|
-
'getUserID',
|
186
|
-
'getUserInfo',
|
187
|
-
'handleFriendRequest',
|
188
|
-
'handleMessageRequest',
|
189
|
-
'listenMqtt',
|
190
|
-
'logout',
|
191
|
-
'markAsDelivered',
|
192
|
-
'markAsRead',
|
193
|
-
'markAsReadAll',
|
194
|
-
'markAsSeen',
|
195
|
-
'muteThread',
|
196
|
-
'removeUserFromGroup',
|
197
|
-
'resolvePhotoUrl',
|
198
|
-
'searchForThread',
|
199
|
-
'sendTypingIndicator',
|
200
|
-
'setMessageReaction',
|
201
|
-
'setTitle',
|
202
|
-
'threadColors',
|
203
|
-
'unsendMessage',
|
204
|
-
'unfriend',
|
205
|
-
|
206
|
-
// HTTP
|
207
|
-
'httpGet',
|
208
|
-
'httpPost',
|
209
|
-
|
210
|
-
// Deprecated features
|
211
|
-
"getThreadListDeprecated",
|
212
|
-
'getThreadHistoryDeprecated',
|
213
|
-
'getThreadInfoDeprecated',
|
214
|
-
];
|
215
|
-
|
216
|
-
var defaultFuncs = utils.makeDefaults(html, userID, ctx);
|
217
|
-
|
218
|
-
// Load all api functions in a loop
|
219
|
-
apiFuncNames.map(v => api[v] = require('./src/' + v)(defaultFuncs, api, ctx));
|
220
|
-
|
221
|
-
return [ctx, defaultFuncs, api];
|
222
|
-
}
|
279
|
+
// This means the account has login approvals turned on.
|
280
|
+
if (headers.location.indexOf('https://www.facebook.com/checkpoint/') > -1) {
|
281
|
+
log.info("login", "You have login approvals turned on.");
|
282
|
+
var nextURL = 'https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php';
|
223
283
|
|
224
|
-
|
225
|
-
|
226
|
-
var html = res.body;
|
227
|
-
var $ = cheerio.load(html);
|
228
|
-
var arr = [];
|
229
|
-
|
230
|
-
// This will be empty, but just to be sure we leave it
|
231
|
-
$("#login_form input").map((i, v) => arr.push({ val: $(v).val(), name: $(v).attr("name") }));
|
232
|
-
|
233
|
-
arr = arr.filter(function(v) {
|
234
|
-
return v.val && v.val.length;
|
235
|
-
});
|
236
|
-
|
237
|
-
var form = utils.arrToForm(arr);
|
238
|
-
form.lsd = utils.getFrom(html, "[\"LSD\",[],{\"token\":\"", "\"}");
|
239
|
-
form.lgndim = Buffer.from("{\"w\":1440,\"h\":900,\"aw\":1440,\"ah\":834,\"c\":24}").toString('base64');
|
240
|
-
form.email = email;
|
241
|
-
form.pass = password;
|
242
|
-
form.default_persistent = '0';
|
243
|
-
form.lgnrnd = utils.getFrom(html, "name=\"lgnrnd\" value=\"", "\"");
|
244
|
-
form.locale = 'en_US';
|
245
|
-
form.timezone = '240';
|
246
|
-
form.lgnjs = ~~(Date.now() / 1000);
|
247
|
-
|
248
|
-
|
249
|
-
// Getting cookies from the HTML page... (kill me now plz)
|
250
|
-
// we used to get a bunch of cookies in the headers of the response of the
|
251
|
-
// request, but FB changed and they now send those cookies inside the JS.
|
252
|
-
// They run the JS which then injects the cookies in the page.
|
253
|
-
// The "solution" is to parse through the html and find those cookies
|
254
|
-
// which happen to be conveniently indicated with a _js_ in front of their
|
255
|
-
// variable name.
|
256
|
-
//
|
257
|
-
// ---------- Very Hacky Part Starts -----------------
|
258
|
-
var willBeCookies = html.split("\"_js_");
|
259
|
-
willBeCookies.slice(1).map(function(val) {
|
260
|
-
var cookieData = JSON.parse("[\"" + utils.getFrom(val, "", "]") + "]");
|
261
|
-
jar.setCookie(utils.formatCookie(cookieData, "facebook"), "https://www.facebook.com");
|
262
|
-
});
|
263
|
-
// ---------- Very Hacky Part Ends -----------------
|
264
|
-
|
265
|
-
log.info("login", "Logging in...");
|
266
|
-
return utils
|
267
|
-
.post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110", jar, form, loginOptions)
|
284
|
+
return utils
|
285
|
+
.get(headers.location, jar, null, loginOptions)
|
268
286
|
.then(utils.saveCookies(jar))
|
269
|
-
.then(function(res) {
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
287
|
+
.then(function (res) {
|
288
|
+
var html = res.body;
|
289
|
+
// Make the form in advance which will contain the fb_dtsg and nh
|
290
|
+
var $ = cheerio.load(html);
|
291
|
+
var arr = [];
|
292
|
+
$("form input").map(function (i, v) {
|
293
|
+
arr.push({ val: $(v).val(), name: $(v).attr("name") });
|
294
|
+
});
|
295
|
+
|
296
|
+
arr = arr.filter(function (v) {
|
297
|
+
return v.val && v.val.length;
|
298
|
+
});
|
299
|
+
|
300
|
+
var form = utils.arrToForm(arr);
|
301
|
+
if (html.indexOf("checkpoint/?next") > -1) {
|
302
|
+
setTimeout(() => {
|
303
|
+
checkVerified = setInterval((_form) => {
|
304
|
+
/* utils
|
305
|
+
.post("https://www.facebook.com/login/approvals/approved_machine_check/", jar, form, loginOptions, null, {
|
306
|
+
"Referer": "https://www.facebook.com/checkpoint/?next"
|
307
|
+
})
|
308
|
+
.then(utils.saveCookies(jar))
|
309
|
+
.then(res => {
|
310
|
+
try {
|
311
|
+
JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*()/, ""));
|
312
|
+
} catch (ex) {
|
313
|
+
clearInterval(checkVerified);
|
314
|
+
log.info("login", "Verified from browser. Logging in...");
|
315
|
+
return loginHelper(utils.getAppState(jar), email, password, loginOptions, callback);
|
316
|
+
}
|
317
|
+
})
|
318
|
+
.catch(ex => {
|
319
|
+
log.error("login", ex);
|
320
|
+
}); */
|
321
|
+
}, 5000, {
|
322
|
+
fb_dtsg: form.fb_dtsg,
|
323
|
+
jazoest: form.jazoest,
|
324
|
+
dpr: 1
|
325
|
+
});
|
326
|
+
}, 2500);
|
327
|
+
throw {
|
328
|
+
error: 'login-approval',
|
329
|
+
continue: function submit2FA(code) {
|
330
|
+
form.approvals_code = code;
|
331
|
+
form['submit[Continue]'] = $("#checkpointSubmitButton").html(); //'Continue';
|
332
|
+
var prResolve = null;
|
333
|
+
var prReject = null;
|
334
|
+
var rtPromise = new Promise(function (resolve, reject) {
|
335
|
+
prResolve = resolve;
|
336
|
+
prReject = reject;
|
337
|
+
});
|
338
|
+
if (typeof code == "string") {
|
339
|
+
utils
|
340
|
+
.post(nextURL, jar, form, loginOptions)
|
341
|
+
.then(utils.saveCookies(jar))
|
342
|
+
.then(function (res) {
|
343
|
+
var $ = cheerio.load(res.body);
|
344
|
+
var error = $("#approvals_code").parent().attr("data-xui-error");
|
345
|
+
if (error) {
|
346
|
+
throw {
|
347
|
+
error: 'login-approval',
|
348
|
+
errordesc: "Invalid 2FA code.",
|
349
|
+
lerror: error,
|
350
|
+
continue: submit2FA
|
351
|
+
};
|
352
|
+
}
|
353
|
+
})
|
354
|
+
.then(function () {
|
355
|
+
// Use the same form (safe I hope)
|
356
|
+
delete form.no_fido;
|
357
|
+
delete form.approvals_code;
|
358
|
+
form.name_action_selected = 'dont_save'; //'save_device';
|
359
|
+
|
360
|
+
return utils
|
361
|
+
.post(nextURL, jar, form, loginOptions)
|
362
|
+
.then(utils.saveCookies(jar));
|
363
|
+
})
|
364
|
+
.then(function (res) {
|
365
|
+
var headers = res.headers;
|
366
|
+
if (!headers.location && res.body.indexOf('Review Recent Login') > -1) {
|
367
|
+
throw { error: "Something went wrong with login approvals." };
|
368
|
+
}
|
369
|
+
|
370
|
+
var appState = utils.getAppState(jar);
|
371
|
+
|
372
|
+
if (callback === prCallback) {
|
373
|
+
callback = function (err, api) {
|
374
|
+
if (err) {
|
375
|
+
return prReject(err);
|
376
|
+
}
|
377
|
+
return prResolve(api);
|
378
|
+
};
|
379
|
+
}
|
380
|
+
|
381
|
+
// Simply call loginHelper because all it needs is the jar
|
382
|
+
// and will then complete the login process
|
383
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
384
|
+
})
|
385
|
+
.catch(function (err) {
|
386
|
+
// Check if using Promise instead of callback
|
387
|
+
if (callback === prCallback) {
|
388
|
+
prReject(err);
|
389
|
+
} else {
|
390
|
+
callback(err);
|
391
|
+
}
|
392
|
+
});
|
393
|
+
} else {
|
394
|
+
utils
|
395
|
+
.post("https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php", jar, form, loginOptions, null, {
|
396
|
+
"Referer": "https://www.facebook.com/checkpoint/?next"
|
397
|
+
})
|
280
398
|
.then(utils.saveCookies(jar))
|
281
|
-
.then(
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
if (html.indexOf("checkpoint/?next") > -1) {
|
294
|
-
setTimeout(() => {
|
295
|
-
checkVerified = setInterval((_form) => {}, 5000, {
|
296
|
-
fb_dtsg: form.fb_dtsg,
|
297
|
-
jazoest: form.jazoest,
|
298
|
-
dpr: 1
|
299
|
-
});
|
300
|
-
}, 2500);
|
301
|
-
throw {
|
302
|
-
error: 'login-approval',
|
303
|
-
continue: function submit2FA(code) {
|
304
|
-
form.approvals_code = code;
|
305
|
-
form['submit[Continue]'] = $("#checkpointSubmitButton").html(); //'Continue';
|
306
|
-
var prResolve = null;
|
307
|
-
var prReject = null;
|
308
|
-
var rtPromise = new Promise(function(resolve, reject) {
|
309
|
-
prResolve = resolve;
|
310
|
-
prReject = reject;
|
311
|
-
});
|
312
|
-
if (typeof code == "string") {
|
313
|
-
utils
|
314
|
-
.post(nextURL, jar, form, loginOptions)
|
315
|
-
.then(utils.saveCookies(jar))
|
316
|
-
.then(function(res) {
|
317
|
-
var $ = cheerio.load(res.body);
|
318
|
-
var error = $("#approvals_code").parent().attr("data-xui-error");
|
319
|
-
if (error) {
|
320
|
-
throw {
|
321
|
-
error: 'login-approval',
|
322
|
-
errordesc: "Invalid 2FA code.",
|
323
|
-
lerror: error,
|
324
|
-
continue: submit2FA
|
325
|
-
};
|
326
|
-
}
|
327
|
-
})
|
328
|
-
.then(function() {
|
329
|
-
// Use the same form (safe I hope)
|
330
|
-
delete form.no_fido;
|
331
|
-
delete form.approvals_code;
|
332
|
-
form.name_action_selected = 'dont_save'; //'save_device';
|
333
|
-
|
334
|
-
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
335
|
-
})
|
336
|
-
.then(function(res) {
|
337
|
-
var headers = res.headers;
|
338
|
-
if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: "Something went wrong with login approvals." };
|
339
|
-
|
340
|
-
var appState = utils.getAppState(jar);
|
341
|
-
|
342
|
-
if (callback === prCallback) {
|
343
|
-
callback = function(err, api) {
|
344
|
-
if (err) return prReject(err);
|
345
|
-
return prResolve(api);
|
346
|
-
};
|
347
|
-
}
|
348
|
-
|
349
|
-
// Simply call loginHelper because all it needs is the jar
|
350
|
-
// and will then complete the login process
|
351
|
-
return loginHelper(appState, email, password, loginOptions, callback);
|
352
|
-
})
|
353
|
-
.catch(function(err) {
|
354
|
-
// Check if using Promise instead of callback
|
355
|
-
if (callback === prCallback) prReject(err);
|
356
|
-
else callback(err);
|
357
|
-
});
|
358
|
-
} else {
|
359
|
-
utils
|
360
|
-
.post("https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php", jar, form, loginOptions, null, { "Referer": "https://www.facebook.com/checkpoint/?next" })
|
361
|
-
.then(utils.saveCookies(jar))
|
362
|
-
.then(res => {
|
363
|
-
try {
|
364
|
-
JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
|
365
|
-
} catch (ex) {
|
366
|
-
clearInterval(checkVerified);
|
367
|
-
log.info("login", "Verified from browser. Logging in...");
|
368
|
-
if (callback === prCallback) {
|
369
|
-
callback = function(err, api) {
|
370
|
-
if (err) return prReject(err);
|
371
|
-
return prResolve(api);
|
372
|
-
};
|
373
|
-
}
|
374
|
-
return loginHelper(utils.getAppState(jar), email, password, loginOptions, callback);
|
375
|
-
}
|
376
|
-
})
|
377
|
-
.catch(ex => {
|
378
|
-
log.error("login", ex);
|
379
|
-
if (callback === prCallback) prReject(ex);
|
380
|
-
else callback(ex);
|
381
|
-
});
|
382
|
-
}
|
383
|
-
return rtPromise;
|
384
|
-
}
|
385
|
-
};
|
386
|
-
} else {
|
387
|
-
if (!loginOptions.forceLogin) throw { error: "Couldn't login. Facebook might have blocked this account. Please login with a browser or enable the option 'forceLogin' and try again." };
|
388
|
-
|
389
|
-
if (html.indexOf("Suspicious Login Attempt") > -1) form['submit[This was me]'] = "This was me";
|
390
|
-
else form['submit[This Is Okay]'] = "This Is Okay";
|
391
|
-
|
392
|
-
return utils
|
393
|
-
.post(nextURL, jar, form, loginOptions)
|
394
|
-
.then(utils.saveCookies(jar))
|
395
|
-
.then(function() {
|
396
|
-
// Use the same form (safe I hope)
|
397
|
-
form.name_action_selected = 'save_device';
|
398
|
-
|
399
|
-
return utils.post(nextURL, jar, form, loginOptions).then(utils.saveCookies(jar));
|
400
|
-
})
|
401
|
-
.then(function(res) {
|
402
|
-
var headers = res.headers;
|
403
|
-
|
404
|
-
if (!headers.location && res.body.indexOf('Review Recent Login') > -1) throw { error: "Something went wrong with review recent login." };
|
405
|
-
|
406
|
-
var appState = utils.getAppState(jar);
|
407
|
-
|
408
|
-
// Simply call loginHelper because all it needs is the jar
|
409
|
-
// and will then complete the login process
|
410
|
-
return loginHelper(appState, email, password, loginOptions, callback);
|
411
|
-
})
|
412
|
-
.catch(e => callback(e));
|
399
|
+
.then(res => {
|
400
|
+
try {
|
401
|
+
JSON.parse(res.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/, ""));
|
402
|
+
} catch (ex) {
|
403
|
+
clearInterval(checkVerified);
|
404
|
+
if (callback === prCallback) {
|
405
|
+
callback = function (err, api) {
|
406
|
+
if (err) {
|
407
|
+
return prReject(err);
|
408
|
+
}
|
409
|
+
return prResolve(api);
|
410
|
+
};
|
413
411
|
}
|
412
|
+
return loginHelper(utils.getAppState(jar), email, password, loginOptions, callback);
|
413
|
+
}
|
414
|
+
})
|
415
|
+
.catch(ex => {
|
416
|
+
log.error("login", ex);
|
417
|
+
if (callback === prCallback) {
|
418
|
+
prReject(ex);
|
419
|
+
} else {
|
420
|
+
callback(ex);
|
421
|
+
}
|
414
422
|
});
|
423
|
+
}
|
424
|
+
return rtPromise;
|
425
|
+
}
|
426
|
+
};
|
427
|
+
} else {
|
428
|
+
if (!loginOptions.forceLogin) {
|
429
|
+
throw { error: "Couldn't login. Facebook might have blocked this account. Please login with a browser or enable the option 'forceLogin' and try again." };
|
430
|
+
}
|
431
|
+
if (html.indexOf("Suspicious Login Attempt") > -1) {
|
432
|
+
form['submit[This was me]'] = "This was me";
|
433
|
+
} else {
|
434
|
+
form['submit[This Is Okay]'] = "This Is Okay";
|
415
435
|
}
|
416
436
|
|
417
|
-
return utils
|
437
|
+
return utils
|
438
|
+
.post(nextURL, jar, form, loginOptions)
|
439
|
+
.then(utils.saveCookies(jar))
|
440
|
+
.then(function () {
|
441
|
+
// Use the same form (safe I hope)
|
442
|
+
form.name_action_selected = 'save_device';
|
443
|
+
|
444
|
+
return utils
|
445
|
+
.post(nextURL, jar, form, loginOptions)
|
446
|
+
.then(utils.saveCookies(jar));
|
447
|
+
})
|
448
|
+
.then(function (res) {
|
449
|
+
var headers = res.headers;
|
450
|
+
|
451
|
+
if (!headers.location && res.body.indexOf('Review Recent Login') > -1) {
|
452
|
+
throw { error: "Something went wrong with review recent login." };
|
453
|
+
}
|
454
|
+
|
455
|
+
var appState = utils.getAppState(jar);
|
456
|
+
|
457
|
+
// Simply call loginHelper because all it needs is the jar
|
458
|
+
// and will then complete the login process
|
459
|
+
return loginHelper(appState, email, password, loginOptions, callback);
|
460
|
+
})
|
461
|
+
.catch(function (e) {
|
462
|
+
callback(e);
|
463
|
+
});
|
464
|
+
}
|
418
465
|
});
|
419
|
-
|
466
|
+
}
|
467
|
+
|
468
|
+
return utils
|
469
|
+
.get('https://www.facebook.com/', jar, null, loginOptions)
|
470
|
+
.then(utils.saveCookies(jar));
|
471
|
+
});
|
472
|
+
};
|
420
473
|
}
|
421
474
|
|
422
475
|
// Helps the login
|
423
476
|
function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
// Load the main page.
|
436
|
-
mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
|
437
|
-
} else {
|
438
|
-
// Open the main page, then we login with the given credentials and finally
|
439
|
-
// load the main page again (it'll give us some IDs that we need)
|
440
|
-
mainPromise = utils
|
441
|
-
.get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
|
442
|
-
.then(utils.saveCookies(jar))
|
443
|
-
.then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
|
444
|
-
.then(function() {
|
445
|
-
return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar));
|
446
|
-
});
|
447
|
-
}
|
477
|
+
var mainPromise = null;
|
478
|
+
var jar = utils.getJar();
|
479
|
+
|
480
|
+
// If we're given an appState we loop through it and save each cookie
|
481
|
+
// back into the jar.
|
482
|
+
if (appState) {
|
483
|
+
appState.map(function (c) {
|
484
|
+
var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
|
485
|
+
jar.setCookie(str, "http://" + c.domain);
|
486
|
+
});
|
448
487
|
|
449
|
-
|
450
|
-
|
451
|
-
|
488
|
+
// Load the main page.
|
489
|
+
mainPromise = utils
|
490
|
+
.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true })
|
491
|
+
.then(utils.saveCookies(jar));
|
492
|
+
} else {
|
493
|
+
// Open the main page, then we login with the given credentials and finally
|
494
|
+
// load the main page again (it'll give us some IDs that we need)
|
495
|
+
mainPromise = utils
|
496
|
+
.get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
|
497
|
+
.then(utils.saveCookies(jar))
|
498
|
+
.then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
|
499
|
+
.then(function () {
|
500
|
+
return utils
|
501
|
+
.get('https://www.facebook.com/', jar, null, globalOptions)
|
502
|
+
.then(utils.saveCookies(jar));
|
503
|
+
});
|
504
|
+
}
|
505
|
+
|
506
|
+
var ctx = null;
|
507
|
+
var _defaultFuncs = null;
|
508
|
+
var api = null;
|
509
|
+
|
510
|
+
mainPromise = mainPromise
|
511
|
+
.then(function (res) {
|
512
|
+
// Hacky check for the redirection that happens on some ISPs, which doesn't return statusCode 3xx
|
513
|
+
var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
|
514
|
+
var redirect = reg.exec(res.body);
|
515
|
+
if (redirect && redirect[1]) {
|
516
|
+
return utils
|
517
|
+
.get(redirect[1], jar, null, globalOptions)
|
518
|
+
.then(utils.saveCookies(jar));
|
519
|
+
}
|
520
|
+
return res;
|
521
|
+
})
|
522
|
+
.then(function (res) {
|
523
|
+
var html = res.body;
|
524
|
+
var stuff = buildAPI(globalOptions, html, jar);
|
525
|
+
ctx = stuff[0];
|
526
|
+
_defaultFuncs = stuff[1];
|
527
|
+
api = stuff[2];
|
528
|
+
return res;
|
529
|
+
});
|
452
530
|
|
531
|
+
// given a pageID we log in as a page
|
532
|
+
if (globalOptions.pageID) {
|
453
533
|
mainPromise = mainPromise
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
.then(function(res) {
|
462
|
-
var html = res.body;
|
463
|
-
var stuff = buildAPI(globalOptions, html, jar);
|
464
|
-
ctx = stuff[0];
|
465
|
-
_defaultFuncs = stuff[1];
|
466
|
-
api = stuff[2];
|
467
|
-
return res;
|
468
|
-
});
|
469
|
-
|
470
|
-
// given a pageID we log in as a page
|
471
|
-
if (globalOptions.pageID) {
|
472
|
-
mainPromise = mainPromise
|
473
|
-
.then(function() {
|
474
|
-
return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
|
475
|
-
})
|
476
|
-
.then(function(resData) {
|
477
|
-
var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
|
478
|
-
url = url.substring(0, url.length - 1);
|
479
|
-
return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
|
480
|
-
});
|
481
|
-
}
|
534
|
+
.then(function () {
|
535
|
+
return utils
|
536
|
+
.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
|
537
|
+
})
|
538
|
+
.then(function (resData) {
|
539
|
+
var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
|
540
|
+
url = url.substring(0, url.length - 1);
|
482
541
|
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
542
|
+
return utils
|
543
|
+
.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
|
544
|
+
});
|
545
|
+
}
|
546
|
+
|
547
|
+
// At the end we call the callback or catch an exception
|
548
|
+
mainPromise
|
549
|
+
.then(function () {
|
550
|
+
return callback(null, api);
|
551
|
+
})
|
552
|
+
.catch(function (e) {
|
553
|
+
log.error("login", e.error || e);
|
554
|
+
callback(e);
|
555
|
+
});
|
493
556
|
}
|
494
557
|
|
495
558
|
function login(loginData, options, callback) {
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
559
|
+
if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
|
560
|
+
callback = options;
|
561
|
+
options = {};
|
562
|
+
}
|
563
|
+
|
564
|
+
var globalOptions = {
|
565
|
+
selfListen: false,
|
566
|
+
listenEvents: false,
|
567
|
+
listenTyping: false,
|
568
|
+
updatePresence: false,
|
569
|
+
forceLogin: false,
|
570
|
+
autoMarkDelivery: true,
|
571
|
+
autoMarkRead: false,
|
572
|
+
autoReconnect: true,
|
573
|
+
logRecordSize: defaultLogRecordSize,
|
574
|
+
online: true,
|
575
|
+
emitReady: false,
|
576
|
+
userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 15_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.1 Mobile/15E148 Safari/604.1"
|
577
|
+
};
|
578
|
+
|
579
|
+
setOptions(globalOptions, options);
|
580
|
+
|
581
|
+
var prCallback = null;
|
582
|
+
if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
|
583
|
+
var rejectFunc = null;
|
584
|
+
var resolveFunc = null;
|
585
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
586
|
+
resolveFunc = resolve;
|
587
|
+
rejectFunc = reject;
|
588
|
+
});
|
589
|
+
prCallback = function (error, api) {
|
590
|
+
if (error) {
|
591
|
+
return rejectFunc(error);
|
592
|
+
}
|
593
|
+
return resolveFunc(api);
|
514
594
|
};
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
|
520
|
-
var rejectFunc = null;
|
521
|
-
var resolveFunc = null;
|
522
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
523
|
-
resolveFunc = resolve;
|
524
|
-
rejectFunc = reject;
|
525
|
-
});
|
526
|
-
prCallback = function(error, api) {
|
527
|
-
if (error) return rejectFunc(error);
|
528
|
-
return resolveFunc(api);
|
529
|
-
};
|
530
|
-
callback = prCallback;
|
531
|
-
}
|
532
|
-
loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
|
533
|
-
return returnPromise;
|
595
|
+
callback = prCallback;
|
596
|
+
}
|
597
|
+
loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
|
598
|
+
return returnPromise;
|
534
599
|
}
|
535
600
|
|
536
|
-
module.exports = login;
|
601
|
+
module.exports = login;
|
602
|
+
|