@poucode/baileys 0.0.1-security → 1.0.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.
Files changed (116) hide show
  1. package/LICENSE +30 -0
  2. package/README.md +433 -3
  3. package/WAProto/GenerateStatics.sh +3 -0
  4. package/WAProto/WAProto.proto +6902 -0
  5. package/WAProto/fix-imports.js +85 -0
  6. package/WAProto/index.d.ts +79257 -0
  7. package/WAProto/index.js +242946 -0
  8. package/engine-requirements.js +10 -0
  9. package/lib/Defaults/index.js +129 -0
  10. package/lib/Signal/Group/ciphertext-message.js +11 -0
  11. package/lib/Signal/Group/group-session-builder.js +29 -0
  12. package/lib/Signal/Group/group_cipher.js +81 -0
  13. package/lib/Signal/Group/index.js +11 -0
  14. package/lib/Signal/Group/keyhelper.js +17 -0
  15. package/lib/Signal/Group/sender-chain-key.js +25 -0
  16. package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
  17. package/lib/Signal/Group/sender-key-message.js +65 -0
  18. package/lib/Signal/Group/sender-key-name.js +47 -0
  19. package/lib/Signal/Group/sender-key-record.js +40 -0
  20. package/lib/Signal/Group/sender-key-state.js +83 -0
  21. package/lib/Signal/Group/sender-message-key.js +25 -0
  22. package/lib/Signal/libsignal.js +430 -0
  23. package/lib/Signal/lid-mapping.js +276 -0
  24. package/lib/Socket/Client/index.js +2 -0
  25. package/lib/Socket/Client/types.js +10 -0
  26. package/lib/Socket/Client/websocket.js +85 -0
  27. package/lib/Socket/business.js +378 -0
  28. package/lib/Socket/chats.js +1192 -0
  29. package/lib/Socket/communities.js +430 -0
  30. package/lib/Socket/groups.js +373 -0
  31. package/lib/Socket/index.js +11 -0
  32. package/lib/Socket/luxu.js +386 -0
  33. package/lib/Socket/messages-recv.js +1915 -0
  34. package/lib/Socket/messages-send.js +1452 -0
  35. package/lib/Socket/mex.js +41 -0
  36. package/lib/Socket/newsletter.js +380 -0
  37. package/lib/Socket/socket.js +987 -0
  38. package/lib/Socket/username.js +234 -0
  39. package/lib/Store/index.js +10 -0
  40. package/lib/Store/keyed-db.js +108 -0
  41. package/lib/Store/make-cache-manager-store.js +86 -0
  42. package/lib/Store/make-in-memory-store.js +198 -0
  43. package/lib/Store/make-ordered-dictionary.js +75 -0
  44. package/lib/Store/object-repository.js +32 -0
  45. package/lib/Types/Auth.js +1 -0
  46. package/lib/Types/Bussines.js +1 -0
  47. package/lib/Types/Call.js +1 -0
  48. package/lib/Types/Chat.js +7 -0
  49. package/lib/Types/Contact.js +1 -0
  50. package/lib/Types/Events.js +1 -0
  51. package/lib/Types/GroupMetadata.js +1 -0
  52. package/lib/Types/Label.js +24 -0
  53. package/lib/Types/LabelAssociation.js +6 -0
  54. package/lib/Types/Message.js +10 -0
  55. package/lib/Types/Mex.js +36 -0
  56. package/lib/Types/Product.js +1 -0
  57. package/lib/Types/Signal.js +1 -0
  58. package/lib/Types/Socket.js +2 -0
  59. package/lib/Types/State.js +55 -0
  60. package/lib/Types/USync.js +1 -0
  61. package/lib/Types/index.js +25 -0
  62. package/lib/Utils/auth-utils.js +301 -0
  63. package/lib/Utils/browser-utils.js +48 -0
  64. package/lib/Utils/business.js +230 -0
  65. package/lib/Utils/chat-utils.js +871 -0
  66. package/lib/Utils/companion-reg-client-utils.js +34 -0
  67. package/lib/Utils/crypto.js +117 -0
  68. package/lib/Utils/decode-wa-message.js +349 -0
  69. package/lib/Utils/event-buffer.js +621 -0
  70. package/lib/Utils/generics.js +402 -0
  71. package/lib/Utils/history.js +133 -0
  72. package/lib/Utils/identity-change-handler.js +49 -0
  73. package/lib/Utils/index.js +22 -0
  74. package/lib/Utils/link-preview.js +84 -0
  75. package/lib/Utils/logger.js +2 -0
  76. package/lib/Utils/lt-hash.js +7 -0
  77. package/lib/Utils/make-mutex.js +32 -0
  78. package/lib/Utils/message-composer.js +273 -0
  79. package/lib/Utils/message-retry-manager.js +264 -0
  80. package/lib/Utils/messages-media.js +787 -0
  81. package/lib/Utils/messages.js +1259 -0
  82. package/lib/Utils/noise-handler.js +200 -0
  83. package/lib/Utils/offline-node-processor.js +39 -0
  84. package/lib/Utils/pre-key-manager.js +105 -0
  85. package/lib/Utils/process-message.js +629 -0
  86. package/lib/Utils/reporting-utils.js +257 -0
  87. package/lib/Utils/signal.js +200 -0
  88. package/lib/Utils/stanza-ack.js +37 -0
  89. package/lib/Utils/sync-action-utils.js +48 -0
  90. package/lib/Utils/tc-token-utils.js +162 -0
  91. package/lib/Utils/use-multi-file-auth-state.js +120 -0
  92. package/lib/Utils/validate-connection.js +202 -0
  93. package/lib/WABinary/constants.js +1300 -0
  94. package/lib/WABinary/decode.js +261 -0
  95. package/lib/WABinary/encode.js +219 -0
  96. package/lib/WABinary/generic-utils.js +204 -0
  97. package/lib/WABinary/index.js +5 -0
  98. package/lib/WABinary/jid-utils.js +97 -0
  99. package/lib/WABinary/types.js +1 -0
  100. package/lib/WAM/BinaryInfo.js +9 -0
  101. package/lib/WAM/constants.js +22852 -0
  102. package/lib/WAM/encode.js +149 -0
  103. package/lib/WAM/index.js +3 -0
  104. package/lib/WAUSync/Protocols/USyncContactProtocol.js +51 -0
  105. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
  106. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
  107. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
  108. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
  109. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
  110. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
  111. package/lib/WAUSync/Protocols/index.js +5 -0
  112. package/lib/WAUSync/USyncQuery.js +97 -0
  113. package/lib/WAUSync/USyncUser.js +30 -0
  114. package/lib/WAUSync/index.js +3 -0
  115. package/lib/index.js +19 -0
  116. package/package.json +149 -3
