@yemo-dev/yebail 1.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 (106) hide show
  1. package/EXAMPLES.md +641 -0
  2. package/LICENSE +21 -0
  3. package/README.md +141 -0
  4. package/WAProto/GenerateStatics.sh +4 -0
  5. package/WAProto/WAProto.proto +4775 -0
  6. package/WAProto/index.js +116311 -0
  7. package/engine-requirements.js +10 -0
  8. package/lib/Defaults/index.js +142 -0
  9. package/lib/Defaults/phonenumber-mcc.json +223 -0
  10. package/lib/Defaults/yebail-version.json +7 -0
  11. package/lib/Signal/Group/ciphertext-message.js +15 -0
  12. package/lib/Signal/Group/group-session-builder.js +64 -0
  13. package/lib/Signal/Group/group_cipher.js +96 -0
  14. package/lib/Signal/Group/index.js +57 -0
  15. package/lib/Signal/Group/keyhelper.js +55 -0
  16. package/lib/Signal/Group/queue-job.js +57 -0
  17. package/lib/Signal/Group/sender-chain-key.js +34 -0
  18. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  19. package/lib/Signal/Group/sender-key-message.js +69 -0
  20. package/lib/Signal/Group/sender-key-name.js +51 -0
  21. package/lib/Signal/Group/sender-key-record.js +53 -0
  22. package/lib/Signal/Group/sender-key-state.js +99 -0
  23. package/lib/Signal/Group/sender-message-key.js +29 -0
  24. package/lib/Signal/libsignal.js +196 -0
  25. package/lib/Signal/lid-mapping.js +148 -0
  26. package/lib/Socket/Client/index.js +18 -0
  27. package/lib/Socket/Client/types.js +13 -0
  28. package/lib/Socket/Client/websocket.js +72 -0
  29. package/lib/Socket/business.js +368 -0
  30. package/lib/Socket/chats.js +992 -0
  31. package/lib/Socket/communities.js +430 -0
  32. package/lib/Socket/groups.js +323 -0
  33. package/lib/Socket/index.js +10 -0
  34. package/lib/Socket/messages-recv.js +1133 -0
  35. package/lib/Socket/messages-send.js +992 -0
  36. package/lib/Socket/newsletter.js +250 -0
  37. package/lib/Socket/socket.js +631 -0
  38. package/lib/Socket/usync.js +70 -0
  39. package/lib/Store/index.js +8 -0
  40. package/lib/Store/make-in-memory-store.js +421 -0
  41. package/lib/Store/make-ordered-dictionary.js +81 -0
  42. package/lib/Store/object-repository.js +27 -0
  43. package/lib/Types/Auth.js +2 -0
  44. package/lib/Types/Call.js +2 -0
  45. package/lib/Types/Chat.js +4 -0
  46. package/lib/Types/Contact.js +2 -0
  47. package/lib/Types/Events.js +2 -0
  48. package/lib/Types/GroupMetadata.js +2 -0
  49. package/lib/Types/Label.js +27 -0
  50. package/lib/Types/LabelAssociation.js +9 -0
  51. package/lib/Types/Message.js +7 -0
  52. package/lib/Types/Newsletter.js +18 -0
  53. package/lib/Types/Product.js +2 -0
  54. package/lib/Types/Signal.js +2 -0
  55. package/lib/Types/Socket.js +2 -0
  56. package/lib/Types/State.js +2 -0
  57. package/lib/Types/USync.js +2 -0
  58. package/lib/Types/index.js +42 -0
  59. package/lib/Utils/auth-utils.js +188 -0
  60. package/lib/Utils/browser-utils.js +35 -0
  61. package/lib/Utils/business.js +230 -0
  62. package/lib/Utils/chat-utils.js +763 -0
  63. package/lib/Utils/crypto.js +187 -0
  64. package/lib/Utils/decode-wa-message.js +293 -0
  65. package/lib/Utils/event-buffer.js +514 -0
  66. package/lib/Utils/generics.js +453 -0
  67. package/lib/Utils/history.js +94 -0
  68. package/lib/Utils/index.js +37 -0
  69. package/lib/Utils/link-preview.js +121 -0
  70. package/lib/Utils/logger.js +7 -0
  71. package/lib/Utils/lt-hash.js +47 -0
  72. package/lib/Utils/make-mutex.js +43 -0
  73. package/lib/Utils/message-retry-manager.js +128 -0
  74. package/lib/Utils/messages-media.js +910 -0
  75. package/lib/Utils/messages.js +1129 -0
  76. package/lib/Utils/noise-handler.js +150 -0
  77. package/lib/Utils/process-message.js +448 -0
  78. package/lib/Utils/signal.js +150 -0
  79. package/lib/Utils/use-custom-auth-state.js +110 -0
  80. package/lib/Utils/use-multi-file-auth-state.js +43 -0
  81. package/lib/Utils/use-sqlite-auth-state.js +39 -0
  82. package/lib/Utils/validate-connection.js +237 -0
  83. package/lib/Utils/yebail-event-stream.js +55 -0
  84. package/lib/WABinary/constants.js +1303 -0
  85. package/lib/WABinary/decode.js +275 -0
  86. package/lib/WABinary/encode.js +250 -0
  87. package/lib/WABinary/generic-utils.js +110 -0
  88. package/lib/WABinary/index.js +21 -0
  89. package/lib/WABinary/jid-utils.js +136 -0
  90. package/lib/WABinary/types.js +2 -0
  91. package/lib/WAM/BinaryInfo.js +13 -0
  92. package/lib/WAM/constants.js +15350 -0
  93. package/lib/WAM/encode.js +155 -0
  94. package/lib/WAM/index.js +19 -0
  95. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  96. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  97. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  98. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  99. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  100. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  101. package/lib/WAUSync/Protocols/index.js +20 -0
  102. package/lib/WAUSync/USyncQuery.js +89 -0
  103. package/lib/WAUSync/USyncUser.js +26 -0
  104. package/lib/WAUSync/index.js +19 -0
  105. package/lib/index.js +46 -0
  106. package/package.json +114 -0
