@xbibzlibrary/whatsbibz 1.3.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 (260) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/LICENSE +22 -0
  3. package/LICENSE.upstream +21 -0
  4. package/README.md +280 -0
  5. package/VERIFIKASI-IDENTITAS-2026-09-03.md +138 -0
  6. package/WAProto/GenerateStatics.sh +3 -0
  7. package/WAProto/WAProto.proto +6035 -0
  8. package/WAProto/fix-imports.js +81 -0
  9. package/WAProto/index.d.ts +15314 -0
  10. package/WAProto/index.js +132326 -0
  11. package/assets/logo/README.md +21 -0
  12. package/assets/logo/png/banner-1200x360.png +0 -0
  13. package/assets/logo/png/icon-1024.png +0 -0
  14. package/assets/logo/png/icon-128.png +0 -0
  15. package/assets/logo/png/icon-16.png +0 -0
  16. package/assets/logo/png/icon-24.png +0 -0
  17. package/assets/logo/png/icon-256.png +0 -0
  18. package/assets/logo/png/icon-32.png +0 -0
  19. package/assets/logo/png/icon-48.png +0 -0
  20. package/assets/logo/png/icon-512.png +0 -0
  21. package/assets/logo/png/icon-64.png +0 -0
  22. package/assets/logo/png/mark-512.png +0 -0
  23. package/assets/logo/preview.png +0 -0
  24. package/assets/logo/whatsbibz.ico +0 -0
  25. package/lib/BibzWhats/client.d.ts +95 -0
  26. package/lib/BibzWhats/client.js +501 -0
  27. package/lib/BibzWhats/device-identity.d.ts +60 -0
  28. package/lib/BibzWhats/device-identity.js +234 -0
  29. package/lib/BibzWhats/extract.d.ts +29 -0
  30. package/lib/BibzWhats/extract.js +115 -0
  31. package/lib/BibzWhats/index.d.ts +7 -0
  32. package/lib/BibzWhats/index.js +8 -0
  33. package/lib/BibzWhats/jid.d.ts +22 -0
  34. package/lib/BibzWhats/jid.js +98 -0
  35. package/lib/BibzWhats/pairing.d.ts +35 -0
  36. package/lib/BibzWhats/pairing.js +186 -0
  37. package/lib/BibzWhats/send.d.ts +9 -0
  38. package/lib/BibzWhats/send.js +107 -0
  39. package/lib/BibzWhats/version.d.ts +6 -0
  40. package/lib/BibzWhats/version.js +7 -0
  41. package/lib/Defaults/index.d.ts +73 -0
  42. package/lib/Defaults/index.js +141 -0
  43. package/lib/Modded/message_builder.d.ts +15 -0
  44. package/lib/Modded/message_builder.js +2330 -0
  45. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  46. package/lib/Signal/Group/ciphertext-message.js +11 -0
  47. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  48. package/lib/Signal/Group/group-session-builder.js +29 -0
  49. package/lib/Signal/Group/group_cipher.d.ts +16 -0
  50. package/lib/Signal/Group/group_cipher.js +81 -0
  51. package/lib/Signal/Group/index.d.ts +11 -0
  52. package/lib/Signal/Group/index.js +11 -0
  53. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  54. package/lib/Signal/Group/keyhelper.js +17 -0
  55. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  56. package/lib/Signal/Group/sender-chain-key.js +25 -0
  57. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  58. package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
  59. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  60. package/lib/Signal/Group/sender-key-message.js +65 -0
  61. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  62. package/lib/Signal/Group/sender-key-name.js +47 -0
  63. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  64. package/lib/Signal/Group/sender-key-record.js +40 -0
  65. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  66. package/lib/Signal/Group/sender-key-state.js +83 -0
  67. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  68. package/lib/Signal/Group/sender-message-key.js +25 -0
  69. package/lib/Signal/libsignal.d.ts +4 -0
  70. package/lib/Signal/libsignal.js +406 -0
  71. package/lib/Signal/lid-mapping.d.ts +18 -0
  72. package/lib/Signal/lid-mapping.js +276 -0
  73. package/lib/Socket/Client/index.d.ts +2 -0
  74. package/lib/Socket/Client/index.js +2 -0
  75. package/lib/Socket/Client/types.d.ts +15 -0
  76. package/lib/Socket/Client/types.js +10 -0
  77. package/lib/Socket/Client/websocket.d.ts +12 -0
  78. package/lib/Socket/Client/websocket.js +53 -0
  79. package/lib/Socket/business.d.ts +537 -0
  80. package/lib/Socket/business.js +421 -0
  81. package/lib/Socket/chats.d.ts +110 -0
  82. package/lib/Socket/chats.js +1006 -0
  83. package/lib/Socket/communities.d.ts +646 -0
  84. package/lib/Socket/communities.js +430 -0
  85. package/lib/Socket/engine.d.ts +129 -0
  86. package/lib/Socket/engine.js +767 -0
  87. package/lib/Socket/groups.d.ts +149 -0
  88. package/lib/Socket/groups.js +326 -0
  89. package/lib/Socket/index.d.ts +637 -0
  90. package/lib/Socket/index.js +14 -0
  91. package/lib/Socket/messages-recv.d.ts +239 -0
  92. package/lib/Socket/messages-recv.js +1307 -0
  93. package/lib/Socket/messages-send.d.ts +580 -0
  94. package/lib/Socket/messages-send.js +1639 -0
  95. package/lib/Socket/mex.d.ts +2 -0
  96. package/lib/Socket/mex.js +47 -0
  97. package/lib/Socket/newsletter.d.ts +176 -0
  98. package/lib/Socket/newsletter.js +456 -0
  99. package/lib/Socket/socket.d.ts +56 -0
  100. package/lib/Socket/socket.js +998 -0
  101. package/lib/Types/Auth.d.ts +115 -0
  102. package/lib/Types/Auth.js +1 -0
  103. package/lib/Types/Bussines.d.ts +36 -0
  104. package/lib/Types/Bussines.js +1 -0
  105. package/lib/Types/Call.d.ts +14 -0
  106. package/lib/Types/Call.js +1 -0
  107. package/lib/Types/Chat.d.ts +124 -0
  108. package/lib/Types/Chat.js +7 -0
  109. package/lib/Types/Contact.d.ts +23 -0
  110. package/lib/Types/Contact.js +1 -0
  111. package/lib/Types/Events.d.ts +241 -0
  112. package/lib/Types/Events.js +1 -0
  113. package/lib/Types/GroupMetadata.d.ts +67 -0
  114. package/lib/Types/GroupMetadata.js +1 -0
  115. package/lib/Types/Label.d.ts +46 -0
  116. package/lib/Types/Label.js +24 -0
  117. package/lib/Types/LabelAssociation.d.ts +29 -0
  118. package/lib/Types/LabelAssociation.js +6 -0
  119. package/lib/Types/Message.d.ts +427 -0
  120. package/lib/Types/Message.js +10 -0
  121. package/lib/Types/Newsletter.d.ts +134 -0
  122. package/lib/Types/Newsletter.js +30 -0
  123. package/lib/Types/Product.d.ts +78 -0
  124. package/lib/Types/Product.js +1 -0
  125. package/lib/Types/Signal.d.ts +77 -0
  126. package/lib/Types/Signal.js +1 -0
  127. package/lib/Types/Socket.d.ts +173 -0
  128. package/lib/Types/Socket.js +2 -0
  129. package/lib/Types/State.d.ts +38 -0
  130. package/lib/Types/State.js +12 -0
  131. package/lib/Types/USync.d.ts +25 -0
  132. package/lib/Types/USync.js +1 -0
  133. package/lib/Types/index.d.ts +75 -0
  134. package/lib/Types/index.js +32 -0
  135. package/lib/Utils/auth-utils.d.ts +18 -0
  136. package/lib/Utils/auth-utils.js +289 -0
  137. package/lib/Utils/browser-utils.d.ts +3 -0
  138. package/lib/Utils/browser-utils.js +47 -0
  139. package/lib/Utils/business.d.ts +22 -0
  140. package/lib/Utils/business.js +230 -0
  141. package/lib/Utils/chat-utils.d.ts +69 -0
  142. package/lib/Utils/chat-utils.js +811 -0
  143. package/lib/Utils/companion-reg-client-utils.d.ts +20 -0
  144. package/lib/Utils/companion-reg-client-utils.js +66 -0
  145. package/lib/Utils/crypto.d.ts +41 -0
  146. package/lib/Utils/crypto.js +117 -0
  147. package/lib/Utils/decode-wa-message.d.ts +47 -0
  148. package/lib/Utils/decode-wa-message.js +282 -0
  149. package/lib/Utils/event-buffer.d.ts +35 -0
  150. package/lib/Utils/event-buffer.js +590 -0
  151. package/lib/Utils/generics.d.ts +90 -0
  152. package/lib/Utils/generics.js +384 -0
  153. package/lib/Utils/history.d.ts +21 -0
  154. package/lib/Utils/history.js +130 -0
  155. package/lib/Utils/identity-change-handler.d.ts +36 -0
  156. package/lib/Utils/identity-change-handler.js +48 -0
  157. package/lib/Utils/index.d.ts +25 -0
  158. package/lib/Utils/index.js +24 -0
  159. package/lib/Utils/link-preview.d.ts +20 -0
  160. package/lib/Utils/link-preview.js +84 -0
  161. package/lib/Utils/logger.d.ts +12 -0
  162. package/lib/Utils/logger.js +2 -0
  163. package/lib/Utils/lt-hash.d.ts +10 -0
  164. package/lib/Utils/lt-hash.js +7 -0
  165. package/lib/Utils/make-mutex.d.ts +8 -0
  166. package/lib/Utils/make-mutex.js +32 -0
  167. package/lib/Utils/message-retry-manager.d.ts +109 -0
  168. package/lib/Utils/message-retry-manager.js +224 -0
  169. package/lib/Utils/messages-media.d.ts +129 -0
  170. package/lib/Utils/messages-media.js +784 -0
  171. package/lib/Utils/messages.d.ts +90 -0
  172. package/lib/Utils/messages.js +1240 -0
  173. package/lib/Utils/noise-handler.d.ts +19 -0
  174. package/lib/Utils/noise-handler.js +200 -0
  175. package/lib/Utils/offline-node-processor.d.ts +16 -0
  176. package/lib/Utils/offline-node-processor.js +39 -0
  177. package/lib/Utils/platform-identity.d.ts +14 -0
  178. package/lib/Utils/platform-identity.js +148 -0
  179. package/lib/Utils/pre-key-manager.d.ts +27 -0
  180. package/lib/Utils/pre-key-manager.js +105 -0
  181. package/lib/Utils/process-message.d.ts +59 -0
  182. package/lib/Utils/process-message.js +544 -0
  183. package/lib/Utils/reporting-utils.d.ts +10 -0
  184. package/lib/Utils/reporting-utils.js +257 -0
  185. package/lib/Utils/rich-messages.d.ts +276 -0
  186. package/lib/Utils/rich-messages.js +1143 -0
  187. package/lib/Utils/signal.d.ts +33 -0
  188. package/lib/Utils/signal.js +158 -0
  189. package/lib/Utils/stanza-ack.d.ts +10 -0
  190. package/lib/Utils/stanza-ack.js +37 -0
  191. package/lib/Utils/sticker-pack.d.ts +10 -0
  192. package/lib/Utils/sticker-pack.js +111 -0
  193. package/lib/Utils/sync-action-utils.d.ts +18 -0
  194. package/lib/Utils/sync-action-utils.js +47 -0
  195. package/lib/Utils/tc-token-utils.d.ts +8 -0
  196. package/lib/Utils/tc-token-utils.js +45 -0
  197. package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
  198. package/lib/Utils/use-multi-file-auth-state.js +120 -0
  199. package/lib/Utils/validate-connection.d.ts +10 -0
  200. package/lib/Utils/validate-connection.js +222 -0
  201. package/lib/VoIP/audio-feeder.d.ts +15 -0
  202. package/lib/VoIP/audio-feeder.js +136 -0
  203. package/lib/VoIP/index.d.ts +12 -0
  204. package/lib/VoIP/index.js +282 -0
  205. package/lib/VoIP/relay-transport.d.ts +43 -0
  206. package/lib/VoIP/relay-transport.js +559 -0
  207. package/lib/VoIP/signaling.js +603 -0
  208. package/lib/VoIP/types.d.ts +69 -0
  209. package/lib/VoIP/types.js +17 -0
  210. package/lib/VoIP/wasm-engine.d.ts +103 -0
  211. package/lib/VoIP/wasm-engine.js +1214 -0
  212. package/lib/VoIP/worker-bootstrap.js +1042 -0
  213. package/lib/WABinary/constants.d.ts +27 -0
  214. package/lib/WABinary/constants.js +1300 -0
  215. package/lib/WABinary/decode.d.ts +6 -0
  216. package/lib/WABinary/decode.js +261 -0
  217. package/lib/WABinary/encode.d.ts +2 -0
  218. package/lib/WABinary/encode.js +219 -0
  219. package/lib/WABinary/generic-utils.d.ts +16 -0
  220. package/lib/WABinary/generic-utils.js +190 -0
  221. package/lib/WABinary/index.d.ts +5 -0
  222. package/lib/WABinary/index.js +5 -0
  223. package/lib/WABinary/jid-utils.d.ts +47 -0
  224. package/lib/WABinary/jid-utils.js +95 -0
  225. package/lib/WABinary/types.d.ts +18 -0
  226. package/lib/WABinary/types.js +1 -0
  227. package/lib/WAM/BinaryInfo.d.ts +8 -0
  228. package/lib/WAM/BinaryInfo.js +9 -0
  229. package/lib/WAM/constants.d.ts +39 -0
  230. package/lib/WAM/constants.js +22852 -0
  231. package/lib/WAM/encode.d.ts +2 -0
  232. package/lib/WAM/encode.js +149 -0
  233. package/lib/WAM/index.d.ts +3 -0
  234. package/lib/WAM/index.js +3 -0
  235. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  236. package/lib/WAUSync/Protocols/USyncContactProtocol.js +28 -0
  237. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  238. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
  239. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  240. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
  241. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  242. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
  243. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  244. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
  245. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +9 -0
  246. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
  247. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  248. package/lib/WAUSync/Protocols/index.js +4 -0
  249. package/lib/WAUSync/USyncQuery.d.ts +28 -0
  250. package/lib/WAUSync/USyncQuery.js +93 -0
  251. package/lib/WAUSync/USyncUser.d.ts +12 -0
  252. package/lib/WAUSync/USyncUser.js +22 -0
  253. package/lib/WAUSync/index.d.ts +3 -0
  254. package/lib/WAUSync/index.js +3 -0
  255. package/lib/assets/wasm/loader.js +5 -0
  256. package/lib/assets/wasm/whatsapp.wasm +0 -0
  257. package/lib/assets/wasm/worker-modules.js +273 -0
  258. package/lib/index.d.ts +21 -0
  259. package/lib/index.js +22 -0
  260. package/package.json +111 -0
