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