@ubedsockets/baileys 1.6.6 → 1.6.7

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 (87) hide show
  1. package/WAProto/GenerateStatics.sh +4 -3
  2. package/WAProto/WAProto.proto +511 -1215
  3. package/WAProto/index.js +131318 -59331
  4. package/lib/Defaults/index.js +92 -76
  5. package/lib/Signal/Group/ciphertext-message.js +5 -2
  6. package/lib/Signal/Group/group-session-builder.js +41 -7
  7. package/lib/Signal/Group/group_cipher.js +51 -37
  8. package/lib/Signal/Group/index.js +57 -12
  9. package/lib/Signal/Group/keyhelper.js +44 -7
  10. package/lib/Signal/Group/sender-chain-key.js +15 -7
  11. package/lib/Signal/Group/sender-key-distribution-message.js +11 -8
  12. package/lib/Signal/Group/sender-key-message.js +12 -9
  13. package/lib/Signal/Group/sender-key-name.js +5 -2
  14. package/lib/Signal/Group/sender-key-record.js +21 -9
  15. package/lib/Signal/Group/sender-key-state.js +42 -27
  16. package/lib/Signal/Group/sender-message-key.js +7 -4
  17. package/lib/Signal/libsignal.js +90 -347
  18. package/lib/Socket/Client/index.js +18 -3
  19. package/lib/Socket/Client/types.js +6 -4
  20. package/lib/Socket/Client/websocket.js +78 -21
  21. package/lib/Socket/business.js +43 -162
  22. package/lib/Socket/chats.js +249 -571
  23. package/lib/Socket/groups.js +99 -114
  24. package/lib/Socket/index.js +9 -11
  25. package/lib/Socket/messages-recv.js +559 -1277
  26. package/lib/Socket/messages-send.js +669 -674
  27. package/lib/Socket/newsletter.js +286 -149
  28. package/lib/Socket/socket.js +235 -548
  29. package/lib/Types/Auth.js +2 -2
  30. package/lib/Types/Call.js +2 -2
  31. package/lib/Types/Chat.js +4 -8
  32. package/lib/Types/Contact.js +2 -2
  33. package/lib/Types/Events.js +2 -2
  34. package/lib/Types/GroupMetadata.js +2 -2
  35. package/lib/Types/Label.js +5 -3
  36. package/lib/Types/LabelAssociation.js +5 -3
  37. package/lib/Types/Message.js +7 -11
  38. package/lib/Types/Product.js +2 -2
  39. package/lib/Types/Signal.js +2 -2
  40. package/lib/Types/Socket.js +2 -3
  41. package/lib/Types/State.js +2 -56
  42. package/lib/Types/USync.js +2 -2
  43. package/lib/Types/index.js +31 -15
  44. package/lib/Utils/auth-utils.js +136 -239
  45. package/lib/Utils/business.js +69 -66
  46. package/lib/Utils/chat-utils.js +238 -380
  47. package/lib/Utils/crypto.js +127 -56
  48. package/lib/Utils/decode-wa-message.js +63 -173
  49. package/lib/Utils/event-buffer.js +70 -174
  50. package/lib/Utils/generics.js +207 -159
  51. package/lib/Utils/history.js +53 -93
  52. package/lib/Utils/index.js +33 -22
  53. package/lib/Utils/link-preview.js +58 -17
  54. package/lib/Utils/logger.js +7 -3
  55. package/lib/Utils/lt-hash.js +46 -3
  56. package/lib/Utils/make-mutex.js +34 -24
  57. package/lib/Utils/messages-media.js +744 -483
  58. package/lib/Utils/messages.js +621 -411
  59. package/lib/Utils/noise-handler.js +99 -149
  60. package/lib/Utils/process-message.js +150 -459
  61. package/lib/Utils/signal.js +73 -112
  62. package/lib/Utils/use-multi-file-auth-state.js +27 -23
  63. package/lib/Utils/validate-connection.js +104 -74
  64. package/lib/WABinary/constants.js +11 -9
  65. package/lib/WABinary/decode.js +52 -49
  66. package/lib/WABinary/encode.js +49 -19
  67. package/lib/WABinary/generic-utils.js +43 -46
  68. package/lib/WABinary/index.js +21 -6
  69. package/lib/WABinary/jid-utils.js +45 -72
  70. package/lib/WABinary/types.js +2 -2
  71. package/lib/WAM/BinaryInfo.js +5 -2
  72. package/lib/WAM/constants.js +11958 -19461
  73. package/lib/WAM/encode.js +22 -17
  74. package/lib/WAM/index.js +19 -4
  75. package/lib/WAUSync/Protocols/USyncContactProtocol.js +13 -33
  76. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +14 -11
  77. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +11 -8
  78. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +13 -9
  79. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +22 -20
  80. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +8 -13
  81. package/lib/WAUSync/Protocols/index.js +20 -6
  82. package/lib/WAUSync/USyncQuery.js +35 -44
  83. package/lib/WAUSync/USyncUser.js +5 -10
  84. package/lib/WAUSync/index.js +19 -4
  85. package/lib/index.js +70 -11
  86. package/package.json +60 -100
  87. package/engine-requirements.js +0 -10
