@dongdev/fca-unofficial 0.0.6 → 0.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.
package/index.js CHANGED
@@ -1,308 +1,418 @@
1
1
  "use strict";
2
-
3
2
  const utils = require("./utils");
4
3
  const log = require("npmlog");
5
-
4
+ const axios = require("axios");
5
+ const { execSync } = require("child_process");
6
+ const fs = require("fs");
7
+ const path = require("path");
8
+ const models = require("./lib/database/models");
9
+ const logger = require("./lib/logger");
6
10
  let checkVerified = null;
7
-
8
11
  const defaultLogRecordSize = 100;
9
12
  log.maxRecordSize = defaultLogRecordSize;
10
-
13
+ const defaultConfig = {
14
+ autoUpdate: true,
15
+ mqtt: {
16
+ enabled: true,
17
+ reconnectInterval: 3600,
18
+ }
19
+ };
20
+ const configPath = path.join(process.cwd(), "fca-config.json");
21
+ let config;
22
+ if (!fs.existsSync(configPath)) {
23
+ fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
24
+ config = defaultConfig;
25
+ } else {
26
+ try {
27
+ const fileContent = fs.readFileSync(configPath, 'utf8');
28
+ config = JSON.parse(fileContent);
29
+ config = { ...defaultConfig, ...config };
30
+ } catch (err) {
31
+ logger("Error reading config file, using defaults", "error");
32
+ config = defaultConfig;
33
+ }
34
+ }
35
+ global.fca = {
36
+ config: config
37
+ };
38
+ async function checkForUpdates() {
39
+ if (!global.fca.config.autoUpdate) {
40
+ logger("Auto update is disabled", "info");
41
+ }
42
+ try {
43
+ const response = await axios.get("https://raw.githubusercontent.com/DongDev-VN/fca-unofficial/refs/heads/main/package.json");
44
+ const remoteVersion = response.data.version;
45
+ const localPackage = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8"));
46
+ const localVersion = localPackage.version;
47
+ if (remoteVersion !== localVersion) {
48
+ logger(`New version available: ${remoteVersion}`, "FCA-UPDATE");
49
+ logger("Installing latest version...", "FCA-UPDATE");
50
+ execSync(`npm i ${localPackage.name}@latest`);
51
+ logger("Update completed! Please restart your application", "FCA-UPDATE");
52
+ process.exit(1);
53
+ } else {
54
+ logger(`You are using the latest version: ${localVersion}`, 'info');
55
+ }
56
+ } catch (err) {
57
+ logger("Failed to check for updates:", err, "error");
58
+ }
59
+ }
60
+ if (global.fca.config.autoUpdate) {
61
+ checkForUpdates();
62
+ }
63
+ const Boolean_Option = [
64
+ "online",
65
+ "selfListen",
66
+ "listenEvents",
67
+ "updatePresence",
68
+ "forceLogin",
69
+ "autoMarkDelivery",
70
+ "autoMarkRead",
71
+ "listenTyping",
72
+ "autoReconnect",
73
+ "emitReady",
74
+ ];
11
75
  function setOptions(globalOptions, options) {
12
- Object.keys(options).map(function (key) {
13
- switch (key) {
14
- case 'online':
15
- globalOptions.online = Boolean(options.online);
16
- break;
17
- case 'logLevel':
18
- log.level = options.logLevel;
19
- globalOptions.logLevel = options.logLevel;
20
- break;
21
- case 'logRecordSize':
22
- log.maxRecordSize = options.logRecordSize;
23
- globalOptions.logRecordSize = options.logRecordSize;
24
- break;
25
- case 'selfListen':
26
- globalOptions.selfListen = Boolean(options.selfListen);
27
- break;
28
- case 'selfListenEvent':
29
- globalOptions.selfListenEvent = options.selfListenEvent;
30
- break;
31
- case 'listenEvents':
32
- globalOptions.listenEvents = Boolean(options.listenEvents);
33
- break;
34
- case 'pageID':
35
- globalOptions.pageID = options.pageID.toString();
36
- break;
37
- case 'updatePresence':
38
- globalOptions.updatePresence = Boolean(options.updatePresence);
39
- break;
40
- case 'forceLogin':
41
- globalOptions.forceLogin = Boolean(options.forceLogin);
42
- break;
43
- case 'userAgent':
44
- globalOptions.userAgent = options.userAgent;
45
- break;
46
- case 'autoMarkDelivery':
47
- globalOptions.autoMarkDelivery = Boolean(options.autoMarkDelivery);
48
- break;
49
- case 'autoMarkRead':
50
- globalOptions.autoMarkRead = Boolean(options.autoMarkRead);
51
- break;
52
- case 'listenTyping':
53
- globalOptions.listenTyping = Boolean(options.listenTyping);
54
- break;
55
- case 'proxy':
56
- if (typeof options.proxy != "string") {
57
- delete globalOptions.proxy;
58
- utils.setProxy();
59
- } else {
60
- globalOptions.proxy = options.proxy;
61
- utils.setProxy(globalOptions.proxy);
62
- }
63
- break;
64
- case 'autoReconnect':
65
- globalOptions.autoReconnect = Boolean(options.autoReconnect);
66
- break;
67
- case 'emitReady':
68
- globalOptions.emitReady = Boolean(options.emitReady);
69
- break;
70
- default:
71
- log.warn("setOptions", "Unrecognized option given to setOptions: " + key);
72
- break;
73
- }
74
- });
76
+ Object.keys(options).map(function(key) {
77
+ switch (Boolean_Option.includes(key)) {
78
+ case true: {
79
+ globalOptions[key] = Boolean(options[key]);
80
+ break;
81
+ }
82
+ case false: {
83
+ switch (key) {
84
+ case "pauseLog": {
85
+ if (options.pauseLog) log.pause();
86
+ else log.resume();
87
+ break;
88
+ }
89
+ case "logLevel": {
90
+ log.level = options.logLevel;
91
+ globalOptions.logLevel = options.logLevel;
92
+ break;
93
+ }
94
+ case "logRecordSize": {
95
+ log.maxRecordSize = options.logRecordSize;
96
+ globalOptions.logRecordSize = options.logRecordSize;
97
+ break;
98
+ }
99
+ case "pageID": {
100
+ globalOptions.pageID = options.pageID.toString();
101
+ break;
102
+ }
103
+ case "userAgent": {
104
+ globalOptions.userAgent =
105
+ options.userAgent ||
106
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36";
107
+ break;
108
+ }
109
+ case "proxy": {
110
+ if (typeof options.proxy != "string") {
111
+ delete globalOptions.proxy;
112
+ utils.setProxy();
113
+ } else {
114
+ globalOptions.proxy = options.proxy;
115
+ utils.setProxy(globalOptions.proxy);
116
+ }
117
+ break;
118
+ }
119
+ default: {
120
+ log.warn(
121
+ "setOptions",
122
+ "Unrecognized option given to setOptions: " + key
123
+ );
124
+ break;
125
+ }
126
+ }
127
+ break;
128
+ }
129
+ }
130
+ });
75
131
  }
