whalibmob 5.5.65 → 5.5.66

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.
@@ -839,10 +839,22 @@ class MessageSender {
839
839
 
840
840
  // Determine addressing mode for this group (lid = modern groups, pn = legacy)
841
841
  const groupAddressingMode = this._client._groupAddressingMode.get(groupJid) || 'lid';
842
- // For LID-mode groups, sender identity is own LID JID; otherwise own PN JID
843
- const senderIdentity = (groupAddressingMode === 'lid' && this._client._myLid)
844
- ? this._client._myLid
845
- : ownJid;
842
+ // A stanza addressed with addressing_mode='lid' must carry participants in
843
+ // LID space only. Mixing @s.whatsapp.net targets into it is exactly what
844
+ // DeviceManager warns about, and the server answers it with ack 479.
845
+ const useLid = groupAddressingMode === 'lid';
846
+ if (useLid && !this._client._myLid) {
847
+ throw new Error(
848
+ 'Cannot send to ' + groupJid + ': group is LID-addressed but our own LID ' +
849
+ 'is unknown (the server did not supply lid= on <success>). ' +
850
+ 'Reconnect so the LID is re-issued.'
851
+ );
852
+ }
853
+ const myLidUser = useLid ? phoneFromJid(this._client._myLid) : null;
854
+ // For LID-mode groups, sender identity is own LID JID; otherwise own PN JID.
855
+ // Normalised to the bare user so it matches the participant targets below.
856
+ const selfJid = useLid ? `${myLidUser}@lid` : ownJid;
857
+ const senderIdentity = selfJid;
846
858
 
847
859
  const rawSKDM = await this._signal.buildSKDM(groupJid, senderIdentity);
848
860
  const skdmMsg = encodeSenderKeyDistributionMessage(groupJid, rawSKDM);
@@ -850,16 +862,31 @@ class MessageSender {
850
862
  // Resolve member phones for session/device queries.
851
863
  // For LID members without a PN mapping, keep the raw LID user part so
852
864
  // bulkEnsureSessionsForLid can still acquire sessions for them.
865
+ // "40778226909:2@s.whatsapp.net" → "<ourLid>:2@lid" — keep the device
866
+ // suffix, swap identity and domain.
867
+ const ownJidToLid = (jid) => {
868
+ const base = String(jid).replace(/@(?:s\.whatsapp\.net|lid)$/, '');
869
+ const colon = base.indexOf(':');
870
+ return myLidUser + (colon >= 0 ? base.slice(colon) : '') + '@lid';
871
+ };
872
+
853
873
  const lidMembersWithoutPn = [];
854
874
  const memberPhones = [...new Set(
855
875
  members.map(jid => {
856
876
  const isLid = jid.endsWith('@lid');
857
877
  const raw = phoneFromJid(jid);
858
878
  if (isLid) {
859
- const pn = this._client._lidToPn && this._client._lidToPn.get(raw);
860
- if (pn) return pn;
861
- // No PN mapping yet track for LID-direct session ensure
862
- lidMembersWithoutPn.push(jid);
879
+ // In a LID-addressed group, resolve LID members through the LID path
880
+ // even when we know their phone number — swapping in the PN would put
881
+ // an @s.whatsapp.net target into a @lid stanza.
882
+ if (!useLid) {
883
+ const pn = this._client._lidToPn && this._client._lidToPn.get(raw);
884
+ if (pn) return pn;
885
+ }
886
+ // Our own LID is a member too — ensureOwnDeviceSessions already
887
+ // covers those devices, so listing it here would encrypt the SKDM
888
+ // for ourselves twice and emit duplicate <to> entries.
889
+ if (raw !== myLidUser) lidMembersWithoutPn.push(jid);
863
890
  return null;
864
891
  }
865
892
  return raw;
@@ -879,11 +906,17 @@ class MessageSender {
879
906
  this._devMgr.ensureOwnDeviceSessions(ownPhone, this._signal)
880
907
  ]);
881
908
 
882
- const allTargets = [...memberDevices, ...lidDevices, ...ownDevices];
909
+ // Own devices come back as @s.whatsapp.net — re-express them in LID space
910
+ // so every target in a LID stanza shares one address family.
911
+ const ownTargets = useLid ? ownDevices.map(ownJidToLid) : ownDevices;
912
+
913
+ // Dedupe: a device reached through more than one path must still appear
914
+ // exactly once in <participants>.
915
+ const allTargets = [...new Set([...memberDevices, ...lidDevices, ...ownTargets])];
883
916
 
884
- const phashTargets = allTargets.includes(ownJid)
917
+ const phashTargets = allTargets.includes(selfJid)
885
918
  ? allTargets
886
- : [ownJid, ...allTargets];
919
+ : [selfJid, ...allTargets];
887
920
 
888
921
  const skStore = this._signal.senderKeyStore;
889
922
  const existingSkdmMap = skStore.getSKDMMap(groupJid);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whalibmob",
3
- "version": "5.5.65",
3
+ "version": "5.5.66",
4
4
  "description": "WhatsApp library for interaction with WhatsApp Mobile API no web",
5
5
  "author": "Kunboruto50",
6
6
  "main": "index.js",