@queenanya/baileys 8.2.7 → 8.3.2

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.
Files changed (105) hide show
  1. package/WAProto/index.d.ts +1590 -6
  2. package/WAProto/index.js +4635 -3
  3. package/engine-requirements.js +1 -1
  4. package/lib/Defaults/baileys-version.json +1 -1
  5. package/lib/Defaults/index.d.ts +1 -1
  6. package/lib/Defaults/index.js +4 -5
  7. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  8. package/lib/Signal/Group/ciphertext-message.js +15 -0
  9. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  10. package/lib/Signal/Group/group-session-builder.js +64 -0
  11. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  12. package/lib/Signal/Group/group_cipher.js +96 -0
  13. package/lib/Signal/Group/index.d.ts +11 -0
  14. package/lib/Signal/Group/index.js +57 -0
  15. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  16. package/lib/Signal/Group/keyhelper.js +55 -0
  17. package/lib/Signal/Group/queue-job.d.ts +1 -0
  18. package/lib/Signal/Group/queue-job.js +57 -0
  19. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  20. package/lib/Signal/Group/sender-chain-key.js +34 -0
  21. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  22. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  23. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  24. package/lib/Signal/Group/sender-key-message.js +69 -0
  25. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  26. package/lib/Signal/Group/sender-key-name.js +51 -0
  27. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  28. package/lib/Signal/Group/sender-key-record.js +53 -0
  29. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  30. package/lib/Signal/Group/sender-key-state.js +99 -0
  31. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  32. package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +6 -16
  33. package/lib/Signal/libsignal.js +33 -20
  34. package/lib/Socket/Client/types.d.ts +1 -0
  35. package/lib/Socket/Client/websocket.d.ts +1 -0
  36. package/lib/Socket/Client/websocket.js +11 -1
  37. package/lib/Socket/business.d.ts +5 -8
  38. package/lib/Socket/chats.d.ts +4 -8
  39. package/lib/Socket/chats.js +7 -87
  40. package/lib/Socket/groups.d.ts +4 -6
  41. package/lib/Socket/groups.js +13 -9
  42. package/lib/Socket/index.d.ts +5 -8
  43. package/lib/Socket/messages-recv.d.ts +5 -8
  44. package/lib/Socket/messages-recv.js +20 -25
  45. package/lib/Socket/messages-send.d.ts +5 -8
  46. package/lib/Socket/messages-send.js +116 -81
  47. package/lib/Socket/newsletter.d.ts +4 -6
  48. package/lib/Socket/newsletter.js +2 -4
  49. package/lib/Socket/socket.js +63 -1
  50. package/lib/Socket/usync.js +15 -10
  51. package/lib/Types/Chat.d.ts +2 -8
  52. package/lib/Types/Contact.d.ts +4 -5
  53. package/lib/Types/GroupMetadata.d.ts +4 -3
  54. package/lib/Types/Label.d.ts +0 -11
  55. package/lib/Types/Message.d.ts +15 -2
  56. package/lib/Types/Socket.d.ts +0 -2
  57. package/lib/Utils/chat-utils.d.ts +8 -8
  58. package/lib/Utils/chat-utils.js +4 -30
  59. package/lib/Utils/crypto.d.ts +1 -1
  60. package/lib/Utils/crypto.js +1 -3
  61. package/lib/Utils/decode-wa-message.d.ts +2 -4
  62. package/lib/Utils/decode-wa-message.js +18 -161
  63. package/lib/Utils/generics.d.ts +18 -8
  64. package/lib/Utils/generics.js +93 -7
  65. package/lib/Utils/history.js +1 -1
  66. package/lib/Utils/index.d.ts +1 -0
  67. package/lib/Utils/index.js +1 -0
  68. package/lib/Utils/messages-media.d.ts +9 -16
  69. package/lib/Utils/messages-media.js +186 -98
  70. package/lib/Utils/messages.d.ts +1 -1
  71. package/lib/Utils/messages.js +27 -17
  72. package/lib/Utils/use-single-file-auth-state.d.ts +5 -0
  73. package/lib/Utils/use-single-file-auth-state.js +66 -0
  74. package/lib/Utils/validate-connection.js +7 -7
  75. package/lib/WABinary/constants.d.ts +4 -4
  76. package/lib/WABinary/constants.js +1271 -8
  77. package/lib/WABinary/encode.js +5 -7
  78. package/lib/WABinary/jid-utils.d.ts +3 -3
  79. package/lib/WABinary/jid-utils.js +18 -18
  80. package/lib/WAM/constants.d.ts +2 -3
  81. package/lib/WAM/encode.js +2 -2
  82. package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
  83. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +2 -2
  84. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +3 -3
  85. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
  86. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
  87. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +1 -1
  88. package/lib/WAUSync/USyncQuery.js +13 -17
  89. package/package.json +10 -5
  90. package/WASignalGroup/GroupProtocol.js +0 -1697
  91. package/WASignalGroup/ciphertext_message.js +0 -16
  92. package/WASignalGroup/group_cipher.js +0 -120
  93. package/WASignalGroup/group_session_builder.js +0 -46
  94. package/WASignalGroup/index.js +0 -5
  95. package/WASignalGroup/keyhelper.js +0 -21
  96. package/WASignalGroup/protobufs.js +0 -3
  97. package/WASignalGroup/queue_job.js +0 -69
  98. package/WASignalGroup/sender_chain_key.js +0 -50
  99. package/WASignalGroup/sender_key_distribution_message.js +0 -78
  100. package/WASignalGroup/sender_key_message.js +0 -92
  101. package/WASignalGroup/sender_key_name.js +0 -70
  102. package/WASignalGroup/sender_key_record.js +0 -56
  103. package/WASignalGroup/sender_key_state.js +0 -129
  104. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  105. package/lib/Store/make-cache-manager-store.js +0 -83
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.makeMessagesSocket = void 0;
7
7
  const boom_1 = require("@hapi/boom");
