@baileys-md/baileys 10.1.0 → 11.0.0

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 (122) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1303 -2
  3. package/WAProto/GenerateStatics.sh +3 -0
  4. package/WAProto/WAProto.proto +4633 -0
  5. package/WAProto/fix-imports.js +29 -0
  6. package/WAProto/index.js +13516 -4182
  7. package/lib/Defaults/baileys-version.js +1 -0
  8. package/lib/Defaults/index.js +51 -72
  9. package/lib/Signal/Group/ciphertext-message.js +12 -0
  10. package/lib/Signal/Group/group-session-builder.js +30 -0
  11. package/lib/Signal/Group/group_cipher.js +94 -0
  12. package/lib/Signal/Group/index.js +12 -0
  13. package/lib/Signal/Group/keyhelper.js +19 -0
  14. package/lib/Signal/Group/queue-job.js +54 -0
  15. package/lib/Signal/Group/sender-chain-key.js +32 -0
  16. package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
  17. package/lib/Signal/Group/sender-key-message.js +67 -0
  18. package/lib/Signal/Group/sender-key-name.js +48 -0
  19. package/lib/Signal/Group/sender-key-record.js +50 -0
  20. package/lib/Signal/Group/sender-key-state.js +96 -0
  21. package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +4 -16
  22. package/lib/Signal/libsignal.js +41 -61
  23. package/lib/Socket/Client/index.js +3 -19
  24. package/lib/Socket/Client/types.js +11 -0
  25. package/lib/Socket/Client/websocket.js +50 -0
  26. package/lib/Socket/business.js +37 -42
  27. package/lib/Socket/chats.js +194 -187
  28. package/lib/Socket/communities.js +351 -0
  29. package/lib/Socket/groups.js +87 -90
  30. package/lib/Socket/index.js +7 -8
  31. package/lib/Socket/messages-recv.js +360 -335
  32. package/lib/Socket/messages-send.js +156 -279
  33. package/lib/Socket/mex.js +42 -0
  34. package/lib/Socket/newsletter.js +144 -213
  35. package/lib/Socket/socket.js +128 -161
  36. package/lib/Socket/usync.js +19 -26
  37. package/lib/Types/Auth.js +2 -2
  38. package/lib/Types/Call.js +2 -2
  39. package/lib/Types/Chat.js +8 -4
  40. package/lib/Types/Contact.js +2 -2
  41. package/lib/Types/Events.js +2 -2
  42. package/lib/Types/GroupMetadata.js +2 -2
  43. package/lib/Types/Label.js +3 -5
  44. package/lib/Types/LabelAssociation.js +3 -5
  45. package/lib/Types/Message.js +7 -7
  46. package/lib/Types/Newsletter.js +30 -17
  47. package/lib/Types/Product.js +2 -2
  48. package/lib/Types/Signal.js +2 -2
  49. package/lib/Types/Socket.js +3 -2
  50. package/lib/Types/State.js +2 -2
  51. package/lib/Types/USync.js +2 -2
  52. package/lib/Types/index.js +15 -31
  53. package/lib/Utils/auth-utils.js +31 -47
  54. package/lib/Utils/baileys-event-stream.js +15 -22
  55. package/lib/Utils/business.js +66 -69
  56. package/lib/Utils/chat-utils.js +200 -195
  57. package/lib/Utils/crypto.js +70 -85
  58. package/lib/Utils/decode-wa-message.js +47 -51
  59. package/lib/Utils/event-buffer.js +36 -46
  60. package/lib/Utils/generics.js +116 -188
  61. package/lib/Utils/history.js +37 -46
  62. package/lib/Utils/index.js +19 -33
  63. package/lib/Utils/link-preview.js +14 -55
  64. package/lib/Utils/logger.js +3 -7
  65. package/lib/Utils/lt-hash.js +23 -26
  66. package/lib/{Store → Utils}/make-in-memory-store.js +19 -27
  67. package/lib/Utils/make-mutex.js +7 -10
  68. package/lib/{Store → Utils}/make-ordered-dictionary.js +1 -3
  69. package/lib/Utils/messages-media.js +236 -368
  70. package/lib/Utils/messages.js +278 -510
  71. package/lib/Utils/noise-handler.js +22 -31
  72. package/lib/{Store → Utils}/object-repository.js +1 -4
  73. package/lib/Utils/process-message.js +144 -148
  74. package/lib/Utils/signal.js +71 -64
  75. package/lib/Utils/use-multi-file-auth-state.js +112 -84
  76. package/lib/Utils/validate-connection.js +72 -115
  77. package/lib/WABinary/constants.js +1281 -20
  78. package/lib/WABinary/decode.js +15 -52
  79. package/lib/WABinary/encode.js +14 -48
  80. package/lib/WABinary/generic-utils.js +31 -39
  81. package/lib/WABinary/index.js +6 -21
  82. package/lib/WABinary/jid-utils.js +23 -40
  83. package/lib/WABinary/types.js +2 -2
  84. package/lib/WAM/BinaryInfo.js +2 -5
  85. package/lib/WAM/constants.js +2257 -2366
  86. package/lib/WAM/encode.js +17 -21
  87. package/lib/WAM/index.js +4 -19
  88. package/lib/WAUSync/Protocols/USyncContactProtocol.js +8 -11
  89. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +11 -14
  90. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +9 -12
  91. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +9 -13
  92. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +20 -22
  93. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +3 -6
  94. package/lib/WAUSync/Protocols/index.js +5 -20
  95. package/lib/WAUSync/USyncQuery.js +34 -32
  96. package/lib/WAUSync/USyncUser.js +2 -5
  97. package/lib/WAUSync/index.js +4 -19
  98. package/lib/index.js +11 -33
  99. package/package.json +25 -54
  100. package/WASignalGroup/GroupProtocol.js +0 -1697
  101. package/WASignalGroup/ciphertext_message.js +0 -16
  102. package/WASignalGroup/group_cipher.js +0 -120
  103. package/WASignalGroup/group_session_builder.js +0 -46
  104. package/WASignalGroup/index.js +0 -5
  105. package/WASignalGroup/keyhelper.js +0 -21
  106. package/WASignalGroup/protobufs.js +0 -3
  107. package/WASignalGroup/queue_job.js +0 -69
  108. package/WASignalGroup/sender_chain_key.js +0 -50
  109. package/WASignalGroup/sender_key_distribution_message.js +0 -78
  110. package/WASignalGroup/sender_key_message.js +0 -92
  111. package/WASignalGroup/sender_key_name.js +0 -70
  112. package/WASignalGroup/sender_key_record.js +0 -56
  113. package/WASignalGroup/sender_key_state.js +0 -129
  114. package/lib/Defaults/baileys-version.json +0 -3
  115. package/lib/Defaults/phonenumber-mcc.json +0 -223
  116. package/lib/Socket/Client/abstract-socket-client.js +0 -13
  117. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  118. package/lib/Socket/Client/web-socket-client.js +0 -62
  119. package/lib/Socket/registration.js +0 -166
  120. package/lib/Store/index.js +0 -8
  121. package/lib/Store/make-cache-manager-store.js +0 -83
  122. package/lib/Store/make-mongo-store.js +0 -567
