@hbmodsofc/baileys 2.5.0 → 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 (162) hide show
  1. package/LICENSE +1 -1
  2. package/README.MD +220 -1198
  3. package/WAProto/GenerateStatics.sh +4 -0
  4. package/WAProto/WAProto.proto +5619 -0
  5. package/engine-requirements.js +1 -1
  6. package/lib/Defaults/baileys-version.json +1 -1
  7. package/lib/Defaults/index.js +97 -122
  8. package/lib/Defaults/phonenumber_mcc.json +223 -0
  9. package/lib/Socket/Client/index.js +2 -3
  10. package/lib/Socket/Client/{web-socket-client.js → websocket.js} +54 -5
  11. package/lib/Socket/business.js +8 -2
  12. package/lib/Socket/chats.js +455 -288
  13. package/lib/Socket/communities.js +441 -0
  14. package/lib/Socket/groups.js +38 -23
  15. package/lib/Socket/hbmods.js +374 -406
  16. package/lib/Socket/index.js +43 -11
  17. package/lib/Socket/messages-recv.js +24 -69
  18. package/lib/Socket/messages-send.js +391 -419
  19. package/lib/Socket/newsletter.js +104 -190
  20. package/lib/Socket/socket.js +40 -54
  21. package/lib/Store/index.js +1 -3
  22. package/lib/Store/make-in-memory-store.js +27 -15
  23. package/lib/Store/make-ordered-dictionary.js +2 -2
  24. package/lib/Types/Label.js +1 -1
  25. package/lib/Types/LabelAssociation.js +1 -1
  26. package/lib/Types/Message.js +0 -2
  27. package/lib/Types/Newsletter.js +18 -38
  28. package/lib/Types/index.js +2 -2
  29. package/lib/Utils/async-iterable.js +41 -0
  30. package/lib/Utils/audioToBuffer.js +29 -0
  31. package/lib/Utils/auth-utils.js +6 -13
  32. package/lib/Utils/baileys-event-stream.js +1 -1
  33. package/lib/Utils/browser-utils.js +35 -0
  34. package/lib/Utils/business.js +2 -2
  35. package/lib/Utils/chat-utils.js +36 -35
  36. package/lib/Utils/crypto.js +71 -29
  37. package/lib/Utils/decode-wa-message.js +65 -56
  38. package/lib/Utils/event-buffer.js +13 -9
  39. package/lib/Utils/generics.js +88 -84
  40. package/lib/Utils/history.js +4 -6
  41. package/lib/Utils/index.js +3 -0
  42. package/lib/Utils/link-preview.js +34 -1
  43. package/lib/Utils/lt-hash.js +6 -6
  44. package/lib/Utils/message-retry-manager.js +128 -0
  45. package/lib/Utils/messages-media.js +340 -246
  46. package/lib/Utils/messages.js +329 -192
  47. package/lib/Utils/noise-handler.js +18 -23
  48. package/lib/Utils/process-message.js +108 -25
  49. package/lib/Utils/resolveJid.js +52 -0
  50. package/lib/Utils/signal.js +26 -26
  51. package/lib/Utils/streamToBuffer.js +15 -0
  52. package/lib/Utils/use-multi-file-auth-state.js +3 -0
  53. package/lib/Utils/validate-connection.js +1 -3
  54. package/lib/WABinary/constants.js +1276 -13
  55. package/lib/WABinary/decode.js +26 -13
  56. package/lib/WABinary/encode.js +137 -152
  57. package/lib/WABinary/generic-utils.js +37 -125
  58. package/lib/WABinary/jid-utils.js +28 -5
  59. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
  60. package/lib/index.js +2 -1
  61. package/package.json +112 -104
  62. package/lib/Defaults/index.d.ts +0 -53
  63. package/lib/Defaults/phonenumber-mcc.json +0 -223
  64. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  65. package/lib/Signal/Group/group-session-builder.d.ts +0 -14
  66. package/lib/Signal/Group/group_cipher.d.ts +0 -17
  67. package/lib/Signal/Group/index.d.ts +0 -11
  68. package/lib/Signal/Group/keyhelper.d.ts +0 -10
  69. package/lib/Signal/Group/queue-job.d.ts +0 -1
  70. package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
  71. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
  72. package/lib/Signal/Group/sender-key-message.d.ts +0 -18
  73. package/lib/Signal/Group/sender-key-name.d.ts +0 -17
  74. package/lib/Signal/Group/sender-key-record.d.ts +0 -30
  75. package/lib/Signal/Group/sender-key-state.d.ts +0 -38
  76. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  77. package/lib/Signal/libsignal.d.ts +0 -3
  78. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
  79. package/lib/Socket/Client/index.d.ts +0 -3
  80. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  81. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  82. package/lib/Socket/Client/web-socket-client.d.ts +0 -12
  83. package/lib/Socket/business.d.ts +0 -171
  84. package/lib/Socket/chats.d.ts +0 -267
  85. package/lib/Socket/groups.d.ts +0 -115
  86. package/lib/Socket/hbmods.d.ts +0 -254
  87. package/lib/Socket/index.d.ts +0 -173
  88. package/lib/Socket/messages-recv.d.ts +0 -161
  89. package/lib/Socket/messages-send.d.ts +0 -149
  90. package/lib/Socket/newsletter.d.ts +0 -134
  91. package/lib/Socket/registration.d.ts +0 -267
  92. package/lib/Socket/registration.js +0 -166
  93. package/lib/Socket/socket.d.ts +0 -43
  94. package/lib/Socket/usync.d.ts +0 -36
  95. package/lib/Store/index.d.ts +0 -3
  96. package/lib/Store/make-cache-manager-store.d.ts +0 -13
  97. package/lib/Store/make-cache-manager-store.js +0 -83
  98. package/lib/Store/make-in-memory-store.d.ts +0 -118
  99. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  100. package/lib/Store/object-repository.d.ts +0 -10
  101. package/lib/Types/Auth.d.ts +0 -110
  102. package/lib/Types/Call.d.ts +0 -13
  103. package/lib/Types/Chat.d.ts +0 -102
  104. package/lib/Types/Contact.d.ts +0 -19
  105. package/lib/Types/Events.d.ts +0 -157
  106. package/lib/Types/GroupMetadata.d.ts +0 -55
  107. package/lib/Types/Label.d.ts +0 -35
  108. package/lib/Types/LabelAssociation.d.ts +0 -29
  109. package/lib/Types/Message.d.ts +0 -273
  110. package/lib/Types/Newsletter.d.ts +0 -103
  111. package/lib/Types/Product.d.ts +0 -78
  112. package/lib/Types/Signal.d.ts +0 -57
  113. package/lib/Types/Socket.d.ts +0 -111
  114. package/lib/Types/State.d.ts +0 -27
  115. package/lib/Types/USync.d.ts +0 -25
  116. package/lib/Types/index.d.ts +0 -57
  117. package/lib/Utils/auth-utils.d.ts +0 -18
  118. package/lib/Utils/baileys-event-stream.d.ts +0 -16
  119. package/lib/Utils/business.d.ts +0 -22
  120. package/lib/Utils/chat-utils.d.ts +0 -71
  121. package/lib/Utils/crypto.d.ts +0 -41
  122. package/lib/Utils/decode-wa-message.d.ts +0 -19
  123. package/lib/Utils/event-buffer.d.ts +0 -35
  124. package/lib/Utils/generics.d.ts +0 -92
  125. package/lib/Utils/generics.js.bak +0 -433
  126. package/lib/Utils/history.d.ts +0 -15
  127. package/lib/Utils/index.d.ts +0 -17
  128. package/lib/Utils/link-preview.d.ts +0 -21
  129. package/lib/Utils/logger.d.ts +0 -4
  130. package/lib/Utils/lt-hash.d.ts +0 -12
  131. package/lib/Utils/make-mutex.d.ts +0 -7
  132. package/lib/Utils/messages-media.d.ts +0 -116
  133. package/lib/Utils/messages.d.ts +0 -77
  134. package/lib/Utils/noise-handler.d.ts +0 -21
  135. package/lib/Utils/process-message.d.ts +0 -41
  136. package/lib/Utils/signal.d.ts +0 -32
  137. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  138. package/lib/Utils/validate-connection.d.ts +0 -11
  139. package/lib/Utils/validate-connection.js.bak +0 -237
  140. package/lib/WABinary/constants.d.ts +0 -30
  141. package/lib/WABinary/decode.d.ts +0 -7
  142. package/lib/WABinary/encode.d.ts +0 -3
  143. package/lib/WABinary/generic-utils.d.ts +0 -17
  144. package/lib/WABinary/index.d.ts +0 -5
  145. package/lib/WABinary/jid-utils.d.ts +0 -31
  146. package/lib/WABinary/types.d.ts +0 -18
  147. package/lib/WAM/BinaryInfo.d.ts +0 -17
  148. package/lib/WAM/constants.d.ts +0 -38
  149. package/lib/WAM/encode.d.ts +0 -3
  150. package/lib/WAM/index.d.ts +0 -3
  151. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
  152. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
  153. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
  154. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
  155. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
  156. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
  157. package/lib/WAUSync/Protocols/index.d.ts +0 -4
  158. package/lib/WAUSync/USyncQuery.d.ts +0 -28
  159. package/lib/WAUSync/USyncUser.d.ts +0 -12
  160. package/lib/WAUSync/index.d.ts +0 -3
  161. package/lib/index.d.ts +0 -12
  162. /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
