@vinzsocket/baileys 2.8.10 → 2.8.30

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 (83) hide show
  1. package/lib/Defaults/index.js +75 -73
  2. package/lib/Signal/Group/ciphertext-message.js +9 -9
  3. package/lib/Signal/Group/group-session-builder.js +21 -21
  4. package/lib/Signal/Group/group_cipher.js +79 -81
  5. package/lib/Signal/Group/index.js +2 -2
  6. package/lib/Signal/Group/keyhelper.js +9 -9
  7. package/lib/Signal/Group/queue-job.js +43 -46
  8. package/lib/Signal/Group/sender-chain-key.js +24 -25
  9. package/lib/Signal/Group/sender-key-distribution-message.js +50 -58
  10. package/lib/Signal/Group/sender-key-message.js +55 -60
  11. package/lib/Signal/Group/sender-key-name.js +38 -39
  12. package/lib/Signal/Group/sender-key-record.js +39 -41
  13. package/lib/Signal/Group/sender-key-state.js +85 -89
  14. package/lib/Signal/Group/sender-message-key.js +22 -22
  15. package/lib/Signal/libsignal.js +387 -292
  16. package/lib/Signal/lid-mapping.js +98 -93
  17. package/lib/Socket/Client/types.js +6 -6
  18. package/lib/Socket/Client/websocket.js +44 -44
  19. package/lib/Socket/business.js +350 -365
  20. package/lib/Socket/chats.js +1019 -914
  21. package/lib/Socket/communities.js +454 -376
  22. package/lib/Socket/groups.js +378 -310
  23. package/lib/Socket/index.js +11 -11
  24. package/lib/Socket/messages-recv.js +1355 -1182
  25. package/lib/Socket/messages-send.js +1224 -1081
  26. package/lib/Socket/mex.js +40 -34
  27. package/lib/Socket/newsletter.js +212 -169
  28. package/lib/Socket/socket.js +896 -757
  29. package/lib/Store/index.js +1 -1
  30. package/lib/Store/make-cache-manager-store.js +75 -79
  31. package/lib/Store/make-in-memory-store.js +450 -389
  32. package/lib/Store/make-ordered-dictionary.js +73 -76
  33. package/lib/Store/object-repository.js +24 -22
  34. package/lib/Types/Chat.js +1 -7
  35. package/lib/Types/Label.js +20 -20
  36. package/lib/Types/LabelAssociation.js +2 -2
  37. package/lib/Types/Message.js +2 -2
  38. package/lib/Types/Newsletter.js +24 -24
  39. package/lib/Types/Socket.js +1 -1
  40. package/lib/Types/State.js +8 -8
  41. package/lib/Types/index.js +10 -10
  42. package/lib/Utils/auth-utils.js +408 -401
  43. package/lib/Utils/baileys-event-stream.js +44 -35
  44. package/lib/Utils/business.js +200 -197
  45. package/lib/Utils/chat-utils.js +775 -708
  46. package/lib/Utils/crypto.js +97 -85
  47. package/lib/Utils/decode-wa-message.js +240 -227
  48. package/lib/Utils/event-buffer.js +547 -518
  49. package/lib/Utils/extended-messages.js +250 -203
  50. package/lib/Utils/generics.js +300 -289
  51. package/lib/Utils/history.js +76 -69
  52. package/lib/Utils/lid-resolver.js +47 -42
  53. package/lib/Utils/link-preview.js +75 -65
  54. package/lib/Utils/logger.js +3 -1
  55. package/lib/Utils/lt-hash.js +38 -34
  56. package/lib/Utils/make-mutex.js +32 -34
  57. package/lib/Utils/mention.js +79 -86
  58. package/lib/Utils/message-retry-manager.js +148 -136
  59. package/lib/Utils/messages-media.js +652 -562
  60. package/lib/Utils/messages.js +753 -707
  61. package/lib/Utils/noise-handler.js +156 -135
  62. package/lib/Utils/process-message.js +404 -341
  63. package/lib/Utils/signal.js +180 -118
  64. package/lib/Utils/use-multi-file-auth-state.js +87 -91
  65. package/lib/Utils/validate-connection.js +167 -142
  66. package/lib/WABinary/constants.js +28 -1293
  67. package/lib/WABinary/decode.js +220 -218
  68. package/lib/WABinary/encode.js +199 -201
  69. package/lib/WABinary/generic-utils.js +80 -77
  70. package/lib/WABinary/jid-utils.js +41 -35
  71. package/lib/WAM/BinaryInfo.js +7 -7
  72. package/lib/WAM/constants.js +1 -15241
  73. package/lib/WAM/encode.js +124 -131
  74. package/lib/WAUSync/Protocols/USyncContactProtocol.js +23 -23
  75. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +51 -47
  76. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +22 -22
  77. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +30 -32
  78. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +19 -19
  79. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -43
  80. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +17 -17
  81. package/lib/WAUSync/USyncQuery.js +82 -84
  82. package/lib/WAUSync/USyncUser.js +20 -20
  83. package/package.json +4 -2
@@ -5,54 +5,60 @@ export const PSA_WID = '0@c.us';
5
5
  export const STORIES_JID = 'status@broadcast';
