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