@@ -1,81 +1,83 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAdditionalNode = exports.getBinaryNodeFilter = exports.binaryNodeToString = exports.getBinaryNodeMessages = exports.reduceBinaryNodeToDictionary = exports.assertNodeErrorFree = exports.getBinaryNodeChildUInt = exports.getBinaryNodeChildString = exports.getBinaryNodeChildBuffer = exports.getBinaryNodeChild = exports.getAllBinaryNodeChildren = exports.getBinaryNodeChildren = void 0;
3
+ exports.getBinaryNodeMessages = exports.reduceBinaryNodeToDictionary = exports.assertNodeErrorFree = exports.getBinaryNodeChildUInt = exports.getBinaryNodeChildString = exports.getBinaryNodeChildBuffer = exports.getBinaryNodeChild = exports.getAllBinaryNodeChildren = exports.getBinaryNodeChildren = void 0;
4
+ exports.binaryNodeToString = binaryNodeToString;
4
5
  const boom_1 = require("@hapi/boom");
5
6
  const WAProto_1 = require("../../WAProto");
6
- const Utils_1 = require("../Utils")
7
7
  // some extra useful utilities
8
8
  const getBinaryNodeChildren = (node, childTag) => {
9
- if (Array.isArray(node?.content)) {
10
- return node.content.filter(item => item.tag === childTag)
9
+ if (Array.isArray(node === null || node === void 0 ? void 0 : node.content)) {
10
+ return node.content.filter(item => item.tag === childTag);
11
11
  }
12
- return []
13
- }
12
+ return [];
13
+ };
14
14
  exports.getBinaryNodeChildren = getBinaryNodeChildren;