@@ -1,24 +1,26 @@
1
- import { Boom } from '@hapi/boom';
2
- import { proto } from '../../WAProto/index.js';
3
- import { WAMessageAddressingMode, WAMessageStubType } from '../Types/index.js';
4
- import { generateMessageIDV2, unixTimestampSeconds } from '../Utils/index.js';
5
- import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString, isLidUser, isPnUser, jidEncode, jidNormalizedUser } from '../WABinary/index.js';
6
- import { makeChatsSocket } from './chats.js';
7
- export const makeGroupsSocket = (config) => {
8
- const sock = makeChatsSocket(config);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractGroupMetadata = exports.makeGroupsSocket = void 0;
4
+ const WAProto_1 = require("../../WAProto");
5
+ const Types_1 = require("../Types");
6
+ const Utils_1 = require("../Utils");
7
+ const WABinary_1 = require("../WABinary");
8
+ const chats_1 = require("./chats");
9
+ const makeGroupsSocket = (config) => {
10
+ const sock = (0, chats_1.makeChatsSocket)(config);
9
11
  const { authState, ev, query, upsertMessage } = sock;
10
- const groupQuery = async (jid, type, content) => query({
12
+ const groupQuery = async (jid, type, content) => (query({
11
13
  tag: 'iq',
12
14
  attrs: {
13
15
  type,
14
16
  xmlns: 'w:g2',
15
- to: jid
17
+ to: jid,
16
18
  },
17
19
  content
18
- });
20
+ }));
19
21
  const groupMetadata = async (jid) => {
20
22
  const result = await groupQuery(jid, 'get', [{ tag: 'query', attrs: { request: 'interactive' } }]);
21
- return extractGroupMetadata(result);
23
+ return (0, exports.extractGroupMetadata)(result);
22
24
  };
23
25
  const groupFetchAllParticipating = async () => {
24
26
  const result = await query({
@@ -26,7 +28,7 @@ export const makeGroupsSocket = (config) => {
26
28
  attrs: {
27
29
  to: '@g.us',
28
30
  xmlns: 'w:g2',
29
- type: 'get'
31
+ type: 'get',
30
32
  },
31
33
  content: [
32
34
  {
@@ -40,11 +42,11 @@ export const makeGroupsSocket = (config) => {
40
42
  ]
41
43
  });
42
44
  const data = {};
43
- const groupsChild = getBinaryNodeChild(result, 'groups');
45
+ const groupsChild = (0, WABinary_1.getBinaryNodeChild)(result, 'groups');
44
46
  if (groupsChild) {
45
- const groups = getBinaryNodeChildren(groupsChild, 'group');
47
+ const groups = (0, WABinary_1.getBinaryNodeChildren)(groupsChild, 'group');
46
48
  for (const groupNode of groups) {
47
- const meta = extractGroupMetadata({
49
+ const meta = (0, exports.extractGroupMetadata)({
48
50
  tag: 'result',
49
51
  attrs: {},
50
52
  content: [groupNode]
@@ -52,12 +54,11 @@ export const makeGroupsSocket = (config) => {
52
54
  data[meta.id] = meta;
53
55
  }
54
56
  }
55
- // TODO: properly parse LID / PN DATA
56
57
  sock.ev.emit('groups.update', Object.values(data));
57
58
  return data;
58
59
  };
59
60
  sock.ws.on('CB:ib,,dirty', async (node) => {
60
- const { attrs } = getBinaryNodeChild(node, 'dirty');
61
+ const { attrs } = (0, WABinary_1.getBinaryNodeChild)(node, 'dirty');
61
62
  if (attrs.type !== 'groups') {
62
63
  return;
63
64
  }
@@ -66,9 +67,10 @@ export const makeGroupsSocket = (config) => {
66
67
  });
67
68
  return {
68
69
  ...sock,
70
+ groupQuery,
69
71
  groupMetadata,
70
72
  groupCreate: async (subject, participants) => {
71
- const key = generateMessageIDV2();
73
+ const key = (0, Utils_1.generateMessageIDV2)();
72
74
  const result = await groupQuery('@g.us', 'set', [
73
75
  {
74
76
  tag: 'create',
@@ -82,14 +84,16 @@ export const makeGroupsSocket = (config) => {
82
84
  }))
83
85
  }
84
86
  ]);
85
- return extractGroupMetadata(result);
87
+ return (0, exports.extractGroupMetadata)(result);
86
88
  },
87
89
  groupLeave: async (id) => {
88
90
  await groupQuery('@g.us', 'set', [
89
91
  {
90
92
  tag: 'leave',
91
93
  attrs: {},
92
- content: [{ tag: 'group', attrs: { id } }]
94
+ content: [
95
+ { tag: 'group', attrs: { id } }
96
+ ]
93
97
  }
94
98
  ]);
95
99
  },
@@ -109,13 +113,12 @@ export const makeGroupsSocket = (config) => {
109
113
  attrs: {}
110
114
  }
111
115
  ]);
112
- const node = getBinaryNodeChild(result, 'membership_approval_requests');
113
- const participants = getBinaryNodeChildren(node, 'membership_approval_request');
116
+ const node = (0, WABinary_1.getBinaryNodeChild)(result, 'membership_approval_requests');
117
+ const participants = (0, WABinary_1.getBinaryNodeChildren)(node, 'membership_approval_request');
114
118
  return participants.map(v => v.attrs);
115
119
  },
116
120
  groupRequestParticipantsUpdate: async (jid, participants, action) => {
117
- const result = await groupQuery(jid, 'set', [
118
- {
121
+ const result = await groupQuery(jid, 'set', [{
119
122
  tag: 'membership_requests_action',
120
123
  attrs: {},
121
124
  content: [
@@ -128,11 +131,10 @@ export const makeGroupsSocket = (config) => {
128
131
  }))
129
132
  }
130
133
  ]
131
- }
132
- ]);
133
- const node = getBinaryNodeChild(result, 'membership_requests_action');
134
- const nodeAction = getBinaryNodeChild(node, action);
135
- const participantsAffected = getBinaryNodeChildren(nodeAction, 'participant');
134
+ }]);
135
+ const node = (0, WABinary_1.getBinaryNodeChild)(result, 'membership_requests_action');
136
+ const nodeAction = (0, WABinary_1.getBinaryNodeChild)(node, action);
137
+ const participantsAffected = (0, WABinary_1.getBinaryNodeChildren)(nodeAction, 'participant');
136
138
  return participantsAffected.map(p => {
137
139
  return { status: p.attrs.error || '200', jid: p.attrs.jid };
138
140
  });
@@ -148,40 +150,43 @@ export const makeGroupsSocket = (config) => {
148
150
  }))
149
151
  }
150
152
  ]);
