@itsliaaa/baileys 0.1.8 → 0.1.10

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.
package/WAProto/index.js CHANGED
@@ -17539,10 +17539,32 @@ export const proto = $root.proto = (() => {
17539
17539
  this[ks[i]] = p[ks[i]];
17540
17540
  }
17541
17541
 
17542
- Citation.prototype.title = "";
17543
- Citation.prototype.subtitle = "";
17544
- Citation.prototype.cmsId = "";
17545
- Citation.prototype.imageUrl = "";
17542
+ Citation.prototype.title = null;
17543
+ Citation.prototype.subtitle = null;
17544
+ Citation.prototype.cmsId = null;
17545
+ Citation.prototype.imageUrl = null;
17546
+
17547
+ let $oneOfFields;
17548
+
17549
+ Object.defineProperty(Citation.prototype, "_title", {
17550
+ get: $util.oneOfGetter($oneOfFields = ["title"]),
17551
+ set: $util.oneOfSetter($oneOfFields)
17552
+ });
17553
+
17554
+ Object.defineProperty(Citation.prototype, "_subtitle", {
17555
+ get: $util.oneOfGetter($oneOfFields = ["subtitle"]),
17556
+ set: $util.oneOfSetter($oneOfFields)
17557
+ });
17558
+
17559
+ Object.defineProperty(Citation.prototype, "_cmsId", {
17560
+ get: $util.oneOfGetter($oneOfFields = ["cmsId"]),
17561
+ set: $util.oneOfSetter($oneOfFields)
17562
+ });
17563
+
17564
+ Object.defineProperty(Citation.prototype, "_imageUrl", {
17565
+ get: $util.oneOfGetter($oneOfFields = ["imageUrl"]),
17566
+ set: $util.oneOfSetter($oneOfFields)
17567
+ });
17546
17568
 
17547
17569
  Citation.create = function create(properties) {
17548
17570
  return new Citation(properties);
@@ -17618,23 +17640,25 @@ export const proto = $root.proto = (() => {
17618
17640
  if (!o)
17619
17641
  o = {};
17620
17642
  var d = {};
17621
- if (o.defaults) {
17622
- d.title = "";
17623
- d.subtitle = "";
17624
- d.cmsId = "";
17625
- d.imageUrl = "";
17626
- }
17627
17643
  if (m.title != null && m.hasOwnProperty("title")) {
17628
17644
  d.title = m.title;
17645
+ if (o.oneofs)
17646
+ d._title = "title";
17629
17647
  }
17630
17648
  if (m.subtitle != null && m.hasOwnProperty("subtitle")) {
17631
17649
  d.subtitle = m.subtitle;
17650
+ if (o.oneofs)
17651
+ d._subtitle = "subtitle";
17632
17652
  }
17633
17653
  if (m.cmsId != null && m.hasOwnProperty("cmsId")) {
17634
17654
  d.cmsId = m.cmsId;
17655
+ if (o.oneofs)
17656
+ d._cmsId = "cmsId";
17635
17657
  }
17636
17658
  if (m.imageUrl != null && m.hasOwnProperty("imageUrl")) {
17637
17659
  d.imageUrl = m.imageUrl;
17660
+ if (o.oneofs)
17661
+ d._imageUrl = "imageUrl";
17638
17662
  }
17639
17663
  return d;
17640
17664
  };
@@ -31803,6 +31827,7 @@ export const proto = $root.proto = (() => {
31803
31827
  ClientHello.prototype.paddedBytes = null;
31804
31828
  ClientHello.prototype.sendServerHelloPaddedBytes = null;
31805
31829
  ClientHello.prototype.simulateXxkemFs = null;
31830
+ ClientHello.prototype.pqMode = null;
31806
31831
 
31807
31832
  let $oneOfFields;
31808
31833
 
@@ -31846,6 +31871,11 @@ export const proto = $root.proto = (() => {
31846
31871
  set: $util.oneOfSetter($oneOfFields)
31847
31872
  });
31848
31873
 
31874
+ Object.defineProperty(ClientHello.prototype, "_pqMode", {
31875
+ get: $util.oneOfGetter($oneOfFields = ["pqMode"]),
31876
+ set: $util.oneOfSetter($oneOfFields)
31877
+ });
31878
+
31849
31879
  ClientHello.create = function create(properties) {
31850
31880
  return new ClientHello(properties);
31851
31881
  };
@@ -31869,6 +31899,8 @@ export const proto = $root.proto = (() => {
31869
31899
  w.uint32(56).bool(m.sendServerHelloPaddedBytes);
31870
31900
  if (m.simulateXxkemFs != null && Object.hasOwnProperty.call(m, "simulateXxkemFs"))
31871
31901
  w.uint32(64).bool(m.simulateXxkemFs);
31902
+ if (m.pqMode != null && Object.hasOwnProperty.call(m, "pqMode"))
31903
+ w.uint32(72).int32(m.pqMode);
31872
31904
  return w;
31873
31905
  };
31874
31906
 
@@ -31913,6 +31945,10 @@ export const proto = $root.proto = (() => {
31913
31945
  m.simulateXxkemFs = r.bool();
31914
31946
  break;
31915
31947
  }
31948
+ case 9: {
31949
+ m.pqMode = r.int32();
31950
+ break;
31951
+ }
31916
31952
  default:
31917
31953
  r.skipType(t & 7);
31918
31954
  break;
@@ -31964,6 +32000,50 @@ export const proto = $root.proto = (() => {
31964
32000
  if (d.simulateXxkemFs != null) {
31965
32001
  m.simulateXxkemFs = Boolean(d.simulateXxkemFs);
31966
32002
  }
32003
+ switch (d.pqMode) {
32004
+ default:
32005
+ if (typeof d.pqMode === "number") {
32006
+ m.pqMode = d.pqMode;
32007
+ break;
32008
+ }
32009
+ break;
32010
+ case "HANDSHAKE_PQ_MODE_UNKNOWN":
32011
+ case 0:
32012
+ m.pqMode = 0;
32013
+ break;
32014
+ case "XXKEM":
32015
+ case 1:
32016
+ m.pqMode = 1;
32017
+ break;
32018
+ case "XXKEM_FS":
32019
+ case 2:
32020
+ m.pqMode = 2;
32021
+ break;
32022
+ case "WA_CLASSICAL":
32023
+ case 3:
32024
+ m.pqMode = 3;
32025
+ break;
32026
+ case "WA_PQ":
32027
+ case 4:
32028
+ m.pqMode = 4;
32029
+ break;
32030
+ case "IKKEM":
32031
+ case 5:
32032
+ m.pqMode = 5;
32033
+ break;
32034
+ case "IKKEM_FS":
32035
+ case 6:
32036
+ m.pqMode = 6;
32037
+ break;
32038
+ case "XXKEM_2":
32039
+ case 7:
32040
+ m.pqMode = 7;
32041
+ break;
32042
+ case "IKKEM_2":
32043
+ case 8:
32044
+ m.pqMode = 8;
32045
+ break;
32046
+ }
31967
32047
  return m;
31968
32048
  };
31969
32049
 
@@ -32011,6 +32091,11 @@ export const proto = $root.proto = (() => {
32011
32091
  if (o.oneofs)
32012
32092
  d._simulateXxkemFs = "simulateXxkemFs";
32013
32093
  }
32094
+ if (m.pqMode != null && m.hasOwnProperty("pqMode")) {
32095
+ d.pqMode = o.enums === String ? $root.proto.HandshakeMessage.HandshakePqMode[m.pqMode] === undefined ? m.pqMode : $root.proto.HandshakeMessage.HandshakePqMode[m.pqMode] : m.pqMode;
32096
+ if (o.oneofs)
32097
+ d._pqMode = "pqMode";
32098
+ }
32014
32099
  return d;
32015
32100
  };
32016
32101
 
@@ -32028,6 +32113,20 @@ export const proto = $root.proto = (() => {
32028
32113
  return ClientHello;
32029
32114
  })();
32030
32115
 
32116
+ HandshakeMessage.HandshakePqMode = (function() {
32117
+ const valuesById = {}, values = Object.create(valuesById);
32118
+ values[valuesById[0] = "HANDSHAKE_PQ_MODE_UNKNOWN"] = 0;
32119
+ values[valuesById[1] = "XXKEM"] = 1;
32120
+ values[valuesById[2] = "XXKEM_FS"] = 2;
32121
+ values[valuesById[3] = "WA_CLASSICAL"] = 3;
32122
+ values[valuesById[4] = "WA_PQ"] = 4;
32123
+ values[valuesById[5] = "IKKEM"] = 5;
32124
+ values[valuesById[6] = "IKKEM_FS"] = 6;
32125
+ values[valuesById[7] = "XXKEM_2"] = 7;
32126
+ values[valuesById[8] = "IKKEM_2"] = 8;
32127
+ return values;
32128
+ })();
32129
+
32031
32130
  HandshakeMessage.ServerHello = (function() {
32032
32131
 
32033
32132
  function ServerHello(p) {
@@ -86114,11 +86213,28 @@ export const proto = $root.proto = (() => {
86114
86213
  this[ks[i]] = p[ks[i]];
86115
86214
  }
86116
86215
 
86117
- CustomPaymentMethod.prototype.credentialId = "";
86118
- CustomPaymentMethod.prototype.country = "";
86119
- CustomPaymentMethod.prototype.type = "";
86216
+ CustomPaymentMethod.prototype.credentialId = null;
86217
+ CustomPaymentMethod.prototype.country = null;
86218
+ CustomPaymentMethod.prototype.type = null;
86120
86219
  CustomPaymentMethod.prototype.metadata = $util.emptyArray;
86121
86220
 
86221
+ let $oneOfFields;
86222
+
86223
+ Object.defineProperty(CustomPaymentMethod.prototype, "_credentialId", {
86224
+ get: $util.oneOfGetter($oneOfFields = ["credentialId"]),
86225
+ set: $util.oneOfSetter($oneOfFields)
86226
+ });
86227
+
86228
+ Object.defineProperty(CustomPaymentMethod.prototype, "_country", {
86229
+ get: $util.oneOfGetter($oneOfFields = ["country"]),
86230
+ set: $util.oneOfSetter($oneOfFields)
86231
+ });
86232
+
86233
+ Object.defineProperty(CustomPaymentMethod.prototype, "_type", {
86234
+ get: $util.oneOfGetter($oneOfFields = ["type"]),
86235
+ set: $util.oneOfSetter($oneOfFields)
86236
+ });
86237
+
86122
86238
  CustomPaymentMethod.create = function create(properties) {
86123
86239
  return new CustomPaymentMethod(properties);
86124
86240
  };
@@ -86207,19 +86323,20 @@ export const proto = $root.proto = (() => {
86207
86323
  if (o.arrays || o.defaults) {
86208
86324
  d.metadata = [];
86209
86325
  }
86210
- if (o.defaults) {
86211
- d.credentialId = "";
86212
- d.country = "";
86213
- d.type = "";
86214
- }
86215
86326
  if (m.credentialId != null && m.hasOwnProperty("credentialId")) {
86216
86327
  d.credentialId = m.credentialId;
86328
+ if (o.oneofs)
86329
+ d._credentialId = "credentialId";
86217
86330
  }
86218
86331
  if (m.country != null && m.hasOwnProperty("country")) {
86219
86332
  d.country = m.country;
86333
+ if (o.oneofs)
86334
+ d._country = "country";
86220
86335
  }
86221
86336
  if (m.type != null && m.hasOwnProperty("type")) {
86222
86337
  d.type = m.type;
86338
+ if (o.oneofs)
86339
+ d._type = "type";
86223
86340
  }
86224
86341
  if (m.metadata && m.metadata.length) {
86225
86342
  d.metadata = [];
@@ -86253,8 +86370,20 @@ export const proto = $root.proto = (() => {
86253
86370
  this[ks[i]] = p[ks[i]];
86254
86371
  }
86255
86372
 
86256
- CustomPaymentMethodMetadata.prototype.key = "";
86257
- CustomPaymentMethodMetadata.prototype.value = "";
86373
+ CustomPaymentMethodMetadata.prototype.key = null;
86374
+ CustomPaymentMethodMetadata.prototype.value = null;
86375
+
86376
+ let $oneOfFields;
86377
+
86378
+ Object.defineProperty(CustomPaymentMethodMetadata.prototype, "_key", {
86379
+ get: $util.oneOfGetter($oneOfFields = ["key"]),
86380
+ set: $util.oneOfSetter($oneOfFields)
86381
+ });
86382
+
86383
+ Object.defineProperty(CustomPaymentMethodMetadata.prototype, "_value", {
86384
+ get: $util.oneOfGetter($oneOfFields = ["value"]),
86385
+ set: $util.oneOfSetter($oneOfFields)
86386
+ });
86258
86387
 
86259
86388
  CustomPaymentMethodMetadata.create = function create(properties) {
86260
86389
  return new CustomPaymentMethodMetadata(properties);
@@ -86312,15 +86441,15 @@ export const proto = $root.proto = (() => {
86312
86441
  if (!o)
86313
86442
  o = {};
86314
86443
  var d = {};
86315
- if (o.defaults) {
86316
- d.key = "";
86317
- d.value = "";
86318
- }
86319
86444
  if (m.key != null && m.hasOwnProperty("key")) {
86320
86445
  d.key = m.key;
86446
+ if (o.oneofs)
86447
+ d._key = "key";
86321
86448
  }
86322
86449
  if (m.value != null && m.hasOwnProperty("value")) {
86323
86450
  d.value = m.value;
86451
+ if (o.oneofs)
86452
+ d._value = "value";
86324
86453
  }
86325
86454
  return d;
86326
86455
  };
@@ -87441,11 +87570,16 @@ export const proto = $root.proto = (() => {
87441
87570
  this[ks[i]] = p[ks[i]];
87442
87571
  }
87443
87572
 
87444
- InteractiveMessageAction.prototype.type = 1;
87573
+ InteractiveMessageAction.prototype.type = null;
87445
87574
  InteractiveMessageAction.prototype.agmId = null;
87446
87575
 
87447
87576
  let $oneOfFields;
87448
87577
 
87578
+ Object.defineProperty(InteractiveMessageAction.prototype, "_type", {
87579
+ get: $util.oneOfGetter($oneOfFields = ["type"]),
87580
+ set: $util.oneOfSetter($oneOfFields)
87581
+ });
87582
+
87449
87583
  Object.defineProperty(InteractiveMessageAction.prototype, "_agmId", {
87450
87584
  get: $util.oneOfGetter($oneOfFields = ["agmId"]),
87451
87585
  set: $util.oneOfSetter($oneOfFields)
@@ -87516,11 +87650,10 @@ export const proto = $root.proto = (() => {
87516
87650
  if (!o)
87517
87651
  o = {};
87518
87652
  var d = {};
87519
- if (o.defaults) {
87520
- d.type = o.enums === String ? "DISABLE_CTA" : 1;
87521
- }
87522
87653
  if (m.type != null && m.hasOwnProperty("type")) {
87523
87654
  d.type = o.enums === String ? $root.proto.SyncActionValue.InteractiveMessageAction.InteractiveMessageActionMode[m.type] === undefined ? m.type : $root.proto.SyncActionValue.InteractiveMessageAction.InteractiveMessageActionMode[m.type] : m.type;
87655
+ if (o.oneofs)
87656
+ d._type = "type";
87524
87657
  }
87525
87658
  if (m.agmId != null && m.hasOwnProperty("agmId")) {
87526
87659
  d.agmId = m.agmId;
@@ -89007,13 +89140,23 @@ export const proto = $root.proto = (() => {
89007
89140
  this[ks[i]] = p[ks[i]];
89008
89141
  }
89009
89142
 
89010
- MerchantPaymentPartnerAction.prototype.status = 0;
89011
- MerchantPaymentPartnerAction.prototype.country = "";
89143
+ MerchantPaymentPartnerAction.prototype.status = null;
89144
+ MerchantPaymentPartnerAction.prototype.country = null;
89012
89145
  MerchantPaymentPartnerAction.prototype.gatewayName = null;
89013
89146
  MerchantPaymentPartnerAction.prototype.credentialId = null;
89014
89147
 
89015
89148
  let $oneOfFields;
89016
89149
 
89150
+ Object.defineProperty(MerchantPaymentPartnerAction.prototype, "_status", {
89151
+ get: $util.oneOfGetter($oneOfFields = ["status"]),
89152
+ set: $util.oneOfSetter($oneOfFields)
89153
+ });
89154
+
89155
+ Object.defineProperty(MerchantPaymentPartnerAction.prototype, "_country", {
89156
+ get: $util.oneOfGetter($oneOfFields = ["country"]),
89157
+ set: $util.oneOfSetter($oneOfFields)
89158
+ });
89159
+
89017
89160
  Object.defineProperty(MerchantPaymentPartnerAction.prototype, "_gatewayName", {
89018
89161
  get: $util.oneOfGetter($oneOfFields = ["gatewayName"]),
89019
89162
  set: $util.oneOfSetter($oneOfFields)
@@ -89111,15 +89254,15 @@ export const proto = $root.proto = (() => {
89111
89254
  if (!o)
89112
89255
  o = {};
89113
89256
  var d = {};
89114
- if (o.defaults) {
89115
- d.status = o.enums === String ? "ACTIVE" : 0;
89116
- d.country = "";
89117
- }
89118
89257
  if (m.status != null && m.hasOwnProperty("status")) {
89119
89258
  d.status = o.enums === String ? $root.proto.SyncActionValue.MerchantPaymentPartnerAction.Status[m.status] === undefined ? m.status : $root.proto.SyncActionValue.MerchantPaymentPartnerAction.Status[m.status] : m.status;
89259
+ if (o.oneofs)
89260
+ d._status = "status";
89120
89261
  }
89121
89262
  if (m.country != null && m.hasOwnProperty("country")) {
89122
89263
  d.country = m.country;
89264
+ if (o.oneofs)
89265
+ d._country = "country";
89123
89266
  }
89124
89267
  if (m.gatewayName != null && m.hasOwnProperty("gatewayName")) {
89125
89268
  d.gatewayName = m.gatewayName;
@@ -90238,8 +90381,20 @@ export const proto = $root.proto = (() => {
90238
90381
  this[ks[i]] = p[ks[i]];
90239
90382
  }
90240
90383
 
90241
- PaymentTosAction.prototype.paymentNotice = 0;
90242
- PaymentTosAction.prototype.accepted = false;
90384
+ PaymentTosAction.prototype.paymentNotice = null;
90385
+ PaymentTosAction.prototype.accepted = null;
90386
+
90387
+ let $oneOfFields;
90388
+
90389
+ Object.defineProperty(PaymentTosAction.prototype, "_paymentNotice", {
90390
+ get: $util.oneOfGetter($oneOfFields = ["paymentNotice"]),
90391
+ set: $util.oneOfSetter($oneOfFields)
90392
+ });
90393
+
90394
+ Object.defineProperty(PaymentTosAction.prototype, "_accepted", {
90395
+ get: $util.oneOfGetter($oneOfFields = ["accepted"]),
90396
+ set: $util.oneOfSetter($oneOfFields)
90397
+ });
90243
90398
 
90244
90399
  PaymentTosAction.create = function create(properties) {
90245
90400
  return new PaymentTosAction(properties);
@@ -90306,15 +90461,15 @@ export const proto = $root.proto = (() => {
90306
90461
  if (!o)
90307
90462
  o = {};
90308
90463
  var d = {};
90309
- if (o.defaults) {
90310
- d.paymentNotice = o.enums === String ? "BR_PAY_PRIVACY_POLICY" : 0;
90311
- d.accepted = false;
90312
- }
90313
90464
  if (m.paymentNotice != null && m.hasOwnProperty("paymentNotice")) {
90314
90465
  d.paymentNotice = o.enums === String ? $root.proto.SyncActionValue.PaymentTosAction.PaymentNotice[m.paymentNotice] === undefined ? m.paymentNotice : $root.proto.SyncActionValue.PaymentTosAction.PaymentNotice[m.paymentNotice] : m.paymentNotice;
90466
+ if (o.oneofs)
90467
+ d._paymentNotice = "paymentNotice";
90315
90468
  }
90316
90469
  if (m.accepted != null && m.hasOwnProperty("accepted")) {
90317
90470
  d.accepted = m.accepted;
90471
+ if (o.oneofs)
90472
+ d._accepted = "accepted";
90318
90473
  }
90319
90474
  return d;
90320
90475
  };
@@ -4,7 +4,7 @@ import { Browsers } from '../Utils/browser-utils.js';
4
4
  import logger from '../Utils/logger.js';
5
5
  const version = [2, 3000, 1035194821];
6
6
  export const UNAUTHORIZED_CODES = [401, 403, 419];
7
- export const BIZ_BOT_SUPPORT_PAYLOAD = '{"version":1,"is_ai_message":true,"should_show_system_message":false,"ticket_id":"7004947587700716","citation_items":[],"ticket_locale":"us"}';
7
+ export const BIZ_BOT_SUPPORT_PAYLOAD = '{"version":1,"is_ai_message":true,"should_upload_client_logs":false,"should_show_system_message":false,"ticket_id":"7004947587700716","citation_items":[],"ticket_locale":"us"}';
8
8
  export const DEFAULT_ORIGIN = 'https://web.whatsapp.com';
9
9
  export const CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
10
10
  export const CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/';
@@ -26,7 +26,6 @@ export const NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
26
26
  export const DICT_VERSION = 3;
27
27
  export const KEY_BUNDLE_TYPE = Buffer.from([5]);
28
28
  export const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]); // last is "DICT_VERSION"
29
- export const OLD_GROUP_ID_REGEX = /^(\d{1,15})-(\d+)@g\.us$/;
30
29
  /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
31
30
  export const URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
32
31
  export const WA_CERT_DETAILS = {
@@ -2,7 +2,7 @@ import NodeCache from '@cacheable/node-cache';
2
2
  import { Boom } from '@hapi/boom';
3
3
  import { randomBytes } from 'crypto';
4
4
  import { proto } from '../../WAProto/index.js';
5
- import { BIZ_BOT_SUPPORT_PAYLOAD, DEFAULT_CACHE_TTLS, OLD_GROUP_ID_REGEX, WA_DEFAULT_EPHEMERAL } from '../Defaults/index.js';
5
+ import { BIZ_BOT_SUPPORT_PAYLOAD, DEFAULT_CACHE_TTLS, WA_DEFAULT_EPHEMERAL } from '../Defaults/index.js';
6
6
  import { aggregateMessageKeysNotFromMe, assertMediaContent, bindWaitForEvent, decryptMediaRetryData, delay, encodeNewsletterMessage, encodeSignedDeviceIdentity, encodeWAMessage, encryptMediaRetryRequest, extractDeviceJids, generateMessageIDV2, generateParticipantHashV2, generateWAMessageFromContent, generateWAMessage, getStatusCodeForMediaRetry, getUrlFromDirectPath, getWAUploadToServer, hasValidAlbumMedia, MessageRetryManager, normalizeMessageContent, parseAndInjectE2ESessions, shouldIncludeBizBinaryNode, unixTimestampSeconds } from '../Utils/index.js';
7
7
  import { AssociationType } from '../Types/index.js';
8
8
  import { getUrlInfo } from '../Utils/link-preview.js';
@@ -432,7 +432,7 @@ export const makeMessagesSocket = (config) => {
432
432
  const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }) => {
433
433
  const meId = authState.creds.me.id;
434
434
  const meLid = authState.creds.me?.lid;
435
- const isRetryResend = Boolean(participant?.jid);
435
+ const isRetryResend = !!participant?.jid;
436
436
  let shouldIncludeDeviceIdentity = isRetryResend;
437
437
  const statusJid = 'status@broadcast';
438
438
  const { user, server } = jidDecode(jid);
@@ -497,7 +497,7 @@ export const makeMessagesSocket = (config) => {
497
497
  attrs: {
498
498
  to: jid,
499
499
  id: msgId,
500
- type: getMessageType(message),
500
+ type: getMessageType(innerMessage),
501
501
  ...(additionalAttributes || {})
502
502
  },
503
503
  content: binaryNodeContent
@@ -731,7 +731,7 @@ export const makeMessagesSocket = (config) => {
731
731
  attrs: {
732
732
  id: msgId,
733
733
  to: destinationJid,
734
- type: getMessageType(message),
734
+ type: getMessageType(innerMessage),
735
735
  ...(additionalAttributes || {})
736
736
  },
737
737
  content: binaryNodeContent
@@ -802,17 +802,10 @@ export const makeMessagesSocket = (config) => {
802
802
  stanza.content.push(...additionalNodes);
803
803
  }
804
804
  // Lia@Changes 30-01-26 --- Add Biz Binary Node to support button messages
805
- else if (shouldIncludeBizBinaryNode(innerMessage)) {
805
+ if (shouldIncludeBizBinaryNode(innerMessage)) {
806
806
  const bizNode = getBizBinaryNode(innerMessage);
807
807
  stanza.content.push(bizNode);
808
808
  }
809
- if (isGroup && OLD_GROUP_ID_REGEX.test(jid) && !innerMessage.reactionMessage) {
810
- stanza.content.push({
811
- tag: 'multicast',
812
- attrs: {},
813
- content: undefined
814
- })
815
- }
816
809
  logger.debug({ msgId }, `sending message to ${participants.length} devices`);
817
810
  await sendNode(stanza);
818
811
  // Add message to retry cache if enabled
@@ -823,24 +816,23 @@ export const makeMessagesSocket = (config) => {
823
816
  return msgId;
824
817
  };
825
818
  const getMessageType = (message) => {
826
- const normalizedMessage = normalizeMessageContent(message);
827
- if (!normalizedMessage)
819
+ if (!message)
828
820
  return 'text';
829
- if (normalizedMessage.reactionMessage || normalizedMessage.encReactionMessage) {
821
+ if (message.reactionMessage || message.encReactionMessage) {
830
822
  return 'reaction';
831
823
  }
832
- if (normalizedMessage.pollCreationMessage ||
833
- normalizedMessage.pollCreationMessageV2 ||
834
- normalizedMessage.pollCreationMessageV3 ||
835
- normalizedMessage.pollCreationMessageV5 ||
836
- normalizedMessage.pollCreationMessageV6 ||
837
- normalizedMessage.pollUpdateMessage) {
824
+ if (message.pollCreationMessage ||
825
+ message.pollCreationMessageV2 ||
826
+ message.pollCreationMessageV3 ||
827
+ message.pollCreationMessageV5 ||
828
+ message.pollCreationMessageV6 ||
829
+ message.pollUpdateMessage) {
838
830
  return 'poll';
839
831
  }
840
- if (normalizedMessage.eventMessage) {
832
+ if (message.eventMessage) {
841
833
  return 'event';
842
834
  }
843
- if (getMediaType(normalizedMessage) !== '') {
835
+ if (getMediaType(message) !== '') {
844
836
  return 'media';
845
837
  }
846
838
  return 'text';
@@ -655,35 +655,34 @@ export const generateForwardMessageContent = (message, forceForward) => {
655
655
  return content;
656
656
  };
657
657
  export const hasNonNullishProperty = (message, key) => {
658
- return (typeof message === 'object' &&
659
- message !== null &&
658
+ return message != null &&
659
+ typeof message === 'object' &&
660
660
  key in message &&
661
- message[key] !== null &&
662
- message[key] !== undefined);
661
+ message[key] != null;
663
662
  };
664
663
  export const hasOptionalProperty = (obj, key) => {
665
- return typeof obj === 'object' &&
666
- obj !== null &&
664
+ return obj != null &&
665
+ typeof obj === 'object' &&
667
666
  key in obj &&
668
- obj[key] !== null;
667
+ obj[key] != null;
669
668
  };
670
669
  // Lia@Changes 06-02-26 --- Validate album message media to avoid bug 👀
671
670
  export const hasValidAlbumMedia = (message) => {
672
- return Boolean(message.imageMessage ||
673
- message.videoMessage);
671
+ return message.imageMessage ||
672
+ message.videoMessage;
674
673
  };
675
674
  export const hasValidInteractiveHeader = (message) => {
676
- return Boolean(message.imageMessage ||
675
+ return message.imageMessage ||
677
676
  message.videoMessage ||
678
677
  message.documentMessage ||
679
678
  message.productMessage ||
680
- message.locationMessage);
679
+ message.locationMessage;
681
680
  };
682
681
  // Lia@Changes 30-01-26 --- Validate carousel cards header to avoid bug 👀
683
682
  export const hasValidCarouselHeader = (message) => {
684
- return Boolean(message.imageMessage ||
683
+ return message.imageMessage ||
685
684
  message.videoMessage ||
686
- message.productMessage);
685
+ message.productMessage;
687
686
  };
688
687
  export const generateWAMessageContent = async (message, options) => {
689
688
  var _a, _b;
@@ -1875,11 +1874,13 @@ const isWebPBuffer = (buffer) => {
1875
1874
  * such as buttons or other supported interactive types.
1876
1875
  */
1877
1876
  export const shouldIncludeBizBinaryNode = (message) => {
1878
- const messageType = getContentType(message);
1879
- return (
1880
- messageType === 'buttonsMessage' ||
1881
- messageType === 'interactiveMessage' ||
1882
- messageType === 'listMessage' ||
1883
- messageType === 'templateMessage'
1884
- );
1877
+ const hasValidInteractive =
1878
+ message.interactiveMessage &&
1879
+ !message.interactiveMessage.carouselMessage &&
1880
+ !message.interactiveMessage.collectionMessage &&
1881
+ !message.interactiveMessage.shopStorefrontMessage;
1882
+ return (message.buttonsMessage ||
1883
+ message.interactiveMessage ||
1884
+ message.listMessage ||
1885
+ hasValidInteractive);
1885
1886
  };
@@ -1,4 +1,5 @@
1
1
  import { Boom } from '@hapi/boom';
2
+ import { randomBytes } from 'crypto';
2
3
  import { proto } from '../../WAProto/index.js';
3
4
  import {} from './types.js';
4
5
  // some extra useful utilities
@@ -131,48 +132,65 @@ const FLOWS_MAP = {
131
132
  wa_payment_transaction_details: true,
132
133
  automated_greeting_message_view_catalog: true
133
134
  };
134
- const qualityAttribute = {
135
- tag: 'quality_control',
136
- attrs: { source_type: 'third_party' }
137
- };
138
- const defaultContent = [qualityAttribute]
139
- const listContent = [
135
+ const DECISION_SOURCE_CONTENT = [
140
136
  {
141
- tag: 'list',
142
- attrs: { v: '2', type: 'product_list' }
143
- },
144
- qualityAttribute
137
+ tag: 'decision_source',
138
+ attrs: { value: 'df' }
139
+ }
145
140
  ];
141
+ const LIST_TYPE_CONTENT = {
142
+ tag: 'list',
143
+ attrs: { v: '2', type: 'product_list' }
144
+ };
145
+ const NATIVE_FLOW_ATTRIBUTE = { type: 'native_flow', v: '1' };
146
+ const MIXED_NATIVE_FLOW = {
147
+ tag: 'interactive',
148
+ attrs: NATIVE_FLOW_ATTRIBUTE,
149
+ content: [
150
+ {
151
+ tag: 'native_flow',
152
+ attrs: { v: '9', name: 'mixed' }
153
+ }
154
+ ]
155
+ };
146
156
  export const getBizBinaryNode = (message) => {
147
157
  const flowMsg = message.interactiveMessage?.nativeFlowMessage;
148
- const buttonName = flowMsg?.buttons?.[0]?.name;
149
- if (buttonName === 'review_and_pay' || buttonName === 'payment_info') {
158
+ const firstButtonName = flowMsg?.buttons?.[0]?.name;
159
+ const qualityContent = {
160
+ tag: 'quality_control',
161
+ attrs: {
162
+ decision_id: randomBytes(20).toString('hex'),
163
+ source_type: 'third_party'
164
+ },
165
+ content: DECISION_SOURCE_CONTENT
166
+ };
167
+ if (firstButtonName === 'review_and_pay' || firstButtonName === 'payment_info') {
150
168
  return {
151
169
  tag: 'biz',
152
170
  attrs: {
153
- native_flow_name: buttonName === 'review_and_pay' ?
171
+ native_flow_name: firstButtonName === 'review_and_pay' ?
154
172
  'order_details' :
155
- buttonName
173
+ firstButtonName
156
174
  },
157
- content: defaultContent
175
+ content: [qualityContent]
158
176
  };
159
177
  }
160
- if (buttonName && FLOWS_MAP[buttonName]) {
178
+ if (firstButtonName && FLOWS_MAP[firstButtonName]) {
161
179
  return {
162
180
  tag: 'biz',
163
181
  attrs: {},
164
182
  content: [
165
183
  {
166
184
  tag: 'interactive',
167
- attrs: { type: 'native_flow', v: '1' },
185
+ attrs: NATIVE_FLOW_ATTRIBUTE,
168
186
  content: [
169
187
  {
170
188
  tag: 'native_flow',
171
- attrs: { v: '2', name: buttonName }
189
+ attrs: { v: '2', name: firstButtonName }
172
190
  }
173
191
  ]
174
192
  },
175
- qualityAttribute
193
+ qualityContent
176
194
  ]
177
195
  };
178
196
  }
@@ -181,17 +199,8 @@ export const getBizBinaryNode = (message) => {
181
199
  tag: 'biz',
182
200
  attrs: {},
183
201
  content: [
184
- {
185
- tag: 'interactive',
186
- attrs: { type: 'native_flow', v: '1' },
187
- content: [
188
- {
189
- tag: 'native_flow',
190
- attrs: { v: '9', name: 'mixed' }
191
- }
192
- ]
193
- },
194
- qualityAttribute
202
+ MIXED_NATIVE_FLOW,
203
+ qualityContent
195
204
  ]
196
205
  };
197
206
  }
@@ -199,12 +208,15 @@ export const getBizBinaryNode = (message) => {
199
208
  return {
200
209
  tag: 'biz',
201
210
  attrs: {},
202
- content: listContent
211
+ content: [
212
+ LIST_TYPE_CONTENT,
213
+ qualityContent
214
+ ]
203
215
  };
204
216
  }
205
217
  return {
206
218
  tag: 'biz',
207
219
  attrs: {},
208
- content: defaultContent
220
+ content: [qualityContent]
209
221
  };
210
222
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itsliaaa/baileys",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "A simple fork of Baileys for WhatsApp automation",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",