silva-baileys 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 (99) hide show
  1. package/.github/workflows/publish.yml +26 -0
  2. package/LICENSE +21 -0
  3. package/README.md +154 -0
  4. package/WAProto/GenerateStatics.sh +2 -0
  5. package/WAProto/WAProto.proto +4633 -0
  6. package/WAProto/index.js +165059 -0
  7. package/assets/logo.png +0 -0
  8. package/engine-requirements.js +10 -0
  9. package/lib/Defaults/baileys-version.json +3 -0
  10. package/lib/Defaults/index.js +105 -0
  11. package/lib/Signal/Group/ciphertext-message.js +15 -0
  12. package/lib/Signal/Group/group-session-builder.js +64 -0
  13. package/lib/Signal/Group/group_cipher.js +96 -0
  14. package/lib/Signal/Group/index.js +57 -0
  15. package/lib/Signal/Group/keyhelper.js +55 -0
  16. package/lib/Signal/Group/queue-job.js +57 -0
  17. package/lib/Signal/Group/sender-chain-key.js +34 -0
  18. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  19. package/lib/Signal/Group/sender-key-message.js +69 -0
  20. package/lib/Signal/Group/sender-key-name.js +51 -0
  21. package/lib/Signal/Group/sender-key-record.js +53 -0
  22. package/lib/Signal/Group/sender-key-state.js +99 -0
  23. package/lib/Signal/Group/sender-message-key.js +29 -0
  24. package/lib/Signal/libsignal.js +174 -0
  25. package/lib/Socket/Client/index.js +18 -0
  26. package/lib/Socket/Client/types.js +13 -0
  27. package/lib/Socket/Client/websocket.js +62 -0
  28. package/lib/Socket/business.js +260 -0
  29. package/lib/Socket/chats.js +880 -0
  30. package/lib/Socket/gcstatus.js +237 -0
  31. package/lib/Socket/groups.js +340 -0
  32. package/lib/Socket/index.js +10 -0
  33. package/lib/Socket/messages-recv.js +1079 -0
  34. package/lib/Socket/messages-send.js +1057 -0
  35. package/lib/Socket/mex.js +46 -0
  36. package/lib/Socket/newsletter.js +233 -0
  37. package/lib/Socket/socket.js +617 -0
  38. package/lib/Socket/usync.js +65 -0
  39. package/lib/Types/Auth.js +2 -0
  40. package/lib/Types/Call.js +2 -0
  41. package/lib/Types/Chat.js +10 -0
  42. package/lib/Types/Contact.js +2 -0
  43. package/lib/Types/Events.js +2 -0
  44. package/lib/Types/GroupMetadata.js +2 -0
  45. package/lib/Types/Label.js +27 -0
  46. package/lib/Types/LabelAssociation.js +9 -0
  47. package/lib/Types/Message.js +7 -0
  48. package/lib/Types/Newsletter.js +33 -0
  49. package/lib/Types/Product.js +2 -0
  50. package/lib/Types/Signal.js +2 -0
  51. package/lib/Types/Socket.js +2 -0
  52. package/lib/Types/State.js +2 -0
  53. package/lib/Types/USync.js +2 -0
  54. package/lib/Types/index.js +42 -0
  55. package/lib/Utils/auth-utils.js +199 -0
  56. package/lib/Utils/baileys-event-stream.js +63 -0
  57. package/lib/Utils/business.js +240 -0
  58. package/lib/Utils/chat-utils.js +741 -0
  59. package/lib/Utils/crypto.js +187 -0
  60. package/lib/Utils/decode-wa-message.js +284 -0
  61. package/lib/Utils/event-buffer.js +516 -0
  62. package/lib/Utils/generics.js +400 -0
  63. package/lib/Utils/history.js +100 -0
  64. package/lib/Utils/index.js +34 -0
  65. package/lib/Utils/lid-mapping.js +88 -0
  66. package/lib/Utils/link-preview.js +122 -0
  67. package/lib/Utils/logger.js +7 -0
  68. package/lib/Utils/lt-hash.js +51 -0
  69. package/lib/Utils/make-mutex.js +44 -0
  70. package/lib/Utils/messages-media.js +706 -0
  71. package/lib/Utils/messages.js +797 -0
  72. package/lib/Utils/noise-handler.js +150 -0
  73. package/lib/Utils/process-message.js +381 -0
  74. package/lib/Utils/signal.js +155 -0
  75. package/lib/Utils/use-multi-file-auth-state.js +124 -0
  76. package/lib/Utils/validate-connection.js +170 -0
  77. package/lib/WABinary/constants.js +1303 -0
  78. package/lib/WABinary/decode.js +266 -0
  79. package/lib/WABinary/encode.js +252 -0
  80. package/lib/WABinary/generic-utils.js +110 -0
  81. package/lib/WABinary/index.js +21 -0
  82. package/lib/WABinary/jid-utils.js +66 -0
  83. package/lib/WABinary/types.js +2 -0
  84. package/lib/WAM/BinaryInfo.js +13 -0
  85. package/lib/WAM/constants.js +15243 -0
  86. package/lib/WAM/encode.js +153 -0
  87. package/lib/WAM/index.js +19 -0
  88. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  89. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  90. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  91. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  92. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  93. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  94. package/lib/WAUSync/Protocols/index.js +20 -0
  95. package/lib/WAUSync/USyncQuery.js +93 -0
  96. package/lib/WAUSync/USyncUser.js +26 -0
  97. package/lib/WAUSync/index.js +19 -0
  98. package/lib/index.js +30 -0
  99. package/package.json +40 -0
