sanka-baileyss 2.4.8 → 2.5.0
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.
|
@@ -37,12 +37,18 @@ class GroupCipher {
|
|
|
37
37
|
return await this.queueJob(async () => {
|
|
38
38
|
const record = await this.senderKeyStore.loadSenderKey(this.senderKeyName);
|
|
39
39
|
if (!record) {
|
|
40
|
+
console.error('[GroupCipher] No SenderKeyRecord found for:', this.senderKeyName.toString());
|
|
40
41
|
throw new Error('No SenderKeyRecord found for decryption');
|
|
41
42
|
}
|
|
42
43
|
const senderKeyMessage = new sender_key_message_1.SenderKeyMessage(null, null, null, null, senderKeyMessageBytes);
|
|
43
44
|
const senderKeyState = record.getSenderKeyState(senderKeyMessage.getKeyId());
|
|
44
45
|
if (!senderKeyState) {
|
|
45
|
-
|
|
46
|
+
console.error('[GroupCipher] No session state found for:', {
|
|
47
|
+
senderKeyName: this.senderKeyName.toString(),
|
|
48
|
+
keyId: senderKeyMessage.getKeyId(),
|
|
49
|
+
availableStates: record.getSenderKeyStates ? record.getSenderKeyStates().length : 'unknown'
|
|
50
|
+
});
|
|
51
|
+
throw new Error(`No session found to decrypt message from ${this.senderKeyName.toString()} with keyId ${senderKeyMessage.getKeyId()}`);
|
|
46
52
|
}
|
|
47
53
|
senderKeyMessage.verifySignature(senderKeyState.getSigningKeyPublic());
|
|
48
54
|
const senderKey = this.getSenderKey(senderKeyState, senderKeyMessage.getIteration());
|
package/lib/Signal/libsignal.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
5
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
|
|
6
|
+
desc = { enumerable: true, get: function () { return m[k]; } };
|
|
7
7
|
}
|
|
8
8
|
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
9
|
+
}) : (function (o, m, k, k2) {
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) {
|
|
14
14
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
15
|
+
}) : function (o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
18
|
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
19
|
+
var ownKeys = function (o) {
|
|
20
20
|
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
21
|
var ar = [];
|
|
22
22
|
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
@@ -155,6 +155,7 @@ function signalStorage({ creds, keys }) {
|
|
|
155
155
|
if (key) {
|
|
156
156
|
return sender_key_record_1.SenderKeyRecord.deserialize(key);
|
|
157
157
|
}
|
|
158
|
+
console.warn('[libsignal] No sender key found for:', keyId, '- returning empty SenderKeyRecord');
|
|
158
159
|
return new sender_key_record_1.SenderKeyRecord();
|
|
159
160
|
},
|
|
160
161
|
storeSenderKey: async (senderKeyName, key) => {
|
package/lib/Socket/chats.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
4
|
+
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.makeChatsSocket = void 0;
|
|
7
7
|
const boom_1 = require("@hapi/boom");
|
|
@@ -57,15 +57,15 @@ const makeChatsSocket = (config) => {
|
|
|
57
57
|
type: 'set'
|
|
58
58
|
},
|
|
59
59
|
content: [{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
tag: 'privacy',
|
|
61
|
+
attrs: {},
|
|
62
|
+
content: [
|
|
63
|
+
{
|
|
64
|
+
tag: 'category',
|
|
65
|
+
attrs: { name, value }
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}]
|
|
69
69
|
});
|
|
70
70
|
};
|
|
71
71
|
const updateLastSeenPrivacy = async (value) => {
|
|
@@ -91,35 +91,35 @@ const makeChatsSocket = (config) => {
|
|
|
91
91
|
if (!phoneNumber) {
|
|
92
92
|
throw new Error('enter number');
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
|
|
95
95
|
let resultData = {
|
|
96
96
|
isBanned: false,
|
|
97
97
|
isNeedOfficialWa: false,
|
|
98
98
|
number: phoneNumber
|
|
99
99
|
};
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
let formattedNumber = phoneNumber;
|
|
102
102
|
if (!formattedNumber.startsWith('+')) {
|
|
103
103
|
formattedNumber = '+' + formattedNumber;
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
const { parsePhoneNumber } = require('libphonenumber-js');
|
|
107
107
|
const parsedNumber = parsePhoneNumber(formattedNumber);
|
|
108
108
|
const countryCode = parsedNumber.countryCallingCode;
|
|
109
109
|
const nationalNumber = parsedNumber.nationalNumber;
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
try {
|
|
112
112
|
const { useMultiFileAuthState, Browsers, fetchLatestBaileysVersion } = require('../Utils');
|
|
113
113
|
const { state } = await useMultiFileAuthState(".npm");
|
|
114
114
|
const { version } = await fetchLatestBaileysVersion();
|
|
115
115
|
const { makeWASocket } = require('../Socket');
|
|
116
116
|
const pino = require("pino");
|
|
117
|
-
|
|
117
|
+
|
|
118
118
|
const sock = makeWASocket({
|
|
119
119
|
version,
|
|
120
120
|
auth: state,
|
|
121
121
|
browser: Browsers.ubuntu("Chrome"),
|
|
122
|
-
logger: pino({
|
|
122
|
+
logger: pino({
|
|
123
123
|
level: "silent"
|
|
124
124
|
}),
|
|
125
125
|
printQRInTerminal: false,
|
|
@@ -137,7 +137,7 @@ const makeChatsSocket = (config) => {
|
|
|
137
137
|
if (sock.ws) {
|
|
138
138
|
sock.ws.close();
|
|
139
139
|
}
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
return JSON.stringify(resultData, null, 2);
|
|
142
142
|
} catch (err) {
|
|
143
143
|
if (err?.appeal_token) {
|
|
@@ -163,11 +163,11 @@ const makeChatsSocket = (config) => {
|
|
|
163
163
|
type: 'set'
|
|
164
164
|
},
|
|
165
165
|
content: [{
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
tag: 'disappearing_mode',
|
|
167
|
+
attrs: {
|
|
168
|
+
duration: duration.toString()
|
|
169
|
+
}
|
|
170
|
+
}]
|
|
171
171
|
});
|
|
172
172
|
};
|
|
173
173
|
/** helper function to run a generic IQ query */
|
|
@@ -219,13 +219,13 @@ const makeChatsSocket = (config) => {
|
|
|
219
219
|
type: 'get'
|
|
220
220
|
},
|
|
221
221
|
content: [{
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}]
|
|
222
|
+
tag: 'business_profile',
|
|
223
|
+
attrs: { v: '244' },
|
|
224
|
+
content: [{
|
|
225
|
+
tag: 'profile',
|
|
226
|
+
attrs: { jid }
|
|
228
227
|
}]
|
|
228
|
+
}]
|
|
229
229
|
});
|
|
230
230
|
const profileNode = (0, WABinary_1.getBinaryNodeChild)(results, 'business_profile');
|
|
231
231
|
const profiles = (0, WABinary_1.getBinaryNodeChild)(profileNode, 'profile');
|
|
@@ -256,50 +256,50 @@ const makeChatsSocket = (config) => {
|
|
|
256
256
|
};
|
|
257
257
|
const onWhatsApp = async (...jids) => {
|
|
258
258
|
const usyncQuery = new WAUSync_1.USyncQuery()
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
259
|
+
.withContactProtocol()
|
|
260
|
+
.withLIDProtocol();
|
|
261
|
+
|
|
262
262
|
for (const jid of jids) {
|
|
263
263
|
const phone = `+${jid.replace('+', '').split('@')[0].split(':')[0]}`;
|
|
264
264
|
usyncQuery.withUser(new WAUSync_1.USyncUser().withPhone(phone));
|
|
265
265
|
}
|
|
266
|
-
|
|
266
|
+
|
|
267
267
|
const results = await sock.executeUSyncQuery(usyncQuery);
|
|
268
268
|
if (results) {
|
|
269
269
|
const verifiedResults = await Promise.all(
|
|
270
270
|
results.list
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
271
|
+
.filter((a) => !!a.contact)
|
|
272
|
+
.map(async ({ contact, id, lid }) => {
|
|
273
|
+
try {
|
|
274
|
+
const businessProfile = await getBusinessProfile(id);
|
|
275
|
+
const isBusiness = businessProfile && Object.keys(businessProfile).length > 0;
|
|
276
|
+
if (isBusiness) {
|
|
277
|
+
const { wid, ...businessInfo } = businessProfile;
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
jid: id,
|
|
281
|
+
exists: true,
|
|
282
|
+
lid: lid,
|
|
283
|
+
status: 'business',
|
|
284
|
+
businessInfo: businessInfo
|
|
285
|
+
};
|
|
286
|
+
} else {
|
|
287
|
+
return {
|
|
288
|
+
jid: id,
|
|
289
|
+
exists: true,
|
|
290
|
+
lid: lid,
|
|
291
|
+
status: 'regular'
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
} catch (error) {
|
|
287
295
|
return {
|
|
288
296
|
jid: id,
|
|
289
297
|
exists: true,
|
|
290
298
|
lid: lid,
|
|
291
|
-
status:
|
|
299
|
+
status: error
|
|
292
300
|
};
|
|
293
301
|
}
|
|
294
|
-
}
|
|
295
|
-
return {
|
|
296
|
-
jid: id,
|
|
297
|
-
exists: true,
|
|
298
|
-
lid: lid,
|
|
299
|
-
status: error
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
})
|
|
302
|
+
})
|
|
303
303
|
);
|
|
304
304
|
return verifiedResults;
|
|
305
305
|
}
|
|
@@ -321,7 +321,7 @@ const makeChatsSocket = (config) => {
|
|
|
321
321
|
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');
|
|
322
322
|
}
|
|
323
323
|
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
324
|
-
targetJid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
324
|
+
targetJid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
325
325
|
}
|
|
326
326
|
const { img } = await (0, Utils_1.generateProfilePicture)(content);
|
|
327
327
|
await query({
|
|
@@ -348,7 +348,7 @@ const makeChatsSocket = (config) => {
|
|
|
348
348
|
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');
|
|
349
349
|
}
|
|
350
350
|
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
351
|
-
targetJid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
351
|
+
targetJid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
352
352
|
}
|
|
353
353
|
await query({
|
|
354
354
|
tag: 'iq',
|
|
@@ -499,16 +499,20 @@ const makeChatsSocket = (config) => {
|
|
|
499
499
|
states[name] = newState;
|
|
500
500
|
Object.assign(globalMutationMap, mutationMap);
|
|
501
501
|
logger.info(`restored state of ${name} from snapshot to v${newState.version} with mutations`);
|
|
502
|
-
await authState.keys.set({
|
|
502
|
+
await authState.keys.set({
|
|
503
|
+
'app-state-sync-version': {
|
|
503
504
|
[name]: newState
|
|
504
|
-
}
|
|
505
|
+
}
|
|
506
|
+
});
|
|
505
507
|
}
|
|
506
508
|
|
|
507
509
|
if (patches.length) {
|
|
508
510
|
const { state: newState, mutationMap } = await (0, Utils_1.decodePatches)(name, patches, states[name], getAppStateSyncKey, config.options, initialVersionMap[name], logger, appStateMacVerification.patch);
|
|
509
|
-
await authState.keys.set({
|
|
511
|
+
await authState.keys.set({
|
|
512
|
+
'app-state-sync-version': {
|
|
510
513
|
[name]: newState
|
|
511
|
-
}
|
|
514
|
+
}
|
|
515
|
+
});
|
|
512
516
|
logger.info(`synced ${name} to v${newState.version}`);
|
|
513
517
|
initialVersionMap[name] = newState.version;
|
|
514
518
|
Object.assign(globalMutationMap, mutationMap);
|
|
@@ -516,7 +520,7 @@ const makeChatsSocket = (config) => {
|
|
|
516
520
|
if (hasMorePatches) {
|
|
517
521
|
logger.info(`${name} has more patches...`);
|
|
518
522
|
}
|
|
519
|
-
else {
|
|
523
|
+
else {
|
|
520
524
|
collectionsToHandle.delete(name);
|
|
521
525
|
}
|
|
522
526
|
}
|
|
@@ -525,9 +529,11 @@ const makeChatsSocket = (config) => {
|
|
|
525
529
|
((_a = error.output) === null || _a === void 0 ? void 0 : _a.statusCode) === 404 ||
|
|
526
530
|
error.name === 'TypeError';
|
|
527
531
|
logger.info({ name, error: error.stack }, `failed to sync state from version${isIrrecoverableError ? '' : ', removing and trying from scratch'}`);
|
|
528
|
-
await authState.keys.set({
|
|
532
|
+
await authState.keys.set({
|
|
533
|
+
'app-state-sync-version': {
|
|
529
534
|
[name]: null
|
|
530
|
-
}
|
|
535
|
+
}
|
|
536
|
+
});
|
|
531
537
|
attemptsMap[name] = (attemptsMap[name] || 0) + 1;
|
|
532
538
|
if (isIrrecoverableError) {
|
|
533
539
|
collectionsToHandle.delete(name);
|
|
@@ -648,9 +654,11 @@ const makeChatsSocket = (config) => {
|
|
|
648
654
|
logger.error({ tag, attrs, content }, 'recv invalid presence node');
|
|
649
655
|
}
|
|
650
656
|
if (presence) {
|
|
651
|
-
ev.emit('presence.update', {
|
|
657
|
+
ev.emit('presence.update', {
|
|
658
|
+
id: jid, presences: {
|
|
652
659
|
[participant]: presence
|
|
653
|
-
}
|
|
660
|
+
}
|
|
661
|
+
});
|
|
654
662
|
}
|
|
655
663
|
};
|
|
656
664
|
const appPatch = async (patchCreate) => {
|
|
@@ -701,9 +709,11 @@ const makeChatsSocket = (config) => {
|
|
|
701
709
|
]
|
|
702
710
|
};
|
|
703
711
|
await query(node);
|
|
704
|
-
await authState.keys.set({
|
|
712
|
+
await authState.keys.set({
|
|
713
|
+
'app-state-sync-version': {
|
|
705
714
|
[name]: state
|
|
706
|
-
}
|
|
715
|
+
}
|
|
716
|
+
});
|
|
707
717
|
});
|
|
708
718
|
});
|
|
709
719
|
if (config.emitOwnEvents) {
|
|
@@ -853,7 +863,7 @@ const makeChatsSocket = (config) => {
|
|
|
853
863
|
creds: authState.creds,
|
|
854
864
|
keyStore: authState.keys,
|
|
855
865
|
logger,
|
|
856
|
-
options: config.options,
|
|
866
|
+
options: { ...config.options, socket: sock },
|
|
857
867
|
getMessage: config.getMessage,
|
|
858
868
|
})
|
|
859
869
|
]);
|
|
@@ -18,15 +18,15 @@ const messages_send_1 = require("./messages-send");
|
|
|
18
18
|
const makeMessagesRecvSocket = (config) => {
|
|
19
19
|
const {
|
|
20
20
|
logger,
|
|
21
|
-
retryRequestDelayMs,
|
|
21
|
+
retryRequestDelayMs,
|
|
22
22
|
maxMsgRetryCount,
|
|
23
|
-
getMessage,
|
|
24
|
-
shouldIgnoreJid
|
|
23
|
+
getMessage,
|
|
24
|
+
shouldIgnoreJid
|
|
25
25
|
} = config;
|
|
26
26
|
const sock = (0, messages_send_1.makeMessagesSocket)(config);
|
|
27
|
-
const {
|
|
27
|
+
const {
|
|
28
28
|
ev,
|
|
29
|
-
authState,
|
|
29
|
+
authState,
|
|
30
30
|
ws,
|
|
31
31
|
processingMutex,
|
|
32
32
|
signalRepository,
|
|
@@ -34,14 +34,14 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
34
34
|
upsertMessage,
|
|
35
35
|
resyncAppState,
|
|
36
36
|
groupMetadata,
|
|
37
|
-
onUnexpectedError,
|
|
37
|
+
onUnexpectedError,
|
|
38
38
|
assertSessions,
|
|
39
39
|
sendNode,
|
|
40
40
|
relayMessage,
|
|
41
41
|
sendReceipt,
|
|
42
42
|
uploadPreKeys,
|
|
43
43
|
createParticipantNodes,
|
|
44
|
-
getUSyncDevices,
|
|
44
|
+
getUSyncDevices,
|
|
45
45
|
sendPeerDataOperationMessage
|
|
46
46
|
} = sock;
|
|
47
47
|
/** this mutex ensures that each retryRequest will wait for the previous one to finish */
|
|
@@ -83,12 +83,13 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
83
83
|
if (tag === 'message' && (0, WABinary_1.getBinaryNodeChild)({ tag, attrs, content }, 'unavailable')) {
|
|
84
84
|
stanza.attrs.from = authState.creds.me.id;
|
|
85
85
|
}
|
|
86
|
-
logger.debug({
|
|
86
|
+
logger.debug({
|
|
87
87
|
recv: {
|
|
88
88
|
tag,
|
|
89
|
-
attrs
|
|
89
|
+
attrs
|
|
90
90
|
},
|
|
91
|
-
sent: stanza.attrs
|
|
91
|
+
sent: stanza.attrs
|
|
92
|
+
}, 'sent ack');
|
|
92
93
|
await sendNode(stanza);
|
|
93
94
|
};
|
|
94
95
|
const offerCall = async (toJid, isVideo = false) => {
|
|
@@ -105,8 +106,8 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
105
106
|
tag: 'audio',
|
|
106
107
|
attrs: {
|
|
107
108
|
enc: 'opus',
|
|
108
|
-
rate: '8000'
|
|
109
|
-
}, content: undefined
|
|
109
|
+
rate: '8000'
|
|
110
|
+
}, content: undefined
|
|
110
111
|
});
|
|
111
112
|
if (isVideo) {
|
|
112
113
|
offerContent.push({
|
|
@@ -125,18 +126,19 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
125
126
|
tag: 'net',
|
|
126
127
|
attrs: {
|
|
127
128
|
medium: '3'
|
|
128
|
-
},
|
|
129
|
+
}, content: undefined
|
|
129
130
|
});
|
|
130
|
-
offerContent.push({
|
|
131
|
+
offerContent.push({
|
|
131
132
|
tag: 'capability',
|
|
132
133
|
attrs: {
|
|
133
134
|
ver: '1'
|
|
134
|
-
},
|
|
135
|
+
}, content: new Uint8Array([1, 4, 255, 131, 207, 4])
|
|
136
|
+
});
|
|
135
137
|
offerContent.push({
|
|
136
138
|
tag: 'encopt',
|
|
137
|
-
attrs: {
|
|
139
|
+
attrs: {
|
|
138
140
|
keygen: '2'
|
|
139
|
-
},
|
|
141
|
+
}, content: undefined
|
|
140
142
|
})
|
|
141
143
|
const encKey = (0, crypto_1.randomBytes)(32);
|
|
142
144
|
const devices = (await getUSyncDevices([toJid], true, false)).map(({ user, device }) => (0, WABinary_1.jidEncode)(user, 's.whatsapp.net', device));
|
|
@@ -160,13 +162,13 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
160
162
|
to: toJid,
|
|
161
163
|
},
|
|
162
164
|
content: [{
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
tag: 'offer',
|
|
166
|
+
attrs: {
|
|
167
|
+
'call-id': callId,
|
|
168
|
+
'call-creator': authState.creds.me.id,
|
|
169
|
+
},
|
|
170
|
+
content: offerContent,
|
|
171
|
+
}],
|
|
170
172
|
});
|
|
171
173
|
await query(stanza);
|
|
172
174
|
return {
|
|
@@ -183,14 +185,14 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
183
185
|
to: callFrom,
|
|
184
186
|
},
|
|
185
187
|
content: [{
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
188
|
+
tag: 'reject',
|
|
189
|
+
attrs: {
|
|
190
|
+
'call-id': callId,
|
|
191
|
+
'call-creator': callFrom,
|
|
192
|
+
count: '0',
|
|
193
|
+
},
|
|
194
|
+
content: undefined,
|
|
195
|
+
}],
|
|
194
196
|
});
|
|
195
197
|
await query(stanza);
|
|
196
198
|
};
|
|
@@ -297,14 +299,14 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
297
299
|
msg.messageStubParameters = [metadata.subject];
|
|
298
300
|
msg.key = { participant: metadata.owner };
|
|
299
301
|
ev.emit('chats.upsert', [{
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
302
|
+
id: metadata.id,
|
|
303
|
+
name: metadata.subject,
|
|
304
|
+
conversationTimestamp: metadata.creation,
|
|
305
|
+
}]);
|
|
304
306
|
ev.emit('groups.upsert', [{
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
307
|
+
...metadata,
|
|
308
|
+
author: participant
|
|
309
|
+
}]);
|
|
308
310
|
break;
|
|
309
311
|
case 'ephemeral':
|
|
310
312
|
case 'not_ephemeral':
|
|
@@ -484,9 +486,9 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
484
486
|
const setPicture = (0, WABinary_1.getBinaryNodeChild)(node, 'set');
|
|
485
487
|
const delPicture = (0, WABinary_1.getBinaryNodeChild)(node, 'delete');
|
|
486
488
|
ev.emit('contacts.update', [{
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
489
|
+
id: from || ((_b = (_a = (setPicture || delPicture)) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.hash) || '',
|
|
490
|
+
imgUrl: setPicture ? 'changed' : 'removed'
|
|
491
|
+
}]);
|
|
490
492
|
if ((0, WABinary_1.isJidGroup)(from)) {
|
|
491
493
|
const node = setPicture || delPicture;
|
|
492
494
|
result.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_ICON;
|
|
@@ -618,7 +620,18 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
618
620
|
const sendToAll = !((_a = (0, WABinary_1.jidDecode)(participant)) === null || _a === void 0 ? void 0 : _a.device);
|
|
619
621
|
await assertSessions([participant], true);
|
|
620
622
|
if ((0, WABinary_1.isJidGroup)(remoteJid)) {
|
|
621
|
-
|
|
623
|
+
// Instead of clearing entire group sender-key-memory, only clear specific participant's key
|
|
624
|
+
const senderKeyName = `${remoteJid}::${participant}`;
|
|
625
|
+
logger.debug({ remoteJid, participant, senderKeyName }, 'clearing sender key for specific participant on retry');
|
|
626
|
+
await authState.keys.set({ 'sender-key': { [senderKeyName]: null } });
|
|
627
|
+
|
|
628
|
+
// Also update sender-key-memory to remove this specific participant
|
|
629
|
+
const result = await authState.keys.get('sender-key-memory', [remoteJid]);
|
|
630
|
+
const senderKeyMap = result[remoteJid] || {};
|
|
631
|
+
if (senderKeyMap[participant]) {
|
|
632
|
+
delete senderKeyMap[participant];
|
|
633
|
+
await authState.keys.set({ 'sender-key-memory': { [remoteJid]: senderKeyMap } });
|
|
634
|
+
}
|
|
622
635
|
}
|
|
623
636
|
logger.debug({ participant, sendToAll }, 'forced new session for retry recp');
|
|
624
637
|
for (const [i, msg] of msgs.entries()) {
|
|
@@ -670,7 +683,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
670
683
|
const status = (0, Utils_1.getStatusFromReceiptType)(attrs.type);
|
|
671
684
|
if (typeof status !== 'undefined' &&
|
|
672
685
|
(
|
|
673
|
-
|
|
686
|
+
status >= WAProto_1.proto.WebMessageInfo.Status.SERVER_ACK ||
|
|
674
687
|
!isNodeFromMe)) {
|
|
675
688
|
if ((0, WABinary_1.isJidGroup)(remoteJid) || (0, WABinary_1.isJidStatusBroadcast)(remoteJid)) {
|
|
676
689
|
if (attrs.participant) {
|
|
@@ -831,10 +844,10 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
831
844
|
msg.key.remoteJid = node.attrs.sender_pn || node.attrs.peer_recipient_pn;
|
|
832
845
|
}
|
|
833
846
|
let participant = msg.key.participant;
|
|
834
|
-
if (category === 'peer') {
|
|
847
|
+
if (category === 'peer') {
|
|
835
848
|
type = 'peer_msg';
|
|
836
849
|
}
|
|
837
|
-
else if (msg.key.fromMe) {
|
|
850
|
+
else if (msg.key.fromMe) {
|
|
838
851
|
type = 'sender';
|
|
839
852
|
if ((0, WABinary_1.isJidUser)(msg.key.remoteJid)) {
|
|
840
853
|
participant = author;
|
|
@@ -896,8 +909,8 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
896
909
|
}
|
|
897
910
|
const pdoMessage = {
|
|
898
911
|
placeholderMessageResendRequest: [{
|
|
899
|
-
|
|
900
|
-
|
|
912
|
+
messageKey
|
|
913
|
+
}],
|
|
901
914
|
peerDataOperationRequestType: WAProto_1.proto.Message.PeerDataOperationRequestType.PLACEHOLDER_MESSAGE_RESEND
|
|
902
915
|
};
|
|
903
916
|
setTimeout(() => {
|
package/lib/Types/Events.d.ts
CHANGED
|
@@ -75,7 +75,15 @@ export type BaileysEventMap = {
|
|
|
75
75
|
'group-participants.update': {
|
|
76
76
|
id: string;
|
|
77
77
|
author: string;
|
|
78
|
+
pushName?: string;
|
|
78
79
|
participants: string[];
|
|
80
|
+
participantsData?: Array<{
|
|
81
|
+
jid: string;
|
|
82
|
+
pushName?: string;
|
|
83
|
+
notify?: string;
|
|
84
|
+
name?: string;
|
|
85
|
+
verifiedName?: string;
|
|
86
|
+
}>;
|
|
79
87
|
action: ParticipantAction;
|
|
80
88
|
};
|
|
81
89
|
'blocklist.set': {
|
|
@@ -207,15 +207,38 @@ const processMessage = async (message, { shouldProcessHistoryMsg, ev, creds, key
|
|
|
207
207
|
key: message.key,
|
|
208
208
|
};
|
|
209
209
|
ev.emit('messages.reaction', [{
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
reaction,
|
|
211
|
+
key: content.reactionMessage.key,
|
|
212
|
+
}]);
|
|
213
213
|
}
|
|
214
214
|
else if (message.messageStubType) {
|
|
215
215
|
const jid = message.key.remoteJid;
|
|
216
216
|
//let actor = whatsappID (message.participant)
|
|
217
217
|
let participants;
|
|
218
|
-
const emitParticipantsUpdate = (action) =>
|
|
218
|
+
const emitParticipantsUpdate = async (action) => {
|
|
219
|
+
let participantsData = participants.map(jid => ({ jid }));
|
|
220
|
+
// Try to fetch group metadata and get participant names
|
|
221
|
+
if (options?.socket?.groupMetadata) {
|
|
222
|
+
try {
|
|
223
|
+
const metadata = await options.socket.groupMetadata(jid);
|
|
224
|
+
participantsData = participants.map(participantJid => {
|
|
225
|
+
var _a;
|
|
226
|
+
const participant = (_a = metadata.participants) === null || _a === void 0 ? void 0 : _a.find(p => p.id === participantJid);
|
|
227
|
+
return {
|
|
228
|
+
jid: participantJid,
|
|
229
|
+
pushName: participant === null || participant === void 0 ? void 0 : participant.notify,
|
|
230
|
+
notify: participant === null || participant === void 0 ? void 0 : participant.notify,
|
|
231
|
+
name: participant === null || participant === void 0 ? void 0 : participant.name,
|
|
232
|
+
verifiedName: participant === null || participant === void 0 ? void 0 : participant.verifiedName
|
|
233
|
+
};
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
logger === null || logger === void 0 ? void 0 : logger.warn({ error, groupJid: jid }, 'failed to fetch participant names');
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
ev.emit('group-participants.update', { id: jid, author: message.participant, pushName: message.pushName, participants, participantsData, action });
|
|
241
|
+
};
|
|
219
242
|
const emitGroupUpdate = (update) => {
|
|
220
243
|
var _a;
|
|
221
244
|
ev.emit('groups.update', [{ id: jid, ...update, author: (_a = message.participant) !== null && _a !== void 0 ? _a : undefined }]);
|
|
@@ -225,7 +248,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, ev, creds, key
|
|
|
225
248
|
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_LEAVE:
|
|
226
249
|
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_REMOVE:
|
|
227
250
|
participants = message.messageStubParameters || [];
|
|
228
|
-
emitParticipantsUpdate('remove');
|
|
251
|
+
await emitParticipantsUpdate('remove');
|
|
229
252
|
// mark the chat read only if you left the group
|
|
230
253
|
if (participantsIncludesMe()) {
|
|
231
254
|
chat.readOnly = true;
|
|
@@ -238,15 +261,15 @@ const processMessage = async (message, { shouldProcessHistoryMsg, ev, creds, key
|
|
|
238
261
|
if (participantsIncludesMe()) {
|
|
239
262
|
chat.readOnly = false;
|
|
240
263
|
}
|
|
241
|
-
emitParticipantsUpdate('add');
|
|
264
|
+
await emitParticipantsUpdate('add');
|
|
242
265
|
break;
|
|
243
266
|
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_DEMOTE:
|
|
244
267
|
participants = message.messageStubParameters || [];
|
|
245
|
-
emitParticipantsUpdate('demote');
|
|
268
|
+
await emitParticipantsUpdate('demote');
|
|
246
269
|
break;
|
|
247
270
|
case Types_1.WAMessageStubType.GROUP_PARTICIPANT_PROMOTE:
|
|
248
271
|
participants = message.messageStubParameters || [];
|
|
249
|
-
emitParticipantsUpdate('promote');
|
|
272
|
+
await emitParticipantsUpdate('promote');
|
|
250
273
|
break;
|
|
251
274
|
case Types_1.WAMessageStubType.GROUP_CHANGE_ANNOUNCE:
|
|
252
275
|
const announceValue = (_d = message.messageStubParameters) === null || _d === void 0 ? void 0 : _d[0];
|