@hbmodsofc/baileys 1.7.8 → 2.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 (155) hide show
  1. package/LICENSE +1 -1
  2. package/WAProto/index.js +157084 -24729
  3. package/lib/Defaults/baileys-version.json +3 -0
  4. package/lib/Defaults/index.d.ts +8 -12
  5. package/lib/Defaults/index.js +124 -90
  6. package/lib/Defaults/phonenumber-mcc.json +223 -0
  7. package/lib/Signal/Group/group_cipher.d.ts +1 -0
  8. package/lib/Signal/Group/group_cipher.js +39 -28
  9. package/lib/Signal/Group/queue-job.d.ts +1 -0
  10. package/lib/Signal/Group/queue-job.js +57 -0
  11. package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
  12. package/lib/Signal/Group/sender-chain-key.js +2 -9
  13. package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
  14. package/lib/Signal/Group/sender-key-message.js +3 -3
  15. package/lib/Signal/Group/sender-key-state.d.ts +4 -4
  16. package/lib/Signal/Group/sender-key-state.js +16 -47
  17. package/lib/Signal/libsignal.d.ts +3 -7
  18. package/lib/Signal/libsignal.js +39 -224
  19. package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +3 -1
  20. package/lib/Socket/Client/index.d.ts +3 -2
  21. package/lib/Socket/Client/index.js +3 -2
  22. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  23. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  24. package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
  25. package/lib/Socket/Client/{websocket.js → web-socket-client.js} +16 -10
  26. package/lib/Socket/business.d.ts +78 -94
  27. package/lib/Socket/business.js +11 -130
  28. package/lib/Socket/chats.d.ts +233 -63
  29. package/lib/Socket/chats.js +184 -234
  30. package/lib/Socket/groups.d.ts +41 -62
  31. package/lib/Socket/groups.js +64 -76
  32. package/lib/Socket/hbmods.d.ts +253 -0
  33. package/lib/Socket/hbmods.js +1 -0
  34. package/lib/Socket/index.d.ts +83 -129
  35. package/lib/Socket/index.js +6 -13
  36. package/lib/Socket/messages-recv.d.ts +48 -59
  37. package/lib/Socket/messages-recv.js +371 -516
  38. package/lib/Socket/messages-send.d.ts +67 -86
  39. package/lib/Socket/messages-send.js +1 -1091
  40. package/lib/Socket/newsletter.d.ts +64 -76
  41. package/lib/Socket/newsletter.js +1 -184
  42. package/lib/Socket/registration.d.ts +267 -0
  43. package/lib/Socket/registration.js +166 -0
  44. package/lib/Socket/socket.d.ts +13 -19
  45. package/lib/Socket/socket.js +1 -805
  46. package/lib/Socket/usync.d.ts +36 -0
  47. package/lib/Socket/usync.js +70 -0
  48. package/lib/Types/Auth.d.ts +10 -4
  49. package/lib/Types/Call.d.ts +1 -1
  50. package/lib/Types/Chat.d.ts +9 -29
  51. package/lib/Types/Chat.js +1 -7
  52. package/lib/Types/Contact.d.ts +1 -5
  53. package/lib/Types/Events.d.ts +14 -55
  54. package/lib/Types/GroupMetadata.d.ts +5 -15
  55. package/lib/Types/Label.d.ts +0 -11
  56. package/lib/Types/Label.js +1 -1
  57. package/lib/Types/LabelAssociation.js +1 -1
  58. package/lib/Types/Message.d.ts +49 -75
  59. package/lib/Types/Message.js +7 -10
  60. package/lib/Types/Newsletter.d.ts +98 -129
  61. package/lib/Types/Newsletter.js +38 -33
  62. package/lib/Types/Product.d.ts +1 -1
  63. package/lib/Types/Signal.d.ts +1 -29
  64. package/lib/Types/Socket.d.ts +22 -48
  65. package/lib/Types/State.d.ts +2 -13
  66. package/lib/Types/State.js +0 -12
  67. package/lib/Types/USync.d.ts +1 -1
  68. package/lib/Types/index.d.ts +3 -10
  69. package/lib/Types/index.js +2 -2
  70. package/lib/Utils/auth-utils.d.ts +3 -3
  71. package/lib/Utils/auth-utils.js +102 -378
  72. package/lib/Utils/baileys-event-stream.js +1 -1
  73. package/lib/Utils/business.d.ts +2 -2
  74. package/lib/Utils/business.js +13 -19
  75. package/lib/Utils/chat-utils.d.ts +22 -21
  76. package/lib/Utils/chat-utils.js +154 -201
  77. package/lib/Utils/crypto.d.ts +19 -18
  78. package/lib/Utils/crypto.js +37 -78
  79. package/lib/Utils/decode-wa-message.d.ts +7 -34
  80. package/lib/Utils/decode-wa-message.js +66 -138
  81. package/lib/Utils/event-buffer.d.ts +8 -6
  82. package/lib/Utils/event-buffer.js +43 -81
  83. package/lib/Utils/generics.d.ts +27 -27
  84. package/lib/Utils/generics.js +133 -128
  85. package/lib/Utils/history.d.ts +5 -9
  86. package/lib/Utils/history.js +23 -17
  87. package/lib/Utils/index.d.ts +0 -2
  88. package/lib/Utils/index.js +0 -2
  89. package/lib/Utils/link-preview.d.ts +4 -4
  90. package/lib/Utils/link-preview.js +12 -40
  91. package/lib/Utils/logger.d.ts +3 -11
  92. package/lib/Utils/lt-hash.d.ts +8 -8
  93. package/lib/Utils/lt-hash.js +24 -23
  94. package/lib/Utils/make-mutex.d.ts +2 -2
  95. package/lib/Utils/make-mutex.js +2 -3
  96. package/lib/Utils/messages-media.d.ts +41 -37
  97. package/lib/Utils/messages-media.js +368 -252
  98. package/lib/Utils/messages.d.ts +15 -13
  99. package/lib/Utils/messages.js +261 -274
  100. package/lib/Utils/noise-handler.d.ts +15 -13
  101. package/lib/Utils/noise-handler.js +26 -20
  102. package/lib/Utils/process-message.d.ts +8 -9
  103. package/lib/Utils/process-message.js +93 -157
  104. package/lib/Utils/signal.d.ts +5 -6
  105. package/lib/Utils/signal.js +29 -37
  106. package/lib/Utils/use-multi-file-auth-state.d.ts +2 -1
  107. package/lib/Utils/use-multi-file-auth-state.js +7 -12
  108. package/lib/Utils/validate-connection.d.ts +6 -5
  109. package/lib/Utils/validate-connection.js +97 -39
  110. package/lib/WABinary/constants.d.ts +27 -24
  111. package/lib/WABinary/constants.js +13 -1276
  112. package/lib/WABinary/decode.d.ts +4 -3
  113. package/lib/WABinary/decode.js +14 -28
  114. package/lib/WABinary/encode.d.ts +2 -1
  115. package/lib/WABinary/encode.js +147 -134
  116. package/lib/WABinary/generic-utils.d.ts +7 -4
  117. package/lib/WABinary/generic-utils.js +125 -40
  118. package/lib/WABinary/jid-utils.d.ts +8 -13
  119. package/lib/WABinary/jid-utils.js +16 -27
  120. package/lib/WAM/BinaryInfo.d.ts +11 -2
  121. package/lib/WAM/constants.d.ts +2 -3
  122. package/lib/WAM/constants.js +2359 -2252
  123. package/lib/WAM/encode.d.ts +2 -1
  124. package/lib/WAM/encode.js +11 -8
  125. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
  126. package/lib/WAUSync/Protocols/USyncContactProtocol.js +4 -3
  127. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
  128. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
  129. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
  130. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
  131. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
  132. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +6 -5
  133. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
  134. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
  135. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -4
  136. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +3 -11
  137. package/lib/WAUSync/USyncQuery.d.ts +2 -2
  138. package/lib/WAUSync/USyncQuery.js +15 -19
  139. package/lib/WAUSync/USyncUser.d.ts +5 -5
  140. package/lib/WAUSync/index.d.ts +1 -1
  141. package/lib/WAUSync/index.js +1 -1
  142. package/package.json +102 -104
  143. package/lib/Signal/lid-mapping.d.ts +0 -26
  144. package/lib/Signal/lid-mapping.js +0 -146
  145. package/lib/Socket/communities.d.ts +0 -232
  146. package/lib/Socket/communities.js +0 -402
  147. package/lib/Socket/mex.d.ts +0 -2
  148. package/lib/Socket/mex.js +0 -45
  149. package/lib/Types/Bussines.d.ts +0 -24
  150. package/lib/Types/Bussines.js +0 -2
  151. package/lib/Utils/lidToJid-test.d.ts +0 -11
  152. package/lib/Utils/lidToJid-test.js +0 -27
  153. package/lib/Utils/message-retry-manager.d.ts +0 -81
  154. package/lib/Utils/message-retry-manager.js +0 -152
  155. /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