151
- const node = getBinaryNodeChild(result, action);
152
- const participantsAffected = getBinaryNodeChildren(node, 'participant');
153
+ const node = (0, WABinary_1.getBinaryNodeChild)(result, action);
154
+ const participantsAffected = (0, WABinary_1.getBinaryNodeChildren)(node, 'participant');
153
155
  return participantsAffected.map(p => {
154
156
  return { status: p.attrs.error || '200', jid: p.attrs.jid, content: p };
155
157
  });
156
158
  },
157
159
  groupUpdateDescription: async (jid, description) => {
160
+ var _a;
158
161
  const metadata = await groupMetadata(jid);
159
- const prev = metadata.descId ?? null;
162
+ const prev = (_a = metadata.descId) !== null && _a !== void 0 ? _a : null;
160
163
  await groupQuery(jid, 'set', [
161
164
  {
162
165
  tag: 'description',
163
166
  attrs: {
164
- ...(description ? { id: generateMessageIDV2() } : { delete: 'true' }),
167
+ ...(description ? { id: (0, Utils_1.generateMessageIDV2)() } : { delete: 'true' }),
165
168
  ...(prev ? { prev } : {})
166
169
  },
167
- content: description ? [{ tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }] : undefined
170
+ content: description ? [
171
+ { tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }
172
+ ] : undefined
168
173
  }
169
174
  ]);
170
175
  },