15
15
  const getAllBinaryNodeChildren = ({ content }) => {
16
16
  if (Array.isArray(content)) {
17
- return content
17
+ return content;
18
18
  }
19
- return []
20
- }
19
+ return [];
20
+ };
21
21
  exports.getAllBinaryNodeChildren = getAllBinaryNodeChildren;
22
22
  const getBinaryNodeChild = (node, childTag) => {
23
- if (Array.isArray(node?.content)) {
24
- return node?.content.find(item => item.tag === childTag)
23
+ if (Array.isArray(node === null || node === void 0 ? void 0 : node.content)) {
24
+ return node === null || node === void 0 ? void 0 : node.content.find(item => item.tag === childTag);
25
25
  }
26
- }
26
+ };
27
27
  exports.getBinaryNodeChild = getBinaryNodeChild;
28
28
  const getBinaryNodeChildBuffer = (node, childTag) => {
29
- const child = getBinaryNodeChild(node, childTag)?.content
29
+ var _a;
30
+ const child = (_a = (0, exports.getBinaryNodeChild)(node, childTag)) === null || _a === void 0 ? void 0 : _a.content;
30
31
  if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
31
- return child
32
+ return child;
32
33
  }
33
- }
34
+ };
34
35
  exports.getBinaryNodeChildBuffer = getBinaryNodeChildBuffer;
35
36
  const getBinaryNodeChildString = (node, childTag) => {
36
- const child = getBinaryNodeChild(node, childTag)?.content
37
+ var _a;
38
+ const child = (_a = (0, exports.getBinaryNodeChild)(node, childTag)) === null || _a === void 0 ? void 0 : _a.content;
37
39
  if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
38
- return Buffer.from(child).toString('utf-8')
40
+ return Buffer.from(child).toString('utf-8');
39
41
  }
40
42
  else if (typeof child === 'string') {
41
- return child
43
+ return child;
42
44
  }
43
- }
45
+ };
44
46
  exports.getBinaryNodeChildString = getBinaryNodeChildString;
45
47
  const getBinaryNodeChildUInt = (node, childTag, length) => {
46
- const buff = getBinaryNodeChildBuffer(node, childTag)
48
+ const buff = (0, exports.getBinaryNodeChildBuffer)(node, childTag);
47
49
  if (buff) {
48
- return bufferToUInt(buff, length)
50
+ return bufferToUInt(buff, length);
49
51
  }
50
- }
52
+ };
51
53
  exports.getBinaryNodeChildUInt = getBinaryNodeChildUInt;
52
54
  const assertNodeErrorFree = (node) => {
53
- const errNode = getBinaryNodeChild(node, 'error')
55
+ const errNode = (0, exports.getBinaryNodeChild)(node, 'error');
54
56
  if (errNode) {
55
- throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code })
57
+ throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code });
56
58
  }
57
- }
59
+ };
58
60
  exports.assertNodeErrorFree = assertNodeErrorFree;
59
61
  const reduceBinaryNodeToDictionary = (node, tag) => {
60
- const nodes = getBinaryNodeChildren(node, tag)
62
+ const nodes = (0, exports.getBinaryNodeChildren)(node, tag);
61
63
  const dict = nodes.reduce((dict, { attrs }) => {
62
- dict[attrs.name || attrs.config_code] = attrs.value || attrs.config_value
63
- return dict
64
- }, {})
65
- return dict
66
- }
64
+ dict[attrs.name || attrs.config_code] = attrs.value || attrs.config_value;
65
+ return dict;
66
+ }, {});
67
+ return dict;
68
+ };
67
69
  exports.reduceBinaryNodeToDictionary = reduceBinaryNodeToDictionary;
68
70
  const getBinaryNodeMessages = ({ content }) => {
69
- const msgs = []
71
+ const msgs = [];
70
72
  if (Array.isArray(content)) {
71
73
  for (const item of content) {
72
74
  if (item.tag === 'message') {
73
- msgs.push(WAProto_1.proto.WebMessageInfo.decode(item.content))
75
+ msgs.push(WAProto_1.proto.WebMessageInfo.decode(item.content));
74
76
  }
75
77
  }
76
78
  }
77
- return msgs
78
- }
79
+ return msgs;
80
+ };
79
81
  exports.getBinaryNodeMessages = getBinaryNodeMessages;
