zalo-api-sdk 1.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 (459) hide show
  1. package/.prettierrc +5 -0
  2. package/.tmp-cache/_update-notifier-last-checked +0 -0
  3. package/CODE_OF_CONDUCT.md +157 -0
  4. package/CONTRIBUTING.md +491 -0
  5. package/LICENSE +21 -0
  6. package/README.md +421 -0
  7. package/SECURITY.md +82 -0
  8. package/commit-push.sh +79 -0
  9. package/deploy.sh +172 -0
  10. package/dist/Errors/ZaloApiError.d.ts +4 -0
  11. package/dist/Errors/ZaloApiError.js +7 -0
  12. package/dist/Errors/index.d.ts +1 -0
  13. package/dist/Errors/index.js +1 -0
  14. package/dist/apis/acceptFriendRequest.d.ts +2 -0
  15. package/dist/apis/acceptFriendRequest.js +28 -0
  16. package/dist/apis/addGroupBlockedMember.d.ts +2 -0
  17. package/dist/apis/addGroupBlockedMember.js +28 -0
  18. package/dist/apis/addGroupDeputy.d.ts +2 -0
  19. package/dist/apis/addGroupDeputy.js +30 -0
  20. package/dist/apis/addQuickMessage.d.ts +11 -0
  21. package/dist/apis/addQuickMessage.js +60 -0
  22. package/dist/apis/addReaction.d.ts +18 -0
  23. package/dist/apis/addReaction.js +294 -0
  24. package/dist/apis/addUnreadMark.d.ts +8 -0
  25. package/dist/apis/addUnreadMark.js +52 -0
  26. package/dist/apis/addUserToGroup.d.ts +5 -0
  27. package/dist/apis/addUserToGroup.js +34 -0
  28. package/dist/apis/blockUser.d.ts +2 -0
  29. package/dist/apis/blockUser.js +28 -0
  30. package/dist/apis/blockViewFeed.d.ts +2 -0
  31. package/dist/apis/blockViewFeed.js +30 -0
  32. package/dist/apis/changeAccountAvatar.d.ts +3 -0
  33. package/dist/apis/changeAccountAvatar.js +52 -0
  34. package/dist/apis/changeFriendAlias.d.ts +2 -0
  35. package/dist/apis/changeFriendAlias.js +27 -0
  36. package/dist/apis/changeGroupAvatar.d.ts +3 -0
  37. package/dist/apis/changeGroupAvatar.js +44 -0
  38. package/dist/apis/changeGroupName.d.ts +4 -0
  39. package/dist/apis/changeGroupName.js +32 -0
  40. package/dist/apis/changeGroupOwner.d.ts +4 -0
  41. package/dist/apis/changeGroupOwner.js +30 -0
  42. package/dist/apis/createAutoReply.d.ts +14 -0
  43. package/dist/apis/createAutoReply.js +37 -0
  44. package/dist/apis/createCatalog.d.ts +7 -0
  45. package/dist/apis/createCatalog.js +29 -0
  46. package/dist/apis/createGroup.d.ts +28 -0
  47. package/dist/apis/createGroup.js +43 -0
  48. package/dist/apis/createNoteGroup.d.ts +7 -0
  49. package/dist/apis/createNoteGroup.js +47 -0
  50. package/dist/apis/createPoll.d.ts +57 -0
  51. package/dist/apis/createPoll.js +40 -0
  52. package/dist/apis/createProductCatalog.d.ts +23 -0
  53. package/dist/apis/createProductCatalog.js +50 -0
  54. package/dist/apis/createReminder.d.ts +10 -0
  55. package/dist/apis/createReminder.js +63 -0
  56. package/dist/apis/custom.d.ts +9 -0
  57. package/dist/apis/custom.js +15 -0
  58. package/dist/apis/deleteAutoReply.d.ts +5 -0
  59. package/dist/apis/deleteAutoReply.js +29 -0
  60. package/dist/apis/deleteAvatar.d.ts +9 -0
  61. package/dist/apis/deleteAvatar.js +27 -0
  62. package/dist/apis/deleteCatalog.d.ts +2 -0
  63. package/dist/apis/deleteCatalog.js +28 -0
  64. package/dist/apis/deleteChat.d.ts +19 -0
  65. package/dist/apis/deleteChat.js +50 -0
  66. package/dist/apis/deleteMessage.d.ts +14 -0
  67. package/dist/apis/deleteMessage.js +52 -0
  68. package/dist/apis/deleteProductCatalog.d.ts +10 -0
  69. package/dist/apis/deleteProductCatalog.js +31 -0
  70. package/dist/apis/disableGroupLink.d.ts +2 -0
  71. package/dist/apis/disableGroupLink.js +24 -0
  72. package/dist/apis/disperseGroup.d.ts +2 -0
  73. package/dist/apis/disperseGroup.js +28 -0
  74. package/dist/apis/editNoteGroup.d.ts +32 -0
  75. package/dist/apis/editNoteGroup.js +40 -0
  76. package/dist/apis/editReminder.d.ts +18 -0
  77. package/dist/apis/editReminder.js +61 -0
  78. package/dist/apis/enableGroupLink.d.ts +6 -0
  79. package/dist/apis/enableGroupLink.js +25 -0
  80. package/dist/apis/fetchAccountInfo.d.ts +34 -0
  81. package/dist/apis/fetchAccountInfo.js +10 -0
  82. package/dist/apis/findUser.d.ts +15 -0
  83. package/dist/apis/findUser.js +40 -0
  84. package/dist/apis/forwardMessage.d.ts +26 -0
  85. package/dist/apis/forwardMessage.js +99 -0
  86. package/dist/apis/getAliasList.d.ts +8 -0
  87. package/dist/apis/getAliasList.js +27 -0
  88. package/dist/apis/getAllFriends.d.ts +34 -0
  89. package/dist/apis/getAllFriends.js +32 -0
  90. package/dist/apis/getAllGroups.d.ts +7 -0
  91. package/dist/apis/getAllGroups.js +10 -0
  92. package/dist/apis/getArchivedChatList.d.ts +5 -0
  93. package/dist/apis/getArchivedChatList.js +23 -0
  94. package/dist/apis/getAutoDeleteChat.d.ts +9 -0
  95. package/dist/apis/getAutoDeleteChat.js +21 -0
  96. package/dist/apis/getAutoReplyList.d.ts +6 -0
  97. package/dist/apis/getAutoReplyList.js +24 -0
  98. package/dist/apis/getAvatarList.d.ts +12 -0
  99. package/dist/apis/getAvatarList.js +28 -0
  100. package/dist/apis/getBizAccount.d.ts +19 -0
  101. package/dist/apis/getBizAccount.js +27 -0
  102. package/dist/apis/getCatalogList.d.ts +12 -0
  103. package/dist/apis/getCatalogList.js +32 -0
  104. package/dist/apis/getContext.d.ts +1 -0
  105. package/dist/apis/getContext.js +4 -0
  106. package/dist/apis/getCookie.d.ts +1 -0
  107. package/dist/apis/getCookie.js +9 -0
  108. package/dist/apis/getFriendBoardList.d.ts +5 -0
  109. package/dist/apis/getFriendBoardList.js +26 -0
  110. package/dist/apis/getFriendRequestStatus.d.ts +8 -0
  111. package/dist/apis/getFriendRequestStatus.js +25 -0
  112. package/dist/apis/getGroupBlockedMember.d.ts +17 -0
  113. package/dist/apis/getGroupBlockedMember.js +29 -0
  114. package/dist/apis/getGroupInfo.d.ts +43 -0
  115. package/dist/apis/getGroupInfo.js +32 -0
  116. package/dist/apis/getGroupLinkDetail.d.ts +6 -0
  117. package/dist/apis/getGroupLinkDetail.js +25 -0
  118. package/dist/apis/getGroupLinkInfo.d.ts +31 -0
  119. package/dist/apis/getGroupLinkInfo.js +28 -0
  120. package/dist/apis/getGroupMembersInfo.d.ts +17 -0
  121. package/dist/apis/getGroupMembersInfo.js +24 -0
  122. package/dist/apis/getHiddenConversations.d.ts +11 -0
  123. package/dist/apis/getHiddenConversations.js +23 -0
  124. package/dist/apis/getLabels.d.ts +15 -0
  125. package/dist/apis/getLabels.js +28 -0
  126. package/dist/apis/getListBoard.d.ts +15 -0
  127. package/dist/apis/getListBoard.js +45 -0
  128. package/dist/apis/getListReminder.d.ts +22 -0
  129. package/dist/apis/getListReminder.js +47 -0
  130. package/dist/apis/getMute.d.ts +13 -0
  131. package/dist/apis/getMute.js +22 -0
  132. package/dist/apis/getOwnId.d.ts +1 -0
  133. package/dist/apis/getOwnId.js +4 -0
  134. package/dist/apis/getPendingGroupMembers.d.ts +10 -0
  135. package/dist/apis/getPendingGroupMembers.js +27 -0
  136. package/dist/apis/getPinConversations.d.ts +5 -0
  137. package/dist/apis/getPinConversations.js +22 -0
  138. package/dist/apis/getPollDetail.d.ts +3 -0
  139. package/dist/apis/getPollDetail.js +30 -0
  140. package/dist/apis/getProductCatalogList.d.ts +14 -0
  141. package/dist/apis/getProductCatalogList.js +33 -0
  142. package/dist/apis/getQR.d.ts +4 -0
  143. package/dist/apis/getQR.js +29 -0
  144. package/dist/apis/getQuickMessage.d.ts +7 -0
  145. package/dist/apis/getQuickMessage.js +24 -0
  146. package/dist/apis/getReceivedFriendRequests.d.ts +35 -0
  147. package/dist/apis/getReceivedFriendRequests.js +22 -0
  148. package/dist/apis/getReminder.d.ts +13 -0
  149. package/dist/apis/getReminder.js +25 -0
  150. package/dist/apis/getReminderResponses.d.ts +5 -0
  151. package/dist/apis/getReminderResponses.js +24 -0
  152. package/dist/apis/getSentFriendRequest.d.ts +17 -0
  153. package/dist/apis/getSentFriendRequest.js +24 -0
  154. package/dist/apis/getStickers.d.ts +1 -0
  155. package/dist/apis/getStickers.js +40 -0
  156. package/dist/apis/getStickersDetail.d.ts +24 -0
  157. package/dist/apis/getStickersDetail.js +40 -0
  158. package/dist/apis/getUnreadMark.d.ts +14 -0
  159. package/dist/apis/getUnreadMark.js +30 -0
  160. package/dist/apis/getUserInfo.d.ts +39 -0
  161. package/dist/apis/getUserInfo.js +42 -0
  162. package/dist/apis/inviteUserToGroups.d.ts +10 -0
  163. package/dist/apis/inviteUserToGroups.js +30 -0
  164. package/dist/apis/joinGroupLink.d.ts +2 -0
  165. package/dist/apis/joinGroupLink.js +27 -0
  166. package/dist/apis/keepAlive.d.ts +4 -0
  167. package/dist/apis/keepAlive.js +22 -0
  168. package/dist/apis/lastOnline.d.ts +7 -0
  169. package/dist/apis/lastOnline.js +26 -0
  170. package/dist/apis/leaveGroup.d.ts +4 -0
  171. package/dist/apis/leaveGroup.js +33 -0
  172. package/dist/apis/listen.d.ts +100 -0
  173. package/dist/apis/listen.js +424 -0
  174. package/dist/apis/lockPoll.d.ts +2 -0
  175. package/dist/apis/lockPoll.js +28 -0
  176. package/dist/apis/login.d.ts +3 -0
  177. package/dist/apis/login.js +96 -0
  178. package/dist/apis/loginQR.d.ts +70 -0
  179. package/dist/apis/loginQR.js +359 -0
  180. package/dist/apis/parseLink.d.ts +21 -0
  181. package/dist/apis/parseLink.js +27 -0
  182. package/dist/apis/removeFriend.d.ts +2 -0
  183. package/dist/apis/removeFriend.js +28 -0
  184. package/dist/apis/removeFriendAlias.d.ts +2 -0
  185. package/dist/apis/removeFriendAlias.js +24 -0
  186. package/dist/apis/removeGroupBlockedMember.d.ts +2 -0
  187. package/dist/apis/removeGroupBlockedMember.js +28 -0
  188. package/dist/apis/removeGroupDeputy.d.ts +2 -0
  189. package/dist/apis/removeGroupDeputy.js +30 -0
  190. package/dist/apis/removeQuickMessage.d.ts +5 -0
  191. package/dist/apis/removeQuickMessage.js +27 -0
  192. package/dist/apis/removeReminder.d.ts +3 -0
  193. package/dist/apis/removeReminder.js +40 -0
  194. package/dist/apis/removeUnreadMark.d.ts +8 -0
  195. package/dist/apis/removeUnreadMark.js +50 -0
  196. package/dist/apis/removeUserFromGroup.d.ts +4 -0
  197. package/dist/apis/removeUserFromGroup.js +34 -0
  198. package/dist/apis/resetHiddenConversPin.d.ts +2 -0
  199. package/dist/apis/resetHiddenConversPin.js +20 -0
  200. package/dist/apis/reuseAvatar.d.ts +2 -0
  201. package/dist/apis/reuseAvatar.js +26 -0
  202. package/dist/apis/reviewPendingMemberRequest.d.ts +6 -0
  203. package/dist/apis/reviewPendingMemberRequest.js +31 -0
  204. package/dist/apis/sendBankCard.d.ts +9 -0
  205. package/dist/apis/sendBankCard.js +39 -0
  206. package/dist/apis/sendCard.d.ts +10 -0
  207. package/dist/apis/sendCard.js +59 -0
  208. package/dist/apis/sendDeliveredEvent.d.ts +16 -0
  209. package/dist/apis/sendDeliveredEvent.js +55 -0
  210. package/dist/apis/sendFriendRequest.d.ts +2 -0
  211. package/dist/apis/sendFriendRequest.js +39 -0
  212. package/dist/apis/sendLink.d.ts +10 -0
  213. package/dist/apis/sendLink.js +61 -0
  214. package/dist/apis/sendMessage.d.ts +99 -0
  215. package/dist/apis/sendMessage.js +460 -0
  216. package/dist/apis/sendReport.d.ts +17 -0
  217. package/dist/apis/sendReport.js +53 -0
  218. package/dist/apis/sendSeenEvent.d.ts +16 -0
  219. package/dist/apis/sendSeenEvent.js +63 -0
  220. package/dist/apis/sendSticker.d.ts +6 -0
  221. package/dist/apis/sendSticker.js +56 -0
  222. package/dist/apis/sendTypingEvent.d.ts +5 -0
  223. package/dist/apis/sendTypingEvent.js +33 -0
  224. package/dist/apis/sendVideo.d.ts +35 -0
  225. package/dist/apis/sendVideo.js +118 -0
  226. package/dist/apis/sendVoice.d.ts +12 -0
  227. package/dist/apis/sendVoice.js +73 -0
  228. package/dist/apis/setHiddenConversations.d.ts +3 -0
  229. package/dist/apis/setHiddenConversations.js +37 -0
  230. package/dist/apis/setMute.d.ts +17 -0
  231. package/dist/apis/setMute.js +67 -0
  232. package/dist/apis/setPinnedConversations.d.ts +3 -0
  233. package/dist/apis/setPinnedConversations.js +34 -0
  234. package/dist/apis/unblockUser.d.ts +2 -0
  235. package/dist/apis/unblockUser.js +28 -0
  236. package/dist/apis/undo.d.ts +9 -0
  237. package/dist/apis/undo.js +42 -0
  238. package/dist/apis/undoFriendRequest.d.ts +2 -0
  239. package/dist/apis/undoFriendRequest.js +27 -0
  240. package/dist/apis/updateAutoDeleteChat.d.ts +9 -0
  241. package/dist/apis/updateAutoDeleteChat.js +40 -0
  242. package/dist/apis/updateAutoReply.d.ts +14 -0
  243. package/dist/apis/updateAutoReply.js +37 -0
  244. package/dist/apis/updateCatalog.d.ts +11 -0
  245. package/dist/apis/updateCatalog.js +30 -0
  246. package/dist/apis/updateGroupSettings.d.ts +40 -0
  247. package/dist/apis/updateGroupSettings.js +43 -0
  248. package/dist/apis/updateHiddenConversPin.d.ts +2 -0
  249. package/dist/apis/updateHiddenConversPin.js +30 -0
  250. package/dist/apis/updateLabels.d.ts +24 -0
  251. package/dist/apis/updateLabels.js +34 -0
  252. package/dist/apis/updateLang.d.ts +7 -0
  253. package/dist/apis/updateLang.js +32 -0
  254. package/dist/apis/updateProductCatalog.d.ts +25 -0
  255. package/dist/apis/updateProductCatalog.js +51 -0
  256. package/dist/apis/updateProfile.d.ts +13 -0
  257. package/dist/apis/updateProfile.js +42 -0
  258. package/dist/apis/updateQuickMessage.d.ts +11 -0
  259. package/dist/apis/updateQuickMessage.js +61 -0
  260. package/dist/apis/updateSettings.d.ts +3 -0
  261. package/dist/apis/updateSettings.js +23 -0
  262. package/dist/apis/uploadAttachment.d.ts +50 -0
  263. package/dist/apis/uploadAttachment.js +205 -0
  264. package/dist/apis/uploadProductPhoto.d.ts +14 -0
  265. package/dist/apis/uploadProductPhoto.js +50 -0
  266. package/dist/cjs/Errors/ZaloApiError.cjs +11 -0
  267. package/dist/cjs/apis/acceptFriendRequest.cjs +33 -0
  268. package/dist/cjs/apis/addGroupBlockedMember.cjs +33 -0
  269. package/dist/cjs/apis/addGroupDeputy.cjs +35 -0
  270. package/dist/cjs/apis/addQuickMessage.cjs +65 -0
  271. package/dist/cjs/apis/addReaction.cjs +304 -0
  272. package/dist/cjs/apis/addUnreadMark.cjs +62 -0
  273. package/dist/cjs/apis/addUserToGroup.cjs +39 -0
  274. package/dist/cjs/apis/blockUser.cjs +33 -0
  275. package/dist/cjs/apis/blockViewFeed.cjs +35 -0
  276. package/dist/cjs/apis/changeAccountAvatar.cjs +57 -0
  277. package/dist/cjs/apis/changeFriendAlias.cjs +32 -0
  278. package/dist/cjs/apis/changeGroupAvatar.cjs +49 -0
  279. package/dist/cjs/apis/changeGroupName.cjs +37 -0
  280. package/dist/cjs/apis/changeGroupOwner.cjs +35 -0
  281. package/dist/cjs/apis/createAutoReply.cjs +42 -0
  282. package/dist/cjs/apis/createCatalog.cjs +34 -0
  283. package/dist/cjs/apis/createGroup.cjs +48 -0
  284. package/dist/cjs/apis/createNoteGroup.cjs +52 -0
  285. package/dist/cjs/apis/createPoll.cjs +45 -0
  286. package/dist/cjs/apis/createProductCatalog.cjs +55 -0
  287. package/dist/cjs/apis/createReminder.cjs +73 -0
  288. package/dist/cjs/apis/custom.cjs +19 -0
  289. package/dist/cjs/apis/deleteAutoReply.cjs +34 -0
  290. package/dist/cjs/apis/deleteAvatar.cjs +32 -0
  291. package/dist/cjs/apis/deleteCatalog.cjs +33 -0
  292. package/dist/cjs/apis/deleteChat.cjs +60 -0
  293. package/dist/cjs/apis/deleteMessage.cjs +62 -0
  294. package/dist/cjs/apis/deleteProductCatalog.cjs +36 -0
  295. package/dist/cjs/apis/disableGroupLink.cjs +29 -0
  296. package/dist/cjs/apis/disperseGroup.cjs +33 -0
  297. package/dist/cjs/apis/editNoteGroup.cjs +45 -0
  298. package/dist/cjs/apis/editReminder.cjs +71 -0
  299. package/dist/cjs/apis/enableGroupLink.cjs +30 -0
  300. package/dist/cjs/apis/fetchAccountInfo.cjs +15 -0
  301. package/dist/cjs/apis/findUser.cjs +45 -0
  302. package/dist/cjs/apis/forwardMessage.cjs +109 -0
  303. package/dist/cjs/apis/getAliasList.cjs +32 -0
  304. package/dist/cjs/apis/getAllFriends.cjs +37 -0
  305. package/dist/cjs/apis/getAllGroups.cjs +15 -0
  306. package/dist/cjs/apis/getArchivedChatList.cjs +28 -0
  307. package/dist/cjs/apis/getAutoDeleteChat.cjs +26 -0
  308. package/dist/cjs/apis/getAutoReplyList.cjs +29 -0
  309. package/dist/cjs/apis/getAvatarList.cjs +33 -0
  310. package/dist/cjs/apis/getBizAccount.cjs +32 -0
  311. package/dist/cjs/apis/getCatalogList.cjs +37 -0
  312. package/dist/cjs/apis/getContext.cjs +9 -0
  313. package/dist/cjs/apis/getCookie.cjs +14 -0
  314. package/dist/cjs/apis/getFriendBoardList.cjs +31 -0
  315. package/dist/cjs/apis/getFriendRequestStatus.cjs +30 -0
  316. package/dist/cjs/apis/getGroupBlockedMember.cjs +34 -0
  317. package/dist/cjs/apis/getGroupInfo.cjs +37 -0
  318. package/dist/cjs/apis/getGroupLinkDetail.cjs +30 -0
  319. package/dist/cjs/apis/getGroupLinkInfo.cjs +33 -0
  320. package/dist/cjs/apis/getGroupMembersInfo.cjs +29 -0
  321. package/dist/cjs/apis/getHiddenConversations.cjs +28 -0
  322. package/dist/cjs/apis/getLabels.cjs +33 -0
  323. package/dist/cjs/apis/getListBoard.cjs +55 -0
  324. package/dist/cjs/apis/getListReminder.cjs +57 -0
  325. package/dist/cjs/apis/getMute.cjs +27 -0
  326. package/dist/cjs/apis/getOwnId.cjs +9 -0
  327. package/dist/cjs/apis/getPendingGroupMembers.cjs +32 -0
  328. package/dist/cjs/apis/getPinConversations.cjs +27 -0
  329. package/dist/cjs/apis/getPollDetail.cjs +35 -0
  330. package/dist/cjs/apis/getProductCatalogList.cjs +38 -0
  331. package/dist/cjs/apis/getQR.cjs +34 -0
  332. package/dist/cjs/apis/getQuickMessage.cjs +29 -0
  333. package/dist/cjs/apis/getReceivedFriendRequests.cjs +27 -0
  334. package/dist/cjs/apis/getReminder.cjs +30 -0
  335. package/dist/cjs/apis/getReminderResponses.cjs +29 -0
  336. package/dist/cjs/apis/getSentFriendRequest.cjs +29 -0
  337. package/dist/cjs/apis/getStickers.cjs +45 -0
  338. package/dist/cjs/apis/getStickersDetail.cjs +45 -0
  339. package/dist/cjs/apis/getUnreadMark.cjs +35 -0
  340. package/dist/cjs/apis/getUserInfo.cjs +47 -0
  341. package/dist/cjs/apis/inviteUserToGroups.cjs +35 -0
  342. package/dist/cjs/apis/joinGroupLink.cjs +32 -0
  343. package/dist/cjs/apis/keepAlive.cjs +27 -0
  344. package/dist/cjs/apis/lastOnline.cjs +31 -0
  345. package/dist/cjs/apis/leaveGroup.cjs +38 -0
  346. package/dist/cjs/apis/listen.cjs +435 -0
  347. package/dist/cjs/apis/lockPoll.cjs +33 -0
  348. package/dist/cjs/apis/login.cjs +102 -0
  349. package/dist/cjs/apis/loginQR.cjs +364 -0
  350. package/dist/cjs/apis/parseLink.cjs +32 -0
  351. package/dist/cjs/apis/removeFriend.cjs +33 -0
  352. package/dist/cjs/apis/removeFriendAlias.cjs +29 -0
  353. package/dist/cjs/apis/removeGroupBlockedMember.cjs +33 -0
  354. package/dist/cjs/apis/removeGroupDeputy.cjs +35 -0
  355. package/dist/cjs/apis/removeQuickMessage.cjs +32 -0
  356. package/dist/cjs/apis/removeReminder.cjs +50 -0
  357. package/dist/cjs/apis/removeUnreadMark.cjs +60 -0
  358. package/dist/cjs/apis/removeUserFromGroup.cjs +39 -0
  359. package/dist/cjs/apis/resetHiddenConversPin.cjs +25 -0
  360. package/dist/cjs/apis/reuseAvatar.cjs +31 -0
  361. package/dist/cjs/apis/reviewPendingMemberRequest.cjs +36 -0
  362. package/dist/cjs/apis/sendBankCard.cjs +49 -0
  363. package/dist/cjs/apis/sendCard.cjs +69 -0
  364. package/dist/cjs/apis/sendDeliveredEvent.cjs +65 -0
  365. package/dist/cjs/apis/sendFriendRequest.cjs +44 -0
  366. package/dist/cjs/apis/sendLink.cjs +71 -0
  367. package/dist/cjs/apis/sendMessage.cjs +469 -0
  368. package/dist/cjs/apis/sendReport.cjs +63 -0
  369. package/dist/cjs/apis/sendSeenEvent.cjs +73 -0
  370. package/dist/cjs/apis/sendSticker.cjs +66 -0
  371. package/dist/cjs/apis/sendTypingEvent.cjs +43 -0
  372. package/dist/cjs/apis/sendVideo.cjs +128 -0
  373. package/dist/cjs/apis/sendVoice.cjs +83 -0
  374. package/dist/cjs/apis/setHiddenConversations.cjs +47 -0
  375. package/dist/cjs/apis/setMute.cjs +77 -0
  376. package/dist/cjs/apis/setPinnedConversations.cjs +44 -0
  377. package/dist/cjs/apis/unblockUser.cjs +33 -0
  378. package/dist/cjs/apis/undo.cjs +52 -0
  379. package/dist/cjs/apis/undoFriendRequest.cjs +32 -0
  380. package/dist/cjs/apis/updateAutoDeleteChat.cjs +50 -0
  381. package/dist/cjs/apis/updateAutoReply.cjs +42 -0
  382. package/dist/cjs/apis/updateCatalog.cjs +35 -0
  383. package/dist/cjs/apis/updateGroupSettings.cjs +48 -0
  384. package/dist/cjs/apis/updateHiddenConversPin.cjs +35 -0
  385. package/dist/cjs/apis/updateLabels.cjs +39 -0
  386. package/dist/cjs/apis/updateLang.cjs +37 -0
  387. package/dist/cjs/apis/updateProductCatalog.cjs +56 -0
  388. package/dist/cjs/apis/updateProfile.cjs +47 -0
  389. package/dist/cjs/apis/updateQuickMessage.cjs +66 -0
  390. package/dist/cjs/apis/updateSettings.cjs +28 -0
  391. package/dist/cjs/apis/uploadAttachment.cjs +215 -0
  392. package/dist/cjs/apis/uploadProductPhoto.cjs +55 -0
  393. package/dist/cjs/context.cjs +34 -0
  394. package/dist/cjs/index.cjs +121 -0
  395. package/dist/cjs/models/AutoReply.cjs +9 -0
  396. package/dist/cjs/models/DeliveredMessage.cjs +23 -0
  397. package/dist/cjs/models/Enum.cjs +95 -0
  398. package/dist/cjs/models/FriendEvent.cjs +87 -0
  399. package/dist/cjs/models/GroupEvent.cjs +88 -0
  400. package/dist/cjs/models/Message.cjs +32 -0
  401. package/dist/cjs/models/Reaction.cjs +74 -0
  402. package/dist/cjs/models/SeenMessage.cjs +23 -0
  403. package/dist/cjs/models/Typing.cjs +23 -0
  404. package/dist/cjs/models/Undo.cjs +16 -0
  405. package/dist/cjs/models/ZBusiness.cjs +46 -0
  406. package/dist/cjs/update.cjs +27 -0
  407. package/dist/cjs/utils.cjs +732 -0
  408. package/dist/cjs/zalo.cjs +360 -0
  409. package/dist/context.d.ts +177 -0
  410. package/dist/context.js +28 -0
  411. package/dist/index.d.ts +130 -0
  412. package/dist/index.js +11 -0
  413. package/dist/models/Attachment.d.ts +9 -0
  414. package/dist/models/Attachment.js +1 -0
  415. package/dist/models/AutoReply.d.ts +20 -0
  416. package/dist/models/AutoReply.js +7 -0
  417. package/dist/models/Board.d.ts +54 -0
  418. package/dist/models/Board.js +1 -0
  419. package/dist/models/Catalog.d.ts +16 -0
  420. package/dist/models/Catalog.js +1 -0
  421. package/dist/models/DeliveredMessage.d.ts +27 -0
  422. package/dist/models/DeliveredMessage.js +17 -0
  423. package/dist/models/Enum.d.ts +87 -0
  424. package/dist/models/Enum.js +93 -0
  425. package/dist/models/FriendEvent.d.ts +107 -0
  426. package/dist/models/FriendEvent.js +83 -0
  427. package/dist/models/GroupEvent.d.ts +197 -0
  428. package/dist/models/GroupEvent.js +84 -0
  429. package/dist/models/Message.d.ts +91 -0
  430. package/dist/models/Message.js +26 -0
  431. package/dist/models/ProductCatalog.d.ts +17 -0
  432. package/dist/models/ProductCatalog.js +1 -0
  433. package/dist/models/QuickMessage.d.ts +25 -0
  434. package/dist/models/QuickMessage.js +1 -0
  435. package/dist/models/Reaction.d.ts +85 -0
  436. package/dist/models/Reaction.js +70 -0
  437. package/dist/models/Reminder.d.ts +35 -0
  438. package/dist/models/Reminder.js +1 -0
  439. package/dist/models/SeenMessage.d.ts +26 -0
  440. package/dist/models/SeenMessage.js +17 -0
  441. package/dist/models/Typing.d.ts +24 -0
  442. package/dist/models/Typing.js +17 -0
  443. package/dist/models/Undo.d.ts +34 -0
  444. package/dist/models/Undo.js +12 -0
  445. package/dist/models/ZBusiness.d.ts +29 -0
  446. package/dist/models/ZBusiness.js +42 -0
  447. package/dist/models/index.d.ts +17 -0
  448. package/dist/models/index.js +17 -0
  449. package/dist/update.d.ts +2 -0
  450. package/dist/update.js +22 -0
  451. package/dist/utils.d.ts +168 -0
  452. package/dist/utils.js +748 -0
  453. package/dist/zalo.d.ts +291 -0
  454. package/dist/zalo.js +354 -0
  455. package/eslint.config.js +21 -0
  456. package/index.d.ts +2 -0
  457. package/package.json +143 -0
  458. package/qr.png +0 -0
  459. package/rollup.config.js +28 -0
