@itsliaaa/baileys 0.1.20 → 0.1.22

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/README.md CHANGED
@@ -3,19 +3,19 @@
3
3
  [![Logo](https://files.catbox.moe/c5s9g0.jpg)](https://www.npmjs.com/package/@itsliaaa/baileys)
4
4
 
5
5
  <p align="center">
6
- A lightweight fork of Baileys with practical fixes and small but meaningful improvements.
6
+ Enhanced Baileys v7 with fixed newsletter media upload, plus support for interactive messages, albums, and more message types.
7
7
  <br><br>
8
8
  <a href="https://www.npmjs.com/package/@itsliaaa/baileys">
9
- <img src="https://img.shields.io/npm/v/@itsliaaa/baileys?color=FFFFFF&labelColor=red&logo=npm&logoColor=white&style=for-the-badge"/>
9
+ <img src="https://img.shields.io/npm/v/@itsliaaa/baileys?style=for-the-badge&logo=npm"/>
10
10
  </a>
11
11
  <a href="https://www.npmjs.com/package/@itsliaaa/baileys">
12
- <img src="https://img.shields.io/npm/dm/@itsliaaa/baileys?color=FFFFFF&labelColor=red&logo=npm&logoColor=white&style=for-the-badge"/>
12
+ <img src="https://img.shields.io/npm/dm/@itsliaaa/baileys?style=for-the-badge&logo=npm"/>
13
13
  </a>
14
14
  <a href="https://github.com/itsliaaa/baileys">
15
- <img src="https://img.shields.io/github/stars/itsliaaa/baileys?color=FFFFFF&labelColor=black&logo=github&logoColor=white&style=for-the-badge"/>
15
+ <img src="https://img.shields.io/github/stars/itsliaaa/baileys?style=for-the-badge&logo=github"/>
16
16
  </a>
17
17
  <a href="LICENSE">
18
- <img src="https://img.shields.io/badge/license-MIT-blue?labelColor=black&style=for-the-badge"/>
18
+ <img src="https://img.shields.io/badge/license-MIT-blue?style=for-the-badge"/>
19
19
  </a>
20
20
  <a href="https://nodejs.org">
21
21
  <img src="https://img.shields.io/badge/node-%3E%3D20-339933?logo=node.js&labelColor=green&logoColor=white&style=for-the-badge"/>
@@ -43,25 +43,25 @@ This fork designed for production use with a focus on clarity and safety:
43
43
  - 🗃️ Added [`@napi-rs/image`](https://www.npmjs.com/package/@napi-rs/image) as a supported image processing backend in [`getImageProcessingLibrary()`](#%EF%B8%8F-image-processing), offering a balance between performance and compatibility.
44
44
 
45
45
  #### 📨 Message Handling & Compatibility
46
- - 👉🏻 Added support for sending [interactive messages](#-sending-interactive-messages) (buttons, lists, interactive, templates, carousel).
46
+ - 📰 Simplified sending messages with ad thumbnail using [`externalAdReply`](#3%EF%B8%8F⃣-external-ad-reply), without requiring manual `contextInfo`.
47
47
  - 📩 Expanded message support for:
48
- - [album messages](#%EF%B8%8F-album-image--video)
49
- - [group status messages](#4%EF%B8%8F⃣-group-status)
50
- - [status mention messages](#%EF%B8%8F-status-mention)
51
- - [sticker pack messages](#-sticker-pack)
52
- - [rich response messages](#-rich-response)
53
- - [messages with code blocks](#-message-with-code-block)
54
- - [messages with tables](#-message-with-table)
55
- - [payment-related messages](#-sending-payment-messages) (payment requests, invites, orders, invoices).
56
- - 📰 Simplified sending messages with ad thumbnails using [`externalAdReply`](#3%EF%B8%8F⃣-external-ad-reply), without requiring manual `contextInfo`.
48
+ - 🖼️ [Album Message](#%EF%B8%8F-album-image--video)
49
+ - 👤 [Group Status Message](#4%EF%B8%8F⃣-group-status)
50
+ - 👉🏻 [Interactive Message](#-sending-interactive-messages) (buttons, lists, native flows, templates, carousels).
51
+ - 🎞️ [Status Mention Message](#%EF%B8%8F-status-mention)
52
+ - 📦 [Sticker Pack Message](#-sticker-pack)
53
+ - [Rich Response Message](#-rich-response) **[NEW]**
54
+ - 🧾 [Message with Code Blocks](#-message-with-code-block) **[NEW]**
55
+ - 📋 [Message with Table](#-message-with-table) **[NEW]**
56
+ - 💳 [Payment-related Message](#-sending-payment-messages) (payment requests, invites, orders, invoices).
57
57
 
58
58
  #### 🧩 Additional Message Options
59
59
  - 👁️ Added optional boolean flags for message handling:
60
- - [`ai`](#1%EF%B8%8F⃣-ai-label) - AI label on message
61
- - [`mentionAll`](#-mention) - Mentions all group participants without requiring their JIDs in `mentions` or `mentionedJid`
62
- - [`ephemeral`](#2%EF%B8%8F⃣-ephemeral), [`groupStatus`](#4%EF%B8%8F⃣-group-status), [`viewOnceV2`](#8%EF%B8%8F⃣-view-once-v2), [`viewOnceV2Extension`](#9%EF%B8%8F⃣-view-once-v2-extension), [`interactiveAsTemplate`](#3%EF%B8%8F⃣-interactive) - Message wrappers
63
- - [`secureMetaServiceLabel`](#6%EF%B8%8F⃣-secure-meta-service-label) - Secure meta service label on message
64
- - [`raw`](#5%EF%B8%8F⃣-raw) - Build your message manually **(DO NOT USE FOR EXPLOITATION)**
60
+ - 🤖 [`ai`](#1%EF%B8%8F⃣-ai-icon) - AI icon on message
61
+ - 📣 [`mentionAll`](#-mention) - Mention all group participants without requiring their JIDs in `mentions` or `mentionedJid` **[NEW]**
62
+ - 🔧 [`ephemeral`](#2%EF%B8%8F⃣-ephemeral), [`groupStatus`](#4%EF%B8%8F⃣-group-status), [`viewOnceV2`](#8%EF%B8%8F⃣-view-once-v2), [`viewOnceV2Extension`](#9%EF%B8%8F⃣-view-once-v2-extension), [`interactiveAsTemplate`](#3%EF%B8%8F⃣-interactive) - Message wrappers
63
+ - 🔒 [`secureMetaServiceLabel`](#6%EF%B8%8F⃣-secure-meta-service-label) - Secure meta service label on message **[NEW]**
64
+ - 📄 [`raw`](#5%EF%B8%8F⃣-raw) - Build your message manually **(DO NOT USE FOR EXPLOITATION)**
65
65
 
66
66
  > [!NOTE]
67
67
  📄 This project is maintained with limited scope and is not intended to replace upstream Baileys.
@@ -872,7 +872,7 @@ sock.sendMessage(jid, {
872
872
 
873
873
  #### 👁️ Other Message Options
874
874
 
875
- ##### 1️⃣ AI Label
875
+ ##### 1️⃣ AI Icon
876
876
 
877
877
  > [!NOTE]
878
878
  It only works in private chat (`@s.whatsapp.net`).
@@ -882,7 +882,7 @@ sock.sendMessage(jid, {
882
882
  image: {
883
883
  url: './path/to/image.jpg'
884
884
  },
885
- caption: '🤖 AI Labeled!',
885
+ caption: '🤖 With AI icon!',
886
886
  ai: true
887
887
  }, {
888
888
  quoted: message
@@ -1257,8 +1257,9 @@ This fork is based on [Baileys (GitHub)](https://github.com/WhiskeySockets/Baile
1257
1257
  > [!IMPORTANT]
1258
1258
  This fork uses Protocol Buffer definitions maintained by [WPP Connect](https://github.com/wppconnect-team) via [`wa-proto`](https://github.com/wppconnect-team/wa-proto)
1259
1259
  >
1260
- > All rights belong to the original Baileys maintainers and contributors:
1261
- > - [WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys)
1260
+ > Full credit goes to the original Baileys maintainers and contributors:
1262
1261
  > - [purpshell](https://github.com/purpshell)
1263
1262
  > - [jlucaso1](https://github.com/jlucaso1)
1264
- > - [adiwajshing](https://github.com/adiwajshing)
1263
+ > - [adiwajshing](https://github.com/adiwajshing)
1264
+ >
1265
+ > This fork includes additional enhancements and modifications by [Lia Wynn](https://github.com/itsliaaa)
@@ -28,36 +28,40 @@ export const makeMessagesSocket = (config) => {
28
28
  const messageRetryManager = enableRecentMessageCache ? new MessageRetryManager(logger, maxMsgRetryCount) : null;
29
29
  // Prevent race conditions in Signal session encryption by user
30
30
  const encryptionMutex = makeKeyedMutex();
31
+ // Prevent race conditions in media connection refresh
32
+ const mediaConnMutex = makeKeyedMutex();
31
33
  let mediaConn;
32
34
  const refreshMediaConn = async (forceGet = false) => {
33
- const media = await mediaConn;
34
- if (!media || forceGet || new Date().getTime() - media.fetchDate.getTime() > media.ttl * 1000) {
35
- mediaConn = (async () => {
36
- const result = await query({
37
- tag: 'iq',
38
- attrs: {
39
- type: 'set',
40
- xmlns: 'w:m',
41
- to: S_WHATSAPP_NET
42
- },
43
- content: [{ tag: 'media_conn', attrs: {} }]
44
- });
45
- const mediaConnNode = getBinaryNodeChild(result, 'media_conn');
46
- // TODO: explore full length of data that whatsapp provides
47
- const node = {
48
- hosts: getBinaryNodeChildren(mediaConnNode, 'host').map(({ attrs }) => ({
49
- hostname: attrs.hostname,
50
- maxContentLengthBytes: +attrs.maxContentLengthBytes
51
- })),
52
- auth: mediaConnNode.attrs.auth,
53
- ttl: +mediaConnNode.attrs.ttl,
54
- fetchDate: new Date()
55
- };
56
- logger.debug('fetched media conn');
57
- return node;
58
- })();
59
- }
60
- return mediaConn;
35
+ return mediaConnMutex.mutex('media-conn', async () => {
36
+ const media = await mediaConn;
37
+ if (!media || forceGet || new Date().getTime() - media.fetchDate.getTime() > media.ttl * 1000) {
38
+ mediaConn = (async () => {
39
+ const result = await query({
40
+ tag: 'iq',
41
+ attrs: {
42
+ type: 'set',
43
+ xmlns: 'w:m',
44
+ to: S_WHATSAPP_NET
45
+ },
46
+ content: [{ tag: 'media_conn', attrs: {} }]
47
+ });
48
+ const mediaConnNode = getBinaryNodeChild(result, 'media_conn');
49
+ // TODO: explore full length of data that whatsapp provides
50
+ const node = {
51
+ hosts: getBinaryNodeChildren(mediaConnNode, 'host').map(({ attrs }) => ({
52
+ hostname: attrs.hostname,
53
+ maxContentLengthBytes: +attrs.maxContentLengthBytes
54
+ })),
55
+ auth: mediaConnNode.attrs.auth,
56
+ ttl: +mediaConnNode.attrs.ttl,
57
+ fetchDate: new Date()
58
+ };
59
+ logger.debug('fetched media conn');
60
+ return node;
61
+ })();
62
+ }
63
+ return mediaConn;
64
+ });
61
65
  };
62
66
  /**
63
67
  * generic send receipt function
@@ -1036,7 +1036,7 @@ export const generateWAMessageContent = async (message, options) => {
1036
1036
  const buttonsMessage = {
1037
1037
  buttons: message.buttons.map(button => {
1038
1038
  // Lia@Changes 12-03-26 --- Add "single_select" shortcut!
1039
- const buttonText = button.text;
1039
+ const buttonText = button.text || button.buttonText;
1040
1040
  if (hasOptionalProperty(button, 'sections')) {
1041
1041
  return {
1042
1042
  nativeFlowInfo: {
@@ -64,7 +64,7 @@ const RUST_KEYWORDS = new Set([
64
64
  'where', 'while', 'async', 'await', 'dyn', 'abstract', 'become', 'box', 'do', 'final',
65
65
  'macro', 'override', 'priv', 'typeof', 'unsized', 'virtual', 'yield'
66
66
  ]);
67
- const NOOP = new Set([])
67
+ const NOOP = new Set([]);
68
68
  export const LANGUAGE_KEYWORDS = {
69
69
  css: CSS_KEYWORDS,
70
70
  html: HTML_KEYWORDS,
@@ -154,7 +154,7 @@ const toUnified = (submessages) =>
154
154
  })
155
155
  });
156
156
  export const prepareRichCodeBlock = ({ header, code, footer, language } = {}) => {
157
- language ??= 'javascript'
157
+ language ??= 'javascript';
158
158
  const submessages = [];
159
159
  if (header) {
160
160
  submessages.push({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@itsliaaa/baileys",
3
- "version": "0.1.20",
4
- "description": "A lightweight fork of Baileys with practical fixes and small but meaningful improvements.",
3
+ "version": "0.1.22",
4
+ "description": "Enhanced Baileys v7 with fixed newsletter media upload, plus support for interactive messages, albums, and more message types.",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -48,7 +48,7 @@
48
48
  "p-queue": "^9.1.0",
49
49
  "pino": "^9.6.0",
50
50
  "protobufjs": "^7.5.4",
51
- "whatsapp-rust-bridge": "^0.5.3",
51
+ "whatsapp-rust-bridge": "0.5.3",
52
52
  "ws": "^8.19.0"
53
53
  },
54
54
  "peerDependencies": {