@@ -1,86 +1,81 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
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;
5
4
  const boom_1 = require("@hapi/boom");
6
- const index_js_1 = require("../../WAProto/index.js");
5
+ const WAProto_1 = require("../../WAProto");
6
+ const Utils_1 = require("../Utils")
7
7
  // some extra useful utilities
8
8
  const getBinaryNodeChildren = (node, childTag) => {
9
9
  if (Array.isArray(node?.content)) {
10
- return node.content.filter(item => item.tag === childTag);
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
23
  if (Array.isArray(node?.content)) {
24
- return node?.content.find(item => item.tag === childTag);
24
+ return 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 = (0, exports.getBinaryNodeChild)(node, childTag)?.content;
29
+ const child = getBinaryNodeChild(node, childTag)?.content
30
30
  if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
31
- return child;
31
+ return child
32
32
  }
33
- };
33
+ }
34
34
  exports.getBinaryNodeChildBuffer = getBinaryNodeChildBuffer;
35
35
  const getBinaryNodeChildString = (node, childTag) => {
36
- const child = (0, exports.getBinaryNodeChild)(node, childTag)?.content;
36
+ const child = getBinaryNodeChild(node, childTag)?.content
37
37
  if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
38
- return Buffer.from(child).toString('utf-8');
38
+ return Buffer.from(child).toString('utf-8')
39
39
  }