@@ -0,0 +1,26 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - name: Setup Node.js
15
+ uses: actions/setup-node@v4
16
+ with:
17
+ node-version: '20'
18
+ registry-url: 'https://registry.npmjs.org'
19
+
20
+ - name: Install dependencies
21
+ run: npm install
22
+
23
+ - name: Publish to npm
24
+ run: npm publish --access public
25
+ env:
26
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 Gifted Tech
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,154 @@
1
+ <p align="center">
2
+ <img src="./assets/logo.png" alt="Silva Baileys Logo" width="200"/>
3
+ </p>
4
+
5
+ <h1 align="center">Silva-Baileys</h1>
6
+
7
+ <p align="center">
8
+ A fast, lightweight, full-featured WhatsApp Web API library for Node.js
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/silva-baileys"><img src="https://img.shields.io/npm/v/silva-baileys.svg?style=flat-square&color=25D366" alt="npm version"/></a>
13
+ <a href="https://www.npmjs.com/package/silva-baileys"><img src="https://img.shields.io/npm/dm/silva-baileys.svg?style=flat-square&color=25D366" alt="npm downloads"/></a>
14
+ <a href="https://github.com/SilvaTechB/silva-baileys/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/silva-baileys.svg?style=flat-square" alt="License"/></a>
15
+ </p>
16
+
17
+ ---
18
+
19
+ ## Disclaimer
20
+
21
+ This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or affiliates. Use at your own discretion. Do not spam people with this. We discourage any stalkerware, bulk or automated messaging usage.
22
+
23
+ ---
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ npm install silva-baileys
29
+ ```
30
+
31
+ ```bash
32
+ yarn add silva-baileys
33
+ ```
34
+
35
+ ---
36
+
37
+ ## Quick Start
38
+
39
+ ### CommonJS
40
+
41
+ ```javascript
42
+ const { default: makeWASocket, useMultiFileAuthState, Browsers } = require('silva-baileys')
43
+ ```
44
+
45
+ ### ES Modules / TypeScript
46
+
47
+ ```javascript
48
+ import pkg from 'silva-baileys'
49
+ const { default: makeWASocket, useMultiFileAuthState, Browsers } = pkg
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Basic Usage
55
+
56
+ ```javascript
57
+ const { default: makeWASocket, useMultiFileAuthState, DisconnectReason } = require('silva-baileys')
58
+ const { Boom } = require('@hapi/boom')
59
+
60
+ async function connectToWhatsApp() {
61
+ const { state, saveCreds } = await useMultiFileAuthState('auth_info')
62
+
63
+ const sock = makeWASocket({
64
+ auth: state,
65
+ printQRInTerminal: true
66
+ })
67
+
68
+ sock.ev.on('creds.update', saveCreds)
69
+
70
+ sock.ev.on('connection.update', (update) => {
71
+ const { connection, lastDisconnect } = update
72
+ if (connection === 'close') {
73
+ const shouldReconnect = (lastDisconnect.error instanceof Boom)?.output?.statusCode !== DisconnectReason.loggedOut
74
+ console.log('Connection closed, reconnecting:', shouldReconnect)
75
+ if (shouldReconnect) connectToWhatsApp()
76
+ } else if (connection === 'open') {
77
+ console.log('Connected!')
78
+ }
79
+ })
80
+
81
+ sock.ev.on('messages.upsert', async ({ messages }) => {
82
+ const msg = messages[0]
83
+ if (!msg.key.fromMe && msg.message) {
84
+ console.log('New message:', msg.message)
85
+ }
86
+ })
87
+ }
88
+
89
+ connectToWhatsApp()
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Features
95
+
96
+ - Full WhatsApp Web API support
97
+ - Multi-device support with QR code and pairing code authentication
98
+ - LID (Link ID) addressing support for both personal chats and groups
99
+ - Group status/story sending
100
+ - Session management and restoration
101
+ - Send & receive messages, media, documents, stickers
102
+ - Group management
103
+ - Privacy settings control
104
+ - Profile management
105
+ - Newsletter support
106
+ - And much more!
107
+
108
+ ---
109
+
110
+ ## API Reference
111
+
112
+ ### `makeWASocket(config)`
113
+
114
+ Creates a new WhatsApp socket connection.
115
+
116
+ | Option | Type | Description |
117
+ |--------|------|-------------|
118
+ | `auth` | `AuthenticationState` | Auth state from `useMultiFileAuthState` |
119
+ | `printQRInTerminal` | `boolean` | Print QR code in the terminal |
120
+ | `browser` | `[string, string, string]` | Browser identity tuple |
121
+ | `logger` | `Logger` | Custom pino logger instance |
122
+
123
+ ### `useMultiFileAuthState(folder)`
124
+
125
+ Manages authentication state using multiple files in a folder.
126
+
127
+ ```javascript
128
+ const { state, saveCreds } = await useMultiFileAuthState('./auth_info')
129
+ ```
130
+
131
+ ### Sending Messages
132
+
133
+ ```javascript
134
+ // Text message
135
+ await sock.sendMessage(jid, { text: 'Hello!' })
136
+
137
+ // Image with caption
138
+ await sock.sendMessage(jid, { image: { url: './image.jpg' }, caption: 'Look at this!' })
139
+
140
+ // Video
141
+ await sock.sendMessage(jid, { video: { url: './video.mp4' }, caption: 'Check this out' })
142
+
143
+ // Reply to a message
144
+ await sock.sendMessage(jid, { text: 'This is a reply' }, { quoted: msg })
145
+
146
+ // Send with mentions
147
+ await sock.sendMessage(jid, { text: '@user', mentions: [userJid] })
148
+ ```
149
+
150
+ ---
151
+
152
+ ## License
153
+
154
+ MIT — see [LICENSE](./LICENSE) for details.
@@ -0,0 +1,2 @@
1
+ yarn pbjs -t static-module -w commonjs -o ./WAProto/index.js ./WAProto/WAProto.proto;
2
+ yarn pbts -o ./WAProto/index.d.ts ./WAProto/index.js;