171
176
  groupInviteCode: async (jid) => {
172
177
  const result = await groupQuery(jid, 'get', [{ tag: 'invite', attrs: {} }]);
173
- const inviteNode = getBinaryNodeChild(result, 'invite');
174
- return inviteNode?.attrs.code;
178
+ const inviteNode = (0, WABinary_1.getBinaryNodeChild)(result, 'invite');
179
+ return inviteNode === null || inviteNode === void 0 ? void 0 : inviteNode.attrs.code;
175
180
  },
176
181
  groupRevokeInvite: async (jid) => {
177
182
  const result = await groupQuery(jid, 'set', [{ tag: 'invite', attrs: {} }]);
178
- const inviteNode = getBinaryNodeChild(result, 'invite');
179
- return inviteNode?.attrs.code;
183
+ const inviteNode = (0, WABinary_1.getBinaryNodeChild)(result, 'invite');
184
+ return inviteNode === null || inviteNode === void 0 ? void 0 : inviteNode.attrs.code;
180
185
  },
181
186
  groupAcceptInvite: async (code) => {
182
187
  const results = await groupQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }]);
183
- const result = getBinaryNodeChild(results, 'group');
184
- return result?.attrs.jid;
188
+ const result = (0, WABinary_1.getBinaryNodeChild)(results, 'group');
189
+ return result === null || result === void 0 ? void 0 : result.attrs.jid;
185
190
  },
186
191
  /**
187
192
  * revoke a v4 invite for someone
@@ -190,9 +195,7 @@ export const makeGroupsSocket = (config) => {
190
195
  * @returns true if successful
191
196
  */
192
197
  groupRevokeInviteV4: async (groupJid, invitedJid) => {
193
- const result = await groupQuery(groupJid, 'set', [
194
- { tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }
195
- ]);
198
+ const result = await groupQuery(groupJid, 'set', [{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }]);
196
199
  return !!result;
197
200
  },
198
201
  /**
@@ -201,22 +204,21 @@ export const makeGroupsSocket = (config) => {
201
204
  * @param inviteMessage the message to accept
202
205
  */
203
206
  groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