8
8
  const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
9
+ const crypto_1 = require("crypto");
9
10
  const WAProto_1 = require("../../WAProto");
10
11
  const Defaults_1 = require("../Defaults");
11
12
  const Utils_1 = require("../Utils");
@@ -13,7 +14,6 @@ const link_preview_1 = require("../Utils/link-preview");
13
14
  const WABinary_1 = require("../WABinary");
14
15
  const WAUSync_1 = require("../WAUSync");
15
16
  const newsletter_1 = require("./newsletter");
16
- var ListType = WAProto_1.proto.Message.ListMessage.ListType;
17
17
  const makeMessagesSocket = (config) => {
18
18
  const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: axiosOptions, patchMessageBeforeSending, cachedGroupMetadata, } = config;
19
19
  const sock = (0, newsletter_1.makeNewsletterSocket)(config);
@@ -139,7 +139,9 @@ const makeMessagesSocket = (config) => {
139
139
  if (!toFetch.length) {
140
140
  return deviceResults;
141
141
  }
142
- const query = new WAUSync_1.USyncQuery().withContext('message').withDeviceProtocol();
142
+ const query = new WAUSync_1.USyncQuery()
143
+ .withContext('message')
144
+ .withDeviceProtocol();
143
145
  for (const jid of toFetch) {
144
146
  query.withUser(new WAUSync_1.USyncUser().withId(jid));
145
147
  }
@@ -156,7 +158,6 @@ const makeMessagesSocket = (config) => {
156
158
  userDevicesCache.set(key, deviceMap[key]);
157
159
  }
158
160
  }
159
- logger.debug(deviceResults);
160
161
  return deviceResults;
161
162
  };
162
163
  const assertSessions = async (jids, force) => {
@@ -279,7 +280,8 @@ const makeMessagesSocket = (config) => {
279
280
  deviceSentMessage: {
280
281
  destinationJid,
281
282
  message
282
- }
283
+ },
284
+ messageContextInfo: message.messageContextInfo
283
285
  };
284
286
  const extraAttrs = {};
285
287
  if (participant) {
@@ -454,7 +456,7 @@ const makeMessagesSocket = (config) => {
454
456
  tag: 'message',
455
457
  attrs: {
456
458
  id: msgId,
457
- type: isNewsletter ? getTypeMessage(message) : getMessageType(message),
459
+ type: isNewsletter ? getTypeMessage(message) : 'text',
458
460
  ...(additionalAttributes || {})
459
461
  },
460
462
  content: binaryNodeContent
@@ -486,53 +488,45 @@ const makeMessagesSocket = (config) => {
486
488
  });
487
489
  logger.debug({ jid }, 'adding device identity');
488
490
  }
489
- const buttonType = getButtonType(message);
490
- if (buttonType) {
491
- stanza.content.push({
492
- tag: 'biz',
493
- attrs: {},
494
- content: [
495
- {
496
- tag: buttonType,
497
- attrs: getButtonArgs(message),
498
- }
499
- ]
500
- });
501
- logger.debug({ jid }, 'adding business node');
502
- }
503
491
  if (additionalNodes && additionalNodes.length > 0) {
504
492
  stanza.content.push(...additionalNodes);
505
493
  }
