bb-fca 2.0.8 → 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 (105) hide show
  1. package/dist/core/models/buildAPI.js +3 -3
  2. package/dist/core/models/buildAPI.js.map +1 -1
  3. package/dist/core/models/loginHelper.js +29 -28
  4. package/dist/core/models/loginHelper.js.map +1 -1
  5. package/dist/deltas/apis/create.js +9 -0
  6. package/dist/deltas/apis/create.js.map +1 -1
  7. package/dist/deltas/apis/messaging/editMessage.js +13 -24
  8. package/dist/deltas/apis/messaging/editMessage.js.map +1 -1
  9. package/dist/deltas/apis/messaging/emoji.js +34 -88
  10. package/dist/deltas/apis/messaging/emoji.js.map +1 -1
  11. package/dist/deltas/apis/messaging/gcmember.js +48 -101
  12. package/dist/deltas/apis/messaging/gcmember.js.map +1 -1
  13. package/dist/deltas/apis/messaging/gcname.js +28 -79
  14. package/dist/deltas/apis/messaging/gcname.js.map +1 -1
  15. package/dist/deltas/apis/messaging/gcrule.js +47 -105
  16. package/dist/deltas/apis/messaging/gcrule.js.map +1 -1
  17. package/dist/deltas/apis/messaging/markAsDelivered.js +10 -12
  18. package/dist/deltas/apis/messaging/markAsDelivered.js.map +1 -1
  19. package/dist/deltas/apis/messaging/markAsRead.js +25 -60
  20. package/dist/deltas/apis/messaging/markAsRead.js.map +1 -1
  21. package/dist/deltas/apis/messaging/markAsReadAll.js +9 -11
  22. package/dist/deltas/apis/messaging/markAsReadAll.js.map +1 -1
  23. package/dist/deltas/apis/messaging/markAsSeen.js +10 -37
  24. package/dist/deltas/apis/messaging/markAsSeen.js.map +1 -1
  25. package/dist/deltas/apis/messaging/nickname.js +38 -98
  26. package/dist/deltas/apis/messaging/nickname.js.map +1 -1
  27. package/dist/deltas/apis/messaging/notes.js +52 -90
  28. package/dist/deltas/apis/messaging/notes.js.map +1 -1
  29. package/dist/deltas/apis/messaging/resolvePhotoUrl.js +17 -42
  30. package/dist/deltas/apis/messaging/resolvePhotoUrl.js.map +1 -1
  31. package/dist/deltas/apis/messaging/sendMessage.js +14 -15
  32. package/dist/deltas/apis/messaging/sendMessage.js.map +1 -1
  33. package/dist/deltas/apis/messaging/sendTypingIndicator.js +7 -13
  34. package/dist/deltas/apis/messaging/sendTypingIndicator.js.map +1 -1
  35. package/dist/deltas/apis/messaging/setMessageReaction.js +24 -14
  36. package/dist/deltas/apis/messaging/setMessageReaction.js.map +1 -1
  37. package/dist/deltas/apis/messaging/shareContact.js +14 -12
  38. package/dist/deltas/apis/messaging/shareContact.js.map +1 -1
  39. package/dist/deltas/apis/messaging/stickers.js +4 -5
  40. package/dist/deltas/apis/messaging/stickers.js.map +1 -1
  41. package/dist/deltas/apis/messaging/theme.js +142 -213
  42. package/dist/deltas/apis/messaging/theme.js.map +1 -1
  43. package/dist/deltas/apis/messaging/unsendMessage.js +14 -7
  44. package/dist/deltas/apis/messaging/unsendMessage.js.map +1 -1
  45. package/dist/deltas/apis/posting/group.js +22 -129
  46. package/dist/deltas/apis/posting/group.js.map +1 -1
  47. package/dist/deltas/apis/posting/post.js +805 -12
  48. package/dist/deltas/apis/posting/post.js.map +1 -1
  49. package/dist/index.d.ts +35 -58
  50. package/dist/types/deltas/apis/create.d.ts +9 -0
  51. package/dist/types/deltas/apis/messaging/editMessage.d.ts +4 -5
  52. package/dist/types/deltas/apis/messaging/emoji.d.ts +7 -1
  53. package/dist/types/deltas/apis/messaging/gcmember.d.ts +7 -1
  54. package/dist/types/deltas/apis/messaging/gcname.d.ts +9 -1
  55. package/dist/types/deltas/apis/messaging/gcrule.d.ts +7 -1
  56. package/dist/types/deltas/apis/messaging/markAsDelivered.d.ts +1 -2
  57. package/dist/types/deltas/apis/messaging/markAsRead.d.ts +1 -1
  58. package/dist/types/deltas/apis/messaging/markAsReadAll.d.ts +1 -2
  59. package/dist/types/deltas/apis/messaging/markAsSeen.d.ts +1 -1
  60. package/dist/types/deltas/apis/messaging/nickname.d.ts +7 -1
  61. package/dist/types/deltas/apis/messaging/notes.d.ts +13 -11
  62. package/dist/types/deltas/apis/messaging/resolvePhotoUrl.d.ts +4 -6
  63. package/dist/types/deltas/apis/messaging/sendMessage.d.ts +1 -1
  64. package/dist/types/deltas/apis/messaging/sendTypingIndicator.d.ts +1 -1
  65. package/dist/types/deltas/apis/messaging/setMessageReaction.d.ts +6 -1
  66. package/dist/types/deltas/apis/messaging/shareContact.d.ts +1 -2
  67. package/dist/types/deltas/apis/messaging/stickers.d.ts +1 -1
  68. package/dist/types/deltas/apis/messaging/theme.d.ts +8 -1
  69. package/dist/types/deltas/apis/messaging/unsendMessage.d.ts +6 -1
  70. package/dist/types/deltas/apis/posting/group.d.ts +1 -23
  71. package/dist/types/deltas/apis/posting/post.d.ts +23 -0
  72. package/dist/types/utils/constants.d.ts +26 -16
  73. package/dist/utils/constants.js +42 -29
  74. package/dist/utils/constants.js.map +1 -1
  75. package/package.json +1 -1
  76. package/src/core/models/buildAPI.ts +3 -3
  77. package/src/core/models/loginHelper.ts +32 -30
  78. package/src/deltas/apis/create.ts +10 -0
  79. package/src/deltas/apis/messaging/editMessage.ts +16 -26
  80. package/src/deltas/apis/messaging/emoji.ts +45 -97
  81. package/src/deltas/apis/messaging/gcmember.ts +68 -113
  82. package/src/deltas/apis/messaging/gcname.ts +42 -91
  83. package/src/deltas/apis/messaging/gcrule.ts +61 -111
  84. package/src/deltas/apis/messaging/markAsDelivered.ts +19 -14
  85. package/src/deltas/apis/messaging/markAsRead.ts +45 -72
  86. package/src/deltas/apis/messaging/markAsReadAll.ts +17 -17
  87. package/src/deltas/apis/messaging/markAsSeen.ts +17 -41
  88. package/src/deltas/apis/messaging/nickname.ts +50 -116
  89. package/src/deltas/apis/messaging/notes.ts +59 -95
  90. package/src/deltas/apis/messaging/resolvePhotoUrl.ts +27 -50
  91. package/src/deltas/apis/messaging/sendMessage.ts +28 -26
  92. package/src/deltas/apis/messaging/sendTypingIndicator.ts +13 -12
  93. package/src/deltas/apis/messaging/setMessageReaction.ts +45 -20
  94. package/src/deltas/apis/messaging/shareContact.ts +25 -15
  95. package/src/deltas/apis/messaging/stickers.ts +4 -4
  96. package/src/deltas/apis/messaging/theme.ts +172 -259
  97. package/src/deltas/apis/messaging/unsendMessage.ts +23 -7
  98. package/src/deltas/apis/posting/group.ts +56 -172
  99. package/src/deltas/apis/posting/post.ts +932 -33
  100. package/src/types/index.d.ts +35 -58
  101. package/src/utils/constants.ts +84 -57
  102. package/a.html +0 -537
  103. package/a.json +0 -5915
  104. package/src/utils/formatters.old.ts +0 -1049
  105. package/task.txt +0 -24
