bb-fca 2.0.9 → 2.0.10

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.
Files changed (81) hide show
  1. package/dist/deltas/apis/messaging/editMessage.js +13 -24
  2. package/dist/deltas/apis/messaging/editMessage.js.map +1 -1
  3. package/dist/deltas/apis/messaging/emoji.js +34 -88
  4. package/dist/deltas/apis/messaging/emoji.js.map +1 -1
  5. package/dist/deltas/apis/messaging/gcmember.js +48 -101
  6. package/dist/deltas/apis/messaging/gcmember.js.map +1 -1
  7. package/dist/deltas/apis/messaging/gcname.js +28 -79
  8. package/dist/deltas/apis/messaging/gcname.js.map +1 -1
  9. package/dist/deltas/apis/messaging/gcrule.js +47 -105
  10. package/dist/deltas/apis/messaging/gcrule.js.map +1 -1
  11. package/dist/deltas/apis/messaging/markAsDelivered.js +10 -12
  12. package/dist/deltas/apis/messaging/markAsDelivered.js.map +1 -1
  13. package/dist/deltas/apis/messaging/markAsRead.js +25 -60
  14. package/dist/deltas/apis/messaging/markAsRead.js.map +1 -1
  15. package/dist/deltas/apis/messaging/markAsReadAll.js +9 -11
  16. package/dist/deltas/apis/messaging/markAsReadAll.js.map +1 -1
  17. package/dist/deltas/apis/messaging/markAsSeen.js +10 -37
  18. package/dist/deltas/apis/messaging/markAsSeen.js.map +1 -1
  19. package/dist/deltas/apis/messaging/nickname.js +38 -98
  20. package/dist/deltas/apis/messaging/nickname.js.map +1 -1
  21. package/dist/deltas/apis/messaging/notes.js +52 -90
  22. package/dist/deltas/apis/messaging/notes.js.map +1 -1
  23. package/dist/deltas/apis/messaging/resolvePhotoUrl.js +17 -42
  24. package/dist/deltas/apis/messaging/resolvePhotoUrl.js.map +1 -1
  25. package/dist/deltas/apis/messaging/sendMessage.js +14 -15
  26. package/dist/deltas/apis/messaging/sendMessage.js.map +1 -1
  27. package/dist/deltas/apis/messaging/sendTypingIndicator.js +7 -13
  28. package/dist/deltas/apis/messaging/sendTypingIndicator.js.map +1 -1
  29. package/dist/deltas/apis/messaging/setMessageReaction.js +24 -14
  30. package/dist/deltas/apis/messaging/setMessageReaction.js.map +1 -1
  31. package/dist/deltas/apis/messaging/shareContact.js +14 -12
  32. package/dist/deltas/apis/messaging/shareContact.js.map +1 -1
  33. package/dist/deltas/apis/messaging/stickers.js +4 -5
  34. package/dist/deltas/apis/messaging/stickers.js.map +1 -1
  35. package/dist/deltas/apis/messaging/theme.js +142 -213
  36. package/dist/deltas/apis/messaging/theme.js.map +1 -1
  37. package/dist/deltas/apis/messaging/unsendMessage.js +14 -7
  38. package/dist/deltas/apis/messaging/unsendMessage.js.map +1 -1
  39. package/dist/deltas/apis/posting/group.js +33 -11
  40. package/dist/deltas/apis/posting/group.js.map +1 -1
  41. package/dist/types/deltas/apis/messaging/editMessage.d.ts +4 -5
  42. package/dist/types/deltas/apis/messaging/emoji.d.ts +7 -1
  43. package/dist/types/deltas/apis/messaging/gcmember.d.ts +7 -1
  44. package/dist/types/deltas/apis/messaging/gcname.d.ts +9 -1
  45. package/dist/types/deltas/apis/messaging/gcrule.d.ts +7 -1
  46. package/dist/types/deltas/apis/messaging/markAsDelivered.d.ts +1 -2
  47. package/dist/types/deltas/apis/messaging/markAsRead.d.ts +1 -1
  48. package/dist/types/deltas/apis/messaging/markAsReadAll.d.ts +1 -2
  49. package/dist/types/deltas/apis/messaging/markAsSeen.d.ts +1 -1
  50. package/dist/types/deltas/apis/messaging/nickname.d.ts +7 -1
  51. package/dist/types/deltas/apis/messaging/notes.d.ts +13 -11
  52. package/dist/types/deltas/apis/messaging/resolvePhotoUrl.d.ts +4 -6
  53. package/dist/types/deltas/apis/messaging/sendMessage.d.ts +1 -1
  54. package/dist/types/deltas/apis/messaging/sendTypingIndicator.d.ts +1 -1
  55. package/dist/types/deltas/apis/messaging/setMessageReaction.d.ts +6 -1
  56. package/dist/types/deltas/apis/messaging/shareContact.d.ts +1 -2
  57. package/dist/types/deltas/apis/messaging/stickers.d.ts +1 -1
  58. package/dist/types/deltas/apis/messaging/theme.d.ts +8 -1
  59. package/dist/types/deltas/apis/messaging/unsendMessage.d.ts +6 -1
  60. package/package.json +1 -1
  61. package/src/deltas/apis/messaging/editMessage.ts +16 -26
  62. package/src/deltas/apis/messaging/emoji.ts +45 -97
  63. package/src/deltas/apis/messaging/gcmember.ts +68 -113
  64. package/src/deltas/apis/messaging/gcname.ts +42 -91
  65. package/src/deltas/apis/messaging/gcrule.ts +61 -111
  66. package/src/deltas/apis/messaging/markAsDelivered.ts +19 -14
  67. package/src/deltas/apis/messaging/markAsRead.ts +45 -72
  68. package/src/deltas/apis/messaging/markAsReadAll.ts +17 -17
  69. package/src/deltas/apis/messaging/markAsSeen.ts +17 -41
  70. package/src/deltas/apis/messaging/nickname.ts +50 -116
  71. package/src/deltas/apis/messaging/notes.ts +59 -95
  72. package/src/deltas/apis/messaging/resolvePhotoUrl.ts +27 -50
  73. package/src/deltas/apis/messaging/sendMessage.ts +28 -26
  74. package/src/deltas/apis/messaging/sendTypingIndicator.ts +13 -12
  75. package/src/deltas/apis/messaging/setMessageReaction.ts +45 -20
  76. package/src/deltas/apis/messaging/shareContact.ts +25 -15
  77. package/src/deltas/apis/messaging/stickers.ts +4 -4
  78. package/src/deltas/apis/messaging/theme.ts +172 -259
  79. package/src/deltas/apis/messaging/unsendMessage.ts +23 -7
  80. package/src/deltas/apis/posting/group.ts +36 -11
  81. package/request.txt +0 -60