80
82
  function bufferToUInt(e, t) {
81
83
  let a = 0;
@@ -106,93 +108,3 @@ function binaryNodeToString(node, i = 0) {
106
108
  const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>';
107
109
  return tag + content;
108
110
  }
109
- exports.binaryNodeToString = binaryNodeToString;
110
- const getBinaryNodeFilter = (node) => {
111
- if (!Array.isArray(node)) return false
112
-
113
- return node.some(item =>
114
- ['native_flow'].includes(item?.content?.[0]?.content?.[0]?.tag) ||
115
- ['interactive', 'buttons', 'list'].includes(item?.content?.[0]?.tag) ||
116
- ['hsm', 'biz'].includes(item?.tag) ||
117
- ['bot'].includes(item?.tag) && item?.attrs?.biz_bot === '1'
118
- )
119
- }
120
- exports.getBinaryNodeFilter = getBinaryNodeFilter;
121
- const getAdditionalNode = (name) => {
122
- if (name) name = name.toLowerCase()
123
- const ts = Utils_1.unixTimestampSeconds(new Date()) - 77980457
124
-
125
- const order_response_name = {
126
- review_and_pay: 'order_details',
127
- review_order: 'order_status',
128
- payment_info: 'payment_info',
129
- payment_status: 'payment_status',
130
- payment_method: 'payment_method'
131
- }
132
-
133
- const flow_name = {
134
- cta_catalog: 'cta_catalog',
135
- mpm: 'mpm',
136
- call_request: 'call_permission_request',
137
- view_catalog: 'automated_greeting_message_view_catalog',
138
- wa_pay_detail: 'wa_payment_transaction_details',
139
- send_location: 'send_location',
140
- }
141
-
142
- if(order_response_name[name]) {
143
- return [{
144
- tag: 'biz',
145
- attrs: {
146
- native_flow_name: order_response_name[name]
147
- },
148
- content: []
149
- }]
150
- } else if (flow_name[name] || name === 'interactive' || name === 'buttons') {
151
- return [{
152
- tag: 'biz',
153
- attrs: {
154
- actual_actors: '2',
155
- host_storage: '2',
156
- privacy_mode_ts: `${ts}`
157
- },
158
- content: [{
159
- tag: 'engagement',
160
- attrs: {
161
- customer_service_state: 'open',
162
- conversation_state: 'open'
163
- }
164
- }, {
165
- tag: 'interactive',
166
- attrs: {
167
- type: 'native_flow',
168
- v: '1'
169
- },
170
- content: [{
171
- tag: 'native_flow',
172
- attrs: {
173
- v: '9',
174
- name: flow_name[name] ?? 'mixed',
175
- },
176
- content: []
177
- }]
178
- }]
179
- }]
180
- } else {
181
- return [{
182
- tag: 'biz',
183
- attrs: {
184
- actual_actors: '2',
185
- host_storage: '2',
186
- privacy_mode_ts: `${ts}`
187
- },
188
- content: [{
189
- tag: 'engagement',
190
- attrs: {
191
- customer_service_state: 'open',
192
- conversation_state: 'open'
193
- }
194
- }]
195
- }]
196
- }
197
- }
198
- exports.getAdditionalNode = getAdditionalNode;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jidNormalizedUser = exports.isJidNewsLetter = exports.isJidStatusBroadcast = exports.isJidGroup = exports.isJidBroadcast = exports.isLidUser = exports.isJidUser = exports.areJidsSameUser = exports.jidDecode = exports.jidEncode = exports.STORIES_JID = exports.PSA_WID = exports.SERVER_JID = exports.OFFICIAL_BIZ_JID = exports.S_WHATSAPP_NET = void 0;
3
+ exports.lidToJid = exports.getBotJid = exports.jidNormalizedUser = exports.isJidBot = exports.isJidStatusBroadcast = exports.isJidGroup = exports.isJidNewsletter = exports.isJidBroadcast = exports.isLidUser = exports.isJidUser = exports.isJidMetaAi = exports.areJidsSameUser = exports.jidDecode = exports.jidEncode = exports.META_AI_JID = exports.STORIES_JID = exports.PSA_WID = exports.SERVER_JID = exports.OFFICIAL_BIZ_JID = exports.S_WHATSAPP_NET = void 0;
4
4
  exports.S_WHATSAPP_NET = '@s.whatsapp.net';
5
5
  exports.OFFICIAL_BIZ_JID = '16505361212@c.us';
6
6
  exports.SERVER_JID = 'server@c.us';
7
7
  exports.PSA_WID = '0@c.us';
8
8
  exports.STORIES_JID = 'status@broadcast';
9
+ exports.META_AI_JID = '13135550002@c.us';
9
10
  const jidEncode = (user, server, device, agent) => {
10
11
  return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}`;
11
12
  };
@@ -20,7 +21,7 @@ const jidDecode = (jid) => {
20
21
  const [userAgent, device] = userCombined.split(':');
21
22
  const user = userAgent.split('_')[0];
22
23
  return {
23
- server,
24
+ server: server,
24
25
  user,
25
26
  domainType: server === 'lid' ? 1 : 0,
26
27
  device: device ? +device : undefined
@@ -33,6 +34,9 @@ const areJidsSameUser = (jid1, jid2) => {
33
34
  return (((_a = (0, exports.jidDecode)(jid1)) === null || _a === void 0 ? void 0 : _a.user) === ((_b = (0, exports.jidDecode)(jid2)) === null || _b === void 0 ? void 0 : _b.user));
34
35
  };
35
36
  exports.areJidsSameUser = areJidsSameUser;
37
+ /** is the jid Meta IA */
38
+ const isJidMetaAi = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@bot'));
39
+ exports.isJidMetaAi = isJidMetaAi;
36
40
  /** is the jid a user */
37
41
  const isJidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@s.whatsapp.net'));
38
42
  exports.isJidUser = isJidUser;
@@ -42,15 +46,18 @@ exports.isLidUser = isLidUser;
42
46
  /** is the jid a broadcast */
43
47
  const isJidBroadcast = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@broadcast'));
44
48
  exports.isJidBroadcast = isJidBroadcast;
49
+ /** is the jid a newsletter */
50
+ const isJidNewsletter = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@newsletter'));
51
+ exports.isJidNewsletter = isJidNewsletter;
45
52
  /** is the jid a group */
46
53
  const isJidGroup = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@g.us'));
47
54
  exports.isJidGroup = isJidGroup;
48
55
  /** is the jid the status broadcast */
49
56
  const isJidStatusBroadcast = (jid) => jid === 'status@broadcast';
50
57
  exports.isJidStatusBroadcast = isJidStatusBroadcast;
51
- /** is the jid the newsletter */
52
- const isJidNewsLetter = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('newsletter'));
53
- exports.isJidNewsLetter = isJidNewsLetter;
58
+ const botRegexp = /^1313555\d{4}$|^131655500\d{2}$/;
59
+ const isJidBot = (jid) => (jid && botRegexp.test(jid.split('@')[0]) && jid.endsWith('@c.us'));
60
+ exports.isJidBot = isJidBot;
54
61
  const jidNormalizedUser = (jid) => {
55
62
  const result = (0, exports.jidDecode)(jid);
56
63
  if (!result) {
@@ -60,3 +67,19 @@ const jidNormalizedUser = (jid) => {
60
67
  return (0, exports.jidEncode)(user, server === 'c.us' ? 's.whatsapp.net' : server);
61
68
  };
62
69
  exports.jidNormalizedUser = jidNormalizedUser;
70
+ const lidToJid = jid => jid && jid.endsWith('@lid') ? jid.replace('@lid','@s.whatsapp.net') : jid;
71
+ exports.lidToJid = lidToJid;
72
+ const getBotJid = (jid) => {
73
+ const BOT_MAP = new Map([["867051314767696", "13135550002"], ["1061492271844689", "13135550005"], ["245886058483988", "13135550009"], ["3509905702656130", "13135550012"], ["1059680132034576", "13135550013"], ["715681030623646", "13135550014"], ["1644971366323052", "13135550015"], ["582497970646566", "13135550019"], ["645459357769306", "13135550022"], ["294997126699143", "13135550023"], ["1522631578502677", "13135550027"], ["719421926276396", "13135550030"], ["1788488635002167", "13135550031"], ["24232338603080193", "13135550033"], ["689289903143209", "13135550035"], ["871626054177096", "13135550039"], ["362351902849370", "13135550042"], ["1744617646041527", "13135550043"], ["893887762270570", "13135550046"], ["1155032702135830", "13135550047"], ["333931965993883", "13135550048"], ["853748013058752", "13135550049"], ["1559068611564819", "13135550053"], ["890487432705716", "13135550054"], ["240254602395494", "13135550055"], ["1578420349663261", "13135550062"], ["322908887140421", "13135550065"], ["3713961535514771", "13135550067"], ["997884654811738", "13135550070"], ["403157239387035", "13135550081"], ["535242369074963", "13135550082"], ["946293427247659", "13135550083"], ["3664707673802291", "13135550084"], ["1821827464894892", "13135550085"], ["1760312477828757", "13135550086"], ["439480398712216", "13135550087"], ["1876735582800984", "13135550088"], ["984025089825661", "13135550089"], ["1001336351558186", "13135550090"], ["3739346336347061", "13135550091"], ["3632749426974980", "13135550092"], ["427864203481615", "13135550093"], ["1434734570493055", "13135550094"], ["992873449225921", "13135550095"], ["813087747426445", "13135550096"], ["806369104931434", "13135550098"], ["1220982902403148", "13135550099"], ["1365893374104393", "13135550100"], ["686482033622048", "13135550200"], ["1454999838411253", "13135550201"], ["718584497008509", "13135550202"], ["743520384213443", "13135550301"], ["1147715789823789", "13135550302"], ["1173034540372201", "13135550303"], ["974785541030953", "13135550304"], ["1122200255531507", "13135550305"], ["899669714813162", "13135550306"], ["631880108970650", "13135550307"], ["435816149330026", "13135550308"], ["1368717161184556", "13135550309"], ["7849963461784891", "13135550310"], ["3609617065968984", "13135550312"], ["356273980574602", "13135550313"], ["1043447920539760", "13135550314"], ["1052764336525346", "13135550315"], ["2631118843732685", "13135550316"], ["510505411332176", "13135550317"], ["1945664239227513", "13135550318"], ["1518594378764656", "13135550319"], ["1378821579456138", "13135550320"], ["490214716896013", "13135550321"], ["1028577858870699", "13135550322"], ["308915665545959", "13135550323"], ["845884253678900", "13135550324"], ["995031308616442", "13135550325"], ["2787365464763437", "13135550326"], ["1532790990671645", "13135550327"], ["302617036180485", "13135550328"], ["723376723197227", "13135550329"], ["8393570407377966", "13135550330"], ["1931159970680725", "13135550331"], ["401073885688605", "13135550332"], ["2234478453565422", "13135550334"], ["814748673882312", "13135550335"], ["26133635056281592", "13135550336"], ["1439804456676119", "13135550337"], ["889851503172161", "13135550338"], ["1018283232836879", "13135550339"], ["1012781386779537", "13135559000"], ["823280953239532", "13135559001"], ["1597090934573334", "13135559002"], ["485965054020343", "13135559003"], ["1033381648363446", "13135559004"], ["491802010206446", "13135559005"], ["1017139033184870", "13135559006"], ["499638325922174", "13135559008"], ["468946335863664", "13135559009"], ["1570389776875816", "13135559010"], ["1004342694328995", "13135559011"], ["1012240323971229", "13135559012"], ["392171787222419", "13135559013"], ["952081212945019", "13135559016"], ["444507875070178", "13135559017"], ["1274819440594668", "13135559018"], ["1397041101147050", "13135559019"], ["425657699872640", "13135559020"], ["532292852562549", "13135559021"], ["705863241720292", "13135559022"], ["476449815183959", "13135559023"], ["488071553854222", "13135559024"], ["468693832665397", "13135559025"], ["517422564037340", "13135559026"], ["819805466613825", "13135559027"], ["1847708235641382", "13135559028"], ["716282970644228", "13135559029"], ["521655380527741", "13135559030"], ["476193631941905", "13135559031"], ["485600497445562", "13135559032"], ["440217235683910", "13135559033"], ["523342446758478", "13135559034"], ["514784864360240", "13135559035"], ["505790121814530", "13135559036"], ["420008964419580", "13135559037"], ["492141680204555", "13135559038"], ["388462787271952", "13135559039"], ["423473920752072", "13135559040"], ["489574180468229", "13135559041"], ["432360635854105", "13135559042"], ["477878201669248", "13135559043"], ["351656951234045", "13135559044"], ["430178036732582", "13135559045"], ["434537312944552", "13135559046"], ["1240614300631808", "13135559047"], ["473135945605128", "13135559048"], ["423669800729310", "13135559049"], ["3685666705015792", "13135559050"], ["504196509016638", "13135559051"], ["346844785189449", "13135559052"], ["504823088911074", "13135559053"], ["402669415797083", "13135559054"], ["490939640234431", "13135559055"], ["875124128063715", "13135559056"], ["468788962654605", "13135559057"], ["562386196354570", "13135559058"], ["372159285928791", "13135559059"], ["531017479591050", "13135559060"], ["1328873881401826", "13135559061"], ["1608363646390484", "13135559062"], ["1229628561554232", "13135559063"], ["348802211530364", "13135559064"], ["3708535859420184", "13135559065"], ["415517767742187", "13135559066"], ["479330341612638", "13135559067"], ["480785414723083", "13135559068"], ["387299107507991", "13135559069"], ["333389813188944", "13135559070"], ["391794130316996", "13135559071"], ["457893470576314", "13135559072"], ["435550496166469", "13135559073"], ["1620162702100689", "13135559074"], ["867491058616043", "13135559075"], ["816224117357759", "13135559076"], ["334065176362830", "13135559077"], ["489973170554709", "13135559078"], ["473060669049665", "13135559079"], ["1221505815643060", "13135559080"], ["889000703096359", "13135559081"], ["475235961979883", "13135559082"], ["3434445653519934", "13135559084"], ["524503026827421", "13135559085"], ["1179639046403856", "13135559086"], ["471563305859144", "13135559087"], ["533896609192881", "13135559088"], ["365443583168041", "13135559089"], ["836082305329393", "13135559090"], ["1056787705969916", "13135559091"], ["503312598958357", "13135559092"], ["3718606738453460", "13135559093"], ["826066052850902", "13135559094"], ["1033611345091888", "13135559095"], ["3868390816783240", "13135559096"], ["7462677740498860", "13135559097"], ["436288576108573", "13135559098"], ["1047559746718900", "13135559099"], ["1099299455255491", "13135559100"], ["1202037301040633", "13135559101"], ["1720619402074074", "13135559102"], ["1030422235101467", "13135559103"], ["827238979523502", "13135559104"], ["1516443722284921", "13135559105"], ["1174442747196709", "13135559106"], ["1653165225503842", "13135559107"], ["1037648777635013", "13135559108"], ["551617757299900", "13135559109"], ["1158813558718726", "13135559110"], ["2463236450542262", "13135559111"], ["1550393252501466", "13135559112"], ["2057065188042796", "13135559113"], ["506163028760735", "13135559114"], ["2065249100538481", "13135559115"], ["1041382867195858", "13135559116"], ["886500209499603", "13135559117"], ["1491615624892655", "13135559118"], ["486563697299617", "13135559119"], ["1175736513679463", "13135559120"], ["491811473512352", "13165550064"]]);
74
+ const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1;
75
+ if (sepIdx < 0) {
76
+ return jid;
77
+ }
78
+ const server = jid.slice(sepIdx + 1);
79
+ if (server !== 'bot')
80
+ return jid;
81
+ const user = jid.slice(0, sepIdx);
82
+ const mappedNumber = BOT_MAP.get(user);
83
+ return mappedNumber ? `${mappedNumber}@s.whatsapp.net` : jid;
84
+ };
85
+ exports.getBotJid = getBotJid;
@@ -16,7 +16,7 @@ class USyncDisappearingModeProtocol {
16
16
  return null;
17
17
  }
18
18
  parser(node) {
19
- if (node.tag === 'status') {
19
+ if (node.tag === 'disappearing_mode') {
20
20
  (0, WABinary_1.assertNodeErrorFree)(node);
21
21
  const duration = +(node === null || node === void 0 ? void 0 : node.attrs.duration);
22
22
  const setAt = new Date(+((node === null || node === void 0 ? void 0 : node.attrs.t) || 0) * 1000);
package/lib/index.js CHANGED
@@ -80,5 +80,6 @@ __exportStar(require("./Defaults"), exports);
80
80
  __exportStar(require("./WABinary"), exports);
81
81
  __exportStar(require("./WAM"), exports);
82
82
  __exportStar(require("./WAUSync"), exports);
83
+ __exportStar(require("./Api"), exports);
83
84
 
84
- exports.default = Socket_1.default;
85
+ exports.default = Socket_1.default;
package/package.json CHANGED
@@ -1,106 +1,114 @@
1
1
  {
2
- "name": "@hbmodsofc/baileys",
3
- "version": "2.5.0",
4
- "description": "HBMods-OFC modified Baileys WhatsApp API for custom bots and personal projects",
5
- "keywords": [
6
- "HBWABot",
7
- "Baileys",
8
- "2025",
9
- "mizo"
10
- ],
11
- "license": "MIT",
12
- "author": "Herbert Suantak",
13
- "type": "commonjs",
14
- "main": "lib/index.js",
15
- "types": "lib/index.d.ts",
16
- "directories": {
17
- "lib": "lib"
18
- },
19
- "files": [
20
- "lib/*",
21
- "WAProto/*.js",
22
- "engine-requirements.js"
23
- ],
24
- "scripts": {
25
- "build:all": "tsc && typedoc",
26
- "build:docs": "typedoc",
27
- "build:tsc": "tsc",
28
- "changelog:last": "conventional-changelog -p angular -r 2",
29
- "changelog:preview": "conventional-changelog -p angular -u",
30
- "gen:protobuf": "sh WAProto/GenerateStatics.sh",
31
- "lint": "eslint src --ext .js,.ts,.jsx,.tsx",
32
- "lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
33
- "prepack": "",
34
- "prepare": "",
35
- "preinstall": "node ./engine-requirements.js",
36
- "release": "release-it",
37
- "test": "jest"
38
- },
39
- "dependencies": {
40
- "@adiwajshing/keyed-db": "^0.2.4",
41
- "@hapi/boom": "^9.1.3",
42
- "@cacheable/node-cache": "^1.4.0",
43
- "async-mutex": "^0.5.0",
44
- "audio-decode": "^2.1.3",
45
- "axios": "^1.3.3",
46
- "cache-manager": "4.0.1",
47
- "chalk": "^4.1.2",
48
- "futoin-hkdf": "^1.5.1",
49
- "libphonenumber-js": "^1.10.20",
50
- "lodash": "^4.17.21",
51
- "libsignal": "npm:@shennmine/libsignal-node",
52
- "music-metadata": "^7.12.3",
53
- "node-cache": "^5.1.2",
54
- "node-fetch": "^2.6.1",
55
- "pino": "^8.14.1",
56
- "protobufjs": "^7.2.4",
57
- "uuid": "^9.0.0",
58
- "ws": "^8.13.0"
59
- },
60
- "devDependencies": {
61
- "@adiwajshing/eslint-config": "github:adiwajshing/eslint-config",
62
- "@types/got": "^9.6.11",
63
- "@types/jest": "^27.5.1",
64
- "@types/node": "^16.0.0",
65
- "@types/sharp": "^0.29.4",
66
- "@types/ws": "^8.0.0",
67
- "conventional-changelog-cli": "^2.2.2",
68
- "eslint": "^8.0.0",
69
- "jest": "^27.0.6",
70
- "jimp": "^1.6.0",
71
- "link-preview-js": "^3.0.0",
72
- "open": "^8.4.2",
73
- "qrcode-terminal": "^0.12.0",
74
- "release-it": "^15.10.3",
75
- "sharp": "^0.34.5",
76
- "ts-jest": "^27.0.3",
77
- "ts-node": "^10.8.1",
78
- "typedoc": "^0.24.7",
79
- "typescript": "^4.6.4",
80
- "json": "^11.0.0"
81
- },
82
- "peerDependencies": {
83
- "jimp": "^1.6.0",
84
- "link-preview-js": "^3.0.0",
85
- "qrcode-terminal": "^0.12.0",
86
- "sharp": "^0.34.5"
87
- },
88
- "peerDependenciesMeta": {
89
- "jimp": {
90
- "optional": true
91
- },
92
- "link-preview-js": {
93
- "optional": true
94
- },
95
- "qrcode-terminal": {
96
- "optional": true
97
- },
98
- "sharp": {
99
- "optional": true
100
- }
101
- },
102
- "engines": {
103
- "node": ">=20.0.0"
104
- },
105
- "packageManager": "yarn@1.22.19"
2
+ "name": "@hbmodsofc/baileys",
3
+ "version": "3.0.0",
4
+ "description": "HBMods-OFC modified Baileys WhatsApp API for custom bots and personal projects",
5
+ "keywords": [
6
+ "HBWABot",
7
+ "Baileys",
8
+ "2026",
9
+ "mizo"
10
+ ],
11
+ "homepage": "https://www.npmjs.com/package/@hbmodsofc/baileys",
12
+ "repository": {
13
+ "url": "https://www.npmjs.com/package/@hbmodsofc/baileys"
14
+ },
15
+ "license": "MIT",
16
+ "author": "@hbmodsofc/baileys",
17
+ "type": "commonjs",
18
+ "main": "lib/index.js",
19
+ "types": "lib/index.d.ts",
20
+ "directories": {
21
+ "lib": "lib"
22
+ },
23
+ "files": [
24
+ "lib/*",
25
+ "WAProto/*",
26
+ "engine-requirements.js"
27
+ ],
28
+ "scripts": {
29
+ "build:all": "tsc && typedoc",
30
+ "build:docs": "typedoc",
31
+ "build:tsc": "tsc",
32
+ "changelog:last": "conventional-changelog -p angular -r 2",
33
+ "changelog:preview": "conventional-changelog -p angular -u",
34
+ "changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
35
+ "example": "node --inspect -r ts-node/register Example/example.ts",
36
+ "gen:protobuf": "sh WAProto/GenerateStatics.sh",
37
+ "lint": "eslint src --ext .js,.ts,.jsx,.tsx",
38
+ "lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
39
+ "prepack": "echo 'HBMods WhatsApp Library'",
40
+ "prepare": "echo 'HBMods WhatsApp Library'",
41
+ "preinstall": "node ./engine-requirements.js",
42
+ "release": "release-it",
43
+ "test": "jest"
44
+ },
45
+ "dependencies": {
46
+ "@adiwajshing/keyed-db": "^0.2.4",
47
+ "@cacheable/node-cache": "^1.4.0",
48
+ "@hapi/boom": "^9.1.3",
49
+ "async-mutex": "^0.5.0",
50
+ "axios": "^1.6.0",
51
+ "chalk": "^4.1.2",
52
+ "gradient-string": "^2.0.2",
53
+ "cache-manager": "^5.7.6",
54
+ "cheerio": "^1.0.0-rc.10",
55
+ "libphonenumber-js": "^1.10.20",
56
+ "libsignal": "github:NaufalYupra/libsignal-node",
57
+ "lodash": "^4.17.21",
58
+ "music-metadata": "^7.12.3",
59
+ "pino": "^8.14.1",
60
+ "protobufjs": "^6.11.3",
61
+ "uuid": "^10.0.0",
62
+ "ws": "^8.13.0"
63
+ },
64
+ "devDependencies": {
65
+ "@adiwajshing/eslint-config": "github:adiwajshing/eslint-config",
66
+ "@types/got": "^9.6.11",
67
+ "@types/jest": "^27.5.1",
68
+ "@types/node": "^16.18.126",
69
+ "@types/sharp": "^0.29.4",
70
+ "@types/ws": "^8.0.0",
71
+ "conventional-changelog-cli": "^2.2.2",
72
+ "eslint": "^8.0.0",
73
+ "jest": "^27.0.6",
74
+ "jimp": "^1.6.0",
75
+ "json": "^11.0.0",
76
+ "link-preview-js": "^3.0.0",
77
+ "open": "^8.4.2",
78
+ "qrcode-terminal": "^0.12.0",
79
+ "release-it": "^15.10.3",
80
+ "sharp": "^0.34.5",
81
+ "ts-jest": "^27.0.3",
82
+ "ts-node": "^10.8.1",
83
+ "typedoc": "^0.27.9",
84
+ "typescript": "^5.8.2"
85
+ },
86
+ "peerDependencies": {
87
+ "audio-decode": "^2.1.3",
88
+ "jimp": "^1.6.0",
89
+ "link-preview-js": "^3.0.0",
90
+ "qrcode-terminal": "^0.12.0",
91
+ "sharp": "^0.34.5"
92
+ },
93
+ "peerDependenciesMeta": {
94
+ "audio-decode": {
95
+ "optional": true
96
+ },
97
+ "jimp": {
98
+ "optional": true
99
+ },
100
+ "link-preview-js": {
101
+ "optional": true
102
+ },
103
+ "qrcode-terminal": {
104
+ "optional": true
105
+ },
106
+ "sharp": {
107
+ "optional": true
108
+ }
109
+ },
110
+ "engines": {
111
+ "node": ">=20.0.0"
112
+ },
113
+ "packageManager": "yarn@1.22.19"
106
114
  }
@@ -1,53 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { proto } from '../../WAProto';
4
- import type { MediaType, SocketConfig } from '../Types';
5
- export declare const UNAUTHORIZED_CODES: number[];
6
- export declare const DEFAULT_ORIGIN = "https://web.whatsapp.com";
7
- export declare const DEF_CALLBACK_PREFIX = "CB:";
8
- export declare const DEF_TAG_PREFIX = "TAG:";
9
- export declare const PHONE_CONNECTION_CB = "CB:Pong";
10
- export declare const WA_DEFAULT_EPHEMERAL: number;
11
- export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
12
- export declare const DICT_VERSION = 2;
13
- export declare const KEY_BUNDLE_TYPE: Buffer;
14
- export declare const NOISE_WA_HEADER: Buffer;
15
- /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
16
- export declare const URL_REGEX: RegExp;
17
- export declare const WA_CERT_DETAILS: {
18
- SERIAL: number;
19
- };
20
- export declare const PROCESSABLE_HISTORY_TYPES: proto.Message.HistorySyncNotification.HistorySyncType[];
21
- export declare const DEFAULT_CONNECTION_CONFIG: SocketConfig;
22
- export declare const MEDIA_PATH_MAP: {
23
- [T in MediaType]?: string;
24
- };
25
- export declare const MEDIA_HKDF_KEY_MAPPING: {
26
- audio: string;
27
- document: string;
28
- gif: string;
29
- image: string;
30
- ppic: string;
31
- product: string;
32
- ptt: string;
33
- sticker: string;
34
- video: string;
35
- 'thumbnail-document': string;
36
- 'thumbnail-image': string;
37
- 'thumbnail-video': string;
38
- 'thumbnail-link': string;
39
- 'md-msg-hist': string;
40
- 'md-app-state': string;
41
- 'product-catalog-image': string;
42
- 'payment-bg-image': string;
43
- ptv: string;
44
- };
45
- export declare const MEDIA_KEYS: ("ppic" | "product" | "image" | "video" | "sticker" | "audio" | "gif" | "ptt" | "thumbnail-document" | "thumbnail-image" | "thumbnail-link" | "thumbnail-video" | "md-app-state" | "md-msg-hist" | "document" | "product-catalog-image" | "payment-bg-image" | "ptv")[];
46
- export declare const MIN_PREKEY_COUNT = 5;
47
- export declare const INITIAL_PREKEY_COUNT = 30;
48
- export declare const DEFAULT_CACHE_TTLS: {
49
- SIGNAL_STORE: number;
50
- MSG_RETRY: number;
51
- CALL_OFFER: number;
52
- USER_DEVICES: number;
53
- };