@vinzsocket/baileys 2.8.30 → 3.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 (102) hide show
  1. package/WAProto/fix-imports.js +7 -16
  2. package/WAProto/index.js +1 -37306
  3. package/lib/Defaults/index.js +37 -33
  4. package/lib/Signal/Group/ciphertext-message.js +6 -2
  5. package/lib/Signal/Group/group-session-builder.js +12 -7
  6. package/lib/Signal/Group/group_cipher.js +18 -13
  7. package/lib/Signal/Group/index.js +77 -12
  8. package/lib/Signal/Group/keyhelper.js +15 -8
  9. package/lib/Signal/Group/queue-job.js +7 -2
  10. package/lib/Signal/Group/sender-chain-key.js +11 -6
  11. package/lib/Signal/Group/sender-key-distribution-message.js +10 -6
  12. package/lib/Signal/Group/sender-key-message.js +14 -9
  13. package/lib/Signal/Group/sender-key-name.js +6 -2
  14. package/lib/Signal/Group/sender-key-record.js +13 -9
  15. package/lib/Signal/Group/sender-key-state.js +10 -6
  16. package/lib/Signal/Group/sender-message-key.js +9 -4
  17. package/lib/Signal/libsignal.js +34 -28
  18. package/lib/Signal/lid-mapping.js +24 -19
  19. package/lib/Socket/Client/index.js +25 -3
  20. package/lib/Socket/Client/types.js +8 -4
  21. package/lib/Socket/Client/websocket.js +16 -11
  22. package/lib/Socket/business.js +38 -34
  23. package/lib/Socket/chats.js +100 -95
  24. package/lib/Socket/communities.js +55 -49
  25. package/lib/Socket/groups.js +56 -51
  26. package/lib/Socket/index.js +9 -6
  27. package/lib/Socket/messages-recv.js +150 -145
  28. package/lib/Socket/messages-send.js +109 -104
  29. package/lib/Socket/mex.js +12 -8
  30. package/lib/Socket/newsletter.js +27 -23
  31. package/lib/Socket/socket.js +111 -107
  32. package/lib/Store/index.js +47 -4
  33. package/lib/Store/make-cache-manager-store.js +17 -11
  34. package/lib/Store/make-in-memory-store.js +31 -29
  35. package/lib/Store/make-ordered-dictionary.js +7 -2
  36. package/lib/Store/object-repository.js +7 -2
  37. package/lib/Types/Auth.js +3 -2
  38. package/lib/Types/Bussines.js +3 -2
  39. package/lib/Types/Call.js +3 -2
  40. package/lib/Types/Chat.js +5 -2
  41. package/lib/Types/Contact.js +3 -2
  42. package/lib/Types/Events.js +1 -2
  43. package/lib/Types/GroupMetadata.js +3 -2
  44. package/lib/Types/Label.js +6 -3
  45. package/lib/Types/LabelAssociation.js +6 -3
  46. package/lib/Types/Message.js +16 -7
  47. package/lib/Types/Newsletter.js +8 -5
  48. package/lib/Types/Product.js +3 -2
  49. package/lib/Types/Signal.js +1 -2
  50. package/lib/Types/Socket.js +2 -3
  51. package/lib/Types/State.js +7 -4
  52. package/lib/Types/USync.js +1 -2
  53. package/lib/Types/index.js +153 -15
  54. package/lib/Utils/auth-utils.js +32 -25
  55. package/lib/Utils/baileys-event-stream.js +21 -15
  56. package/lib/Utils/business.js +71 -61
  57. package/lib/Utils/chat-utils.js +91 -77
  58. package/lib/Utils/crypto.js +54 -32
  59. package/lib/Utils/decode-wa-message.js +46 -39
  60. package/lib/Utils/event-buffer.js +24 -19
  61. package/lib/Utils/extended-messages.js +14 -9
  62. package/lib/Utils/generics.js +100 -64
  63. package/lib/Utils/history.js +30 -23
  64. package/lib/Utils/index.js +234 -22
  65. package/lib/Utils/lid-resolver.js +12 -5
  66. package/lib/Utils/link-preview.js +11 -7
  67. package/lib/Utils/logger.js +8 -4
  68. package/lib/Utils/lt-hash.js +8 -5
  69. package/lib/Utils/make-mutex.js +8 -3
  70. package/lib/Utils/mention.js +12 -4
  71. package/lib/Utils/message-retry-manager.js +10 -6
  72. package/lib/Utils/messages-media.js +127 -95
  73. package/lib/Utils/messages.js +122 -98
  74. package/lib/Utils/noise-handler.js +25 -21
  75. package/lib/Utils/process-message.js +72 -63
  76. package/lib/Utils/signal.js +45 -33
  77. package/lib/Utils/use-multi-file-auth-state.js +24 -20
  78. package/lib/Utils/validate-connection.js +54 -47
  79. package/lib/WABinary/constants.js +9 -6
  80. package/lib/WABinary/decode.js +17 -10
  81. package/lib/WABinary/encode.js +11 -6
  82. package/lib/WABinary/generic-utils.js +31 -17
  83. package/lib/WABinary/index.js +58 -6
  84. package/lib/WABinary/jid-utils.js +36 -20
  85. package/lib/WABinary/types.js +2 -2
  86. package/lib/WAM/BinaryInfo.js +6 -2
  87. package/lib/WAM/constants.js +1 -1
  88. package/lib/WAM/encode.js +16 -12
  89. package/lib/WAM/index.js +36 -4
  90. package/lib/WAUSync/Protocols/USyncContactProtocol.js +9 -5
  91. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +10 -6
  92. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +8 -4
  93. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +8 -4
  94. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +9 -4
  95. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +23 -19
  96. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +6 -2
  97. package/lib/WAUSync/Protocols/index.js +58 -6
  98. package/lib/WAUSync/USyncQuery.js +21 -17
  99. package/lib/WAUSync/USyncUser.js +6 -2
  100. package/lib/WAUSync/index.js +36 -4
  101. package/lib/index.js +112 -12
  102. package/package.json +8 -6
