supunmd-bail 2.0.2 → 2.1.3

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 (216) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -2
  3. package/WAProto/index.js +130529 -45236
  4. package/engine-requirements.js +1 -1
  5. package/lib/Defaults/baileys-version.json +1 -1
  6. package/lib/Defaults/index.d.ts +9 -18
  7. package/lib/Defaults/index.js +136 -104
  8. package/lib/Defaults/phonenumber-mcc.json +223 -0
  9. package/lib/Signal/Group/ciphertext-message.d.ts +0 -1
  10. package/lib/Signal/Group/ciphertext-message.js +5 -2
  11. package/lib/Signal/Group/group-session-builder.d.ts +3 -4
  12. package/lib/Signal/Group/group-session-builder.js +41 -7
  13. package/lib/Signal/Group/group_cipher.d.ts +4 -4
  14. package/lib/Signal/Group/group_cipher.js +51 -37
  15. package/lib/Signal/Group/index.d.ts +11 -12
  16. package/lib/Signal/Group/index.js +57 -12
  17. package/lib/Signal/Group/keyhelper.d.ts +1 -2
  18. package/lib/Signal/Group/keyhelper.js +44 -7
  19. package/lib/Signal/Group/queue-job.d.ts +0 -1
  20. package/lib/Signal/Group/queue-job.js +5 -2
  21. package/lib/Signal/Group/sender-chain-key.d.ts +2 -3
  22. package/lib/Signal/Group/sender-chain-key.js +15 -7
  23. package/lib/Signal/Group/sender-key-distribution-message.d.ts +1 -2
  24. package/lib/Signal/Group/sender-key-distribution-message.js +11 -8
  25. package/lib/Signal/Group/sender-key-message.d.ts +1 -2
  26. package/lib/Signal/Group/sender-key-message.js +12 -9
  27. package/lib/Signal/Group/sender-key-name.d.ts +0 -1
  28. package/lib/Signal/Group/sender-key-name.js +5 -2
  29. package/lib/Signal/Group/sender-key-record.d.ts +2 -3
  30. package/lib/Signal/Group/sender-key-record.js +21 -9
  31. package/lib/Signal/Group/sender-key-state.d.ts +6 -7
  32. package/lib/Signal/Group/sender-key-state.js +42 -27
  33. package/lib/Signal/Group/sender-message-key.d.ts +0 -1
  34. package/lib/Signal/Group/sender-message-key.js +7 -4
  35. package/lib/Signal/libsignal.d.ts +3 -5
  36. package/lib/Signal/libsignal.js +90 -258
  37. package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +3 -2
  38. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  39. package/lib/Socket/Client/index.d.ts +3 -3
  40. package/lib/Socket/Client/index.js +19 -3
  41. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  42. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  43. package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -2
  44. package/lib/Socket/Client/web-socket-client.js +62 -0
  45. package/lib/Socket/business.d.ts +108 -125
  46. package/lib/Socket/business.js +43 -159
  47. package/lib/Socket/chats.d.ts +239 -70
  48. package/lib/Socket/chats.js +384 -363
  49. package/lib/Socket/dugong.d.ts +254 -0
  50. package/lib/Socket/dugong.js +484 -0
  51. package/lib/Socket/groups.d.ts +56 -78
  52. package/lib/Socket/groups.js +96 -106
  53. package/lib/Socket/index.d.ts +115 -173
  54. package/lib/Socket/index.js +10 -17
  55. package/lib/Socket/messages-recv.d.ts +79 -91
  56. package/lib/Socket/messages-recv.js +521 -639
  57. package/lib/Socket/messages-send.d.ts +91 -111
  58. package/lib/Socket/messages-send.js +438 -599
  59. package/lib/Socket/newsletter.d.ts +84 -97
  60. package/lib/Socket/newsletter.js +1 -181
  61. package/lib/Socket/registration.d.ts +267 -0
  62. package/lib/Socket/registration.js +166 -0
  63. package/lib/Socket/socket.d.ts +18 -26
  64. package/lib/Socket/socket.js +230 -448
  65. package/lib/Socket/usync.d.ts +16 -17
  66. package/lib/Socket/usync.js +26 -19
  67. package/lib/Store/index.d.ts +3 -0
  68. package/lib/Store/index.js +10 -0
  69. package/lib/Store/make-cache-manager-store.d.ts +13 -0
  70. package/lib/Store/make-cache-manager-store.js +83 -0
  71. package/lib/Store/make-in-memory-store.d.ts +118 -0
  72. package/lib/Store/make-in-memory-store.js +427 -0
  73. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  74. package/lib/Store/make-ordered-dictionary.js +81 -0
  75. package/lib/Store/object-repository.d.ts +10 -0
  76. package/lib/Store/object-repository.js +27 -0
  77. package/lib/Types/Auth.d.ts +12 -13
  78. package/lib/Types/Auth.js +2 -2
  79. package/lib/Types/Call.d.ts +1 -2
  80. package/lib/Types/Call.js +2 -2
  81. package/lib/Types/Chat.d.ts +13 -34
  82. package/lib/Types/Chat.js +4 -8
  83. package/lib/Types/Contact.d.ts +1 -6
  84. package/lib/Types/Contact.js +2 -2
  85. package/lib/Types/Events.d.ts +15 -60
  86. package/lib/Types/Events.js +2 -2
  87. package/lib/Types/GroupMetadata.d.ts +5 -17
  88. package/lib/Types/GroupMetadata.js +2 -2
  89. package/lib/Types/Label.d.ts +0 -12
  90. package/lib/Types/Label.js +5 -3
  91. package/lib/Types/LabelAssociation.d.ts +0 -1
  92. package/lib/Types/LabelAssociation.js +5 -3
  93. package/lib/Types/Message.d.ts +54 -84
  94. package/lib/Types/Message.js +9 -11
  95. package/lib/Types/Newsletter.d.ts +98 -130
  96. package/lib/Types/Newsletter.js +38 -31
  97. package/lib/Types/Product.d.ts +1 -2
  98. package/lib/Types/Product.js +2 -2
  99. package/lib/Types/Signal.d.ts +1 -20
  100. package/lib/Types/Signal.js +2 -2
  101. package/lib/Types/Socket.d.ts +25 -47
  102. package/lib/Types/Socket.js +2 -3
  103. package/lib/Types/State.d.ts +2 -14
  104. package/lib/Types/State.js +2 -13
  105. package/lib/Types/USync.d.ts +2 -3
  106. package/lib/Types/USync.js +2 -2
  107. package/lib/Types/index.d.ts +14 -22
  108. package/lib/Types/index.js +31 -15
  109. package/lib/Utils/auth-utils.d.ts +6 -7
  110. package/lib/Utils/auth-utils.js +148 -199
  111. package/lib/Utils/baileys-event-stream.d.ts +1 -2
  112. package/lib/Utils/baileys-event-stream.js +22 -15
  113. package/lib/Utils/business.d.ts +2 -3
  114. package/lib/Utils/business.js +69 -66
  115. package/lib/Utils/chat-utils.d.ts +22 -21
  116. package/lib/Utils/chat-utils.js +226 -260
  117. package/lib/Utils/crypto.d.ts +19 -19
  118. package/lib/Utils/crypto.js +86 -77
  119. package/lib/Utils/decode-wa-message.d.ts +8 -37
  120. package/lib/Utils/decode-wa-message.js +83 -164
  121. package/lib/Utils/event-buffer.d.ts +8 -7
  122. package/lib/Utils/event-buffer.js +76 -110
  123. package/lib/Utils/generics.d.ts +29 -27
  124. package/lib/Utils/generics.js +210 -168
  125. package/lib/Utils/history.d.ts +8 -12
  126. package/lib/Utils/history.js +46 -34
  127. package/lib/Utils/index.d.ts +17 -20
  128. package/lib/Utils/index.js +33 -20
  129. package/lib/Utils/link-preview.d.ts +5 -5
  130. package/lib/Utils/link-preview.js +22 -14
  131. package/lib/Utils/logger.d.ts +3 -11
  132. package/lib/Utils/logger.js +7 -3
  133. package/lib/Utils/lt-hash.d.ts +8 -9
  134. package/lib/Utils/lt-hash.js +28 -25
  135. package/lib/Utils/make-mutex.d.ts +2 -3
  136. package/lib/Utils/make-mutex.js +10 -7
  137. package/lib/Utils/messages-media.d.ts +44 -42
  138. package/lib/Utils/messages-media.js +475 -319
  139. package/lib/Utils/messages.d.ts +18 -17
  140. package/lib/Utils/messages.js +259 -383
  141. package/lib/Utils/noise-handler.d.ts +15 -14
  142. package/lib/Utils/noise-handler.js +38 -30
  143. package/lib/Utils/process-message.d.ts +13 -14
  144. package/lib/Utils/process-message.js +147 -239
  145. package/lib/Utils/signal.d.ts +5 -7
  146. package/lib/Utils/signal.js +72 -78
  147. package/lib/Utils/use-multi-file-auth-state.d.ts +2 -2
  148. package/lib/Utils/use-multi-file-auth-state.js +27 -29
  149. package/lib/Utils/validate-connection.d.ts +7 -7
  150. package/lib/Utils/validate-connection.js +106 -72
  151. package/lib/WABinary/constants.d.ts +27 -25
  152. package/lib/WABinary/constants.js +20 -1281
  153. package/lib/WABinary/decode.d.ts +5 -5
  154. package/lib/WABinary/decode.js +42 -28
  155. package/lib/WABinary/encode.d.ts +3 -3
  156. package/lib/WABinary/encode.js +154 -105
  157. package/lib/WABinary/generic-utils.d.ts +7 -5
  158. package/lib/WABinary/generic-utils.js +63 -56
  159. package/lib/WABinary/index.d.ts +5 -6
  160. package/lib/WABinary/index.js +21 -6
  161. package/lib/WABinary/jid-utils.d.ts +8 -25
  162. package/lib/WABinary/jid-utils.js +40 -74
  163. package/lib/WABinary/types.d.ts +1 -2
  164. package/lib/WABinary/types.js +2 -2
  165. package/lib/WAM/BinaryInfo.d.ts +11 -3
  166. package/lib/WAM/BinaryInfo.js +5 -2
  167. package/lib/WAM/constants.d.ts +3 -5
  168. package/lib/WAM/constants.js +11958 -19461
  169. package/lib/WAM/encode.d.ts +3 -3
  170. package/lib/WAM/encode.js +22 -17
  171. package/lib/WAM/index.d.ts +3 -4
  172. package/lib/WAM/index.js +19 -4
  173. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -4
  174. package/lib/WAUSync/Protocols/USyncContactProtocol.js +11 -8
  175. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -3
  176. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +14 -11
  177. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -3
  178. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +12 -9
  179. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -3
  180. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +13 -9
  181. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +3 -4
  182. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +22 -20
  183. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -5
  184. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +8 -13
  185. package/lib/WAUSync/Protocols/index.d.ts +4 -5
  186. package/lib/WAUSync/Protocols/index.js +20 -5
  187. package/lib/WAUSync/USyncQuery.d.ts +4 -5
  188. package/lib/WAUSync/USyncQuery.js +35 -40
  189. package/lib/WAUSync/USyncUser.d.ts +5 -6
  190. package/lib/WAUSync/USyncUser.js +5 -2
  191. package/lib/WAUSync/index.d.ts +3 -4
  192. package/lib/WAUSync/index.js +19 -4
  193. package/lib/index.d.ts +9 -19
  194. package/lib/index.js +1 -36
  195. package/package.json +109 -103
  196. package/WAProto/GenerateStatics.sh +0 -3
  197. package/WAProto/WAProto.proto +0 -5519
  198. package/WAProto/fix-imports.js +0 -29
  199. package/WAProto/index.d.ts +0 -11969
  200. package/lib/Signal/lid-mapping.d.ts +0 -23
  201. package/lib/Signal/lid-mapping.js +0 -171
  202. package/lib/Socket/Client/types.js +0 -11
  203. package/lib/Socket/Client/websocket.js +0 -50
  204. package/lib/Socket/communities.d.ts +0 -244
  205. package/lib/Socket/communities.js +0 -431
  206. package/lib/Socket/mex.d.ts +0 -3
  207. package/lib/Socket/mex.js +0 -42
  208. package/lib/Types/Bussines.d.ts +0 -25
  209. package/lib/Types/Bussines.js +0 -2
  210. package/lib/Utils/browser-utils.d.ts +0 -4
  211. package/lib/Utils/browser-utils.js +0 -28
  212. package/lib/Utils/message-retry-manager.d.ts +0 -82
  213. package/lib/Utils/message-retry-manager.js +0 -149
  214. package/lib/Utils/pre-key-manager.d.ts +0 -28
  215. package/lib/Utils/pre-key-manager.js +0 -106
  216. /package/lib/{supun → supunmd} +0 -0
