kage-baileys 3.0.6 → 3.2.4

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 (217) hide show
  1. package/Example/connection.cjs +4 -0
  2. package/README.MD +4726 -48
  3. package/README.md +5941 -0
  4. package/WAProto/WAProto.proto +3395 -415
  5. package/WAProto/compat.cjs +12 -0
  6. package/WAProto/index.d.ts +47104 -19888
  7. package/WAProto/index.js +131979 -57361
  8. package/lib/Addon/http-error.js +43 -0
  9. package/lib/Addon/index.js +32 -0
  10. package/lib/Addon/keyed-db.js +250 -0
  11. package/lib/Addon/link-preview.js +82 -0
  12. package/lib/Defaults/baileys-version.json +3 -0
  13. package/lib/Defaults/connection.js +110 -0
  14. package/lib/Defaults/constants.js +156 -0
  15. package/lib/Defaults/history.js +46 -0
  16. package/lib/Defaults/index.js +230 -0
  17. package/lib/Defaults/media.js +104 -0
  18. package/lib/Defaults/phonenumber-mcc.json +223 -0
  19. package/lib/Defaults/prefix.js +44 -0
  20. package/lib/Extensions/business-advanced.js +382 -0
  21. package/lib/Extensions/business.js +159 -0
  22. package/lib/Extensions/chats-advanced.js +1106 -0
  23. package/lib/Extensions/chats.js +349 -0
  24. package/lib/Extensions/communities-advanced.js +430 -0
  25. package/lib/Extensions/community.js +94 -0
  26. package/lib/Extensions/groups-advanced.js +343 -0
  27. package/lib/Extensions/index.js +30 -0
  28. package/lib/Extensions/messages-recv-advanced.js +1690 -0
  29. package/lib/Extensions/messages-send-advanced.js +622 -0
  30. package/lib/Extensions/messages-send.js +1380 -0
  31. package/lib/Extensions/newsletter-advanced.js +228 -0
  32. package/lib/Extensions/newsletter.js +72 -0
  33. package/lib/Extensions/socket.js +389 -0
  34. package/lib/Modded/message_builder.js +2084 -4
  35. package/lib/Signal/Group/ciphertext-message.js +54 -0
  36. package/lib/Signal/Group/group-session-builder.js +124 -0
  37. package/lib/Signal/Group/group_cipher.js +216 -0
  38. package/lib/Signal/Group/index.js +124 -0
  39. package/lib/Signal/Group/keyhelper.js +108 -0
  40. package/lib/Signal/Group/sender-chain-key.js +83 -0
  41. package/lib/Signal/Group/sender-key-distribution-message.js +157 -0
  42. package/lib/Signal/Group/sender-key-message.js +166 -0
  43. package/lib/Signal/Group/sender-key-name.js +130 -0
  44. package/lib/Signal/Group/sender-key-record.js +113 -0
  45. package/lib/Signal/Group/sender-key-state.js +208 -0
  46. package/lib/Signal/Group/sender-message-key.js +82 -0
  47. package/lib/Signal/libsignal.js +935 -0
  48. package/lib/Signal/lid-mapping.js +545 -1
  49. package/lib/Socket/Client/index.js +60 -0
  50. package/lib/Socket/Client/types.js +51 -0
  51. package/lib/Socket/Client/websocket.js +152 -0
  52. package/lib/Socket/business.js +831 -0
  53. package/lib/Socket/chats.js +2535 -49
  54. package/lib/Socket/communities.js +450 -1
  55. package/lib/Socket/community.js +1022 -0
  56. package/lib/Socket/dugong.js +1 -1
  57. package/lib/Socket/groups.js +747 -0
  58. package/lib/Socket/index.js +60 -2
  59. package/lib/Socket/messages-recv.js +3450 -5
  60. package/lib/Socket/messages-send.js +3123 -0
  61. package/lib/Socket/mex.js +126 -1
  62. package/lib/Socket/newsletter.js +465 -0
  63. package/lib/Socket/socket.js +2217 -1
  64. package/lib/Store/index.js +79 -0
  65. package/lib/Store/make-cache-manager-store.js +186 -0
  66. package/lib/Store/make-in-memory-store.js +878 -0
  67. package/lib/Store/make-ordered-dictionary.js +187 -0
  68. package/lib/Store/object-repository.js +78 -0
  69. package/lib/Types/Auth.js +25 -0
  70. package/lib/Types/Bussines.js +25 -1
  71. package/lib/Types/Call.js +25 -0
  72. package/lib/Types/Chat.js +39 -0
  73. package/lib/Types/Contact.js +25 -0
  74. package/lib/Types/Events.js +25 -0
  75. package/lib/Types/GroupMetadata.js +25 -0
  76. package/lib/Types/Label.js +76 -0
  77. package/lib/Types/LabelAssociation.js +40 -0
  78. package/lib/Types/Message.js +57 -0
  79. package/lib/Types/Mex.js +56 -1
  80. package/lib/Types/MexUpdates.js +46 -0
  81. package/lib/Types/Newsletter.js +56 -0
  82. package/lib/Types/Product.js +25 -0
  83. package/lib/Types/RichType.js +23 -0
  84. package/lib/Types/Signal.js +25 -0
  85. package/lib/Types/Socket.js +25 -0
  86. package/lib/Types/State.js +92 -0
  87. package/lib/Types/USync.js +25 -0
  88. package/lib/Types/index.js +133 -0
  89. package/lib/Utils/auth-utils.js +703 -0
  90. package/lib/Utils/automation-tools.js +51 -16
  91. package/lib/Utils/baileys-event-stream.js +146 -0
  92. package/lib/Utils/browser-utils.js +95 -0
  93. package/lib/Utils/business.js +525 -0
  94. package/lib/Utils/chat-utils.js +1861 -0
  95. package/lib/Utils/companion-reg-client-utils.js +55 -1
  96. package/lib/Utils/crypto.js +355 -0
  97. package/lib/Utils/decode-wa-message.js +709 -0
  98. package/lib/Utils/event-buffer.js +1323 -8
  99. package/lib/Utils/generics.js +945 -1
  100. package/lib/Utils/history.js +266 -0
  101. package/lib/Utils/identity-change-handler.js +62 -1
  102. package/lib/Utils/index.js +114 -0
  103. package/lib/Utils/link-preview.js +179 -0
  104. package/lib/Utils/logger.js +42 -0
  105. package/lib/Utils/lt-hash.js +73 -0
  106. package/lib/Utils/make-mutex.js +104 -0
  107. package/lib/Utils/message-inspector.js +110 -0
  108. package/lib/Utils/message-retry-manager.js +507 -2
  109. package/lib/Utils/messages-media.js +1931 -1
  110. package/lib/Utils/messages.js +3748 -0
  111. package/lib/Utils/noise-handler.js +423 -0
  112. package/lib/Utils/offline-node-processor.js +53 -1
  113. package/lib/Utils/pre-key-manager.js +255 -1
  114. package/lib/Utils/process-message.js +1592 -0
  115. package/lib/Utils/reporting-utils.js +272 -1
  116. package/lib/Utils/rich-message-utils.js +377 -0
  117. package/lib/Utils/rich-messages.js +1 -1
  118. package/lib/Utils/signal.js +437 -0
  119. package/lib/Utils/stanza-ack.js +51 -1
  120. package/lib/Utils/status-refresh.js +37 -0
  121. package/lib/Utils/status-tools.js +4 -2
  122. package/lib/Utils/sync-action-utils.js +63 -1
  123. package/lib/Utils/tc-token-utils.js +185 -1
  124. package/lib/Utils/terminal-banner.js +31 -0
  125. package/lib/Utils/use-multi-file-auth-state.js +271 -0
  126. package/lib/Utils/use-single-file-auth-state.js +108 -0
  127. package/lib/Utils/use-sqlite-auth-state.js +142 -0
  128. package/lib/Utils/validate-connection.js +497 -1
  129. package/lib/Utils/view-once-compat.js +13 -5
  130. package/lib/VoIP/audio-feeder.js +150 -0
  131. package/lib/VoIP/index.js +289 -0
  132. package/lib/VoIP/relay-transport.js +608 -0
  133. package/lib/VoIP/signaling.js +583 -0
  134. package/lib/VoIP/types.js +30 -0
  135. package/lib/VoIP/wasm-engine.js +1261 -2
  136. package/lib/VoIP/worker-bootstrap.js +1090 -2
  137. package/lib/WABinary/constants.js +2805 -0
  138. package/lib/WABinary/decode.js +649 -2
  139. package/lib/WABinary/encode.js +564 -2
  140. package/lib/WABinary/generic-utils.js +401 -0
  141. package/lib/WABinary/index.js +82 -0
  142. package/lib/WABinary/jid-utils.js +290 -0
  143. package/lib/WABinary/types.js +25 -0
  144. package/lib/WAM/BinaryInfo.js +50 -0
  145. package/lib/WAM/constants.js +45747 -0
  146. package/lib/WAM/encode.js +393 -0
  147. package/lib/WAM/index.js +78 -0
  148. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +135 -0
  149. package/lib/WAUSync/Protocols/USyncContactProtocol.js +110 -0
  150. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +142 -0
  151. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +85 -0
  152. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +69 -0
  153. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +107 -0
  154. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +38 -1
  155. package/lib/WAUSync/Protocols/index.js +83 -0
  156. package/lib/WAUSync/USyncQuery.js +241 -2
  157. package/lib/WAUSync/USyncUser.js +86 -0
  158. package/lib/WAUSync/index.js +78 -0
  159. package/lib/assets/wasm/loader.js +1875 -1
  160. package/lib/assets/wasm/worker-modules.js +11047 -1
  161. package/lib/index.d.ts +126 -0
  162. package/lib/index.js +53 -21
  163. package/lib/index.mjs +437 -0
  164. package/licenses/upstream-MIT.txt +22 -0
  165. package/maintenance/api-coverage.json +1642 -0
  166. package/maintenance/archivos-sha256.json +207 -0
  167. package/maintenance/consumer-validation.log +3 -0
  168. package/maintenance/dependency-audit.json +4 -4
  169. package/maintenance/extension-inventory.json +57 -0
  170. package/maintenance/protocol-update.json +1101 -0
  171. package/maintenance/protocol-wire-audit.json +4 -0
  172. package/maintenance/reference-socket-surface.json +209 -0
  173. package/maintenance/resumen-validacion.json +50 -0
  174. package/maintenance/validation.log +2725 -0
  175. package/maintenance/verification.json +566 -0
  176. package/package.json +107 -9
  177. package/scripts/check-imports.cjs +10 -0
  178. package/scripts/check-package.cjs +40 -0
  179. package/scripts/check-syntax.cjs +1 -1
  180. package/scripts/generate-protobuf.cjs +6 -1
  181. package/scripts/generate-public-types.cjs +9 -0
  182. package/scripts/kage-base64-fix.cjs +45 -0
  183. package/scripts/maintenance.cjs +10 -0
  184. package/test/advanced.test.cjs +24 -0
  185. package/test/base64-fix.test.cjs +49 -0
  186. package/test/maintenance.test.cjs +1 -1
  187. package/test/npm-publication.test.cjs +141 -0
  188. package/test/recepcion-reparada.test.cjs +98 -0
  189. package/test/resilience-binary.test.cjs +69 -0
  190. package/test/resilience-transport.test.cjs +34 -0
  191. package/test/types.test.ts +5 -0
  192. package/test/upgrade.test.cjs +104 -0
  193. package/tsconfig.json +20 -0
  194. package/WAProto/p.html +0 -1
  195. package/lib/KageExtra/Modded/message_builder.js +0 -2330
  196. package/lib/KageExtra/VoIP/audio-feeder.js +0 -136
  197. package/lib/KageExtra/VoIP/index.js +0 -282
  198. package/lib/KageExtra/VoIP/relay-transport.js +0 -559
  199. package/lib/KageExtra/VoIP/signaling.js +0 -603
  200. package/lib/KageExtra/VoIP/types.js +0 -17
  201. package/lib/KageExtra/VoIP/wasm-engine.js +0 -1214
  202. package/lib/KageExtra/VoIP/worker-bootstrap.js +0 -1042
  203. package/lib/KageExtra/assets/wasm/loader.js +0 -5
  204. package/lib/KageExtra/assets/wasm/whatsapp.wasm +0 -0
  205. package/lib/KageExtra/assets/wasm/worker-modules.js +0 -273
  206. package/lib/KageExtra/index.js +0 -3
  207. package/lib/KageExtra/package.json +0 -1
  208. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -53
  209. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -24
  210. package/maintenance/revision-full-check.txt +0 -1097
  211. package/maintenance/revision-library-tests.tap +0 -1088
  212. package/maintenance/revision-protobuf.txt +0 -5
  213. package/maintenance/revision-syntax.txt +0 -5
  214. package/maintenance/schema-coverage.json +0 -23
  215. package/maintenance/schema-merge.json +0 -30
  216. package/maintenance/validation-node20.txt +0 -191
  217. package/maintenance/validation-node22.txt +0 -237