@@ -1,11 +1,16 @@
1
- import { proto } from '../../WAProto/index.js';
2
- import { WAMessageStubType } from '../Types/index.js';
3
- import { generateMessageID, generateMessageIDV2, unixTimestampSeconds } from '../Utils/index.js';
4
- import logger from '../Utils/logger.js';
5
- import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString, jidEncode, jidNormalizedUser } from '../WABinary/index.js';
6
- import { makeBusinessSocket } from './business.js';
7
- export const makeCommunitiesSocket = config => {
8
- const sock = makeBusinessSocket(config);
1
+ Object.defineProperty(exports, "__esModule", {
2
+ value: true
3
+ });
4
+ exports.makeCommunitiesSocket = exports.extractCommunityMetadata = void 0;
5
+ var _index = require("../../WAProto/index.js");
6
+ var _index2 = require("../Types/index.js");
7
+ var _index3 = require("../Utils/index.js");
8
+ var _logger = _interopRequireDefault(require("../Utils/logger.js"));
9
+ var _index4 = require("../WABinary/index.js");
10
+ var _business = require("./business.js");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const makeCommunitiesSocket = config => {
13
+ const sock = (0, _business.makeBusinessSocket)(config);
9
14
  const {
10
15
  authState,
11
16
  ev,
@@ -51,9 +56,9 @@ export const makeCommunitiesSocket = config => {
51
56
  }]
52
57
  });
53
58
  const data = {};
