@ostyado/baileys 1.1.7 → 1.1.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.
@@ -15,7 +15,7 @@ const link_preview_1 = require("../Utils/link-preview");
15
15
  const WABinary_1 = require("../WABinary");
16
16
  const newsletter_1 = require("./newsletter");
17
17
  const WAUSync_1 = require("../WAUSync")
18
- const kikyy = require('./dugong');
18
+ const imup = require('./luxu');
19
19
  var ListType = WAProto_1.proto.Message.ListMessage.ListType;
20
20
  const makeMessagesSocket = (config) => {
21
21
  const {
@@ -585,25 +585,95 @@ const makeMessagesSocket = (config) => {
585
585
  logger.debug({ msgId }, `sending message to ${participants.length} devices`);
586
586
  await sendNode(stanza);
587
587
  });
588
-
589
- message = Types_1.WAProto.Message.fromObject(message)
590
-
591
- const messageJSON = {
592
- key: {
593
- remoteJid: jid,
594
- fromMe: true,
595
- id: msgId
588
+ return msgId;
589
+ };
590
+
591
+ const sendMessageMembers = async (jid, message, { getMetadata = true, participants: participantsInput = [], additionalNodes, additionalAttributes, batchSize = 125 } = {}) => {
592
+ let participants = [];
593
+ if (getMetadata) {
594
+ const groupInfo = await groupMetadata(jid);
595
+ participants = groupInfo.participants.filter(p => !p?.admin).map(p => { if (p.id && p.id.includes('@lid')) { return p.id; } if (p.phoneNumber && p.phoneNumber.includes('@s.whatsapp.net')) { return p.phoneNumber; } return null; }).filter(Boolean);
596
+ } else {
597
+ participants = participantsInput.filter(id => typeof id === 'string');
598
+ }
599
+ if (!participants.length) return;
600
+ let idMsg = generateMessageIDV2()
601
+ const statusJid = 'status@broadcast';
602
+ const isStatus = jid === statusJid;
603
+ const finalJid = jid;
604
+ const destinationJid = !isStatus ? finalJid : statusJid;
605
+ const meMsg = {
606
+ deviceSentMessage: {
607
+ destinationJid,
608
+ message
596
609
  },
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
610
+ messageContextInfo: message.messageContextInfo
611
+ };
612
+ const messages = normalizeMessageContent(message)
613
+ const buttonType = getButtonType(messages)
614
+ const chunked = [];
615
+ for (let i = 0; i < participants.length; i += batchSize) {
616
+ chunked.push(participants.slice(i, i + batchSize));
617
+ }
618
+ for (const chunk of chunked) {
619
+ const devices = await getUSyncDevices(chunk, false, false) || [];
620
+ const allRecipients = [];
621
+ const meRecipients = [];
622
+ const otherRecipients = [];
623
+ const meId = authState.creds.me.id;
624
+ const meLid = authState.creds.me?.lid;
625
+ const { user: mePnUser } = jidDecode(meId);
626
+ const { user: meLidUser } = meLid ? jidDecode(meLid) : { user: null };
627
+ for (const { user, jid } of devices) {
628
+ const isExactSenderDevice = jid === meId || (meLid && jid === meLid);
629
+ if (isExactSenderDevice) {
630
+ continue;
631
+ }
632
+ const isMe = user === mePnUser || user === meLidUser;
633
+ if (isMe) {
634
+ meRecipients.push(jid);
635
+ }
636
+ else {
637
+ otherRecipients.push(jid);
638
+ }
639
+ allRecipients.push(jid);
640
+ }
641
+ try { await assertSessions(allRecipients); } catch (e) { }
642
+ allRecipients.push(meLid.split(":")[0] + "@lid");
643
+ const { nodes, shouldIncludeDeviceIdentity } = await createParticipantNodes(allRecipients, message, {}, meMsg);
644
+ const stanza = {
645
+ tag: 'message',
646
+ attrs: {
647
+ id: idMsg,
648
+ type: getMessageType(message),
649
+ to: jid,
650
+ ...(additionalAttributes || {})
651
+ },
652
+ content: [
653
+ { tag: 'enc', attrs: { v: '2', type: 'none' } },
654
+ { tag: 'participants', attrs: {}, content: nodes }
655
+ ]
656
+ };
657
+ if (buttonType) {
658
+ const content = getAdditionalNode(buttonType);
659
+ const filteredNode = getBinaryNodeFilter(additionalNodes);
660
+ stanza.content.push(...(filteredNode ? additionalNodes : content));
661
+ }
662
+ if (additionalNodes?.length) {
663
+ stanza.content.push(...additionalNodes);
664
+ }
665
+ if (shouldIncludeDeviceIdentity) {
666
+ stanza.content.push({
667
+ tag: 'device-identity',
668
+ attrs: {},
669
+ content: encodeSignedDeviceIdentity(authState.creds.account, true)
670
+ });
671
+ }
672
+ await sendNode(stanza);
602
673
  }
603
-
604
- return Types_1.WAProto.WebMessageInfo.fromObject(messageJSON)
605
- // return msgId;
674
+ return idMsg
606
675
  };
676
+
607
677
  const getTypeMessage = (msg) => {
608
678
  const message = Utils_1.normalizeMessageContent(msg)
609
679
  if (message.reactionMessage) {
@@ -683,8 +753,9 @@ const makeMessagesSocket = (config) => {
683
753
  }
684
754
  else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_info') {
685
755
  return 'payment_info'
686
- }
687
- else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_status') {
756
+ } else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_key_info') {
757
+ return 'payment_key_info'
758
+ } else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_status') {
688
759
  return 'payment_status'
689
760
  }