@@ -12,10 +12,14 @@ const allowedProperties = {
12
12
  location: true,
13
13
  };
14
14
 
15
- export default function(defaultFuncs: any, api: any, ctx: any) {
16
- async function uploadAttachment(attachments) {
17
- var uploads = [];
18
- for (var i = 0; i < attachments.length; i++) {
15
+ export default function sendMessage(
16
+ defaultFuncs: any,
17
+ api: any,
18
+ ctx: any,
19
+ ): Function {
20
+ async function uploadAttachment(attachments: any[]): Promise<any[]> {
21
+ const uploads: any[] = [];
22
+ for (let i = 0; i < attachments.length; i++) {
19
23
  if (!utils.isReadableStream(attachments[i])) {
20
24
  throw new Error(
21
25
  'Attachment should be a readable stream and not ' +
@@ -42,7 +46,7 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
42
46
  return uploads;
43
47
  }
44
48
 
45
- async function getUrl(url) {
49
+ async function getUrl(url: string): Promise<any> {
46
50
  const resData = await defaultFuncs
47
51
  .post(
48
52
  'https://www.facebook.com/message_share_attachment/fromURI/',
@@ -60,19 +64,18 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
60
64
  }
61
65
 
62
66
  async function sendContent(
63
- form,
64
- threadID,
65
- isSingleUser,
66
- messageAndOTID,
67
- callback?,
68
- ) {
67
+ form: Record<string, any>,
68
+ threadID: any,
69
+ isSingleUser: boolean,
70
+ messageAndOTID: string,
71
+ ): Promise<any> {
69
72
  // There are three cases here:
70
73
  // 1. threadID is of type array, where we're starting a new group chat with users
71
74
  // specified in the array.
72
75
  // 2. User is sending a message to a specific user.
73
76
  // 3. No additional form params and the message goes to an existing group chat.
74
77
  if (utils.getType(threadID) === 'Array') {
75
- for (var i = 0; i < threadID.length; i++) {
78
+ for (let i = 0; i < threadID.length; i++) {
76
79
  form['specific_to_list[' + i + ']'] = 'fbid:' + threadID[i];
77
80
  }
78
81
  form['specific_to_list[' + threadID.length + ']'] = 'fbid:' + ctx.userID;
@@ -131,10 +134,15 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
131
134
  return messageInfo;
132
135
  }
133
136
 
134
- return async (msg, threadID, replyToMessage, isSingleUser = false) => {
135
- let msgType = utils.getType(msg);
136
- let threadIDType = utils.getType(threadID);
137
- let messageIDType = utils.getType(replyToMessage);
137
+ return async function sendMessage(
138
+ msg: any,
139
+ threadID: any,
140
+ replyToMessage?: string,
141
+ isSingleUser: boolean = false,
142
+ ): Promise<any> {
143
+ const msgType = utils.getType(msg);
144
+ const threadIDType = utils.getType(threadID);
145
+ const messageIDType = utils.getType(replyToMessage);
138
146
  if (msgType !== 'String' && msgType !== 'Object')
139
147
  throw new Error(
140
148
  'Message should be of type string or object and not ' + msgType + '.',
@@ -156,7 +164,7 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
156
164
  if (msgType === 'String') {
157
165
  msg = { body: msg };
158
166
  }
159
- let disallowedProperties = Object.keys(msg).filter(
167
+ const disallowedProperties = Object.keys(msg).filter(
160
168
  (prop) => !allowedProperties[prop],
161
169
  );
162
170
  if (disallowedProperties.length > 0) {
@@ -164,8 +172,8 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
164
172
  'Dissallowed props: `' + disallowedProperties.join(', ') + '`',
165
173
  );
166
174
  }
167
- let messageAndOTID = utils.generateOfflineThreadingID();
168
- let form: Record<string, any> = {
175
+ const messageAndOTID = utils.generateOfflineThreadingID();
176
+ const form: Record<string, any> = {
169
177
  client: 'mercury',
170
178
  action_type: 'ma-type:user-generated-message',
171
179
  author: 'fbid:' + ctx.userID,
@@ -275,12 +283,6 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
275
283
  form['profile_xmd[' + i + '][type]'] = 'p';
276
284
  }
277
285
  }
278
- const result = await sendContent(
279
- form,
280
- threadID,
281
- isSingleUser,
282
- messageAndOTID,
283
- );
284
- return result;
286
+ return await sendContent(form, threadID, isSingleUser, messageAndOTID);
285
287
  };
286
288
  }
@@ -1,6 +1,4 @@
1
1
  // @ChoruOfficial
2
- 'use strict';
3
-
4
2
  import utils = require('../../../utils');
5
3
 
6
4
  /**
@@ -8,16 +6,21 @@ import utils = require('../../../utils');
8
6
  * @param {Object} api
9
7
  * @param {Object} ctx
10
8
  */
11
- export default function(defaultFuncs: any, api: any, ctx: any) {
9
+ export default function sendTypingIndicator(
10
+ defaultFuncs: any,
11
+ api: any,
12
+ ctx: any,
13
+ ): Function {
12
14
  /**
13
15
  * Sends a typing indicator to a specific thread.
14
- * @param {boolean} sendTyping - True to show typing indicator, false to hide.
15
- * @param {string} threadID - The ID of the thread to send the typing indicator to.
16
- * @param {Function} [callback] - An optional callback function.
16
+ * @param {boolean} sendTyping - True to show typing, false to hide.
17
+ * @param {string} threadID - The ID of the thread.
17
18
  * @returns {Promise<void>}
18
19
  */
19
- return async function sendTypingIndicatorV2(sendTyping, threadID, callback) {
20
- let count_req = 0;
20
+ return async function sendTypingIndicator(
21
+ sendTyping: boolean,
22
+ threadID: string,
23
+ ): Promise<void> {
21
24
  const wsContent = {
22
25
  app_id: 2220391788200892,
23
26
  payload: JSON.stringify({
@@ -30,9 +33,10 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
30
33
  }),
31
34
  version: 5849951561777440,
32
35
  }),
33
- request_id: ++count_req,
36
+ request_id: ++ctx.wsReqNumber,
34
37
  type: 4,
35
38
  };
39
+
36
40
  await new Promise<void>((resolve, reject) =>
37
41
  ctx.mqttClient.publish(
38
42
  '/ls_req',
@@ -41,8 +45,5 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
41
45
  (err, _packet) => (err ? reject(err) : resolve()),
42
46
  ),
43
47
  );
44
- if (callback) {
45
- callback();
46
- }
47
48
  };
48
49
  }
@@ -1,25 +1,50 @@
1
- import utils = require("../../../utils");
1
+ import utils = require('../../../utils');
2
2
  // @NethWs3Dev
3
3
 
4
- export default function(defaultFuncs: any, api: any, ctx: any) {
5
- return async (reaction, messageID) => {
6
- if (!reaction) throw new Error("Please enter a valid emoji.");
7
- const defData = await defaultFuncs.postFormData("https://www.facebook.com/webgraphql/mutation/", ctx.jar, {}, {
8
- doc_id: "1491398900900362",
9
- variables: JSON.stringify({
10
- data: {
11
- client_mutation_id: ctx.clientMutationId++,
12
- actor_id: ctx.userID,
13
- action: reaction == "" ? "REMOVE_REACTION" : "ADD_REACTION",
14
- message_id: messageID,
15
- reaction
16
- }
17
- }),
18
- dpr: 1
19
- });
20
- const resData = await utils.parseAndCheckLogin(ctx.jar, defaultFuncs)(defData);
4
+ /**
5
+ * @param {Object} defaultFuncs
6
+ * @param {Object} api
7
+ * @param {Object} ctx
8
+ */
9
+ export default function setMessageReaction(
10
+ defaultFuncs: any,
11
+ api: any,
12
+ ctx: any,
13
+ ): Function {
14
+ /**
15
+ * Sets or removes a reaction on a message.
16
+ * @param {string} reaction - The emoji to react with, or empty string to remove.
17
+ * @param {string} messageID - The ID of the message to react to.
18
+ * @returns {Promise<void>}
19
+ */
20
+ return async function setMessageReaction(
21
+ reaction: string,
22
+ messageID: string,
23
+ ): Promise<void> {
24
+ if (!reaction && reaction !== '')
25
+ throw new Error('Please enter a valid emoji.');
26
+ const defData = await defaultFuncs.postFormData(
27
+ 'https://www.facebook.com/webgraphql/mutation/',
28
+ ctx.jar,
29
+ {},
30
+ {
31
+ doc_id: '1491398900900362',
32
+ variables: JSON.stringify({
33
+ data: {
34
+ client_mutation_id: ctx.clientMutationId++,
35
+ actor_id: ctx.userID,
36
+ action:
37
+ reaction === '' ? 'REMOVE_REACTION' : 'ADD_REACTION',
38
+ message_id: messageID,
39
+ reaction,
40
+ },
41
+ }),
42
+ dpr: 1,
43
+ },
44
+ );
45
+ const resData = await utils.parseAndCheckLogin(ctx, defaultFuncs)(defData);
21
46
  if (!resData) {
22
- throw new Error("setMessageReactionLegacy returned empty object.");
47
+ throw new Error('setMessageReaction returned empty object.');
23
48
  }
24
49
  };
25
- };
50
+ }
@@ -1,36 +1,44 @@
1
- import utils = require("../../../utils");
1
+ import utils = require('../../../utils');
2
2
 
3
3
  /**
4
4
  * @module shareContact
5
5
  * @param {Object} defaultFuncs - The default functions provided by the API.
6
6
  * @param {Object} api - The full API object.
7
7
  * @param {Object} ctx - The context object.
8
- * @returns {function(text: string, senderID: string, threadID: string, callback: Function): void} - A function to share a contact.
9
8
  */
10
- export default function(defaultFuncs: any, api: any, ctx: any) {
9
+ export default function shareContact(
10
+ defaultFuncs: any,
11
+ api: any,
12
+ ctx: any,
13
+ ): Function {
11
14
  /**
12
15
  * Shares a user's contact information into a specific thread via MQTT.
13
- * @param {string} [text] - An optional message to send along with the contact card.
14
- * @param {string} senderID - The Facebook user ID of the contact you want to share.
16
+ * @param {string} text - An optional message to send along with the contact card.
17
+ * @param {string} senderID - The Facebook user ID of the contact to share.
15
18
  * @param {string} threadID - The ID of the thread where the contact will be shared.
16
- * @param {Function} [callback] - An optional callback function to be executed.
19
+ * @param {Function} [callback] - An optional callback function.
20
+ * @returns {void}
17
21
  */
18
- return function shareContact(text, senderID, threadID, callback) {
22
+ return function shareContact(
23
+ text: string,
24
+ senderID: string,
25
+ threadID: string,
26
+ callback?: Function,
27
+ ): void {
19
28
  if (!ctx.mqttClient) {
20
29
  throw new Error('Not connected to MQTT');
21
30
  }
22
31
 
23
32
  ctx.wsReqNumber ??= 0;
24
33
  ctx.wsTaskNumber ??= 0;
25
-
26
34
  ctx.wsReqNumber += 1;
27
35
  ctx.wsTaskNumber += 1;
28
36
 
29
37
  const queryPayload = {
30
38
  contact_id: senderID,
31
39
  sync_group: 1,
32
- text: text || "",
33
- thread_id: threadID
40
+ text: text || '',
41
+ thread_id: threadID,
34
42
  };
35
43
 
36
44
  const query = {
@@ -38,7 +46,7 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
38
46
  label: '359',
39
47
  payload: JSON.stringify(queryPayload),
40
48
  queue_name: 'messenger_contact_sharing',
41
- task_id: Math.random() * 1001 << 0,
49
+ task_id: Math.trunc(Math.random() * 1001),
42
50
  };
43
51
 
44
52
  const context: any = {
@@ -51,13 +59,15 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
51
59
  request_id: ctx.wsReqNumber,
52
60
  type: 3,
53
61
  };
54
-
55
62
  context.payload = JSON.stringify(context.payload);
56
63
 
57
64
  if (typeof callback === 'function') {
58
- ctx.callback_Task[ctx.wsReqNumber] = { callback, type: "shareContact" };
65
+ ctx.callback_Task[ctx.wsReqNumber] = { callback, type: 'shareContact' };
59
66
  }
60
67
 
61
- ctx.mqttClient.publish('/ls_req', JSON.stringify(context), { qos: 1, retain: false });
68
+ ctx.mqttClient.publish('/ls_req', JSON.stringify(context), {
69
+ qos: 1,
70
+ retain: false,
71
+ });
62
72
  };
63
- };
73
+ }
@@ -15,7 +15,7 @@ function formatPackList(data) {
15
15
  const storePacks = data?.data?.viewer?.sticker_store?.available_packs?.edges;
16
16
 
17
17
  const packData = storePacks || trayPacks;
18
- if (!packData || !packData.edges) return { packs: [], page_info: { has_next_page: false } };
18
+ if (!packData?.edges) return { packs: [], page_info: { has_next_page: false } };
19
19
 
20
20
  const formattedPacks = packData.edges.map(edge => edge.node ? ({
21
21
  id: edge.node.id,
@@ -85,7 +85,7 @@ function formatAiStickers(data) {
85
85
  })).filter(Boolean);
86
86
  }
87
87
 
88
- export default function(defaultFuncs: any, api: any, ctx: any) {
88
+ export default function stickers(defaultFuncs: any, api: any, ctx: any) {
89
89
  /**
90
90
  * Make a GraphQL request and handle login and error checking
91
91
  * @param {object} form - Form data for the request
@@ -159,7 +159,7 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
159
159
  allPacks.push(...packs);
160
160
  utils.log(`Fetched first page with ${packs.length} packs.`);
161
161
 
162
- while (page_info && page_info.has_next_page) {
162
+ while (page_info?.has_next_page) {
163
163
  utils.log("Fetching next page with cursor:", page_info.end_cursor);
164
164
 
165
165
  const paginatedForm = {
@@ -252,4 +252,4 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
252
252
  return formatAiStickers(res);
253
253
  }
254
254
  };
255
- };
255
+ }