76
-
77
132
  function buildAPI(globalOptions, html, jar) {
78
- const maybeCookie = jar.getCookies("https://www.facebook.com").filter(function (val) {
79
- return val.cookieString().split("=")[0] === "c_user";
80
- });
81
-
82
- const objCookie = jar.getCookies("https://www.facebook.com").reduce(function (obj, val) {
83
- obj[val.cookieString().split("=")[0]] = val.cookieString().split("=")[1];
84
- return obj;
85
- }, {});
86
-
87
- if (maybeCookie.length === 0) {
88
- 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." };
89
- }
90
-
91
- if (html.indexOf("/checkpoint/block/?next") > -1) {
92
- log.warn("login", "Checkpoint detected. Please log in with a browser to verify.");
93
- }
94
-
95
- const userID = maybeCookie[0].cookieString().split("=")[1].toString();
96
- const i_userID = objCookie.i_user || null;
97
- log.info("login", `Logged in as ${userID}`);
98
-
99
- try {
100
- clearInterval(checkVerified);
101
- } catch (_) { }
102
-
103
- const clientID = (Math.random() * 2147483648 | 0).toString(16);
104
-
105
-
106
- const oldFBMQTTMatch = html.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/);
107
- let mqttEndpoint, region, fb_dtsg, irisSeqID;
108
- try {
109
- const endpointMatch = html.match(/"endpoint":"([^"]+)"/);
110
- if (endpointMatch) {
111
- mqttEndpoint = endpointMatch[1].replace(/\\\//g, '/');
112
- const url = new URL(mqttEndpoint);
113
- region = url.searchParams.get('region')?.toUpperCase() || "PRN";
114
- }
115
- log.info('login', `Sever region ${region}`);
116
- } catch (e) {
117
- log.warning('login', 'Not MQTT endpoint');
118
- }
119
- const tokenMatch = html.match(/DTSGInitialData.*?token":"(.*?)"/);
120
- if (tokenMatch) {
121
- fb_dtsg = tokenMatch[1];
122
- }
123
-
124
- // All data available to api functions
125
- const ctx = {
126
- userID: userID,
127
- i_userID: i_userID,
128
- jar: jar,
129
- clientID: clientID,
130
- globalOptions: globalOptions,
131
- loggedIn: true,
132
- access_token: 'NONE',
133
- clientMutationId: 0,
134
- mqttClient: undefined,
135
- lastSeqId: irisSeqID,
136
- syncToken: undefined,
137
- mqttEndpoint,
138
- region,
139
- firstListen: true,
140
- fb_dtsg
141
- };
142
-
143
- const api = {
144
- setOptions: setOptions.bind(null, globalOptions),
145
- getAppState: function getAppState() {
146
- const appState = utils.getAppState(jar);
147
- // filter duplicate
148
- return appState.filter((item, index, self) => self.findIndex((t) => { return t.key === item.key }) === index);
149
- }
150
- };
151
-
152
- const defaultFuncs = utils.makeDefaults(html, i_userID || userID, ctx);
153
- require('fs').readdirSync(__dirname + '/src/').filter((v) => v.endsWith('.js')).map(function (v) {
154
- api[v.replace('.js', '')] = require('./src/' + v)(defaultFuncs, api, ctx);
155
- });
156
- api.listen = api.listenMqtt;
157
-
158
- return [ctx, defaultFuncs, api];
133
+ const maybeCookie = jar
134
+ .getCookies("https://www.facebook.com")
135
+ .filter(function(val) {
136
+ return val.cookieString().split("=")[0] === "c_user";
137
+ });
138
+ const objCookie = jar
139
+ .getCookies("https://www.facebook.com")
140
+ .reduce(function(obj, val) {
141
+ obj[val.cookieString().split("=")[0]] = val.cookieString().split("=")[1];
142
+ return obj;
143
+ }, {});
144
+ if (maybeCookie.length === 0) {
145
+ throw {
146
+ error:
147
+ "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.",
148
+ };
149
+ }
150
+ if (html.indexOf("/checkpoint/block/?next") > -1 || html.indexOf("/checkpoint/?next") > -1) {
151
+ throw {
152
+ error: "Checkpoint detected. Please log in with a browser to verify.",
153
+ }
154
+ }
155
+ const userID = maybeCookie[0]
156
+ .cookieString()
157
+ .split("=")[1]
158
+ .toString();
159
+ const i_userID = objCookie.i_user || null;
160
+ logger(`Logged in as ${userID}`, 'info');
161
+ try {
162
+ clearInterval(checkVerified);
163
+ } catch (_) {}
164
+ const clientID = ((Math.random() * 2147483648) | 0).toString(16);
165
+ let mqttEndpoint, region, fb_dtsg, irisSeqID;
166
+ try {
167
+ const endpointMatch = html.match(/"endpoint":"([^"]+)"/);
168
+ if (endpointMatch) {
169
+ mqttEndpoint = endpointMatch[1].replace(/\\\//g, "/");
170
+ const url = new URL(mqttEndpoint);
171
+ region = url.searchParams.get("region")?.toUpperCase() || "PRN";
172
+ }
173
+ logger(`Sever region ${region}`, 'info');
174
+ } catch (e) {
175
+ log.warning("login", "Not MQTT endpoint");
176
+ }
177
+ const tokenMatch = html.match(/DTSGInitialData.*?token":"(.*?)"/);
178
+ if (tokenMatch) {
179
+ fb_dtsg = tokenMatch[1];
180
+ }
181
+ (async () => {
182
+ try {
183
+ await models.sequelize.authenticate();
184
+ await models.syncAll();
185
+ } catch (error) {
186
+ console.error(error);
187
+ console.error('Database connection failed:', error.message);
188
+ }
189
+ })();
190
+ logger(`FCA fix by DongDev`, 'info');
191
+ const ctx = {
192
+ userID: userID,
193
+ i_userID: i_userID,
194
+ jar: jar,
195
+ clientID: clientID,
196
+ globalOptions: globalOptions,
197
+ loggedIn: true,
198
+ access_token: "NONE",
199
+ clientMutationId: 0,
200
+ mqttClient: undefined,
201
+ lastSeqId: irisSeqID,
202
+ syncToken: undefined,
203
+ mqttEndpoint,
204
+ region,
205
+ firstListen: true,
206
+ fb_dtsg,
207
+ };
208
+ const api = {
209
+ setOptions: setOptions.bind(null, globalOptions),
210
+ getAppState: function getAppState() {
211
+ const appState = utils.getAppState(jar);
212
+ return appState.filter(
213
+ (item, index, self) =>
214
+ self.findIndex((t) => {
215
+ return t.key === item.key;
216
+ }) === index
217
+ );
218
+ },
219
+ };
220
+ const defaultFuncs = utils.makeDefaults(html, i_userID || userID, ctx);
221
+ require("fs")
222
+ .readdirSync(__dirname + "/src/")
223
+ .filter((v) => v.endsWith(".js"))
224
+ .map(function(v) {
225
+ api[v.replace(".js", "")] = require("./src/" + v)(defaultFuncs, api, ctx);
226
+ });
227
+ api.listen = api.listenMqtt;
228
+ setInterval(checkForUpdates, 1000 * 60 * 60 * 24);
229
+ setInterval(async () => {
230
+ api
231
+ .refreshFb_dtsg()
232
+ .then(() => {
233
+ logger("Successfully refreshed fb_dtsg", 'info');
234
+ })
235
+ .catch((err) => {
236
+ console.error("An error occurred while refreshing fb_dtsg", err);
237
+ });
238
+ }, 1000 * 60 * 60 * 24);
239
+ return [ctx, defaultFuncs, api];
159
240
  }
160
-
161
- // Helps the login
162
- function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
163
- let mainPromise = null;
164
- const jar = utils.getJar();
165
-
166
- // If we're given an appState we loop through it and save each cookie
167
- // back into the jar.
168
- if (appState) {
169
- // check and convert cookie to appState
170
- if (utils.getType(appState) === 'Array' && appState.some(c => c.name)) {
171
- appState = appState.map(c => {
172
- c.key = c.name;
173
- delete c.name;
174
- return c;
175
- })
176
- }
177
- else if (utils.getType(appState) === 'String') {
178
- const arrayAppState = [];
179
- appState.split(';').forEach(c => {
180
- const [key, value] = c.split('=');
181
-
182
- arrayAppState.push({
183
- key: (key || "").trim(),
184
- value: (value || "").trim(),
185
- domain: "facebook.com",
186
- path: "/",
187
- expires: new Date().getTime() + 1000 * 60 * 60 * 24 * 365
188
- });
189
- });
190
- appState = arrayAppState;
191
- }
192
-
193
- appState.map(function (c) {
194
- const str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
195
- jar.setCookie(str, "http://" + c.domain);
196
- });
197
-
198
- // Load the main page.
199
- mainPromise = utils
200
- .get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true })
201
- .then(utils.saveCookies(jar));
202
- } else {
203
- if (email) {
204
- throw { error: "Currently, the login method by email and password is no longer supported, please use the login method by appState" };
205
- }
206
- else {
207
- throw { error: "No appState given." };
208
- }
209
- }
210
-
211
- let ctx = null;
212
- let _defaultFuncs = null;
213
- let api = null;
214
-
215
- mainPromise = mainPromise
216
- .then(function (res) {
217
- // Hacky check for the redirection that happens on some ISPs, which doesn't return statusCode 3xx
218
- const reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
219
- const redirect = reg.exec(res.body);
220
- if (redirect && redirect[1]) {
221
- return utils
222
- .get(redirect[1], jar, null, globalOptions)
223
- .then(utils.saveCookies(jar));
224
- }
225
- return res;
226
- })
227
- .then(function (res) {
228
- const html = res.body;
229
- const stuff = buildAPI(globalOptions, html, jar);
230
- ctx = stuff[0];
231
- _defaultFuncs = stuff[1];
232
- api = stuff[2];
233
- return res;
234
- });
235
-
236
- // given a pageID we log in as a page
237
- if (globalOptions.pageID) {
238
- mainPromise = mainPromise
239
- .then(function () {
240
- return utils
241
- .get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
242
- })
243
- .then(function (resData) {
244
- let url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
245
- url = url.substring(0, url.length - 1);
246
-
247
- return utils
248
- .get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
249
- });
250
- }
251
-
252
- // At the end we call the callback or catch an exception
253
- mainPromise
254
- .then(function () {
255
- log.info("login", 'Done logging in.');
256
- return callback(null, api);
257
- })
258
- .catch(function (e) {
259
- log.error("login", e.error || e);
260
- callback(e);
261
- });
241
+ function loginHelper(
242
+ appState,
243
+ email,
244
+ password,
245
+ globalOptions,
246
+ callback,
247
+ prCallback
248
+ ) {
249
+ let mainPromise = null;
250
+ const jar = utils.getJar();
251
+ if (appState) {
252
+ if (utils.getType(appState) === "Array" && appState.some((c) => c.name)) {
253
+ appState = appState.map((c) => {
254
+ c.key = c.name;
255
+ delete c.name;
256
+ return c;
257
+ });
258
+ } else if (utils.getType(appState) === "String") {
259
+ const arrayAppState = [];
260
+ appState.split(";").forEach((c) => {
261
+ const [key, value] = c.split("=");
262
+ arrayAppState.push({
263
+ key: (key || "").trim(),
264
+ value: (value || "").trim(),
265
+ domain: "facebook.com",
266
+ path: "/",
267
+ expires: new Date().getTime() + 1000 * 60 * 60 * 24 * 365,
268
+ });
269
+ });
270
+ appState = arrayAppState;
271
+ }
272
+ appState.map(function(c) {
273
+ const str =
274
+ c.key +
275
+ "=" +
276
+ c.value +
277
+ "; expires=" +
278
+ c.expires +
279
+ "; domain=" +
280
+ c.domain +
281
+ "; path=" +
282
+ c.path +
283
+ ";";
284
+ jar.setCookie(str, "http://" + c.domain);
285
+ });
286
+ mainPromise = utils
287
+ .get("https://www.facebook.com/", jar, null, globalOptions, {
288
+ noRef: true,
289
+ })
290
+ .then(utils.saveCookies(jar));
291
+ } else {
292
+ if (email) {
293
+ throw {
294
+ error:
295
+ "Currently, the login method by email and password is no longer supported, please use the login method by appState",
296
+ };
297
+ } else {
298
+ throw { error: "No appState given." };
299
+ }
300
+ }
301
+ let ctx = null;
302
+ let _defaultFuncs = null;
303
+ let api = null;
304
+ mainPromise = mainPromise
305
+ .then(function(res) {
306
+ const reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
307
+ const redirect = reg.exec(res.body);
308
+ if (redirect && redirect[1]) {
309
+ return utils
310
+ .get(redirect[1], jar, null, globalOptions)
311
+ .then(utils.saveCookies(jar));
312
+ }
313
+ return res;
314
+ })
315
+ .then(function(res) {
316
+ const html = res.body;
317
+ const stuff = buildAPI(globalOptions, html, jar);
318
+ ctx = stuff[0];
319
+ _defaultFuncs = stuff[1];
320
+ api = stuff[2];
321
+ return res;
322
+ });
323
+ if (globalOptions.pageID) {
324
+ mainPromise = mainPromise
325
+ .then(function() {
326
+ return utils.get(
327
+ "https://www.facebook.com/" +
328
+ ctx.globalOptions.pageID +
329
+ "/messages/?section=messages&subsection=inbox",
330
+ ctx.jar,
331
+ null,
332
+ globalOptions
333
+ );
334
+ })
335
+ .then(function(resData) {
336
+ let url = utils
337
+ .getFrom(
338
+ resData.body,
339
+ 'window.location.replace("https:\\/\\/www.facebook.com\\',
340
+ '");'
341
+ )
342
+ .split("\\")
343
+ .join("");
344
+ url = url.substring(0, url.length - 1);
345
+ return utils.get(
346
+ "https://www.facebook.com" + url,
347
+ ctx.jar,
348
+ null,
349
+ globalOptions
350
+ );
351
+ });
352
+ }
353
+ mainPromise
354
+ .then(function() {
355
+ logger("Done logging in", 'info');
356
+ return callback(null, api);
357
+ })
358
+ .catch(function(e) {
359
+ log.error("login", e.error || e);
360
+ callback(e);
361
+ });
262
362
  }