@@ -1,26 +1,23 @@
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);
1
+ import { proto } from '../../WAProto/index.js';
2
+ import { WAMessageStubType } from '../Types/index.js';
3
+ import { generateMessageIDV2, unixTimestampSeconds } from '../Utils/index.js';
4
+ import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString, isJidUser, isLidUser, jidEncode, jidNormalizedUser } from '../WABinary/index.js';
5
+ import { makeChatsSocket } from './chats.js';
6
+ export const makeGroupsSocket = (config) => {
7
+ const sock = makeChatsSocket(config);
11
8
  const { authState, ev, query, upsertMessage } = sock;
12
- const groupQuery = async (jid, type, content) => (query({
9
+ const groupQuery = async (jid, type, content) => query({
13
10
  tag: 'iq',
14
11
  attrs: {
15
12
  type,
16
13
  xmlns: 'w:g2',
17
- to: jid,
14
+ to: jid
18
15
  },
19
16
  content
20
- }));
17
+ });
21
18
  const groupMetadata = async (jid) => {
22
19
  const result = await groupQuery(jid, 'get', [{ tag: 'query', attrs: { request: 'interactive' } }]);
23
- return (0, exports.extractGroupMetadata)(result);
20
+ return extractGroupMetadata(result);
24
21
  };
25
22
  const groupFetchAllParticipating = async () => {
26
23
  const result = await query({
@@ -28,7 +25,7 @@ const makeGroupsSocket = (config) => {
28
25
  attrs: {
29
26
  to: '@g.us',
30
27
  xmlns: 'w:g2',
31
- type: 'get',
28
+ type: 'get'
32
29
  },
33
30
  content: [
34
31
  {
@@ -42,11 +39,11 @@ const makeGroupsSocket = (config) => {
42
39
  ]
43
40
  });
44
41
  const data = {};
45
- const groupsChild = (0, WABinary_1.getBinaryNodeChild)(result, 'groups');
42
+ const groupsChild = getBinaryNodeChild(result, 'groups');
46
43
  if (groupsChild) {
47
- const groups = (0, WABinary_1.getBinaryNodeChildren)(groupsChild, 'group');
44
+ const groups = getBinaryNodeChildren(groupsChild, 'group');
48
45
  for (const groupNode of groups) {
49
- const meta = (0, exports.extractGroupMetadata)({
46
+ const meta = extractGroupMetadata({
50
47
  tag: 'result',
51
48
  attrs: {},
52
49
  content: [groupNode]
@@ -58,7 +55,7 @@ const makeGroupsSocket = (config) => {
58
55
  return data;
59
56
  };
60
57
  sock.ws.on('CB:ib,,dirty', async (node) => {
61
- const { attrs } = (0, WABinary_1.getBinaryNodeChild)(node, 'dirty');
58
+ const { attrs } = getBinaryNodeChild(node, 'dirty');
62
59
  if (attrs.type !== 'groups') {
63
60
  return;
64
61
  }
@@ -69,7 +66,7 @@ const makeGroupsSocket = (config) => {
69
66
  ...sock,
70
67
  groupMetadata,
71
68
  groupCreate: async (subject, participants) => {
72
- const key = (0, Utils_1.generateMessageIDV2)();
69
+ const key = generateMessageIDV2();
73
70
  const result = await groupQuery('@g.us', 'set', [
74
71
  {
75
72
  tag: 'create',
@@ -83,16 +80,14 @@ const makeGroupsSocket = (config) => {
83
80
  }))
84
81
  }
85
82
  ]);
86
- return (0, exports.extractGroupMetadata)(result);
83
+ return extractGroupMetadata(result);
87
84
  },
88
85
  groupLeave: async (id) => {
89
86
  await groupQuery('@g.us', 'set', [
90
87
  {
91
88
  tag: 'leave',
92
89
  attrs: {},
93
- content: [
94
- { tag: 'group', attrs: { id } }
95
- ]
90
+ content: [{ tag: 'group', attrs: { id } }]
96
91
  }
97
92
  ]);
98
93
  },
@@ -112,12 +107,13 @@ const makeGroupsSocket = (config) => {
112
107
  attrs: {}
113
108
  }
114
109
  ]);
115
- const node = (0, WABinary_1.getBinaryNodeChild)(result, 'membership_approval_requests');
116
- const participants = (0, WABinary_1.getBinaryNodeChildren)(node, 'membership_approval_request');
110
+ const node = getBinaryNodeChild(result, 'membership_approval_requests');
111
+ const participants = getBinaryNodeChildren(node, 'membership_approval_request');
117
112
  return participants.map(v => v.attrs);
118
113
  },
119
114
  groupRequestParticipantsUpdate: async (jid, participants, action) => {
120
- const result = await groupQuery(jid, 'set', [{
115
+ const result = await groupQuery(jid, 'set', [
116
+ {
121
117
  tag: 'membership_requests_action',
122
118
  attrs: {},
123
119
  content: [
@@ -130,10 +126,11 @@ const makeGroupsSocket = (config) => {
130
126
  }))
131
127
  }
132
128
  ]
133
- }]);
134
- const node = (0, WABinary_1.getBinaryNodeChild)(result, 'membership_requests_action');
135
- const nodeAction = (0, WABinary_1.getBinaryNodeChild)(node, action);
136
- const participantsAffected = (0, WABinary_1.getBinaryNodeChildren)(nodeAction, 'participant');
129
+ }
130
+ ]);
131
+ const node = getBinaryNodeChild(result, 'membership_requests_action');
132
+ const nodeAction = getBinaryNodeChild(node, action);
133
+ const participantsAffected = getBinaryNodeChildren(nodeAction, 'participant');
137
134
  return participantsAffected.map(p => {
138
135
  return { status: p.attrs.error || '200', jid: p.attrs.jid };
139
136
  });
@@ -149,43 +146,40 @@ const makeGroupsSocket = (config) => {
149
146
  }))
150
147
  }
151
148
  ]);
152
- const node = (0, WABinary_1.getBinaryNodeChild)(result, action);
153
- const participantsAffected = (0, WABinary_1.getBinaryNodeChildren)(node, 'participant');
149
+ const node = getBinaryNodeChild(result, action);
150
+ const participantsAffected = getBinaryNodeChildren(node, 'participant');
154
151
  return participantsAffected.map(p => {
155
152
  return { status: p.attrs.error || '200', jid: p.attrs.jid, content: p };
156
153
  });
157
154
  },
158
155
  groupUpdateDescription: async (jid, description) => {
159
- var _a;
160
156
  const metadata = await groupMetadata(jid);
161
- const prev = (_a = metadata.descId) !== null && _a !== void 0 ? _a : null;
157
+ const prev = metadata.descId ?? null;
162
158
  await groupQuery(jid, 'set', [
163
159
  {
164
160
  tag: 'description',
165
161
  attrs: {
166
- ...(description ? { id: (0, Utils_1.generateMessageIDV2)() } : { delete: 'true' }),
162
+ ...(description ? { id: generateMessageIDV2() } : { delete: 'true' }),
167
163
  ...(prev ? { prev } : {})
168
164
  },
169
- content: description ? [
170
- { tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }
171
- ] : undefined
165
+ content: description ? [{ tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }] : undefined
172
166
  }
173
167
  ]);
174
168
  },
175
169
  groupInviteCode: async (jid) => {
176
170
  const result = await groupQuery(jid, 'get', [{ tag: 'invite', attrs: {} }]);
177
- const inviteNode = (0, WABinary_1.getBinaryNodeChild)(result, 'invite');
178
- return inviteNode === null || inviteNode === void 0 ? void 0 : inviteNode.attrs.code;
171
+ const inviteNode = getBinaryNodeChild(result, 'invite');
172
+ return inviteNode?.attrs.code;
179
173
  },
180
174
  groupRevokeInvite: async (jid) => {
181
175
  const result = await groupQuery(jid, 'set', [{ tag: 'invite', attrs: {} }]);
182
- const inviteNode = (0, WABinary_1.getBinaryNodeChild)(result, 'invite');
183
- return inviteNode === null || inviteNode === void 0 ? void 0 : inviteNode.attrs.code;
176
+ const inviteNode = getBinaryNodeChild(result, 'invite');
177
+ return inviteNode?.attrs.code;
184
178
  },
185
179
  groupAcceptInvite: async (code) => {
186
180
  const results = await groupQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }]);
