@realvare/based 2.7.5 → 2.7.51

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.
@@ -299,17 +299,8 @@ const makeMessagesRecvSocket = (config) => {
299
299
  case 'remove':
300
300
  case 'add':
301
301
  case 'leave':
302
- const stubType = `GROUP_PARTICIPANT_${child.tag.toUpperCase()}`;
303
- msg.messageStubType = Types_1.WAMessageStubType[stubType];
304
- const participants = (0, WABinary_1.getBinaryNodeChildren)(child, 'participant').map(p => p.attrs.jid);
305
- if (participants.length === 1 &&
306
- // if recv. "remove" message and sender removed themselves
307
- // mark as left
308
- (0, WABinary_1.areJidsSameUser)(participants[0], participant) &&
309
- child.tag === 'remove') {
310
- msg.messageStubType = Types_1.WAMessageStubType.GROUP_PARTICIPANT_LEAVE;
311
- }
312
- msg.messageStubParameters = participants;
302
+ msg.messageStubType = Types_1.WAMessageStubType.GROUP_PARTICIPANT_LEAVE;
303
+ msg.messageStubParameters = [participant];
313
304
  break;
314
305
  case 'subject':
315
306
  msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_SUBJECT;
@@ -815,19 +806,7 @@ const makeMessagesRecvSocket = (config) => {
815
806
  await Promise.all([
816
807
  processingMutex.mutex(async () => {
817
808
  var _a, _b, _c, _d, _e, _f;
818
- try {
819
- await decrypt();
820
- } catch (error) {
821
- if(error.message.includes('Bad MAC') || error.message.includes('No matching sessions')) {
822
- logger.warn({ key: msg.key, jid: author, error: error.message }, 'Decryption failed, clearing session to recover');
823
- const { SessionRecord } = require('../Signal');
824
- await signalRepository.storeSession(author, new SessionRecord());
825
- return sendMessageAck(node, Utils_1.NACK_REASONS.ParsingError);
826
- }
827
-
828
- throw error;
829
- }
830
-
809
+ await decrypt();
831
810
  // message failed to decrypt
832
811
  if (msg.messageStubType === WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT) {
833
812
  if (((_a = msg === null || msg === void 0 ? void 0 : msg.messageStubParameters) === null || _a === void 0 ? void 0 : _a[0]) === Utils_1.MISSING_KEYS_ERROR_TEXT) {
@@ -859,9 +838,8 @@ const makeMessagesRecvSocket = (config) => {
859
838
  if (msg.message.extendedTextMessage.contextInfo) {
860
839
  const metadata = await groupMetadata(msg.key.remoteJid);
861
840
  const sender = msg.message.extendedTextMessage.contextInfo.participant;
862
- const found = metadata.participants.find(p => p.id === sender);
863
- msg.message.extendedTextMessage.contextInfo.participant = (found === null || found === void 0 ? void 0 : found.jid) || sender;
864
- }
841
+ const found = metadata.participants.find(p => p.id === sender);
842
+ msg.message.extendedTextMessage.contextInfo.participant = (found === null || found === void 0 ? void 0 : found.jid) || (0, WABinary_1.lidToJid)(sender); }
865
843
  }
866
844
  if (!(0, WABinary_1.isJidGroup)(msg.key.remoteJid) && (0, WABinary_1.isLidUser)(msg.key.remoteJid)) {
867
845
  msg.key.remoteJid = node.attrs.sender_pn || node.attrs.peer_recipient_pn;
@@ -937,13 +915,15 @@ const makeMessagesRecvSocket = (config) => {
937
915
  }],
938
916
  peerDataOperationRequestType: WAProto_1.proto.Message.PeerDataOperationRequestType.PLACEHOLDER_MESSAGE_RESEND
939
917
  };
940
- setTimeout(() => {
941
- if (placeholderResendCache.get(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id)) {
942
- logger.debug({ messageKey }, 'PDO message without response after 15 seconds. Phone possibly offline');
943
- placeholderResendCache.del(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id);
944
- }
945
- }, 15000);
946
- return sendPeerDataOperationMessage(pdoMessage);
918
+ const result = await Promise.race([
919
+ sendPeerDataOperationMessage(pdoMessage),
920
+ (0, Utils_1.delay)(15000).then(() => 'timeout')
921
+ ]);
922
+ if (result === 'timeout') {
923
+ logger.debug({ messageKey }, 'PDO message without response after 15 seconds. Phone possibly offline');
924
+ placeholderResendCache.del(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id);
925
+ }
926
+ return result;
947
927
  };
948
928
  const handleCall = async (node) => {
949
929
  const { attrs } = node;
@@ -2,6 +2,6 @@ export declare const makeMutex: () => {
2
2
  mutex<T>(code: () => Promise<T> | T): Promise<T>;
3
3
  };
4
4
  export type Mutex = ReturnType<typeof makeMutex>;
5
- export declare const makeKeyedMutex: () => {
5
+ export declare const makeKeyedMutex: (maxQueueSize?: number) => {
6
6
  mutex<T>(key: string, task: () => Promise<T> | T): Promise<T>;
7
7
  };
@@ -29,12 +29,12 @@ const makeMutex = () => {
29
29
  };
30
30
  };
31
31
  exports.makeMutex = makeMutex;
32
- const makeKeyedMutex = () => {
32
+ const makeKeyedMutex = (maxQueueSize = 1000) => {
33
33
  const map = {};
34
34
  return {
35
35
  mutex(key, task) {
36
36
  if (!map[key]) {
37
- map[key] = (0, exports.makeMutex)();
37
+ map[key] = (0, exports.makeMutex)(maxQueueSize);
38
38
  }
39
39
  return map[key].mutex(task);
40
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realvare/based",
3
- "version": "2.7.5",
3
+ "version": "2.7.51",
4
4
  "description": "whatsapp api by sam",
5
5
  "keywords": [
6
6
  "baileys",
@@ -72,7 +72,7 @@
72
72
  "jest": "^29.7.0",
73
73
  "jimp": "^1.6.0",
74
74
  "json": "^11.0.0",
75
- "link-preview-js": "^3.0.0",
75
+ "link-preview-js": "^4.0.0",
76
76
  "open": "^10.1.0",
77
77
  "qrcode-terminal": "^0.12.0",
78
78
  "release-it": "^16.1.0",
@@ -84,7 +84,7 @@
84
84
  },
85
85
  "peerDependencies": {
86
86
  "audio-decode": "^2.1.3",
87
- "link-preview-js": "^3.0.0",
87
+ "link-preview-js": "^4.0.0",
88
88
  "qrcode-terminal": "^0.12.0",
89
89
  "sharp": "^0.33.0"
90
90
  },