@@ -0,0 +1,421 @@
1
+ import { getRawMediaUploadData } from "../Utils/index.js";
2
+ import {
3
+ parseCatalogNode,
4
+ parseCollectionsNode,
5
+ parseOrderDetailsNode,
6
+ parseProductNode,
7
+ toProductNode,
8
+ uploadingNecessaryImagesOfProduct,
9
+ } from "../Utils/business.js";
10
+ import { jidNormalizedUser, S_WHATSAPP_NET } from "../WABinary/index.js";
11
+ import { getBinaryNodeChild } from "../WABinary/generic-utils.js";
12
+ import { makeMessagesRecvSocket } from "./messages-recv.js";
13
+
14
+ export const makeBusinessSocket = (config) => {
15
+ const sock = makeMessagesRecvSocket(config);
16
+ const { authState, query, waUploadToServer } = sock;
17
+
18
+ const updateBussinesProfile = async (args) => {
19
+ const node = [];
20
+ const simpleFields = ["address", "email", "description"];
21
+ node.push(
22
+ ...simpleFields
23
+ .filter((key) => args[key] !== undefined && args[key] !== null)
24
+ .map((key) => ({
25
+ tag: key,
26
+ attrs: {},
27
+ content: args[key],
28
+ })),
29
+ );
30
+ if (args.websites !== undefined) {
31
+ node.push(
32
+ ...args.websites.map((website) => ({
33
+ tag: "website",
34
+ attrs: {},
35
+ content: website,
36
+ })),
37
+ );
38
+ }
39
+ if (args.hours !== undefined) {
40
+ node.push({
41
+ tag: "business_hours",
42
+ attrs: { timezone: args.hours.timezone },
43
+ content: args.hours.days.map((dayConfig) => {
44
+ const base = {
45
+ tag: "business_hours_config",
46
+ attrs: {
47
+ day_of_week: dayConfig.day,
48
+ mode: dayConfig.mode,
49
+ },
50
+ };
51
+ if (dayConfig.mode === "specific_hours") {
52
+ return {
53
+ ...base,
54
+ attrs: {
55
+ ...base.attrs,
56
+ open_time: dayConfig.openTimeInMinutes,
57
+ close_time: dayConfig.closeTimeInMinutes,
58
+ },
59
+ };
60
+ }
61
+ return base;
62
+ }),
63
+ });
64
+ }
65
+ const result = await query({
66
+ tag: "iq",
67
+ attrs: {
68
+ to: S_WHATSAPP_NET,
69
+ type: "set",
70
+ xmlns: "w:biz",
71
+ },
72
+ content: [
73
+ {
74
+ tag: "business_profile",
75
+ attrs: {
76
+ v: "3",
77
+ mutation_type: "delta",
78
+ },
79
+ content: node,
80
+ },
81
+ ],
82
+ });
83
+ return result;
84
+ };
85
+
86
+ const updateBusinessProfile = updateBussinesProfile;
87
+
88
+ const updateCoverPhoto = async (photo) => {
89
+ const { fileSha256, filePath } = await getRawMediaUploadData(
90
+ photo,
91
+ "biz-cover-photo",
92
+ );
93
+ const fileSha256B64 = fileSha256.toString("base64");
94
+ const { meta_hmac, fbid, ts } = await waUploadToServer(filePath, {
95
+ fileEncSha256B64: fileSha256B64,
96
+ mediaType: "biz-cover-photo",
97
+ });
98
+ await query({
99
+ tag: "iq",
100
+ attrs: {
101
+ to: S_WHATSAPP_NET,
102
+ type: "set",
103
+ xmlns: "w:biz",
104
+ },
105
+ content: [
106
+ {
107
+ tag: "business_profile",
108
+ attrs: {
109
+ v: "3",
110
+ mutation_type: "delta",
111
+ },
112
+ content: [
113
+ {
114
+ tag: "cover_photo",
115
+ attrs: {
116
+ id: String(fbid),
117
+ op: "update",
118
+ token: meta_hmac,
119
+ ts: String(ts),
120
+ },
121
+ },
122
+ ],
123
+ },
124
+ ],
125
+ });
126
+ return fbid;
127
+ };
128
+
129
+ const removeCoverPhoto = async (id) => {
130
+ return await query({
131
+ tag: "iq",
132
+ attrs: {
133
+ to: S_WHATSAPP_NET,
134
+ type: "set",
135
+ xmlns: "w:biz",
136
+ },
137
+ content: [
138
+ {
139
+ tag: "business_profile",
140
+ attrs: {
141
+ v: "3",
142
+ mutation_type: "delta",
143
+ },
144
+ content: [
145
+ {
146
+ tag: "cover_photo",
147
+ attrs: { op: "delete", id },
148
+ },
149
+ ],
150
+ },
151
+ ],
152
+ });
153
+ };
154
+
155
+ const getCatalog = async ({ jid, limit, cursor }) => {
156
+ jid = jid || authState.creds.me?.id;
157
+ jid = jidNormalizedUser(jid);
158
+ const queryParamNodes = [
159
+ {
160
+ tag: "limit",
161
+ attrs: {},
162
+ content: Buffer.from((limit || 10).toString()),
163
+ },
164
+ {
165
+ tag: "width",
166
+ attrs: {},
167
+ content: Buffer.from("100"),
168
+ },
169
+ {
170
+ tag: "height",
171
+ attrs: {},
172
+ content: Buffer.from("100"),
173
+ },
174
+ ];
175
+ if (cursor) {
176
+ queryParamNodes.push({
177
+ tag: "after",
178
+ attrs: {},
179
+ content: cursor,
180
+ });
181
+ }
182
+ const result = await query({
183
+ tag: "iq",
184
+ attrs: {
185
+ to: S_WHATSAPP_NET,
186
+ type: "get",
187
+ xmlns: "w:biz:catalog",
188
+ },
189
+ content: [
190
+ {
191
+ tag: "product_catalog",
192
+ attrs: {
193
+ jid,
194
+ allow_shop_source: "true",
195
+ },
196
+ content: queryParamNodes,
197
+ },
198
+ ],
199
+ });
200
+ return parseCatalogNode(result);
201
+ };
202
+
203
+ const getCollections = async (jid, limit = 51) => {
204
+ jid = jid || authState.creds.me?.id;
205
+ jid = jidNormalizedUser(jid);
206
+ const result = await query({
207
+ tag: "iq",
208
+ attrs: {
209
+ to: S_WHATSAPP_NET,
210
+ type: "get",
211
+ xmlns: "w:biz:catalog",
212
+ smax_id: "35",
213
+ },
214
+ content: [
215
+ {
216
+ tag: "collections",
217
+ attrs: {
218
+ biz_jid: jid,
219
+ },
220
+ content: [
221
+ {
222
+ tag: "collection_limit",
223
+ attrs: {},
224
+ content: Buffer.from(limit.toString()),
225
+ },
226
+ {
227
+ tag: "item_limit",
228
+ attrs: {},
229
+ content: Buffer.from(limit.toString()),
230
+ },
231
+ {
232
+ tag: "width",
233
+ attrs: {},
234
+ content: Buffer.from("100"),
235
+ },
236
+ {
237
+ tag: "height",
238
+ attrs: {},
239
+ content: Buffer.from("100"),
240
+ },
241
+ ],
242
+ },
243
+ ],
244
+ });
245
+ return parseCollectionsNode(result);
246
+ };
247
+
248
+ const getOrderDetails = async (orderId, tokenBase64) => {
249
+ const result = await query({
250
+ tag: "iq",
251
+ attrs: {
252
+ to: S_WHATSAPP_NET,
253
+ type: "get",
254
+ xmlns: "fb:thrift_iq",
255
+ smax_id: "5",
256
+ },
257
+ content: [
258
+ {
259
+ tag: "order",
260
+ attrs: {
261
+ op: "get",
262
+ id: orderId,
263
+ },
264
+ content: [
265
+ {
266
+ tag: "image_dimensions",
267
+ attrs: {},
268
+ content: [
269
+ {
270
+ tag: "width",
271
+ attrs: {},
272
+ content: Buffer.from("100"),
273
+ },
274
+ {
275
+ tag: "height",
276
+ attrs: {},
277
+ content: Buffer.from("100"),
278
+ },
279
+ ],
280
+ },
281
+ {
282
+ tag: "token",
283
+ attrs: {},
284
+ content: Buffer.from(tokenBase64),
285
+ },
286
+ ],
287
+ },
288
+ ],
289
+ });
290
+ return parseOrderDetailsNode(result);
291
+ };
292
+
293
+ const productUpdate = async (productId, update) => {
294
+ update = await uploadingNecessaryImagesOfProduct(update, waUploadToServer);
295
+ const editNode = toProductNode(productId, update);
296
+ const result = await query({
297
+ tag: "iq",
298
+ attrs: {
299
+ to: S_WHATSAPP_NET,
300
+ type: "set",
301
+ xmlns: "w:biz:catalog",
302
+ },
303
+ content: [
304
+ {
305
+ tag: "product_catalog_edit",
306
+ attrs: { v: "1" },
307
+ content: [
308
+ editNode,
309
+ {
310
+ tag: "width",
311
+ attrs: {},
312
+ content: "100",
313
+ },
314
+ {
315
+ tag: "height",
316
+ attrs: {},
317
+ content: "100",
318
+ },
319
+ ],
320
+ },
321
+ ],
322
+ });
323
+ const productCatalogEditNode = getBinaryNodeChild(
324
+ result,
325
+ "product_catalog_edit",
326
+ );
327
+ const productNode = getBinaryNodeChild(productCatalogEditNode, "product");
328
+ return parseProductNode(productNode);
329
+ };
330
+
331
+ const productCreate = async (create) => {
332
+ // ensure isHidden is defined
333
+ create.isHidden = !!create.isHidden;
334
+ create = await uploadingNecessaryImagesOfProduct(create, waUploadToServer);
335
+ const createNode = toProductNode(undefined, create);
336
+ const result = await query({
337
+ tag: "iq",
338
+ attrs: {
339
+ to: S_WHATSAPP_NET,
340
+ type: "set",
341
+ xmlns: "w:biz:catalog",
342
+ },
343
+ content: [
344
+ {
345
+ tag: "product_catalog_add",
346
+ attrs: { v: "1" },
347
+ content: [
348
+ createNode,
349
+ {
350
+ tag: "width",
351
+ attrs: {},
352
+ content: "100",
353
+ },
354
+ {
355
+ tag: "height",
356
+ attrs: {},
357
+ content: "100",
358
+ },
359
+ ],
360
+ },
361
+ ],
362
+ });
363
+ const productCatalogAddNode = getBinaryNodeChild(
364
+ result,
365
+ "product_catalog_add",
366
+ );
367
+ const productNode = getBinaryNodeChild(productCatalogAddNode, "product");
368
+ return parseProductNode(productNode);
369
+ };
370
+
371
+ const productDelete = async (productIds) => {
372
+ const result = await query({
373
+ tag: "iq",
374
+ attrs: {
375
+ to: S_WHATSAPP_NET,
376
+ type: "set",
377
+ xmlns: "w:biz:catalog",
378
+ },
379
+ content: [
380
+ {
381
+ tag: "product_catalog_delete",
382
+ attrs: { v: "1" },
383
+ content: productIds.map((id) => ({
384
+ tag: "product",
385
+ attrs: {},
386
+ content: [
387
+ {
388
+ tag: "id",
389
+ attrs: {},
390
+ content: Buffer.from(id),
391
+ },
392
+ ],
393
+ })),
394
+ },
395
+ ],
396
+ });
397
+ const productCatalogDelNode = getBinaryNodeChild(
398
+ result,
399
+ "product_catalog_delete",
400
+ );
401
+ return {
402
+ deleted: +(productCatalogDelNode?.attrs.deleted_count || 0),
403
+ };
404
+ };
405
+
406
+ return {
407
+ ...sock,
408
+ logger: config.logger,
409
+ getOrderDetails,
410
+ getCatalog,
411
+ getCollections,
412
+ productCreate,
413
+ productDelete,
414
+ productUpdate,
415
+ updateBusinessProfile,
416
+ updateBussinesProfile,
417
+ updateCoverPhoto,
418
+ removeCoverPhoto,
419
+ };
420
+ };
421
+
@@ -0,0 +1,110 @@
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
+ messageMutex: {
14
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
15
+ };
16
+ receiptMutex: {
17
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
18
+ };
19
+ appStatePatchMutex: {
20
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
21
+ };
22
+ notificationMutex: {
23
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
24
+ };
25
+ fetchPrivacySettings: (force?: boolean) => Promise<{
26
+ [_: string]: string;
27
+ }>;
28
+ upsertMessage: (msg: WAMessage, type: MessageUpsertType) => Promise<void>;
29
+ appPatch: (patchCreate: WAPatchCreate) => Promise<void>;
30
+ sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise<void>;
31
+ presenceSubscribe: (toJid: string) => Promise<void>;
32
+ profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
33
+ fetchBlocklist: () => Promise<(string | undefined)[]>;
34
+ fetchStatus: (...jids: string[]) => Promise<import("../WAUSync/index.js").USyncQueryResultList[] | undefined>;
35
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync/index.js").USyncQueryResultList[] | undefined>;
36
+ updateProfilePicture: (jid: string, content: WAMediaUpload, dimensions?: {
37
+ width: number;
38
+ height: number;
39
+ }) => Promise<void>;
40
+ removeProfilePicture: (jid: string) => Promise<void>;
41
+ updateProfileStatus: (status: string) => Promise<void>;
42
+ updateProfileName: (name: string) => Promise<void>;
43
+ updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
44
+ updateDisableLinkPreviewsPrivacy: (isPreviewsDisabled: boolean) => Promise<void>;
45
+ updateCallPrivacy: (value: WAPrivacyCallValue) => Promise<void>;
46
+ updateMessagesPrivacy: (value: WAPrivacyMessagesValue) => Promise<void>;
47
+ updateLastSeenPrivacy: (value: WAPrivacyValue) => Promise<void>;
48
+ updateOnlinePrivacy: (value: WAPrivacyOnlineValue) => Promise<void>;
49
+ updateProfilePicturePrivacy: (value: WAPrivacyValue) => Promise<void>;
50
+ updateStatusPrivacy: (value: WAPrivacyValue) => Promise<void>;
51
+ updateReadReceiptsPrivacy: (value: WAReadReceiptsValue) => Promise<void>;
52
+ updateGroupsAddPrivacy: (value: WAPrivacyGroupAddValue) => Promise<void>;
53
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>;
54
+ getBusinessProfile: (jid: string) => Promise<WABusinessProfile | void>;
55
+ resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
56
+ chatModify: (mod: ChatModification, jid: string) => Promise<void>;
57
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
58
+ addOrEditContact: (jid: string, contact: proto.SyncActionValue.IContactAction) => Promise<void>;
59
+ removeContact: (jid: string) => Promise<void>;
60
+ addLabel: (jid: string, labels: LabelActionBody) => Promise<void>;
61
+ addChatLabel: (jid: string, labelId: string) => Promise<void>;
62
+ removeChatLabel: (jid: string, labelId: string) => Promise<void>;
63
+ addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
64
+ removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
65
+ star: (jid: string, messages: {
66
+ id: string;
67
+ fromMe?: boolean;
68
+ }[], star: boolean) => Promise<void>;
69
+ addOrEditQuickReply: (quickReply: QuickReplyAction) => Promise<void>;
70
+ removeQuickReply: (timestamp: string) => Promise<void>;
71
+ type: "md";
72
+ ws: import("./Client/websocket.js").WebSocketClient;
73
+ ev: import("../Types/index.js").BaileysEventEmitter & {
74
+ process(handler: (events: Partial<import("../Types/index.js").BaileysEventMap>) => void | Promise<void>): () => void;
75
+ buffer(): void;
76
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
77
+ flush(): boolean;
78
+ isBuffering(): boolean;
79
+ };
80
+ authState: {
81
+ creds: import("../Types/index.js").AuthenticationCreds;
82
+ keys: import("../Types/index.js").SignalKeyStoreWithTransaction;
83
+ };
84
+ signalRepository: import("../Types/index.js").SignalRepositoryWithLIDStore;
85
+ user: import("../Types/index.js").Contact | undefined;
86
+ generateMessageTag: () => string;
87
+ query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
88
+ waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T | undefined>;
89
+ waitForSocketOpen: () => Promise<void>;
90
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
91
+ sendNode: (frame: BinaryNode) => Promise<void>;
92
+ logout: (msg?: string) => Promise<void>;
93
+ end: (error: Error | undefined) => Promise<void>;
94
+ onUnexpectedError: (err: Error | Boom, msg: string) => void;
95
+ uploadPreKeys: (count?: number, retryCount?: number) => Promise<void>;
96
+ uploadPreKeysToServerIfRequired: () => Promise<void>;
97
+ digestKeyBundle: () => Promise<void>;
98
+ rotateSignedPreKey: () => Promise<void>;
99
+ requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
100
+ updateServerTimeOffset: ({ attrs }: BinaryNode) => void;
101
+ sendUnifiedSession: () => Promise<void>;
102
+ wamBuffer: import("../index.js").BinaryInfo;
103
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types/index.js").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
104
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
105
+ executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync/index.js").USyncQueryResult | undefined>;
106
+ onWhatsApp: (...phoneNumber: string[]) => Promise<{
107
+ jid: string;
108
+ exists: boolean;
109
+ }[] | undefined>;
110
+ };