187
- const result = (0, WABinary_1.getBinaryNodeChild)(results, 'group');
188
- return result === null || result === void 0 ? void 0 : result.attrs.jid;
181
+ const result = getBinaryNodeChild(results, 'group');
182
+ return result?.attrs.jid;
189
183
  },
190
184
  /**
191
185
  * revoke a v4 invite for someone
@@ -194,7 +188,9 @@ const makeGroupsSocket = (config) => {
194
188
  * @returns true if successful
195
189
  */
196
190
  groupRevokeInviteV4: async (groupJid, invitedJid) => {
197
- const result = await groupQuery(groupJid, 'set', [{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }]);
191
+ const result = await groupQuery(groupJid, 'set', [
192
+ { tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }
193
+ ]);
198
194
  return !!result;
199
195
  },
200
196
  /**
@@ -203,21 +199,22 @@ const makeGroupsSocket = (config) => {
203
199
  * @param inviteMessage the message to accept
204
200
  */
205
201
  groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
206
- var _a;
207
202
  key = typeof key === 'string' ? { remoteJid: key } : key;
208
- const results = await groupQuery(inviteMessage.groupJid, 'set', [{
203
+ const results = await groupQuery(inviteMessage.groupJid, 'set', [
204
+ {
209
205
  tag: 'accept',
210
206
  attrs: {
211
207
  code: inviteMessage.inviteCode,
212
208
  expiration: inviteMessage.inviteExpiration.toString(),
213
209
  admin: key.remoteJid
214
210
  }
215
- }]);
211
+ }
212
+ ]);
216
213
  // if we have the full message key
