@crysnovax/baileys 2.5.6 → 2.6.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.
- package/README.md +11 -0
- package/README.md[old] +1612 -0
- package/WAProto/index.js +14789 -3578
- package/lib/Defaults/index.js +14 -7
- package/lib/Signal/libsignal.js +40 -18
- package/lib/Socket/business.js +2 -1
- package/lib/Socket/chats.js +266 -92
- package/lib/Socket/chats.js[past] +1213 -0
- package/lib/Socket/communities.js +2 -1
- package/lib/Socket/groups.js +24 -5
- package/lib/Socket/messages-recv.js +617 -322
- package/lib/Socket/messages-send.js +160 -61
- package/lib/Socket/newsletter.js +4 -4
- package/lib/Socket/socket.js +49 -20
- package/lib/Types/{Newsletter.js → Mex.js} +10 -4
- package/lib/Types/State.js +37 -1
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +13 -1
- package/lib/Utils/chat-utils.js +81 -21
- package/lib/Utils/decode-wa-message.js +35 -1
- package/lib/Utils/index.js +1 -0
- package/lib/Utils/messages-media.js +28 -16
- package/lib/Utils/messages-media.js[past] +842 -0
- package/lib/Utils/messages.js +325 -352
- package/lib/Utils/signal.js +43 -1
- package/lib/Utils/tc-token-utils.js +150 -5
- package/lib/Utils/use-sqlite-auth-state.js +108 -0
- package/lib/WABinary/constants.js +91 -0
- package/package.json +45 -10
|
@@ -85,6 +85,7 @@ export const makeCommunitiesSocket = (config) => {
|
|
|
85
85
|
});
|
|
86
86
|
return {
|
|
87
87
|
...sock,
|
|
88
|
+
communityQuery,
|
|
88
89
|
communityMetadata,
|
|
89
90
|
communityCreate: async (subject, body) => {
|
|
90
91
|
const descriptionId = generateMessageID().substring(0, 12);
|
|
@@ -427,4 +428,4 @@ export const extractCommunityMetadata = (result) => {
|
|
|
427
428
|
addressingMode: getBinaryNodeChildString(community, 'addressing_mode')
|
|
428
429
|
};
|
|
429
430
|
return metadata;
|
|
430
|
-
};
|
|
431
|
+
};
|
package/lib/Socket/groups.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
1
2
|
import { proto } from '../../WAProto/index.js';
|
|
2
3
|
import { WAMessageAddressingMode, WAMessageStubType } from '../Types/index.js';
|
|
3
4
|
import { generateMessageIDV2, unixTimestampSeconds } from '../Utils/index.js';
|
|
@@ -38,7 +39,7 @@ export const makeGroupsSocket = (config) => {
|
|
|
38
39
|
}
|
|
39
40
|
]
|
|
40
41
|
});
|
|
41
|
-
const data =
|
|
42
|
+
const data = {};
|
|
42
43
|
const groupsChild = getBinaryNodeChild(result, 'groups');
|
|
43
44
|
if (groupsChild) {
|
|
44
45
|
const groups = getBinaryNodeChildren(groupsChild, 'group');
|
|
@@ -65,7 +66,7 @@ export const makeGroupsSocket = (config) => {
|
|
|
65
66
|
});
|
|
66
67
|
return {
|
|
67
68
|
...sock,
|
|
68
|
-
|
|
69
|
+
groupQuery,
|
|
69
70
|
groupMetadata,
|
|
70
71
|
groupCreate: async (subject, participants) => {
|
|
71
72
|
const key = generateMessageIDV2();
|
|
@@ -266,22 +267,36 @@ export const makeGroupsSocket = (config) => {
|
|
|
266
267
|
{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }
|
|
267
268
|
]);
|
|
268
269
|
},
|
|
269
|
-
groupFetchAllParticipating
|
|
270
|
-
groupQuery
|
|
270
|
+
groupFetchAllParticipating
|
|
271
271
|
};
|
|
272
272
|
};
|
|
273
273
|
export const extractGroupMetadata = (result) => {
|
|
274
274
|
const group = getBinaryNodeChild(result, 'group');
|
|
275
|
+
if (!group) {
|
|
276
|
+
// Mirror WAWeb: surface server/client errors with their code+text instead of crashing.
|
|
277
|
+
const errorNode = getBinaryNodeChild(result, 'error');
|
|
278
|
+
if (errorNode) {
|
|
279
|
+
const code = errorNode.attrs.code ? +errorNode.attrs.code : 500;
|
|
280
|
+
const text = errorNode.attrs.text || 'group metadata query failed';
|
|
281
|
+
throw new Boom(text, { statusCode: code, data: errorNode });
|
|
282
|
+
}
|
|
283
|
+
throw new Boom('Invalid group metadata response: missing <group> node', { data: result });
|
|
284
|
+
}
|
|
285
|
+
if (!group.attrs.id) {
|
|
286
|
+
throw new Boom('Invalid group metadata response: missing group id', { data: group });
|
|
287
|
+
}
|
|
275
288
|
const descChild = getBinaryNodeChild(group, 'description');
|
|
276
289
|
let desc;
|
|
277
290
|
let descId;
|
|
278
291
|
let descOwner;
|
|
279
292
|
let descOwnerPn;
|
|
293
|
+
let descOwnerUsername;
|
|
280
294
|
let descTime;
|
|
281
295
|
if (descChild) {
|
|
282
296
|
desc = getBinaryNodeChildString(descChild, 'body');
|
|
283
297
|
descOwner = descChild.attrs.participant ? jidNormalizedUser(descChild.attrs.participant) : undefined;
|
|
284
298
|
descOwnerPn = descChild.attrs.participant_pn ? jidNormalizedUser(descChild.attrs.participant_pn) : undefined;
|
|
299
|
+
descOwnerUsername = descChild.attrs.participant_username || undefined;
|
|
285
300
|
descTime = +descChild.attrs.t;
|
|
286
301
|
descId = descChild.attrs.id;
|
|
287
302
|
}
|
|
@@ -295,16 +310,19 @@ export const extractGroupMetadata = (result) => {
|
|
|
295
310
|
subject: group.attrs.subject,
|
|
296
311
|
subjectOwner: group.attrs.s_o,
|
|
297
312
|
subjectOwnerPn: group.attrs.s_o_pn,
|
|
313
|
+
subjectOwnerUsername: group.attrs.s_o_username,
|
|
298
314
|
subjectTime: +group.attrs.s_t,
|
|
299
315
|
size: group.attrs.size ? +group.attrs.size : getBinaryNodeChildren(group, 'participant').length,
|
|
300
316
|
creation: +group.attrs.creation,
|
|
301
317
|
owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
|
|
302
318
|
ownerPn: group.attrs.creator_pn ? jidNormalizedUser(group.attrs.creator_pn) : undefined,
|
|
319
|
+
ownerUsername: group.attrs.creator_username || undefined,
|
|
303
320
|
owner_country_code: group.attrs.creator_country_code,
|
|
304
321
|
desc,
|
|
305
322
|
descId,
|
|
306
323
|
descOwner,
|
|
307
324
|
descOwnerPn,
|
|
325
|
+
descOwnerUsername,
|
|
308
326
|
descTime,
|
|
309
327
|
linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
|
|
310
328
|
restrict: !!getBinaryNodeChild(group, 'locked'),
|
|
@@ -319,10 +337,11 @@ export const extractGroupMetadata = (result) => {
|
|
|
319
337
|
id: attrs.jid,
|
|
320
338
|
phoneNumber: isLidUser(attrs.jid) && isPnUser(attrs.phone_number) ? attrs.phone_number : undefined,
|
|
321
339
|
lid: isPnUser(attrs.jid) && isLidUser(attrs.lid) ? attrs.lid : undefined,
|
|
340
|
+
username: attrs.participant_username || attrs.username || undefined,
|
|
322
341
|
admin: (attrs.type || null)
|
|
323
342
|
};
|
|
324
343
|
}),
|
|
325
344
|
ephemeralDuration: eph ? +eph : undefined
|
|
326
345
|
};
|
|
327
346
|
return metadata;
|
|
328
|
-
};
|
|
347
|
+
};
|