@@ -1,56 +1,33 @@
1
- import utils = require("../../../utils");
1
+ import utils = require('../../../utils');
2
2
 
3
3
  /**
4
4
  * @module resolvePhotoUrl
5
- * @description Fetches the direct URL of a Facebook photo using its photo ID.
6
- * @param {Object} defaultFuncs - An object containing default request functions.
7
- * @param {Object} api - Facebook API object (unused here but kept for compatibility).
8
- * @param {Object} ctx - Context object containing cookies (jar) and other session info.
9
- * @returns {Function} resolvePhotoUrl - A function that takes a photo ID and optional callback, and returns a Promise resolving to the photo URL.
5
+ * @param {Object} defaultFuncs
6
+ * @param {Object} api
7
+ * @param {Object} ctx
10
8
  */
11
- export default function(defaultFuncs: any, api: any, ctx: any) {
12
-   /**
13
-    * @function resolvePhotoUrl
14
-    * @param {string} photoID - The ID of the Facebook photo to resolve.
15
-    * @param {Function} [callback] - Optional Node-style callback function `(err, photoUrl)`.
16
-    * @returns {Promise<string>} A Promise that resolves to the direct photo URL.
17
-    */
18
-   return function resolvePhotoUrl(photoID, callback) {
19
-     let resolveFunc: Function = function () {};
20
-     let rejectFunc: Function = function () {};
21
-     const returnPromise = new Promise<any>(function (resolve, reject) {
22
-       resolveFunc = resolve;
23
-       rejectFunc = reject;
24
-     });
9
+ export default function resolvePhotoUrl(
10
+ defaultFuncs: any,
11
+ api: any,
12
+ ctx: any,
13
+ ): Function {
14
+ /**
15
+ * Fetches the direct URL of a Facebook photo by its photo ID.
16
+ * @param {string} photoID - The ID of the Facebook photo.
17
+ * @returns {Promise<string>} Resolves to the direct photo URL.
18
+ */
19
+ return async function resolvePhotoUrl(photoID: string): Promise<string> {
20
+ const resData = await defaultFuncs
21
+ .get('https://www.facebook.com/mercury/attachments/photo', ctx.jar, {
22
+ photo_id: photoID,
23
+ })
24
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs));
25
25
 
26
-     if (!callback) {
27
-       callback = function (err, photoUrl) {
28
-         if (err) {
29
-           return rejectFunc(err);
30
-         }
31
-         resolveFunc(photoUrl);
32
-       };
33
-     }
26
+ if (resData.error) {
27
+ utils.error('resolvePhotoUrl', resData.error);
28
+ throw resData;
29
+ }
34
30
 
35
-     defaultFuncs
36
-       .get("https://www.facebook.com/mercury/attachments/photo", ctx.jar, {
37
-         photo_id: photoID,
38
-       })
39
-       .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
40
-       .then((resData) => {
41
-         if (resData.error) {
42
-           throw resData;
43
-         }
44
-
45
-         const photoUrl = resData.jsmods.require[0][3][0];
46
-
47
-         return callback(null, photoUrl);
48
-       })
49
-       .catch((err) => {
50
-         utils.error("resolvePhotoUrl", err);
51
-         return callback(err);
52
-       });
53
-
54
-     return returnPromise;
55
-   };
56
- };
31
+ return resData.jsmods.require[0][3][0];
32
+ };
33
+ }
@@ -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
+ }