217
214
  // update the invite message to be expired
218
215
  if (key.id) {
219
216
  // create new invite message that is expired
220
- inviteMessage = WAProto_1.proto.Message.GroupInviteMessage.fromObject(inviteMessage);
217
+ inviteMessage = proto.Message.GroupInviteMessage.fromObject(inviteMessage);
221
218
  inviteMessage.inviteExpiration = 0;
222
219
  inviteMessage.inviteCode = '';
223
220
  ev.emit('messages.update', [
@@ -235,27 +232,25 @@ const makeGroupsSocket = (config) => {
235
232
  await upsertMessage({
236
233
  key: {
237
234
  remoteJid: inviteMessage.groupJid,
238
- id: (0, Utils_1.generateMessageIDV2)((_a = sock.user) === null || _a === void 0 ? void 0 : _a.id),
235
+ id: generateMessageIDV2(sock.user?.id),
239
236
  fromMe: false,
240
- participant: key.remoteJid,
237
+ participant: key.remoteJid
241
238
  },
242
- messageStubType: Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD,
243
- messageStubParameters: [
244
- authState.creds.me.id
245
- ],
239
+ messageStubType: WAMessageStubType.GROUP_PARTICIPANT_ADD,
240
+ messageStubParameters: [authState.creds.me.id],
246
241
  participant: key.remoteJid,
247
- messageTimestamp: (0, Utils_1.unixTimestampSeconds)()
242
+ messageTimestamp: unixTimestampSeconds()
248
243
  }, 'notify');
249
244
  return results.attrs.from;
250
245
  }),
251
246
  groupGetInviteInfo: async (code) => {
252
247
  const results = await groupQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }]);
