bb-fca 2.0.8 → 2.0.9

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.
@@ -5,7 +5,7 @@ import utils = require('../../../utils');
5
5
  * @description A module for joining, leaving, and listing Facebook groups.
6
6
  * @license Ex-it
7
7
  */
8
- export default function(defaultFuncs: any, api: any, ctx: any) {
8
+ export default function (defaultFuncs: any, api: any, ctx: any) {
9
9
  /**
10
10
  * Deep-searches an object/array tree for the first value matching a predicate.
11
11
  */
@@ -163,7 +163,9 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
163
163
  /**
164
164
  * Builds the GraphQL POST form for groups pagination.
165
165
  */
166
- function buildGroupsGraphQLForm(variables: object): Record<string, string> {
166
+ function buildGroupsGraphQLForm(
167
+ variables: object,
168
+ ): Record<string, string> {
167
169
  return {
168
170
  av: ctx.userID,
169
171
  __user: ctx.userID,
@@ -172,7 +174,8 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
172
174
  jazoest: ctx.jazoest,
173
175
  lsd: ctx.lsd,
174
176
  fb_api_caller_class: 'RelayModern',
175
- fb_api_req_friendly_name: 'GroupsCometJoinedGroupsListPaginationQuery',
177
+ fb_api_req_friendly_name:
178
+ 'GroupsCometJoinedGroupsListPaginationQuery',
176
179
  variables: JSON.stringify(variables),
177
180
  server_timestamps: 'true',
178
181
  doc_id: '8957838874246460',
@@ -273,83 +276,46 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
273
276
  * @returns {Promise<Object>} A promise that resolves to the API response data on success.
274
277
  * @throws {Error} If the groupID is missing or the API request fails.
275
278
  */
276
- join: async function(groupID: string, inviteShortLinkKey?: string | null) {
279
+ join: async function (groupID: string) {
277
280
  if (!groupID) throw new Error('groupID is required.');
278
281
 
279
- const actorId = ctx.i_userID || ctx.userID;
280
-
281
282
  const variables = {
282
- feedType: 'DISCUSSION',
283
- groupID: groupID,
284
283
  input: {
285
- action_source: 'GROUP_MALL',
284
+ group_id: groupID,
285
+ group_share_tracking_params: null,
286
+ join_action_source: 'GROUP_HEADER',
286
287
  attribution_id_v2:
287
- 'CometGroupDiscussionRoot.react,comet.group,via_cold_start,' +
288
+ 'GroupsCometGroupHeaderActionButton.react,comet.group,via_cold_start,' +
288
289
  Date.now() +
289
- ',874165,2361831622,,',
290
- group_id: groupID,
291
- group_share_tracking_params: {
292
- app_id: '2220391788200892',
293
- exp_id: 'null',
294
- is_from_share: false,
295
- },
296
- actor_id: actorId,
297
- client_mutation_id: '1',
290
+ ',,,',
291
+ actor_id: ctx.userID,
292
+ client_mutation_id: Math.floor(Math.random() * 10 + 1).toString(),
298
293
  },
299
- inviteShortLinkKey: inviteShortLinkKey ?? null,
300
- isChainingRecommendationUnit: false,
301
294
  scale: 1,
302
- source: 'GROUP_MALL',
303
- renderLocation: 'group_mall',
304
- __relay_internal__pv__groups_comet_use_glvrelayprovider: false,
305
- __relay_internal__pv__GroupsCometGYSJUnifiedUnitCardImageHeightrelayprovider: 150,
306
- __relay_internal__pv__GroupsCometGroupChatLazyLoadLastMessageSnippetrelayprovider: false,
307
295
  };
308
296
 
309
297
  const form = {
310
- av: actorId,
311
- __aaid: '0',
312
- __user: actorId,
298
+ av: ctx.userID,
299
+ __user: ctx.userID,
313
300
  __a: '1',
314
- __req: '18',
315
- __hs: '20530.HCSV2:comet_pkg.2.1...0',
316
- dpr: '1',
317
- __ccg: 'GOOD',
318
- __comet_req: '15',
319
301
  fb_dtsg: ctx.fb_dtsg,
320
302
  jazoest: ctx.jazoest,
321
303
  lsd: ctx.lsd,
322
- __spin_r: '1035418183',
323
- __spin_b: 'trunk',
324
- __spin_t: Math.floor(Date.now() / 1000).toString(),
325
- __crn: 'comet.fbweb.CometGroupDiscussionRoute',
326
304
  fb_api_caller_class: 'RelayModern',
327
- fb_api_req_friendly_name: 'GroupCometJoinForumMutation',
305
+ fb_api_req_friendly_name: 'GroupCometJoinMutation',
328
306
  variables: JSON.stringify(variables),
329
- server_timestamps: 'true',
330
- doc_id: '26180016991684264',
331
- };
332
-
333
- const customHeader = {
334
- 'x-fb-friendly-name': 'GroupCometJoinForumMutation',
335
- 'x-fb-lsd': ctx.lsd || '',
336
- 'x-asbd-id': '359341',
337
- origin: 'https://www.facebook.com',
338
- referer: `https://www.facebook.com/groups/${groupID}`,
307
+ doc_id: '6192959194068498',
339
308
  };
340
309
 
341
- const res = await utils.post(
310
+ const res = await defaultFuncs.post(
342
311
  'https://www.facebook.com/api/graphql/',
343
312
  ctx.jar,
344
313
  form,
345
- ctx.globalOptions,
346
- ctx,
347
- customHeader,
314
+ {},
348
315
  );
349
316
 
350
- const data = parseResponseBody(res.body);
351
- if (data?.errors) throw new Error(JSON.stringify(data.errors));
352
- return data?.data ?? data;
317
+ if (res.data?.errors) throw new Error(JSON.stringify(res.data.errors));
318
+ return res.data?.data ?? res.data;
353
319
  },
354
320
 
355
321
  /**
@@ -359,151 +325,45 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
359
325
  * @returns {Promise<Object>} A promise that resolves to the API response data on success.
360
326
  * @throws {Error} If the groupID is missing or the API request fails.
361
327
  */
362
- leave: async function(groupID: string) {
328
+ leave: async function (groupID: string) {
363
329
  if (!groupID) throw new Error('groupID is required.');
364
330
 
365
- const actorId = ctx.i_userID || ctx.userID;
366
-
367
331
  const variables = {
368
332
  input: {
369
- attribution_id_v2:
370
- 'CometGroupDiscussionRoot.react,comet.group,via_cold_start,' +
371
- Date.now() +
372
- ',243486,2361831622,,',
373
333
  group_id: groupID,
374
- actor_id: actorId,
375
- client_mutation_id: '1',
376
- },
377
- inviteShortLinkKey: null,
378
- isChainingRecommendationUnit: false,
379
- ordering: ['viewer_added'],
380
- scale: 1,
381
- groupID: groupID,
382
- __relay_internal__pv__GroupsCometGYSJUnifiedUnitCardImageHeightrelayprovider: 150,
383
- __relay_internal__pv__GroupsCometGroupChatLazyLoadLastMessageSnippetrelayprovider: false,
384
- };
385
-
386
- const form = {
387
- av: actorId,
388
- __aaid: '0',
389
- __user: actorId,
390
- __a: '1',
391
- __req: '1f',
392
- __hs: '20530.HCSV2:comet_pkg.2.1...0',
393
- dpr: '1',
394
- __ccg: 'EXCELLENT',
395
- __comet_req: '15',
396
- fb_dtsg: ctx.fb_dtsg,
397
- jazoest: ctx.jazoest,
398
- lsd: ctx.lsd,
399
- __spin_r: '1035418183',
400
- __spin_b: 'trunk',
401
- __spin_t: Math.floor(Date.now() / 1000).toString(),
402
- __crn: 'comet.fbweb.CometGroupDiscussionRoute',
403
- fb_api_caller_class: 'RelayModern',
404
- fb_api_req_friendly_name: 'GroupCometLeaveForumMutation',
405
- variables: JSON.stringify(variables),
406
- server_timestamps: 'true',
407
- doc_id: '26077711195170900',
408
- };
409
-
410
- const customHeader = {
411
- 'x-fb-friendly-name': 'GroupCometLeaveForumMutation',
412
- 'x-fb-lsd': ctx.lsd || '',
413
- 'x-asbd-id': '359341',
414
- origin: 'https://www.facebook.com',
415
- referer: `https://www.facebook.com/groups/${groupID}`,
416
- };
417
-
418
- const res = await utils.post(
419
- 'https://www.facebook.com/api/graphql/',
420
- ctx.jar,
421
- form,
422
- ctx.globalOptions,
423
- ctx,
424
- customHeader,
425
- );
426
-
427
- const data = parseResponseBody(res.body);
428
- if (data?.errors) throw new Error(JSON.stringify(data.errors));
429
- return data?.data ?? data;
430
- },
431
-
432
- /**
433
- * Invites friends to a Facebook group.
434
- * @async
435
- * @param {string} groupID The ID of the group to invite friends to.
436
- * @param {string[]} userIDs Array of user IDs to invite.
437
- * @returns {Promise<Object>} A promise that resolves to the API response data on success.
438
- * @throws {Error} If the groupID or userIDs are missing or the API request fails.
439
- */
440
- inviteFriends: async function(groupID: string, userIDs: string[]) {
441
- if (!groupID) throw new Error('groupID is required.');
442
- if (!userIDs?.length)
443
- throw new Error('userIDs is required and must not be empty.');
444
-
445
- const actorId = ctx.i_userID || ctx.userID;
446
-
447
- const variables = {
448
- input: {
334
+ action_source: 'GROUP_HEADER',
449
335
  attribution_id_v2:
450
- 'CometGroupDiscussionRoot.react,comet.group,via_cold_start,' +
336
+ 'GroupsCometGroupHeaderActionButton.react,comet.group,via_cold_start,' +
451
337
  Date.now() +
452
- ',829526,2361831622,,',
453
- email_addresses: [],
454
- group_id: groupID,
455
- source: 'comet_invite_friends',
456
- user_ids: userIDs,
457
- actor_id: actorId,
458
- client_mutation_id: '2',
338
+ ',,,',
339
+ actor_id: ctx.userID,
340
+ client_mutation_id: Math.floor(Math.random() * 10 + 1).toString(),
459
341
  },
460
- groupID: groupID,
342
+ scale: 1,
461
343
  };
462
344
 
463
345
  const form = {
464
- av: actorId,
465
- __aaid: '0',
466
- __user: actorId,
346
+ av: ctx.userID,
347
+ __user: ctx.userID,
467
348
  __a: '1',
468
- __req: '1a',
469
- __hs: '20530.HCSV2:comet_pkg.2.1...0',
470
- dpr: '1',
471
- __ccg: 'EXCELLENT',
472
- __comet_req: '15',
473
349
  fb_dtsg: ctx.fb_dtsg,
474
350
  jazoest: ctx.jazoest,
475
351
  lsd: ctx.lsd,
476
- __spin_r: '1035418183',
477
- __spin_b: 'trunk',
478
- __spin_t: Math.floor(Date.now() / 1000).toString(),
479
- __crn: 'comet.fbweb.CometGroupDiscussionRoute',
480
352
  fb_api_caller_class: 'RelayModern',
481
- fb_api_req_friendly_name: 'useGroupAddMembersMutation',
353
+ fb_api_req_friendly_name: 'GroupCometLeaveMutation',
482
354
  variables: JSON.stringify(variables),
483
- server_timestamps: 'true',
484
- doc_id: '25892331960437758',
485
- };
486
-
487
- const customHeader = {
488
- 'x-fb-friendly-name': 'useGroupAddMembersMutation',
489
- 'x-fb-lsd': ctx.lsd || '',
490
- 'x-asbd-id': '359341',
491
- origin: 'https://www.facebook.com',
492
- referer: `https://www.facebook.com/groups/${groupID}`,
355
+ doc_id: '5583297681747014',
493
356
  };
494
357
 
495
- const res = await utils.post(
358
+ const res = await defaultFuncs.post(
496
359
  'https://www.facebook.com/api/graphql/',
497
360
  ctx.jar,
498
361
  form,
499
- ctx.globalOptions,
500
- ctx,
501
- customHeader,
362
+ {},
502
363
  );
503
364
 
504
- const data = parseResponseBody(res.body);
505
- if (data?.errors) throw new Error(JSON.stringify(data.errors));
506
- return data?.data ?? data;
365
+ if (res.data?.errors) throw new Error(JSON.stringify(res.data.errors));
366
+ return res.data?.data ?? res.data;
507
367
  },
508
368
 
509
369
  /**
@@ -523,7 +383,7 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
523
383
  * // Page 2+
524
384
  * const page2 = await api.group.getJoinedGroups(page1.endCursor);
525
385
  */
526
- getJoinedGroups: async function(
386
+ getJoinedGroups: async function (
527
387
  cursor: string | null = null,
528
388
  count: number = 10,
529
389
  ): Promise<JoinedGroupsResult> {
@@ -603,7 +463,7 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
603
463
  * @param {{ limit?: number; cursor?: string | null; locale?: string }} [options]
604
464
  * @returns {Promise<{ groups: any[]; cursor: string | null; hasNextPage: boolean }>} Search result and pagination info.
605
465
  */
606
- searchGroup: async function(
466
+ searchGroup: async function (
607
467
  keyword: string,
608
468
  options: { limit?: number; cursor?: string | null; locale?: string } = {},
609
469
  ): Promise<{ groups: any[]; cursor: string | null; hasNextPage: boolean }> {
@@ -664,25 +524,37 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
664
524
  stream_initial_count: 0,
665
525
  useDefaultActor: false,
666
526
  __relay_internal__pv__GHLShouldChangeAdIdFieldNamerelayprovider: true,
667
- __relay_internal__pv__GHLShouldChangeSponsoredDataFieldNamerelayprovider: true,
668
- __relay_internal__pv__CometFeedStory_enable_post_permalink_white_space_clickrelayprovider: false,
669
- __relay_internal__pv__CometUFICommentActionLinksRewriteEnabledrelayprovider: false,
670
- __relay_internal__pv__CometUFICommentAvatarStickerAnimatedImagerelayprovider: false,
527
+ __relay_internal__pv__GHLShouldChangeSponsoredDataFieldNamerelayprovider:
528
+ true,
529
+ __relay_internal__pv__CometFeedStory_enable_post_permalink_white_space_clickrelayprovider:
530
+ false,
531
+ __relay_internal__pv__CometUFICommentActionLinksRewriteEnabledrelayprovider:
532
+ false,
533
+ __relay_internal__pv__CometUFICommentAvatarStickerAnimatedImagerelayprovider:
534
+ false,
671
535
  __relay_internal__pv__IsWorkUserrelayprovider: false,
672
- __relay_internal__pv__TestPilotShouldIncludeDemoAdUseCaserelayprovider: false,
673
- __relay_internal__pv__FBReels_deprecate_short_form_video_context_gkrelayprovider: true,
674
- __relay_internal__pv__FBReels_enable_view_dubbed_audio_type_gkrelayprovider: true,
675
- __relay_internal__pv__CometImmersivePhotoCanUserDisable3DMotionrelayprovider: false,
536
+ __relay_internal__pv__TestPilotShouldIncludeDemoAdUseCaserelayprovider:
537
+ false,
538
+ __relay_internal__pv__FBReels_deprecate_short_form_video_context_gkrelayprovider:
539
+ true,
540
+ __relay_internal__pv__FBReels_enable_view_dubbed_audio_type_gkrelayprovider:
541
+ true,
542
+ __relay_internal__pv__CometImmersivePhotoCanUserDisable3DMotionrelayprovider:
543
+ false,
676
544
  __relay_internal__pv__WorkCometIsEmployeeGKProviderrelayprovider: false,
677
545
  __relay_internal__pv__IsMergQAPollsrelayprovider: false,
678
- __relay_internal__pv__FBReelsMediaFooter_comet_enable_reels_ads_gkrelayprovider: true,
679
- __relay_internal__pv__CometUFIReactionsEnableShortNamerelayprovider: false,
546
+ __relay_internal__pv__FBReelsMediaFooter_comet_enable_reels_ads_gkrelayprovider:
547
+ true,
548
+ __relay_internal__pv__CometUFIReactionsEnableShortNamerelayprovider:
549
+ false,
680
550
  __relay_internal__pv__CometUFICommentAutoTranslationTyperelayprovider:
681
551
  'ORIGINAL',
682
552
  __relay_internal__pv__CometUFIShareActionMigrationrelayprovider: true,
683
553
  __relay_internal__pv__CometUFISingleLineUFIrelayprovider: false,
684
- __relay_internal__pv__CometUFI_dedicated_comment_routable_dialog_gkrelayprovider: true,
685
- __relay_internal__pv__FBReelsIFUTileContent_reelsIFUPlayOnHoverrelayprovider: true,
554
+ __relay_internal__pv__CometUFI_dedicated_comment_routable_dialog_gkrelayprovider:
555
+ true,
556
+ __relay_internal__pv__FBReelsIFUTileContent_reelsIFUPlayOnHoverrelayprovider:
557
+ true,
686
558
  __relay_internal__pv__GroupsCometGYSJFeedItemHeightrelayprovider: 150,
687
559
  __relay_internal__pv__ShouldEnableBakedInTextStoriesrelayprovider: false,
688
560
  __relay_internal__pv__StoriesShouldIncludeFbNotesrelayprovider: false,
@@ -708,9 +580,7 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
708
580
  'x-fb-lsd': ctx.lsd || '',
709
581
  'x-asbd-id': '359341',
710
582
  origin: 'https://www.facebook.com',
711
- referer: `https://www.facebook.com/groups/search/groups_home?q=${encodeURIComponent(
712
- keyword,
713
- )}&locale=${encodeURIComponent(locale)}`,
583
+ referer: `https://www.facebook.com/groups/search/groups_home?q=${encodeURIComponent(keyword)}&locale=${encodeURIComponent(locale)}`,
714
584
  };
715
585
 
716
586
  const res = await utils.post(
@@ -737,17 +607,6 @@ export default function(defaultFuncs: any, api: any, ctx: any) {
737
607
  hasNextPage: Boolean(pageInfo.has_next_page),
738
608
  };
739
609
  },
740
-
741
- /**
742
- * Alias for searchGroup.
743
- * @see searchGroup
744
- */
745
- searchGroups: async function(
746
- keyword: string,
747
- options: { limit?: number; cursor?: string | null; locale?: string } = {},
748
- ): Promise<{ groups: any[]; cursor: string | null; hasNextPage: boolean }> {
749
- return groupModule.searchGroup(keyword, options);
750
- },
751
610
  };
752
611
 
753
612
  return groupModule;