6
6
  export const META_AI_JID = '13135550002@c.us';
7
7
  export const jidEncode = (user, server, device, agent) => {
8
- return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}`;
8
+ return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}`;
9
9
  };
10
- export const jidDecode = (jid) => {
11
- const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1;
12
- if (sepIdx < 0) {
13
- return undefined;
14
- }
15
- const server = jid.slice(sepIdx + 1);
16
- const userCombined = jid.slice(0, sepIdx);
17
- const [userAgent, device] = userCombined.split(':');
18
- const user = userAgent.split('_')[0];
19
- return {
20
- server: server,
21
- user,
22
- domainType: server === 'lid' ? 1 : 0,
23
- device: device ? +device : undefined
24
- };
10
+ export const jidDecode = jid => {
11
+ const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1;
12
+ if (sepIdx < 0) {
13
+ return undefined;
14
+ }
15
+ const server = jid.slice(sepIdx + 1);
16
+ const userCombined = jid.slice(0, sepIdx);
17
+ const [userAgent, device] = userCombined.split(':');
18
+ const user = userAgent.split('_')[0];
19
+ return {
20
+ server: server,
21
+ user,
22
+ domainType: server === 'lid' ? 1 : 0,
23
+ device: device ? +device : undefined
24
+ };
25
25
  };
26
26
  /** is the jid a user */
27
27
  export const areJidsSameUser = (jid1, jid2) => jidDecode(jid1)?.user === jidDecode(jid2)?.user;
28
28
  /** is the jid Meta AI */
29
- export const isJidMetaAI = (jid) => jid?.endsWith('@bot');
29
+ export const isJidMetaAI = jid => jid?.endsWith('@bot');
30
30
  /** is the jid a PN user */
31
- export const isPnUser = (jid) => jid?.endsWith('@s.whatsapp.net');
31
+ export const isPnUser = jid => jid?.endsWith('@s.whatsapp.net');
32
32
  /** is the jid a LID */
33
- export const isLidUser = (jid) => jid?.endsWith('@lid');
33
+ export const isLidUser = jid => jid?.endsWith('@lid');
34
34
  /** is the jid a broadcast */
35
- export const isJidBroadcast = (jid) => jid?.endsWith('@broadcast');
35
+ export const isJidBroadcast = jid => jid?.endsWith('@broadcast');
36
36
  /** is the jid a group */
37
- export const isJidGroup = (jid) => jid?.endsWith('@g.us');
37
+ export const isJidGroup = jid => jid?.endsWith('@g.us');
38
38
  /** is the jid the status broadcast */
39
- export const isJidStatusBroadcast = (jid) => jid === 'status@broadcast';
39
+ export const isJidStatusBroadcast = jid => jid === 'status@broadcast';
40
40
  /** is the jid a newsletter */
41
- export const isJidNewsletter = (jid) => jid?.endsWith('@newsletter');
41
+ export const isJidNewsletter = jid => jid?.endsWith('@newsletter');
42
42
  const botRegexp = /^1313555\d{4}$|^131655500\d{2}$/;
43
- export const isJidBot = (jid) => jid && botRegexp.test(jid.split('@')[0]) && jid.endsWith('@c.us');
44
- export const jidNormalizedUser = (jid) => {
45
- const result = jidDecode(jid);
46
- if (!result) {
47
- return '';
48
- }
49
- const { user, server } = result;
50
- return jidEncode(user, server === 'c.us' ? 's.whatsapp.net' : server);
43
+ export const isJidBot = jid => jid && botRegexp.test(jid.split('@')[0]) && jid.endsWith('@c.us');
44
+ export const jidNormalizedUser = jid => {
45
+ const result = jidDecode(jid);
46
+ if (!result) {
47
+ return '';
48
+ }
49
+ const {
50
+ user,
51
+ server
52
+ } = result;
53
+ return jidEncode(user, server === 'c.us' ? 's.whatsapp.net' : server);
51
54
  };
52
55
  export const transferDevice = (fromJid, toJid) => {
53
- const fromDecoded = jidDecode(fromJid);
54
- const deviceId = fromDecoded?.device || 0;
55
- const { server, user } = jidDecode(toJid);
56
- return jidEncode(user, server, deviceId);
56
+ const fromDecoded = jidDecode(fromJid);
57
+ const deviceId = fromDecoded?.device || 0;
58
+ const {
59
+ server,
60
+ user
61
+ } = jidDecode(toJid);
62
+ return jidEncode(user, server, deviceId);
57
63
  };
58
64
  //# sourceMappingURL=jid-utils.js.map
@@ -1,10 +1,10 @@
1
1
  export class BinaryInfo {
2
- constructor(options = {}) {
3
- this.protocolVersion = 5;
4
- this.sequence = 0;
5
- this.events = [];
6
- this.buffer = [];
7
- Object.assign(this, options);
8
- }
2
+ constructor(options = {}) {
3
+ this.protocolVersion = 5;
4
+ this.sequence = 0;
5
+ this.events = [];
6
+ this.buffer = [];
7
+ Object.assign(this, options);
8
+ }
9
9
  }
10
10
  //# sourceMappingURL=BinaryInfo.js.map