@ntzckofficial/baileys 0.0.0-stage → 2.1.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 (289) hide show
  1. package/Example/example.ts +235 -0
  2. package/LICENSE +21 -0
  3. package/README.md +43 -2
  4. package/WAProto/GenerateStatics.sh +3 -0
  5. package/WAProto/WAProto.proto +5479 -0
  6. package/WAProto/fix-imports.js +81 -0
  7. package/WAProto/index.d.ts +17302 -0
  8. package/WAProto/index.js +125089 -0
  9. package/index.cjs +29 -0
  10. package/index.d.ts +2 -0
  11. package/package.json +114 -4
  12. package/src/Defaults/index.d.ts +153 -0
  13. package/src/Defaults/index.js +165 -0
  14. package/src/MessageBuilder/bot-signature.d.ts +22 -0
  15. package/src/MessageBuilder/bot-signature.js +123 -0
  16. package/src/MessageBuilder/extras.d.ts +449 -0
  17. package/src/MessageBuilder/extras.js +1357 -0
  18. package/src/MessageBuilder/index.d.ts +210 -0
  19. package/src/MessageBuilder/index.js +3561 -0
  20. package/src/MessageBuilder/metaai.d.ts +438 -0
  21. package/src/MessageBuilder/metaai.js +891 -0
  22. package/src/Signal/Group/ciphertext-message.d.ts +10 -0
  23. package/src/Signal/Group/ciphertext-message.js +12 -0
  24. package/src/Signal/Group/group-session-builder.d.ts +8 -0
  25. package/src/Signal/Group/group-session-builder.js +28 -0
  26. package/src/Signal/Group/group_cipher.d.ts +11 -0
  27. package/src/Signal/Group/group_cipher.js +79 -0
  28. package/src/Signal/Group/index.d.ts +12 -0
  29. package/src/Signal/Group/index.js +12 -0
  30. package/src/Signal/Group/keyhelper.d.ts +7 -0
  31. package/src/Signal/Group/keyhelper.js +18 -0
  32. package/src/Signal/Group/sender-chain-key.d.ts +14 -0
  33. package/src/Signal/Group/sender-chain-key.js +26 -0
  34. package/src/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  35. package/src/Signal/Group/sender-key-distribution-message.js +63 -0
  36. package/src/Signal/Group/sender-key-message.d.ts +19 -0
  37. package/src/Signal/Group/sender-key-message.js +66 -0
  38. package/src/Signal/Group/sender-key-name.d.ts +12 -0
  39. package/src/Signal/Group/sender-key-name.js +48 -0
  40. package/src/Signal/Group/sender-key-record.d.ts +13 -0
  41. package/src/Signal/Group/sender-key-record.js +41 -0
  42. package/src/Signal/Group/sender-key-state.d.ts +17 -0
  43. package/src/Signal/Group/sender-key-state.js +84 -0
  44. package/src/Signal/Group/sender-message-key.d.ts +12 -0
  45. package/src/Signal/Group/sender-message-key.js +26 -0
  46. package/src/Signal/libsignal.d.ts +55 -0
  47. package/src/Signal/libsignal.js +459 -0
  48. package/src/Signal/lid-mapping.d.ts +21 -0
  49. package/src/Signal/lid-mapping.js +275 -0
  50. package/src/Socket/Client/index.d.ts +3 -0
  51. package/src/Socket/Client/index.js +3 -0
  52. package/src/Socket/Client/types.d.ts +6 -0
  53. package/src/Socket/Client/types.js +10 -0
  54. package/src/Socket/Client/websocket.d.ts +13 -0
  55. package/src/Socket/Client/websocket.js +54 -0
  56. package/src/Socket/business.d.ts +432 -0
  57. package/src/Socket/business.js +380 -0
  58. package/src/Socket/chats.d.ts +248 -0
  59. package/src/Socket/chats.js +1485 -0
  60. package/src/Socket/communities.d.ts +599 -0
  61. package/src/Socket/communities.js +422 -0
  62. package/src/Socket/groups.d.ts +299 -0
  63. package/src/Socket/groups.js +340 -0
  64. package/src/Socket/index.d.ts +582 -0
  65. package/src/Socket/index.js +43 -0
  66. package/src/Socket/messages-recv.d.ts +371 -0
  67. package/src/Socket/messages-recv.js +1813 -0
  68. package/src/Socket/messages-send.d.ts +391 -0
  69. package/src/Socket/messages-send.js +1575 -0
  70. package/src/Socket/mex.d.ts +2 -0
  71. package/src/Socket/mex.js +45 -0
  72. package/src/Socket/newsletter.d.ts +469 -0
  73. package/src/Socket/newsletter.js +643 -0
  74. package/src/Socket/socket.d.ts +78 -0
  75. package/src/Socket/socket.js +1088 -0
  76. package/src/Store/index.d.ts +4 -0
  77. package/src/Store/index.js +4 -0
  78. package/src/Store/make-in-memory-store.d.ts +63 -0
  79. package/src/Store/make-in-memory-store.js +398 -0
  80. package/src/Store/make-ordered-dictionary.d.ts +13 -0
  81. package/src/Store/make-ordered-dictionary.js +79 -0
  82. package/src/Store/object-repository.d.ts +11 -0
  83. package/src/Store/object-repository.js +24 -0
  84. package/src/Types/Auth.d.ts +2 -0
  85. package/src/Types/Auth.js +2 -0
  86. package/src/Types/Bussines.d.ts +2 -0
  87. package/src/Types/Bussines.js +2 -0
  88. package/src/Types/Call.d.ts +2 -0
  89. package/src/Types/Call.js +2 -0
  90. package/src/Types/Chat.d.ts +3 -0
  91. package/src/Types/Chat.js +25 -0
  92. package/src/Types/Contact.d.ts +2 -0
  93. package/src/Types/Contact.js +2 -0
  94. package/src/Types/Events.d.ts +2 -0
  95. package/src/Types/Events.js +1 -0
  96. package/src/Types/GroupMetadata.d.ts +6 -0
  97. package/src/Types/GroupMetadata.js +7 -0
  98. package/src/Types/Label.d.ts +3 -0
  99. package/src/Types/Label.js +25 -0
  100. package/src/Types/LabelAssociation.d.ts +3 -0
  101. package/src/Types/LabelAssociation.js +7 -0
  102. package/src/Types/Message.d.ts +14 -0
  103. package/src/Types/Message.js +24 -0
  104. package/src/Types/Mex.d.ts +3 -0
  105. package/src/Types/Mex.js +96 -0
  106. package/src/Types/Product.d.ts +2 -0
  107. package/src/Types/Product.js +2 -0
  108. package/src/Types/Signal.d.ts +2 -0
  109. package/src/Types/Signal.js +1 -0
  110. package/src/Types/Socket.d.ts +2 -0
  111. package/src/Types/Socket.js +1 -0
  112. package/src/Types/State.d.ts +6 -0
  113. package/src/Types/State.js +55 -0
  114. package/src/Types/USync.d.ts +2 -0
  115. package/src/Types/USync.js +1 -0
  116. package/src/Types/index.d.ts +14 -0
  117. package/src/Types/index.js +26 -0
  118. package/src/Utils/auth-store.d.ts +30 -0
  119. package/src/Utils/auth-store.js +77 -0
  120. package/src/Utils/auth-utils.d.ts +59 -0
  121. package/src/Utils/auth-utils.js +287 -0
  122. package/src/Utils/browser-utils.d.ts +10 -0
  123. package/src/Utils/browser-utils.js +29 -0
  124. package/src/Utils/business.d.ts +50 -0
  125. package/src/Utils/business.js +227 -0
  126. package/src/Utils/chat-utils.d.ts +409 -0
  127. package/src/Utils/chat-utils.js +847 -0
  128. package/src/Utils/companion-reg-client-utils.d.ts +5 -0
  129. package/src/Utils/companion-reg-client-utils.js +40 -0
  130. package/src/Utils/crypto.d.ts +40 -0
  131. package/src/Utils/crypto.js +111 -0
  132. package/src/Utils/decode-wa-message.d.ts +100 -0
  133. package/src/Utils/decode-wa-message.js +398 -0
  134. package/src/Utils/event-buffer.d.ts +23 -0
  135. package/src/Utils/event-buffer.js +625 -0
  136. package/src/Utils/generics.d.ts +64 -0
  137. package/src/Utils/generics.js +376 -0
  138. package/src/Utils/group-metadata-cache.d.ts +5 -0
  139. package/src/Utils/group-metadata-cache.js +26 -0
  140. package/src/Utils/history.d.ts +76 -0
  141. package/src/Utils/history.js +132 -0
  142. package/src/Utils/html-app.d.ts +19 -0
  143. package/src/Utils/html-app.js +97 -0
  144. package/src/Utils/html-multiplayer.d.ts +10 -0
  145. package/src/Utils/html-multiplayer.js +95 -0
  146. package/src/Utils/identity-change-handler.d.ts +14 -0
  147. package/src/Utils/identity-change-handler.js +49 -0
  148. package/src/Utils/index.d.ts +45 -0
  149. package/src/Utils/index.js +45 -0
  150. package/src/Utils/link-preview-metadata.d.ts +47 -0
  151. package/src/Utils/link-preview-metadata.js +89 -0
  152. package/src/Utils/link-preview.d.ts +13 -0
  153. package/src/Utils/link-preview.js +80 -0
  154. package/src/Utils/logger.d.ts +3 -0
  155. package/src/Utils/logger.js +3 -0
  156. package/src/Utils/lt-hash.d.ts +7 -0
  157. package/src/Utils/lt-hash.js +4 -0
  158. package/src/Utils/make-mutex.d.ts +7 -0
  159. package/src/Utils/make-mutex.js +33 -0
  160. package/src/Utils/message-retry-manager.d.ts +80 -0
  161. package/src/Utils/message-retry-manager.js +256 -0
  162. package/src/Utils/messages-media.d.ts +137 -0
  163. package/src/Utils/messages-media.js +815 -0
  164. package/src/Utils/messages.d.ts +63 -0
  165. package/src/Utils/messages.js +2153 -0
  166. package/src/Utils/modern-messages.d.ts +150 -0
  167. package/src/Utils/modern-messages.js +496 -0
  168. package/src/Utils/native-flow.d.ts +11 -0
  169. package/src/Utils/native-flow.js +116 -0
  170. package/src/Utils/newsletter-status.d.ts +158 -0
  171. package/src/Utils/newsletter-status.js +651 -0
  172. package/src/Utils/noise-handler.d.ts +21 -0
  173. package/src/Utils/noise-handler.js +201 -0
  174. package/src/Utils/offline-node-processor.d.ts +10 -0
  175. package/src/Utils/offline-node-processor.js +34 -0
  176. package/src/Utils/optional-media.d.ts +3 -0
  177. package/src/Utils/optional-media.js +46 -0
  178. package/src/Utils/payment-messages.d.ts +66 -0
  179. package/src/Utils/payment-messages.js +161 -0
  180. package/src/Utils/pre-key-manager.d.ts +26 -0
  181. package/src/Utils/pre-key-manager.js +96 -0
  182. package/src/Utils/process-message.d.ts +61 -0
  183. package/src/Utils/process-message.js +689 -0
  184. package/src/Utils/reporting-utils.d.ts +13 -0
  185. package/src/Utils/reporting-utils.js +257 -0
  186. package/src/Utils/scheduled-message.d.ts +51 -0
  187. package/src/Utils/scheduled-message.js +113 -0
  188. package/src/Utils/sender-key-memory.d.ts +20 -0
  189. package/src/Utils/sender-key-memory.js +52 -0
  190. package/src/Utils/signal.d.ts +83 -0
  191. package/src/Utils/signal.js +194 -0
  192. package/src/Utils/stanza-ack.d.ts +17 -0
  193. package/src/Utils/stanza-ack.js +31 -0
  194. package/src/Utils/status-stickers.d.ts +127 -0
  195. package/src/Utils/status-stickers.js +261 -0
  196. package/src/Utils/sync-action-utils.d.ts +3 -0
  197. package/src/Utils/sync-action-utils.js +45 -0
  198. package/src/Utils/tc-token-utils.d.ts +30 -0
  199. package/src/Utils/tc-token-utils.js +156 -0
  200. package/src/Utils/ttl-cache.d.ts +29 -0
  201. package/src/Utils/ttl-cache.js +121 -0
  202. package/src/Utils/use-mongo-auth-state.d.ts +22 -0
  203. package/src/Utils/use-mongo-auth-state.js +68 -0
  204. package/src/Utils/use-multi-file-auth-state.d.ts +12 -0
  205. package/src/Utils/use-multi-file-auth-state.js +119 -0
  206. package/src/Utils/use-mysql-auth-state.d.ts +20 -0
  207. package/src/Utils/use-mysql-auth-state.js +80 -0
  208. package/src/Utils/use-postgres-auth-state.d.ts +20 -0
  209. package/src/Utils/use-postgres-auth-state.js +80 -0
  210. package/src/Utils/use-redis-auth-state.d.ts +20 -0
  211. package/src/Utils/use-redis-auth-state.js +90 -0
  212. package/src/Utils/use-single-file-auth-state.d.ts +11 -0
  213. package/src/Utils/use-single-file-auth-state.js +109 -0
  214. package/src/Utils/use-sqlite-auth-state.d.ts +13 -0
  215. package/src/Utils/use-sqlite-auth-state.js +121 -0
  216. package/src/Utils/useNekoDBAuth.d.ts +19 -0
  217. package/src/Utils/useNekoDBAuth.js +111 -0
  218. package/src/Utils/username.d.ts +12 -0
  219. package/src/Utils/username.js +59 -0
  220. package/src/Utils/validate-connection.d.ts +44 -0
  221. package/src/Utils/validate-connection.js +208 -0
  222. package/src/Utils/voice-recognition.d.ts +53 -0
  223. package/src/Utils/voice-recognition.js +219 -0
  224. package/src/Voip/audio-feeder.d.ts +25 -0
  225. package/src/Voip/audio-feeder.js +269 -0
  226. package/src/Voip/index.d.ts +89 -0
  227. package/src/Voip/index.js +937 -0
  228. package/src/Voip/relay-transport.d.ts +6 -0
  229. package/src/Voip/relay-transport.js +825 -0
  230. package/src/Voip/signaling.d.ts +12 -0
  231. package/src/Voip/signaling.js +1100 -0
  232. package/src/Voip/types.d.ts +3 -0
  233. package/src/Voip/types.js +13 -0
  234. package/src/Voip/video-feeder.d.ts +25 -0
  235. package/src/Voip/video-feeder.js +269 -0
  236. package/src/Voip/wasm-engine.d.ts +27 -0
  237. package/src/Voip/wasm-engine.js +1308 -0
  238. package/src/Voip/worker-bootstrap.js +1024 -0
  239. package/src/WABinary/constants.d.ts +23 -0
  240. package/src/WABinary/constants.js +1301 -0
  241. package/src/WABinary/decode.d.ts +10 -0
  242. package/src/WABinary/decode.js +262 -0
  243. package/src/WABinary/encode.d.ts +3 -0
  244. package/src/WABinary/encode.js +220 -0
  245. package/src/WABinary/generic-utils.d.ts +77 -0
  246. package/src/WABinary/generic-utils.js +215 -0
  247. package/src/WABinary/index.d.ts +6 -0
  248. package/src/WABinary/index.js +6 -0
  249. package/src/WABinary/jid-utils.d.ts +31 -0
  250. package/src/WABinary/jid-utils.js +98 -0
  251. package/src/WABinary/types.d.ts +2 -0
  252. package/src/WABinary/types.js +1 -0
  253. package/src/WAM/BinaryInfo.d.ts +8 -0
  254. package/src/WAM/BinaryInfo.js +10 -0
  255. package/src/WAM/constants.d.ts +34927 -0
  256. package/src/WAM/constants.js +22853 -0
  257. package/src/WAM/encode.d.ts +2 -0
  258. package/src/WAM/encode.js +149 -0
  259. package/src/WAM/index.d.ts +4 -0
  260. package/src/WAM/index.js +4 -0
  261. package/src/WAUSync/Protocols/USyncContactProtocol.d.ts +37 -0
  262. package/src/WAUSync/Protocols/USyncContactProtocol.js +51 -0
  263. package/src/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  264. package/src/WAUSync/Protocols/USyncDeviceProtocol.js +52 -0
  265. package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  266. package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
  267. package/src/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  268. package/src/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
  269. package/src/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
  270. package/src/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
  271. package/src/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +39 -0
  272. package/src/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
  273. package/src/WAUSync/Protocols/UsyncLIDProtocol.d.ts +15 -0
  274. package/src/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
  275. package/src/WAUSync/Protocols/index.d.ts +6 -0
  276. package/src/WAUSync/Protocols/index.js +6 -0
  277. package/src/WAUSync/USyncQuery.d.ts +21 -0
  278. package/src/WAUSync/USyncQuery.js +94 -0
  279. package/src/WAUSync/USyncUser.d.ts +17 -0
  280. package/src/WAUSync/USyncUser.js +31 -0
  281. package/src/WAUSync/index.d.ts +4 -0
  282. package/src/WAUSync/index.js +4 -0
  283. package/src/assets/wasm/README.md +76 -0
  284. package/src/assets/wasm/loader.js +5 -0
  285. package/src/assets/wasm/whatsapp.wasm +0 -0
  286. package/src/assets/wasm/worker-modules.js +273 -0
  287. package/src/custom.js +85 -0
  288. package/src/index.d.ts +49 -0
  289. package/src/index.js +55 -0