54
- const communitiesChild = getBinaryNodeChild(result, 'communities');
59
+ const communitiesChild = (0, _index4.getBinaryNodeChild)(result, 'communities');
55
60
  if (communitiesChild) {
56
- const communities = getBinaryNodeChildren(communitiesChild, 'community');
61
+ const communities = (0, _index4.getBinaryNodeChildren)(communitiesChild, 'community');
57
62
  for (const communityNode of communities) {
58
63
  const meta = extractCommunityMetadata({
59
64
  tag: 'result',
@@ -67,13 +72,13 @@ export const makeCommunitiesSocket = config => {
67
72
  return data;
68
73
  };
69
74
  async function parseGroupResult(node) {
70
- logger.info({
75
+ _logger.default.info({
71
76
  node
72
77
  }, 'parseGroupResult');
73
- const groupNode = getBinaryNodeChild(node, 'group');
78
+ const groupNode = (0, _index4.getBinaryNodeChild)(node, 'group');
74
79
  if (groupNode) {
75
80
  try {
76
- logger.info({
81
+ _logger.default.info({
77
82
  groupNode
78
83
  }, 'groupNode');
79
84
  const metadata = await sock.groupMetadata(`${groupNode.attrs.id}@g.us`);
@@ -94,7 +99,7 @@ export const makeCommunitiesSocket = config => {
94
99
  sock.ws.on('CB:ib,,dirty', async node => {
95
100
  const {
96
101
  attrs
97
- } = getBinaryNodeChild(node, 'dirty');
102
+ } = (0, _index4.getBinaryNodeChild)(node, 'dirty');
98
103
  if (attrs.type !== 'communities') {
99
104
  return;
100
105
  }
@@ -105,7 +110,7 @@ export const makeCommunitiesSocket = config => {
105
110
  ...sock,
106
111
  communityMetadata,
107
112
  communityCreate: async (subject, body) => {
108
- const descriptionId = generateMessageID().substring(0, 12);
113
+ const descriptionId = (0, _index3.generateMessageID)().substring(0, 12);
109
114
  const result = await communityQuery('@g.us', 'set', [{
110
115
  tag: 'create',
111
116
  attrs: {
@@ -137,7 +142,7 @@ export const makeCommunitiesSocket = config => {
137
142
  return await parseGroupResult(result);
138
143
  },
139
144
  communityCreateGroup: async (subject, participants, parentCommunityJid) => {
140
- const key = generateMessageIDV2();
145
+ const key = (0, _index3.generateMessageIDV2)();
141
146
  const result = await communityQuery('@g.us', 'set', [{
142
147
  tag: 'create',
143
148
  attrs: {
@@ -214,8 +219,8 @@ export const makeCommunitiesSocket = config => {
214
219
  tag: 'membership_approval_requests',
215
220
  attrs: {}
216
221
  }]);
217
- const node = getBinaryNodeChild(result, 'membership_approval_requests');
218
- const participants = getBinaryNodeChildren(node, 'membership_approval_request');
222
+ const node = (0, _index4.getBinaryNodeChild)(result, 'membership_approval_requests');
223
+ const participants = (0, _index4.getBinaryNodeChildren)(node, 'membership_approval_request');
219
224
  return participants.map(v => v.attrs);
220
225
  },
221
226
  communityRequestParticipantsUpdate: async (jid, participants, action) => {
@@ -233,9 +238,9 @@ export const makeCommunitiesSocket = config => {
233
238
  }))
234
239
  }]
235
240
  }]);
236
- const node = getBinaryNodeChild(result, 'membership_requests_action');
237
- const nodeAction = getBinaryNodeChild(node, action);
238
- const participantsAffected = getBinaryNodeChildren(nodeAction, 'participant');
241
+ const node = (0, _index4.getBinaryNodeChild)(result, 'membership_requests_action');
242
+ const nodeAction = (0, _index4.getBinaryNodeChild)(node, action);
243
+ const participantsAffected = (0, _index4.getBinaryNodeChildren)(nodeAction, 'participant');
239
244
  return participantsAffected.map(p => {
240
245
  return {
241
246
  status: p.attrs.error || '200',
@@ -254,8 +259,8 @@ export const makeCommunitiesSocket = config => {
254
259
  }
255
260
  }))
256
261
  }]);
257
- const node = getBinaryNodeChild(result, action);
258
- const participantsAffected = getBinaryNodeChildren(node, 'participant');
262
+ const node = (0, _index4.getBinaryNodeChild)(result, action);
263
+ const participantsAffected = (0, _index4.getBinaryNodeChildren)(node, 'participant');
259
264
  return participantsAffected.map(p => {
260
265
  return {
261
266
  status: p.attrs.error || '200',
@@ -271,7 +276,7 @@ export const makeCommunitiesSocket = config => {
271
276
  tag: 'description',
272
277
  attrs: {
273
278
  ...(description ? {
274
- id: generateMessageID()
279
+ id: (0, _index3.generateMessageID)()
275
280
  } : {
276
281
  delete: 'true'
277
282
  }),
@@ -291,7 +296,7 @@ export const makeCommunitiesSocket = config => {
291
296
  tag: 'invite',
292
297
  attrs: {}
293
298
  }]);
294
- const inviteNode = getBinaryNodeChild(result, 'invite');
299
+ const inviteNode = (0, _index4.getBinaryNodeChild)(result, 'invite');
295
300
  return inviteNode?.attrs.code;
296
301
  },
297
302
  communityRevokeInvite: async jid => {
@@ -299,7 +304,7 @@ export const makeCommunitiesSocket = config => {
299
304
  tag: 'invite',
300
305
  attrs: {}
301
306
  }]);
302
- const inviteNode = getBinaryNodeChild(result, 'invite');
307
+ const inviteNode = (0, _index4.getBinaryNodeChild)(result, 'invite');
303
308
  return inviteNode?.attrs.code;
304
309
  },
305
310
  communityAcceptInvite: async code => {
@@ -309,7 +314,7 @@ export const makeCommunitiesSocket = config => {
309
314
  code
310
315
  }
311
316
  }]);
312
- const result = getBinaryNodeChild(results, 'community');
317
+ const result = (0, _index4.getBinaryNodeChild)(results, 'community');
313
318
  return result?.attrs.jid;
314
319
  },
315
320
  /**
@@ -352,7 +357,7 @@ export const makeCommunitiesSocket = config => {
352
357
  // update the invite message to be expired
353
358
  if (key.id) {
354
359
  // create new invite message that is expired
355
- inviteMessage = proto.Message.GroupInviteMessage.create(inviteMessage);
360
+ inviteMessage = _index.proto.Message.GroupInviteMessage.create(inviteMessage);
356
361
  inviteMessage.inviteExpiration = 0;
357
362
  inviteMessage.inviteCode = '';
358
363
  ev.emit('messages.update', [{
@@ -368,14 +373,14 @@ export const makeCommunitiesSocket = config => {
368
373
  await upsertMessage({
369
374
  key: {
370
375
  remoteJid: inviteMessage.groupJid,
371
- id: generateMessageIDV2(sock.user?.id),
376
+ id: (0, _index3.generateMessageIDV2)(sock.user?.id),
372
377
  fromMe: false,
373
378
  participant: key.remoteJid
374
379
  },
375
- messageStubType: WAMessageStubType.GROUP_PARTICIPANT_ADD,
380
+ messageStubType: _index2.WAMessageStubType.GROUP_PARTICIPANT_ADD,
376
381
  messageStubParameters: [authState.creds.me.id],
377
382
  participant: key.remoteJid,
378
- messageTimestamp: unixTimestampSeconds()
383
+ messageTimestamp: (0, _index3.unixTimestampSeconds)()
379
384
  }, 'notify');
380
385
  return results.attrs.from;
381
386
  }),
@@ -428,36 +433,37 @@ export const makeCommunitiesSocket = config => {
428
433
  communityFetchAllParticipating
429
434
  };
430
435
  };
431
- export const extractCommunityMetadata = result => {
432
- const community = getBinaryNodeChild(result, 'community');
433
- const descChild = getBinaryNodeChild(community, 'description');
436
+ exports.makeCommunitiesSocket = makeCommunitiesSocket;
437
+ const extractCommunityMetadata = result => {
438
+ const community = (0, _index4.getBinaryNodeChild)(result, 'community');
439
+ const descChild = (0, _index4.getBinaryNodeChild)(community, 'description');
434
440
  let desc;
435
441
  let descId;
436
442
  if (descChild) {
437
- desc = getBinaryNodeChildString(descChild, 'body');
443
+ desc = (0, _index4.getBinaryNodeChildString)(descChild, 'body');
438
444
  descId = descChild.attrs.id;
439
445
  }
440
- const communityId = community.attrs.id?.includes('@') ? community.attrs.id : jidEncode(community.attrs.id || '', 'g.us');
441
- const eph = getBinaryNodeChild(community, 'ephemeral')?.attrs.expiration;
442
- const memberAddMode = getBinaryNodeChildString(community, 'member_add_mode') === 'all_member_add';
446
+ const communityId = community.attrs.id?.includes('@') ? community.attrs.id : (0, _index4.jidEncode)(community.attrs.id || '', 'g.us');
447
+ const eph = (0, _index4.getBinaryNodeChild)(community, 'ephemeral')?.attrs.expiration;
448
+ const memberAddMode = (0, _index4.getBinaryNodeChildString)(community, 'member_add_mode') === 'all_member_add';
443
449
  const metadata = {
444
450
  id: communityId,
445
451
  subject: community.attrs.subject || '',
446
452
  subjectOwner: community.attrs.s_o,
447
453
  subjectTime: Number(community.attrs.s_t || 0),
448
- size: getBinaryNodeChildren(community, 'participant').length,
454
+ size: (0, _index4.getBinaryNodeChildren)(community, 'participant').length,
449
455
  creation: Number(community.attrs.creation || 0),
450
- owner: community.attrs.creator ? jidNormalizedUser(community.attrs.creator) : undefined,
456
+ owner: community.attrs.creator ? (0, _index4.jidNormalizedUser)(community.attrs.creator) : undefined,
451
457
  desc,
452
458
  descId,
453
- linkedParent: getBinaryNodeChild(community, 'linked_parent')?.attrs.jid || undefined,
454
- restrict: !!getBinaryNodeChild(community, 'locked'),
455
- announce: !!getBinaryNodeChild(community, 'announcement'),
456
- isCommunity: !!getBinaryNodeChild(community, 'parent'),
457
- isCommunityAnnounce: !!getBinaryNodeChild(community, 'default_sub_community'),
458
- joinApprovalMode: !!getBinaryNodeChild(community, 'membership_approval_mode'),
459
+ linkedParent: (0, _index4.getBinaryNodeChild)(community, 'linked_parent')?.attrs.jid || undefined,
460
+ restrict: !!(0, _index4.getBinaryNodeChild)(community, 'locked'),
461
+ announce: !!(0, _index4.getBinaryNodeChild)(community, 'announcement'),
462
+ isCommunity: !!(0, _index4.getBinaryNodeChild)(community, 'parent'),
463
+ isCommunityAnnounce: !!(0, _index4.getBinaryNodeChild)(community, 'default_sub_community'),
464
+ joinApprovalMode: !!(0, _index4.getBinaryNodeChild)(community, 'membership_approval_mode'),
459
465
  memberAddMode,
460
- participants: getBinaryNodeChildren(community, 'participant').map(({
466
+ participants: (0, _index4.getBinaryNodeChildren)(community, 'participant').map(({
461
467
  attrs
462
468
  }) => {
463
469
  return {
@@ -466,8 +472,8 @@ export const extractCommunityMetadata = result => {
466
472
  };
467
473
  }),
468
474
  ephemeralDuration: eph ? +eph : undefined,
469
- addressingMode: getBinaryNodeChildString(community, 'addressing_mode')
475
+ addressingMode: (0, _index4.getBinaryNodeChildString)(community, 'addressing_mode')
470
476
  };
471
477
  return metadata;
472
478
  };
473
- //# sourceMappingURL=communities.js.map
479
+ exports.extractCommunityMetadata = extractCommunityMetadata;
@@ -1,11 +1,15 @@
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 { feedGroupMetadata } from '../Utils/lid-resolver.js';
5
- import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString, isLidUser, isPnUser, jidEncode, jidNormalizedUser } from '../WABinary/index.js';
6
- import { makeChatsSocket } from './chats.js';
7
- export const makeGroupsSocket = config => {
8
- const sock = makeChatsSocket(config);
1
+ Object.defineProperty(exports, "__esModule", {
2
+ value: true
3
+ });
4
+ exports.makeGroupsSocket = exports.extractGroupMetadata = void 0;
5
+ var _index = require("../../WAProto/index.js");
6
+ var _index2 = require("../Types/index.js");
7
+ var _index3 = require("../Utils/index.js");
8
+ var _lidResolver = require("../Utils/lid-resolver.js");
9
+ var _index4 = require("../WABinary/index.js");
10
+ var _chats = require("./chats.js");
11
+ const makeGroupsSocket = config => {
12
+ const sock = (0, _chats.makeChatsSocket)(config);
9
13
  const {
10
14
  authState,
11
15
  ev,
@@ -51,9 +55,9 @@ export const makeGroupsSocket = config => {
51
55
  }]
52
56
  });
53
57
  const data = {};
54
- const groupsChild = getBinaryNodeChild(result, 'groups');
58
+ const groupsChild = (0, _index4.getBinaryNodeChild)(result, 'groups');
55
59
  if (groupsChild) {
56
- const groups = getBinaryNodeChildren(groupsChild, 'group');
60
+ const groups = (0, _index4.getBinaryNodeChildren)(groupsChild, 'group');
57
61
  for (const groupNode of groups) {
58
62
  const meta = extractGroupMetadata({
59
63
  tag: 'result',
@@ -69,7 +73,7 @@ export const makeGroupsSocket = config => {
69
73
  sock.ws.on('CB:ib,,dirty', async node => {
70
74
  const {
71
75
  attrs
72
- } = getBinaryNodeChild(node, 'dirty');
76
+ } = (0, _index4.getBinaryNodeChild)(node, 'dirty');
73
77
  if (attrs.type !== 'groups') {
74
78
  return;
75
79
  }
@@ -80,7 +84,7 @@ export const makeGroupsSocket = config => {
80
84
  ...sock,
81
85
  groupMetadata,
82
86
  groupCreate: async (subject, participants) => {
83
- const key = generateMessageIDV2();
87
+ const key = (0, _index3.generateMessageIDV2)();
84
88
  const result = await groupQuery('@g.us', 'set', [{
85
89
  tag: 'create',
86
90
  attrs: {
@@ -120,8 +124,8 @@ export const makeGroupsSocket = config => {
120
124
  tag: 'membership_approval_requests',
121
125
  attrs: {}
122
126
  }]);
123
- const node = getBinaryNodeChild(result, 'membership_approval_requests');
124
- const participants = getBinaryNodeChildren(node, 'membership_approval_request');
127
+ const node = (0, _index4.getBinaryNodeChild)(result, 'membership_approval_requests');
128
+ const participants = (0, _index4.getBinaryNodeChildren)(node, 'membership_approval_request');
125
129
  return participants.map(v => v.attrs);
126
130
  },
127
131
  groupRequestParticipantsUpdate: async (jid, participants, action) => {
@@ -139,9 +143,9 @@ export const makeGroupsSocket = config => {
139
143
  }))
140
144
  }]
141
145
  }]);
142
- const node = getBinaryNodeChild(result, 'membership_requests_action');
143
- const nodeAction = getBinaryNodeChild(node, action);
144
- const participantsAffected = getBinaryNodeChildren(nodeAction, 'participant');
146
+ const node = (0, _index4.getBinaryNodeChild)(result, 'membership_requests_action');
147
+ const nodeAction = (0, _index4.getBinaryNodeChild)(node, action);
148
+ const participantsAffected = (0, _index4.getBinaryNodeChildren)(nodeAction, 'participant');
145
149
  return participantsAffected.map(p => {
146
150
  return {
147
151
  status: p.attrs.error || '200',
@@ -160,8 +164,8 @@ export const makeGroupsSocket = config => {
160
164
  }
161
165
  }))
162
166
  }]);
163
- const node = getBinaryNodeChild(result, action);
164
- const participantsAffected = getBinaryNodeChildren(node, 'participant');
167
+ const node = (0, _index4.getBinaryNodeChild)(result, action);
168
+ const participantsAffected = (0, _index4.getBinaryNodeChildren)(node, 'participant');
165
169
  return participantsAffected.map(p => {
166
170
  return {
167
171
  status: p.attrs.error || '200',
@@ -177,7 +181,7 @@ export const makeGroupsSocket = config => {
177
181
  tag: 'description',
178
182
  attrs: {
179
183
  ...(description ? {
180
- id: generateMessageIDV2()
184
+ id: (0, _index3.generateMessageIDV2)()
181
185
  } : {
182
186
  delete: 'true'
183
187
  }),
@@ -197,7 +201,7 @@ export const makeGroupsSocket = config => {
197
201
  tag: 'invite',
198
202
  attrs: {}
199
203
  }]);
200
- const inviteNode = getBinaryNodeChild(result, 'invite');
204
+ const inviteNode = (0, _index4.getBinaryNodeChild)(result, 'invite');
201
205
  return inviteNode?.attrs.code;
202
206
  },
203
207
  groupRevokeInvite: async jid => {
@@ -205,7 +209,7 @@ export const makeGroupsSocket = config => {
205
209
  tag: 'invite',
206
210
  attrs: {}
207
211
  }]);
208
- const inviteNode = getBinaryNodeChild(result, 'invite');
212
+ const inviteNode = (0, _index4.getBinaryNodeChild)(result, 'invite');
209
213
  return inviteNode?.attrs.code;
210
214
  },
211
215
  groupAcceptInvite: async code => {
@@ -215,7 +219,7 @@ export const makeGroupsSocket = config => {
215
219
  code
216
220
  }
217
221
  }]);
218
- const result = getBinaryNodeChild(results, 'group');
222
+ const result = (0, _index4.getBinaryNodeChild)(results, 'group');
219
223
  return result?.attrs.jid;
220
224
  },
221
225
  /**
@@ -258,7 +262,7 @@ export const makeGroupsSocket = config => {
258
262
  // update the invite message to be expired
259
263
  if (key.id) {
260
264
  // create new invite message that is expired
261
- inviteMessage = proto.Message.GroupInviteMessage.create(inviteMessage);
265
+ inviteMessage = _index.proto.Message.GroupInviteMessage.create(inviteMessage);
262
266
  inviteMessage.inviteExpiration = 0;
263
267
  inviteMessage.inviteCode = '';
264
268
  ev.emit('messages.update', [{
@@ -274,14 +278,14 @@ export const makeGroupsSocket = config => {
274
278
  await upsertMessage({
275
279
  key: {
276
280
  remoteJid: inviteMessage.groupJid,
277
- id: generateMessageIDV2(sock.user?.id),
281
+ id: (0, _index3.generateMessageIDV2)(sock.user?.id),
278
282
  fromMe: false,
279
283
  participant: key.remoteJid
280
284
  },
281
- messageStubType: WAMessageStubType.GROUP_PARTICIPANT_ADD,
285
+ messageStubType: _index2.WAMessageStubType.GROUP_PARTICIPANT_ADD,
282
286
  messageStubParameters: [authState.creds.me.id],
283
287
  participant: key.remoteJid,
284
- messageTimestamp: unixTimestampSeconds()
288
+ messageTimestamp: (0, _index3.unixTimestampSeconds)()
285
289
  }, 'notify');
286
290
  return results.attrs.from;
287
291
  }),
@@ -334,62 +338,63 @@ export const makeGroupsSocket = config => {
334
338
  groupFetchAllParticipating
335
339
  };
336
340
  };
337
- export const extractGroupMetadata = result => {
338
- const group = getBinaryNodeChild(result, 'group');
339
- const descChild = getBinaryNodeChild(group, 'description');
341
+ exports.makeGroupsSocket = makeGroupsSocket;
342
+ const extractGroupMetadata = result => {
343
+ const group = (0, _index4.getBinaryNodeChild)(result, 'group');
344
+ const descChild = (0, _index4.getBinaryNodeChild)(group, 'description');
340
345
  let desc;
341
346
  let descId;
342
347
  let descOwner;
343
348
  let descOwnerPn;
344
349
  let descTime;
345
350
  if (descChild) {
346
- desc = getBinaryNodeChildString(descChild, 'body');
347
- descOwner = descChild.attrs.participant ? jidNormalizedUser(descChild.attrs.participant) : undefined;
348
- descOwnerPn = descChild.attrs.participant_pn ? jidNormalizedUser(descChild.attrs.participant_pn) : undefined;
351
+ desc = (0, _index4.getBinaryNodeChildString)(descChild, 'body');
352
+ descOwner = descChild.attrs.participant ? (0, _index4.jidNormalizedUser)(descChild.attrs.participant) : undefined;
353
+ descOwnerPn = descChild.attrs.participant_pn ? (0, _index4.jidNormalizedUser)(descChild.attrs.participant_pn) : undefined;
349
354
  descTime = +descChild.attrs.t;
350
355
  descId = descChild.attrs.id;
351
356
  }
352
- const groupId = group.attrs.id.includes('@') ? group.attrs.id : jidEncode(group.attrs.id, 'g.us');
353
- const eph = getBinaryNodeChild(group, 'ephemeral')?.attrs.expiration;
354
- const memberAddMode = getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add';
357
+ const groupId = group.attrs.id.includes('@') ? group.attrs.id : (0, _index4.jidEncode)(group.attrs.id, 'g.us');
358
+ const eph = (0, _index4.getBinaryNodeChild)(group, 'ephemeral')?.attrs.expiration;
359
+ const memberAddMode = (0, _index4.getBinaryNodeChildString)(group, 'member_add_mode') === 'all_member_add';
355
360
  const metadata = {
356
361
  id: groupId,
357
362
  notify: group.attrs.notify,
358
- addressingMode: group.attrs.addressing_mode === 'lid' ? WAMessageAddressingMode.LID : WAMessageAddressingMode.PN,
363
+ addressingMode: group.attrs.addressing_mode === 'lid' ? _index2.WAMessageAddressingMode.LID : _index2.WAMessageAddressingMode.PN,
359
364
  subject: group.attrs.subject,
360
365
  subjectOwner: group.attrs.s_o,
361
366
  subjectOwnerPn: group.attrs.s_o_pn,
362
367
  subjectTime: +group.attrs.s_t,
363
- size: group.attrs.size ? +group.attrs.size : getBinaryNodeChildren(group, 'participant').length,
368
+ size: group.attrs.size ? +group.attrs.size : (0, _index4.getBinaryNodeChildren)(group, 'participant').length,
364
369
  creation: +group.attrs.creation,
365
- owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
366
- ownerPn: group.attrs.creator_pn ? jidNormalizedUser(group.attrs.creator_pn) : undefined,
370
+ owner: group.attrs.creator ? (0, _index4.jidNormalizedUser)(group.attrs.creator) : undefined,
371
+ ownerPn: group.attrs.creator_pn ? (0, _index4.jidNormalizedUser)(group.attrs.creator_pn) : undefined,
367
372
  owner_country_code: group.attrs.creator_country_code,
368
373
  desc,
369
374
  descId,
370
375
  descOwner,
371
376
  descOwnerPn,
372
377
  descTime,
373
- linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
374
- restrict: !!getBinaryNodeChild(group, 'locked'),
375
- announce: !!getBinaryNodeChild(group, 'announcement'),
376
- isCommunity: !!getBinaryNodeChild(group, 'parent'),
377
- isCommunityAnnounce: !!getBinaryNodeChild(group, 'default_sub_group'),
378
- joinApprovalMode: !!getBinaryNodeChild(group, 'membership_approval_mode'),
378
+ linkedParent: (0, _index4.getBinaryNodeChild)(group, 'linked_parent')?.attrs.jid || undefined,
379
+ restrict: !!(0, _index4.getBinaryNodeChild)(group, 'locked'),
380
+ announce: !!(0, _index4.getBinaryNodeChild)(group, 'announcement'),
381
+ isCommunity: !!(0, _index4.getBinaryNodeChild)(group, 'parent'),
382
+ isCommunityAnnounce: !!(0, _index4.getBinaryNodeChild)(group, 'default_sub_group'),
383
+ joinApprovalMode: !!(0, _index4.getBinaryNodeChild)(group, 'membership_approval_mode'),
379
384
  memberAddMode,
380
- participants: getBinaryNodeChildren(group, 'participant').map(({
385
+ participants: (0, _index4.getBinaryNodeChildren)(group, 'participant').map(({
381
386
  attrs
382
387
  }) => {
383
388
  return {
384
389
  id: attrs.jid,
385
- phoneNumber: isLidUser(attrs.jid) && isPnUser(attrs.phoneNumber) ? attrs.phoneNumber : undefined,
386
- lid: isPnUser(attrs.jid) && isLidUser(attrs.lid) ? attrs.lid : undefined,
390
+ phoneNumber: (0, _index4.isLidUser)(attrs.jid) && (0, _index4.isPnUser)(attrs.phoneNumber) ? attrs.phoneNumber : undefined,
391
+ lid: (0, _index4.isPnUser)(attrs.jid) && (0, _index4.isLidUser)(attrs.lid) ? attrs.lid : undefined,
387
392
  admin: attrs.type || null
388
393
  };
389
394
  }),
390
395
  ephemeralDuration: eph ? +eph : undefined
391
396
  };
392
- feedGroupMetadata(metadata);
397
+ (0, _lidResolver.feedGroupMetadata)(metadata);
393
398
  return metadata;
394
399
  };
395
- //# sourceMappingURL=groups.js.map
400
+ exports.extractGroupMetadata = extractGroupMetadata;
@@ -1,9 +1,13 @@
1
- import { DEFAULT_CONNECTION_CONFIG } from '../Defaults/index.js';
2
- import { makeCommunitiesSocket } from './communities.js';
1
+ Object.defineProperty(exports, "__esModule", {
2
+ value: true
3
+ });
4
+ exports.default = void 0;
5
+ var _index = require("../Defaults/index.js");
6
+ var _communities = require("./communities.js");
3
7
  // export the last socket layer
4
8
  const makeWASocket = config => {
5
9
  const newConfig = {
6
- ...DEFAULT_CONNECTION_CONFIG,
10
+ ..._index.DEFAULT_CONNECTION_CONFIG,
7
11
  ...config
8
12
  };
9
13
  // If the user hasn't provided their own history sync function,
@@ -11,7 +15,6 @@ const makeWASocket = config => {
11
15
  if (config.shouldSyncHistoryMessage === undefined) {
12
16
  newConfig.shouldSyncHistoryMessage = () => !!newConfig.syncFullHistory;
13
17
  }
14
- return makeCommunitiesSocket(newConfig);
18
+ return (0, _communities.makeCommunitiesSocket)(newConfig);
15
19
  };
16
- export default makeWASocket;
17
- //# sourceMappingURL=index.js.map
20
+ var _default = exports.default = makeWASocket;