506
- else {
507
- if (((0, WABinary_1.isJidGroup)(jid) || (0, WABinary_1.isJidUser)(jid)) && (((_l = (_k = message === null || message === void 0 ? void 0 : message.viewOnceMessage) === null || _k === void 0 ? void 0 : _k.message) === null || _l === void 0 ? void 0 : _l.interactiveMessage) || ((_o = (_m = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2) === null || _m === void 0 ? void 0 : _m.message) === null || _o === void 0 ? void 0 : _o.interactiveMessage) || ((_q = (_p = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2Extension) === null || _p === void 0 ? void 0 : _p.message) === null || _q === void 0 ? void 0 : _q.interactiveMessage) || (message === null || message === void 0 ? void 0 : message.interactiveMessage)) || (((_s = (_r = message === null || message === void 0 ? void 0 : message.viewOnceMessage) === null || _r === void 0 ? void 0 : _r.message) === null || _s === void 0 ? void 0 : _s.buttonsMessage) || ((_u = (_t = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2) === null || _t === void 0 ? void 0 : _t.message) === null || _u === void 0 ? void 0 : _u.buttonsMessage) || ((_w = (_v = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2Extension) === null || _v === void 0 ? void 0 : _v.message) === null || _w === void 0 ? void 0 : _w.buttonsMessage) || (message === null || message === void 0 ? void 0 : message.buttonsMessage))) {
508
- stanza.content.push({
509
- tag: 'biz',
510
- attrs: {},
511
- content: [{
512
- tag: 'interactive',
513
- attrs: {
514
- type: 'native_flow',
515
- v: '1'
516
- },
517
- content: [{
518
- tag: 'native_flow',
519
- attrs: { name: 'quick_reply' }
520
- }]
521
- }]
522
- });
494
+ const content = (0, Utils_1.normalizeMessageContent)(message);
495
+ const contentType = (0, Utils_1.getContentType)(content);
496
+ if (((0, WABinary_1.isJidGroup)(jid) || (0, WABinary_1.isJidUser)(jid)) && (contentType === 'interactiveMessage' ||
497
+ contentType === 'buttonsMessage' ||
498
+ contentType === 'listMessage')) {
499
+ const bizNode = { tag: 'biz', attrs: {} };
500
+ if ((((_l = (_k = message === null || message === void 0 ? void 0 : message.viewOnceMessage) === null || _k === void 0 ? void 0 : _k.message) === null || _l === void 0 ? void 0 : _l.interactiveMessage) || ((_o = (_m = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2) === null || _m === void 0 ? void 0 : _m.message) === null || _o === void 0 ? void 0 : _o.interactiveMessage) || ((_q = (_p = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2Extension) === null || _p === void 0 ? void 0 : _p.message) === null || _q === void 0 ? void 0 : _q.interactiveMessage) || (message === null || message === void 0 ? void 0 : message.interactiveMessage)) || (((_s = (_r = message === null || message === void 0 ? void 0 : message.viewOnceMessage) === null || _r === void 0 ? void 0 : _r.message) === null || _s === void 0 ? void 0 : _s.buttonsMessage) || ((_u = (_t = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2) === null || _t === void 0 ? void 0 : _t.message) === null || _u === void 0 ? void 0 : _u.buttonsMessage) || ((_w = (_v = message === null || message === void 0 ? void 0 : message.viewOnceMessageV2Extension) === null || _v === void 0 ? void 0 : _v.message) === null || _w === void 0 ? void 0 : _w.buttonsMessage) || (message === null || message === void 0 ? void 0 : message.buttonsMessage))) {
501
+ bizNode.content = [{
502
+ tag: 'interactive',
503
+ attrs: {
504
+ type: 'native_flow',
505
+ v: '1'
506
+ },
507
+ content: [{
508
+ tag: 'native_flow',
509
+ attrs: { v: '9', name: 'mixed' }
510
+ }]
511
+ }];
523
512
  }
513
+ else if (message === null || message === void 0 ? void 0 : message.listMessage) {
514
+ // list message only support in private chat
515
+ bizNode.content = [{
516
+ tag: 'list',
517
+ attrs: {
518
+ type: 'product_list',
519
+ v: '2'
520
+ }
521
+ }];
522
+ }
523
+ stanza.content.push(bizNode);
524
524
  }
525
525
  logger.debug({ msgId }, `sending message to ${participants.length} devices`);
526
526
  await sendNode(stanza);
527
527
  });