40
40
  else if (typeof child === 'string') {
41
- return child;
41
+ return child
42
42
  }
43
- };
43
+ }
44
44
  exports.getBinaryNodeChildString = getBinaryNodeChildString;
45
45
  const getBinaryNodeChildUInt = (node, childTag, length) => {
46
- const buff = (0, exports.getBinaryNodeChildBuffer)(node, childTag);
46
+ const buff = getBinaryNodeChildBuffer(node, childTag)
47
47
  if (buff) {
48
- return bufferToUInt(buff, length);
48
+ return bufferToUInt(buff, length)
49
49
  }
50
- };
50
+ }
51
51
  exports.getBinaryNodeChildUInt = getBinaryNodeChildUInt;
52
52
  const assertNodeErrorFree = (node) => {
53
- const errNode = (0, exports.getBinaryNodeChild)(node, 'error');
53
+ const errNode = getBinaryNodeChild(node, 'error')
54
54
  if (errNode) {
55
- throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code });
55
+ throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code })
56
56
  }
57
- };
57
+ }
58
58
  exports.assertNodeErrorFree = assertNodeErrorFree;
59
59
  const reduceBinaryNodeToDictionary = (node, tag) => {
60
- const nodes = (0, exports.getBinaryNodeChildren)(node, tag);
60
+ const nodes = getBinaryNodeChildren(node, tag)
61
61
  const dict = nodes.reduce((dict, { attrs }) => {
62
- if (typeof attrs.name === 'string') {
63
- dict[attrs.name] = attrs.value || attrs.config_value;
64
- }
65
- else {
66
- dict[attrs.config_code] = attrs.value || attrs.config_value;
67
- }
68
- return dict;
69
- }, {});
70
- return dict;
71
- };
62
+ dict[attrs.name || attrs.config_code] = attrs.value || attrs.config_value
63
+ return dict
64
+ }, {})
65
+ return dict
66
+ }
72
67
  exports.reduceBinaryNodeToDictionary = reduceBinaryNodeToDictionary;
73
68
  const getBinaryNodeMessages = ({ content }) => {
74
- const msgs = [];
69
+ const msgs = []
75
70
  if (Array.isArray(content)) {
76
71
  for (const item of content) {
77
72
  if (item.tag === 'message') {
78
- msgs.push(index_js_1.proto.WebMessageInfo.decode(item.content));
73
+ msgs.push(WAProto_1.proto.WebMessageInfo.decode(item.content))
79
74
  }
80
75
  }
81
76
  }
82
- return msgs;
83
- };
77
+ return msgs
78
+ }
84
79
  exports.getBinaryNodeMessages = getBinaryNodeMessages;
