@dongdev/fca-unofficial 2.0.11 → 2.0.13

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.d.ts ADDED
@@ -0,0 +1,615 @@
1
+ // Origin: NOCOM-BOT/mod_fbmsg_legacy
2
+
3
+ declare module '@dongdev/fca-unofficial' {
4
+ import type { Readable, Duplex, Transform } from "stream";
5
+ import type EventEmitter from "events";
6
+
7
+ type ReadableStream = Readable | Duplex | Transform;
8
+ function login(credentials: Partial<{
9
+ email: string,
10
+ password: string,
11
+ appState: AppstateData
12
+ }>, options: Partial<IFCAU_Options>, callback: (err: Error | null, api: IFCAU_API) => void): void;
13
+ function login(credentials: Partial<{
14
+ email: string,
15
+ password: string,
16
+ appState: AppstateData
17
+ }>, options: Partial<IFCAU_Options>): Promise<IFCAU_API>;
18
+ function login(credentials: Partial<{
19
+ email: string,
20
+ password: string,
21
+ appState: AppstateData
22
+ }>, callback: (err: Error | null, api: IFCAU_API) => void): void;
23
+ function login(credentials: Partial<{
24
+ email: string,
25
+ password: string,
26
+ appState: AppstateData
27
+ }>): Promise<IFCAU_API>;
28
+
29
+ export default login;
30
+
31
+ export type Cookie = {
32
+ key: string,
33
+ value: string,
34
+ domain: string,
35
+ path?: string,
36
+ hostOnly?: boolean,
37
+ creation?: string,
38
+ lastAccessed?: string
39
+ }
40
+
41
+ export type AppstateData = {
42
+ appState: Cookie[]
43
+ }
44
+
45
+ export type MessageObject = {
46
+ body: string,
47
+ sticker?: string,
48
+ attachment?: ReadableStream | ReadableStream[],
49
+ url?: string,
50
+ emoji?: string,
51
+ emojiSize?: string,
52
+ mentions?: {
53
+ tag: string,
54
+ id: string,
55
+ fromIndex?: number
56
+ }[],
57
+ location?: {
58
+ latitude: number,
59
+ longitude: number,
60
+ current?: boolean
61
+ }
62
+ }
63
+
64
+ function sendMessage(
65
+ message: string | MessageObject,
66
+ threadID: string | string[],
67
+ callback?: (err?: Error, data?: { threadID: string, messageID: string, timestamp: number }) => void,
68
+ replyMessageID?: string,
69
+ isGroup?: boolean
70
+ ): Promise<{ threadID: string, messageID: string, timestamp: number }>;
71
+ function sendMessage(
72
+ message: string | MessageObject,
73
+ threadID: string | string[],
74
+ replyMessageID?: string,
75
+ isGroup?: boolean
76
+ ): Promise<{ threadID: string, messageID: string, timestamp: number }>;
77
+
78
+ export type IFCAU_API = {
79
+ addUserToGroup: (userID: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
80
+ changeAdminStatus: (threadID: string, adminIDs: string | string[], adminStatus: boolean, callback?: (err?: Error) => void) => Promise<void>,
81
+ changeApprovalMode: (approvalMode: 0 | 1, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
82
+ changeArchivedStatus: (threadOrThreads: string | string[], archive: boolean, callback?: (err?: Error) => void) => Promise<void>,
83
+ changeBlockedStatus: (userID: string, blocked: boolean, callback?: (err?: Error) => void) => Promise<void>,
84
+ changeGroupImage: (image: ReadableStream, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
85
+ changeNickname: (nickname: string, threadID: string, pariticipantID: string, callback?: (err?: Error) => void) => Promise<void>,
86
+ changeThreadColor: (color: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
87
+ changeThreadEmoji: (emoji: string | null, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
88
+ createNewGroup: (participantIDs: string[], groupTitle?: string, callback?: (err: Error, threadID: string) => void) => Promise<string>,
89
+ createPoll: (title: string, threadID: string, options?: { [item: string]: boolean }, callback?: (err?: Error) => void) => Promise<void>,
90
+ deleteMessage: (messageOrMessages: string | string[], callback?: (err?: Error) => void) => Promise<void>,
91
+ deleteThread: (threadOrThreads: string | string[], callback?: (err?: Error) => void) => Promise<void>,
92
+ editMessage: (text: string, messageID: string, callback?: (err?: Error) => void) => Promise<void>,
93
+ forwardAttachment: (attachmentID: string, userOrUsers: string | string[], callback?: (err?: Error) => void) => Promise<void>,
94
+ forwardMessage: (messageID: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
95
+ getAppState: () => any,
96
+ getCurrentUserID: () => string,
97
+ getEmojiUrl: (c: string, size: number, pixelRatio: number) => string,
98
+ getFriendsList: (callback?: (err: Error | null, friends: IFCAU_Friend[]) => void) => Promise<IFCAU_Friend[]>,
99
+ getThreadHistory: (threadID: string, amount: number, time?: number, callback?: (err: Error | null, messages: any[]) => void) => Promise<any[]>,
100
+ getThreadInfo: (threadID: string, callback?: (err: Error | null, thread: IFCAU_Thread) => void) => Promise<IFCAU_Thread>,
101
+ getThreadList: (limit: number, timestamp: number | null, tags: string[], callback?: (err: Error | null, threads: IFCAU_ThreadList) => void) => Promise<IFCAU_ThreadList>,
102
+ getThreadPictures: (threadID: string, offset: number, limit: number, callback?: (err: Error | null, pictures: string[]) => void) => Promise<string[]>,
103
+ getUserID: (name: string, callback?: (err: Error | null, obj: IFCAU_UserIDResponse) => void) => Promise<IFCAU_UserIDResponse>,
104
+ getUserInfo: (userOrUsers: string | string[], callback?: (err: Error | null, users: { [id: string]: IFCAU_User }) => void) => Promise<{ [id: string]: IFCAU_User }>,
105
+ threadColors: {
106
+ [color: string]: string
107
+ },
108
+ handleMessageRequest(threadOrThreads: string | string[], accept: boolean, callback: (err?: Error) => void): Promise<void>;
109
+ listen(callback?: (err: Error | null, message: IFCAU_ListenMessage) => void): EventEmitter;
110
+ listenMqtt(callback?: (err: Error | null, message: IFCAU_ListenMessage) => void): EventEmitter & { stopListening: (callback?: () => void) => void };
111
+ logout: (callback?: (err?: Error) => void) => Promise<void>,
112
+ markAsDelivered(threadID: string, messageID: string, callback?: (err?: Error) => void): Promise<void>,
113
+ markAsRead(threadID: string, read?: boolean, callback?: (err?: Error) => void): Promise<void>,
114
+ markAsReadAll: (callback?: (err?: Error) => void) => Promise<void>,
115
+ markAsSeen(seenTimestamp?: number, callback?: (err?: Error) => void): Promise<void>,
116
+ muteThread: (threadID: string, muteSeconds: number, callback?: (err?: Error) => void) => Promise<void>,
117
+ pinMessage: (pinMode: boolean, messageID: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
118
+ removeUserFromGroup: (userID: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
119
+ resolvePhotoUrl: (photoID: string, callback?: (err: Error | null, url: string) => void) => Promise<string>,
120
+ sendMessage: typeof sendMessage,
121
+ sendTypingIndicator: (threadID: string, callback?: (err?: Error) => void) => Promise<void>,
122
+ sendTypingIndicatorMqtt: (isTyping: boolean, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
123
+ setMessageReaction: (reaction: string, messageID: string, callback?: (err?: Error) => void, forceCustomReaction?: boolean) => Promise<void>,
124
+ setMessageReactionMqtt: (reaction: string, messageID: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
125
+ setOptions: (options: Partial<IFCAU_Options>) => void,
126
+ setTitle: (newTitle: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
127
+ unsendMessage: (messageID: string, callback?: (err?: Error) => void) => Promise<void>,
128
+ unsendMessageMqtt: (messageID: string, threadID: string, callback?: (err?: Error) => void) => Promise<void>,
129
+ }
130
+
131
+ export type IFCAU_ListenMessage =
132
+ {
133
+ type: "message",
134
+ attachments: IFCAU_Attachment[],
135
+ args: string[],
136
+ body: string,
137
+ isGroup: boolean,
138
+ mentions: { [id: string]: string },
139
+ messageID: string,
140
+ senderID: string,
141
+ threadID: string,
142
+ isUnread: boolean,
143
+ participantIDs: string[]
144
+ } |
145
+ {
146
+ type: "event",
147
+ author: string,
148
+ logMessageBody: string,
149
+ logMessageData: {
150
+ image: {
151
+ attachmentID: string,
152
+ width: number,
153
+ height: number,
154
+ url: string
155
+ }
156
+ },
157
+ logMessageType: "log:thread-image",
158
+ threadID: string
159
+ } |
160
+ {
161
+ type: "event",
162
+ author: string,
163
+ logMessageBody: string,
164
+ logMessageData: {
165
+ addedParticipants: {
166
+ fanoutPolicy: string,
167
+ firstName: string,
168
+ fullName: string,
169
+ groupJoinStatus: string,
170
+ initialFolder: string,
171
+ initialFolderId: {
172
+ systemFolderId: string,
173
+ },
174
+ lastUnsubscribeTimestampMs: string,
175
+ userFbId: string,
176
+ isMessengerUser: boolean
177
+ }[],
178
+ },
179
+ logMessageType: "log:subscribe",
180
+ threadID: string,
181
+ participantIDs: string[]
182
+ } |
183
+ {
184
+ type: "event",
185
+ author: string,
186
+ logMessageBody: string,
187
+ logMessageData: { leftParticipantFbId: string },
188
+ logMessageType: "log:unsubscribe",
189
+ threadID: string,
190
+ participantIDs: string[]
191
+ } |
192
+ {
193
+ type: "event",
194
+ author: string,
195
+ logMessageBody: string,
196
+ logMessageData: { name: string },
197
+ logMessageType: "log:thread-name",
198
+ threadID: string,
199
+ participantIDs: string[]
200
+ } |
201
+ {
202
+ type: "event",
203
+ author: string,
204
+ logMessageBody: string,
205
+ logMessageData: {
206
+ theme_color: string,
207
+ gradient?: string,
208
+ should_show_icon: string,
209
+ theme_id: string,
210
+ accessibility_label: string,
211
+ theme_name_with_subtitle: string,
212
+ theme_emoji?: string
213
+ },
214
+ logMessageType: "log:thread-color",
215
+ threadID: string,
216
+ participantIDs: string[]
217
+ } |
218
+ {
219
+ type: "event",
220
+ author: string,
221
+ logMessageBody: string,
222
+ logMessageData: {
223
+ thread_quick_reaction_instruction_key_id: string,
224
+ thread_quick_reaction_emoji: string,
225
+ thread_quick_reaction_emoji_url: string
226
+ },
227
+ logMessageType: "log:thread-icon",
228
+ threadID: string,
229
+ participantIDs: string[]
230
+ } |
231
+ {
232
+ type: "event",
233
+ author: string,
234
+ logMessageBody: string,
235
+ logMessageData: {
236
+ nickname: string,
237
+ participant_id: string
238
+ },
239
+ logMessageType: "log:user-nickname",
240
+ threadID: string,
241
+ participantIDs: string[]
242
+ } |
243
+ {
244
+ type: "event",
245
+ author: string,
246
+ logMessageBody: string,
247
+ logMessageData: {
248
+ THREAD_CATEGORY: string,
249
+ TARGET_ID: string,
250
+ ADMIN_TYPE: string,
251
+ ADMIN_EVENT: 'add_admin' | 'remove_admin'
252
+ },
253
+ logMessageType: "log:thread-admins",
254
+ threadID: string,
255
+ participantIDs: string[]
256
+ } |
257
+ {
258
+ type: "event",
259
+ author: string,
260
+ logMessageBody: string,
261
+ logMessageData: {
262
+ removed_option_ids: string,
263
+ question_json: string,
264
+ event_type: 'question_creation' | 'update_vote' | 'add_unvoted_option' | 'multiple_updates',
265
+ added_option_ids: string,
266
+ new_option_texts: string,
267
+ new_option_ids: string,
268
+ question_id: string,
269
+ },
270
+ logMessageType: "log:thread-poll",
271
+ threadID: string,
272
+ participantIDs: string[]
273
+ } |
274
+ {
275
+ type: "event",
276
+ author: string,
277
+ logMessageBody: string,
278
+ logMessageData: { APPROVAL_MODE: '0' | '1', THREAD_CATEGORY: string },
279
+ logMessageType: "log:thread-approval-mode",
280
+ threadID: string,
281
+ participantIDs: string[]
282
+ } |
283
+ {
284
+ type: "event",
285
+ author: string,
286
+ logMessageBody: string,
287
+ logMessageData: any,
288
+ logMessageType: "log:thread-call",
289
+ threadID: string,
290
+ participantIDs: string[]
291
+ } |
292
+ {
293
+ type: "typ",
294
+ from: string,
295
+ fromMobile: boolean,
296
+ isTyping: boolean,
297
+ threadID: string
298
+ } |
299
+ {
300
+ type: "read",
301
+ threadID: string,
302
+ time: number,
303
+ } |
304
+ {
305
+ type: "read_receipt",
306
+ reader: string,
307
+ threadID: string,
308
+ time: number
309
+ } | {
310
+ type: "message_reaction",
311
+ threadID: string,
312
+ messageID: string,
313
+ reaction: string,
314
+ senderID: string,
315
+ userID: string,
316
+ reactionTimestamp: number
317
+ } | {
318
+ type: "presence",
319
+ statuses: number,
320
+ timestamp: number,
321
+ userID: string
322
+ } | {
323
+ type: "message_unsend",
324
+ threadID: string,
325
+ senderID: string,
326
+ messageID: string,
327
+ deletionnTimestamp: number
328
+ } | {
329
+ type: "message_reply"
330
+ attachments: IFCAU_Attachment[],
331
+ args: string[],
332
+ body: string,
333
+ isGroup: boolean,
334
+ mentions: { [id: string]: string },
335
+ messageID: string,
336
+ senderID: string,
337
+ threadID: string,
338
+ isUnread: boolean,
339
+ participantIDs: string[],
340
+ messageReply: {
341
+ attachments: IFCAU_Attachment[],
342
+ body: string,
343
+ isGroup: boolean,
344
+ mentions: { [id: string]: string },
345
+ messageID: string,
346
+ senderID: string,
347
+ threadID: string,
348
+ isUnread: boolean
349
+ }
350
+ };
351
+
352
+ export type IFCAU_Attachment =
353
+ {
354
+ type: "sticker",
355
+ ID: string,
356
+ url: string,
357
+ packID: string,
358
+ spriteUrl: string,
359
+ spriteUrl2x: string,
360
+ width: number,
361
+ height: number,
362
+ caption: string,
363
+ description: string,
364
+ frameCount: number,
365
+ frameRate: number,
366
+ framesPerRow: number,
367
+ framesPerCol: number
368
+ } |
369
+ {
370
+ type: "file",
371
+ ID: string,
372
+ filename: string,
373
+ url: string,
374
+ isMalicious: boolean,
375
+ contentType: string
376
+ } |
377
+ {
378
+ type: "photo",
379
+ ID: string,
380
+ filename: string,
381
+ thumbnailUrl: string,
382
+ previewUrl: string,
383
+ previewWidth: number,
384
+ previewHeight: number,
385
+ largePreviewUrl: string,
386
+ largePreviewWidth: number,
387
+ largePreviewHeight: number,
388
+ url: string,
389
+ width: number,
390
+ height: number
391
+ } |
392
+ {
393
+ type: "animated_image",
394
+ ID: string,
395
+ filename: string,
396
+ previewUrl: string,
397
+ previewWidth: number,
398
+ previewHeight: number,
399
+ url: string,
400
+ width: number,
401
+ height: number
402
+ } |
403
+ {
404
+ type: "video",
405
+ ID: string,
406
+ filename: string,
407
+ previewUrl: string,
408
+ previewWidth: number,
409
+ previewHeight: number,
410
+ url: string,
411
+ width: number,
412
+ height: number
413
+ duration: number,
414
+ videoType: string
415
+ } |
416
+ {
417
+ type: "audio",
418
+ ID: string,
419
+ filename: string,
420
+ audioType: string,
421
+ duration: number,
422
+ url: string,
423
+ isVoiceMail: boolean
424
+ } |
425
+ {
426
+ type: "location",
427
+ ID: string,
428
+ latitude: number,
429
+ longitude: number,
430
+ image: string,
431
+ width: number,
432
+ height: number,
433
+ url: string,
434
+ address: string
435
+ } |
436
+ {
437
+ type: "share",
438
+ ID: string,
439
+ url: string,
440
+ title: string,
441
+ description: string,
442
+ source: string,
443
+ image: string,
444
+ width: number,
445
+ height: number,
446
+ playable: boolean,
447
+ duration: number,
448
+ playableUrl: string,
449
+ subattachments: any,
450
+ properties: any
451
+ }
452
+
453
+ export type IFCAU_User = {
454
+ name: string,
455
+ firstName?: string,
456
+ vanity?: string,
457
+ thumbSrc: string,
458
+ profileUrl: string | null,
459
+ gender?: number,
460
+ type: string,
461
+ isFriend?: boolean,
462
+ isBirthday: boolean,
463
+ searchToken: any,
464
+ alternateName?: string
465
+ }
466
+
467
+ export type IFCAU_UserIDResponse = {
468
+ userID: string,
469
+ photoUrl: string,
470
+ indexRank: number,
471
+ name: string,
472
+ isVerified: boolean,
473
+ profileUrl: string,
474
+ category: string,
475
+ score: number,
476
+ type: string
477
+ }[];
478
+
479
+ export type IFCAU_Options = {
480
+ pauseLog: boolean,
481
+ logLevel: "silly" | "verbose" | "info" | "http" | "warn" | "error" | "silent",
482
+ selfListen: boolean,
483
+ listenEvents: boolean,
484
+ pageID: string,
485
+ updatePresence: boolean,
486
+ forceLogin: boolean,
487
+ userAgent: string,
488
+ autoMarkDelivery: boolean,
489
+ autoMarkRead: boolean,
490
+ proxy: string,
491
+ online: boolean
492
+ }
493
+
494
+ export type IFCAU_Friend = {
495
+ alternativeName: string,
496
+ firstName: string,
497
+ gender: string,
498
+ userID: string,
499
+ isFriend: boolean,
500
+ fullName: string,
501
+ profilePicture: string,
502
+ type: string,
503
+ profileUrl: string,
504
+ vanity: string,
505
+ isBirthday: boolean
506
+ }
507
+
508
+ export type IFCAU_Thread = {
509
+ threadID: string,
510
+ participantIDs: string[],
511
+ threadName: string,
512
+ userInfo: (IFCAU_User & { id: string })[],
513
+ nicknames: { [id: string]: string } | null,
514
+ unreadCount: number,
515
+ messageCount: number,
516
+ imageSrc: string,
517
+ timestamp: number,
518
+ muteUntil: number | null,
519
+ isGroup: boolean,
520
+ isSubscribed: boolean,
521
+ folder: 'INBOX' | 'ARCHIVE' | string,
522
+ isArchived: boolean,
523
+ cannotReplyReason: string | null,
524
+ lastReadTimestamp: number,
525
+ emoji: string | null,
526
+ color: string | null,
527
+ adminIDs: string[],
528
+ approvalMode: boolean,
529
+ approvalQueue: { inviterID: string, requesterID: string, timestamp: string }[]
530
+ }
531
+
532
+ export type IFCAU_ThreadList = {
533
+ threadID: string,
534
+ name: string,
535
+ unreadCount: number,
536
+ messageCount: number,
537
+ imageSrc: string,
538
+ emoji: string | null,
539
+ color: string | null,
540
+ nicknames: { userid: string, nickname: string }[],
541
+ muteUntil: number | null,
542
+ participants: IFCAU_ThreadList_Participants[],
543
+ adminIDs: string[],
544
+ folder: "INBOX" | "ARCHIVED" | "PENNDING" | "OTHER" | string,
545
+ isGroup: boolean,
546
+ customizationEnabled: boolean,
547
+ participantAddMode: string,
548
+ reactionMuteMode: string,
549
+ isArchived: boolean,
550
+ isSubscribed: boolean,
551
+ timestamp: number,
552
+ snippet: string,
553
+ snippetAttachments: string
554
+ snippetSender: string,
555
+ lastMessageTimestamp: number,
556
+ listReadTimestamp: number | null,
557
+ cannotReplyReason: string | null,
558
+ approvalMode: string
559
+ }[]
560
+
561
+ export type IFCAU_ThreadList_Participants =
562
+ {
563
+ accountType: "User",
564
+ userID: string,
565
+ name: string,
566
+ shortName: string,
567
+ gender: string,
568
+ url: string,
569
+ profilePicture: string,
570
+ username: string | null,
571
+ isViewerFriend: boolean,
572
+ isMessengerUser: boolean,
573
+ isVerified: boolean,
574
+ isMessageBlockedByViewer: boolean,
575
+ isViewerCoworker: boolean
576
+ } |
577
+ {
578
+ accountType: "Page",
579
+ userID: string,
580
+ name: string,
581
+ url: string,
582
+ profilePicture: string,
583
+ username: string | null,
584
+ acceptMessengerUserFeedback: boolean,
585
+ isMessengerUser: boolean,
586
+ isVerified: boolean,
587
+ isMessengerPlatformBot: boolean,
588
+ isMessageBlockedByViewer: boolean,
589
+ } |
590
+ {
591
+ accountType: "ReducedMessagingActor",
592
+ userID: string,
593
+ name: string,
594
+ url: string,
595
+ profilePicture: string,
596
+ username: string | null,
597
+ acceptMessengerUserFeedback: boolean,
598
+ isMessageBlockedByViewer: boolean
599
+ } |
600
+ {
601
+ accountType: "UnavailableMessagingActor",
602
+ userID: string,
603
+ name: string,
604
+ url: null,
605
+ profilePicture: string,
606
+ username: null,
607
+ acceptMessengerUserFeedback: boolean,
608
+ isMessageBlockedByViewer: boolean
609
+ } |
610
+ {
611
+ accountType: string,
612
+ userID: string,
613
+ name: string
614
+ };
615
+ }
@@ -0,0 +1,34 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const logger = require("../func/logger");
4
+ const defaultConfig = {
5
+ autoUpdate: true,
6
+ mqtt: { enabled: true, reconnectInterval: 3600 },
7
+ autoLogin: true,
8
+ credentials: { email: "", password: "", twofactor: "" }
9
+ };
10
+
11
+ function loadConfig() {
12
+ const configPath = path.join(process.cwd(), "fca-config.json");
13
+ let config;
14
+ if (!fs.existsSync(configPath)) {
15
+ try {
16
+ fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
17
+ config = defaultConfig;
18
+ } catch (err) {
19
+ logger(`Error writing config file: ${err.message}`, "error");
20
+ config = defaultConfig;
21
+ }
22
+ } else {
23
+ try {
24
+ const fileContent = fs.readFileSync(configPath, "utf8");
25
+ config = Object.assign({}, defaultConfig, JSON.parse(fileContent));
26
+ } catch (err) {
27
+ logger(`Error reading config file: ${err.message}`, "error");
28
+ config = defaultConfig;
29
+ }
30
+ }
31
+ return { config, configPath };
32
+ }
33
+
34
+ module.exports = { loadConfig, defaultConfig };
@@ -0,0 +1,59 @@
1
+ const { getType } = require("../src/utils/format");
2
+ const { setOptions } = require("./options");
3
+ const { loadConfig } = require("./config");
4
+ const { checkAndUpdateVersion } = require("../func/checkUpdate");
5
+ const loginHelper = require("./loginHelper");
6
+
7
+ const { config } = loadConfig();
8
+ global.fca = { config };
9
+
10
+ function login(loginData, options, callback) {
11
+ if (getType(options) === "Function" || getType(options) === "AsyncFunction") {
12
+ callback = options;
13
+ options = {};
14
+ }
15
+ const globalOptions = {
16
+ selfListen: false,
17
+ selfListenEvent: false,
18
+ listenEvents: false,
19
+ listenTyping: false,
20
+ updatePresence: false,
21
+ forceLogin: false,
22
+ autoMarkDelivery: true,
23
+ autoMarkRead: false,
24
+ autoReconnect: true,
25
+ online: true,
26
+ emitReady: false,
27
+ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
28
+ };
29
+ setOptions(globalOptions, options);
30
+ let prCallback = null;
31
+ let rejectFunc = null;
32
+ let resolveFunc = null;
33
+ let returnPromise = null;
34
+ if (getType(callback) !== "Function" && getType(callback) !== "AsyncFunction") {
35
+ returnPromise = new Promise(function (resolve, reject) {
36
+ resolveFunc = resolve;
37
+ rejectFunc = reject;
38
+ });
39
+ prCallback = function (error, api) {
40
+ if (error) return rejectFunc(error);
41
+ return resolveFunc(api);
42
+ };
43
+ callback = prCallback;
44
+ }
45
+ const proceed = () => loginHelper(loginData.appState, loginData.Cookie, loginData.email, loginData.password, globalOptions, callback, prCallback);
46
+ if (config && config.autoUpdate) {
47
+ const p = checkAndUpdateVersion();
48
+ if (p && typeof p.then === "function") {
49
+ p.then(proceed).catch(err => callback(err));
50
+ } else {
51
+ proceed();
52
+ }
53
+ } else {
54
+ proceed();
55
+ }
56
+ return returnPromise;
57
+ }
58
+
59
+ module.exports = login;