263
-
264
363
  function login(loginData, options, callback) {
265
- if (utils.getType(options) === 'Function' || utils.getType(options) === 'AsyncFunction') {
266
- callback = options;
267
- options = {};
268
- }
269
-
270
- const globalOptions = {
271
- selfListen: false,
272
- selfListenEvent: false,
273
- listenEvents: false,
274
- listenTyping: false,
275
- updatePresence: false,
276
- forceLogin: false,
277
- autoMarkDelivery: true,
278
- autoMarkRead: false,
279
- autoReconnect: true,
280
- logRecordSize: defaultLogRecordSize,
281
- online: true,
282
- emitReady: false,
283
- userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
284
- };
285
-
286
- setOptions(globalOptions, options);
287
-
288
- let prCallback = null;
289
- if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
290
- let rejectFunc = null;
291
- let resolveFunc = null;
292
- var returnPromise = new Promise(function (resolve, reject) {
293
- resolveFunc = resolve;
294
- rejectFunc = reject;
295
- });
296
- prCallback = function (error, api) {
297
- if (error) {
298
- return rejectFunc(error);
299
- }
300
- return resolveFunc(api);
301
- };
302
- callback = prCallback;
303
- }
304
- loginHelper(loginData.appState, loginData.email, loginData.password, globalOptions, callback, prCallback);
305
- return returnPromise;
364
+ if (
365
+ utils.getType(options) === "Function" ||
366
+ utils.getType(options) === "AsyncFunction"
367
+ ) {
368
+ callback = options;
369
+ options = {};
370
+ }
371
+ const globalOptions = {
372
+ selfListen: false,
373
+ selfListenEvent: false,
374
+ listenEvents: false,
375
+ listenTyping: false,
376
+ updatePresence: false,
377
+ forceLogin: false,
378
+ autoMarkDelivery: true,
379
+ autoMarkRead: false,
380
+ autoReconnect: true,
381
+ logRecordSize: defaultLogRecordSize,
382
+ online: true,
383
+ emitReady: false,
384
+ userAgent:
385
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
386
+ };
387
+ setOptions(globalOptions, options);
388
+ let prCallback = null;
389
+ if (
390
+ utils.getType(callback) !== "Function" &&
391
+ utils.getType(callback) !== "AsyncFunction"
392
+ ) {
393
+ let rejectFunc = null;
394
+ let resolveFunc = null;
395
+ var returnPromise = new Promise(function(resolve, reject) {
396
+ resolveFunc = resolve;
397
+ rejectFunc = reject;
398
+ });
399
+ prCallback = function(error, api) {
400
+ if (error) {
401
+ return rejectFunc(error);
402
+ }
403
+ return resolveFunc(api);
404
+ };
405
+ callback = prCallback;
406
+ }
407
+ loginHelper(
408
+ loginData.appState,
409
+ loginData.email,
410
+ loginData.password,
411
+ globalOptions,
412
+ callback,
413
+ prCallback
414
+ );
415
+ return returnPromise;
306
416
  }
307
417
 
308
418
  module.exports = login;