kevinx-baileys 1.2.0 → 1.2.1

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 (151) hide show
  1. package/kevinx-baileys/CHANGELOG.md +24 -0
  2. package/{LICENSE → kevinx-baileys/LICENSE} +0 -1
  3. package/{README.md → kevinx-baileys/README.md} +25 -0
  4. package/{lib → kevinx-baileys/lib}/Socket/Client/websocket.js +9 -4
  5. package/{lib → kevinx-baileys/lib}/Socket/messages-send.js +3 -1
  6. package/{lib → kevinx-baileys/lib}/Socket/mex.js +1 -1
  7. package/{lib → kevinx-baileys/lib}/Socket/newsletter.js +94 -2
  8. package/{lib → kevinx-baileys/lib}/Socket/socket.js +14 -1
  9. package/{lib → kevinx-baileys/lib}/Store/make-cache-manager-store.js +1 -1
  10. package/{lib → kevinx-baileys/lib}/Utils/browser-utils.js +1 -0
  11. package/{lib → kevinx-baileys/lib}/index.d.ts +9 -0
  12. package/kevinx-baileys/package.json +153 -0
  13. package/kevinx-baileys/test/extras.test.mjs +187 -0
  14. package/kevinx-baileys/test/hooks.mjs +10 -0
  15. package/kevinx-baileys/test/register.mjs +2 -0
  16. package/kevinx_baileys_v1_2_1-1.2.1.tgz +0 -0
  17. package/package.json +10 -151
  18. package/CHANGELOG.md +0 -12
  19. /package/{WAProto → kevinx-baileys/WAProto}/GenerateStatics.sh +0 -0
  20. /package/{WAProto → kevinx-baileys/WAProto}/WAProto.proto +0 -0
  21. /package/{WAProto → kevinx-baileys/WAProto}/fix-imports.js +0 -0
  22. /package/{WAProto → kevinx-baileys/WAProto}/index.d.ts +0 -0
  23. /package/{WAProto → kevinx-baileys/WAProto}/index.js +0 -0
  24. /package/{engine-requirements.js → kevinx-baileys/engine-requirements.js} +0 -0
  25. /package/{lib → kevinx-baileys/lib}/Defaults/index.js +0 -0
  26. /package/{lib → kevinx-baileys/lib}/Extras/auth-mongo.js +0 -0
  27. /package/{lib → kevinx-baileys/lib}/Extras/auth-redis.js +0 -0
  28. /package/{lib → kevinx-baileys/lib}/Extras/auth-state-core.js +0 -0
  29. /package/{lib → kevinx-baileys/lib}/Extras/channel.js +0 -0
  30. /package/{lib → kevinx-baileys/lib}/Extras/extend.js +0 -0
  31. /package/{lib → kevinx-baileys/lib}/Extras/group-tools.js +0 -0
  32. /package/{lib → kevinx-baileys/lib}/Extras/index.js +0 -0
  33. /package/{lib → kevinx-baileys/lib}/Extras/kevinx-socket.js +0 -0
  34. /package/{lib → kevinx-baileys/lib}/Extras/pairing.js +0 -0
  35. /package/{lib → kevinx-baileys/lib}/Extras/send-queue.js +0 -0
  36. /package/{lib → kevinx-baileys/lib}/Extras/session-tools.js +0 -0
  37. /package/{lib → kevinx-baileys/lib}/Extras/shortcuts.js +0 -0
  38. /package/{lib → kevinx-baileys/lib}/Extras/update-check.js +0 -0
  39. /package/{lib → kevinx-baileys/lib}/Extras/utils.js +0 -0
  40. /package/{lib → kevinx-baileys/lib}/Signal/Group/ciphertext-message.js +0 -0
  41. /package/{lib → kevinx-baileys/lib}/Signal/Group/group-session-builder.js +0 -0
  42. /package/{lib → kevinx-baileys/lib}/Signal/Group/group_cipher.js +0 -0
  43. /package/{lib → kevinx-baileys/lib}/Signal/Group/index.js +0 -0
  44. /package/{lib → kevinx-baileys/lib}/Signal/Group/keyhelper.js +0 -0
  45. /package/{lib → kevinx-baileys/lib}/Signal/Group/sender-chain-key.js +0 -0
  46. /package/{lib → kevinx-baileys/lib}/Signal/Group/sender-key-distribution-message.js +0 -0
  47. /package/{lib → kevinx-baileys/lib}/Signal/Group/sender-key-message.js +0 -0
  48. /package/{lib → kevinx-baileys/lib}/Signal/Group/sender-key-name.js +0 -0
  49. /package/{lib → kevinx-baileys/lib}/Signal/Group/sender-key-record.js +0 -0
  50. /package/{lib → kevinx-baileys/lib}/Signal/Group/sender-key-state.js +0 -0
  51. /package/{lib → kevinx-baileys/lib}/Signal/Group/sender-message-key.js +0 -0
  52. /package/{lib → kevinx-baileys/lib}/Signal/libsignal.js +0 -0
  53. /package/{lib → kevinx-baileys/lib}/Signal/lid-mapping.js +0 -0
  54. /package/{lib → kevinx-baileys/lib}/Socket/Client/index.js +0 -0
  55. /package/{lib → kevinx-baileys/lib}/Socket/Client/types.js +0 -0
  56. /package/{lib → kevinx-baileys/lib}/Socket/MessageBuilder.js +0 -0
  57. /package/{lib → kevinx-baileys/lib}/Socket/business.js +0 -0
  58. /package/{lib → kevinx-baileys/lib}/Socket/chats.js +0 -0
  59. /package/{lib → kevinx-baileys/lib}/Socket/communities.js +0 -0
  60. /package/{lib → kevinx-baileys/lib}/Socket/graphql.js +0 -0
  61. /package/{lib → kevinx-baileys/lib}/Socket/groups.js +0 -0
  62. /package/{lib → kevinx-baileys/lib}/Socket/index.js +0 -0
  63. /package/{lib → kevinx-baileys/lib}/Socket/interop.js +0 -0
  64. /package/{lib → kevinx-baileys/lib}/Socket/luxu.js +0 -0
  65. /package/{lib → kevinx-baileys/lib}/Socket/message-builder.js +0 -0
  66. /package/{lib → kevinx-baileys/lib}/Socket/messages-recv.js +0 -0
  67. /package/{lib → kevinx-baileys/lib}/Socket/privacy.js +0 -0
  68. /package/{lib → kevinx-baileys/lib}/Socket/username.js +0 -0
  69. /package/{lib → kevinx-baileys/lib}/Store/index.js +0 -0
  70. /package/{lib → kevinx-baileys/lib}/Store/keyed-db.js +0 -0
  71. /package/{lib → kevinx-baileys/lib}/Store/make-in-memory-store.js +0 -0
  72. /package/{lib → kevinx-baileys/lib}/Store/make-ordered-dictionary.js +0 -0
  73. /package/{lib → kevinx-baileys/lib}/Store/object-repository.js +0 -0
  74. /package/{lib → kevinx-baileys/lib}/Types/Auth.js +0 -0
  75. /package/{lib → kevinx-baileys/lib}/Types/Bussines.js +0 -0
  76. /package/{lib → kevinx-baileys/lib}/Types/Call.js +0 -0
  77. /package/{lib → kevinx-baileys/lib}/Types/Chat.js +0 -0
  78. /package/{lib → kevinx-baileys/lib}/Types/Contact.js +0 -0
  79. /package/{lib → kevinx-baileys/lib}/Types/Events.js +0 -0
  80. /package/{lib → kevinx-baileys/lib}/Types/GroupMetadata.js +0 -0
  81. /package/{lib → kevinx-baileys/lib}/Types/Label.js +0 -0
  82. /package/{lib → kevinx-baileys/lib}/Types/LabelAssociation.js +0 -0
  83. /package/{lib → kevinx-baileys/lib}/Types/Message.js +0 -0
  84. /package/{lib → kevinx-baileys/lib}/Types/Mex.js +0 -0
  85. /package/{lib → kevinx-baileys/lib}/Types/Product.js +0 -0
  86. /package/{lib → kevinx-baileys/lib}/Types/Signal.js +0 -0
  87. /package/{lib → kevinx-baileys/lib}/Types/Socket.js +0 -0
  88. /package/{lib → kevinx-baileys/lib}/Types/State.js +0 -0
  89. /package/{lib → kevinx-baileys/lib}/Types/USync.js +0 -0
  90. /package/{lib → kevinx-baileys/lib}/Types/index.js +0 -0
  91. /package/{lib → kevinx-baileys/lib}/Utils/auth-utils.js +0 -0
  92. /package/{lib → kevinx-baileys/lib}/Utils/banner.js +0 -0
  93. /package/{lib → kevinx-baileys/lib}/Utils/business.js +0 -0
  94. /package/{lib → kevinx-baileys/lib}/Utils/chat-utils.js +0 -0
  95. /package/{lib → kevinx-baileys/lib}/Utils/companion-reg-client-utils.js +0 -0
  96. /package/{lib → kevinx-baileys/lib}/Utils/crypto.js +0 -0
  97. /package/{lib → kevinx-baileys/lib}/Utils/decode-wa-message.js +0 -0
  98. /package/{lib → kevinx-baileys/lib}/Utils/event-buffer.js +0 -0
  99. /package/{lib → kevinx-baileys/lib}/Utils/generics.js +0 -0
  100. /package/{lib → kevinx-baileys/lib}/Utils/history.js +0 -0
  101. /package/{lib → kevinx-baileys/lib}/Utils/identity-change-handler.js +0 -0
  102. /package/{lib → kevinx-baileys/lib}/Utils/index.js +0 -0
  103. /package/{lib → kevinx-baileys/lib}/Utils/link-preview.js +0 -0
  104. /package/{lib → kevinx-baileys/lib}/Utils/logger.js +0 -0
  105. /package/{lib → kevinx-baileys/lib}/Utils/lt-hash.js +0 -0
  106. /package/{lib → kevinx-baileys/lib}/Utils/make-mutex.js +0 -0
  107. /package/{lib → kevinx-baileys/lib}/Utils/message-composer.js +0 -0
  108. /package/{lib → kevinx-baileys/lib}/Utils/message-retry-manager.js +0 -0
  109. /package/{lib → kevinx-baileys/lib}/Utils/messages-media.js +0 -0
  110. /package/{lib → kevinx-baileys/lib}/Utils/messages.js +0 -0
  111. /package/{lib → kevinx-baileys/lib}/Utils/noise-handler.js +0 -0
  112. /package/{lib → kevinx-baileys/lib}/Utils/offline-node-processor.js +0 -0
  113. /package/{lib → kevinx-baileys/lib}/Utils/pre-key-manager.js +0 -0
  114. /package/{lib → kevinx-baileys/lib}/Utils/process-message.js +0 -0
  115. /package/{lib → kevinx-baileys/lib}/Utils/reporting-utils.js +0 -0
  116. /package/{lib → kevinx-baileys/lib}/Utils/signal.js +0 -0
  117. /package/{lib → kevinx-baileys/lib}/Utils/stanza-ack.js +0 -0
  118. /package/{lib → kevinx-baileys/lib}/Utils/sticker.js +0 -0
  119. /package/{lib → kevinx-baileys/lib}/Utils/sync-action-utils.js +0 -0
  120. /package/{lib → kevinx-baileys/lib}/Utils/tc-token-utils.js +0 -0
  121. /package/{lib → kevinx-baileys/lib}/Utils/use-multi-file-auth-state.js +0 -0
  122. /package/{lib → kevinx-baileys/lib}/Utils/use-sqlite-auth-state.js +0 -0
  123. /package/{lib → kevinx-baileys/lib}/Utils/validate-connection.js +0 -0
  124. /package/{lib → kevinx-baileys/lib}/WABinary/constants.js +0 -0
  125. /package/{lib → kevinx-baileys/lib}/WABinary/decode.js +0 -0
  126. /package/{lib → kevinx-baileys/lib}/WABinary/encode.js +0 -0
  127. /package/{lib → kevinx-baileys/lib}/WABinary/generic-utils.js +0 -0
  128. /package/{lib → kevinx-baileys/lib}/WABinary/index.js +0 -0
  129. /package/{lib → kevinx-baileys/lib}/WABinary/jid-utils.js +0 -0
  130. /package/{lib → kevinx-baileys/lib}/WABinary/types.js +0 -0
  131. /package/{lib → kevinx-baileys/lib}/WAM/BinaryInfo.js +0 -0
  132. /package/{lib → kevinx-baileys/lib}/WAM/constants.js +0 -0
  133. /package/{lib → kevinx-baileys/lib}/WAM/encode.js +0 -0
  134. /package/{lib → kevinx-baileys/lib}/WAM/index.js +0 -0
  135. /package/{lib → kevinx-baileys/lib}/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -0
  136. /package/{lib → kevinx-baileys/lib}/WAUSync/Protocols/USyncBusinessProtocol.js +0 -0
  137. /package/{lib → kevinx-baileys/lib}/WAUSync/Protocols/USyncContactProtocol.js +0 -0
  138. /package/{lib → kevinx-baileys/lib}/WAUSync/Protocols/USyncDeviceProtocol.js +0 -0
  139. /package/{lib → kevinx-baileys/lib}/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -0
  140. /package/{lib → kevinx-baileys/lib}/WAUSync/Protocols/USyncFeatureProtocol.js +0 -0
  141. /package/{lib → kevinx-baileys/lib}/WAUSync/Protocols/USyncLIDProtocol.js +0 -0
  142. /package/{lib → kevinx-baileys/lib}/WAUSync/Protocols/USyncPictureProtocol.js +0 -0
  143. /package/{lib → kevinx-baileys/lib}/WAUSync/Protocols/USyncSidelistProtocol.js +0 -0
  144. /package/{lib → kevinx-baileys/lib}/WAUSync/Protocols/USyncStatusProtocol.js +0 -0
  145. /package/{lib → kevinx-baileys/lib}/WAUSync/Protocols/USyncTextStatusProtocol.js +0 -0
  146. /package/{lib → kevinx-baileys/lib}/WAUSync/Protocols/USyncUsernameProtocol.js +0 -0
  147. /package/{lib → kevinx-baileys/lib}/WAUSync/Protocols/index.js +0 -0
  148. /package/{lib → kevinx-baileys/lib}/WAUSync/USyncQuery.js +0 -0
  149. /package/{lib → kevinx-baileys/lib}/WAUSync/USyncUser.js +0 -0
  150. /package/{lib → kevinx-baileys/lib}/WAUSync/index.js +0 -0
  151. /package/{lib → kevinx-baileys/lib}/index.js +0 -0
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ ## 1.2.1
4
+ - Added `sock.toLid(jid)` (single-JID shortcut returning the LID string or `null`)
5
+ - Added `sock.newsletterReactionMode(jid, mode)` (`ALL` / `BASIC` / `NONE` / `BLOCKLIST`)
6
+ - Added `sock.newsletterFetchUpdates(jid, count, after, since)` (parsed views + reaction counts)
7
+ - Added `sock.newsletterFetchMessagesDecoded(type, key, count, after)` (decrypted + parsed channel messages, supports invite keys)
8
+ - Added `Browsers.kevinx(browser)`
9
+ - Exported `wMexQuery` from `Socket/mex.js`
10
+ - Fixed `sendMessageMembers`: with `onlyMember: true` and no admin data the message was sent to 0 members (empty array is truthy); now falls back to all members
11
+ - Fixed `makeCacheManagerAuthState`: creds TTL was 63115200 *milliseconds* (~17.5 h) instead of 2 years
12
+ - Fixed raw send while the socket is still connecting: waits for the socket to open instead of failing immediately
13
+ - Fixed `WebSocketClient.send()` never calling its callback when there is no socket; connect timeout now falls back to 30 s
14
+
15
+ ## 1.2.0
16
+ - Added `makeKevinXSocket()` (auto-reconnect with backoff, no reconnect on loggedOut / replaced / forbidden)
17
+ - Added `sock.pair()`, `sock.reply()`, `sock.sendWithTyping()`, `sock.sendStatus*()`
18
+ - Added `sock.queue` / `sock.broadcast()` (random delay send queue)
19
+ - Added `backupSession`, `restoreSession`, `cleanSession`
20
+ - Added `useMongoAuthState`, `useRedisAuthState`
21
+ - Added `sock.channel.*`, built-in group metadata cache, `sock.tagAll()`, `sock.hidetag()`
22
+ - Added opt-in update check (`KEVINX_CHECK_UPDATE=true`)
23
+ - Added TypeScript typings
24
+ - New startup banner: boxed layout, diagonal gradient logo, runtime info, thanks/follow lines. `KEVINX_BANNER=compact` for one line, `false` to disable, `NO_COLOR=1` for no colours; narrow terminals get the compact one automatically
@@ -1,6 +1,5 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Rajeh Taher/WhiskeySockets (Baileys)
4
3
  Copyright (c) 2026 KevinX (https://t.me/kevinxddd) — modifications
5
4
 
6
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -155,6 +155,31 @@ await sock.sendMessage(m.chat, { text: 'KevinX Baileys' }, { ptcp: true })
155
155
 
156
156
  ---
157
157
 
158
+ ## What's new in 1.2.1
159
+
160
+ Additive again; no existing method is removed or renamed.
161
+
162
+ ```js
163
+ // PN -> LID (single value, or null)
164
+ const lid = await sock.toLid('62812xxxxxxx@s.whatsapp.net')
165
+
166
+ // Channel: who may react, and parsed views / reaction counts
167
+ await sock.newsletterReactionMode('120363...@newsletter', 'BASIC') // ALL | BASIC | NONE | BLOCKLIST
168
+ const stats = await sock.newsletterFetchUpdates('120363...@newsletter', 20)
169
+ // [{ server_id, views, reactions: [{ code, count }] }]
170
+
171
+ // Channel messages, decrypted + parsed (also works with an invite key)
172
+ const posts = await sock.newsletterFetchMessagesDecoded('invite', 'INVITE_KEY', 10)
173
+
174
+ // Browser preset
175
+ const sock = makeWASocket({ browser: Browsers.kevinx('Chrome') })
176
+
177
+ // Send to a group's members one by one (admins only when onlyMember is true)
178
+ await sock.sendMessageMembers(groupJid, { text: 'Hello' }, { delayMs: 1500, onlyMember: true })
179
+ ```
180
+
181
+ Fixes: `sendMessageMembers` no longer sends to 0 people when admin data is empty, the cache-manager auth state keeps `creds` for 2 years (the TTL was in the wrong unit), raw sends wait for a still-connecting socket, and `WebSocketClient.send()` reports an error when there is no socket. Full list in `CHANGELOG.md`.
182
+
158
183
  ## What's new in 1.2
159
184
 
160
185
  Everything below is additive. Existing code keeps working, and no existing socket method is replaced.
@@ -25,8 +25,8 @@ export class WebSocketClient extends AbstractSocketClient {
25
25
  this.socket = new WebSocket(this.url, {
26
26
  origin: DEFAULT_ORIGIN,
27
27
  headers: this.config.options?.headers,
28
- handshakeTimeout: this.config.connectTimeoutMs,
29
- timeout: this.config.connectTimeoutMs,
28
+ handshakeTimeout: this.config.connectTimeoutMs || 30000,
29
+ timeout: this.config.connectTimeoutMs || 30000,
30
30
  agent: this.config.agent
31
31
  });
32
32
  this.socket.setMaxListeners(0);
@@ -47,8 +47,13 @@ export class WebSocketClient extends AbstractSocketClient {
47
47
  this.socket = null;
48
48
  }
49
49
  send(str, cb) {
50
- this.socket?.send(str, cb);
51
- return Boolean(this.socket);
50
+ if (!this.socket) {
51
+ // no socket at all: report it instead of never calling cb (which would hang until timeout)
52
+ cb?.(new Error('WebSocket is not connected'));
53
+ return false;
54
+ }
55
+ this.socket.send(str, cb);
56
+ return true;
52
57
  }
53
58
  }
54
59
  //# sourceMappingURL=websocket.js.map
@@ -1484,7 +1484,9 @@ export const makeMessagesSocket = (config) => {
1484
1484
  const isAdmin = groupData.participants.filter((x) => x.admin !== null).map((y) => y.id);
1485
1485
  let participantJids = groupData.participants.map(z => z.id);
1486
1486
  if (onlyMember) {
1487
- participantJids = isAdmin ? isAdmin : participantJids;
1487
+ // an empty array is truthy in JS, so check .length to really fall back to all members
1488
+ // when no admin data is available (otherwise the message goes to 0 people)
1489
+ participantJids = isAdmin.length ? isAdmin : participantJids;
1488
1490
  }
1489
1491
  logger.info(`Sending message to ${participantJids.length} members from ${jid}`);
1490
1492
  for (let i = 0; i < participantJids.length; i++) {
@@ -1,7 +1,7 @@
1
1
  import { Boom } from '@hapi/boom'
2
2
  import { S_WHATSAPP_NET, getBinaryNodeChild } from '../WABinary/index.js'
3
3
 
4
- const wMexQuery = (variables, queryId, query, generateMessageTag) => {
4
+ export const wMexQuery = (variables, queryId, query, generateMessageTag) => {
5
5
  return query({
6
6
  tag: 'iq',
7
7
  attrs: {
@@ -1,6 +1,7 @@
1
1
  import * as Types from '../Types/index.js'
2
+ import { decryptMessageNode } from '../Utils/decode-wa-message.js'
2
3
  import { generateProfilePicture } from '../Utils/messages-media.js'
3
- import { getBinaryNodeChild } from '../WABinary/index.js'
4
+ import { S_WHATSAPP_NET, getAllBinaryNodeChildren, getBinaryNodeChild, getBinaryNodeChildren } from '../WABinary/index.js'
4
5
  import { makeGroupsSocket } from './groups.js'
5
6
  import { executeWMexQuery } from './mex.js'
6
7
 
@@ -38,7 +39,7 @@ const parseNewsletterMetadata = result => {
38
39
 
39
40
  export const makeNewsletterSocket = config => {
40
41
  const sock = makeGroupsSocket(config)
41
- const { query, generateMessageTag } = sock
42
+ const { query, generateMessageTag, authState, signalRepository } = sock
42
43
 
43
44
  const mexQuery = (variables, queryId, dataPath) => {
44
45
  return executeWMexQuery(variables, queryId, dataPath, query, generateMessageTag)
@@ -68,6 +69,48 @@ export const makeNewsletterSocket = config => {
68
69
  }, delay)
69
70
  })
70
71
 
72
+ /** parse the result of a `messages` / `message_updates` newsletter fetch (views, reactions, decrypted message) */
73
+ const parseFetchedUpdates = async (node, type) => {
74
+ let child
75
+ if (type === 'messages') {
76
+ child = getBinaryNodeChild(node, 'messages')
77
+ } else {
78
+ const parent = getBinaryNodeChild(node, 'message_updates')
79
+ child = getBinaryNodeChild(parent, 'messages')
80
+ }
81
+ return Promise.all(
82
+ getAllBinaryNodeChildren(child).map(async messageNode => {
83
+ messageNode.attrs.from = child?.attrs.jid
84
+ const views = parseInt(getBinaryNodeChild(messageNode, 'views_count')?.attrs?.count || '0', 10)
85
+ const reactionNode = getBinaryNodeChild(messageNode, 'reactions')
86
+ const reactions = getBinaryNodeChildren(reactionNode, 'reaction').map(({ attrs }) => ({
87
+ count: +attrs.count,
88
+ code: attrs.code
89
+ }))
90
+ const data = { server_id: messageNode.attrs.server_id, views, reactions }
91
+ if (type === 'messages') {
92
+ const { fullMessage: message, decrypt } = await decryptMessageNode(
93
+ messageNode,
94
+ authState.creds.me.id,
95
+ authState.creds.me.lid || '',
96
+ signalRepository,
97
+ config.logger
98
+ )
99
+ await decrypt()
100
+ data.message = message
101
+ }
102
+ return data
103
+ })
104
+ )
105
+ }
106
+
107
+ const newsletterIq = (to, type, content) =>
108
+ query({
109
+ tag: 'iq',
110
+ attrs: { id: generateMessageTag(), type, xmlns: 'newsletter', to },
111
+ content
112
+ })
113
+
71
114
  const newsletterUpdate = async (jid, updates) => {
72
115
  const variables = {
73
116
  newsletter_id: jid,
@@ -81,6 +124,55 @@ export const makeNewsletterSocket = config => {
81
124
 
82
125
  return {
83
126
  ...sock,
127
+ /**
128
+ * Set which reactions are allowed on a channel.
129
+ * @param {string} jid newsletter jid
130
+ * @param {'ALL'|'BASIC'|'NONE'|'BLOCKLIST'} mode reaction mode
131
+ */
132
+ newsletterReactionMode: async (jid, mode) => {
133
+ const variables = { newsletter_id: jid, updates: { settings: { reaction_codes: { value: mode } } } }
134
+ return mexQuery(variables, Types.QueryIds.UPDATE_METADATA, 'xwa2_newsletter_update')
135
+ },
136
+
137
+ /**
138
+ * Fetch message updates (views + reaction counts) of a channel, parsed.
139
+ * @returns {Promise<{ server_id: string, views: number, reactions: { count: number, code: string }[] }[]>}
140
+ */
141
+ newsletterFetchUpdates: async (jid, count, after, since) => {
142
+ const result = await newsletterIq(jid, 'get', [
143
+ {
144
+ tag: 'message_updates',
145
+ attrs: {
146
+ count: count.toString(),
147
+ after: after?.toString() || '100',
148
+ since: since?.toString() || '0'
149
+ }
150
+ }
151
+ ])
152
+ return parseFetchedUpdates(result, 'updates')
153
+ },
154
+
155
+ /**
156
+ * Fetch channel messages and return them decrypted + parsed (views, reactions, message).
157
+ * Unlike `newsletterFetchMessages` (raw node), this also accepts an invite key.
158
+ * @param {'jid'|'invite'} type
159
+ * @param {string} key newsletter jid, or invite code when type is 'invite'
160
+ */
161
+ newsletterFetchMessagesDecoded: async (type, key, count, after) => {
162
+ const result = await newsletterIq(S_WHATSAPP_NET, 'get', [
163
+ {
164
+ tag: 'messages',
165
+ attrs: {
166
+ type,
167
+ ...(type === 'invite' ? { key } : { jid: key }),
168
+ count: count.toString(),
169
+ after: after?.toString() || '100'
170
+ }
171
+ }
172
+ ])
173
+ return parseFetchedUpdates(result, 'messages')
174
+ },
175
+
84
176
  newsletterFetchAllSubscribe: async () => {
85
177
  const list = await executeWMexQuery(
86
178
  {},
@@ -57,7 +57,15 @@ export const makeSocket = (config) => {
57
57
  /** send a raw buffer */
58
58
  const sendRawMessage = async (data) => {
59
59
  if (!ws.isOpen) {
60
- throw new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed });
60
+ // socket is still connecting (e.g. right after a network hiccup): wait for it
61
+ // instead of failing immediately. waitForSocketOpen() throws 'Connection Closed'
62
+ // if the socket is already closed/closing.
63
+ if (!ws.isConnecting) {
64
+ throw new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed });
65
+ }
66
+ await promiseTimeout(connectTimeoutMs, (resolve, reject) => {
67
+ waitForSocketOpen().then(resolve, reject);
68
+ });
61
69
  }
62
70
  const bytes = noise.encodeFrame(data);
63
71
  await promiseTimeout(connectTimeoutMs, async (resolve, reject) => {
@@ -1099,6 +1107,11 @@ export const makeSocket = (config) => {
1099
1107
  fetchNewChatMessageCap,
1100
1108
  toPn,
1101
1109
  toLID,
1110
+ /** single-JID convenience: PN jid -> LID string (or null) */
1111
+ toLid: async (jid) => {
1112
+ const res = await toLID(jid);
1113
+ return res?.[0]?.lid ?? null;
1114
+ },
1102
1115
  fetchUsername,
1103
1116
  checkBan
1104
1117
  };
@@ -12,7 +12,7 @@ export default async function makeCacheManagerAuthState(store, sessionKey) {
12
12
 
13
13
  const writeData = async (file, data) => {
14
14
  let ttl = undefined;
15
- if (file === "creds") ttl = 63115200; // 2 years
15
+ if (file === "creds") ttl = 63115200 * 1000; // 2 years (cache-manager ttl is in milliseconds)
16
16
  await databaseConn.set(
17
17
  defaultKey(file),
18
18
  JSON.stringify(data, Utils_1.BufferJSON.replacer),
@@ -30,6 +30,7 @@ export const Browsers = {
30
30
  ubuntu: browser => ['Ubuntu', getBrowserN(browser), '22.04.4'],
31
31
  macOS: browser => ['Mac OS', getBrowserN(browser), '14.4.1'],
32
32
  baileys: browser => ['Baileys', getBrowserN(browser), '6.5.0'],
33
+ kevinx: browser => ['KevinX', getBrowserN(browser), '1.2.1'],
33
34
  windows: browser => ['Windows', getBrowserN(browser), '10.0.22631'],
34
35
  iOS: browser => ['iOS', getBrowserN(browser), '18.2'],
35
36
  android: browser => ['Android', getBrowserN(browser), '14.0.0'],
@@ -140,6 +140,14 @@ export interface WASocket {
140
140
  newsletterMetadata(type: 'invite' | 'jid', key: string): Promise<any>
141
141
  newsletterFollow(jid: string): Promise<any>
142
142
  newsletterReactMessage(jid: string, serverId: string, reaction?: string): Promise<void>
143
+ /** allowed reactions on a channel */
144
+ newsletterReactionMode(jid: string, mode: 'ALL' | 'BASIC' | 'NONE' | 'BLOCKLIST'): Promise<any>
145
+ /** views + reaction counts of recent channel messages (parsed) */
146
+ newsletterFetchUpdates(jid: string, count: number, after?: number | string, since?: number | string): Promise<{ server_id: string; views: number; reactions: { count: number; code: string }[] }[]>
147
+ /** channel messages, decrypted and parsed (accepts an invite key) */
148
+ newsletterFetchMessagesDecoded(type: 'jid' | 'invite', key: string, count: number, after?: number | string): Promise<{ server_id: string; views: number; reactions: { count: number; code: string }[]; message?: any }[]>
149
+ /** PN jid -> LID string (null if not found) */
150
+ toLid(jid: string): Promise<string | null>
143
151
 
144
152
  /* existing helpers (unchanged signatures) */
145
153
  sendText(jid: string, text: string, options?: object, quoted?: WAMessage | null): Promise<any>
@@ -256,6 +264,7 @@ export declare const Browsers: {
256
264
  ubuntu(browser: string): [string, string, string]
257
265
  macOS(browser: string): [string, string, string]
258
266
  baileys(browser: string): [string, string, string]
267
+ kevinx(browser: string): [string, string, string]
259
268
  windows(browser: string): [string, string, string]
260
269
  iOS(browser: string): [string, string, string]
261
270
  android(browser: string): [string, string, string]
@@ -0,0 +1,153 @@
1
+ {
2
+ "name": "kevinx-baileys",
3
+ "version": "1.2.1",
4
+ "description": "KevinX Baileys — a WebSockets library for interacting with WhatsApp Web (multi-device, pairing code, interactive messages, newsletter, auto-reconnect, send queue, typings).",
5
+ "keywords": [
6
+ "baileys",
7
+ "kevinx-baileys",
8
+ "whatsapp",
9
+ "whatsapp-baileys",
10
+ "whatsapp-bot",
11
+ "multi-device",
12
+ "auto-reconnect",
13
+ "typescript",
14
+ "whatsapp-api"
15
+ ],
16
+ "homepage": "https://t.me/kevinxddd",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://t.me/kevinxddd"
20
+ },
21
+ "bugs": {
22
+ "url": "https://t.me/kevinxddd"
23
+ },
24
+ "license": "MIT",
25
+ "author": "KevinX (https://t.me/kevinxddd)",
26
+ "type": "module",
27
+ "main": "lib/index.js",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./lib/index.d.ts",
31
+ "import": "./lib/index.js",
32
+ "default": "./lib/index.js"
33
+ },
34
+ "./WAProto": "./WAProto/index.js",
35
+ "./lib/*": "./lib/*",
36
+ "./WAProto/*": "./WAProto/*",
37
+ "./package.json": "./package.json"
38
+ },
39
+ "files": [
40
+ "lib/**/*",
41
+ "WAProto/**/*",
42
+ "engine-requirements.js",
43
+ "LICENSE",
44
+ "README.md",
45
+ "CHANGELOG.md"
46
+ ],
47
+ "scripts": {
48
+ "gen:protobuf": "sh WAProto/GenerateStatics.sh",
49
+ "preinstall": "node ./engine-requirements.js",
50
+ "test": "node --import ./test/register.mjs --test test/extras.test.mjs",
51
+ "prepublishOnly": "npm test"
52
+ },
53
+ "dependencies": {
54
+ "@cacheable/node-cache": "^1.4.0",
55
+ "@hapi/boom": "^9.1.3",
56
+ "async-mutex": "^0.5.0",
57
+ "cache-manager": "^7.2.8",
58
+ "chalk": "^4.1.2",
59
+ "fluent-ffmpeg": "^2.1.3",
60
+ "libsignal": "^6.0.0",
61
+ "lru-cache": "^11.1.0",
62
+ "music-metadata": "^11.12.3",
63
+ "p-queue": "^9.0.0",
64
+ "pino": "^9.6",
65
+ "protobufjs": "^7.5.6",
66
+ "whatsapp-rust-bridge": "0.5.4",
67
+ "ws": "^8.13.0"
68
+ },
69
+ "devDependencies": {
70
+ "@eslint/eslintrc": "^3.3.1",
71
+ "@eslint/js": "^9.31.0",
72
+ "@types/jest": "^30.0.0",
73
+ "@types/node": "^20.9.0",
74
+ "@types/ws": "^8.0.0",
75
+ "@typescript-eslint/eslint-plugin": "^8",
76
+ "@typescript-eslint/parser": "^8",
77
+ "@whiskeysockets/eslint-config": "^1.0.0",
78
+ "conventional-changelog": "^7.1.1",
79
+ "conventional-changelog-angular": "^8.0.0",
80
+ "esbuild-register": "^3.6.0",
81
+ "eslint": "^9",
82
+ "eslint-config-prettier": "^10.1.2",
83
+ "eslint-plugin-prettier": "^5.4.0",
84
+ "jest": "^30.0.5",
85
+ "jimp": "^1.6.1",
86
+ "jiti": "^2.4.2",
87
+ "json": "^11.0.0",
88
+ "link-preview-js": "^3.0.0",
89
+ "lru-cache": "^11.1.0",
90
+ "open": "^8.4.2",
91
+ "pino-pretty": "^13.1.1",
92
+ "prettier": "^3.5.3",
93
+ "protobufjs-cli": "^1.1.3",
94
+ "release-it": "^20.0.1",
95
+ "ts-jest": "^29.4.0",
96
+ "tsc-esm-fix": "^3.1.2",
97
+ "tsx": "^4.20.3",
98
+ "typedoc": "^0.27.9",
99
+ "typedoc-plugin-markdown": "4.4.2",
100
+ "typescript": "^5.8.2"
101
+ },
102
+ "peerDependencies": {
103
+ "audio-decode": "^2.1.3",
104
+ "jimp": "^1.6.1",
105
+ "link-preview-js": "^3.0.0",
106
+ "sharp": "*"
107
+ },
108
+ "peerDependenciesMeta": {
109
+ "audio-decode": {
110
+ "optional": true
111
+ },
112
+ "jimp": {
113
+ "optional": true
114
+ },
115
+ "link-preview-js": {
116
+ "optional": true
117
+ }
118
+ },
119
+ "resolutions": {
120
+ "ajv@npm:^6.12.4": "^6.14.0",
121
+ "basic-ftp": "^5.2.4",
122
+ "brace-expansion@npm:^1.1.7": "^1.1.13",
123
+ "brace-expansion@npm:^2.0.1": "^2.0.3",
124
+ "flatted": "^3.4.2",
125
+ "glob@npm:^10.2.2": "^10.5.0",
126
+ "glob@npm:^10.3.10": "^10.5.0",
127
+ "glob@npm:^10.5.0": "^10.5.0",
128
+ "handlebars": "^4.7.9",
129
+ "ip-address": "^10.1.1",
130
+ "js-yaml@npm:^3.13.1": "^3.14.2",
131
+ "js-yaml@npm:^4.1.0": "^4.1.1",
132
+ "markdown-it": "^14.1.1",
133
+ "minimatch@npm:^3.0.4": "^3.1.5",
134
+ "minimatch@npm:^3.1.2": "^3.1.5",
135
+ "minimatch@npm:^5.0.1": "^5.1.8",
136
+ "minimatch@npm:^9.0.4": "^9.0.9",
137
+ "minimatch@npm:^9.0.5": "^9.0.9",
138
+ "picomatch@npm:^2.0.4": "^2.3.2",
139
+ "picomatch@npm:^2.3.1": "^2.3.2",
140
+ "picomatch@npm:^4.0.0": "^4.0.4",
141
+ "picomatch@npm:^4.0.2": "^4.0.4",
142
+ "socks": "^2.8.8",
143
+ "tar": "^7.5.11",
144
+ "tmp": "^0.2.5",
145
+ "underscore": "^1.13.8",
146
+ "yaml@npm:^2.6.1": "^2.8.4"
147
+ },
148
+ "packageManager": "yarn@4.9.2",
149
+ "engines": {
150
+ "node": ">=20.0.0"
151
+ },
152
+ "types": "lib/index.d.ts"
153
+ }