@@ -0,0 +1,235 @@
1
+ import { Boom } from '@hapi/boom'
2
+ import NodeCache from '@cacheable/node-cache'
3
+ import readline from 'readline'
4
+ import makeWASocket, { CacheStore, DEFAULT_CONNECTION_CONFIG, DisconnectReason, fetchLatestBaileysVersion, generateMessageIDV2, getAggregateVotesInPollMessage, isJidNewsletter, makeCacheableSignalKeyStore, proto, useMultiFileAuthState, WAMessageContent, WAMessageKey } from '../src'
5
+ import P from 'pino'
6
+
7
+ const logger = P({
8
+ level: "trace",
9
+ transport: {
10
+ targets: [
11
+ {
12
+ target: "pino-pretty", // pretty-print for console
13
+ options: { colorize: true },
14
+ level: "trace",
15
+ },
16
+ {
17
+ target: "pino/file", // raw file output
18
+ options: { destination: './wa-logs.txt' },
19
+ level: "trace",
20
+ },
21
+ ],
22
+ },
23
+ })
24
+ logger.level = 'trace'
25
+
26
+ const doReplies = process.argv.includes('--do-reply')
27
+ const usePairingCode = process.argv.includes('--use-pairing-code')
28
+
29
+ // external map to store retry counts of messages when decryption/encryption fails
30
+ // keep this out of the socket itself, so as to prevent a message decryption/encryption loop across socket restarts
31
+ const msgRetryCounterCache = new NodeCache() as CacheStore
32
+
33
+ const onDemandMap = new Map<string, string>()
34
+
35
+ // Read line interface
36
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
37
+ const question = (text: string) => new Promise<string>((resolve) => rl.question(text, resolve))
38
+
39
+ // start a connection
40
+ const startSock = async() => {
41
+ const { state, saveCreds } = await useMultiFileAuthState('baileys_auth_info')
42
+ // NOTE: For unit testing purposes only
43
+ if (process.env.ADV_SECRET_KEY) {
44
+ state.creds.advSecretKey = process.env.ADV_SECRET_KEY
45
+ }
46
+ // fetch latest version of WA Web
47
+ const { version, isLatest } = await fetchLatestBaileysVersion()
48
+ logger.debug({version: version.join('.'), isLatest}, `using latest WA version`)
49
+
50
+ const sock = makeWASocket({
51
+ version,
52
+ logger,
53
+ waWebSocketUrl: process.env.SOCKET_URL ?? DEFAULT_CONNECTION_CONFIG.waWebSocketUrl,
54
+ auth: {
55
+ creds: state.creds,
56
+ /** caching makes the store faster to send/recv messages */
57
+ keys: makeCacheableSignalKeyStore(state.keys, logger),
58
+ },
59
+ msgRetryCounterCache,
60
+ generateHighQualityLinkPreview: true,
61
+ // ignore all broadcast messages -- to receive the same
62
+ // comment the line below out
63
+ // shouldIgnoreJid: jid => isJidBroadcast(jid),
64
+ // implement to handle retries & poll updates
65
+ getMessage
66
+ })
67
+
68
+ // the process function lets you process all events that just occurred
69
+ // efficiently in a batch
70
+ sock.ev.process(
71
+ // events is a map for event name => event data
72
+ async(events) => {
73
+ // something about the connection changed
74
+ // maybe it closed, or we received all offline message or connection opened
75
+ if(events['connection.update']) {
76
+ const update = events['connection.update']
77
+ const { connection, lastDisconnect, qr } = update
78
+ if(connection === 'close') {
79
+ // reconnect if not logged out
80
+ if((lastDisconnect?.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut) {
81
+ startSock()
82
+ } else {
83
+ logger.fatal('Connection closed. You are logged out.')
84
+ }
85
+ }
86
+
87
+ if (qr) {
88
+ // Pairing code for Web clients
89
+ if (usePairingCode && !sock.authState.creds.registered) {
90
+ const phoneNumber = await question('Please enter your phone number:\n')
91
+ const code = await sock.requestPairingCode(phoneNumber)
92
+ console.log(`Pairing code: ${code}`)
93
+ }
94
+ }
95
+
96
+ logger.debug(update, 'connection update')
97
+ }
98
+
99
+ // credentials updated -- save them
100
+ if(events['creds.update']) {
101
+ await saveCreds()
102
+ logger.debug({}, 'creds save triggered')
103
+ }
104
+
105
+ if(events['labels.association']) {
106
+ logger.debug(events['labels.association'], 'labels.association event fired')
107
+ }
108
+
109
+
110
+ if(events['labels.edit']) {
111
+ logger.debug(events['labels.edit'], 'labels.edit event fired')
112
+ }
113
+
114
+ if(events['call']) {
115
+ logger.debug(events['call'], 'call event fired')
116
+ }
117
+
118
+ // history received
119
+ if(events['messaging-history.set']) {
120
+ const { chats, contacts, messages, isLatest, progress, syncType } = events['messaging-history.set']
121
+ if (syncType === proto.HistorySync.HistorySyncType.ON_DEMAND) {
122
+ logger.debug(messages, 'received on-demand history sync')
123
+ }
124
+ logger.debug({contacts: contacts.length, chats: chats.length, messages: messages.length, isLatest, progress, syncType: syncType?.toString() }, 'messaging-history.set event fired')
125
+ }
126
+
127
+ // received a new message
128
+ if (events['messages.upsert']) {
129
+ const upsert = events['messages.upsert']
130
+ logger.debug(upsert, 'messages.upsert fired')
131
+
132
+ if (!!upsert.requestId) {
133
+ logger.debug(upsert, 'placeholder request message received')
134
+ }
135
+
136
+
137
+
138
+ if (upsert.type === 'notify') {
139
+ for (const msg of upsert.messages) {
140
+ if (msg.message?.conversation || msg.message?.extendedTextMessage?.text) {
141
+ const text = msg.message?.conversation || msg.message?.extendedTextMessage?.text
142
+ if (text == "requestPlaceholder" && !upsert.requestId) {
143
+ const messageId = await sock.requestPlaceholderResend(msg.key)
144
+ logger.debug({ id: messageId }, 'requested placeholder resync')
145
+ }
146
+
147
+ // go to an old chat and send this
148
+ if (text == "onDemandHistSync") {
149
+ const messageId = await sock.fetchMessageHistory(50, msg.key, msg.messageTimestamp!)
150
+ logger.debug({ id: messageId }, 'requested on-demand history resync')
151
+ }
152
+
153
+ if (!msg.key.fromMe && doReplies && !isJidNewsletter(msg.key?.remoteJid!)) {
154
+ const id = generateMessageIDV2(sock.user?.id)
155
+ logger.debug({id, orig_id: msg.key.id }, 'replying to message')
156
+ await sock.sendMessage(msg.key.remoteJid!, { text: 'pong '+msg.key.id }, {messageId: id })
157
+ }
158
+ }
159
+ }
160
+ }
161
+ }
162
+
163
+ // messages updated like status delivered, message deleted etc.
164
+ if(events['messages.update']) {
165
+ logger.debug(events['messages.update'], 'messages.update fired')
166
+
167
+ for(const { key, update } of events['messages.update']) {
168
+ if(update.pollUpdates) {
169
+ const pollCreation: proto.IMessage = {} // get the poll creation message somehow
170
+ if(pollCreation) {
171
+ console.log(
172
+ 'got poll update, aggregation: ',
173
+ getAggregateVotesInPollMessage({
174
+ message: pollCreation,
175
+ pollUpdates: update.pollUpdates,
176
+ })
177
+ )
178
+ }
179
+ }
180
+ }
181
+ }
182
+
183
+ if(events['message-receipt.update']) {
184
+ logger.debug(events['message-receipt.update'])
185
+ }
186
+
187
+ if (events['contacts.upsert']) {
188
+ logger.debug(events['contacts.upsert'])
189
+ }
190
+
191
+ if(events['messages.reaction']) {
192
+ logger.debug(events['messages.reaction'])
193
+ }
194
+
195
+ if(events['presence.update']) {
196
+ logger.debug(events['presence.update'])
197
+ }
198
+
199
+ if(events['chats.update']) {
200
+ logger.debug(events['chats.update'])
201
+ }
202
+
203
+ if(events['contacts.update']) {
204
+ for(const contact of events['contacts.update']) {
205
+ if(typeof contact.imgUrl !== 'undefined') {
206
+ const newUrl = contact.imgUrl === null
207
+ ? null
208
+ : await sock!.profilePictureUrl(contact.id!).catch(() => null)
209
+ logger.debug({id: contact.id, newUrl}, `contact has a new profile pic` )
210
+ }
211
+ }
212
+ }
213
+
214
+ if(events['chats.delete']) {
215
+ logger.debug('chats deleted ', events['chats.delete'])
216
+ }
217
+
218
+ if(events['group.member-tag.update']) {
219
+ logger.debug('group member tag update', JSON.stringify(events['group.member-tag.update'], undefined, 2))
220
+ }
221
+ }
222
+ )
223
+
224
+ return sock
225
+
226
+ async function getMessage(key: WAMessageKey): Promise<WAMessageContent | undefined> {
227
+ // Implement a way to retreive messages that were upserted from messages.upsert
228
+ // up to you
229
+
230
+ // only if store is present
231
+ return proto.Message.create({ conversation: 'test' })
232
+ }
233
+ }
234
+
235
+ startSock()
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Rajeh Taher/WhiskeySockets
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 CHANGED
@@ -1,3 +1,44 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # Baileys
4
+
5
+ **A lightweight WhatsApp Web API library for Node.js**
6
+
7
+ ![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?style=for-the-badge&logo=typescript&logoColor=white)![JavaScript](https://img.shields.io/badge/JavaScript-F7DF1E?style=for-the-badge&logo=javascript&logoColor=black)![Node.js](https://img.shields.io/badge/Node.js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white)![npm](https://img.shields.io/badge/npm-CB3837?style=for-the-badge&logo=npm&logoColor=white)![License](https://img.shields.io/badge/License-MIT-blue?style=for-the-badge)
8
+
9
+
10
+
11
+ Made by **NotZack**
12
+ Ig: mhmmd.z.k_
13
+ Tele: @notzackfx
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ ## What is Baileys?
20
+
21
+ Baileys is a WebSocket-based library that lets you interact with WhatsApp Web without a browser. It connects as a linked device, so you can build bots, automation tools, and integrations in Node.js.
22
+
23
+
24
+ ## Features
25
+
26
+ - Send and receive text, images, video, audio, documents, and stickers
27
+ - Group, community, and channel (newsletter) management
28
+ - Pairing code and QR login
29
+ - Multi-device support
30
+ - Written in TypeScript, with full type definitions
31
+ - Custom startup banner
32
+
33
+ ## Tech Stack
34
+
35
+ | Language / Runtime | Purpose |
36
+ | --- | --- |
37
+ | TypeScript | Main source code |
38
+ | JavaScript | Compiled output (ESM) |
39
+ | Node.js | Runtime environment |
40
+
41
+ ## Installation
42
+
43
+ ```sh
44
+ npm install @ntzcofficial/baileys
@@ -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