@@ -0,0 +1,430 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractCommunityMetadata = exports.makeCommunitiesSocket = void 0;
4
+ const WAProto_1 = require("../../WAProto");
5
+ const Types_1 = require("../Types");
6
+ const Utils_1 = require("../Utils");
7
+ const logger_1 = require("../Utils/logger");
8
+ const WABinary_1 = require("../WABinary");
9
+ const business_1 = require("./business");
10
+ const makeCommunitiesSocket = (config) => {
11
+ const sock = (0, business_1.makeBusinessSocket)(config);
12
+ const { authState, ev, query, upsertMessage } = sock;
13
+ const communityQuery = async (jid, type, content) => query({
14
+ tag: 'iq',
15
+ attrs: {
16
+ type,
17
+ xmlns: 'w:g2',
18
+ to: jid
19
+ },
20
+ content
21
+ });
22
+ const communityMetadata = async (jid) => {
23
+ const result = await communityQuery(jid, 'get', [{ tag: 'query', attrs: { request: 'interactive' } }]);
24
+ return extractCommunityMetadata(result);
25
+ };
26
+ const communityFetchAllParticipating = async () => {
27
+ const result = await query({
28
+ tag: 'iq',
29
+ attrs: {
30
+ to: '@g.us',
31
+ xmlns: 'w:g2',
32
+ type: 'get'
33
+ },
34
+ content: [
35
+ {
36
+ tag: 'participating',
37
+ attrs: {},
38
+ content: [
39
+ { tag: 'participants', attrs: {} },
40
+ { tag: 'description', attrs: {} }
41
+ ]
42
+ }
43
+ ]
44
+ });
45
+ const data = {};
46
+ const communitiesChild = (0, WABinary_1.getBinaryNodeChild)(result, 'communities');
47
+ if (communitiesChild) {
48
+ const communities = (0, WABinary_1.getBinaryNodeChildren)(communitiesChild, 'community');
49
+ for (const communityNode of communities) {
50
+ const meta = extractCommunityMetadata({
51
+ tag: 'result',
52
+ attrs: {},
53
+ content: [communityNode]
54
+ });
55
+ data[meta.id] = meta;
56
+ }
57
+ }
58
+ sock.ev.emit('groups.update', Object.values(data));
59
+ return data;
60
+ };
61
+ async function parseGroupResult(node) {
62
+ (0, logger_1.default).info({ node }, 'parseGroupResult');
63
+ const groupNode = (0, WABinary_1.getBinaryNodeChild)(node, 'group');
64
+ if (groupNode) {
65
+ try {
66
+ (0, logger_1.default).info({ groupNode }, 'groupNode');
67
+ const metadata = await sock.groupMetadata(`${groupNode.attrs.id}@g.us`);
68
+ return metadata ? metadata : Optional.empty();
69
+ }
70
+ catch (error) {
71
+ console.error('Error parsing group metadata:', error);
72
+ return Optional.empty();
73
+ }
74
+ }
75
+ return Optional.empty();
76
+ }
77
+ const Optional = {
78
+ empty: () => null,
79
+ of: (value) => (value !== null ? { value } : null)
80
+ };
81
+ sock.ws.on('CB:ib,,dirty', async (node) => {
82
+ const dirtyChild = (0, WABinary_1.getBinaryNodeChild)(node, 'dirty');
83
+ const { attrs } = dirtyChild;
84
+ if (attrs.type !== 'communities') {
85
+ return;
86
+ }
87
+ await communityFetchAllParticipating();
88
+ await sock.cleanDirtyBits('groups');
89
+ });
90
+ return {
91
+ ...sock,
92
+ communityMetadata,
93
+ communityCreate: async (subject, body) => {
94
+ const descriptionId = (0, Utils_1.generateMessageID)().substring(0, 12);
95
+ const result = await communityQuery('@g.us', 'set', [
96
+ {
97
+ tag: 'create',
98
+ attrs: { subject },
99
+ content: [
100
+ {
101
+ tag: 'description',
102
+ attrs: { id: descriptionId },
103
+ content: [
104
+ {
105
+ tag: 'body',
106
+ attrs: {},
107
+ content: Buffer.from(body || '', 'utf-8')
108
+ }
109
+ ]
110
+ },
111
+ {
112
+ tag: 'parent',
113
+ attrs: { default_membership_approval_mode: 'request_required' }
114
+ },
115
+ {
116
+ tag: 'allow_non_admin_sub_group_creation',
117
+ attrs: {}
118
+ },
119
+ {
120
+ tag: 'create_general_chat',
121
+ attrs: {}
122
+ }
123
+ ]
124
+ }
125
+ ]);
126
+ return await parseGroupResult(result);
127
+ },
128
+ communityCreateGroup: async (subject, participants, parentCommunityJid) => {
129
+ const key = (0, Utils_1.generateMessageIDV2)();
130
+ const result = await communityQuery('@g.us', 'set', [
131
+ {
132
+ tag: 'create',
133
+ attrs: {
134
+ subject,
135
+ key
136
+ },
137
+ content: [
138
+ ...participants.map(jid => ({
139
+ tag: 'participant',
140
+ attrs: { jid }
141
+ })),
142
+ { tag: 'linked_parent', attrs: { jid: parentCommunityJid } }
143
+ ]
144
+ }
145
+ ]);
146
+ return await parseGroupResult(result);
147
+ },
148
+ communityLeave: async (id) => {
149
+ await communityQuery('@g.us', 'set', [
150
+ {
151
+ tag: 'leave',
152
+ attrs: {},
153
+ content: [{ tag: 'community', attrs: { id } }]
154
+ }
155
+ ]);
156
+ },
157
+ communityUpdateSubject: async (jid, subject) => {
158
+ await communityQuery(jid, 'set', [
159
+ {
160
+ tag: 'subject',
161
+ attrs: {},
162
+ content: Buffer.from(subject, 'utf-8')
163
+ }
164
+ ]);
165
+ },
166
+ communityLinkGroup: async (groupJid, parentCommunityJid) => {
167
+ await communityQuery(parentCommunityJid, 'set', [
168
+ {
169
+ tag: 'links',
170
+ attrs: {},
171
+ content: [
172
+ {
173
+ tag: 'link',
174
+ attrs: { link_type: 'sub_group' },
175
+ content: [{ tag: 'group', attrs: { jid: groupJid } }]
176
+ }
177
+ ]
178
+ }
179
+ ]);
180
+ },
181
+ communityUnlinkGroup: async (groupJid, parentCommunityJid) => {
182
+ await communityQuery(parentCommunityJid, 'set', [
183
+ {
184
+ tag: 'unlink',
185
+ attrs: { unlink_type: 'sub_group' },
186
+ content: [{ tag: 'group', attrs: { jid: groupJid } }]
187
+ }
188
+ ]);
189
+ },
190
+ communityFetchLinkedGroups: async (jid) => {
191
+ let communityJid = jid;
192
+ let isCommunity = false;
193
+ // Try to determine if it is a subgroup or a community
194
+ const metadata = await sock.groupMetadata(jid);
195
+ if (metadata.linkedParent) {
196
+ // It is a subgroup, get the community jid
197
+ communityJid = metadata.linkedParent;
198
+ }
199
+ else {
200
+ // It is a community
201
+ isCommunity = true;
202
+ }
203
+ // Fetch all subgroups of the community
204
+ const result = await communityQuery(communityJid, 'get', [{ tag: 'sub_groups', attrs: {} }]);
205
+ const linkedGroupsData = [];
206
+ const subGroupsNode = (0, WABinary_1.getBinaryNodeChild)(result, 'sub_groups');
207
+ if (subGroupsNode) {
208
+ const groupNodes = (0, WABinary_1.getBinaryNodeChildren)(subGroupsNode, 'group');
209
+ for (const groupNode of groupNodes) {
210
+ linkedGroupsData.push({
211
+ id: groupNode.attrs.id ? (0, WABinary_1.jidEncode)(groupNode.attrs.id, 'g.us') : undefined,
212
+ subject: groupNode.attrs.subject || '',
213
+ creation: groupNode.attrs.creation ? Number(groupNode.attrs.creation) : undefined,
214
+ owner: groupNode.attrs.creator ? (0, WABinary_1.jidNormalizedUser)(groupNode.attrs.creator) : undefined,
215
+ size: groupNode.attrs.size ? Number(groupNode.attrs.size) : undefined
216
+ });
217
+ }
218
+ }
219
+ return {
220
+ communityJid,
221
+ isCommunity,
222
+ linkedGroups: linkedGroupsData
223
+ };
224
+ },
225
+ communityRequestParticipantsList: async (jid) => {
226
+ const result = await communityQuery(jid, 'get', [
227
+ {
228
+ tag: 'membership_approval_requests',
229
+ attrs: {}
230
+ }
231
+ ]);
232
+ const node = (0, WABinary_1.getBinaryNodeChild)(result, 'membership_approval_requests');
233
+ const participants = (0, WABinary_1.getBinaryNodeChildren)(node, 'membership_approval_request');
234
+ return participants.map(v => v.attrs);
235
+ },
236
+ communityRequestParticipantsUpdate: async (jid, participants, action) => {
237
+ const result = await communityQuery(jid, 'set', [
238
+ {
239
+ tag: 'membership_requests_action',
240
+ attrs: {},
241
+ content: [
242
+ {
243
+ tag: action,
244
+ attrs: {},
245
+ content: participants.map(jid => ({
246
+ tag: 'participant',
247
+ attrs: { jid }
248
+ }))
249
+ }
250
+ ]
251
+ }
252
+ ]);
253
+ const node = (0, WABinary_1.getBinaryNodeChild)(result, 'membership_requests_action');
254
+ const nodeAction = (0, WABinary_1.getBinaryNodeChild)(node, action);
255
+ const participantsAffected = (0, WABinary_1.getBinaryNodeChildren)(nodeAction, 'participant');
256
+ return participantsAffected.map(p => {
257
+ return { status: p.attrs.error || '200', jid: p.attrs.jid };
258
+ });
259
+ },
260
+ communityParticipantsUpdate: async (jid, participants, action) => {
261
+ const result = await communityQuery(jid, 'set', [
262
+ {
263
+ tag: action,
264
+ attrs: action === 'remove' ? { linked_groups: 'true' } : {},
265
+ content: participants.map(jid => ({
266
+ tag: 'participant',
267
+ attrs: { jid }
268
+ }))
269
+ }
270
+ ]);
271
+ const node = (0, WABinary_1.getBinaryNodeChild)(result, action);
272
+ const participantsAffected = (0, WABinary_1.getBinaryNodeChildren)(node, 'participant');
273
+ return participantsAffected.map(p => {
274
+ return { status: p.attrs.error || '200', jid: p.attrs.jid, content: p };
275
+ });
276
+ },
277
+ communityUpdateDescription: async (jid, description) => {
278
+ const metadata = await communityMetadata(jid);
279
+ const prev = metadata.descId ?? null;
280
+ await communityQuery(jid, 'set', [
281
+ {
282
+ tag: 'description',
283
+ attrs: {
284
+ ...(description ? { id: (0, Utils_1.generateMessageID)() } : { delete: 'true' }),
285
+ ...(prev ? { prev } : {})
286
+ },
287
+ content: description ? [{ tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }] : undefined
288
+ }
289
+ ]);
290
+ },
291
+ communityInviteCode: async (jid) => {
292
+ const result = await communityQuery(jid, 'get', [{ tag: 'invite', attrs: {} }]);
293
+ const inviteNode = (0, WABinary_1.getBinaryNodeChild)(result, 'invite');
294
+ return inviteNode?.attrs.code;
295
+ },
296
+ communityRevokeInvite: async (jid) => {
297
+ const result = await communityQuery(jid, 'set', [{ tag: 'invite', attrs: {} }]);
298
+ const inviteNode = (0, WABinary_1.getBinaryNodeChild)(result, 'invite');
299
+ return inviteNode?.attrs.code;
300
+ },
301
+ communityAcceptInvite: async (code) => {
302
+ const results = await communityQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }]);
303
+ const result = (0, WABinary_1.getBinaryNodeChild)(results, 'community');
304
+ return result?.attrs.jid;
305
+ },
306
+ communityRevokeInviteV4: async (communityJid, invitedJid) => {
307
+ const result = await communityQuery(communityJid, 'set', [
308
+ { tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }
309
+ ]);
310
+ return !!result;
311
+ },
312
+ /**
313
+ * accept a CommunityInviteMessage
314
+ * @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
315
+ * @param inviteMessage the message to accept
316
+ */
317
+ communityAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
318
+ key = typeof key === 'string' ? { remoteJid: key } : key;
319
+ const results = await communityQuery(inviteMessage.groupJid, 'set', [
320
+ {
321
+ tag: 'accept',
322
+ attrs: {
323
+ code: inviteMessage.inviteCode,
324
+ expiration: inviteMessage.inviteExpiration.toString(),
325
+ admin: key.remoteJid
326
+ }
327
+ }
328
+ ]);
329
+ // if we have the full message key
330
+ // update the invite message to be expired
331
+ if (key.id) {
332
+ inviteMessage = WAProto_1.proto.Message.GroupInviteMessage.fromObject(inviteMessage);
333
+ inviteMessage.inviteExpiration = 0;
334
+ inviteMessage.inviteCode = '';
335
+ ev.emit('messages.update', [
336
+ {
337
+ key,
338
+ update: {
339
+ message: {
340
+ groupInviteMessage: inviteMessage
341
+ }
342
+ }
343
+ }
344
+ ]);
345
+ }
346
+ // generate the community add message
347
+ await upsertMessage({
348
+ key: {
349
+ remoteJid: inviteMessage.groupJid,
350
+ id: (0, Utils_1.generateMessageIDV2)(sock.user?.id),
351
+ fromMe: false,
352
+ participant: key.remoteJid // TODO: investigate if this makes any sense at all
353
+ },
354
+ messageStubType: Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD,
355
+ messageStubParameters: [JSON.stringify(authState.creds.me)],
356
+ participant: key.remoteJid,
357
+ messageTimestamp: (0, Utils_1.unixTimestampSeconds)()
358
+ }, 'notify');
359
+ return results.attrs.from;
360
+ }),
361
+ communityGetInviteInfo: async (code) => {
362
+ const results = await communityQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }]);
363
+ return extractCommunityMetadata(results);
364
+ },
365
+ communityToggleEphemeral: async (jid, ephemeralExpiration) => {
366
+ const content = ephemeralExpiration
367
+ ? { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
368
+ : { tag: 'not_ephemeral', attrs: {} };
369
+ await communityQuery(jid, 'set', [content]);
370
+ },
371
+ communitySettingUpdate: async (jid, setting) => {
372
+ await communityQuery(jid, 'set', [{ tag: setting, attrs: {} }]);
373
+ },
374
+ communityMemberAddMode: async (jid, mode) => {
375
+ await communityQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }]);
376
+ },
377
+ communityJoinApprovalMode: async (jid, mode) => {
378
+ await communityQuery(jid, 'set', [
379
+ { tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'community_join', attrs: { state: mode } }] }
380
+ ]);
381
+ },
382
+ communityFetchAllParticipating
383
+ };
384
+ };
385
+ exports.makeCommunitiesSocket = makeCommunitiesSocket;
386
+ const extractCommunityMetadata = (result) => {
387
+ const community = (0, WABinary_1.getBinaryNodeChild)(result, 'community');
388
+ const descChild = (0, WABinary_1.getBinaryNodeChild)(community, 'description');
389
+ let desc;
390
+ let descId;
391
+ if (descChild) {
392
+ desc = (0, WABinary_1.getBinaryNodeChildString)(descChild, 'body');
393
+ descId = descChild.attrs.id;
394
+ }
395
+ const communityId = community.attrs.id?.includes('@')
396
+ ? community.attrs.id
397
+ : (0, WABinary_1.jidEncode)(community.attrs.id || '', 'g.us');
398
+ const eph = (0, WABinary_1.getBinaryNodeChild)(community, 'ephemeral')?.attrs.expiration;
399
+ const memberAddMode = (0, WABinary_1.getBinaryNodeChildString)(community, 'member_add_mode') === 'all_member_add';
400
+ const metadata = {
401
+ id: communityId,
402
+ subject: community.attrs.subject || '',
403
+ subjectOwner: community.attrs.s_o,
404
+ subjectTime: Number(community.attrs.s_t || 0),
405
+ size: (0, WABinary_1.getBinaryNodeChildren)(community, 'participant').length,
406
+ creation: Number(community.attrs.creation || 0),
407
+ owner: community.attrs.creator ? (0, WABinary_1.jidNormalizedUser)(community.attrs.creator) : undefined,
408
+ desc,
409
+ descId,
410
+ linkedParent: (0, WABinary_1.getBinaryNodeChild)(community, 'linked_parent')?.attrs.jid || undefined,
411
+ restrict: !!(0, WABinary_1.getBinaryNodeChild)(community, 'locked'),
412
+ announce: !!(0, WABinary_1.getBinaryNodeChild)(community, 'announcement'),
413
+ isCommunity: !!(0, WABinary_1.getBinaryNodeChild)(community, 'parent'),
414
+ isCommunityAnnounce: !!(0, WABinary_1.getBinaryNodeChild)(community, 'default_sub_community'),
415
+ joinApprovalMode: !!(0, WABinary_1.getBinaryNodeChild)(community, 'membership_approval_mode'),
416
+ memberAddMode,
417
+ participants: (0, WABinary_1.getBinaryNodeChildren)(community, 'participant').map(({ attrs }) => {
418
+ return {
419
+ // TODO: IMPLEMENT THE PN/LID FIELDS HERE!!
420
+ id: attrs.jid,
421
+ admin: attrs.type || null
422
+ };
423
+ }),
424
+ ephemeralDuration: eph ? +eph : undefined,
425
+ addressingMode: (0, WABinary_1.getBinaryNodeChildString)(community, 'addressing_mode')
426
+ };
427
+ return metadata;
428
+ };
429
+ exports.extractCommunityMetadata = extractCommunityMetadata;
430
+