kage-baileys 25.4.20 → 26.11.32

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.
package/README.md CHANGED
@@ -4,8 +4,8 @@
4
4
 
5
5
  # KAGE BAILEYS
6
6
 
7
- **Kage Baileys — la mejor Baileys de 2026.**
8
- API de WhatsApp Web más completa: portada de perfil (cuentas normales y Business), avatares por defecto estilo WhatsApp, botones, carruseles, Native Flows, VoIP, canales, comunidades, Meta AI, mapeo LID, álbumes, tablas, bloques de código y soporte total del protocolo. Documentación 100 % en español.
7
+ **Kage Baileys — edición de mantenimiento del 30 de noviembre de 2026.**
8
+ Motor extendido de WhatsApp Web: portada de perfil (cuentas normales y Business), avatares por defecto estilo WhatsApp, botones, carruseles, Native Flows, VoIP, canales, comunidades, Meta AI, mapeo LID, álbumes, tablas, bloques de código y soporte total del protocolo. Documentación 100 % en español.
9
9
 
10
10
  Documentación 100 % en español
11
11
 
@@ -1221,7 +1221,7 @@ await sock.sendMessage(jid, {
1221
1221
  ### Paquete de stickers
1222
1222
 
1223
1223
  > [!IMPORTANT]
1224
- > Sin `sharp` ni `@napi-rs/image`, la portada (`cover`) y los stickers deben estar ya en formato WebP.
1224
+ > Para convertir archivos que no sean WebP instala `sharp` o `@napi-rs/image`. Si los stickers y la portada ya son WebP, no necesitan conversión.
1225
1225
 
1226
1226
  ```javascript
1227
1227
  await sock.sendMessage(jid, {
@@ -1229,21 +1229,26 @@ await sock.sendMessage(jid, {
1229
1229
  name: 'Mi pack',
1230
1230
  publisher: 'kage-baileys',
1231
1231
  description: 'Descripción',
1232
+ packId: 'mi-pack-01', // opcional
1232
1233
  cover: Buffer, // Buffer de imagen
1233
1234
  stickers: [
1234
1235
  {
1235
- sticker: { url: 'https://example.com/sticker.webp' },
1236
- emojis: ['❤'], // opcional
1237
- accessibilityLabel: '', // opcional
1236
+ data: Buffer, // también se acepta la propiedad sticker
1237
+ emojis: ['❤'], // opcional
1238
+ accessibilityLabel: '', // opcional
1238
1239
  isLottie: false, // opcional
1239
1240
  isAnimated: false // opcional
1240
1241
  },
1241
- { sticker: Buffer, emojis: ['❤'] }
1242
+ { sticker: { url: 'https://example.com/sticker.webp' }, emojis: ['❤'] }
1242
1243
  ]
1243
1244
  }
1244
- })
1245
+ }, { quoted: message })
1245
1246
  ```
1246
1247
 
1248
+ El envío genera un único mensaje `stickerPackMessage`: crea el ZIP del paquete, cifra los datos, sube el archivo y la miniatura y después construye el protobuf de WhatsApp. Se admiten `data`, `sticker` o un `Buffer` directo en cada entrada.
1249
+
1250
+ Para ver los cambios de compatibilidad y sus límites, consulta [REPARACION-STICKER-PACK-ES.md](REPARACION-STICKER-PACK-ES.md) y [INFORME-INTEGRACION-ES.md](INFORME-INTEGRACION-ES.md).
1251
+
1247
1252
  ## 👁️ Opciones adicionales de mensajes
1248
1253
 
1249
1254
  ### Visualización única (view once)
@@ -117,8 +117,8 @@ export const MEDIA_HKDF_KEY_MAPPING = {
117
117
  'biz-cover-photo': 'Image'
118
118
  };
119
119
  Object.assign(MEDIA_PATH_MAP, {
120
- 'sticker-pack': '/mms/sticker',
121
- 'thumbnail-sticker-pack': '/mms/image',
120
+ 'sticker-pack': '/mms/sticker-pack',
121
+ 'thumbnail-sticker-pack': '/mms/thumbnail-sticker-pack',
122
122
  'thumbnail-link': '/mms/image',
123
123
  'thumbnail-image': '/mms/image',
124
124
  'thumbnail-video': '/mms/video',
@@ -8,8 +8,8 @@ const MEDIA_PATH_MAP = {
8
8
  document: '/mms/document',
9
9
  audio: '/mms/audio',
10
10
  sticker: '/mms/image',
11
- 'sticker-pack': '/mms/sticker',
12
- 'thumbnail-sticker-pack': '/mms/image',
11
+ 'sticker-pack': '/mms/sticker-pack',
12
+ 'thumbnail-sticker-pack': '/mms/thumbnail-sticker-pack',
13
13
  'thumbnail-link': '/mms/image',
14
14
  'product-catalog-image': '/product/image',
15
15
  'md-app-state': '',
@@ -208,6 +208,22 @@ export type AnyRegularMessageContent = (({
208
208
  body?: string;
209
209
  footer?: string;
210
210
  } | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
211
+ export type WAMessageStickerPackSticker = WAMediaUpload | {
212
+ data?: WAMediaUpload;
213
+ sticker?: WAMediaUpload;
214
+ emojis?: string[];
215
+ accessibilityLabel?: string;
216
+ isLottie?: boolean;
217
+ isAnimated?: boolean;
218
+ };
219
+ export type WAMessageStickerPack = {
220
+ name?: string;
221
+ publisher?: string;
222
+ description?: string;
223
+ packId?: string;
224
+ cover: WAMediaUpload;
225
+ stickers: WAMessageStickerPackSticker[];
226
+ };
211
227
  export type KageMessageContent =
212
228
  | { raw: proto.IMessage }
213
229
  | { audioSticker: WAMediaUpload }
@@ -216,7 +232,8 @@ export type KageMessageContent =
216
232
  | { links: unknown[]; title?: string }
217
233
  | { table: unknown; title?: string }
218
234
  | { richResponse: unknown }
219
- | { stickers: WAMediaUpload[]; name?: string; publisher?: string; description?: string; cover?: WAMediaUpload }
235
+ | ({ stickers: WAMessageStickerPackSticker[]; name?: string; publisher?: string; description?: string; packId?: string; cover: WAMediaUpload })
236
+ | { stickerPack: WAMessageStickerPack }
220
237
  | { flowReply: unknown }
221
238
  | { listReply: unknown }
222
239
  | { orderText: string }
@@ -280,12 +280,24 @@ const toBuffer = async (stream) => {
280
280
  };
281
281
  exports.toBuffer = toBuffer;
282
282
  const getStream = async (item, opts) => {
283
- if (Buffer.isBuffer(item)) {
284
- return { stream: (0, exports.toReadable)(item), type: 'buffer' };
283
+ if (item == null) {
284
+ throw new index_js_2.HttpError('No se recibió un archivo multimedia (data, sticker o cover).', { statusCode: 400 });
285
+ }
286
+ if (Buffer.isBuffer(item) || item instanceof Uint8Array) {
287
+ return { stream: (0, exports.toReadable)(Buffer.from(item)), type: 'buffer' };
288
+ }
289
+ if (typeof item !== 'object') {
290
+ throw new index_js_2.HttpError('Fuente multimedia no válida. Usa Buffer, { stream } o { url }.', { statusCode: 400 });
285
291
  }
286
292
  if ('stream' in item) {
293
+ if (!item.stream || typeof item.stream[Symbol.asyncIterator] !== 'function') {
294
+ throw new index_js_2.HttpError('La propiedad stream no contiene un flujo legible.', { statusCode: 400 });
295
+ }
287
296
  return { stream: item.stream, type: 'readable' };
288
297
  }
298
+ if (item.url == null) {
299
+ throw new index_js_2.HttpError('La fuente multimedia debe incluir url o stream.', { statusCode: 400 });
300
+ }
289
301
  const urlStr = item.url.toString();
290
302
  if (urlStr.startsWith('data:')) {
291
303
  const buffer = Buffer.from(urlStr.split(',')[1], 'base64');
@@ -251,7 +251,10 @@ const prepareProductMessage = async (message, options) => {
251
251
 
252
252
 
253
253
  const prepareStickerPackMessage = async (message, options) => {
254
- const { cover, stickers = [], name = '📦 Sticker Pack', publisher = 'GitHub: itsliaaa', description = '🏷️ kage-baileys' } = message;
254
+ if (!message || typeof message !== 'object') {
255
+ throw new index_js_2.HttpError('El contenido del paquete de stickers no es válido.', { statusCode: 400 });
256
+ }
257
+ const { cover, stickers = [], name = '📦 Sticker Pack', publisher = 'Kage Baileys', description = 'Paquete de stickers', packId } = message;
255
258
  if (stickers.length > 60) {
256
259
  throw new index_js_2.HttpError('Sticker pack exceeds the maximum limit of 60 stickers', { statusCode: 400 });
257
260
  }
@@ -267,7 +270,10 @@ const prepareStickerPackMessage = async (message, options) => {
267
270
  if (Array.isArray(stickers) && stickers.length && options.mediaCache) {
268
271
  const urls = [];
269
272
  for (let i = 0; i < stickers.length; i++) {
270
- const data = stickers[i].data;
273
+ const entry = stickers[i];
274
+ const data = Buffer.isBuffer(entry) || entry instanceof Uint8Array
275
+ ? undefined
276
+ : entry?.data ?? entry?.sticker;
271
277
  if (typeof data === 'object' && data?.url) {
272
278
  urls.push(data.url);
273
279
  }
@@ -287,14 +293,23 @@ const prepareStickerPackMessage = async (message, options) => {
287
293
  const hasSharp = 'sharp' in lib && !!lib.sharp?.default;
288
294
  const hasImage = 'image' in lib && !!lib.image?.Transformer;
289
295
  const hasJimp = 'jimp' in lib && !!lib.jimp?.Jimp;
290
- if (!hasSharp && !hasImage) {
291
- throw new index_js_2.HttpError('No image processing library (sharp or @napi-rs/image) available for converting sticker to WebP.');
296
+ if (!hasSharp && !hasImage && !hasJimp) {
297
+ throw new index_js_2.HttpError('No hay un motor de imágenes disponible. Instala sharp, @napi-rs/image o jimp.');
298
+ }
299
+ if (typeof options.upload !== 'function') {
300
+ throw new index_js_2.HttpError('El socket no proporcionó la función de subida multimedia necesaria para el paquete.', { statusCode: 500 });
292
301
  }
293
- const stickerPackIdValue = (0, generics_js_1.generateMessageIDV2)();
302
+ const stickerPackIdValue = packId ? String(packId) : (0, generics_js_1.generateMessageIDV2)();
294
303
  const stickerData = new Array(stickers.length);
295
304
  const stickerMetadata = new Array(stickers.length);
296
305
  await Promise.all(stickers.map(async (sticker, index) => {
297
- const { stream } = await (0, messages_media_js_1.getStream)(sticker.data);
306
+ const mediaSource = Buffer.isBuffer(sticker) || sticker instanceof Uint8Array
307
+ ? sticker
308
+ : sticker?.data ?? sticker?.sticker ?? (sticker?.url || sticker?.stream ? sticker : undefined);
309
+ if (mediaSource == null) {
310
+ throw new index_js_2.HttpError(`Faltan los datos del sticker ${index + 1}. Usa { data: Buffer } o { sticker: Buffer }.`, { statusCode: 400 });
311
+ }
312
+ const { stream } = await (0, messages_media_js_1.getStream)(mediaSource);
298
313
  const buffer = await (0, messages_media_js_1.toBuffer)(stream);
299
314
  let webpBuffer;
300
315
  let isAnimated = false;
@@ -308,11 +323,14 @@ const prepareStickerPackMessage = async (message, options) => {
308
323
  .webp({ quality: 80 })
309
324
  .toBuffer();
310
325
  }
311
- else {
326
+ else if (hasImage) {
312
327
  webpBuffer = await new lib.image.Transformer(buffer)
313
328
  .resize(512, 512)
314
329
  .webp(80);
315
330
  }
331
+ else {
332
+ throw new index_js_2.HttpError(`El sticker ${index + 1} no es WebP. Para convertirlo instala sharp o @napi-rs/image.`, { statusCode: 400 });
333
+ }
316
334
  if (webpBuffer.length > 1024 * 1024) {
317
335
  throw new index_js_2.HttpError(`Sticker at index ${index} exceeds the 1MB size limit`, { statusCode: 400 });
318
336
  }
@@ -346,11 +364,14 @@ const prepareStickerPackMessage = async (message, options) => {
346
364
  .webp({ quality: 80 })
347
365
  .toBuffer();
348
366
  }
349
- else {
367
+ else if (hasImage) {
350
368
  coverWebpBuffer = await new lib.image.Transformer(coverBuffer)
351
369
  .resize(512, 512)
352
370
  .webp(80);
353
371
  }
372
+ else {
373
+ throw new index_js_2.HttpError('La portada no es WebP. Para convertirla instala sharp o @napi-rs/image.', { statusCode: 400 });
374
+ }
354
375
  stickerData[stickers.length] = {
355
376
  name: trayIconFileName,
356
377
  data: coverWebpBuffer
@@ -396,7 +417,7 @@ const prepareStickerPackMessage = async (message, options) => {
396
417
  thumbnailBuffer = await new lib.image.Transformer(coverBuffer).resize(252, 252).jpeg();
397
418
  }
398
419
  else if (hasJimp) {
399
- const jimpImage = await lib.jimp.Jimp.read(coverBuffer);
420
+ const jimpImage = await lib.jimp.Jimp.read(coverWebpBuffer);
400
421
  thumbnailBuffer = await jimpImage.resize({ w: 252, h: 252 }).getBuffer('image/jpeg');
401
422
  }
402
423
  else {
@@ -784,8 +805,12 @@ const generateWAMessageContent = async (message, options) => {
784
805
  }
785
806
  }
786
807
  }
787
- else if ((0, exports.hasNonNullishProperty)(message, 'stickers')) {
788
- m.stickerPackMessage = await prepareStickerPackMessage(message, options);
808
+ else if ((0, exports.hasNonNullishProperty)(message, 'stickerPack') ||
809
+ (0, exports.hasNonNullishProperty)(message, 'stickers')) {
810
+ const stickerPackInput = message.stickerPack && typeof message.stickerPack === 'object'
811
+ ? message.stickerPack
812
+ : message;
813
+ m.stickerPackMessage = await prepareStickerPackMessage(stickerPackInput, options);
789
814
  }
790
815
  else if ((0, exports.hasNonNullishProperty)(message, 'pin')) {
791
816
  m.pinInChatMessage = {};
@@ -249,12 +249,24 @@ export const toBuffer = async (stream) => {
249
249
  return Buffer.concat(chunks);
250
250
  };
251
251
  export const getStream = async (item, opts) => {
252
- if (Buffer.isBuffer(item)) {
253
- return { stream: toReadable(item), type: 'buffer' };
252
+ if (item == null) {
253
+ throw new Boom('No se recibió un archivo multimedia (data, sticker o cover).', { statusCode: 400 });
254
+ }
255
+ if (Buffer.isBuffer(item) || item instanceof Uint8Array) {
256
+ return { stream: toReadable(Buffer.from(item)), type: 'buffer' };
257
+ }
258
+ if (typeof item !== 'object') {
259
+ throw new Boom('Fuente multimedia no válida. Usa Buffer, { stream } o { url }.', { statusCode: 400 });
254
260
  }
255
261
  if ('stream' in item) {
262
+ if (!item.stream || typeof item.stream[Symbol.asyncIterator] !== 'function') {
263
+ throw new Boom('La propiedad stream no contiene un flujo legible.', { statusCode: 400 });
264
+ }
256
265
  return { stream: item.stream, type: 'readable' };
257
266
  }
267
+ if (item.url == null) {
268
+ throw new Boom('La fuente multimedia debe incluir url o stream.', { statusCode: 400 });
269
+ }
258
270
  const urlStr = item.url.toString();
259
271
  if (urlStr.startsWith('data:')) {
260
272
  const buffer = Buffer.from(urlStr.split(',')[1], 'base64');
@@ -10,7 +10,7 @@ const loadKageMessages = () => {
10
10
 
11
11
  const kageKeys = new Set([
12
12
  'raw', 'audioSticker', 'soundSticker', 'code', 'links', 'table', 'richResponse',
13
- 'stickers', 'flowReply', 'listReply', 'orderText', 'paymentInviteServiceType',
13
+ 'stickers', 'stickerPack', 'flowReply', 'listReply', 'orderText', 'paymentInviteServiceType',
14
14
  'pollResult', 'pollUpdate', 'keep', 'buttons', 'templateButtons', 'carousel',
15
15
  'album', 'product', 'secureMetaServiceLabel', 'ai'
16
16
  ]);
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "kage-baileys",
3
3
  "type": "module",
4
- "version": "25.4.20",
5
- "description": "Kage Baileys with confirmed pairing registration state, resilient reconnect classification, hardened Native Flow review_and_pay, expanded WAProto schema and compatibility helpers",
4
+ "version": "26.11.32",
5
+ "description": "Kage Baileys: motor compatible con Baileys, mensajes interactivos, medios, paquetes nativos de stickers y extensiones Kage; documentación en español.",
6
6
  "keywords": [
7
7
  "whatsapp",
8
8
  "automation"
@@ -24,7 +24,10 @@
24
24
  "scripts/**/*",
25
25
  "README.md",
26
26
  "LICENSE",
27
- "VALIDATION-REPORT-25.4.10.md"
27
+ "VALIDATION-REPORT-25.4.10.md",
28
+ "REPARACION-STICKER-PACK-ES.md",
29
+ "INFORME-INTEGRACION-ES.md",
30
+ "PROMPT-MAESTRO-REPARACION-KAGE-ES.txt"
28
31
  ],
29
32
  "scripts": {
30
33
  "build:all": "npm run check",
@@ -36,7 +39,7 @@
36
39
  "gen:protobuf": "sh WAProto/GenerateStatics.sh",
37
40
  "lint": "node ./scripts/verify-package.mjs",
38
41
  "release": "release-it",
39
- "test": "node ./scripts/verify-pairing-flow.mjs"
42
+ "test": "node ./scripts/verify-pairing-flow.mjs && node ./scripts/verify-sticker-pack.mjs"
40
43
  },
41
44
  "dependencies": {
42
45
  "@adiwajshing/keyed-db": "^0.2.4",
@@ -0,0 +1,38 @@
1
+ import assert from 'node:assert/strict';
2
+ import { readFileSync } from 'node:fs';
3
+ import { fileURLToPath } from 'node:url';
4
+ import path from 'node:path';
5
+
6
+ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
7
+ const read = file => readFileSync(path.join(root, file), 'utf8');
8
+ const wrapper = read('lib/Utils/messages.js');
9
+ const generator = read('lib/Utils/kage-messages.cjs');
10
+ const defaults = read('lib/Defaults/index.js');
11
+ const defaultsBridge = read('lib/Defaults/media.cjs');
12
+ const media = read('lib/Utils/kage-messages-media.cjs');
13
+ const types = read('lib/Types/Message.d.ts');
14
+
15
+ assert.match(wrapper, /'stickers',\s*'stickerPack'/,
16
+ 'Nested stickerPack content must route through Kage message generator');
17
+ assert.match(generator, /hasNonNullishProperty\)\(message, 'stickerPack'\)/,
18
+ 'Kage generator must accept the nested stickerPack property');
19
+ assert.match(generator, /hasNonNullishProperty\)\(message, 'stickers'\)/,
20
+ 'Kage generator must preserve the legacy top-level stickers form');
21
+ assert.match(generator, /message\.stickerPack\s*&&\s*typeof message\.stickerPack === 'object'/,
22
+ 'Kage generator must unwrap the nested stickerPack payload');
23
+ assert.match(generator, /sticker\?\.data\s*\?\?\s*sticker\?\.sticker/,
24
+ 'Sticker input must accept both data and sticker aliases');
25
+ assert.match(defaults, /'sticker-pack': '\/mms\/sticker-pack'/,
26
+ 'Sticker pack upload route must use /mms/sticker-pack');
27
+ assert.match(defaults, /'thumbnail-sticker-pack': '\/mms\/thumbnail-sticker-pack'/,
28
+ 'Sticker pack thumbnail route must use /mms/thumbnail-sticker-pack');
29
+ assert.match(defaultsBridge, /'sticker-pack': '\/mms\/sticker-pack'/,
30
+ 'CJS media bridge must match the sticker pack route');
31
+ assert.match(defaults, /'thumbnail-sticker-pack': 'Sticker Pack Thumbnail'/,
32
+ 'Sticker pack thumbnail must use its dedicated HKDF label');
33
+ assert.match(media, /if \(item == null\)/,
34
+ 'getStream must reject undefined media before the in-operator');
35
+ assert.match(types, /\{ stickerPack: WAMessageStickerPack \}/,
36
+ 'TypeScript must expose nested stickerPack content');
37
+
38
+ console.log('Paquetes nativos de stickers: 11 comprobaciones estáticas aprobadas.');