@@ -0,0 +1,469 @@
1
+ 'use strict';
2
+
3
+ var FormData = require('form-data');
4
+ var fs = require('node:fs/promises');
5
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
6
+ var Enum = require('../models/Enum.cjs');
7
+ require('../models/FriendEvent.cjs');
8
+ require('../models/GroupEvent.cjs');
9
+ require('../models/Reaction.cjs');
10
+ require('../models/ZBusiness.cjs');
11
+ require('../models/AutoReply.cjs');
12
+ var utils = require('../utils.cjs');
13
+
14
+ const attachmentUrlType = {
15
+ image: "photo_original/send?",
16
+ gif: "gif?",
17
+ video: "asyncfile/msg?",
18
+ others: "asyncfile/msg?",
19
+ };
20
+ function prepareQMSGAttach(quote) {
21
+ const quoteData = quote;
22
+ if (typeof quoteData.content == "string")
23
+ return quoteData.propertyExt;
24
+ if (quoteData.msgType == "chat.todo")
25
+ return {
26
+ properties: {
27
+ color: 0,
28
+ size: 0,
29
+ type: 0,
30
+ subType: 0,
31
+ ext: '{"shouldParseLinkOrContact":0}',
32
+ },
33
+ };
34
+ return Object.assign(Object.assign({}, quoteData.content), { thumbUrl: quoteData.content.thumb, oriUrl: quoteData.content.href, normalUrl: quoteData.content.href });
35
+ }
36
+ function prepareQMSG(quote) {
37
+ const quoteData = quote;
38
+ if (quoteData.msgType == "chat.todo" && typeof quoteData.content == "object" && typeof quoteData.content.params == "string") {
39
+ return JSON.parse(quoteData.content.params).item.content;
40
+ }
41
+ return "";
42
+ }
43
+ exports.TextStyle = void 0;
44
+ (function (TextStyle) {
45
+ TextStyle["Bold"] = "b";
46
+ TextStyle["Italic"] = "i";
47
+ TextStyle["Underline"] = "u";
48
+ TextStyle["StrikeThrough"] = "s";
49
+ TextStyle["Red"] = "c_db342e";
50
+ TextStyle["Orange"] = "c_f27806";
51
+ TextStyle["Yellow"] = "c_f7b503";
52
+ TextStyle["Green"] = "c_15a85f";
53
+ TextStyle["Small"] = "f_13";
54
+ TextStyle["Big"] = "f_18";
55
+ TextStyle["UnorderedList"] = "lst_1";
56
+ TextStyle["OrderedList"] = "lst_2";
57
+ TextStyle["Indent"] = "ind_$";
58
+ })(exports.TextStyle || (exports.TextStyle = {}));
59
+ exports.Urgency = void 0;
60
+ (function (Urgency) {
61
+ Urgency[Urgency["Default"] = 0] = "Default";
62
+ Urgency[Urgency["Important"] = 1] = "Important";
63
+ Urgency[Urgency["Urgent"] = 2] = "Urgent";
64
+ })(exports.Urgency || (exports.Urgency = {}));
65
+ const sendMessageFactory = utils.apiFactory()((api, ctx, utils$1) => {
66
+ const serviceURLs = {
67
+ message: {
68
+ [Enum.ThreadType.User]: utils$1.makeURL(`${api.zpwServiceMap.chat[0]}/api/message`, {
69
+ nretry: 0,
70
+ }),
71
+ [Enum.ThreadType.Group]: utils$1.makeURL(`${api.zpwServiceMap.group[0]}/api/group`, {
72
+ nretry: 0,
73
+ }),
74
+ },
75
+ attachment: {
76
+ [Enum.ThreadType.User]: `${api.zpwServiceMap.file[0]}/api/message/`,
77
+ [Enum.ThreadType.Group]: `${api.zpwServiceMap.file[0]}/api/group/`,
78
+ },
79
+ };
80
+ const { sharefile } = ctx.settings.features;
81
+ function isExceedMaxFile(totalFile) {
82
+ return totalFile > sharefile.max_file;
83
+ }
84
+ function isExceedMaxFileSize(fileSize) {
85
+ return fileSize > sharefile.max_size_share_file_v3 * 1024 * 1024;
86
+ }
87
+ function getGroupLayoutId() {
88
+ return Date.now();
89
+ }
90
+ async function send(data) {
91
+ if (!Array.isArray(data))
92
+ data = [data];
93
+ const requests = [];
94
+ for (const each of data) {
95
+ requests.push((async () => {
96
+ const response = await utils$1.request(each.url, {
97
+ method: "POST",
98
+ body: each.body,
99
+ headers: each.headers,
100
+ });
101
+ return await utils.resolveResponse(ctx, response);
102
+ })());
103
+ }
104
+ return await Promise.all(requests);
105
+ }
106
+ async function upthumb(source, url) {
107
+ const formData = new FormData();
108
+ const buffer = typeof source == "string" ? await fs.readFile(source) : source.data;
109
+ formData.append("fileContent", buffer, {
110
+ filename: "blob",
111
+ contentType: "image/png",
112
+ });
113
+ const params = {
114
+ clientId: Date.now(),
115
+ imei: ctx.imei,
116
+ };
117
+ const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
118
+ if (!encryptedParams)
119
+ throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
120
+ const response = await utils$1.request(utils$1.makeURL(url + "upthumb?", {
121
+ params: encryptedParams,
122
+ }), {
123
+ method: "POST",
124
+ headers: formData.getHeaders(),
125
+ body: formData.getBuffer(),
126
+ });
127
+ return await utils.resolveResponse(ctx, response);
128
+ }
129
+ function handleMentions(type, msg, mentions) {
130
+ let totalMentionLen = 0;
131
+ const mentionsFinal = Array.isArray(mentions) && type == Enum.ThreadType.Group
132
+ ? mentions
133
+ .filter((m) => m.pos >= 0 && m.uid && m.len > 0)
134
+ .map((m) => {
135
+ totalMentionLen += m.len;
136
+ return {
137
+ pos: m.pos,
138
+ uid: m.uid,
139
+ len: m.len,
140
+ type: m.uid == "-1" ? 1 : 0,
141
+ };
142
+ })
143
+ : [];
144
+ if (totalMentionLen > (msg === null || msg === void 0 ? void 0 : msg.length)) {
145
+ throw new ZaloApiError.ZaloApiError("Invalid mentions: total mention characters exceed message length");
146
+ }
147
+ return {
148
+ mentionsFinal,
149
+ msgFinal: msg,
150
+ };
151
+ }
152
+ function handleStyles(params, styles) {
153
+ if (styles)
154
+ Object.assign(params, {
155
+ textProperties: JSON.stringify({
156
+ styles: styles.map((e) => {
157
+ var _a;
158
+ const styleFinal = Object.assign(Object.assign({}, e), { indentSize: undefined, st: e.st == exports.TextStyle.Indent
159
+ ? exports.TextStyle.Indent.replace(/\$/g, `${(_a = e.indentSize) !== null && _a !== void 0 ? _a : 1}0`)
160
+ : e.st });
161
+ utils.removeUndefinedKeys(styleFinal);
162
+ return styleFinal;
163
+ }),
164
+ ver: 0,
165
+ }),
166
+ });
167
+ }
168
+ function handleUrgency(params, urgency) {
169
+ if (urgency == exports.Urgency.Important || urgency == exports.Urgency.Urgent) {
170
+ Object.assign(params, { metaData: { urgency } });
171
+ }
172
+ }
173
+ async function handleMessage({ msg, styles, urgency, mentions, quote, ttl }, threadId, type) {
174
+ if (!msg || (msg === null || msg === void 0 ? void 0 : msg.length) == 0)
175
+ throw new ZaloApiError.ZaloApiError("Missing message content");
176
+ const isGroupMessage = type == Enum.ThreadType.Group;
177
+ const { mentionsFinal, msgFinal } = handleMentions(type, msg, mentions);
178
+ msg = msgFinal;
179
+ if (quote) {
180
+ if (typeof quote.content != "string" && quote.msgType == "webchat") {
181
+ throw new ZaloApiError.ZaloApiError("This kind of `webchat` quote type is not available");
182
+ }
183
+ if (quote.msgType == "group.poll") {
184
+ throw new ZaloApiError.ZaloApiError("The `group.poll` quote type is not available");
185
+ }
186
+ }
187
+ const isMentionsValid = mentionsFinal.length > 0 && isGroupMessage;
188
+ const params = quote
189
+ ? {
190
+ toid: isGroupMessage ? undefined : threadId,
191
+ grid: isGroupMessage ? threadId : undefined,
192
+ message: msg,
193
+ clientId: Date.now(),
194
+ mentionInfo: isMentionsValid ? JSON.stringify(mentionsFinal) : undefined,
195
+ qmsgOwner: quote.uidFrom,
196
+ qmsgId: quote.msgId,
197
+ qmsgCliId: quote.cliMsgId,
198
+ qmsgType: utils.getClientMessageType(quote.msgType),
199
+ qmsgTs: quote.ts,
200
+ qmsg: typeof quote.content == "string" ? quote.content : prepareQMSG(quote),
201
+ imei: isGroupMessage ? undefined : ctx.imei,
202
+ visibility: isGroupMessage ? 0 : undefined,
203
+ qmsgAttach: isGroupMessage ? JSON.stringify(prepareQMSGAttach(quote)) : undefined,
204
+ qmsgTTL: quote.ttl,
205
+ ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
206
+ }
207
+ : {
208
+ message: msg,
209
+ clientId: Date.now(),
210
+ mentionInfo: isMentionsValid ? JSON.stringify(mentionsFinal) : undefined,
211
+ imei: isGroupMessage ? undefined : ctx.imei,
212
+ ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
213
+ visibility: isGroupMessage ? 0 : undefined,
214
+ toid: isGroupMessage ? undefined : threadId,
215
+ grid: isGroupMessage ? threadId : undefined,
216
+ };
217
+ handleStyles(params, styles);
218
+ handleUrgency(params, urgency);
219
+ utils.removeUndefinedKeys(params);
220
+ const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
221
+ if (!encryptedParams)
222
+ throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
223
+ const finalServiceUrl = new URL(serviceURLs.message[type]);
224
+ if (quote) {
225
+ finalServiceUrl.pathname = finalServiceUrl.pathname + "/quote";
226
+ }
227
+ else {
228
+ finalServiceUrl.pathname =
229
+ finalServiceUrl.pathname +
230
+ "/" +
231
+ (isGroupMessage ? (params.mentionInfo ? "mention" : "sendmsg") : "sms");
232
+ }
233
+ return {
234
+ url: finalServiceUrl.toString(),
235
+ body: new URLSearchParams({ params: encryptedParams }),
236
+ };
237
+ }
238
+ async function handleAttachment({ msg, attachments, mentions, quote, ttl, urgency }, threadId, type) {
239
+ if (!attachments)
240
+ throw new ZaloApiError.ZaloApiError("Missing attachments");
241
+ if (!Array.isArray(attachments))
242
+ attachments = [attachments];
243
+ if (attachments.length == 0)
244
+ throw new ZaloApiError.ZaloApiError("Missing attachments");
245
+ attachments = await Promise.all(attachments.map(async (att) => {
246
+ if (typeof att === "string" && /^https?:\/\//i.test(att)) {
247
+ const downloaded = await utils.downloadAttachmentFromUrl(att);
248
+ if (!downloaded)
249
+ throw new ZaloApiError.ZaloApiError(`Failed to download attachment from URL: ${att}`);
250
+ return downloaded;
251
+ }
252
+ return att;
253
+ }));
254
+ const firstSource = attachments[0];
255
+ const firstExtFile = utils.getExtensionFromSource(firstSource);
256
+ const isSingleFile = attachments.length == 1;
257
+ const isGroupMessage = type == Enum.ThreadType.Group;
258
+ const canBeDesc = isSingleFile && ["jpg", "jpeg", "png", "webp"].includes(firstExtFile);
259
+ const gifFiles = attachments.filter((e) => utils.getExtensionFromSource(e) == "gif");
260
+ attachments = attachments.filter((e) => utils.getExtensionFromSource(e) != "gif");
261
+ const uploadAttachment = attachments.length == 0 ? [] : await api.uploadAttachment(attachments, threadId, type);
262
+ const attachmentsData = [];
263
+ let indexInGroupLayout = uploadAttachment.length - 1;
264
+ const groupLayoutId = getGroupLayoutId();
265
+ const { mentionsFinal, msgFinal } = handleMentions(type, msg, mentions);
266
+ msg = msgFinal;
267
+ const isMentionsValid = mentionsFinal.length > 0 && isGroupMessage && attachments.length == 1;
268
+ const isMultiFile = attachments.length > 1;
269
+ let clientId = Date.now();
270
+ for (const attachment of uploadAttachment) {
271
+ let data;
272
+ switch (attachment.fileType) {
273
+ case "image": {
274
+ data = {
275
+ fileType: attachment.fileType,
276
+ params: {
277
+ photoId: attachment.photoId,
278
+ clientId: (clientId++).toString(),
279
+ desc: msg,
280
+ width: attachment.width,
281
+ height: attachment.height,
282
+ toid: isGroupMessage ? undefined : String(threadId),
283
+ grid: isGroupMessage ? String(threadId) : undefined,
284
+ rawUrl: attachment.normalUrl,
285
+ hdUrl: attachment.hdUrl,
286
+ thumbUrl: attachment.thumbUrl,
287
+ oriUrl: isGroupMessage ? attachment.normalUrl : undefined,
288
+ normalUrl: isGroupMessage ? undefined : attachment.normalUrl,
289
+ hdSize: String(attachment.totalSize),
290
+ zsource: -1,
291
+ ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
292
+ jcp: '{"convertible":"jxl"}',
293
+ groupLayoutId: isMultiFile ? groupLayoutId : undefined,
294
+ isGroupLayout: isMultiFile ? 1 : undefined,
295
+ idInGroup: isMultiFile ? indexInGroupLayout-- : undefined,
296
+ totalItemInGroup: isMultiFile ? uploadAttachment.length : undefined,
297
+ mentionInfo: isMentionsValid && canBeDesc && !quote ? JSON.stringify(mentionsFinal) : undefined,
298
+ },
299
+ body: new URLSearchParams(),
300
+ };
301
+ break;
302
+ }
303
+ case "video": {
304
+ data = {
305
+ fileType: attachment.fileType,
306
+ params: {
307
+ fileId: attachment.fileId,
308
+ checksum: attachment.checksum,
309
+ checksumSha: "",
310
+ extention: utils.getFileExtension(attachment.fileName),
311
+ totalSize: attachment.totalSize,
312
+ fileName: attachment.fileName,
313
+ clientId: attachment.clientFileId,
314
+ fType: 1,
315
+ fileCount: 0,
316
+ fdata: "{}",
317
+ toid: isGroupMessage ? undefined : String(threadId),
318
+ grid: isGroupMessage ? String(threadId) : undefined,
319
+ fileUrl: attachment.fileUrl,
320
+ zsource: -1,
321
+ ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
322
+ },
323
+ body: new URLSearchParams(),
324
+ };
325
+ break;
326
+ }
327
+ case "others": {
328
+ data = {
329
+ fileType: attachment.fileType,
330
+ params: {
331
+ fileId: attachment.fileId,
332
+ checksum: attachment.checksum,
333
+ checksumSha: "",
334
+ extention: utils.getFileExtension(attachment.fileName),
335
+ totalSize: attachment.totalSize,
336
+ fileName: attachment.fileName,
337
+ clientId: attachment.clientFileId,
338
+ fType: 1,
339
+ fileCount: 0,
340
+ fdata: "{}",
341
+ toid: isGroupMessage ? undefined : String(threadId),
342
+ grid: isGroupMessage ? String(threadId) : undefined,
343
+ fileUrl: attachment.fileUrl,
344
+ zsource: -1,
345
+ ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
346
+ },
347
+ body: new URLSearchParams(),
348
+ };
349
+ break;
350
+ }
351
+ }
352
+ handleUrgency(data.params, urgency);
353
+ utils.removeUndefinedKeys(data.params);
354
+ const encryptedParams = utils$1.encodeAES(JSON.stringify(data.params));
355
+ if (!encryptedParams)
356
+ throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
357
+ data.body.append("params", encryptedParams);
358
+ attachmentsData.push(data);
359
+ }
360
+ for (const gif of gifFiles) {
361
+ const isFilePath = typeof gif == "string";
362
+ const gifData = isFilePath ? await utils.getGifMetaData(gif) : Object.assign(Object.assign({}, gif.metadata), { fileName: gif.filename });
363
+ if (isExceedMaxFileSize(gifData.totalSize))
364
+ throw new ZaloApiError.ZaloApiError(`File ${isFilePath ? utils.getFileName(gif) : gif.filename} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
365
+ const _upthumb = await upthumb(gif, serviceURLs.attachment[Enum.ThreadType.User]);
366
+ const formData = new FormData();
367
+ formData.append("chunkContent", isFilePath ? await fs.readFile(gif) : gif.data, {
368
+ filename: isFilePath ? utils.getFileName(gif) : gif.filename,
369
+ contentType: "application/octet-stream",
370
+ });
371
+ const params = {
372
+ clientId: Date.now().toString(),
373
+ fileName: gifData.fileName,
374
+ totalSize: gifData.totalSize,
375
+ width: gifData.width,
376
+ height: gifData.height,
377
+ msg: msg,
378
+ type: 1,
379
+ ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
380
+ visibility: isGroupMessage ? 0 : undefined,
381
+ toid: isGroupMessage ? undefined : threadId,
382
+ grid: isGroupMessage ? threadId : undefined,
383
+ thumb: _upthumb.url,
384
+ checksum: (await utils.getMd5LargeFileObject(gif, gifData.totalSize)).data,
385
+ totalChunk: 1,
386
+ chunkId: 1,
387
+ };
388
+ handleUrgency(params, urgency);
389
+ utils.removeUndefinedKeys(params);
390
+ const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
391
+ if (!encryptedParams)
392
+ throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
393
+ attachmentsData.push({
394
+ query: {
395
+ params: encryptedParams,
396
+ type: "1",
397
+ },
398
+ body: formData.getBuffer(),
399
+ headers: formData.getHeaders(),
400
+ fileType: "gif",
401
+ });
402
+ }
403
+ const responses = [];
404
+ for (const data of attachmentsData) {
405
+ responses.push({
406
+ url: utils$1.makeURL(serviceURLs.attachment[type] + attachmentUrlType[data.fileType], Object.assign({
407
+ nretry: "0",
408
+ }, data.query || {})),
409
+ body: data.body,
410
+ headers: data.fileType == "gif" ? data.headers : {},
411
+ });
412
+ }
413
+ return responses;
414
+ }
415
+ /**
416
+ * Send a message to a thread
417
+ *
418
+ * @param message Message content
419
+ * @param threadId group or user id
420
+ * @param type Message type (User or Group)
421
+ * @param quote Message or GroupMessage instance (optional), used for quoting
422
+ *
423
+ * @throws {ZaloApiError}
424
+ */
425
+ return async function sendMessage(message, threadId, type = Enum.ThreadType.User) {
426
+ if (!message)
427
+ throw new ZaloApiError.ZaloApiError("Missing message content");
428
+ if (!threadId)
429
+ throw new ZaloApiError.ZaloApiError("Missing threadId");
430
+ if (typeof message == "string")
431
+ message = { msg: message };
432
+ let { msg, attachments, mentions } = message;
433
+ const { quote, ttl, styles, urgency } = message;
434
+ if (attachments && !Array.isArray(attachments)) {
435
+ attachments = [attachments];
436
+ }
437
+ if (!msg && (!attachments || (attachments && attachments.length == 0)))
438
+ throw new ZaloApiError.ZaloApiError("Missing message content");
439
+ if (attachments && isExceedMaxFile(attachments.length))
440
+ throw new ZaloApiError.ZaloApiError("Exceed maximum file of " + sharefile.max_file);
441
+ const responses = {
442
+ message: null,
443
+ attachment: [],
444
+ };
445
+ if (attachments && attachments.length > 0) {
446
+ const firstExtFile = utils.getExtensionFromSource(attachments[0]);
447
+ const isSingleFile = attachments.length == 1;
448
+ const canBeDesc = isSingleFile && ["jpg", "jpeg", "png", "webp"].includes(firstExtFile);
449
+ if ((!canBeDesc && (msg === null || msg === void 0 ? void 0 : msg.length) > 0) || ((msg === null || msg === void 0 ? void 0 : msg.length) > 0 && quote)) {
450
+ // send message and attachment separately
451
+ await handleMessage(message, threadId, type).then(async (data) => {
452
+ responses.message = (await send(data))[0];
453
+ });
454
+ msg = "";
455
+ mentions = undefined;
456
+ }
457
+ const handledData = await handleAttachment({ msg, mentions, attachments, quote, ttl, urgency }, threadId, type);
458
+ responses.attachment = await send(handledData);
459
+ msg = "";
460
+ }
461
+ if ((msg === null || msg === void 0 ? void 0 : msg.length) > 0) {
462
+ const handledData = await handleMessage(message, threadId, type);
463
+ responses.message = (await send(handledData))[0];
464
+ }
465
+ return responses;
466
+ };
467
+ });
468
+
469
+ exports.sendMessageFactory = sendMessageFactory;
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var Enum = require('../models/Enum.cjs');
5
+ require('../models/FriendEvent.cjs');
6
+ require('../models/GroupEvent.cjs');
7
+ require('../models/Reaction.cjs');
8
+ require('../models/ZBusiness.cjs');
9
+ require('../models/AutoReply.cjs');
10
+ var utils = require('../utils.cjs');
11
+
12
+ exports.ReportReason = void 0;
13
+ (function (ReportReason) {
14
+ ReportReason[ReportReason["Sensitive"] = 1] = "Sensitive";
15
+ ReportReason[ReportReason["Annoy"] = 2] = "Annoy";
16
+ ReportReason[ReportReason["Fraud"] = 3] = "Fraud";
17
+ ReportReason[ReportReason["Other"] = 0] = "Other";
18
+ })(exports.ReportReason || (exports.ReportReason = {}));
19
+ const sendReportFactory = utils.apiFactory()((api, ctx, utils$1) => {
20
+ const serviceURL = {
21
+ [Enum.ThreadType.User]: utils$1.makeURL(`${api.zpwServiceMap.profile[0]}/api/report/abuse-v2`),
22
+ [Enum.ThreadType.Group]: utils$1.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/reportabuse`),
23
+ };
24
+ /**
25
+ * Send report to Zalo
26
+ *
27
+ * @param options Report options
28
+ * @param threadId The threadID to report
29
+ * @param type Thread type, default direct
30
+ *
31
+ * @throws ZaloApiError
32
+ *
33
+ */
34
+ return async function sendReport(options, threadId, type = Enum.ThreadType.User) {
35
+ const params = type == Enum.ThreadType.User
36
+ ? {
37
+ idTo: threadId,
38
+ objId: "person.profile",
39
+ reason: options.reason.toString(),
40
+ content: options.reason == exports.ReportReason.Other ? options.content : undefined,
41
+ }
42
+ : {
43
+ uidTo: threadId,
44
+ type: 14,
45
+ reason: options.reason,
46
+ content: options.reason == exports.ReportReason.Other ? options.content : "",
47
+ imei: ctx.imei,
48
+ };
49
+ utils.removeUndefinedKeys(params);
50
+ const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
51
+ if (!encryptedParams)
52
+ throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
53
+ const response = await utils$1.request(serviceURL[type], {
54
+ method: "POST",
55
+ body: new URLSearchParams({
56
+ params: encryptedParams,
57
+ }),
58
+ });
59
+ return utils$1.resolve(response);
60
+ };
61
+ });
62
+
63
+ exports.sendReportFactory = sendReportFactory;
@@ -0,0 +1,73 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var context = require('../context.cjs');
5
+ var Enum = require('../models/Enum.cjs');
6
+ require('../models/FriendEvent.cjs');
7
+ require('../models/GroupEvent.cjs');
8
+ require('../models/Reaction.cjs');
9
+ require('../models/ZBusiness.cjs');
10
+ require('../models/AutoReply.cjs');
11
+ var utils = require('../utils.cjs');
12
+
13
+ const sendSeenEventFactory = utils.apiFactory()((api, ctx, utils) => {
14
+ const serviceURL = {
15
+ [Enum.ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.chat[0]}/api/message/seenv2`, {
16
+ nretry: 0,
17
+ }),
18
+ [Enum.ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/seenv2`, {
19
+ nretry: 0,
20
+ }),
21
+ };
22
+ /**
23
+ * Send message seen event
24
+ *
25
+ * @param messages List of messages to send seen event
26
+ * @param type Messages type (User or Group), defaults to User
27
+ *
28
+ * @throws ZaloApiError
29
+ */
30
+ return async function sendSeenEvent(messages, type = Enum.ThreadType.User) {
31
+ if (!messages)
32
+ throw new ZaloApiError.ZaloApiError("messages are missing or not in a valid array format.");
33
+ if (!Array.isArray(messages))
34
+ messages = [messages];
35
+ if (messages.length === 0 || messages.length > context.MAX_MESSAGES_PER_SEND)
36
+ throw new ZaloApiError.ZaloApiError("messages must contain between 1 and 50 messages.");
37
+ const isGroup = type === Enum.ThreadType.Group;
38
+ const threadId = isGroup ? messages[0].idTo : messages[0].uidFrom;
39
+ const msgInfos = {
40
+ data: messages.map((msg) => {
41
+ const curThreadId = isGroup ? msg.idTo : msg.uidFrom;
42
+ if (curThreadId !== threadId) {
43
+ throw new ZaloApiError.ZaloApiError("All messages must belong to the same thread.");
44
+ }
45
+ return {
46
+ cmi: msg.cliMsgId,
47
+ gmi: msg.msgId,
48
+ si: msg.uidFrom,
49
+ di: msg.idTo === ctx.uid ? "0" : msg.idTo,
50
+ mt: msg.msgType,
51
+ st: msg.st || 0 === msg.st ? 0 : -1,
52
+ at: msg.at || 0 === msg.at ? 0 : -1,
53
+ cmd: msg.cmd || 0 === msg.cmd ? 0 : -1,
54
+ ts: parseInt(`${msg.ts}`) || 0 === parseInt(`${msg.ts}`) ? 0 : -1,
55
+ };
56
+ }),
57
+ [isGroup ? "grid" : "senderId"]: threadId,
58
+ };
59
+ const params = Object.assign({ msgInfos: JSON.stringify(msgInfos) }, (isGroup ? { imei: ctx.imei } : {}));
60
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
61
+ if (!encryptedParams)
62
+ throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
63
+ const response = await utils.request(serviceURL[type], {
64
+ method: "POST",
65
+ body: new URLSearchParams({
66
+ params: encryptedParams,
67
+ }),
68
+ });
69
+ return utils.resolve(response);
70
+ };
71
+ });
72
+
73
+ exports.sendSeenEventFactory = sendSeenEventFactory;
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var Enum = require('../models/Enum.cjs');
5
+ require('../models/FriendEvent.cjs');
6
+ require('../models/GroupEvent.cjs');
7
+ require('../models/Reaction.cjs');
8
+ require('../models/ZBusiness.cjs');
9
+ require('../models/AutoReply.cjs');
10
+ var utils = require('../utils.cjs');
11
+
12
+ const sendStickerFactory = utils.apiFactory()((api, ctx, utils$1) => {
13
+ const serviceURL = {
14
+ [Enum.ThreadType.User]: utils$1.makeURL(`${api.zpwServiceMap.chat[0]}/api/message/sticker`, {
15
+ nretry: "0",
16
+ }),
17
+ [Enum.ThreadType.Group]: utils$1.makeURL(`${api.zpwServiceMap.group[0]}/api/group/sticker`, {
18
+ nretry: "0",
19
+ }),
20
+ };
21
+ /**
22
+ * Send a sticker to a thread
23
+ *
24
+ * @param sticker Sticker object
25
+ * @param threadId group or user id
26
+ * @param type Message type (User or GroupMessage)
27
+ *
28
+ * @throws ZaloApiError
29
+ */
30
+ return async function sendSticker(sticker, threadId, type = Enum.ThreadType.User) {
31
+ if (!sticker)
32
+ throw new ZaloApiError.ZaloApiError("Missing sticker");
33
+ if (!threadId)
34
+ throw new ZaloApiError.ZaloApiError("Missing threadId");
35
+ if (!sticker.id)
36
+ throw new ZaloApiError.ZaloApiError("Missing sticker id");
37
+ if (!sticker.cateId)
38
+ throw new ZaloApiError.ZaloApiError("Missing sticker cateId");
39
+ if (!sticker.type)
40
+ throw new ZaloApiError.ZaloApiError("Missing sticker type");
41
+ const isGroupMessage = type === Enum.ThreadType.Group;
42
+ const params = {
43
+ stickerId: sticker.id,
44
+ cateId: sticker.cateId,
45
+ type: sticker.type,
46
+ clientId: Date.now(),
47
+ imei: ctx.imei,
48
+ zsource: 101,
49
+ toid: isGroupMessage ? undefined : threadId,
50
+ grid: isGroupMessage ? threadId : undefined,
51
+ };
52
+ utils.removeUndefinedKeys(params);
53
+ const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
54
+ if (!encryptedParams)
55
+ throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
56
+ const response = await utils$1.request(serviceURL[type], {
57
+ method: "POST",
58
+ body: new URLSearchParams({
59
+ params: encryptedParams,
60
+ }),
61
+ });
62
+ return utils$1.resolve(response);
63
+ };
64
+ });
65
+
66
+ exports.sendStickerFactory = sendStickerFactory;