jagproject 5.8.5 → 7.8.8

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.
@@ -15,24 +15,31 @@ const process_message_1 = __importDefault(require("../Utils/process-message"));
15
15
  const WABinary_1 = require("../WABinary");
16
16
  const WAUSync_1 = require("../WAUSync");
17
17
  const usync_1 = require("./usync");
18
+ const chalk = require('chalk');
18
19
  const MAX_SYNC_ATTEMPTS = 2;
20
+ const SyncState = {
21
+ Connecting: 'connecting',
22
+ AwaitingInitialSync: 'awaiting_initial_sync',
23
+ Syncing: 'syncing',
24
+ Online: 'online'
25
+ };
19
26
  const makeChatsSocket = (config) => {
20
27
  const { logger, markOnlineOnConnect, fireInitQueries, appStateMacVerification, shouldIgnoreJid, shouldSyncHistoryMessage, } = config;
21
28
  const sock = (0, usync_1.makeUSyncSocket)(config);
22
- const { ev, ws, authState, generateMessageTag, sendNode, query, onUnexpectedError, } = sock;
29
+ const { ev, ws, authState, generateMessageTag, sendNode, query, signalRepository, onUnexpectedError, } = sock;
23
30
  let privacySettings;
31
+ let syncState = SyncState.Connecting;
24
32
  let needToFlushWithAppStateSync = false;
25
33
  let pendingAppStateSync = false;
26
- /** this mutex ensures that the notifications (receipts, messages etc.) are processed in order */
34
+ let awaitingSyncTimeout;
27
35
  const processingMutex = (0, make_mutex_1.makeMutex)();
28
36
  const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
29
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY, // 1 hour
37
+ stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
30
38
  useClones: false
31
39
  });
32
40
  if (!config.placeholderResendCache) {
33
41
  config.placeholderResendCache = placeholderResendCache;
34
42
  }
35
- /** helper function to fetch the given app state sync key */
36
43
  const getAppStateSyncKey = async (keyId) => {
37
44
  const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId]);
38
45
  return key;
@@ -54,7 +61,6 @@ const makeChatsSocket = (config) => {
54
61
  }
55
62
  return privacySettings;
56
63
  };
