violetics 7.0.0-alpha → 7.0.2-alpha

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