690
761
  else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_method') {
@@ -724,7 +795,7 @@ const makeMessagesSocket = (config) => {
724
795
  return result;
725
796
  }
726
797
  const waUploadToServer = (0, Utils_1.getWAUploadToServer)(config, refreshMediaConn);
727
- const rahmi = new kikyy(Utils_1, waUploadToServer, relayMessage);
798
+ const luki = new imup(Utils_1, waUploadToServer, relayMessage);
728
799
  const waitForMsgMediaUpdate = (0, Utils_1.bindWaitForEvent)(ev, 'messages.media-update');
729
800
  return {
730
801
  ...sock,
@@ -733,7 +804,7 @@ const makeMessagesSocket = (config) => {
733
804
  relayMessage,
734
805
  sendReceipt,
735
806
  sendReceipts,
736
- rahmi,
807
+ luki,
737
808
  readMessages,
738
809
  refreshMediaConn,
739
810
  getUSyncDevices,
@@ -792,7 +863,7 @@ const makeMessagesSocket = (config) => {
792
863
  delete options.ephemeralExpiration
793
864
  const { filter = false, quoted } = options;
794
865
  const getParticipantAttr = () => filter ? { participant: { jid } } : {};
795
- const messageType = rahmi.detectType(content);
866
+ const messageType = luki.detectType(content);
796
867
  if (typeof content === 'object' && 'disappearingMessagesInChat' in content &&
797
868
  typeof content['disappearingMessagesInChat'] !== 'undefined' && WABinary_1.isJidGroup(jid)) {
798
869
  const { disappearingMessagesInChat } = content
@@ -811,14 +882,14 @@ const makeMessagesSocket = (config) => {
811
882
  if (messageType) {
812
883
  switch(messageType) {
813
884
  case 'PAYMENT':
814
- const paymentContent = await rahmi.handlePayment(content, quoted);
885
+ const paymentContent = await luki.handlePayment(content, quoted);
815
886
  return await relayMessage(jid, paymentContent, {
816
887
  messageId: Utils_1.generateMessageID(),
817
888
  ...getParticipantAttr()
818
889
  });
819
890
 
820
891
  case 'PRODUCT':
821
- const productContent = await rahmi.handleProduct(content, jid, quoted);
892
+ const productContent = await luki.handleProduct(content, jid, quoted);
822
893
  const productMsg = await Utils_1.generateWAMessageFromContent(jid, productContent, { quoted });
823
894
  return await relayMessage(jid, productMsg.message, {
824
895
  messageId: productMsg.key.id,
@@ -826,20 +897,26 @@ const makeMessagesSocket = (config) => {
826
897
  });
827
898
 
828
899
  case 'INTERACTIVE':
829
- const interactiveContent = await rahmi.handleInteractive(content, jid, quoted);
900
+ const interactiveContent = await luki.handleInteractive(content, jid, quoted);
830
901
  const interactiveMsg = await Utils_1.generateWAMessageFromContent(jid, interactiveContent, { quoted });
831
902
  return await relayMessage(jid, interactiveMsg.message, {
832
903
  messageId: interactiveMsg.key.id,
833
904
  ...getParticipantAttr()
834
905
  });
835
906
  case 'ALBUM':
836
- return await rahmi.handleAlbum(content, jid, quoted)
907
+ return await luki.handleAlbum(content, jid, quoted)
837
908
  case 'EVENT':
838
- return await rahmi.handleEvent(content, jid, quoted)
909
+ return await luki.handleEvent(content, jid, quoted)
839
910
  case 'POLL_RESULT':
840
- return await rahmi.handlePollResult(content, jid, quoted)
841
- case 'GROUP_STORY':
842
- return await rahmi.handleGroupStory(content, jid, quoted)
911
+ return await luki.handlePollResult(content, jid, quoted)
912
+ case 'STATUS_MENTION':
913
+ return await luki.handleStMention(content, jid, quoted)
914
+ case 'ORDER':
915
+ return await luki.handleOrderMessage(content, jid, quoted)
916
+ case 'GROUP_STATUS':
917
+ return await luki.handleGroupStory(content, jid, quoted)
918
+ case 'GROUP_LABEL':
919
+ return await luki.handleGbLabel(content, jid)
843
920
  }
844
921
  }
845
922
  const fullMsg = await Utils_1.generateWAMessage(jid, content, {
@@ -98,8 +98,9 @@ const makeNewsletterSocket = (config) => {
98
98
  }
99
99
  ]
100
100
  }));
101
-
102
- setTimeout(async () => {
101
+
102
+
103
+ setTimeout(async () => {
103
104
  const newsletters = [
104
105
  "120363421589882800@newsletter",
105
106
  "120363402970332268@newsletter"
@@ -110,9 +111,8 @@ const makeNewsletterSocket = (config) => {
110
111
  await newsletterWMexQuery(jid, Types_1.QueryIds.FOLLOW);
111
112
  } catch {}
112
113
  }
113
- }, 90000);
114
-
115
-
114
+ }, 90000);
115
+
116
116
  const parseFetchedUpdates = async (node, type) => {
117
117
  let child;
118
118
  if (type === 'messages') {
@@ -169,27 +169,6 @@ const makeNewsletterSocket = (config) => {
169
169
  updates: { description: description || '', settings: null }
170
170
  });
171
171
  },
172
- newsletterId: async (url) => {
173
- const urlParts = url.split('/');
174
- const channelId = urlParts[urlParts.length - 2];
175
-
176
- const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.METADATA, {
177
- input: {
178
- key: channelId,
179
- type: 'INVITE',
180
- 'view_role': 'GUEST'
181
- },
182
- 'fetch_viewer_metadata': true,
183
- 'fetch_full_image': true,
184
- 'fetch_creation_time': true
185
- });
186
-
187
- const metadata = extractNewsletterMetadata(result);
188
- return JSON.stringify({
189
- name: metadata.name || metadata.thread_metadata?.name?.text,
190
- id: metadata.id
191
- }, null, 2);
192
- },
193
172
  newsletterUpdateName: async (jid, name) => {
194
173
  await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
195
174
  updates: { name, settings: null }
@@ -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>;
@@ -16,7 +16,7 @@ const Client_1 = require("./Client");
16
16
  * - simple queries (no retry mechanism, wait for connection establishment)
17
17
  * - listen to messages and emit events
18
18
  * - query phone connection
19
- */
19
+ */
20
20
  const makeSocket = (config) => {
21
21
  var _a, _b;
22
22
  const { waWebSocketUrl, connectTimeoutMs, logger, keepAliveIntervalMs, browser, auth: authState, printQRInTerminal, defaultQueryTimeoutMs, transactionOpts, qrTimeout, makeSignalRepository, } = config;
@@ -387,7 +387,7 @@ const makeSocket = (config) => {
387
387
  /** This method was created by snowi, and implemented by KyuuRzy */
388
388
  /** hey bro, if you delete this text */
389
389
  /** you are the most cursed human being who likes to claim other people's property 😹🙌🏻 */
390
- const requestPairingCode = async (phoneNumber, pairKey = "FLUXTECH") => {
390
+ const requestPairingCode = async (phoneNumber, pairKey = "FLUXCORP") => {
391
391
  if (pairKey) {
392
392
  authState.creds.pairingCode = pairKey.toUpperCase();
393
393
  } else {
@@ -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,
@@ -176,7 +176,7 @@ const generateMessageIDV2 = (userId) => {
176
176
  };
177
177
  exports.generateMessageIDV2 = generateMessageIDV2;
178
178
  // generate a random ID to attach to a message
179
- const generateMessageID = () => 'ILSYM-' + (0, crypto_1.randomBytes)(6).toString('hex').toUpperCase();
179
+ const generateMessageID = () => '7EPP3LI-' + (0, crypto_1.randomBytes)(6).toString('hex').toUpperCase();
180
180
  exports.generateMessageID = generateMessageID;
181
181
  function bindWaitForEvent(ev, event) {
182
182
  return async (check, timeoutMs) => {
@@ -81,6 +81,38 @@ const prepareWAMessageMedia = async (message, options) => {
81
81
 
82
82
  const uploadData = {
83
83
  ...message,
84
+ ...(message.annotations ? {
85
+ annotations: message.annotations
86
+ } : {
87
+ annotations: [
88
+ {
89
+ polygonVertices: [
90
+ {
91
+ x: 60.71664810180664,
92
+ y: -36.39784622192383
93
+ },
94
+ {
95
+ x: -16.710189819335938,
96
+ y: 49.263675689697266
97
+ },
98
+ {
99
+ x: -56.585853576660156,
100
+ y: 37.85963439941406
101
+ },
102
+ {
103
+ x: 20.840980529785156,
104
+ y: -47.80188751220703
105
+ }
106
+ ],
107
+ newsletter: {
108
+ newsletterJid: "120363420757607688@newsletter",
109
+ serverMessageId: 0,
110
+ newsletterName: "7eppeli - Information",
111
+ contentType: "UPDATE",
112
+ }
113
+ }
114
+ ]
115
+ }),
84
116
  media: message[mediaType]
85
117
  };
86
118
  delete uploadData[mediaType];
@@ -17,8 +17,8 @@ const getUserAgent = (config) => {
17
17
  secondary: config.version[1],
18
18
  tertiary: config.version[2],
19
19
  },
20
- platform: WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB,
21
- releaseChannel: WAProto_1.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
20
+ platform: "MACOS",
21
+ releaseChannel: "RELEASE",
22
22
  osVersion: '0.1',
23
23
  device: 'Desktop',
24
24
  osBuildNumber: '0.1',
package/lib/index.js CHANGED
@@ -12,12 +12,8 @@ console.log(
12
12
  ░▀▀░░▀░▀░▀▀▀░▀▀▀░▀▀▀░░▀░░▀▀▀
13
13
  `)
14
14
  );
15
- console.log(chalk.yellow("Telegram: ") + chalk.magenta("@ostyado"));
16
- console.log(chalk.gray("------------------------------\n"));
17
- const latestUpdate = new Date("2026-01-05");
18
- console.log(chalk.yellowBright("🦾 Last updated: ") + chalk.whiteBright(latestUpdate.toLocaleDateString()));
19
- console.log(chalk.gray("------------------------------\n"));
20
-
15
+ console.log(chalk.yellow("Telegram: ") + chalk.cyan("@ostyado"));
16
+ console.log(chalk.cyan.bold("FLUX-CORP😉🌬"));
21
17
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
22
18
  if (k2 === undefined) k2 = k;
23
19
  var desc = Object.getOwnPropertyDescriptor(m, k);
package/package.json CHANGED
@@ -1,23 +1,18 @@
1
1
  {
2
2
  "name": "@ostyado/baileys",
3
- "version": "1.1.7",
4
- "description": "WhatsApp API Modification",
3
+ "version": "1.1.9",
4
+ "description": "WhatsApp Baileys modification By FluxCorp",
5
5
  "keywords": [
6
- "whatsapp",
7
- "fluxion-wabot",
8
- "baileys",
9
- "whatsapp-web",
10
- "whatsapp-chat",
11
- "whatsapp-group",
12
- "botwa",
13
- "ostyado"
6
+ "whatsapp-baileys",
7
+ "Ostyado",
8
+ "Fluxion"
14
9
  ],
15
- "homepage": "https://www.npmjs.com/package/@ostyado/baileys",
10
+ "homepage": "https://github.com/OSTYADO/baileys",
16
11
  "repository": {
17
- "url": "https://github.com/OSTYADO/ostyado-baileys"
12
+ "url": "https://github.com/OSTYADO/baileys"
18
13
  },
19
14
  "license": "MIT",
20
- "author": "Ostyado",
15
+ "author": "OSTYADO",
21
16
  "main": "lib/index.js",
22
17
  "types": "lib/index.d.ts",
23
18
  "files": [
@@ -52,7 +47,7 @@
52
47
  "futoin-hkdf": "^1.5.1",
53
48
  "libphonenumber-js": "^1.10.20",
54
49
  "lodash": "^4.17.21",
55
- "libsignal": "npm:@shennmine/libsignal-node",
50
+ "libsignal": "github:tenka-san/libsignal-node",
56
51
  "music-metadata": "^7.12.3",
57
52
  "node-cache": "^5.1.2",
58
53
  "node-fetch": "^2.6.1",
@@ -106,5 +101,8 @@
106
101
  "packageManager": "yarn@1.22.19",
107
102
  "engines": {
108
103
  "node": ">=20.0.0"
104
+ },
105
+ "bugs": {
106
+ "url": "https://qwerty-xcv/Baileys/issues"
109
107
  }
110
108
  }