253
- return (0, exports.extractGroupMetadata)(results);
248
+ return extractGroupMetadata(results);
254
249
  },
255
250
  groupToggleEphemeral: async (jid, ephemeralExpiration) => {
256
- const content = ephemeralExpiration ?
257
- { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } } :
258
- { tag: 'not_ephemeral', attrs: {} };
251
+ const content = ephemeralExpiration
252
+ ? { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
253
+ : { tag: 'not_ephemeral', attrs: {} };
259
254
  await groupQuery(jid, 'set', [content]);
260
255
  },
261
256
  groupSettingUpdate: async (jid, setting) => {
@@ -265,63 +260,65 @@ const makeGroupsSocket = (config) => {
265
260
  await groupQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }]);
266
261
  },
267
262
  groupJoinApprovalMode: async (jid, mode) => {
268
- await groupQuery(jid, 'set', [{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }]);
263
+ await groupQuery(jid, 'set', [
264
+ { tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }
265
+ ]);
269
266
  },
270
267
  groupFetchAllParticipating
271
268
  };
272
269
  };
273
- exports.makeGroupsSocket = makeGroupsSocket;
274
- const extractGroupMetadata = (result) => {
275
- var _a, _b;
276
- const group = (0, WABinary_1.getBinaryNodeChild)(result, 'group');
277
- const descChild = (0, WABinary_1.getBinaryNodeChild)(group, 'description');
270
+ export const extractGroupMetadata = (result) => {
271
+ const group = getBinaryNodeChild(result, 'group');
272
+ const descChild = getBinaryNodeChild(group, 'description');
278
273
  let desc;
279
274
  let descId;
280
275
  let descOwner;
281
- let descOwnerPhoneNumber;
276
+ let descOwnerJid;
282
277
  let descTime;
283
278
  if (descChild) {
284
- desc = (0, WABinary_1.getBinaryNodeChildString)(descChild, 'body');
285
- descOwner = descChild.attrs.participant;
286
- descOwnerPhoneNumber = descChild.attrs.participant_pn;
287
- descId = descChild.attrs.id;
279
+ desc = getBinaryNodeChildString(descChild, 'body');
280
+ descOwner = descChild.attrs.participant ? jidNormalizedUser(descChild.attrs.participant) : undefined;
281
+ descOwnerJid = descChild.attrs.participant_pn ? jidNormalizedUser(descChild.attrs.participant_pn) : undefined;
288
282
  descTime = +descChild.attrs.t;
283
+ descId = descChild.attrs.id;
289
284
  }
290
- const groupSize = group.attrs.size ? Number(group.attrs.size) : undefined;
291
- const groupId = group.attrs.id.includes('@') ? group.attrs.id : (0, WABinary_1.jidEncode)(group.attrs.id, 'g.us');
292
- const eph = (_a = (0, WABinary_1.getBinaryNodeChild)(group, 'ephemeral')) === null || _a === void 0 ? void 0 : _a.attrs.expiration;
293
- const memberAddMode = (0, WABinary_1.getBinaryNodeChildString)(group, 'member_add_mode') === 'all_member_add';
285
+ const groupId = group.attrs.id.includes('@') ? group.attrs.id : jidEncode(group.attrs.id, 'g.us');
286
+ const eph = getBinaryNodeChild(group, 'ephemeral')?.attrs.expiration;
287
+ const memberAddMode = getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add';
294
288
  const metadata = {
295
289
  id: groupId,
296
290
  addressingMode: group.attrs.addressing_mode,
297
291
  subject: group.attrs.subject,
298
292
  subjectOwner: group.attrs.s_o,
299
- subjectOwnerPhoneNumber: group.attrs.s_o_pn,
293
+ subjectOwnerJid: group.attrs.s_o_pn,
300
294
  subjectTime: +group.attrs.s_t,
301
- size: groupSize || (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').length,
295
+ size: group.attrs.size ? +group.attrs.size : getBinaryNodeChildren(group, 'participant').length,
302
296
  creation: +group.attrs.creation,
303
- owner: group.attrs.creator ? (0, WABinary_1.jidNormalizedUser)(group.attrs.creator) : undefined,
297
+ owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
298
+ ownerJid: group.attrs.creator_pn ? jidNormalizedUser(group.attrs.creator_pn) : undefined,
299
+ owner_country_code: group.attrs.creator_country_code,
304
300
  desc,
305
301
  descId,
306
302
  descOwner,
307
- descOwnerPhoneNumber,
303
+ descOwnerJid,
308
304
  descTime,
309
- linkedParent: ((_b = (0, WABinary_1.getBinaryNodeChild)(group, 'linked_parent')) === null || _b === void 0 ? void 0 : _b.attrs.jid) || undefined,
310
- restrict: !!(0, WABinary_1.getBinaryNodeChild)(group, 'locked'),
311
- announce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'announcement'),
312
- isCommunity: !!(0, WABinary_1.getBinaryNodeChild)(group, 'parent'),
313
- isCommunityAnnounce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'default_sub_group'),
314
- joinApprovalMode: !!(0, WABinary_1.getBinaryNodeChild)(group, 'membership_approval_mode'),
305
+ linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
306
+ restrict: !!getBinaryNodeChild(group, 'locked'),
307
+ announce: !!getBinaryNodeChild(group, 'announcement'),
308
+ isCommunity: !!getBinaryNodeChild(group, 'parent'),
309
+ isCommunityAnnounce: !!getBinaryNodeChild(group, 'default_sub_group'),
310
+ joinApprovalMode: !!getBinaryNodeChild(group, 'membership_approval_mode'),
315
311
  memberAddMode,
316
- participants: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').map(({ attrs }) => {
312
+ participants: getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
317
313
  return {
318
314
  id: attrs.jid,
319
- phoneNumber: attrs.phone_number || attrs.jid,
320
- admin: (attrs.type || null),
315
+ jid: isJidUser(attrs.jid) ? attrs.jid : jidNormalizedUser(attrs.phone_number),
316
+ lid: isLidUser(attrs.jid) ? attrs.jid : attrs.lid,
317
+ admin: (attrs.type || null)
321
318
  };
322
319
  }),
323
320
  ephemeralDuration: eph ? +eph : undefined
324
321
  };
325
322
  return metadata;
326
323
  };
327
- exports.extractGroupMetadata = extractGroupMetadata;
324
+ //# sourceMappingURL=groups.js.map
@@ -1,10 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const Defaults_1 = require("../Defaults");
4
- const registration_1 = require("./registration");
1
+ import { DEFAULT_CONNECTION_CONFIG } from '../Defaults/index.js';
2
+ import { makeCommunitiesSocket } from './communities.js';
5
3
  // export the last socket layer
6
- const makeWASocket = (config) => ((0, registration_1.makeRegistrationSocket)({
7
- ...Defaults_1.DEFAULT_CONNECTION_CONFIG,
4
+ const makeWASocket = (config) => makeCommunitiesSocket({
5
+ ...DEFAULT_CONNECTION_CONFIG,
8
6
  ...config
9
- }));
10
- exports.default = makeWASocket;
7
+ });
8
+ export default makeWASocket;
9
+ //# sourceMappingURL=index.js.map