85
80
  function bufferToUInt(e, t) {
86
81
  let a = 0;
@@ -101,7 +96,7 @@ function binaryNodeToString(node, i = 0) {
101
96
  return tabs(i) + Buffer.from(node).toString('hex');
102
97
  }
103
98
  if (Array.isArray(node)) {
104
- return node.map(x => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n');
99
+ return node.map((x) => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n');
105
100
  }
106
101
  const children = binaryNodeToString(node.content, i + 1);
107
102
  const tag = `<${node.tag} ${Object.entries(node.attrs || {})
@@ -111,3 +106,93 @@ function binaryNodeToString(node, i = 0) {
111
106
  const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>';
112
107
  return tag + content;
113
108
  }
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;
@@ -3,34 +3,29 @@ export declare const OFFICIAL_BIZ_JID = "16505361212@c.us";
3
3
  export declare const SERVER_JID = "server@c.us";
4
4
  export declare const PSA_WID = "0@c.us";
5
5
  export declare const STORIES_JID = "status@broadcast";
6
- export declare const META_AI_JID = "13135550002@c.us";
7
- export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid' | 'newsletter' | 'bot';
6
+ export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid' | 'newsletter';
8
7
  export type JidWithDevice = {
9
8
  user: string;
10
9
  device?: number;
11
10
  };
12
11
  export type FullJid = JidWithDevice & {
13
- server: JidServer;
12
+ server: JidServer | string;
14
13
  domainType?: number;
15
14
  };
16
15
  export declare const jidEncode: (user: string | number | null, server: JidServer, device?: number, agent?: number) => string;
17
16
  export declare const jidDecode: (jid: string | undefined) => FullJid | undefined;
18
17
  /** is the jid a user */
19
18
  export declare const areJidsSameUser: (jid1: string | undefined, jid2: string | undefined) => boolean;
20
- /** is the jid Meta AI */
21
- export declare const isJidMetaAI: (jid: string | undefined) => boolean | undefined;
22
- /** is the jid a PN user */
23
- export declare const isPnUser: (jid: string | undefined) => boolean | undefined;
24
- /** is the jid a LID */
19
+ /** is the jid a user */
20
+ export declare const isJidUser: (jid: string | undefined) => boolean | undefined;
21
+ /** is the jid a group */
25
22
  export declare const isLidUser: (jid: string | undefined) => boolean | undefined;
26
23
  /** is the jid a broadcast */
27
24
  export declare const isJidBroadcast: (jid: string | undefined) => boolean | undefined;
28
25
  /** is the jid a group */
29
26
  export declare const isJidGroup: (jid: string | undefined) => boolean | undefined;
30
27
  /** is the jid the status broadcast */
31
- export declare const isJidStatusBroadcast: (jid: string) => jid is "status@broadcast";
32
- /** is the jid a newsletter */
33
- export declare const isJidNewsletter: (jid: string | undefined) => boolean | undefined;
34
- export declare const isJidBot: (jid: string | undefined) => boolean | "" | undefined;
28
+ export declare const isJidStatusBroadcast: (jid: string) => boolean;
29
+ /** is the jid the newsletter */
30
+ export declare const isJidNewsLetter: (jid: string | undefined) => boolean | undefined;
35
31
  export declare const jidNormalizedUser: (jid: string | undefined) => string;
36
- export declare const transferDevice: (fromJid: string, toJid: string) => string;
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transferDevice = exports.jidNormalizedUser = exports.isJidBot = exports.isJidNewsletter = exports.isJidStatusBroadcast = exports.isJidGroup = exports.isJidBroadcast = exports.isLidUser = exports.isPnUser = 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;
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;
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';
10
9
  const jidEncode = (user, server, device, agent) => {
11
10
  return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}`;
12
11
  };
@@ -21,7 +20,7 @@ const jidDecode = (jid) => {
21
20
  const [userAgent, device] = userCombined.split(':');
22
21
  const user = userAgent.split('_')[0];
23
22
  return {
24
- server: server,
23
+ server,
25
24
  user,
26
25
  domainType: server === 'lid' ? 1 : 0,
27
26
  device: device ? +device : undefined
@@ -29,32 +28,29 @@ const jidDecode = (jid) => {
29
28
  };
30
29
  exports.jidDecode = jidDecode;
31
30
  /** is the jid a user */
32
- const areJidsSameUser = (jid1, jid2) => (0, exports.jidDecode)(jid1)?.user === (0, exports.jidDecode)(jid2)?.user;
31
+ const areJidsSameUser = (jid1, jid2) => {
32
+ var _a, _b;
33
+ 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
+ };
33
35
  exports.areJidsSameUser = areJidsSameUser;
34
- /** is the jid Meta AI */
35
- const isJidMetaAI = (jid) => jid?.endsWith('@bot');
36
- exports.isJidMetaAI = isJidMetaAI;
37
- /** is the jid a PN user */
38
- const isPnUser = (jid) => jid?.endsWith('@s.whatsapp.net');
39
- exports.isPnUser = isPnUser;
40
- /** is the jid a LID */
41
- const isLidUser = (jid) => jid?.endsWith('@lid');
36
+ /** is the jid a user */
37
+ const isJidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@s.whatsapp.net'));
38
+ exports.isJidUser = isJidUser;
39
+ /** is the jid a group */
40
+ const isLidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@lid'));
42
41
  exports.isLidUser = isLidUser;
43
42
  /** is the jid a broadcast */
44
- const isJidBroadcast = (jid) => jid?.endsWith('@broadcast');
43
+ const isJidBroadcast = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@broadcast'));
45
44
  exports.isJidBroadcast = isJidBroadcast;
46
45
  /** is the jid a group */
47
- const isJidGroup = (jid) => jid?.endsWith('@g.us');
46
+ const isJidGroup = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@g.us'));
48
47
  exports.isJidGroup = isJidGroup;
49
48
  /** is the jid the status broadcast */
50
49
  const isJidStatusBroadcast = (jid) => jid === 'status@broadcast';
51
50
  exports.isJidStatusBroadcast = isJidStatusBroadcast;
52
- /** is the jid a newsletter */
53
- const isJidNewsletter = (jid) => jid?.endsWith('@newsletter');
54
- exports.isJidNewsletter = isJidNewsletter;
55
- const botRegexp = /^1313555\d{4}$|^131655500\d{2}$/;
56
- const isJidBot = (jid) => jid && botRegexp.test(jid.split('@')[0]) && jid.endsWith('@c.us');
57
- exports.isJidBot = isJidBot;
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
54
  const jidNormalizedUser = (jid) => {
59
55
  const result = (0, exports.jidDecode)(jid);
60
56
  if (!result) {
@@ -64,10 +60,3 @@ const jidNormalizedUser = (jid) => {
64
60
  return (0, exports.jidEncode)(user, server === 'c.us' ? 's.whatsapp.net' : server);
65
61
  };
66
62
  exports.jidNormalizedUser = jidNormalizedUser;
67
- const transferDevice = (fromJid, toJid) => {
68
- const fromDecoded = (0, exports.jidDecode)(fromJid);
69
- const deviceId = fromDecoded?.device || 0;
70
- const { server, user } = (0, exports.jidDecode)(toJid);
71
- return (0, exports.jidEncode)(user, server, deviceId);
72
- };
73
- exports.transferDevice = transferDevice;
@@ -1,8 +1,17 @@
1
- import type { EventInputType } from './constants';
1
+ /// <reference types="node" />
2
2
  export declare class BinaryInfo {
3
3
  protocolVersion: number;
4
4
  sequence: number;
5
- events: EventInputType[];
5
+ events: {
6
+ [x: string]: {
7
+ props: {
8
+ [x: string]: any;
9
+ };
10
+ globals: {
11
+ [x: string]: any;
12
+ };
13
+ };
14
+ }[];
6
15
  buffer: Buffer[];
7
16
  constructor(options?: Partial<BinaryInfo>);
8
17
  }
@@ -28,12 +28,11 @@ type EventByName<T extends Event['name']> = Extract<Event, {
28
28
  export type EventInputType = {
29
29
  [key in Event['name']]: {
30
30
  props: {
31
- [k in keyof EventByName<key>['props']]: Value;
31
+ [k in keyof EventByName<key>['props']]: any;
32
32
  };
33
33
  globals: {
34
- [x: string]: Value;
34
+ [x: string]: any;
35
35
  };
36
36
  };
37
37
  } & {};
38
- export type Value = number | null | string;
39
38
  export {};