sanka-baileyss 2.4.8 → 2.4.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.
|
@@ -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) => {
|
|
@@ -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(() => {
|