@@ -103,4 +103,258 @@
103
103
  });
104
104
  }
105
105
  } exports.PreKeyManager = PreKeyManager;
106
- //# sourceMappingURL=pre-key-manager.js.map
106
+ //#
107
+ // Kage: compatibilidad de API.
108
+ const __kageModule76 = (() => {
109
+ const module = { exports: {} }; const exports = module.exports;
110
+ "use strict"
111
+
112
+ Object.defineProperty(exports, "__esModule", { value: true })
113
+
114
+ const { default: PQueue } = require("p-queue")
115
+
116
+ /**
117
+ * Manages pre-key operations with proper concurrency control
118
+ */
119
+ class PreKeyManager {
120
+ constructor(store, logger) {
121
+ this.store = store
122
+ this.logger = logger
123
+ this.queues = new Map()
124
+ }
125
+
126
+ /**
127
+ * Get or create a queue for a specific key type
128
+ */
129
+ getQueue(keyType) {
130
+ if (!this.queues.has(keyType)) {
131
+ this.queues.set(keyType, new PQueue({ concurrency: 1 }))
132
+ }
133
+ return this.queues.get(keyType)
134
+ }
135
+
136
+ /**
137
+ * Process pre-key operations (updates and deletions)
138
+ */
139
+ async processOperations(data, keyType, transactionCache, mutations, isInTransaction) {
140
+ const keyData = data[keyType]
141
+
142
+ if (!keyData) return
143
+
144
+ return this.getQueue(keyType).add(async () => {
145
+ // Ensure structures exist
146
+ transactionCache[keyType] = transactionCache[keyType] || {}
147
+ mutations[keyType] = mutations[keyType] || {}
148
+
149
+ // Separate deletions from updates
150
+ const deletions = []
151
+ const updates = {}
152
+
153
+ for (const keyId in keyData) {
154
+ if (keyData[keyId] === null) {
155
+ deletions.push(keyId)
156
+ }
157
+ else {
158
+ updates[keyId] = keyData[keyId]
159
+ }
160
+ }
161
+
162
+ // Process updates (no validation needed)
163
+ if (Object.keys(updates).length > 0) {
164
+ Object.assign(transactionCache[keyType], updates)
165
+ Object.assign(mutations[keyType], updates)
166
+ }
167
+
168
+ // Process deletions with validation
169
+ if (deletions.length > 0) {
170
+ await this.processDeletions(keyType, deletions, transactionCache, mutations, isInTransaction)
171
+ }
172
+ })
173
+ }
174
+
175
+ /**
176
+ * Process deletions with validation
177
+ */
178
+ async processDeletions(keyType, ids, transactionCache, mutations, isInTransaction) {
179
+ if (isInTransaction) {
180
+ // In transaction, only allow deletion if key exists in cache
181
+ for (const keyId of ids) {
182
+ if (transactionCache[keyType]?.[keyId]) {
183
+ transactionCache[keyType][keyId] = null
184
+ mutations[keyType][keyId] = null
185
+ }
186
+ else {
187
+ this.logger.warn(`Skipping deletion of non-existent ${keyType} in transaction: ${keyId}`)
188
+ }
189
+ }
190
+ }
191
+ else {
192
+ // Outside transaction, validate against store
193
+ const existingKeys = await this.store.get(keyType, ids)
194
+ for (const keyId of ids) {
195
+ if (existingKeys[keyId]) {
196
+ transactionCache[keyType][keyId] = null
197
+ mutations[keyType][keyId] = null
198
+ }
199
+ else {
200
+ this.logger.warn(`Skipping deletion of non-existent ${keyType}: ${keyId}`)
201
+ }
202
+ }
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Validate and process pre-key deletions outside transactions
208
+ */
209
+ async validateDeletions(data, keyType) {
210
+ const keyData = data[keyType]
211
+
212
+ if (!keyData) return
213
+
214
+ return this.getQueue(keyType).add(async () => {
215
+ // Find all deletion requests
216
+ const deletionIds = Object.keys(keyData).filter(id => keyData[id] === null)
217
+
218
+ if (deletionIds.length === 0) return
219
+
220
+ // Validate deletions
221
+ const existingKeys = await this.store.get(keyType, deletionIds)
222
+
223
+ for (const keyId of deletionIds) {
224
+ if (!existingKeys[keyId]) {
225
+ this.logger.warn(`Skipping deletion of non-existent ${keyType}: ${keyId}`)
226
+ delete data[keyType][keyId]
227
+ }
228
+ }
229
+ })
230
+ }
231
+ }
232
+
233
+ module.exports = {
234
+ PreKeyManager
235
+ }
236
+ return module.exports;
237
+ })();
238
+ for (const key of Object.keys(__kageModule76)) {
239
+ if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule76[key]});
240
+ }
241
+
242
+ // Kage: funciones avanzadas.
243
+ const __kageModule181 = (() => {
244
+ const module = { exports: {} }; const exports = module.exports;
245
+ "use strict";
246
+ Object.defineProperty(exports, "__esModule", { value: true });
247
+ exports.PreKeyManager = void 0;
248
+ const index_js_1 = require("../Addon/index.js");
249
+ /**
250
+ * Manages pre-key operations with proper concurrency control
251
+ */
252
+ class PreKeyManager {
253
+ constructor(store, logger) {
254
+ this.store = store;
255
+ this.logger = logger;
256
+ this.queues = new Map();
257
+ }
258
+ /**
259
+ * Get or create a queue for a specific key type
260
+ */
261
+ getQueue(keyType) {
262
+ if (!this.queues.has(keyType)) {
263
+ this.queues.set(keyType, (0, index_js_1.createQueue)(1));
264
+ }
265
+ return this.queues.get(keyType);
266
+ }
267
+ /**
268
+ * Process pre-key operations (updates and deletions)
269
+ */
270
+ async processOperations(data, keyType, transactionCache, mutations, isInTransaction) {
271
+ const keyData = data[keyType];
272
+ if (!keyData)
273
+ return;
274
+ return this.getQueue(keyType).add(async () => {
275
+ // Ensure structures exist
276
+ transactionCache[keyType] = transactionCache[keyType] || {};
277
+ mutations[keyType] = mutations[keyType] || {};
278
+ // Separate deletions from updates
279
+ const deletions = [];
280
+ const updates = {};
281
+ for (const keyId in keyData) {
282
+ if (keyData[keyId] === null) {
283
+ deletions.push(keyId);
284
+ }
285
+ else {
286
+ updates[keyId] = keyData[keyId];
287
+ }
288
+ }
289
+ // Process updates (no validation needed)
290
+ if (Object.keys(updates).length > 0) {
291
+ Object.assign(transactionCache[keyType], updates);
292
+ Object.assign(mutations[keyType], updates);
293
+ }
294
+ // Process deletions with validation
295
+ if (deletions.length > 0) {
296
+ await this.processDeletions(keyType, deletions, transactionCache, mutations, isInTransaction);
297
+ }
298
+ });
299
+ }
300
+ /**
301
+ * Process deletions with validation
302
+ */
303
+ async processDeletions(keyType, ids, transactionCache, mutations, isInTransaction) {
304
+ if (isInTransaction) {
305
+ // In transaction, only allow deletion if key exists in cache
306
+ for (const keyId of ids) {
307
+ if (transactionCache[keyType]?.[keyId]) {
308
+ transactionCache[keyType][keyId] = null;
309
+ mutations[keyType][keyId] = null;
310
+ }
311
+ else {
312
+ this.logger.warn(`Skipping deletion of non-existent ${keyType} in transaction: ${keyId}`);
313
+ }
314
+ }
315
+ }
316
+ else {
317
+ // Outside transaction, validate against store
318
+ const existingKeys = await this.store.get(keyType, ids);
319
+ for (const keyId of ids) {
320
+ if (existingKeys[keyId]) {
321
+ transactionCache[keyType][keyId] = null;
322
+ mutations[keyType][keyId] = null;
323
+ }
324
+ else {
325
+ this.logger.warn(`Skipping deletion of non-existent ${keyType}: ${keyId}`);
326
+ }
327
+ }
328
+ }
329
+ }
330
+ /**
331
+ * Validate and process pre-key deletions outside transactions
332
+ */
333
+ async validateDeletions(data, keyType) {
334
+ const keyData = data[keyType];
335
+ if (!keyData)
336
+ return;
337
+ return this.getQueue(keyType).add(async () => {
338
+ // Find all deletion requests
339
+ const deletionIds = Object.keys(keyData).filter(id => keyData[id] === null);
340
+ if (deletionIds.length === 0)
341
+ return;
342
+ // Validate deletions
343
+ const existingKeys = await this.store.get(keyType, deletionIds);
344
+ for (const keyId of deletionIds) {
345
+ if (!existingKeys[keyId]) {
346
+ this.logger.warn(`Skipping deletion of non-existent ${keyType}: ${keyId}`);
347
+ delete data[keyType][keyId];
348
+ }
349
+ }
350
+ });
351
+ }
352
+ }
353
+ exports.PreKeyManager = PreKeyManager;
354
+
355
+ return module.exports;
356
+ })();
357
+ for (const key of Object.keys(__kageModule181)) {
358
+ if (key !== '__esModule' && !Object.prototype.hasOwnProperty.call(exports,key)) Object.defineProperty(exports,key,{enumerable:true,configurable:true,get:()=>__kageModule181[key]});
359
+ }
360
+ Object.defineProperty(exports, Symbol.for('kage.advanced'), {value:__kageModule181, configurable:true});