@@ -1,131 +1,17 @@
1
- import { getRawMediaUploadData } from '../Utils/index.js';
2
- import { parseCatalogNode, parseCollectionsNode, parseOrderDetailsNode, parseProductNode, toProductNode, uploadingNecessaryImagesOfProduct } from '../Utils/business.js';
3
- import { jidNormalizedUser, S_WHATSAPP_NET } from '../WABinary/index.js';
4
- import { getBinaryNodeChild } from '../WABinary/generic-utils.js';
5
- import { makeMessagesRecvSocket } from './messages-recv.js';
6
- export const makeBusinessSocket = (config) => {
7
- const sock = makeMessagesRecvSocket(config);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeBusinessSocket = void 0;
4
+ const business_1 = require("../Utils/business");
5
+ const WABinary_1 = require("../WABinary");
6
+ const generic_utils_1 = require("../WABinary/generic-utils");
7
+ const messages_recv_1 = require("./messages-recv");
8
+ const makeBusinessSocket = (config) => {
9
+ const sock = (0, messages_recv_1.makeMessagesRecvSocket)(config);
8
10
  const { authState, query, waUploadToServer } = sock;
9
- const updateBussinesProfile = async (args) => {
10
- const node = [];
11
- const simpleFields = ['address', 'email', 'description'];
12
- node.push(...simpleFields
13
- .filter(key => args[key])
14
- .map(key => ({
15
- tag: key,
16
- attrs: {},
17
- content: args[key]
18
- })));
19
- if (args.websites) {
20
- node.push(...args.websites.map(website => ({
21
- tag: 'website',
22
- attrs: {},
23
- content: website
24
- })));
25
- }
26
- if (args.hours) {
27
- node.push({
28
- tag: 'business_hours',
29
- attrs: { timezone: args.hours.timezone },
30
- content: args.hours.days.map(config => {
31
- const base = {
32
- tag: 'business_hours_config',
33
- attrs: { day_of_week: config.day, mode: config.mode }
34
- };
35
- if (config.mode === 'specific_hours') {
36
- return {
37
- ...base,
38
- attrs: {
39
- ...base.attrs,
40
- open_time: config.openTimeInMinutes,
41
- close_time: config.closeTimeInMinutes
42
- }
43
- };
44
- }
45
- return base;
46
- })
47
- });
48
- }
49
- const result = await query({
50
- tag: 'iq',
51
- attrs: {
52
- to: S_WHATSAPP_NET,
53
- type: 'set',
54
- xmlns: 'w:biz'
55
- },
56
- content: [
57
- {
58
- tag: 'business_profile',
59
- attrs: {
60
- v: '3',
61
- mutation_type: 'delta'
62
- },
63
- content: node
64
- }
65
- ]
66
- });
67
- return result;
68
- };
69
- const updateCoverPhoto = async (photo) => {
70
- const { fileSha256, filePath } = await getRawMediaUploadData(photo, 'biz-cover-photo');
71
- const fileSha256B64 = fileSha256.toString('base64');
72
- const { meta_hmac, fbid, ts } = await waUploadToServer(filePath, {
73
- fileEncSha256B64: fileSha256B64,
74
- mediaType: 'biz-cover-photo'
75
- });
76
- await query({
77
- tag: 'iq',
78
- attrs: {
79
- to: S_WHATSAPP_NET,
80
- type: 'set',
81
- xmlns: 'w:biz'
82
- },
83
- content: [
84
- {
85
- tag: 'business_profile',
86
- attrs: {
87
- v: '3',
88
- mutation_type: 'delta'
89
- },
90
- content: [
91
- {
92
- tag: 'cover_photo',
93
- attrs: { id: String(fbid), op: 'update', token: meta_hmac, ts: String(ts) }
94
- }
95
- ]
96
- }
97
- ]
98
- });
99
- return fbid;
100
- };
101
- const removeCoverPhoto = async (id) => {
102
- return await query({
103
- tag: 'iq',
104
- attrs: {
105
- to: S_WHATSAPP_NET,
106
- type: 'set',
107
- xmlns: 'w:biz'
108
- },
109
- content: [
110
- {
111
- tag: 'business_profile',
112
- attrs: {
113
- v: '3',
114
- mutation_type: 'delta'
115
- },
116
- content: [
117
- {
118
- tag: 'cover_photo',
119
- attrs: { op: 'delete', id }
120
- }
121
- ]
122
- }
123
- ]
124
- });
125
- };
126
11
  const getCatalog = async ({ jid, limit, cursor }) => {
127
- jid = jid || authState.creds.me?.id;
128
- jid = jidNormalizedUser(jid);
12
+ var _a;
13
+ jid = jid || ((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id);
14
+ jid = (0, WABinary_1.jidNormalizedUser)(jid);
129
15
  const queryParamNodes = [
130
16
  {
131
17
  tag: 'limit',
@@ -141,7 +27,7 @@ export const makeBusinessSocket = (config) => {
141
27
  tag: 'height',
142
28
  attrs: {},
143
29
  content: Buffer.from('100')
144
- }
30
+ },
145
31
  ];
146
32
  if (cursor) {
147
33
  queryParamNodes.push({
@@ -153,7 +39,7 @@ export const makeBusinessSocket = (config) => {
153
39
  const result = await query({
154
40
  tag: 'iq',
155
41
  attrs: {
156
- to: S_WHATSAPP_NET,
42
+ to: WABinary_1.S_WHATSAPP_NET,
157
43
  type: 'get',
158
44
  xmlns: 'w:biz:catalog'
159
45
  },
@@ -162,30 +48,31 @@ export const makeBusinessSocket = (config) => {
162
48
  tag: 'product_catalog',
163
49
  attrs: {
164
50
  jid,
165
- allow_shop_source: 'true'
51
+ 'allow_shop_source': 'true'
166
52
  },
167
53
  content: queryParamNodes
168
54
  }
169
55
  ]
170
56
  });
171
- return parseCatalogNode(result);
57
+ return (0, business_1.parseCatalogNode)(result);
172
58
  };
173
59
  const getCollections = async (jid, limit = 51) => {
174
- jid = jid || authState.creds.me?.id;
175
- jid = jidNormalizedUser(jid);
60
+ var _a;
61
+ jid = jid || ((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id);
62
+ jid = (0, WABinary_1.jidNormalizedUser)(jid);
176
63
  const result = await query({
177
64
  tag: 'iq',
178
65
  attrs: {
179
- to: S_WHATSAPP_NET,
66
+ to: WABinary_1.S_WHATSAPP_NET,
180
67
  type: 'get',
181
68
  xmlns: 'w:biz:catalog',
182
- smax_id: '35'
69
+ 'smax_id': '35'
183
70
  },
184
71
  content: [
185
72
  {
186
73
  tag: 'collections',
187
74
  attrs: {
188
- biz_jid: jid
75
+ 'biz_jid': jid,
189
76
  },
190
77
  content: [
191
78
  {
@@ -212,16 +99,16 @@ export const makeBusinessSocket = (config) => {
212
99
  }
213
100
  ]
214
101
  });
215
- return parseCollectionsNode(result);
102
+ return (0, business_1.parseCollectionsNode)(result);
216
103
  };
217
104
  const getOrderDetails = async (orderId, tokenBase64) => {
218
105
  const result = await query({
219
106
  tag: 'iq',
220
107
  attrs: {
221
- to: S_WHATSAPP_NET,
108
+ to: WABinary_1.S_WHATSAPP_NET,
222
109
  type: 'get',
223
110
  xmlns: 'fb:thrift_iq',
224
- smax_id: '5'
111
+ 'smax_id': '5'
225
112
  },
226
113
  content: [
227
114
  {
@@ -256,15 +143,15 @@ export const makeBusinessSocket = (config) => {
256
143
  }
257
144
  ]
258
145
  });
259
- return parseOrderDetailsNode(result);
146
+ return (0, business_1.parseOrderDetailsNode)(result);
260
147
  };
261
148
  const productUpdate = async (productId, update) => {
262
- update = await uploadingNecessaryImagesOfProduct(update, waUploadToServer);
263
- const editNode = toProductNode(productId, update);
149
+ update = await (0, business_1.uploadingNecessaryImagesOfProduct)(update, waUploadToServer);
150
+ const editNode = (0, business_1.toProductNode)(productId, update);
264
151
  const result = await query({
265
152
  tag: 'iq',
266
153
  attrs: {
267
- to: S_WHATSAPP_NET,
154
+ to: WABinary_1.S_WHATSAPP_NET,
268
155
  type: 'set',
269
156
  xmlns: 'w:biz:catalog'
270
157
  },
@@ -288,19 +175,19 @@ export const makeBusinessSocket = (config) => {
288
175
  }
289
176
  ]
290
177
  });
291
- const productCatalogEditNode = getBinaryNodeChild(result, 'product_catalog_edit');
292
- const productNode = getBinaryNodeChild(productCatalogEditNode, 'product');
293
- return parseProductNode(productNode);
178
+ const productCatalogEditNode = (0, generic_utils_1.getBinaryNodeChild)(result, 'product_catalog_edit');
179
+ const productNode = (0, generic_utils_1.getBinaryNodeChild)(productCatalogEditNode, 'product');
180
+ return (0, business_1.parseProductNode)(productNode);
294
181
  };
295
182
  const productCreate = async (create) => {
296
183
  // ensure isHidden is defined
297
184
  create.isHidden = !!create.isHidden;
298
- create = await uploadingNecessaryImagesOfProduct(create, waUploadToServer);
299
- const createNode = toProductNode(undefined, create);
185
+ create = await (0, business_1.uploadingNecessaryImagesOfProduct)(create, waUploadToServer);
186
+ const createNode = (0, business_1.toProductNode)(undefined, create);
300
187
  const result = await query({
301
188
  tag: 'iq',
302
189
  attrs: {
303
- to: S_WHATSAPP_NET,
190
+ to: WABinary_1.S_WHATSAPP_NET,
304
191
  type: 'set',
305
192
  xmlns: 'w:biz:catalog'
306
193
  },
@@ -324,15 +211,15 @@ export const makeBusinessSocket = (config) => {
324
211
  }
325
212
  ]
326
213
  });
327
- const productCatalogAddNode = getBinaryNodeChild(result, 'product_catalog_add');
328
- const productNode = getBinaryNodeChild(productCatalogAddNode, 'product');
329
- return parseProductNode(productNode);
214
+ const productCatalogAddNode = (0, generic_utils_1.getBinaryNodeChild)(result, 'product_catalog_add');
215
+ const productNode = (0, generic_utils_1.getBinaryNodeChild)(productCatalogAddNode, 'product');
216
+ return (0, business_1.parseProductNode)(productNode);
330
217
  };
331
218
  const productDelete = async (productIds) => {
332
219
  const result = await query({
333
220
  tag: 'iq',
334
221
  attrs: {
335
- to: S_WHATSAPP_NET,
222
+ to: WABinary_1.S_WHATSAPP_NET,
336
223
  type: 'set',
337
224
  xmlns: 'w:biz:catalog'
338
225
  },
@@ -354,9 +241,9 @@ export const makeBusinessSocket = (config) => {
354
241
  }
355
242
  ]
356
243
  });
357
- const productCatalogDelNode = getBinaryNodeChild(result, 'product_catalog_delete');
244
+ const productCatalogDelNode = (0, generic_utils_1.getBinaryNodeChild)(result, 'product_catalog_delete');
358
245
  return {
359
- deleted: +(productCatalogDelNode?.attrs.deleted_count || 0)
246
+ deleted: +((productCatalogDelNode === null || productCatalogDelNode === void 0 ? void 0 : productCatalogDelNode.attrs.deleted_count) || 0)
360
247
  };
361
248
  };
362
249
  return {
@@ -367,10 +254,7 @@ export const makeBusinessSocket = (config) => {
367
254
  getCollections,
368
255
  productCreate,
369
256
  productDelete,
370
- productUpdate,
371
- updateBussinesProfile,
372
- updateCoverPhoto,
373
- removeCoverPhoto
257
+ productUpdate
374
258
  };
375
259
  };
376
- //# sourceMappingURL=business.js.map
260
+ exports.makeBusinessSocket = makeBusinessSocket;
@@ -1,98 +1,267 @@
1
- import { Boom } from '@hapi/boom';
2
- import { proto } from '../../WAProto/index.js';
3
- import type { BotListInfo, ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAMessage, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types/index.js';
4
- import type { QuickReplyAction } from '../Types/Bussines.js';
5
- import type { LabelActionBody } from '../Types/Label.js';
6
- import { type BinaryNode } from '../WABinary/index.js';
7
- import { USyncQuery } from '../WAUSync/index.js';
8
- export declare const makeChatsSocket: (config: SocketConfig) => {
9
- createCallLink: (type: "audio" | "video", event?: {
10
- startTime: number;
11
- }, timeoutMs?: number) => Promise<string | undefined>;
12
- getBotListV2: () => Promise<BotListInfo[]>;
13
- processingMutex: {
14
- mutex<T>(code: () => Promise<T> | T): Promise<T>;
1
+ /// <reference types="node" />
2
+ import { AxiosRequestConfig } from 'axios';
3
+ import { KeyPair, SignedKeyPair, SocketConfig } from '../Types';
4
+ export declare const makeRegistrationSocket: (config: SocketConfig) => {
5
+ register: (code: string) => Promise<ExistsResponse>;
6
+ requestRegistrationCode: (registrationOptions?: RegistrationOptions) => Promise<ExistsResponse>;
7
+ logger: import("pino").Logger<import("pino").LoggerOptions>;
8
+ getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
9
+ getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
10
+ products: import("../Types").Product[];
11
+ nextPageCursor: string | undefined;
12
+ }>;
13
+ getCollections: (jid?: string | undefined, limit?: number) => Promise<{
14
+ collections: import("../Types").CatalogCollection[];
15
+ }>;
16
+ productCreate: (create: import("../Types").ProductCreate) => Promise<import("../Types").Product>;
17
+ productDelete: (productIds: string[]) => Promise<{
18
+ deleted: number;
19
+ }>;
20
+ productUpdate: (productId: string, update: import("../Types").ProductUpdate) => Promise<import("../Types").Product>;
21
+ sendMessageAck: ({ tag, attrs, content }: import("../WABinary").BinaryNode) => Promise<void>;
22
+ sendRetryRequest: (node: import("../WABinary").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
23
+ offerCall: (toJid: string, isVideo?: boolean) => Promise<{
24
+ id: string;
25
+ to: string;
26
+ }>;
27
+ rejectCall: (callId: string, callFrom: string) => Promise<void>;
28
+ getPrivacyTokens: (jids: string[]) => Promise<import("../WABinary").BinaryNode>;
29
+ assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
30
+ relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
31
+ sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
32
+ sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
33
+ getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
34
+ [key: string]: string;
15
35
  };
36
+ readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
37
+ refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
38
+ getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
39
+ createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
40
+ [key: string]: string;
41
+ } | undefined) => Promise<{
42
+ nodes: import("../WABinary").BinaryNode[];
43
+ shouldIncludeDeviceIdentity: boolean;
44
+ }>;
45
+ waUploadToServer: import("../Types").WAMediaUploadFunction;
16
46
  fetchPrivacySettings: (force?: boolean) => Promise<{
17
47
  [_: string]: string;
18
48
  }>;
19
- upsertMessage: (msg: WAMessage, type: MessageUpsertType) => Promise<void>;
20
- appPatch: (patchCreate: WAPatchCreate) => Promise<void>;
21
- sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise<void>;
22
- presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
23
- profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
24
- fetchBlocklist: () => Promise<(string | undefined)[]>;
25
- fetchStatus: (...jids: string[]) => Promise<import("../WAUSync/index.js").USyncQueryResultList[] | undefined>;
26
- fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync/index.js").USyncQueryResultList[] | undefined>;
27
- updateProfilePicture: (jid: string, content: WAMediaUpload, dimensions?: {
28
- width: number;
29
- height: number;
30
- }) => Promise<void>;
49
+ updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
50
+ sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
51
+ subscribeNewsletterUpdates: (jid: string) => Promise<{
52
+ duration: string;
53
+ }>;
54
+ newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
55
+ newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
56
+ newsletterUpdateName: (jid: string, name: string) => Promise<void>;
57
+ newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
58
+ newsletterRemovePicture: (jid: string) => Promise<void>;
59
+ newsletterUnfollow: (jid: string) => Promise<void>;
60
+ newsletterFollow: (jid: string) => Promise<void>;
61
+ newsletterUnmute: (jid: string) => Promise<void>;
62
+ newsletterMute: (jid: string) => Promise<void>;
63
+ newsletterAction: (jid: string, type: "mute" | "follow" | "unfollow" | "unmute") => Promise<void>;
64
+ newsletterCreate: (name: string, description: string, reaction_codes: string) => Promise<import("../Types").NewsletterMetadata>;
65
+ newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
66
+ newsletterAdminCount: (jid: string) => Promise<number>;
67
+ newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
68
+ newsletterDemote: (jid: string, user: string) => Promise<void>;
69
+ newsletterDelete: (jid: string) => Promise<void>;
70
+ newsletterReactMessage: (jid: string, serverId: string, code?: string | undefined) => Promise<void>;
71
+ newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
72
+ newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
73
+ groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
74
+ groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
75
+ groupLeave: (id: string) => Promise<void>;
76
+ /** the network code of your mobile network
77
+ * @see {@link https://de.wikipedia.org/wiki/Mobile_Network_Code}
78
+ */
79
+ groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
80
+ groupRequestParticipantsList: (jid: string) => Promise<{
81
+ [key: string]: string;
82
+ }[]>;
83
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
84
+ status: string;
85
+ jid: string;
86
+ }[]>;
87
+ groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
88
+ status: string;
89
+ jid: string;
90
+ content: import("../WABinary").BinaryNode;
91
+ }[]>;
92
+ groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
93
+ groupInviteCode: (jid: string) => Promise<string | undefined>;
94
+ groupRevokeInvite: (jid: string) => Promise<string | undefined>;
95
+ groupAcceptInvite: (code: string) => Promise<string | undefined>;
96
+ groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
97
+ groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
98
+ groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
99
+ groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
100
+ groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
101
+ groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
102
+ groupFetchAllParticipating: () => Promise<{
103
+ [_: string]: import("../Types").GroupMetadata;
104
+ }>;
105
+ processingMutex: {
106
+ mutex<T>(code: () => T | Promise<T>): Promise<T>;
107
+ };
108
+ upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
109
+ appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
110
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
111
+ presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
112
+ profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
113
+ onWhatsApp: (...jids: string[]) => Promise<{
114
+ exists: boolean;
115
+ jid: string;
116
+ }[]>;
117
+ fetchBlocklist: () => Promise<string[]>;
118
+ fetchStatus: (jid: string) => Promise<{
119
+ status: string | undefined;
120
+ setAt: Date;
121
+ } | undefined>;
122
+ updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
31
123
  removeProfilePicture: (jid: string) => Promise<void>;
32
124
  updateProfileStatus: (status: string) => Promise<void>;
33
125
  updateProfileName: (name: string) => Promise<void>;
34
126
  updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
35
- updateDisableLinkPreviewsPrivacy: (isPreviewsDisabled: boolean) => Promise<void>;
36
- updateCallPrivacy: (value: WAPrivacyCallValue) => Promise<void>;
37
- updateMessagesPrivacy: (value: WAPrivacyMessagesValue) => Promise<void>;
38
- updateLastSeenPrivacy: (value: WAPrivacyValue) => Promise<void>;
39
- updateOnlinePrivacy: (value: WAPrivacyOnlineValue) => Promise<void>;
40
- updateProfilePicturePrivacy: (value: WAPrivacyValue) => Promise<void>;
41
- updateStatusPrivacy: (value: WAPrivacyValue) => Promise<void>;
42
- updateReadReceiptsPrivacy: (value: WAReadReceiptsValue) => Promise<void>;
43
- updateGroupsAddPrivacy: (value: WAPrivacyGroupAddValue) => Promise<void>;
127
+ updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
128
+ updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
129
+ updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
130
+ updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
131
+ updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
132
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
44
133
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
45
- getBusinessProfile: (jid: string) => Promise<WABusinessProfile | void>;
46
- resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
47
- chatModify: (mod: ChatModification, jid: string) => Promise<void>;
48
- cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
49
- addOrEditContact: (jid: string, contact: proto.SyncActionValue.IContactAction) => Promise<void>;
50
- removeContact: (jid: string) => Promise<void>;
51
- addLabel: (jid: string, labels: LabelActionBody) => Promise<void>;
134
+ getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
135
+ resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
136
+ chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
137
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
52
138
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
53
139
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
54
140
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
55
141
  removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
56
142
  star: (jid: string, messages: {
57
143
  id: string;
58
- fromMe?: boolean;
144
+ fromMe?: boolean | undefined;
59
145
  }[], star: boolean) => Promise<void>;
60
- addOrEditQuickReply: (quickReply: QuickReplyAction) => Promise<void>;
61
- removeQuickReply: (timestamp: string) => Promise<void>;
62
146
  type: "md";
63
- ws: import("./Client/websocket.js").WebSocketClient;
64
- ev: import("../Types/index.js").BaileysEventEmitter & {
65
- process(handler: (events: Partial<import("../Types/index.js").BaileysEventMap>) => void | Promise<void>): () => void;
147
+ ws: any;
148
+ ev: import("../Types").BaileysEventEmitter & {
149
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
66
150
  buffer(): void;
67
- createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
68
- flush(): boolean;
151
+ createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
152
+ flush(force?: boolean | undefined): boolean;
69
153
  isBuffering(): boolean;
70
154
  };
71
155
  authState: {
72
- creds: import("../Types/index.js").AuthenticationCreds;
73
- keys: import("../Types/index.js").SignalKeyStoreWithTransaction;
156
+ creds: import("../Types").AuthenticationCreds;
157
+ keys: import("../Types").SignalKeyStoreWithTransaction;
74
158
  };
75
- signalRepository: import("../Types/index.js").SignalRepositoryWithLIDStore;
76
- user: import("../Types/index.js").Contact | undefined;
159
+ signalRepository: import("../Types").SignalRepository;
160
+ user: import("../Types").Contact | undefined;
77
161
  generateMessageTag: () => string;
78
- query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
79
- waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T | undefined>;
162
+ query: (node: import("../WABinary").BinaryNode, timeoutMs?: number | undefined) => Promise<import("../WABinary").BinaryNode>;
163
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
80
164
  waitForSocketOpen: () => Promise<void>;
81
165
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
82
- sendNode: (frame: BinaryNode) => Promise<void>;
83
- logout: (msg?: string) => Promise<void>;
166
+ sendNode: (frame: import("../WABinary").BinaryNode) => Promise<void>;
167
+ logout: (msg?: string | undefined) => Promise<void>;
84
168
  end: (error: Error | undefined) => void;
85
- onUnexpectedError: (err: Error | Boom, msg: string) => void;
86
- uploadPreKeys: (count?: number, retryCount?: number) => Promise<void>;
169
+ onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
170
+ uploadPreKeys: (count?: number) => Promise<void>;
87
171
  uploadPreKeysToServerIfRequired: () => Promise<void>;
88
- requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
89
- wamBuffer: import("../index.js").BinaryInfo;
90
- waitForConnectionUpdate: (check: (u: Partial<import("../Types/index.js").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
91
- sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
92
- executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync/index.js").USyncQueryResult | undefined>;
93
- onWhatsApp: (...phoneNumber: string[]) => Promise<{
94
- jid: string;
95
- exists: boolean;
96
- }[] | undefined>;
172
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
173
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
174
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<import("../WABinary").BinaryNode>;
175
+ };
176
+ export interface RegistrationData {
177
+ registrationId: number;
178
+ signedPreKey: SignedKeyPair;
179
+ noiseKey: KeyPair;
180
+ signedIdentityKey: KeyPair;
181
+ identityId: Buffer;
182
+ phoneId: string;
183
+ deviceId: string;
184
+ backupToken: Buffer;
185
+ }
186
+ export interface RegistrationOptions {
187
+ /** your phone number */
188
+ phoneNumber?: string;
189
+ /** the country code of your phone number */
190
+ phoneNumberCountryCode: string;
191
+ /** your phone number without country code */
192
+ phoneNumberNationalNumber: string;
193
+ /** the country code of your mobile network
194
+ * @see {@link https://de.wikipedia.org/wiki/Mobile_Country_Code}
195
+ */
196
+ phoneNumberMobileCountryCode: string;
197
+ /** the network code of your mobile network
198
+ * @see {@link https://de.wikipedia.org/wiki/Mobile_Network_Code}
199
+ */
200
+ phoneNumberMobileNetworkCode: string;
201
+ /**
202
+ * How to send the one time code
203
+ */
204
+ method?: 'sms' | 'voice' | 'captcha';
205
+ /**
206
+ * The captcha code if it was requested
207
+ */
208
+ captcha?: string;
209
+ }
210
+ export type RegistrationParams = RegistrationData & RegistrationOptions;
211
+ export declare function registrationParams(params: RegistrationParams): {
212
+ cc: string;
213
+ in: string;
214
+ Rc: string;
215
+ lg: string;
216
+ lc: string;
217
+ mistyped: string;
218
+ authkey: string;
219
+ e_regid: string;
220
+ e_keytype: string;
221
+ e_ident: string;
222
+ e_skey_id: string;
223
+ e_skey_val: string;
224
+ e_skey_sig: string;
225
+ fdid: string;
226
+ network_ratio_type: string;
227
+ expid: string;
228
+ simnum: string;
229
+ hasinrc: string;
230
+ pid: string;
231
+ id: string;
232
+ backup_token: string;
233
+ token: string;
234
+ fraud_checkpoint_code: string | undefined;
97
235
  };
98
- //# sourceMappingURL=chats.d.ts.map
236
+ /**
237
+ * Requests a registration code for the given phone number.
238
+ */
239
+ export declare function mobileRegisterCode(params: RegistrationParams, fetchOptions?: AxiosRequestConfig): Promise<ExistsResponse>;
240
+ export declare function mobileRegisterExists(params: RegistrationParams, fetchOptions?: AxiosRequestConfig): Promise<ExistsResponse>;
241
+ /**
242
+ * Registers the phone number on whatsapp with the received OTP code.
243
+ */
244
+ export declare function mobileRegister(params: RegistrationParams & {
245
+ code: string;
246
+ }, fetchOptions?: AxiosRequestConfig): Promise<ExistsResponse>;
247
+ /**
248
+ * Encrypts the given string as AEAD aes-256-gcm with the public whatsapp key and a random keypair.
249
+ */
250
+ export declare function mobileRegisterEncrypt(data: string): string;
251
+ export declare function mobileRegisterFetch(path: string, opts?: AxiosRequestConfig): Promise<ExistsResponse>;
252
+ export interface ExistsResponse {
253
+ status: 'fail' | 'sent';
254
+ voice_length?: number;
255
+ voice_wait?: number;
256
+ sms_length?: number;
257
+ sms_wait?: number;
258
+ reason?: 'incorrect' | 'missing_param' | 'code_checkpoint';
259
+ login?: string;
260
+ flash_type?: number;
261
+ ab_hash?: string;
262
+ ab_key?: string;
263
+ exp_cfg?: string;
264
+ lid?: string;
265
+ image_blob?: string;
266
+ audio_blob?: string;
267
+ }