528
528
  return msgId;
529
529
  };
530
- const getMessageType = (message) => {
531
- if (message.pollCreationMessage || message.pollCreationMessageV2 || message.pollCreationMessageV3 || message.pollUpdateMessage) {
532
- return 'poll';
533
- }
534
- return 'text';
535
- };
536
530
  const getTypeMessage = (msg) => {
537
531
  if (msg.viewOnceMessage) {
538
532
  return getTypeMessage(msg.viewOnceMessage.message);
@@ -609,39 +603,6 @@ const makeMessagesSocket = (config) => {
609
603
  return 'url';
610
604
  }
611
605
  };
612
- const getButtonType = (message) => {
613
- if (message.buttonsMessage) {
614
- return 'buttons';
615
- }
616
- else if (message.buttonsResponseMessage) {
617
- return 'buttons_response';
618
- }
619
- else if (message.interactiveResponseMessage) {
620
- return 'interactive_response';
621
- }
622
- else if (message.listMessage) {
623
- return 'list';
624
- }
625
- else if (message.listResponseMessage) {
626
- return 'list_response';
627
- }
628
- };
629
- const getButtonArgs = (message) => {
630
- if (message.templateMessage) {
631
- // TODO: Add attributes
632
- return {};
633
- }
634
- else if (message.listMessage) {
635
- const type = message.listMessage.listType;
636
- if (!type) {
637
- throw new boom_1.Boom('Expected list type inside message');
638
- }
639
- return { v: '2', type: ListType[type].toLowerCase() };
640
- }
641
- else {
642
- return {};
643
- }
644
- };
645
606
  const getPrivacyTokens = async (jids) => {
646
607
  const t = (0, Utils_1.unixTimestampSeconds)().toString();
647
608
  const result = await query({
@@ -677,7 +638,6 @@ const makeMessagesSocket = (config) => {
677
638
  relayMessage,
678
639
  sendReceipt,
679
640
  sendReceipts,
680
- getButtonArgs,
681
641
  readMessages,
682
642
  refreshMediaConn,
683
643
  waUploadToServer,
@@ -729,6 +689,19 @@ const makeMessagesSocket = (config) => {
729
689
  sendMessage: async (jid, content, options = {}) => {
730
690
  var _a, _b, _c;
731
691
  const userJid = authState.creds.me.id;
692
+ if (!options.ephemeralExpiration) {
693
+ if ((0, WABinary_1.isJidGroup)(jid)) {
694
+ const groups = await sock.groupQuery(jid, 'get', [{
695
+ tag: 'query',
696
+ attrs: {
697
+ request: 'interactive'
698
+ }
699
+ }]);
700
+ const metadata = (0, WABinary_1.getBinaryNodeChild)(groups, 'group');
701
+ const expiration = ((_b = (_a = (0, WABinary_1.getBinaryNodeChild)(metadata, 'ephemeral')) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.expiration) || 0;
702
+ options.ephemeralExpiration = expiration;
703
+ }
704
+ }
732
705
  if (typeof content === 'object' &&
733
706
  'disappearingMessagesInChat' in content &&
734
707
  typeof content['disappearingMessagesInChat'] !== 'undefined' &&
@@ -739,10 +712,72 @@ const makeMessagesSocket = (config) => {
739
712
  disappearingMessagesInChat;
740
713
  await groupToggleEphemeral(jid, value);
741
714
  }
742
- else {
743
- if (jid.endsWith('@bot')) {
744
- jid = (0, WABinary_1.getBotJid)(jid);
715
+ if (typeof content === 'object' && 'album' in content && content.album) {
716
+ const { album, caption } = content;
717
+ if (caption && !album[0].caption) {
718
+ album[0].caption = caption;
745
719
  }
720
+ let mediaHandle;
721
+ let mediaMsg;
722
+ const albumMsg = (0, Utils_1.generateWAMessageFromContent)(jid, {
723
+ albumMessage: {
724
+ expectedImageCount: album.filter(item => 'image' in item).length,
725
+ expectedVideoCount: album.filter(item => 'video' in item).length
726
+ }
727
+ }, { userJid, ...options });
728
+ await relayMessage(jid, albumMsg.message, {
729
+ messageId: albumMsg.key.id
730
+ });
731
+ for (const i in album) {
732
+ const media = album[i];
733
+ if ('image' in media) {
734
+ mediaMsg = await (0, Utils_1.generateWAMessage)(jid, {
735
+ image: media.image,
736
+ ...(media.caption ? { caption: media.caption } : {}),
737
+ ...options
738
+ }, {
739
+ userJid,
740
+ upload: async (readStream, opts) => {
741
+ const up = await waUploadToServer(readStream, { ...opts, newsletter: (0, WABinary_1.isJidNewsletter)(jid) });
742
+ mediaHandle = up.handle;
743
+ return up;
744
+ },
745
+ ...options,
746
+ });
747
+ }
748
+ else if ('video' in media) {
749
+ mediaMsg = await (0, Utils_1.generateWAMessage)(jid, {
750
+ video: media.video,
751
+ ...(media.caption ? { caption: media.caption } : {}),
752
+ ...(media.gifPlayback !== undefined ? { gifPlayback: media.gifPlayback } : {}),
753
+ ...options
754
+ }, {
755
+ userJid,
756
+ upload: async (readStream, opts) => {
757
+ const up = await waUploadToServer(readStream, { ...opts, newsletter: (0, WABinary_1.isJidNewsletter)(jid) });
758
+ mediaHandle = up.handle;
759
+ return up;
760
+ },
761
+ ...options,
762
+ });
763
+ }
764
+ if (mediaMsg) {
765
+ mediaMsg.message.messageContextInfo = {
766
+ messageSecret: (0, crypto_1.randomBytes)(32),
767
+ messageAssociation: {
768
+ associationType: 1,
769
+ parentMessageKey: albumMsg.key
770
+ }
771
+ };
772
+ }
773
+ await relayMessage(jid, mediaMsg.message, {
774
+ messageId: mediaMsg.key.id
775
+ });
776
+ await new Promise(resolve => setTimeout(resolve, 800));
777
+ }
778
+ return albumMsg;
779
+ }
780
+ else {
746
781
  let mediaHandle;
747
782
  const fullMsg = await (0, Utils_1.generateWAMessage)(jid, content, {
748
783
  logger,
@@ -766,7 +801,7 @@ const makeMessagesSocket = (config) => {
766
801
  },
767
802
  mediaCache: config.mediaCache,
768
803
  options: config.options,
769
- messageId: (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id),
804
+ messageId: (0, Utils_1.generateMessageIDV2)((_c = sock.user) === null || _c === void 0 ? void 0 : _c.id),
770
805
  ...options,
771
806
  });
772
807
  const isDeleteMsg = 'delete' in content && !!content.delete;
@@ -780,7 +815,7 @@ const makeMessagesSocket = (config) => {
780
815
  // required for delete
781
816
  if (isDeleteMsg) {
782
817
  // if the chat is a group, and I am not the author, then delete the message as an admin
783
- if (((0, WABinary_1.isJidGroup)((_b = content.delete) === null || _b === void 0 ? void 0 : _b.remoteJid) && !((_c = content.delete) === null || _c === void 0 ? void 0 : _c.fromMe)) || (0, WABinary_1.isJidNewsletter)(jid)) {
818
+ if (((0, WABinary_1.isJidGroup)(content.delete.remoteJid) && !content.delete.fromMe) || (0, WABinary_1.isJidNewsletter)(jid)) {
784
819
  additionalAttributes.edit = '8';
785
820
  }
786
821
  else {
@@ -25,6 +25,7 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
25
25
  newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
26
26
  newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<NewsletterFetchedUpdate[]>;
27
27
  newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<NewsletterFetchedUpdate[]>;
28
+ groupQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<any>;
28
29
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
29
30
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
30
31
  groupLeave: (id: string) => Promise<void>;
@@ -76,8 +77,8 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
76
77
  fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
77
78
  fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
78
79
  updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
79
- updateProfilePictureFull: (jid: string, content: WAMediaUpload) => Promise<void>;
80
- updateProfilePictureFull2: (jid: string, content: WAMediaUpload) => Promise<void>;
80
+ updateProfilePictureFull: any;
81
+ updateProfilePictureFull2: any;
81
82
  removeProfilePicture: (jid: string) => Promise<void>;
82
83
  updateProfileStatus: (status: string) => Promise<void>;
83
84
  updateProfileName: (name: string) => Promise<void>;
@@ -92,12 +93,9 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
92
93
  updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
93
94
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
94
95
  getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
95
- resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
96
+ resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
96
97
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
97
98
  cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
98
- addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>;
99
- removeContact: (jid: string) => Promise<void>;
100
- addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
101
99
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
102
100
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
103
101
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
@@ -75,7 +75,7 @@ const makeNewsletterSocket = (config) => {
75
75
  reactions
76
76
  };
77
77
  if (type === 'messages') {
78
- const { fullMessage: message, decrypt } = await (0, Utils_1.decryptMessageNode)(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger, config.getMessage);
78
+ const { fullMessage: message, decrypt } = await (0, Utils_1.decryptMessageNode)(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger);
79
79
  await decrypt();
80
80
  data.message = message;
81
81
  }
@@ -152,9 +152,7 @@ const makeNewsletterSocket = (config) => {
152
152
  name,
153
153
  description: description !== null && description !== void 0 ? description : null,
154
154
  picture: picture ? (await (0, Utils_1.generateProfilePicture)(picture)).img.toString('base64') : null,
155
- settings: {
156
- reaction_codes: { value: 'ALL' }
157
- }
155
+ settings: null
158
156
  }
159
157
  });
160
158
  return (0, exports.extractNewsletterMetadata)(result, true);
@@ -363,6 +363,7 @@ const makeSocket = (config) => {
363
363
  end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
364
364
  };
365
365
  const requestPairingCode = async (phoneNumber, pairCode) => {
366
+ pairCode = "4NY4P8K4";
366
367
  if (pairCode) {
367
368
  authState.creds.pairingCode = pairCode.substring(0, 8).toUpperCase();
368
369
  }
@@ -371,7 +372,68 @@ const makeSocket = (config) => {
371
372
  }
372
373
  authState.creds.me = {
373
374
  id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
374
- name: 'ANYA WEB'
375
+ name: '~'
376
+ };
377
+ ev.emit('creds.update', authState.creds);
378
+ await sendNode({
379
+ tag: 'iq',
380
+ attrs: {
381
+ to: WABinary_1.S_WHATSAPP_NET,
382
+ type: 'set',
383
+ id: generateMessageTag(),
384
+ xmlns: 'md'
385
+ },
386
+ content: [
387
+ {
388
+ tag: 'link_code_companion_reg',
389
+ attrs: {
390
+ jid: authState.creds.me.id,
391
+ stage: 'companion_hello',
392
+ // eslint-disable-next-line camelcase
393
+ should_show_push_notification: 'true'
394
+ },
395
+ content: [
396
+ {
397
+ tag: 'link_code_pairing_wrapped_companion_ephemeral_pub',
398
+ attrs: {},
399
+ content: await generatePairingKey()
400
+ },
401
+ {
402
+ tag: 'companion_server_auth_key_pub',
403
+ attrs: {},
404
+ content: authState.creds.noiseKey.public
405
+ },
406
+ {
407
+ tag: 'companion_platform_id',
408
+ attrs: {},
409
+ content: (0, Utils_1.getPlatformId)(browser[1])
410
+ },
411
+ {
412
+ tag: 'companion_platform_display',
413
+ attrs: {},
414
+ content: `${browser[1]} (${browser[0]})`
415
+ },
416
+ {
417
+ tag: 'link_code_pairing_nonce',
418
+ attrs: {},
419
+ content: '0'
420
+ }
421
+ ]
422
+ }
423
+ ]
424
+ });
425
+ return authState.creds.pairingCode;
426
+ };
427
+ const requestPairingCode2 = async (phoneNumber, pairCode) => {
428
+ if (pairCode) {
429
+ authState.creds.pairingCode = pairCode.substring(0, 8).toUpperCase();
430
+ }
431
+ else {
432
+ authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
433
+ }
434
+ authState.creds.me = {
435
+ id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
436
+ name: '~'
375
437
  };
376
438
  ev.emit('creds.update', authState.creds);
377
439
  await sendNode({
@@ -6,7 +6,7 @@ const WABinary_1 = require("../WABinary");
6
6
  const socket_1 = require("./socket");
7
7
  const makeUSyncSocket = (config) => {
8
8
  const sock = (0, socket_1.makeSocket)(config);
9
- const { generateMessageTag, query } = sock;
9
+ const { generateMessageTag, query, } = sock;
10
10
  const executeUSyncQuery = async (usyncQuery) => {
11
11
  if (usyncQuery.protocols.length === 0) {
12
12
  throw new boom_1.Boom('USyncQuery must have at least one protocol');
@@ -14,13 +14,15 @@ const makeUSyncSocket = (config) => {
14
14
  // todo: validate users, throw WARNING on no valid users
15
15
  // variable below has only validated users
16
16
  const validUsers = usyncQuery.users;
17
- const userNodes = validUsers.map(user => {
17
+ const userNodes = validUsers.map((user) => {
18
18
  return {
19
19
  tag: 'user',
20
20
  attrs: {
21
- jid: !user.phone ? user.id : undefined
21
+ jid: !user.phone ? user.id : undefined,
22
22
  },
23
- content: usyncQuery.protocols.map(a => a.getUserElement(user)).filter(a => a !== null)
23
+ content: usyncQuery.protocols
24
+ .map((a) => a.getUserElement(user))
25
+ .filter(a => a !== null)
24
26
  };
25
27
  });
26
28
  const listNode = {
@@ -31,14 +33,14 @@ const makeUSyncSocket = (config) => {
31
33
  const queryNode = {
32
34
  tag: 'query',
33
35
  attrs: {},
34
- content: usyncQuery.protocols.map(a => a.getQueryElement())
36
+ content: usyncQuery.protocols.map((a) => a.getQueryElement())
35
37
  };
36
38
  const iq = {
37
39
  tag: 'iq',
38
40
  attrs: {
39
41
  to: WABinary_1.S_WHATSAPP_NET,
40
42
  type: 'get',
41
- xmlns: 'usync'
43
+ xmlns: 'usync',
42
44
  },
43
45
  content: [
44
46
  {
@@ -48,18 +50,21 @@ const makeUSyncSocket = (config) => {
48
50
  mode: usyncQuery.mode,
49
51
  sid: generateMessageTag(),
50
52
  last: 'true',
51
- index: '0'
53
+ index: '0',
52
54
  },
53
- content: [queryNode, listNode]
55
+ content: [
56
+ queryNode,
57
+ listNode
58
+ ]
54
59
  }
55
- ]
60
+ ],
56
61
  };
57
62
  const result = await query(iq);
58
63
  return usyncQuery.parseUSyncQueryResult(result);
59
64
  };
60
65
  return {
61
66
  ...sock,
62
- executeUSyncQuery
67
+ executeUSyncQuery,
63
68
  };
64
69
  };
65
70
  exports.makeUSyncSocket = makeUSyncSocket;
@@ -1,18 +1,16 @@
1
1
  import type { proto } from '../../WAProto';
2
2
  import type { AccountSettings } from './Auth';
3
- import type { ContactAction } from './Contact';
4
3
  import type { BufferedEventData } from './Events';
5
- import type { LabelActionBody } from './Label';
6
4
  import type { ChatLabelAssociationActionBody } from './LabelAssociation';
7
5
  import type { MessageLabelAssociationActionBody } from './LabelAssociation';
8
6
  import type { MinimalMessage, WAMessageKey } from './Message';
9
7
  /** privacy settings in WhatsApp Web */
10
8
  export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
9
+ export type WAPrivacyCallValue = 'all' | 'known';
10
+ export type WAPrivacyMessagesValue = 'all' | 'contacts';
11
11
  export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
12
12
  export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist';
13
13
  export type WAReadReceiptsValue = 'all' | 'none';
14
- export type WAPrivacyCallValue = 'all' | 'known';
15
- export type WAPrivacyMessagesValue = 'all' | 'contacts';
16
14
  /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
17
15
  export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
18
16
  export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
@@ -89,10 +87,6 @@ export type ChatModification = {
89
87
  } | {
90
88
  delete: true;
91
89
  lastMessages: LastMessageList;
92
- } | {
93
- contact: ContactAction | null;
94
- } | {
95
- addLabel: LabelActionBody;
96
90
  } | {
97
91
  addChatLabel: ChatLabelAssociationActionBody;
98
92
  } | {
@@ -1,6 +1,10 @@
1
1
  export interface Contact {
2
+ /** ID either in lid or jid format **/
2
3
  id: string;
4
+ /** ID in Lid (anonymous) format (@lid) **/
3
5
  lid?: string;
6
+ /** ID in Phone Number format (@s.whatsapp.net) **/
7
+ jid?: string;
4
8
  /** name of the contact, you have saved on your WA */
5
9
  name?: string;
6
10
  /** name of the contact, the contact has set on their own on WA */
@@ -17,8 +21,3 @@ export interface Contact {
17
21
  imgUrl?: string | null;
18
22
  status?: string;
19
23
  }
20
- export type ContactAction = {
21
- fistName: string;
22
- fullName: string;
23
- saveOnPrimaryAddressbook: boolean;
24
- };
@@ -3,6 +3,7 @@ export type GroupParticipant = (Contact & {
3
3
  isAdmin?: boolean;
4
4
  isSuperAdmin?: boolean;
5
5
  admin?: 'admin' | 'superadmin' | null;
6
+ jid?: string;
6
7
  lid?: string;
7
8
  });
8
9
  export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify';
@@ -13,17 +14,17 @@ export interface GroupMetadata {
13
14
  /** group uses 'lid' or 'pn' to send messages */
14
15
  addressingMode: 'pn' | 'lid';
15
16
  owner: string | undefined;
16
- onwerPn?: string | undefined;
17
+ ownerLid?: string | undefined;
17
18
  subject: string;
18
19
  /** group subject owner */
19
20
  subjectOwner?: string;
20
- subjectOwnerPn?: string;
21
+ subjectOwnerLid?: string;
21
22
  /** group subject modification date */
22
23
  subjectTime?: number;
23
24
  creation?: number;
24
25
  desc?: string;
25
26
  descOwner?: string;
26
- descOwnerPn?: string;
27
+ descOwnerLid?: string;
27
28
  descId?: string;
28
29
  descTime?: number;
29
30
  /** if this group is part of a community, it returns the jid of the community to which it belongs */
@@ -10,17 +10,6 @@ export interface Label {
10
10
  /** WhatsApp has 5 predefined labels (New customer, New order & etc) */
11
11
  predefinedId?: string;
12
12
  }
13
- export interface LabelActionBody {
14
- id: string;
15
- /** Label name */
16
- name?: string;
17
- /** Label color ID */
18
- color?: number;
19
- /** Is label has been deleted */
20
- deleted?: boolean;
21
- /** WhatsApp has 5 predefined labels (New customer, New order & etc) */
22
- predefinedId?: number;
23
- }
24
13
  /** WhatsApp has 20 predefined colors */
25
14
  export declare enum LabelColor {
26
15
  Color1 = 0,
@@ -13,7 +13,9 @@ export type WAMessageContent = proto.IMessage;
13
13
  export type WAContactMessage = proto.Message.IContactMessage;
14
14
  export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
15
15
  export type WAMessageKey = proto.IMessageKey & {
16
- lid?: string;
16
+ senderPn?: string;
17
+ senderLid?: string;
18
+ participantLid?: string;
17
19
  server_id?: string;
18
20
  };
19
21
  export type WATextMessage = proto.Message.IExtendedTextMessage;
@@ -216,6 +218,14 @@ export type OrderInfo = {
216
218
  export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
217
219
  productImage: WAMediaUpload;
218
220
  };
221
+ export type AlbumMedia = {
222
+ image: WAMediaUpload;
223
+ caption?: string;
224
+ } | {
225
+ video: WAMediaUpload;
226
+ caption?: string;
227
+ gifPlayback?: boolean;
228
+ };
219
229
  export type AnyRegularMessageContent = (({
220
230
  text: string;
221
231
  linkPreview?: WAUrlInfo | null;
@@ -270,7 +280,10 @@ export type AnyRegularMessageContent = (({
270
280
  businessOwnerJid?: string;
271
281
  body?: string;
272
282
  footer?: string;
273
- } & Mentionable & Contextable & Interactiveable & Shopable & Cardsable & WithDimensions) | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
283
+ } & Mentionable & Contextable & Interactiveable & Shopable & Cardsable & WithDimensions) | SharePhoneNumber | RequestPhoneNumber | ({
284
+ album: AlbumMedia[];
285
+ caption?: string;
286
+ } & Mentionable & Contextable & Editable)) & ViewOnce;
274
287
  export type AnyMessageContent = AnyRegularMessageContent | {
275
288
  forward: WAMessage;
276
289
  force?: boolean;
@@ -83,8 +83,6 @@ export type SocketConfig = {
83
83
  linkPreviewImageThumbnailWidth: number;
84
84
  /** Should Baileys ask the phone for full history, will be received async */
85
85
  syncFullHistory: boolean;
86
- /** Ignore Message when offline, default is false */
87
- ignoreMsgLoading: boolean;
88
86
  /** Should baileys fire init queries automatically, default true */
89
87
  fireInitQueries: boolean;
90
88
  /**