package/LICENSE ADDED
@@ -0,0 +1,30 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Adhiraj Singh
4
+ Copyright (c) 2022-2026 WhiskeySockets and Baileys contributors
5
+ Copyright (c) 2026 PouCode (modifications and fork maintenance)
6
+
7
+ This software ("PouCode") is a derivative work based on Baileys
8
+ (https://github.com/WhiskeySockets/Baileys), originally created by Adhiraj Singh
9
+ and maintained by the WhiskeySockets community, licensed under the MIT License.
10
+ The original copyright notice above is retained as required by the MIT License.
11
+ Modifications, rebranding, and additional changes in this fork are
12
+ Copyright (c) 2026 PouCode.
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,435 @@
1
- # Security holding package
1
+ # <div align='center'>PouCode</div>
2
2
 
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
3
+ <p align="center">
4
4
 
5
- Please refer to www.npmjs.com/advisories?search=%40poucode%2Fbaileys for more information.
5
+ <img src="https://files.catbox.moe/i497x5.jpg" width="180" alt="Pou"/>
6
+
7
+ </p>
8
+
9
+ <div align='center'>
10
+
11
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
12
+ [![GitHub](https://img.shields.io/badge/source-GitHub-black.svg)](https://github.com/pou-code/Baileys)
13
+ [![Node](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg)](package.json)
14
+
15
+ A WebSockets library for interacting with WhatsApp Web, maintained under the **PouCode** brand.
16
+ This project is a fork built on top of [Baileys](https://github.com/WhiskeySockets/Baileys) by WhiskeySockets.
17
+
18
+ </div>
19
+
20
+ ---
21
+
22
+ ## Installation
23
+
24
+ Requires **Node.js 20+** (this package is ESM-only; see [Import](#import)).
25
+
26
+ From the npm registry (once published):
27
+ ```bash
28
+ npm install @poucode/baileys
29
+ ```
30
+
31
+ Directly from GitHub:
32
+ ```bash
33
+ npm install github:pou-code/Baileys
34
+ ```
35
+
36
+ Or add it to your `package.json` manually:
37
+ ```json
38
+ "dependencies": {
39
+ "@poucode/baileys": "github:pou-code/Baileys"
40
+ }
41
+ ```
42
+
43
+ Already have a bot built on the original `@whiskeysockets/baileys` and don't want to change every
44
+ `require`/`import` in your codebase? Alias the dependency name instead, so the original package
45
+ name points to this fork:
46
+ ```json
47
+ "dependencies": {
48
+ "@whiskeysockets/baileys": "github:pou-code/Baileys"
49
+ }
50
+ ```
51
+ With this alias, keep using `require('@whiskeysockets/baileys')` in your code as-is — npm will
52
+ resolve it to this fork under the hood.
53
+
54
+ You can also pin to a specific branch or commit:
55
+ ```bash
56
+ npm install github:pou-code/Baileys#main
57
+ ```
58
+
59
+ ## Import
60
+
61
+ ESM (works on every supported Node.js version):
62
+ ```javascript
63
+ import makeWASocket, { Browsers, DisconnectReason } from '@poucode/baileys';
64
+ ```
65
+
66
+ CommonJS: the package is ESM-only, so `require()` only works on Node.js 22.12+ or 20.19+
67
+ (Node's `require(esm)` support). On older versions use `import` instead.
68
+ ```javascript
69
+ const {
70
+ default: makeWASocket,
71
+ // other exports
72
+ } = require('@poucode/baileys');
73
+ ```
74
+
75
+ ---
76
+
77
+ # Connecting To WhatsApp
78
+
79
+ ## With QR Code
80
+ ```javascript
81
+ const {
82
+ default: makeWASocket,
83
+ Browsers
84
+ } = require('@poucode/baileys');
85
+
86
+ const client = makeWASocket({
87
+ browser: Browsers.poucode('Chrome')
88
+ });
89
+
90
+ // `printQRInTerminal` is deprecated: the QR string now arrives via connection.update.
91
+ // Render it with your own QR library (e.g. qrcode-terminal) if you want it in the terminal.
92
+ client.ev.on('connection.update', ({ connection, qr }) => {
93
+ if (qr) console.log('Scan this QR string:', qr);
94
+ if (connection === 'open') console.log('Connected');
95
+ });
96
+ ```
97
+
98
+ ## Connect With Pairing Code
99
+ ```javascript
100
+ const {
101
+ default: makeWASocket,
102
+ fetchLatestWaWebVersion,
103
+ Browsers
104
+ } = require('@poucode/baileys');
105
+
106
+ async function start() {
107
+ // fetchLatestWaWebVersion() resolves to { version, isLatest, error? }
108
+ const { version } = await fetchLatestWaWebVersion();
109
+
110
+ const client = makeWASocket({
111
+ browser: Browsers.poucode('Chrome'),
112
+ printQRInTerminal: false,
113
+ version,
114
+ aiLabel: false // set true to show an AI label on messages sent by the bot
115
+ // other options
116
+ });
117
+
118
+ const number = "628XXXXXXXXXX";
119
+ const code = await client.requestPairingCode(number.trim()); // or (number, "YYYYYYYY") for a custom pairing code
120
+
121
+ console.log("Your pairing code: " + code);
122
+ }
123
+
124
+ start();
125
+ ```
126
+
127
+ # Storing Data
128
+ ```javascript
129
+ const {
130
+ default: makeWASocket,
131
+ makeInMemoryStore
132
+ } = require('@poucode/baileys');
133
+ const pino = require('pino');
134
+
135
+ const store = makeInMemoryStore({
136
+ logger: pino().child({ level: 'silent', stream: 'store' })
137
+ });
138
+ const client = makeWASocket({
139
+ // options
140
+ });
141
+ store.bind(client.ev);
142
+
143
+ client.ev.on('contacts.upsert', () => {
144
+ console.log('New contact: ' + Object.values(store.contacts()));
145
+ });
146
+ ```
147
+
148
+ # Sending Messages
149
+
150
+ ## Send / relay a message with `noSelfSync`
151
+
152
+ `noSelfSync` is a `relayMessage` option (private/1-on-1 chats only) that controls whether the
153
+ message is also synced to your **other own linked devices** (other phones/WhatsApp Web sessions
154
+ logged into the same account). It does not affect delivery to the recipient.
155
+
156
+ - **`noSelfSync: true`** — the message is sent to the recipient as normal, but is **not** synced
157
+ to your other own devices. Useful when you don't want a message to show up on your other
158
+ linked sessions (e.g. silent/automated sends from a bot account).
159
+ - **`noSelfSync: false`** (default) — normal behavior. The message is sent to the recipient and
160
+ also synced to your other own devices, so it appears everywhere you're logged in, just like
161
+ sending from the official WhatsApp app.
162
+
163
+ ```javascript
164
+ // Sent to the recipient, but NOT synced to your other devices
165
+ await client.relayMessage(m.chat, {
166
+ conversation: "Hello from PouCode"
167
+ }, {
168
+ noSelfSync: true
169
+ });
170
+
171
+ // Sent to the recipient AND synced to your other devices (default behavior)
172
+ await client.relayMessage(m.chat, {
173
+ conversation: "Hello from PouCode"
174
+ }, {
175
+ noSelfSync: false
176
+ });
177
+
178
+ // Also works through sendMessage
179
+ await client.sendMessage(m.chat, {
180
+ text: "Hello from PouCode"
181
+ }, {
182
+ noSelfSync: true
183
+ });
184
+ ```
185
+
186
+ ## Send an orderMessage
187
+ ```javascript
188
+ const fs = require('fs');
189
+ const thumbnail = fs.readFileSync('./pouthumb.jpg');
190
+
191
+ await client.sendMessage(m.chat, {
192
+ thumbnail,
193
+ message: "Order summary",
194
+ orderTitle: "My Store",
195
+ totalAmount1000: 72502,
196
+ totalCurrencyCode: "IDR"
197
+ }, { quoted: m });
198
+ ```
199
+
200
+ ## Send a pollResultSnapshotMessage
201
+ ```javascript
202
+ await client.sendMessage(m.chat, {
203
+ pollResultMessage: {
204
+ name: "My Poll",
205
+ options: [
206
+ { optionName: "Option 1" },
207
+ { optionName: "Option 2" }
208
+ ],
209
+ newsletter: {
210
+ newsletterName: "0X8 - Society",
211
+ newsletterJid: "120363424944937940@newsletter"
212
+ }
213
+ }
214
+ });
215
+ ```
216
+
217
+ ## Send a productMessage
218
+ ```javascript
219
+ await client.relayMessage(m.chat, {
220
+ productMessage: {
221
+ title: "Product.pdf",
222
+ description: "Product description",
223
+ thumbnail: { url: "./pouthumb.jpg" },
224
+ productId: "EXAMPLE_TOKEN",
225
+ retailerId: "EXAMPLE_RETAILER_ID",
226
+ url: "https://example.com",
227
+ body: "Body text",
228
+ footer: "Footer",
229
+ buttons: [
230
+ {
231
+ name: "cta_url",
232
+ buttonParamsJson: "{\"display_text\":\"Visit\",\"url\":\"https://example.com\"}"
233
+ }
234
+ ],
235
+ priceAmount1000: 72502,
236
+ currencyCode: "IDR"
237
+ }
238
+ });
239
+ ```
240
+
241
+ ## Send an interactiveMessage
242
+ ```javascript
243
+ await client.sendMessage(m.chat, {
244
+ image: { url: "./pouimg.jpg" },
245
+ text: "body",
246
+ title: "title", // required when sending media
247
+ footer: "footer",
248
+ interactiveButtons: [
249
+ {
250
+ name: "single_select",
251
+ buttonParamsJson: JSON.stringify({
252
+ title: "\0"
253
+ })
254
+ }
255
+ ],
256
+ messageParams: JSON.stringify({
257
+ bottom_sheet: {
258
+ /** other params **/
259
+ }
260
+ })
261
+ });
262
+ ```
263
+
264
+ ## Send a member label
265
+ ```javascript
266
+ await client.sendMessage(m.chat, {
267
+ groupLabel: {
268
+ labelText: "Tagged members appear here"
269
+ }
270
+ });
271
+ ```
272
+
273
+ ## Send a message to group members
274
+ ```javascript
275
+ await client.sendMessageMembers(m.chat, {
276
+ extendedTextMessage: {
277
+ text: "Hello members"
278
+ }
279
+ }, {});
280
+ ```
281
+
282
+ # Simple sendMessage Helpers
283
+
284
+ ## Send text
285
+ ```javascript
286
+ await client.sendText(m.chat, "Hello!", {
287
+ contextInfo: {
288
+ mentionedJid: [m.chat]
289
+ }
290
+ }, {
291
+ key: {
292
+ remoteJid: "status@broadcast",
293
+ participant: m.sender,
294
+ fromMe: true
295
+ },
296
+ message: {
297
+ conversation: "\0"
298
+ }
299
+ });
300
+ ```
301
+
302
+ ## Send image
303
+ ```javascript
304
+ await client.sendImage(m.chat, { url: "./pouimg.jpg" }, "Caption", {
305
+ contextInfo: {
306
+ mentionedJid: [m.chat]
307
+ }
308
+ }, {
309
+ key: {
310
+ remoteJid: "status@broadcast",
311
+ participant: m.sender,
312
+ fromMe: true
313
+ },
314
+ message: {
315
+ conversation: "\0"
316
+ }
317
+ });
318
+ ```
319
+
320
+ ## Send video
321
+ ```javascript
322
+ await client.sendVideo(m.chat, { url: "./video.mp4" }, "Caption", {
323
+ contextInfo: {
324
+ mentionedJid: [m.chat]
325
+ }
326
+ }, {
327
+ key: {
328
+ remoteJid: "status@broadcast",
329
+ participant: m.sender,
330
+ fromMe: true
331
+ },
332
+ message: {
333
+ conversation: "\0"
334
+ }
335
+ });
336
+ ```
337
+
338
+ ## Send audio
339
+ ```javascript
340
+ await client.sendAudio(m.chat, { url: "./pouaudio.mp3" }, {
341
+ contextInfo: {
342
+ mentionedJid: [m.chat]
343
+ }
344
+ }, {
345
+ key: {
346
+ remoteJid: "status@broadcast",
347
+ participant: m.sender,
348
+ fromMe: true
349
+ },
350
+ message: {
351
+ conversation: "\0"
352
+ }
353
+ });
354
+ ```
355
+
356
+ ## Send location
357
+ ```javascript
358
+ await client.sendLocation(m.chat, "Caption", 90.0, 90.0, "https://example.com", "1234567890", {
359
+ contextInfo: {
360
+ mentionedJid: [m.chat]
361
+ }
362
+ }, {
363
+ key: {
364
+ remoteJid: "status@broadcast",
365
+ participant: m.sender,
366
+ fromMe: true
367
+ },
368
+ message: {
369
+ conversation: "\0"
370
+ }
371
+ });
372
+ ```
373
+
374
+ ## Send poll
375
+ ```javascript
376
+ await client.sendPoll(m.chat, "Pick one", ["1", "2", "3"], true, {
377
+ contextInfo: {
378
+ mentionedJid: [m.chat]
379
+ }
380
+ }, {
381
+ key: {
382
+ remoteJid: "status@broadcast",
383
+ participant: m.sender,
384
+ fromMe: true
385
+ },
386
+ message: {
387
+ conversation: "\0"
388
+ }
389
+ });
390
+ ```
391
+
392
+ ## Send quiz
393
+ ```javascript
394
+ await client.sendQuiz(m.chat, "Quiz question", ["1", "2", "3"], "2", {
395
+ contextInfo: {
396
+ mentionedJid: [m.chat]
397
+ }
398
+ }, {
399
+ key: {
400
+ remoteJid: "status@broadcast",
401
+ participant: m.sender,
402
+ fromMe: true
403
+ },
404
+ message: {
405
+ conversation: "\0"
406
+ }
407
+ });
408
+ ```
409
+
410
+ ## Send status mention
411
+ ```javascript
412
+ await client.statusMention(m.chat, {
413
+ extendedTextMessage: {
414
+ text: "Mentioned in status"
415
+ }
416
+ });
417
+ ```
418
+
419
+ ---
420
+
421
+ # Credits
422
+
423
+ PouCode is a fork of [Baileys](https://github.com/WhiskeySockets/Baileys), originally created by
424
+ [Adhiraj Singh](https://github.com/adiwajshing) and maintained by the WhiskeySockets community.
425
+ All credit for the underlying protocol implementation goes to the original authors and contributors.
426
+ See [LICENSE](LICENSE) for the full license text and copyright notices.
427
+
428
+ # Contributing
429
+
430
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on reporting issues and submitting pull requests.
431
+
432
+ # Disclaimer
433
+
434
+ This is **not** an official WhatsApp product. Use of this library to send bulk or unsolicited messages
435
+ may violate WhatsApp's Terms of Service and can result in your number being banned. Use responsibly.
@@ -0,0 +1,3 @@
1
+ yarn pbjs -t static-module --no-beautify -w es6 --no-bundle --no-delimited --no-verify --no-comments -o ./index.js ./WAProto.proto;
2
+ yarn pbjs -t static-module --no-beautify -w es6 --no-bundle --no-delimited --no-verify ./WAProto.proto | yarn pbts --no-comments -o ./index.d.ts -;
3
+ node ./fix-imports.js