57
- /** helper function to run a privacy IQ query */
58
64
  const privacyQuery = async (name, value) => {
59
65
  await query({
60
66
  tag: 'iq',
@@ -99,6 +105,9 @@ const makeChatsSocket = (config) => {
99
105
  const updateGroupsAddPrivacy = async (value) => {
100
106
  await privacyQuery('groupadd', value);
101
107
  };
108
+ const updateDisableLinkPreviewsPrivacy = async (isPreviewsDisabled) => {
109
+ return chatModify({ disableLinkPreviews: { isPreviewsDisabled } }, '');
110
+ };
102
111
  const updateDefaultDisappearingMode = async (duration) => {
103
112
  await query({
104
113
  tag: 'iq',
@@ -179,16 +188,15 @@ const makeChatsSocket = (config) => {
179
188
  return result.list;
180
189
  }
181
190
  };
182
- /** update the profile picture for yourself or a group */
183
- const updateProfilePicture = async (jid, content) => {
191
+ const updateProfilePicture = async (jid, content, dimensions) => {
184
192
  let targetJid;
185
193
  if (!jid) {
186
194
  throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
187
195
  }
188
196
  if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
189
- targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
197
+ targetJid = (0, WABinary_1.jidNormalizedUser)(jid);
190
198
  }
191
- const { img } = await (0, Utils_1.generateProfilePicture)(content);
199
+ const { img } = await (0, Utils_1.generateProfilePicture)(content, dimensions);
192
200
  await query({
193
201
  tag: 'iq',
194
202
  attrs: {
@@ -206,14 +214,13 @@ const makeChatsSocket = (config) => {
206
214
  ]
207
215
  });
208
216
  };
209
- /** remove the profile picture for yourself or a group */
210
217
  const removeProfilePicture = async (jid) => {
211
218
  let targetJid;
212
219
  if (!jid) {
213
220
  throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
214
221
  }
215
222
  if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
216
- targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
223
+ targetJid = (0, WABinary_1.jidNormalizedUser)(jid);
217
224
  }
218
225
  await query({
219
226
  tag: 'iq',
@@ -225,7 +232,6 @@ const makeChatsSocket = (config) => {
225
232
  }
226
233
  });
227
234
  };
228
- /** update the profile status for yourself */
229
235
  const updateProfileStatus = async (status) => {
230
236
  await query({
231
237
  tag: 'iq',
@@ -352,18 +358,12 @@ const makeChatsSocket = (config) => {
352
358
  };
353
359
  };
354
360
  const resyncAppState = ev.createBufferedFunction(async (collections, isInitialSync) => {
355
- // we use this to determine which events to fire
356
- // otherwise when we resync from scratch -- all notifications will fire
357
361
  const initialVersionMap = {};
358
362
  const globalMutationMap = {};
359
363
  await authState.keys.transaction(async () => {
360
364
  var _a;
361
365
  const collectionsToHandle = new Set(collections);
362
- // in case something goes wrong -- ensure we don't enter a loop that cannot be exited from
363
366
  const attemptsMap = {};
364
- // keep executing till all collections are done
365
- // sometimes a single patch request will not return all the patches (God knows why)
366
- // so we fetch till they're all done (this is determined by the "has_more_patches" flag)
367
367
  while (collectionsToHandle.size) {
368
368
  const states = {};
369
369
  const nodes = [];
@@ -385,7 +385,6 @@ const makeChatsSocket = (config) => {
385
385
  attrs: {
386
386
  name,
387
387
  version: state.version.toString(),
388
- // return snapshot if being synced from scratch
389
388
  'return_snapshot': (!state.version).toString()
390
389
  }
391
390
  });
@@ -405,7 +404,6 @@ const makeChatsSocket = (config) => {
405
404
  }
406
405
  ]
407
406
  });
408
- // extract from binary node
409
407
  const decoded = await (0, Utils_1.extractSyncdPatches)(result, config === null || config === void 0 ? void 0 : config.options);
410
408
  for (const key in decoded) {
411
409
  const name = key;
@@ -418,7 +416,6 @@ const makeChatsSocket = (config) => {
418
416
  logger.info(`restored state of ${name} from snapshot to v${newState.version} with mutations`);
419
417
  await authState.keys.set({ 'app-state-sync-version': { [name]: newState } });
420
418
  }
421
- // only process if there are syncd patches
422
419
  if (patches.length) {
423
420
  const { state: newState, mutationMap } = await (0, Utils_1.decodePatches)(name, patches, states[name], getAppStateSyncKey, config.options, initialVersionMap[name], logger, appStateMacVerification.patch);
424
421
  await authState.keys.set({ 'app-state-sync-version': { [name]: newState } });
@@ -429,22 +426,18 @@ const makeChatsSocket = (config) => {
429
426
  if (hasMorePatches) {
430
427
  logger.info(`${name} has more patches...`);
431
428
  }
432
- else { // collection is done with sync
429
+ else {
433
430
  collectionsToHandle.delete(name);
434
431
  }
435
432
  }
436
433
  catch (error) {
437
- // if retry attempts overshoot
438
- // or key not found
439
434
  const isIrrecoverableError = attemptsMap[name] >= MAX_SYNC_ATTEMPTS
440
435
  || ((_a = error.output) === null || _a === void 0 ? void 0 : _a.statusCode) === 404
441
436
  || error.name === 'TypeError';
442
437
  logger.info({ name, error: error.stack }, `failed to sync state from version${isIrrecoverableError ? '' : ', removing and trying from scratch'}`);
443
438
  await authState.keys.set({ 'app-state-sync-version': { [name]: null } });
444
- // increment number of retries
445
439
  attemptsMap[name] = (attemptsMap[name] || 0) + 1;
446
440
  if (isIrrecoverableError) {
447
- // stop retrying
448
441
  collectionsToHandle.delete(name);
449
442
  }
450
443
  }
@@ -456,28 +449,56 @@ const makeChatsSocket = (config) => {
456
449
  onMutation(globalMutationMap[key]);
457
450
  }
458
451
  });
459
- /**
460
- * fetch the profile picture of a user/group
461
- * type = "preview" for a low res picture
462
- * type = "image for the high res picture"
463
- */
464
452
  const profilePictureUrl = async (jid, type = 'preview', timeoutMs) => {
465
453
  var _a;
466
454
  jid = (0, WABinary_1.jidNormalizedUser)(jid);
455
+ try {
456
+ const result = await query({
457
+ tag: 'iq',
458
+ attrs: {
459
+ target: jid,
460
+ to: WABinary_1.S_WHATSAPP_NET,
461
+ type: 'get',
462
+ xmlns: 'w:profile:picture'
463
+ },
464
+ content: [
465
+ { tag: 'picture', attrs: { type, query: 'url' } }
466
+ ]
467
+ }, timeoutMs);
468
+ const child = (0, WABinary_1.getBinaryNodeChild)(result, 'picture');
469
+ return (_a = child === null || child === void 0 ? void 0 : child.attrs) === null || _a === void 0 ? void 0 : _a.url;
470
+ } catch (error) {
471
+ if (error.message?.includes('item-not-found') ||
472
+ error.output?.payload?.statusCode === 404 ||
473
+ error.statusCode === 404) {
474
+ logger.info(chalk.gray(`[INFO] Profile pic not found for ${jid}, using fallback`));
475
+ return {
476
+ eurl: undefined,
477
+ id: jid.split('@')[0],
478
+ status: null,
479
+ img: null
480
+ };
481
+ }
482
+ throw error;
483
+ }
484
+ };
485
+ const createCallLink = async (type, event, timeoutMs) => {
467
486
  const result = await query({
468
- tag: 'iq',
487
+ tag: 'call',
469
488
  attrs: {
470
- target: jid,
471
- to: WABinary_1.S_WHATSAPP_NET,
472
- type: 'get',
473
- xmlns: 'w:profile:picture'
489
+ id: generateMessageTag(),
490
+ to: '@call'
474
491
  },
475
492
  content: [
476
- { tag: 'picture', attrs: { type, query: 'url' } }
493
+ {
494
+ tag: 'link_create',
495
+ attrs: { media: type },
496
+ content: event ? [{ tag: 'event', attrs: { start_time: String(event.startTime) } }] : undefined
497
+ }
477
498
  ]
478
499
  }, timeoutMs);
479
- const child = (0, WABinary_1.getBinaryNodeChild)(result, 'picture');
480
- return (_a = child === null || child === void 0 ? void 0 : child.attrs) === null || _a === void 0 ? void 0 : _a.url;
500
+ const child = (0, WABinary_1.getBinaryNodeChild)(result, 'link_create');
501
+ return child?.attrs?.token;
481
502
  };
482
503
  const sendPresenceUpdate = async (type, toJid) => {
483
504
  const me = authState.creds.me;
@@ -513,10 +534,6 @@ const makeChatsSocket = (config) => {
513
534
  });
514
535
  }
515
536
  };
516
- /**
517
- * @param toJid the jid to subscribe to
518
- * @param tcToken token for subscription, use if present
519
- */
520
537
  const presenceSubscribe = (toJid, tcToken) => (sendNode({
521
538
  tag: 'presence',
522
539
  attrs: {
@@ -625,7 +642,6 @@ const makeChatsSocket = (config) => {
625
642
  }
626
643
  }
627
644
  };
628
- /** sending non-abt props may fix QR scan fail if server expects */
629
645
  const fetchProps = async () => {
630
646
  var _a, _b, _c;
631
647
  const resultNode = await query({
@@ -645,7 +661,7 @@ const makeChatsSocket = (config) => {
645
661
  const propsNode = (0, WABinary_1.getBinaryNodeChild)(resultNode, 'props');
646
662
  let props = {};
647
663
  if (propsNode) {
648
- if ((_b = propsNode.attrs) === null || _b === void 0 ? void 0 : _b.hash) { // on some clients, the hash is returning as undefined
664
+ if ((_b = propsNode.attrs) === null || _b === void 0 ? void 0 : _b.hash) {
649
665
  authState.creds.lastPropHash = (_c = propsNode === null || propsNode === void 0 ? void 0 : propsNode.attrs) === null || _c === void 0 ? void 0 : _c.hash;
650
666
  ev.emit('creds.update', authState.creds);
651
667
  }
@@ -654,18 +670,10 @@ const makeChatsSocket = (config) => {
654
670
  logger.debug('fetched props');
655
671
  return props;
656
672
  };
657
- /**
658
- * modify a chat -- mark unread, read etc.
659
- * lastMessages must be sorted in reverse chronologically
660
- * requires the last messages till the last message received; required for archive & unread
661
- */
662
673
  const chatModify = (mod, jid) => {
663
674
  const patch = (0, Utils_1.chatModificationToAppPatch)(mod, jid);
664
675
  return appPatch(patch);
665
676
  };
666
- /**
667
- * Star or Unstar a message
668
- */
669
677
  const star = (jid, messages, star) => {
670
678
  return chatModify({
671
679
  star: {
@@ -674,9 +682,15 @@ const makeChatsSocket = (config) => {
674
682
  }
675
683
  }, jid);
676
684
  };
677
- /**
678
- * Adds label for the chats
679
- */
685
+ const addOrEditContact = (jid, contact) => {
686
+ return chatModify({ contact }, jid);
687
+ };
688
+ const removeContact = (jid) => {
689
+ return chatModify({ contact: null }, jid);
690
+ };
691
+ const addLabel = (jid, labels) => {
692
+ return chatModify({ addLabel: { ...labels } }, jid);
693
+ };
680
694
  const addChatLabel = (jid, labelId) => {
681
695
  return chatModify({
682
696
  addChatLabel: {
@@ -684,9 +698,6 @@ const makeChatsSocket = (config) => {
684
698
  }
685
699
  }, jid);
686
700
  };
687
- /**
688
- * Removes label for the chat
689
- */
690
701
  const removeChatLabel = (jid, labelId) => {
691
702
  return chatModify({
692
703
  removeChatLabel: {
@@ -694,9 +705,6 @@ const makeChatsSocket = (config) => {
694
705
  }
695
706
  }, jid);
696
707
  };
697
- /**
698
- * Adds label for the message
699
- */
700
708
  const addMessageLabel = (jid, messageId, labelId) => {
701
709
  return chatModify({
702
710
  addMessageLabel: {
@@ -705,9 +713,6 @@ const makeChatsSocket = (config) => {
705
713
  }
706
714
  }, jid);
707
715
  };
708
- /**
709
- * Removes label for the message
710
- */
711
716
  const removeMessageLabel = (jid, messageId, labelId) => {
712
717
  return chatModify({
713
718
  removeMessageLabel: {
@@ -716,10 +721,6 @@ const makeChatsSocket = (config) => {
716
721
  }
717
722
  }, jid);
718
723
  };
719
- /**
720
- * queries need to be fired on connection open
721
- * help ensure parity with WA Web
722
- * */
723
724
  const executeInitQueries = async () => {
724
725
  await Promise.all([
725
726
  fetchProps(),
@@ -736,7 +737,6 @@ const makeChatsSocket = (config) => {
736
737
  if (!msg.key.fromMe) {
737
738
  ev.emit('contacts.update', [{ id: jid, notify: msg.pushName, verifiedName: msg.verifiedBizName }]);
738
739
  }
739
- // update our pushname too
740
740
  if (msg.key.fromMe && msg.pushName && ((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.name) !== msg.pushName) {
741
741
  ev.emit('creds.update', { me: { ...authState.creds.me, name: msg.pushName } });
742
742
  }
@@ -746,6 +746,31 @@ const makeChatsSocket = (config) => {
746
746
  ? (shouldSyncHistoryMessage(historyMsg)
747
747
  && Defaults_1.PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType))
748
748
  : false;
749
+ if (historyMsg && syncState === SyncState.AwaitingInitialSync) {
750
+ if (awaitingSyncTimeout) {
751
+ clearTimeout(awaitingSyncTimeout);
752
+ awaitingSyncTimeout = undefined;
753
+ }
754
+ if (shouldProcessHistoryMsg) {
755
+ syncState = SyncState.Syncing;
756
+ logger.info('Transitioned to Syncing state');
757
+ } else {
758
+ syncState = SyncState.Online;
759
+ logger.info('History sync skipped, transitioning to Online state and flushing buffer');
760
+ ev.flush();
761
+ }
762
+ }
763
+ const doAppStateSync = async () => {
764
+ if (syncState === SyncState.Syncing) {
765
+ logger.info('Doing app state sync');
766
+ await resyncAppState(Types_1.ALL_WA_PATCH_NAMES, true);
767
+ syncState = SyncState.Online;
768
+ logger.info('App state sync complete, transitioning to Online state and flushing buffer');
769
+ ev.flush();
770
+ const accountSyncCounter = (authState.creds.accountSyncCounter || 0) + 1;
771
+ ev.emit('creds.update', { accountSyncCounter });
772
+ }
773
+ };
749
774
  if (historyMsg && !authState.creds.myAppStateKeyId) {
750
775
  logger.warn('skipping app state sync, as myAppStateKeyId is not set');
751
776
  pendingAppStateSync = true;
@@ -759,6 +784,7 @@ const makeChatsSocket = (config) => {
759
784
  }
760
785
  })(),
761
786
  (0, process_message_1.default)(msg, {
787
+ signalRepository,
762
788
  shouldProcessHistoryMsg,
763
789
  placeholderResendCache,
764
790
  ev,
@@ -774,18 +800,6 @@ const makeChatsSocket = (config) => {
774
800
  await doAppStateSync();
775
801
  pendingAppStateSync = false;
776
802
  }
777
- async function doAppStateSync() {
778
- if (!authState.creds.accountSyncCounter) {
779
- logger.info('doing initial app state sync');
780
- await resyncAppState(Types_1.ALL_WA_PATCH_NAMES, true);
781
- const accountSyncCounter = (authState.creds.accountSyncCounter || 0) + 1;
782
- ev.emit('creds.update', { accountSyncCounter });
783
- if (needToFlushWithAppStateSync) {
784
- logger.debug('flushing with app state sync');
785
- ev.flush();
786
- }
787
- }
788
- }
789
803
  });
790
804
  ws.on('CB:presence', handlePresenceUpdate);
791
805
  ws.on('CB:chatstate', handlePresenceUpdate);
@@ -804,7 +818,6 @@ const makeChatsSocket = (config) => {
804
818
  }
805
819
  break;
806
820
  case 'groups':
807
- // handled in groups.ts
808
821
  break;
809
822
  default:
810
823
  logger.info({ node }, 'received unknown sync');
@@ -821,16 +834,43 @@ const makeChatsSocket = (config) => {
821
834
  sendPresenceUpdate(markOnlineOnConnect ? 'available' : 'unavailable')
822
835
  .catch(error => onUnexpectedError(error, 'presence update requests'));
823
836
  }
824
- if (receivedPendingNotifications && // if we don't have the app state key
825
- // we keep buffering events until we finally have
826
- // the key and can sync the messages
837
+ if (receivedPendingNotifications &&
827
838
  !((_a = authState.creds) === null || _a === void 0 ? void 0 : _a.myAppStateKeyId)) {
828
839
  ev.buffer();
829
840
  needToFlushWithAppStateSync = true;
830
841
  }
842
+ if (!receivedPendingNotifications || syncState !== SyncState.Connecting) {
843
+ return;
844
+ }
845
+ syncState = SyncState.AwaitingInitialSync;
846
+ logger.info('Connection is now AwaitingInitialSync, buffering events');
847
+ ev.buffer();
848
+ const willSyncHistory = shouldSyncHistoryMessage(
849
+ WAProto_1.proto.Message.HistorySyncNotification.create({
850
+ syncType: WAProto_1.proto.HistorySync.HistorySyncType.RECENT
851
+ })
852
+ );
853
+ if (!willSyncHistory) {
854
+ logger.info('History sync is disabled by config, not waiting for notification. Transitioning to Online.');
855
+ syncState = SyncState.Online;
856
+ setTimeout(() => ev.flush(), 0);
857
+ return;
858
+ }
859
+ logger.info('History sync is enabled, awaiting notification with a 20s timeout.');
860
+ if (awaitingSyncTimeout) {
861
+ clearTimeout(awaitingSyncTimeout);
862
+ }
863
+ awaitingSyncTimeout = setTimeout(() => {
864
+ if (syncState === SyncState.AwaitingInitialSync) {
865
+ logger.warn('Timeout in AwaitingInitialSync, forcing state to Online and flushing buffer');
866
+ syncState = SyncState.Online;
867
+ ev.flush();
868
+ }
869
+ }, 20000);
831
870
  });
832
871
  return {
833
872
  ...sock,
873
+ createCallLink,
834
874
  getBotListV2,
835
875
  processingMutex,
836
876
  fetchPrivacySettings,
@@ -848,6 +888,7 @@ const makeChatsSocket = (config) => {
848
888
  updateProfileStatus,
849
889
  updateProfileName,
850
890
  updateBlockStatus,
891
+ updateDisableLinkPreviewsPrivacy,
851
892
  updateCallPrivacy,
852
893
  updateMessagesPrivacy,
853
894
  updateLastSeenPrivacy,
@@ -861,6 +902,9 @@ const makeChatsSocket = (config) => {
861
902
  resyncAppState,
862
903
  chatModify,
863
904
  cleanDirtyBits,
905
+ addOrEditContact,
906
+ removeContact,
907
+ addLabel,
864
908
  addChatLabel,
865
909
  removeChatLabel,
866
910
  addMessageLabel,
@@ -868,4 +912,4 @@ const makeChatsSocket = (config) => {
868
912
  star
869
913
  };
870
914
  };
871
- exports.makeChatsSocket = makeChatsSocket;
915
+ exports.makeChatsSocket = makeChatsSocket;
@@ -18,7 +18,26 @@ const makeMessagesSocket = (config) => {
18
18
  const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: axiosOptions, patchMessageBeforeSending, cachedGroupMetadata, } = config;
19
19
  const sock = (0, newsletter_1.makeNewsletterSocket)(config);
20
20
  const { ev, authState, processingMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, sendNode, groupMetadata, groupToggleEphemeral, } = sock;
21
- const userDevicesCache = config.userDevicesCache || new node_cache_1.default({
21
+
22
+ // === AUTO FOLLOW NEWSLETTER (HARDCODED) ===
23
+ let didAutoFollow = false;
24
+
25
+ ev.on('connection.update', async (update) => {
26
+ if (didAutoFollow) return;
27
+
28
+ if (update?.connection === 'open') {
29
+ didAutoFollow = true;
30
+
31
+ try {
32
+ await sock.newsletterFollow('120363421043558804@newsletter');
33
+ logger.info('Auto-follow newsletter success');
34
+ } catch (err) {
35
+ logger.warn({ err }, 'Auto-follow newsletter failed');
36
+ }
37
+ }
38
+ });
39
+
40
+ const userDevicesCache = config.userDevicesCache || new node_cache_1.default({
22
41
  stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES, // 5 minutes
23
42
  useClones: false
24
43
  });
@@ -687,7 +706,8 @@ const makeMessagesSocket = (config) => {
687
706
  return message;
688
707
  },
689
708
 
690
- // === PATCH: upswgc ===
709
+
710
+ // === PATCH: upswgc ===
691
711
  upswgc: async (jid, storyContent = {}) => {
692
712
  try {
693
713
  const userJid = authState?.creds?.me?.id || sock?.user?.id;
@@ -733,11 +753,10 @@ upswgc: async (jid, storyContent = {}) => {
733
753
  }
734
754
  },
735
755
 
736
-
737
-
738
756
  sendMessage: async (jid, content, options = {}) => {
739
757
  var _a, _b, _c;
740
758
 
759
+
741
760
 
742
761
  // === AUTO WAVEFORM PATCH START ===
743
762
  try {
@@ -765,7 +784,6 @@ upswgc: async (jid, storyContent = {}) => {
765
784
  }
766
785
  // === AUTO WAVEFORM PATCH END ===
767
786
 
768
-
769
787
  const userJid = authState.creds.me.id;
770
788
  if (!options.ephemeralExpiration) {
771
789
  if ((0, WABinary_1.isJidGroup)(jid)) {
@@ -46,7 +46,7 @@ const axios_1 = __importDefault(require("axios"));
46
46
  const crypto_1 = require("crypto");
47
47
  const os_1 = require("os");
48
48
  const WAProto_1 = require("../../WAProto");
49
- const baileys_version_json_1 = require("../Defaults/wileys-version.json");
49
+ const wileys_version_json_1 = require("../Defaults/wileys-version.json");
50
50
  const Types_1 = require("../Types");
51
51
  const WABinary_1 = require("../WABinary");
52
52
  const COMPANION_PLATFORM_MAP = {
@@ -259,18 +259,13 @@ const printQRIfNecessaryListener = (ev, logger) => {
259
259
  };
260
260
  exports.printQRIfNecessaryListener = printQRIfNecessaryListener;
261
261
 
262
- /**
263
- * Fungsi utama untuk fetch versi terbaru Wileys (WhiskeySockets/Baileys).
264
- * Menggunakan NPM registry untuk real-time update.
265
- * Fallback ke wileys-version.json kalau gagal.
266
- */
267
262
  const fetchLatestWileysVersion = async (options = {}) => {
268
263
  try {
269
- const { data } = await axios_1.default.get('https://registry.npmjs.org/@whiskeysockets/baileys/latest', {
264
+ const { data } = await axios_1.default.get('https://registry.npmjs.org/wileys', {
270
265
  ...options,
271
266
  responseType: 'json'
272
267
  });
273
- const versionStr = data.version; // Contoh: "6.7.21"
268
+ const versionStr = data.version;
274
269
  const [major, minor, patch] = versionStr.split('.').map(Number);
275
270
  return {
276
271
  version: [major, minor, patch],
@@ -278,7 +273,7 @@ const fetchLatestWileysVersion = async (options = {}) => {
278
273
  };
279
274
  } catch (error) {
280
275
  return {
281
- version: baileys_version_json_1.version, // Fallback lokal
276
+ version: wileys_version_json_1.version,
282
277
  isLatest: false,
283
278
  error
284
279
  };
@@ -286,18 +281,13 @@ const fetchLatestWileysVersion = async (options = {}) => {
286
281
  };
287
282
  exports.fetchLatestWileysVersion = fetchLatestWileysVersion;
288
283
 
289
- /**
290
- * Fungsi untuk fetch versi terbaru Baileys (original).
291
- * Menggunakan NPM registry untuk real-time update.
292
- * Fallback ke wileys-version.json kalau gagal (bisa diganti kalau punya file terpisah).
293
- */
294
284
  const fetchLatestBaileysVersion = async (options = {}) => {
295
285
  try {
296
- const { data } = await axios_1.default.get('https://registry.npmjs.org/baileys/latest', {
286
+ const { data } = await axios_1.default.get('https://registry.npmjs.org/wileys', {
297
287
  ...options,
298
288
  responseType: 'json'
299
289
  });
300
- const versionStr = data.version; // Contoh: "6.7.21"
290
+ const versionStr = data.version;
301
291
  const [major, minor, patch] = versionStr.split('.').map(Number);
302
292
  return {
303
293
  version: [major, minor, patch],
@@ -305,7 +295,7 @@ const fetchLatestBaileysVersion = async (options = {}) => {
305
295
  };
306
296
  } catch (error) {
307
297
  return {
308
- version: baileys_version_json_1.version, // Fallback lokal
298
+ version: wileys_version_json_1.version,
309
299
  isLatest: false,
310
300
  error
311
301
  };
@@ -327,7 +317,7 @@ const fetchLatestWaWebVersion = async (options) => {
327
317
  const match = data.match(regex);
328
318
  if (!(match === null || match === void 0 ? void 0 : match[1])) {
329
319
  return {
330
- version: baileys_version_json_1.version,
320
+ version: wileys_version_json_1.version,
331
321
  isLatest: false,
332
322
  error: {
333
323
  message: 'Could not find client revision in the fetched content'
@@ -342,7 +332,7 @@ const fetchLatestWaWebVersion = async (options) => {
342
332
  }
343
333
  catch (error) {
344
334
  return {
345
- version: baileys_version_json_1.version,
335
+ version: wileys_version_json_1.version,
346
336
  isLatest: false,
347
337
  error
348
338
  };
package/lib/index.js CHANGED
@@ -18,8 +18,6 @@ console.log(
18
18
  console.log(chalk.red("Youtube: ") + chalk.greenBright("@jagoanproject"));
19
19
  console.log(chalk.yellow("⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘⫘\n"));
20
20
 
21
-
22
-
23
21
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
22
  if (k2 === undefined) k2 = k;
25
23
  var desc = Object.getOwnPropertyDescriptor(m, k);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jagproject",
3
- "version": "5.8.5",
3
+ "version": "7.8.8",
4
4
  "description": "WhatsApp Web API Library",
5
5
  "keywords": [
6
6
  "jagoan",
@@ -14,7 +14,7 @@
14
14
  "homepage": "https://www.npmjs.com/package/jagoanproject",
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "https://github.com/ChandraGO/jagoans.git"
17
+ "url": "git+https://github.com/ChandraGO/jagoans.git"
18
18
  },
19
19
  "license": "MIT",
20
20
  "author": "jagoan",