207
+ var _a;
204
208
  key = typeof key === 'string' ? { remoteJid: key } : key;
205
- const results = await groupQuery(inviteMessage.groupJid, 'set', [
206
- {
209
+ const results = await groupQuery(inviteMessage.groupJid, 'set', [{
207
210
  tag: 'accept',
208
211
  attrs: {
209
212
  code: inviteMessage.inviteCode,
210
213
  expiration: inviteMessage.inviteExpiration.toString(),
211
214
  admin: key.remoteJid
212
215
  }
213
- }
214
- ]);
216
+ }]);
215
217
  // if we have the full message key
216
218
  // update the invite message to be expired
217
219
  if (key.id) {
218
220
  // create new invite message that is expired
219
- inviteMessage = proto.Message.GroupInviteMessage.fromObject(inviteMessage);
221
+ inviteMessage = WAProto_1.proto.Message.GroupInviteMessage.fromObject(inviteMessage);
220
222
  inviteMessage.inviteExpiration = 0;
221
223
  inviteMessage.inviteCode = '';
222
224
  ev.emit('messages.update', [
@@ -234,25 +236,27 @@ export const makeGroupsSocket = (config) => {
234
236
  await upsertMessage({
235
237
  key: {
236
238
  remoteJid: inviteMessage.groupJid,
237
- id: generateMessageIDV2(sock.user?.id),
239
+ id: (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id),
238
240
  fromMe: false,
239
- participant: key.remoteJid
241
+ participant: key.remoteJid,
240
242
  },
241
- messageStubType: WAMessageStubType.GROUP_PARTICIPANT_ADD,
242
- messageStubParameters: [JSON.stringify(authState.creds.me)],
243
+ messageStubType: Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD,
244
+ messageStubParameters: [
245
+ authState.creds.me.id
246
+ ],
243
247
  participant: key.remoteJid,
244
- messageTimestamp: unixTimestampSeconds()
248
+ messageTimestamp: (0, Utils_1.unixTimestampSeconds)()
245
249
  }, 'notify');
246
250
  return results.attrs.from;
247
251
  }),
248
252
  groupGetInviteInfo: async (code) => {
249
253
  const results = await groupQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }]);
250
- return extractGroupMetadata(results);
254
+ return (0, exports.extractGroupMetadata)(results);
251
255
  },
252
256
  groupToggleEphemeral: async (jid, ephemeralExpiration) => {
253
- const content = ephemeralExpiration
254
- ? { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
255
- : { tag: 'not_ephemeral', attrs: {} };
257
+ const content = ephemeralExpiration ?
258
+ { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } } :
259
+ { tag: 'not_ephemeral', attrs: {} };
256
260
  await groupQuery(jid, 'set', [content]);
257
261
  },
258
262
  groupSettingUpdate: async (jid, setting) => {
@@ -262,86 +266,67 @@ export const makeGroupsSocket = (config) => {
262
266
  await groupQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }]);
263
267
  },
264
268
  groupJoinApprovalMode: async (jid, mode) => {
265
- await groupQuery(jid, 'set', [
266
- { tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }
267
- ]);
269
+ await groupQuery(jid, 'set', [{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }]);
268
270
  },
269
271
  groupFetchAllParticipating
270
272
  };
271
273
  };
