xmd-baileys 1.0.10 → 1.0.12

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.
@@ -82,8 +82,8 @@ exports.DEFAULT_CONNECTION_CONFIG = {
82
82
  emitOwnEvents: !0,
83
83
  defaultQueryTimeoutMs: 6E4,
84
84
  customUploadHosts: [],
85
- retryRequestDelayMs: 250,
86
- maxMsgRetryCount: 5,
85
+ retryRequestDelayMs: 50,
86
+ maxMsgRetryCount: 3,
87
87
  fireInitQueries: !0,
88
88
  auth: void 0,
89
89
  markOnlineOnConnect: !0,
@@ -92,7 +92,7 @@ exports.DEFAULT_CONNECTION_CONFIG = {
92
92
  shouldSyncHistoryMessage: () => !0,
93
93
  shouldIgnoreJid: () => !1,
94
94
  linkPreviewImageThumbnailWidth: 192,
95
- transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3E3 },
95
+ transactionOpts: { maxCommitRetries: 5, delayBetweenTriesMs: 500 },
96
96
  generateHighQualityLinkPreview: !1,
97
97
  options: {},
98
98
  appStateMacVerification: { patch: !1, snapshot: !1 },
@@ -43,10 +43,21 @@ const Group_1 = require("./Group");
43
43
  function makeLibSignalRepository(auth) {
44
44
  const storage = signalStorage(auth);
45
45
  return {
46
- decryptGroupMessage({ group, authorJid, msg }) {
46
+ async decryptGroupMessage({ group, authorJid, msg }) {
47
47
  const senderName = jidToSignalSenderKeyName(group, authorJid);
48
48
  const cipher = new Group_1.GroupCipher(storage, senderName);
49
- return cipher.decrypt(msg);
49
+ try {
50
+ return await cipher.decrypt(msg);
51
+ } catch (err) {
52
+ if (err.message?.includes('Bad MAC') || err.message?.includes('No valid sessions')) {
53
+ const senderNameStr = senderName.toString();
54
+ await auth.keys.set({ 'sender-key': { [senderNameStr]: null } });
55
+ const e = new Error('SESSION_CIPHER_FAIL');
56
+ e.needsRetry = true;
57
+ throw e;
58
+ }
59
+ throw err;
60
+ }
50
61
  },
51
62
  async processSenderKeyDistributionMessage({ item, authorJid }) {
52
63
  const builder = new Group_1.GroupSessionBuilder(storage);
@@ -78,8 +89,12 @@ function makeLibSignalRepository(auth) {
78
89
  throw new Error(`Unknown message type: ${type}`);
79
90
  }
80
91
  } catch (err) {
81
- if (err.message?.includes('Bad MAC')) {
82
- throw new Error('SESSION_CIPHER_FAIL');
92
+ if (err.message?.includes('Bad MAC') || err.message?.includes('No valid sessions')) {
93
+ const sessionId = addr.toString();
94
+ await auth.keys.set({ session: { [sessionId]: null } });
95
+ const e = new Error('SESSION_CIPHER_FAIL');
96
+ e.needsRetry = true;
97
+ throw e;
83
98
  }
84
99
  throw err;
85
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmd-baileys",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "A lightweight, full-featured WhatsApp Web API library for Node.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",