@codexverified/baileys 2.8.11 → 2.10.12
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 +153 -144
- package/lib/Socket/{messages-send (1).js → messages-send.js} +3 -2
- package/lib/Utils/messages.js +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,52 +1,66 @@
|
|
|
1
1
|
# @codexverified/baileys
|
|
2
2
|
|
|
3
|
-
> A
|
|
3
|
+
> A readable, carefully maintained Baileys distribution for building reliable WhatsApp integrations with codexverified/baileys.
|
|
4
4
|
|
|
5
|
-
`@codexverified/baileys` is a Node.js and TypeScript library for
|
|
5
|
+
`@codexverified/baileys` is a Node.js and TypeScript library for creating WhatsApp automations over the Baileys protocol. It provides a socket-oriented API for authentication, messaging, media, interactive content, rich responses, newsletters, groups, communities, business features, account utilities, and carefully documented extensions.
|
|
6
6
|
|
|
7
|
-
The
|
|
7
|
+
The package is maintained by **Codex** under the **CodexVerified** organization. It is intended for developers who want a practical Baileys foundation with familiar interfaces, public TypeScript declarations, readable source code, explicit behavior, and room for carefully tested improvements.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## At a glance
|
|
10
|
+
|
|
11
|
+
This release is version **2.10.12**. It uses ECMAScript modules, supports CommonJS usage where the installed Node.js version permits it, ships public TypeScript declarations, and targets Node.js 20 or newer.
|
|
10
12
|
|
|
11
13
|
| Property | Value |
|
|
12
14
|
| --- | --- |
|
|
13
15
|
| Package | `@codexverified/baileys` |
|
|
14
|
-
| Version | `2.
|
|
16
|
+
| Version | `2.10.12` |
|
|
15
17
|
| Runtime | Node.js 20 or newer |
|
|
16
|
-
| Module format | ESM with CommonJS compatibility where supported |
|
|
17
|
-
| Type declarations | Included |
|
|
18
|
-
| License | MIT |
|
|
18
|
+
| Module format | ESM, with CommonJS compatibility where supported |
|
|
19
|
+
| Type declarations | Included at `lib/index.d.ts` |
|
|
20
|
+
| License | MIT, as declared by the package metadata |
|
|
19
21
|
| Maintainer | Codex |
|
|
22
|
+
| Entry point | `lib/index.js` |
|
|
23
|
+
| Repository | `https://github.com/codexverified/baileys` |
|
|
20
24
|
|
|
21
25
|
## Installation
|
|
22
26
|
|
|
23
|
-
Install the
|
|
27
|
+
Install the package from npm when it is published under your organization:
|
|
24
28
|
|
|
25
29
|
```bash
|
|
26
30
|
npm install @codexverified/baileys
|
|
27
31
|
```
|
|
28
32
|
|
|
29
|
-
To install
|
|
33
|
+
To install a local package archive, place the `.tgz` file beside your application and run:
|
|
30
34
|
|
|
31
35
|
```bash
|
|
32
|
-
npm install ./codex-baileys-2.
|
|
36
|
+
npm install ./codex-baileys-2.10.12.tgz
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Both installation methods use the same import name:
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import { makeWASocket } from '@codexverified/baileys'
|
|
33
43
|
```
|
|
34
44
|
|
|
35
|
-
|
|
45
|
+
For local source auditing, install dependencies without executing package installation hooks:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install --ignore-scripts
|
|
49
|
+
```
|
|
36
50
|
|
|
37
|
-
## Quick
|
|
51
|
+
## Quick start
|
|
38
52
|
|
|
39
|
-
The following example creates a socket,
|
|
53
|
+
The following example creates a socket, stores multi-file authentication credentials, reconnects after an unexpected disconnect, and replies to incoming messages. Keep the session directory private and never commit it to a public repository.
|
|
40
54
|
|
|
41
55
|
```javascript
|
|
42
56
|
import {
|
|
57
|
+
DisconnectReason,
|
|
43
58
|
makeWASocket,
|
|
44
|
-
useMultiFileAuthState
|
|
45
|
-
DisconnectReason
|
|
59
|
+
useMultiFileAuthState
|
|
46
60
|
} from '@codexverified/baileys'
|
|
47
61
|
import P from 'pino'
|
|
48
62
|
|
|
49
|
-
|
|
63
|
+
async function start() {
|
|
50
64
|
const { state, saveCreds } = await useMultiFileAuthState('./session')
|
|
51
65
|
|
|
52
66
|
const sock = makeWASocket({
|
|
@@ -58,14 +72,12 @@ const start = async () => {
|
|
|
58
72
|
|
|
59
73
|
sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
|
|
60
74
|
if (connection === 'open') {
|
|
61
|
-
console.log('Connected
|
|
75
|
+
console.log('Connected with @codexverified/baileys')
|
|
62
76
|
}
|
|
63
77
|
|
|
64
78
|
if (connection === 'close') {
|
|
65
79
|
const statusCode = lastDisconnect?.error?.output?.statusCode
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (shouldReconnect) {
|
|
80
|
+
if (statusCode !== DisconnectReason.loggedOut) {
|
|
69
81
|
start().catch(console.error)
|
|
70
82
|
}
|
|
71
83
|
}
|
|
@@ -85,7 +97,7 @@ const start = async () => {
|
|
|
85
97
|
start().catch(console.error)
|
|
86
98
|
```
|
|
87
99
|
|
|
88
|
-
## CommonJS
|
|
100
|
+
## CommonJS usage
|
|
89
101
|
|
|
90
102
|
For supported Node.js versions, the package can also be loaded through CommonJS:
|
|
91
103
|
|
|
@@ -96,162 +108,159 @@ const {
|
|
|
96
108
|
} = require('@codexverified/baileys')
|
|
97
109
|
```
|
|
98
110
|
|
|
99
|
-
|
|
111
|
+
If your runtime or bundler does not support this interop path, use the ESM import form instead.
|
|
100
112
|
|
|
101
|
-
|
|
113
|
+
## Core capabilities
|
|
102
114
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
| Storage | In-memory stores, ordered dictionaries, cache-manager stores, and persistent authentication storage |
|
|
115
|
+
### Connections and authentication
|
|
116
|
+
|
|
117
|
+
The socket layer manages WebSocket connection events, reconnect handling, browser identity configuration, pairing-code flows, and connection state transitions. Authentication helpers include multi-file credentials for standard deployments, single-file state for compact setups, SQLite-backed persistence when the optional driver is installed, and cache-manager integrations for applications that need custom persistence.
|
|
118
|
+
|
|
119
|
+
### Messages and conversations
|
|
120
|
+
|
|
121
|
+
The message API supports text, mentions, replies, reactions, edits, deletions, forwards, polls, contacts, locations, events, group invitations, quoted messages, disappearing messages, view-once envelopes, and other protocol message types. Message composition is centralized so applications can use the ordinary `sendMessage` flow while opting into advanced structures when required.
|
|
122
|
+
|
|
123
|
+
### Media and albums
|
|
124
|
+
|
|
125
|
+
Images, video, audio, documents, stickers, thumbnails, and albums are supported. Media can be prepared from URLs, local files, or buffers according to the upload configuration. Video messages can opt into GIF playback, and the image-processing layer can use an available `sharp`, `@napi-rs/image`, or `jimp` implementation. Album child-message association uses the WhatsApp-compatible wire value.
|
|
115
126
|
|
|
116
|
-
|
|
127
|
+
### Interactive content
|
|
117
128
|
|
|
118
|
-
|
|
129
|
+
The package includes interactive buttons, lists, native flows, hydrated templates, carousel layouts, button grids, and other structured message formats. Interactive identifiers should be stable and unique within the application. Receiving code should handle the possibility that different WhatsApp clients deliver a selected value through different response envelopes.
|
|
130
|
+
|
|
131
|
+
### Rich content and previews
|
|
132
|
+
|
|
133
|
+
Rich-response utilities cover code blocks, tables, inline entities, LaTeX-oriented content, link previews, and structured response arrays. Rich previews can fetch a title, description, and image for a URL when the optional dependency and network access are available. Applications should retain a plain-text fallback for clients that do not render rich content.
|
|
134
|
+
|
|
135
|
+
### Rich menus
|
|
136
|
+
|
|
137
|
+
The experimental `richMenu` helper builds a structured rich-response envelope with an optional header image, row or carousel cards, stable button identifiers, toast metadata, disclaimers, and a footer action. The package also exposes lower-level preparation utilities for applications that need more control. Rich menus are client-dependent and should be tested against the WhatsApp versions used by the application.
|
|
138
|
+
|
|
139
|
+
### Groups and communities
|
|
140
|
+
|
|
141
|
+
Group operations include group creation, participant management, settings, metadata, invites, labels, and community relationships. Community helpers support linked groups and subgroup operations where the connected account and current protocol permit them.
|
|
142
|
+
|
|
143
|
+
### Newsletters and channel operations
|
|
144
|
+
|
|
145
|
+
Newsletter utilities cover channel metadata, following and unfollowing, posts, reactions, media, and polls. Following is consumer-controlled: the library does not silently follow a trusted channel, inject a fallback channel identifier, or add an automatic channel pill to generated media. Applications should request newsletter actions explicitly and validate identifiers before sending requests.
|
|
146
|
+
|
|
147
|
+
### Account, business, and privacy tools
|
|
148
|
+
|
|
149
|
+
The package includes profile and business helpers, product and catalog operations, privacy controls, username utilities, account-layer and interoperation helpers, status publishing, favorites management, and selected account-management operations. Availability depends on the connected account, WhatsApp rollout, and the permissions associated with that account.
|
|
150
|
+
|
|
151
|
+
### Storage and protocol utilities
|
|
152
|
+
|
|
153
|
+
The distribution includes in-memory and ordered-dictionary stores, cache-manager support, authentication persistence, LID and phone-number resolution, event utilities, message normalization, media retry handling, protocol helpers, and TypeScript declarations in `lib/index.d.ts`.
|
|
154
|
+
|
|
155
|
+
## Everyday message usage
|
|
156
|
+
|
|
157
|
+
Send a text message with the standard socket method:
|
|
119
158
|
|
|
120
159
|
```javascript
|
|
121
160
|
await sock.sendMessage(jid, {
|
|
122
|
-
text: '
|
|
161
|
+
text: 'A message from Codex'
|
|
123
162
|
})
|
|
124
163
|
```
|
|
125
164
|
|
|
126
|
-
|
|
165
|
+
Send media with a caption:
|
|
127
166
|
|
|
128
167
|
```javascript
|
|
129
168
|
await sock.sendMessage(jid, {
|
|
130
|
-
image: { url: './
|
|
131
|
-
caption: 'A
|
|
169
|
+
image: { url: './media/photo.jpg' },
|
|
170
|
+
caption: 'A photo message'
|
|
132
171
|
})
|
|
133
172
|
```
|
|
134
173
|
|
|
135
|
-
|
|
174
|
+
Send a video with GIF-style playback enabled:
|
|
136
175
|
|
|
137
176
|
```javascript
|
|
138
177
|
await sock.sendMessage(jid, {
|
|
139
|
-
video: { url: './animation.mp4' },
|
|
178
|
+
video: { url: './media/animation.mp4' },
|
|
140
179
|
gifPlayback: true,
|
|
141
180
|
caption: 'Animated media'
|
|
142
181
|
})
|
|
143
182
|
```
|
|
144
183
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
The recommended authentication helper is `useMultiFileAuthState`:
|
|
148
|
-
|
|
149
|
-
```javascript
|
|
150
|
-
import { useMultiFileAuthState } from '@codexverified/baileys'
|
|
151
|
-
|
|
152
|
-
const { state, saveCreds } = await useMultiFileAuthState('./session')
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
Authentication data contains sensitive account credentials. Keep the session directory private, exclude it from version control, and do not upload it to public repositories.
|
|
156
|
-
|
|
157
|
-
## Explicit Newsletter Following
|
|
158
|
-
|
|
159
|
-
The package does not automatically follow trusted channels, subscribe to fallback channels, or inject a fallback channel identifier into media messages. Newsletter following is consumer-controlled and must be requested explicitly:
|
|
184
|
+
Use the existing explicit view-once options when you want the media to use a view-once envelope:
|
|
160
185
|
|
|
161
186
|
```javascript
|
|
162
187
|
await sock.sendMessage(jid, {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
188
|
+
image: { url: './media/private-image.jpg' },
|
|
189
|
+
caption: 'Open once',
|
|
190
|
+
viewOnce: true
|
|
166
191
|
})
|
|
167
192
|
```
|
|
168
193
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
## Media Attribution
|
|
172
|
-
|
|
173
|
-
Generated image and video messages do not receive an automatic newsletter annotation or channel pill. If an application intentionally needs message context, it should provide that context explicitly through the supported message options rather than relying on hidden defaults.
|
|
174
|
-
|
|
175
|
-
## CODEX Branding
|
|
176
|
-
|
|
177
|
-
The package displays the following startup identity when a socket is created:
|
|
178
|
-
|
|
179
|
-
```text
|
|
180
|
-
CODEX TECHNOLOGY
|
|
181
|
-
A premium Baileys developed and built by codex
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
Generated message identifiers use the `CODEX` marker. This branding is informational and does not change the WhatsApp protocol or the message transport format.
|
|
185
|
-
|
|
186
|
-
## CODEX Rich Menu and Interactive Helpers
|
|
187
|
-
|
|
188
|
-
The following helpers are available on a socket created with `makeWASocket`. They use the existing message relay and do not change the normal `sendMessage` behavior.
|
|
189
|
-
|
|
190
|
-
### Spoiler media
|
|
191
|
-
|
|
192
|
-
Use `spoiler: true` when sending supported media. The WhatsApp client controls the visual spoiler and download presentation.
|
|
194
|
+
The compatible `mediaSpoilerMode` option provides an additional explicit path. Set it to `viewOnce` for supported image, video, document, or sticker media, or set it to `native` to apply the native spoiler context flag. The option is intentionally opt-in and does not change the default behavior of existing applications.
|
|
193
195
|
|
|
194
196
|
```javascript
|
|
195
197
|
await sock.sendMessage(jid, {
|
|
196
198
|
video: { url: './media/clip.mp4' },
|
|
197
|
-
caption: '
|
|
198
|
-
|
|
199
|
+
caption: 'View-once video',
|
|
200
|
+
mediaSpoilerMode: 'viewOnce'
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
await sock.sendMessage(jid, {
|
|
204
|
+
image: { url: './media/hidden-preview.jpg' },
|
|
205
|
+
mediaSpoilerMode: 'native'
|
|
199
206
|
})
|
|
200
207
|
```
|
|
201
208
|
|
|
202
|
-
|
|
209
|
+
The existing `viewOnce`, `viewOnceV2`, `viewOnceV2Extension`, and `spoiler` options remain supported. When an explicit view-once option is enabled, it takes precedence over `mediaSpoilerMode`.
|
|
203
210
|
|
|
204
|
-
|
|
211
|
+
## Rich menu example
|
|
212
|
+
|
|
213
|
+
The experimental rich-menu helper accepts a header, card rows or a carousel, stable button IDs, and a footer action:
|
|
205
214
|
|
|
206
215
|
```javascript
|
|
207
216
|
await sock.richMenu(jid, {
|
|
208
217
|
header: {
|
|
209
|
-
title: '
|
|
210
|
-
image: {
|
|
218
|
+
title: 'Codex Menu',
|
|
219
|
+
image: {
|
|
220
|
+
url: 'https://example.com/menu.jpg',
|
|
221
|
+
mime_type: 'image/jpeg'
|
|
222
|
+
}
|
|
211
223
|
},
|
|
212
224
|
body: {
|
|
213
225
|
row: true,
|
|
214
226
|
carousel: false,
|
|
215
|
-
cards: [
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
+
cards: [
|
|
228
|
+
{
|
|
229
|
+
title: 'Account',
|
|
230
|
+
buttons: [
|
|
231
|
+
{ id: 'profile', text: 'Profile' },
|
|
232
|
+
{ id: 'settings', text: 'Settings' }
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
title: 'Support',
|
|
237
|
+
buttons: ['help', 'contact']
|
|
238
|
+
}
|
|
239
|
+
]
|
|
227
240
|
},
|
|
228
241
|
footer: {
|
|
229
|
-
text: '
|
|
230
|
-
url: 'https://
|
|
231
|
-
image: { url: 'https://example.com/footer.jpg', mime_type: 'image/jpeg' }
|
|
242
|
+
text: 'Codex Technology',
|
|
243
|
+
url: 'https://example.com'
|
|
232
244
|
}
|
|
233
245
|
})
|
|
234
246
|
```
|
|
235
247
|
|
|
236
|
-
|
|
248
|
+
## Status, grids, tables, and flows
|
|
249
|
+
|
|
250
|
+
The socket also provides helpers for status posts, status mentions, button grids, interactive tables, and WhatsApp flows:
|
|
237
251
|
|
|
238
252
|
```javascript
|
|
239
|
-
await sock.sendStatus({ text: 'New status' }, {
|
|
253
|
+
await sock.sendStatus({ text: 'New Codex status' }, {
|
|
240
254
|
statusJidList: ['1234567890@s.whatsapp.net']
|
|
241
255
|
})
|
|
242
256
|
|
|
243
|
-
await sock.sendStatusMentions({ text: 'Mentioned status' }, [
|
|
244
|
-
'1234567890@s.whatsapp.net',
|
|
245
|
-
'9876543210@s.whatsapp.net'
|
|
246
|
-
])
|
|
247
|
-
|
|
248
257
|
await sock.sendRichButtonGrid(jid, {
|
|
249
258
|
text: 'Choose an option',
|
|
250
259
|
cards: [{
|
|
251
260
|
title: 'Actions',
|
|
252
261
|
buttons: [
|
|
253
|
-
{ id: '
|
|
254
|
-
{ id: '
|
|
262
|
+
{ id: 'first_action', text: 'First action' },
|
|
263
|
+
{ id: 'second_action', text: 'Second action' }
|
|
255
264
|
]
|
|
256
265
|
}]
|
|
257
266
|
})
|
|
@@ -274,53 +283,53 @@ await sock.sendWhatsAppFlow(jid, {
|
|
|
274
283
|
})
|
|
275
284
|
```
|
|
276
285
|
|
|
277
|
-
These helpers
|
|
286
|
+
These helpers are protocol- and client-dependent. Use graceful fallbacks when an application serves a wide range of WhatsApp client versions.
|
|
278
287
|
|
|
279
|
-
##
|
|
288
|
+
## Authentication and deployment guidance
|
|
280
289
|
|
|
281
|
-
|
|
290
|
+
Authentication data contains sensitive account credentials. Keep the session directory private, exclude it from version control, and use a dedicated service account or restricted filesystem permissions where possible. Do not place access tokens, private keys, phone numbers, or personal account data in the README, package archive, or a public repository.
|
|
282
291
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
292
|
+
For production deployments, pin dependencies with a lockfile, use a supported Node.js runtime, monitor connection events, handle logout separately from recoverable disconnects, and keep reconnect logic from creating uncontrolled parallel sockets.
|
|
293
|
+
|
|
294
|
+
## Development workflow
|
|
286
295
|
|
|
287
|
-
Run the package
|
|
296
|
+
Run the package tests with:
|
|
288
297
|
|
|
289
298
|
```bash
|
|
290
299
|
npm test
|
|
291
300
|
```
|
|
292
301
|
|
|
293
|
-
Before submitting changes,
|
|
302
|
+
Before submitting changes, validate ESM syntax, CommonJS compatibility where applicable, generated protocol files, and the declarations in `lib/index.d.ts`. Keep package metadata, exports, runtime requirements, and documentation synchronized. When a protocol behavior is experimental, document the fallback behavior and the client versions used during testing.
|
|
294
303
|
|
|
295
|
-
|
|
296
|
-
2. Keep runtime requirements and package metadata synchronized.
|
|
297
|
-
3. Keep authentication data and personal account information out of commits.
|
|
298
|
-
4. Validate ESM syntax and CommonJS compatibility where applicable.
|
|
299
|
-
5. Document user-visible behavior changes in this README.
|
|
304
|
+
## Recent compatibility updates
|
|
300
305
|
|
|
301
|
-
|
|
306
|
+
The current source includes the verified album compatibility correction: album child messages use association type `1`, the compatible child-association wire value, rather than treating the `MEDIA_ALBUM` message category as the association value.
|
|
302
307
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
308
|
+
The source also preserves the package’s explicit view-once implementations and exposes the opt-in `mediaSpoilerMode` path for applications that want either a view-once envelope or a native spoiler context flag without changing existing defaults.
|
|
309
|
+
|
|
310
|
+
## About Codex
|
|
311
|
+
|
|
312
|
+
This package is built and maintained by **Codex**, also known as **Dev Codex**. Codex is a developer from Nigeria who focuses on practical, accessible, and reliable software projects across the JavaScript and TypeScript ecosystem.
|
|
313
|
+
|
|
314
|
+
Codex works with JavaScript, HTML, TypeScript, Node.js, GitHub, Baileys, APIs, key-value stores, and related developer tools. Projects include application development, websites, WhatsApp bots, Telegram bots, API endpoints, and games.
|
|
310
315
|
|
|
311
|
-
|
|
316
|
+
The developer’s work is driven by a commitment to learning, experimentation, clear documentation, and useful software that developers can understand and extend. This package reflects that commitment through its readable source, public declarations, practical examples, and emphasis on responsible automation.
|
|
312
317
|
|
|
313
|
-
|
|
318
|
+
For updates and direct contact, connect with Codex on Telegram at [@codexverified](https://t.me/codexverified).
|
|
319
|
+
Email: codexauthorized@gmail.com
|
|
314
320
|
|
|
315
|
-
|
|
321
|
+
## Package layout
|
|
316
322
|
|
|
317
|
-
|
|
323
|
+
The `lib/` directory contains the JavaScript implementation, supporting utilities, and public TypeScript declarations. `WAProto/` contains generated WhatsApp protocol definitions. `engine-requirements.js` performs installation-time runtime checks. `package.json` contains package metadata, scripts, dependencies, and exports. This `README.md` is the user-facing installation and usage guide.
|
|
318
324
|
|
|
319
|
-
|
|
325
|
+
## Security and responsible use
|
|
320
326
|
|
|
321
|
-
|
|
327
|
+
This library interacts with WhatsApp accounts and user communications. Use it only with accounts and data you are authorized to control. Respect WhatsApp’s terms, applicable law, and the privacy expectations of message participants. Avoid unsolicited messaging, protect authentication state, limit access to stored media, and provide clear notice when an application performs automated actions.
|
|
322
328
|
|
|
323
|
-
|
|
329
|
+
Never commit session files, access tokens, private keys, phone numbers, or other personal information to a public repository. Review installation scripts and optional dependencies before deploying to production, and use pinned dependency versions for repeatable builds.
|
|
324
330
|
|
|
331
|
+
## License and maintenance
|
|
325
332
|
|
|
333
|
+
This distribution is provided under the license declared in `package.json` and the accompanying license file. Review those terms before redistributing or combining this package with third-party code.
|
|
326
334
|
|
|
335
|
+
**@codexverified/baileys is built and maintained by Codex under the CodexVerified organization.** Contributions, bug reports, and carefully documented improvements are welcome through the project repository.
|
|
@@ -4,7 +4,6 @@ import { randomBytes } from 'crypto';
|
|
|
4
4
|
import { proto } from '../../WAProto/index.js';
|
|
5
5
|
import { BIZ_BOT_SUPPORT_PAYLOAD, DEFAULT_CACHE_TTLS, WA_DEFAULT_EPHEMERAL } from '../Defaults/index.js';
|
|
6
6
|
import { aggregateMessageKeysNotFromMe, assertMediaContent, assertMeId, bindWaitForEvent, buildLinkPreview, decryptMediaRetryData, DEF_MEDIA_HOST, delay, encodeNewsletterMessage, encodeSignedDeviceIdentity, encodeWAMessage, encryptMediaRetryRequest, extractDeviceJids, extractImageThumb, generateMessageIDV2, generateParticipantHashV2, generateWAMessage, generateWAMessageFromContent, getStatusCodeForMediaRetry, getUrlFromDirectPath, getWAUploadToServer, hasValidAlbumMedia, MessageRetryManager, normalizeMessageContent, parseAndInjectE2ESessions, prepareWAMessageMedia, shouldIncludeBizBinaryNode, unixTimestampSeconds } from '../Utils/index.js';
|
|
7
|
-
import { AssociationType } from '../Types/index.js';
|
|
8
7
|
import { getUrlInfo } from '../Utils/link-preview.js';
|
|
9
8
|
import { makeKeyedMutex, makeMutex } from '../Utils/make-mutex.js';
|
|
10
9
|
import { getMessageReportingToken, shouldIncludeReportingToken } from '../Utils/reporting-utils.js';
|
|
@@ -2040,7 +2039,9 @@ export const makeMessagesSocket = (config) => {
|
|
|
2040
2039
|
albumMsg.message.messageContextInfo ||= {};
|
|
2041
2040
|
albumMsg.message.messageContextInfo.messageAssociation = {
|
|
2042
2041
|
parentMessageKey: fullMsg.key,
|
|
2043
|
-
|
|
2042
|
+
// WhatsApp album child messages use association type 1.
|
|
2043
|
+
// MEDIA_ALBUM is a message category, not the child-association wire value.
|
|
2044
|
+
associationType: 1
|
|
2044
2045
|
};
|
|
2045
2046
|
await relayMessage(jid, albumMsg.message, {
|
|
2046
2047
|
messageId: albumMsg.key.id,
|
package/lib/Utils/messages.js
CHANGED
|
@@ -1363,6 +1363,31 @@ export const generateWAMessageContent = async (message, options) => {
|
|
|
1363
1363
|
};
|
|
1364
1364
|
delete message.interactiveAsTemplate;
|
|
1365
1365
|
}
|
|
1366
|
+
// Codex compatibility: expose the public media-spoiler mode without changing
|
|
1367
|
+
// the existing explicit viewOnce/viewOnceV2 behavior. The mode is opt-in.
|
|
1368
|
+
// Supported values are `viewOnce` and `native` for image, video, document,
|
|
1369
|
+
// and sticker messages. Existing `spoiler` and view-once flags take priority.
|
|
1370
|
+
if (hasOptionalProperty(message, 'mediaSpoilerMode') &&
|
|
1371
|
+
!message.viewOnce &&
|
|
1372
|
+
!message.viewOnceV2 &&
|
|
1373
|
+
!message.viewOnceV2Extension) {
|
|
1374
|
+
const messageType = Object.keys(m)[0];
|
|
1375
|
+
const isSpoilerMedia = ['imageMessage', 'videoMessage', 'documentMessage', 'stickerMessage'].includes(messageType);
|
|
1376
|
+
const mode = message.mediaSpoilerMode;
|
|
1377
|
+
if (isSpoilerMedia && mode === 'viewOnce') {
|
|
1378
|
+
m = { viewOnceMessage: { message: m } };
|
|
1379
|
+
}
|
|
1380
|
+
else if (isSpoilerMedia && mode === 'native') {
|
|
1381
|
+
const key = m[messageType];
|
|
1382
|
+
if (key && 'contextInfo' in key && key.contextInfo) {
|
|
1383
|
+
key.contextInfo.isSpoiler = true;
|
|
1384
|
+
}
|
|
1385
|
+
else if (key) {
|
|
1386
|
+
key.contextInfo = { isSpoiler: true };
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
delete message.mediaSpoilerMode;
|
|
1390
|
+
}
|
|
1366
1391
|
// Lia@Changes 30-01-26 --- Add "ephemeral" boolean to wrap message into ephemeralMessage like "viewOnce"
|
|
1367
1392
|
if (hasOptionalProperty(message, 'ephemeral') && !!message.ephemeral) {
|
|
1368
1393
|
m = { ephemeralMessage: { message: m } };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codexverified/baileys",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.12",
|
|
4
4
|
"description": "CODEX TECHNOLOGY a premium Baileys developed and built by Dev Codex, with Meta compositing, bot planning replay, welcome flow, rich messages, interactive messages, albums, and more.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|