272
- export const extractGroupMetadata = (result) => {
273
- const group = getBinaryNodeChild(result, 'group');
274
- if (!group) {
275
- // Mirror WAWeb: surface server/client errors with their code+text instead of crashing.
276
- const errorNode = getBinaryNodeChild(result, 'error');
277
- if (errorNode) {
278
- const code = errorNode.attrs.code ? +errorNode.attrs.code : 500;
279
- const text = errorNode.attrs.text || 'group metadata query failed';
280
- throw new Boom(text, { statusCode: code, data: errorNode });
281
- }
282
- throw new Boom('Invalid group metadata response: missing <group> node', { data: result });
283
- }
284
- if (!group.attrs.id) {
285
- throw new Boom('Invalid group metadata response: missing group id', { data: group });
286
- }
287
- const descChild = getBinaryNodeChild(group, 'description');
274
+ exports.makeGroupsSocket = makeGroupsSocket;
275
+ const extractGroupMetadata = (result) => {
276
+ var _a, _b;
277
+ const group = (0, WABinary_1.getBinaryNodeChild)(result, 'group');
278
+ const descChild = (0, WABinary_1.getBinaryNodeChild)(group, 'description');
288
279
  let desc;
289
280
  let descId;
290
281
  let descOwner;
291
- let descOwnerPn;
292
- let descOwnerUsername;
282
+ let descOwnerLid;
293
283
  let descTime;
294
284
  if (descChild) {
295
- desc = getBinaryNodeChildString(descChild, 'body');
296
- descOwner = descChild.attrs.participant ? jidNormalizedUser(descChild.attrs.participant) : undefined;
297
- descOwnerPn = descChild.attrs.participant_pn ? jidNormalizedUser(descChild.attrs.participant_pn) : undefined;
298
- descOwnerUsername = descChild.attrs.participant_username || undefined;
299
- descTime = +descChild.attrs.t;
285
+ desc = (0, WABinary_1.getBinaryNodeChildString)(descChild, 'body');
286
+ descOwner = (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant_pn || descChild.attrs.participant);
287
+ if (group.attrs.addressing_mode === 'lid') {
288
+ descOwnerLid = (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant);
289
+ }
300
290
  descId = descChild.attrs.id;
291
+ descTime = descChild.attrs.t ? +descChild.attrs.t : undefined;
301
292
  }
302
- const groupId = group.attrs.id.includes('@') ? group.attrs.id : jidEncode(group.attrs.id, 'g.us');
303
- const eph = getBinaryNodeChild(group, 'ephemeral')?.attrs.expiration;
304
- const memberAddMode = getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add';
293
+ const groupSize = group.attrs.size ? Number(group.attrs.size) : undefined;
294
+ const groupId = group.attrs.id.includes('@') ? group.attrs.id : (0, WABinary_1.jidEncode)(group.attrs.id, 'g.us');
295
+ const eph = (_a = (0, WABinary_1.getBinaryNodeChild)(group, 'ephemeral')) === null || _a === void 0 ? void 0 : _a.attrs.expiration;
296
+ const memberAddMode = (0, WABinary_1.getBinaryNodeChildString)(group, 'member_add_mode') === 'all_member_add';
305
297
  const metadata = {
306
298
  id: groupId,
307
- notify: group.attrs.notify,
308
- addressingMode: group.attrs.addressing_mode === 'lid' ? WAMessageAddressingMode.LID : WAMessageAddressingMode.PN,
299
+ addressingMode: group.attrs.addressing_mode,
309
300
  subject: group.attrs.subject,
310
- subjectOwner: group.attrs.s_o,
311
- subjectOwnerPn: group.attrs.s_o_pn,
312
- subjectOwnerUsername: group.attrs.s_o_username,
313
- subjectTime: +group.attrs.s_t,
314
- size: group.attrs.size ? +group.attrs.size : getBinaryNodeChildren(group, 'participant').length,
315
- creation: +group.attrs.creation,
316
- owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
317
- ownerPn: group.attrs.creator_pn ? jidNormalizedUser(group.attrs.creator_pn) : undefined,
318
- ownerUsername: group.attrs.creator_username || undefined,
319
- owner_country_code: group.attrs.creator_country_code,
301
+ subjectOwner: (0, WABinary_1.jidNormalizedUser)(group.attrs.s_o_pn || group.attrs.s_o),
302
+ ...(group.attrs.addressing_mode === 'lid' ? { subjectOwnerLid: (0, WABinary_1.jidNormalizedUser)(group.attrs.s_o) } : {}),
303
+ subjectTime: group.attrs.s_t ? +group.attrs.s_t : undefined,
304
+ size: groupSize || (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').length,
305
+ creation: group.attrs.creation ? +group.attrs.creation : undefined,
306
+ owner: (0, WABinary_1.jidNormalizedUser)(group.attrs.creator_pn || group.attrs.creator),
307
+ ...(group.attrs.addressing_mode === 'lid' ? { ownerLid: (0, WABinary_1.jidNormalizedUser)(group.attrs.creator) } : {}),
320
308
  desc,
321
309
  descId,
322
310
  descOwner,
323
- descOwnerPn,
324
- descOwnerUsername,
311
+ descOwnerLid,
325
312
  descTime,
326
- linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
327
- restrict: !!getBinaryNodeChild(group, 'locked'),
328
- announce: !!getBinaryNodeChild(group, 'announcement'),
329
- isCommunity: !!getBinaryNodeChild(group, 'parent'),
330
- isCommunityAnnounce: !!getBinaryNodeChild(group, 'default_sub_group'),
331
- joinApprovalMode: !!getBinaryNodeChild(group, 'membership_approval_mode'),
313
+ linkedParent: ((_b = (0, WABinary_1.getBinaryNodeChild)(group, 'linked_parent')) === null || _b === void 0 ? void 0 : _b.attrs.jid) || undefined,
314
+ restrict: !!(0, WABinary_1.getBinaryNodeChild)(group, 'locked'),
315
+ announce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'announcement'),
316
+ isCommunity: !!(0, WABinary_1.getBinaryNodeChild)(group, 'parent'),
317
+ isCommunityAnnounce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'default_sub_group'),
318
+ joinApprovalMode: !!(0, WABinary_1.getBinaryNodeChild)(group, 'membership_approval_mode'),
332
319
  memberAddMode,
333
- participants: getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
334
- // TODO: Store LID MAPPINGS
320
+ participants: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').map(({ attrs }) => {
335
321
  return {
336
322
  id: attrs.jid,
337
- phoneNumber: isLidUser(attrs.jid) && isPnUser(attrs.phone_number) ? attrs.phone_number : undefined,
338
- lid: isPnUser(attrs.jid) && isLidUser(attrs.lid) ? attrs.lid : undefined,
339
- username: attrs.participant_username || attrs.username || undefined,
340
- admin: (attrs.type || null)
323
+ jid: attrs.phone_number || attrs.jid,
324
+ lid: attrs.lid || attrs.jid,
325
+ admin: (attrs.type || null),
341
326
  };
342
327
  }),
343
328
  ephemeralDuration: eph ? +eph : undefined
344
329
  };
345
330
  return metadata;
346
331
  };
347
- //# sourceMappingURL=groups.js.map
332
+ exports.extractGroupMetadata = extractGroupMetadata;
@@ -1,12 +1,10 @@
1
- import { DEFAULT_CONNECTION_CONFIG } from '../Defaults/index.js';
2
- import { makeCommunitiesSocket } from './communities.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Defaults_1 = require("../Defaults");
4
+ const business_1 = require("./business");
3
5
  // export the last socket layer
4
- const makeWASocket = (config) => {
5
- const newConfig = {
6
- ...DEFAULT_CONNECTION_CONFIG,
7
- ...config
8
- };
9
- return makeCommunitiesSocket(newConfig);
10
- };
11
- export default makeWASocket;
12
- //# sourceMappingURL=index.js.map
6
+ const makeWASocket = (config) => ((0, business_1.makeBusinessSocket)({
7
+ ...Defaults_1.DEFAULT_CONNECTION_CONFIG,
8
+ ...config
9
+ })); // ⒷⒶⒾⓁⒺⓎⓈ ⒷⓎ ⓋⓎⓏⒺⓃ
10
+ exports.default = makeWASocket;