@ohos-ports/zca-js 2.2.0-beta.1

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 (571) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +225 -0
  3. package/dist/Errors/ZaloApiError.d.ts +4 -0
  4. package/dist/Errors/ZaloApiError.js +7 -0
  5. package/dist/Errors/ZaloApiLoginQRAborted.d.ts +4 -0
  6. package/dist/Errors/ZaloApiLoginQRAborted.js +7 -0
  7. package/dist/Errors/ZaloApiLoginQRDeclined.d.ts +4 -0
  8. package/dist/Errors/ZaloApiLoginQRDeclined.js +7 -0
  9. package/dist/Errors/ZaloApiMissingImageMetadataGetter.d.ts +4 -0
  10. package/dist/Errors/ZaloApiMissingImageMetadataGetter.js +7 -0
  11. package/dist/Errors/index.d.ts +4 -0
  12. package/dist/Errors/index.js +4 -0
  13. package/dist/apis/acceptFriendRequest.d.ts +2 -0
  14. package/dist/apis/acceptFriendRequest.js +28 -0
  15. package/dist/apis/addGroupBlockedMember.d.ts +2 -0
  16. package/dist/apis/addGroupBlockedMember.js +28 -0
  17. package/dist/apis/addGroupDeputy.d.ts +2 -0
  18. package/dist/apis/addGroupDeputy.js +30 -0
  19. package/dist/apis/addPollOptions.d.ts +14 -0
  20. package/dist/apis/addPollOptions.js +26 -0
  21. package/dist/apis/addQuickMessage.d.ts +11 -0
  22. package/dist/apis/addQuickMessage.js +60 -0
  23. package/dist/apis/addReaction.d.ts +18 -0
  24. package/dist/apis/addReaction.js +294 -0
  25. package/dist/apis/addUnreadMark.d.ts +8 -0
  26. package/dist/apis/addUnreadMark.js +52 -0
  27. package/dist/apis/addUserToGroup.d.ts +5 -0
  28. package/dist/apis/addUserToGroup.js +34 -0
  29. package/dist/apis/blockUser.d.ts +2 -0
  30. package/dist/apis/blockUser.js +28 -0
  31. package/dist/apis/blockViewFeed.d.ts +2 -0
  32. package/dist/apis/blockViewFeed.js +30 -0
  33. package/dist/apis/changeAccountAvatar.d.ts +3 -0
  34. package/dist/apis/changeAccountAvatar.js +52 -0
  35. package/dist/apis/changeFriendAlias.d.ts +2 -0
  36. package/dist/apis/changeFriendAlias.js +27 -0
  37. package/dist/apis/changeGroupAvatar.d.ts +3 -0
  38. package/dist/apis/changeGroupAvatar.js +44 -0
  39. package/dist/apis/changeGroupName.d.ts +4 -0
  40. package/dist/apis/changeGroupName.js +32 -0
  41. package/dist/apis/changeGroupOwner.d.ts +4 -0
  42. package/dist/apis/changeGroupOwner.js +30 -0
  43. package/dist/apis/createAutoReply.d.ts +14 -0
  44. package/dist/apis/createAutoReply.js +37 -0
  45. package/dist/apis/createBankAccount.d.ts +8 -0
  46. package/dist/apis/createBankAccount.js +32 -0
  47. package/dist/apis/createCatalog.d.ts +7 -0
  48. package/dist/apis/createCatalog.js +29 -0
  49. package/dist/apis/createGroup.d.ts +28 -0
  50. package/dist/apis/createGroup.js +43 -0
  51. package/dist/apis/createNote.d.ts +7 -0
  52. package/dist/apis/createNote.js +47 -0
  53. package/dist/apis/createPoll.d.ts +36 -0
  54. package/dist/apis/createPoll.js +40 -0
  55. package/dist/apis/createProductCatalog.d.ts +23 -0
  56. package/dist/apis/createProductCatalog.js +50 -0
  57. package/dist/apis/createReminder.d.ts +12 -0
  58. package/dist/apis/createReminder.js +63 -0
  59. package/dist/apis/custom.d.ts +9 -0
  60. package/dist/apis/custom.js +15 -0
  61. package/dist/apis/deleteAutoReply.d.ts +5 -0
  62. package/dist/apis/deleteAutoReply.js +29 -0
  63. package/dist/apis/deleteAvatar.d.ts +9 -0
  64. package/dist/apis/deleteAvatar.js +27 -0
  65. package/dist/apis/deleteBankAccount.d.ts +11 -0
  66. package/dist/apis/deleteBankAccount.js +32 -0
  67. package/dist/apis/deleteCatalog.d.ts +2 -0
  68. package/dist/apis/deleteCatalog.js +28 -0
  69. package/dist/apis/deleteChat.d.ts +19 -0
  70. package/dist/apis/deleteChat.js +50 -0
  71. package/dist/apis/deleteGroupInviteBox.d.ts +9 -0
  72. package/dist/apis/deleteGroupInviteBox.js +27 -0
  73. package/dist/apis/deleteMessage.d.ts +14 -0
  74. package/dist/apis/deleteMessage.js +52 -0
  75. package/dist/apis/deleteProductCatalog.d.ts +10 -0
  76. package/dist/apis/deleteProductCatalog.js +31 -0
  77. package/dist/apis/disableGroupLink.d.ts +2 -0
  78. package/dist/apis/disableGroupLink.js +24 -0
  79. package/dist/apis/disperseGroup.d.ts +2 -0
  80. package/dist/apis/disperseGroup.js +28 -0
  81. package/dist/apis/editNote.d.ts +17 -0
  82. package/dist/apis/editNote.js +46 -0
  83. package/dist/apis/editReminder.d.ts +13 -0
  84. package/dist/apis/editReminder.js +61 -0
  85. package/dist/apis/enableGroupLink.d.ts +6 -0
  86. package/dist/apis/enableGroupLink.js +25 -0
  87. package/dist/apis/fetchAccountInfo.d.ts +5 -0
  88. package/dist/apis/fetchAccountInfo.js +10 -0
  89. package/dist/apis/findUser.d.ts +3 -0
  90. package/dist/apis/findUser.js +42 -0
  91. package/dist/apis/findUserByUsername.d.ts +3 -0
  92. package/dist/apis/findUserByUsername.js +27 -0
  93. package/dist/apis/forwardMessage.d.ts +24 -0
  94. package/dist/apis/forwardMessage.js +99 -0
  95. package/dist/apis/getAliasList.d.ts +8 -0
  96. package/dist/apis/getAliasList.js +27 -0
  97. package/dist/apis/getAllFriends.d.ts +3 -0
  98. package/dist/apis/getAllFriends.js +34 -0
  99. package/dist/apis/getAllGroups.d.ts +7 -0
  100. package/dist/apis/getAllGroups.js +10 -0
  101. package/dist/apis/getArchivedChatList.d.ts +5 -0
  102. package/dist/apis/getArchivedChatList.js +23 -0
  103. package/dist/apis/getAutoDeleteChat.d.ts +9 -0
  104. package/dist/apis/getAutoDeleteChat.js +21 -0
  105. package/dist/apis/getAutoReplyList.d.ts +6 -0
  106. package/dist/apis/getAutoReplyList.js +24 -0
  107. package/dist/apis/getAvatarList.d.ts +12 -0
  108. package/dist/apis/getAvatarList.js +28 -0
  109. package/dist/apis/getAvatarUrlProfile.d.ts +7 -0
  110. package/dist/apis/getAvatarUrlProfile.js +30 -0
  111. package/dist/apis/getBizAccount.d.ts +24 -0
  112. package/dist/apis/getBizAccount.js +27 -0
  113. package/dist/apis/getCatalogList.d.ts +18 -0
  114. package/dist/apis/getCatalogList.js +32 -0
  115. package/dist/apis/getCloseFriends.d.ts +3 -0
  116. package/dist/apis/getCloseFriends.js +20 -0
  117. package/dist/apis/getContext.d.ts +1 -0
  118. package/dist/apis/getContext.js +4 -0
  119. package/dist/apis/getCookie.d.ts +1 -0
  120. package/dist/apis/getCookie.js +9 -0
  121. package/dist/apis/getFriendBoardList.d.ts +5 -0
  122. package/dist/apis/getFriendBoardList.js +26 -0
  123. package/dist/apis/getFriendOnlines.d.ts +10 -0
  124. package/dist/apis/getFriendOnlines.js +35 -0
  125. package/dist/apis/getFriendRecommendations.d.ts +42 -0
  126. package/dist/apis/getFriendRecommendations.js +27 -0
  127. package/dist/apis/getFriendRequestStatus.d.ts +8 -0
  128. package/dist/apis/getFriendRequestStatus.js +25 -0
  129. package/dist/apis/getFullAvatar.d.ts +5 -0
  130. package/dist/apis/getFullAvatar.js +25 -0
  131. package/dist/apis/getGroupBlockedMember.d.ts +23 -0
  132. package/dist/apis/getGroupBlockedMember.js +29 -0
  133. package/dist/apis/getGroupChatHistory.d.ts +8 -0
  134. package/dist/apis/getGroupChatHistory.js +36 -0
  135. package/dist/apis/getGroupInfo.d.ts +16 -0
  136. package/dist/apis/getGroupInfo.js +32 -0
  137. package/dist/apis/getGroupInviteBoxInfo.d.ts +32 -0
  138. package/dist/apis/getGroupInviteBoxInfo.js +38 -0
  139. package/dist/apis/getGroupInviteBoxList.d.ts +38 -0
  140. package/dist/apis/getGroupInviteBoxList.js +31 -0
  141. package/dist/apis/getGroupLinkDetail.d.ts +9 -0
  142. package/dist/apis/getGroupLinkDetail.js +25 -0
  143. package/dist/apis/getGroupLinkInfo.d.ts +34 -0
  144. package/dist/apis/getGroupLinkInfo.js +28 -0
  145. package/dist/apis/getGroupMembersInfo.d.ts +17 -0
  146. package/dist/apis/getGroupMembersInfo.js +24 -0
  147. package/dist/apis/getHiddenConversations.d.ts +11 -0
  148. package/dist/apis/getHiddenConversations.js +23 -0
  149. package/dist/apis/getLabels.d.ts +7 -0
  150. package/dist/apis/getLabels.js +28 -0
  151. package/dist/apis/getListBank.d.ts +5 -0
  152. package/dist/apis/getListBank.js +20 -0
  153. package/dist/apis/getListBankAccount.d.ts +7 -0
  154. package/dist/apis/getListBankAccount.js +27 -0
  155. package/dist/apis/getListBoard.d.ts +21 -0
  156. package/dist/apis/getListBoard.js +45 -0
  157. package/dist/apis/getListDevice.d.ts +10 -0
  158. package/dist/apis/getListDevice.js +22 -0
  159. package/dist/apis/getListReminder.d.ts +28 -0
  160. package/dist/apis/getListReminder.js +47 -0
  161. package/dist/apis/getMultiUsersByPhones.d.ts +5 -0
  162. package/dist/apis/getMultiUsersByPhones.js +39 -0
  163. package/dist/apis/getMute.d.ts +13 -0
  164. package/dist/apis/getMute.js +22 -0
  165. package/dist/apis/getOwnId.d.ts +1 -0
  166. package/dist/apis/getOwnId.js +4 -0
  167. package/dist/apis/getPendingGroupMembers.d.ts +11 -0
  168. package/dist/apis/getPendingGroupMembers.js +27 -0
  169. package/dist/apis/getPinConversations.d.ts +5 -0
  170. package/dist/apis/getPinConversations.js +22 -0
  171. package/dist/apis/getPollDetail.d.ts +3 -0
  172. package/dist/apis/getPollDetail.js +30 -0
  173. package/dist/apis/getProductCatalogList.d.ts +20 -0
  174. package/dist/apis/getProductCatalogList.js +33 -0
  175. package/dist/apis/getQR.d.ts +4 -0
  176. package/dist/apis/getQR.js +29 -0
  177. package/dist/apis/getQuickMessageList.d.ts +7 -0
  178. package/dist/apis/getQuickMessageList.js +24 -0
  179. package/dist/apis/getRelatedFriendGroup.d.ts +6 -0
  180. package/dist/apis/getRelatedFriendGroup.js +30 -0
  181. package/dist/apis/getReminder.d.ts +3 -0
  182. package/dist/apis/getReminder.js +25 -0
  183. package/dist/apis/getReminderResponses.d.ts +5 -0
  184. package/dist/apis/getReminderResponses.js +24 -0
  185. package/dist/apis/getSentFriendRequest.d.ts +18 -0
  186. package/dist/apis/getSentFriendRequest.js +24 -0
  187. package/dist/apis/getSettings.d.ts +3 -0
  188. package/dist/apis/getSettings.js +20 -0
  189. package/dist/apis/getStickerCategoryDetail.d.ts +3 -0
  190. package/dist/apis/getStickerCategoryDetail.js +24 -0
  191. package/dist/apis/getStickers.d.ts +1 -0
  192. package/dist/apis/getStickers.js +40 -0
  193. package/dist/apis/getStickersDetail.d.ts +3 -0
  194. package/dist/apis/getStickersDetail.js +40 -0
  195. package/dist/apis/getUnreadMark.d.ts +14 -0
  196. package/dist/apis/getUnreadMark.js +30 -0
  197. package/dist/apis/getUserInfo.d.ts +8 -0
  198. package/dist/apis/getUserInfo.js +44 -0
  199. package/dist/apis/inviteUserToGroups.d.ts +10 -0
  200. package/dist/apis/inviteUserToGroups.js +30 -0
  201. package/dist/apis/joinGroupInviteBox.d.ts +2 -0
  202. package/dist/apis/joinGroupInviteBox.js +25 -0
  203. package/dist/apis/joinGroupLink.d.ts +2 -0
  204. package/dist/apis/joinGroupLink.js +27 -0
  205. package/dist/apis/keepAlive.d.ts +4 -0
  206. package/dist/apis/keepAlive.js +22 -0
  207. package/dist/apis/lastOnline.d.ts +7 -0
  208. package/dist/apis/lastOnline.js +26 -0
  209. package/dist/apis/leaveGroup.d.ts +4 -0
  210. package/dist/apis/leaveGroup.js +33 -0
  211. package/dist/apis/listen.d.ts +102 -0
  212. package/dist/apis/listen.js +425 -0
  213. package/dist/apis/lockPoll.d.ts +2 -0
  214. package/dist/apis/lockPoll.js +28 -0
  215. package/dist/apis/login.d.ts +3 -0
  216. package/dist/apis/login.js +96 -0
  217. package/dist/apis/loginQR.d.ts +71 -0
  218. package/dist/apis/loginQR.js +365 -0
  219. package/dist/apis/lostFocus.d.ts +4 -0
  220. package/dist/apis/lostFocus.js +23 -0
  221. package/dist/apis/parseLink.d.ts +21 -0
  222. package/dist/apis/parseLink.js +27 -0
  223. package/dist/apis/registerCatalog.d.ts +2 -0
  224. package/dist/apis/registerCatalog.js +27 -0
  225. package/dist/apis/rejectFriendRequest.d.ts +2 -0
  226. package/dist/apis/rejectFriendRequest.js +27 -0
  227. package/dist/apis/removeFriend.d.ts +2 -0
  228. package/dist/apis/removeFriend.js +28 -0
  229. package/dist/apis/removeFriendAlias.d.ts +2 -0
  230. package/dist/apis/removeFriendAlias.js +24 -0
  231. package/dist/apis/removeGroupBlockedMember.d.ts +2 -0
  232. package/dist/apis/removeGroupBlockedMember.js +28 -0
  233. package/dist/apis/removeGroupDeputy.d.ts +2 -0
  234. package/dist/apis/removeGroupDeputy.js +30 -0
  235. package/dist/apis/removeQuickMessage.d.ts +5 -0
  236. package/dist/apis/removeQuickMessage.js +27 -0
  237. package/dist/apis/removeReminder.d.ts +3 -0
  238. package/dist/apis/removeReminder.js +40 -0
  239. package/dist/apis/removeUnreadMark.d.ts +8 -0
  240. package/dist/apis/removeUnreadMark.js +50 -0
  241. package/dist/apis/removeUserFromGroup.d.ts +4 -0
  242. package/dist/apis/removeUserFromGroup.js +34 -0
  243. package/dist/apis/resetHiddenConversPin.d.ts +2 -0
  244. package/dist/apis/resetHiddenConversPin.js +20 -0
  245. package/dist/apis/reuseAvatar.d.ts +2 -0
  246. package/dist/apis/reuseAvatar.js +26 -0
  247. package/dist/apis/reviewPendingMemberRequest.d.ts +14 -0
  248. package/dist/apis/reviewPendingMemberRequest.js +38 -0
  249. package/dist/apis/scanURL.d.ts +4 -0
  250. package/dist/apis/scanURL.js +28 -0
  251. package/dist/apis/searchSticker.d.ts +3 -0
  252. package/dist/apis/searchSticker.js +28 -0
  253. package/dist/apis/sendBankCard.d.ts +9 -0
  254. package/dist/apis/sendBankCard.js +37 -0
  255. package/dist/apis/sendCard.d.ts +10 -0
  256. package/dist/apis/sendCard.js +59 -0
  257. package/dist/apis/sendDeliveredEvent.d.ts +16 -0
  258. package/dist/apis/sendDeliveredEvent.js +55 -0
  259. package/dist/apis/sendFriendRequest.d.ts +2 -0
  260. package/dist/apis/sendFriendRequest.js +39 -0
  261. package/dist/apis/sendLink.d.ts +10 -0
  262. package/dist/apis/sendLink.js +61 -0
  263. package/dist/apis/sendMessage.d.ts +99 -0
  264. package/dist/apis/sendMessage.js +452 -0
  265. package/dist/apis/sendReport.d.ts +17 -0
  266. package/dist/apis/sendReport.js +53 -0
  267. package/dist/apis/sendSeenEvent.d.ts +16 -0
  268. package/dist/apis/sendSeenEvent.js +63 -0
  269. package/dist/apis/sendSticker.d.ts +10 -0
  270. package/dist/apis/sendSticker.js +57 -0
  271. package/dist/apis/sendTypingEvent.d.ts +5 -0
  272. package/dist/apis/sendTypingEvent.js +33 -0
  273. package/dist/apis/sendVideo.d.ts +35 -0
  274. package/dist/apis/sendVideo.js +118 -0
  275. package/dist/apis/sendVoice.d.ts +12 -0
  276. package/dist/apis/sendVoice.js +73 -0
  277. package/dist/apis/setHiddenConversations.d.ts +3 -0
  278. package/dist/apis/setHiddenConversations.js +39 -0
  279. package/dist/apis/setMute.d.ts +20 -0
  280. package/dist/apis/setMute.js +67 -0
  281. package/dist/apis/setPinnedConversations.d.ts +3 -0
  282. package/dist/apis/setPinnedConversations.js +34 -0
  283. package/dist/apis/sharePoll.d.ts +2 -0
  284. package/dist/apis/sharePoll.js +28 -0
  285. package/dist/apis/unblockUser.d.ts +2 -0
  286. package/dist/apis/unblockUser.js +28 -0
  287. package/dist/apis/undo.d.ts +9 -0
  288. package/dist/apis/undo.js +42 -0
  289. package/dist/apis/undoFriendRequest.d.ts +2 -0
  290. package/dist/apis/undoFriendRequest.js +27 -0
  291. package/dist/apis/updateActiveStatus.d.ts +4 -0
  292. package/dist/apis/updateActiveStatus.js +27 -0
  293. package/dist/apis/updateArchivedChatList.d.ts +10 -0
  294. package/dist/apis/updateArchivedChatList.js +34 -0
  295. package/dist/apis/updateAutoDeleteChat.d.ts +9 -0
  296. package/dist/apis/updateAutoDeleteChat.js +40 -0
  297. package/dist/apis/updateAutoReply.d.ts +15 -0
  298. package/dist/apis/updateAutoReply.js +38 -0
  299. package/dist/apis/updateBankAccount.d.ts +9 -0
  300. package/dist/apis/updateBankAccount.js +31 -0
  301. package/dist/apis/updateCatalog.d.ts +11 -0
  302. package/dist/apis/updateCatalog.js +30 -0
  303. package/dist/apis/updateGroupSettings.d.ts +40 -0
  304. package/dist/apis/updateGroupSettings.js +43 -0
  305. package/dist/apis/updateHiddenConversPin.d.ts +2 -0
  306. package/dist/apis/updateHiddenConversPin.js +30 -0
  307. package/dist/apis/updateLabels.d.ts +15 -0
  308. package/dist/apis/updateLabels.js +34 -0
  309. package/dist/apis/updateLang.d.ts +6 -0
  310. package/dist/apis/updateLang.js +30 -0
  311. package/dist/apis/updateProductCatalog.d.ts +25 -0
  312. package/dist/apis/updateProductCatalog.js +51 -0
  313. package/dist/apis/updateProfile.d.ts +20 -0
  314. package/dist/apis/updateProfile.js +43 -0
  315. package/dist/apis/updateProfileBio.d.ts +2 -0
  316. package/dist/apis/updateProfileBio.js +27 -0
  317. package/dist/apis/updateQuickMessage.d.ts +11 -0
  318. package/dist/apis/updateQuickMessage.js +61 -0
  319. package/dist/apis/updateSettings.d.ts +16 -0
  320. package/dist/apis/updateSettings.js +90 -0
  321. package/dist/apis/upgradeGroupToCommunity.d.ts +2 -0
  322. package/dist/apis/upgradeGroupToCommunity.js +27 -0
  323. package/dist/apis/uploadAttachment.d.ts +50 -0
  324. package/dist/apis/uploadAttachment.js +197 -0
  325. package/dist/apis/uploadProductPhoto.d.ts +14 -0
  326. package/dist/apis/uploadProductPhoto.js +50 -0
  327. package/dist/apis/votePoll.d.ts +5 -0
  328. package/dist/apis/votePoll.js +29 -0
  329. package/dist/apis.d.ts +317 -0
  330. package/dist/apis.js +317 -0
  331. package/dist/cjs/Errors/ZaloApiError.cjs +11 -0
  332. package/dist/cjs/Errors/ZaloApiLoginQRAborted.cjs +12 -0
  333. package/dist/cjs/Errors/ZaloApiLoginQRDeclined.cjs +12 -0
  334. package/dist/cjs/Errors/ZaloApiMissingImageMetadataGetter.cjs +12 -0
  335. package/dist/cjs/apis/acceptFriendRequest.cjs +33 -0
  336. package/dist/cjs/apis/addGroupBlockedMember.cjs +33 -0
  337. package/dist/cjs/apis/addGroupDeputy.cjs +35 -0
  338. package/dist/cjs/apis/addPollOptions.cjs +31 -0
  339. package/dist/cjs/apis/addQuickMessage.cjs +65 -0
  340. package/dist/cjs/apis/addReaction.cjs +308 -0
  341. package/dist/cjs/apis/addUnreadMark.cjs +66 -0
  342. package/dist/cjs/apis/addUserToGroup.cjs +39 -0
  343. package/dist/cjs/apis/blockUser.cjs +33 -0
  344. package/dist/cjs/apis/blockViewFeed.cjs +35 -0
  345. package/dist/cjs/apis/changeAccountAvatar.cjs +57 -0
  346. package/dist/cjs/apis/changeFriendAlias.cjs +32 -0
  347. package/dist/cjs/apis/changeGroupAvatar.cjs +49 -0
  348. package/dist/cjs/apis/changeGroupName.cjs +37 -0
  349. package/dist/cjs/apis/changeGroupOwner.cjs +35 -0
  350. package/dist/cjs/apis/createAutoReply.cjs +42 -0
  351. package/dist/cjs/apis/createBankAccount.cjs +37 -0
  352. package/dist/cjs/apis/createCatalog.cjs +34 -0
  353. package/dist/cjs/apis/createGroup.cjs +48 -0
  354. package/dist/cjs/apis/createNote.cjs +52 -0
  355. package/dist/cjs/apis/createPoll.cjs +45 -0
  356. package/dist/cjs/apis/createProductCatalog.cjs +55 -0
  357. package/dist/cjs/apis/createReminder.cjs +77 -0
  358. package/dist/cjs/apis/custom.cjs +19 -0
  359. package/dist/cjs/apis/deleteAutoReply.cjs +34 -0
  360. package/dist/cjs/apis/deleteAvatar.cjs +32 -0
  361. package/dist/cjs/apis/deleteBankAccount.cjs +37 -0
  362. package/dist/cjs/apis/deleteCatalog.cjs +33 -0
  363. package/dist/cjs/apis/deleteChat.cjs +64 -0
  364. package/dist/cjs/apis/deleteGroupInviteBox.cjs +32 -0
  365. package/dist/cjs/apis/deleteMessage.cjs +66 -0
  366. package/dist/cjs/apis/deleteProductCatalog.cjs +36 -0
  367. package/dist/cjs/apis/disableGroupLink.cjs +29 -0
  368. package/dist/cjs/apis/disperseGroup.cjs +33 -0
  369. package/dist/cjs/apis/editNote.cjs +51 -0
  370. package/dist/cjs/apis/editReminder.cjs +75 -0
  371. package/dist/cjs/apis/enableGroupLink.cjs +30 -0
  372. package/dist/cjs/apis/fetchAccountInfo.cjs +15 -0
  373. package/dist/cjs/apis/findUser.cjs +56 -0
  374. package/dist/cjs/apis/findUserByUsername.cjs +41 -0
  375. package/dist/cjs/apis/forwardMessage.cjs +113 -0
  376. package/dist/cjs/apis/getAliasList.cjs +32 -0
  377. package/dist/cjs/apis/getAllFriends.cjs +48 -0
  378. package/dist/cjs/apis/getAllGroups.cjs +15 -0
  379. package/dist/cjs/apis/getArchivedChatList.cjs +28 -0
  380. package/dist/cjs/apis/getAutoDeleteChat.cjs +26 -0
  381. package/dist/cjs/apis/getAutoReplyList.cjs +29 -0
  382. package/dist/cjs/apis/getAvatarList.cjs +33 -0
  383. package/dist/cjs/apis/getAvatarUrlProfile.cjs +44 -0
  384. package/dist/cjs/apis/getBizAccount.cjs +32 -0
  385. package/dist/cjs/apis/getCatalogList.cjs +37 -0
  386. package/dist/cjs/apis/getCloseFriends.cjs +25 -0
  387. package/dist/cjs/apis/getContext.cjs +9 -0
  388. package/dist/cjs/apis/getCookie.cjs +14 -0
  389. package/dist/cjs/apis/getFriendBoardList.cjs +31 -0
  390. package/dist/cjs/apis/getFriendOnlines.cjs +40 -0
  391. package/dist/cjs/apis/getFriendRecommendations.cjs +32 -0
  392. package/dist/cjs/apis/getFriendRequestStatus.cjs +30 -0
  393. package/dist/cjs/apis/getFullAvatar.cjs +30 -0
  394. package/dist/cjs/apis/getGroupBlockedMember.cjs +34 -0
  395. package/dist/cjs/apis/getGroupChatHistory.cjs +51 -0
  396. package/dist/cjs/apis/getGroupInfo.cjs +37 -0
  397. package/dist/cjs/apis/getGroupInviteBoxInfo.cjs +43 -0
  398. package/dist/cjs/apis/getGroupInviteBoxList.cjs +36 -0
  399. package/dist/cjs/apis/getGroupLinkDetail.cjs +30 -0
  400. package/dist/cjs/apis/getGroupLinkInfo.cjs +33 -0
  401. package/dist/cjs/apis/getGroupMembersInfo.cjs +29 -0
  402. package/dist/cjs/apis/getHiddenConversations.cjs +28 -0
  403. package/dist/cjs/apis/getLabels.cjs +33 -0
  404. package/dist/cjs/apis/getListBank.cjs +25 -0
  405. package/dist/cjs/apis/getListBankAccount.cjs +32 -0
  406. package/dist/cjs/apis/getListBoard.cjs +59 -0
  407. package/dist/cjs/apis/getListDevice.cjs +27 -0
  408. package/dist/cjs/apis/getListReminder.cjs +61 -0
  409. package/dist/cjs/apis/getMultiUsersByPhones.cjs +53 -0
  410. package/dist/cjs/apis/getMute.cjs +27 -0
  411. package/dist/cjs/apis/getOwnId.cjs +9 -0
  412. package/dist/cjs/apis/getPendingGroupMembers.cjs +32 -0
  413. package/dist/cjs/apis/getPinConversations.cjs +27 -0
  414. package/dist/cjs/apis/getPollDetail.cjs +35 -0
  415. package/dist/cjs/apis/getProductCatalogList.cjs +38 -0
  416. package/dist/cjs/apis/getQR.cjs +34 -0
  417. package/dist/cjs/apis/getQuickMessageList.cjs +29 -0
  418. package/dist/cjs/apis/getRelatedFriendGroup.cjs +35 -0
  419. package/dist/cjs/apis/getReminder.cjs +30 -0
  420. package/dist/cjs/apis/getReminderResponses.cjs +29 -0
  421. package/dist/cjs/apis/getSentFriendRequest.cjs +29 -0
  422. package/dist/cjs/apis/getSettings.cjs +25 -0
  423. package/dist/cjs/apis/getStickerCategoryDetail.cjs +29 -0
  424. package/dist/cjs/apis/getStickers.cjs +45 -0
  425. package/dist/cjs/apis/getStickersDetail.cjs +45 -0
  426. package/dist/cjs/apis/getUnreadMark.cjs +35 -0
  427. package/dist/cjs/apis/getUserInfo.cjs +58 -0
  428. package/dist/cjs/apis/inviteUserToGroups.cjs +35 -0
  429. package/dist/cjs/apis/joinGroupInviteBox.cjs +30 -0
  430. package/dist/cjs/apis/joinGroupLink.cjs +32 -0
  431. package/dist/cjs/apis/keepAlive.cjs +27 -0
  432. package/dist/cjs/apis/lastOnline.cjs +31 -0
  433. package/dist/cjs/apis/leaveGroup.cjs +38 -0
  434. package/dist/cjs/apis/listen.cjs +440 -0
  435. package/dist/cjs/apis/lockPoll.cjs +33 -0
  436. package/dist/cjs/apis/login.cjs +102 -0
  437. package/dist/cjs/apis/loginQR.cjs +370 -0
  438. package/dist/cjs/apis/lostFocus.cjs +28 -0
  439. package/dist/cjs/apis/parseLink.cjs +32 -0
  440. package/dist/cjs/apis/registerCatalog.cjs +32 -0
  441. package/dist/cjs/apis/rejectFriendRequest.cjs +32 -0
  442. package/dist/cjs/apis/removeFriend.cjs +33 -0
  443. package/dist/cjs/apis/removeFriendAlias.cjs +29 -0
  444. package/dist/cjs/apis/removeGroupBlockedMember.cjs +33 -0
  445. package/dist/cjs/apis/removeGroupDeputy.cjs +35 -0
  446. package/dist/cjs/apis/removeQuickMessage.cjs +32 -0
  447. package/dist/cjs/apis/removeReminder.cjs +54 -0
  448. package/dist/cjs/apis/removeUnreadMark.cjs +64 -0
  449. package/dist/cjs/apis/removeUserFromGroup.cjs +39 -0
  450. package/dist/cjs/apis/resetHiddenConversPin.cjs +25 -0
  451. package/dist/cjs/apis/reuseAvatar.cjs +31 -0
  452. package/dist/cjs/apis/reviewPendingMemberRequest.cjs +43 -0
  453. package/dist/cjs/apis/scanURL.cjs +33 -0
  454. package/dist/cjs/apis/searchSticker.cjs +33 -0
  455. package/dist/cjs/apis/sendBankCard.cjs +51 -0
  456. package/dist/cjs/apis/sendCard.cjs +73 -0
  457. package/dist/cjs/apis/sendDeliveredEvent.cjs +69 -0
  458. package/dist/cjs/apis/sendFriendRequest.cjs +44 -0
  459. package/dist/cjs/apis/sendLink.cjs +75 -0
  460. package/dist/cjs/apis/sendMessage.cjs +466 -0
  461. package/dist/cjs/apis/sendReport.cjs +67 -0
  462. package/dist/cjs/apis/sendSeenEvent.cjs +77 -0
  463. package/dist/cjs/apis/sendSticker.cjs +71 -0
  464. package/dist/cjs/apis/sendTypingEvent.cjs +47 -0
  465. package/dist/cjs/apis/sendVideo.cjs +132 -0
  466. package/dist/cjs/apis/sendVoice.cjs +87 -0
  467. package/dist/cjs/apis/setHiddenConversations.cjs +53 -0
  468. package/dist/cjs/apis/setMute.cjs +81 -0
  469. package/dist/cjs/apis/setPinnedConversations.cjs +48 -0
  470. package/dist/cjs/apis/sharePoll.cjs +33 -0
  471. package/dist/cjs/apis/unblockUser.cjs +33 -0
  472. package/dist/cjs/apis/undo.cjs +56 -0
  473. package/dist/cjs/apis/undoFriendRequest.cjs +32 -0
  474. package/dist/cjs/apis/updateActiveStatus.cjs +32 -0
  475. package/dist/cjs/apis/updateArchivedChatList.cjs +39 -0
  476. package/dist/cjs/apis/updateAutoDeleteChat.cjs +54 -0
  477. package/dist/cjs/apis/updateAutoReply.cjs +43 -0
  478. package/dist/cjs/apis/updateBankAccount.cjs +36 -0
  479. package/dist/cjs/apis/updateCatalog.cjs +35 -0
  480. package/dist/cjs/apis/updateGroupSettings.cjs +48 -0
  481. package/dist/cjs/apis/updateHiddenConversPin.cjs +35 -0
  482. package/dist/cjs/apis/updateLabels.cjs +39 -0
  483. package/dist/cjs/apis/updateLang.cjs +35 -0
  484. package/dist/cjs/apis/updateProductCatalog.cjs +56 -0
  485. package/dist/cjs/apis/updateProfile.cjs +48 -0
  486. package/dist/cjs/apis/updateProfileBio.cjs +32 -0
  487. package/dist/cjs/apis/updateQuickMessage.cjs +66 -0
  488. package/dist/cjs/apis/updateSettings.cjs +95 -0
  489. package/dist/cjs/apis/upgradeGroupToCommunity.cjs +32 -0
  490. package/dist/cjs/apis/uploadAttachment.cjs +211 -0
  491. package/dist/cjs/apis/uploadProductPhoto.cjs +55 -0
  492. package/dist/cjs/apis/votePoll.cjs +34 -0
  493. package/dist/cjs/apis.cjs +322 -0
  494. package/dist/cjs/context.cjs +34 -0
  495. package/dist/cjs/index.cjs +159 -0
  496. package/dist/cjs/models/AutoReply.cjs +9 -0
  497. package/dist/cjs/models/Bank.cjs +263 -0
  498. package/dist/cjs/models/Board.cjs +8 -0
  499. package/dist/cjs/models/DeliveredMessage.cjs +23 -0
  500. package/dist/cjs/models/Enum.cjs +27 -0
  501. package/dist/cjs/models/FriendEvent.cjs +87 -0
  502. package/dist/cjs/models/Group.cjs +13 -0
  503. package/dist/cjs/models/GroupEvent.cjs +94 -0
  504. package/dist/cjs/models/Message.cjs +35 -0
  505. package/dist/cjs/models/Reaction.cjs +74 -0
  506. package/dist/cjs/models/Reminder.cjs +9 -0
  507. package/dist/cjs/models/SeenMessage.cjs +23 -0
  508. package/dist/cjs/models/Typing.cjs +23 -0
  509. package/dist/cjs/models/Undo.cjs +16 -0
  510. package/dist/cjs/models/ZBusiness.cjs +39 -0
  511. package/dist/cjs/update.cjs +34 -0
  512. package/dist/cjs/utils.cjs +703 -0
  513. package/dist/cjs/zalo.cjs +112 -0
  514. package/dist/context.d.ts +179 -0
  515. package/dist/context.js +28 -0
  516. package/dist/index.d.ts +166 -0
  517. package/dist/index.js +14 -0
  518. package/dist/models/Attachment.d.ts +9 -0
  519. package/dist/models/Attachment.js +1 -0
  520. package/dist/models/AutoReply.d.ts +20 -0
  521. package/dist/models/AutoReply.js +7 -0
  522. package/dist/models/Bank.d.ts +291 -0
  523. package/dist/models/Bank.js +262 -0
  524. package/dist/models/Board.d.ts +60 -0
  525. package/dist/models/Board.js +6 -0
  526. package/dist/models/Catalog.d.ts +16 -0
  527. package/dist/models/Catalog.js +1 -0
  528. package/dist/models/DeliveredMessage.d.ts +27 -0
  529. package/dist/models/DeliveredMessage.js +17 -0
  530. package/dist/models/Enum.d.ts +21 -0
  531. package/dist/models/Enum.js +25 -0
  532. package/dist/models/FriendEvent.d.ts +107 -0
  533. package/dist/models/FriendEvent.js +83 -0
  534. package/dist/models/Group.d.ts +125 -0
  535. package/dist/models/Group.js +11 -0
  536. package/dist/models/GroupEvent.d.ts +178 -0
  537. package/dist/models/GroupEvent.js +90 -0
  538. package/dist/models/Label.d.ts +10 -0
  539. package/dist/models/Label.js +1 -0
  540. package/dist/models/Message.d.ts +91 -0
  541. package/dist/models/Message.js +29 -0
  542. package/dist/models/ProductCatalog.d.ts +17 -0
  543. package/dist/models/ProductCatalog.js +1 -0
  544. package/dist/models/QuickMessage.d.ts +25 -0
  545. package/dist/models/QuickMessage.js +1 -0
  546. package/dist/models/Reaction.d.ts +85 -0
  547. package/dist/models/Reaction.js +70 -0
  548. package/dist/models/Reminder.d.ts +51 -0
  549. package/dist/models/Reminder.js +7 -0
  550. package/dist/models/SeenMessage.d.ts +26 -0
  551. package/dist/models/SeenMessage.js +17 -0
  552. package/dist/models/Sticker.d.ts +27 -0
  553. package/dist/models/Sticker.js +1 -0
  554. package/dist/models/Typing.d.ts +24 -0
  555. package/dist/models/Typing.js +17 -0
  556. package/dist/models/Undo.d.ts +34 -0
  557. package/dist/models/Undo.js +12 -0
  558. package/dist/models/User.d.ts +70 -0
  559. package/dist/models/User.js +1 -0
  560. package/dist/models/ZBusiness.d.ts +22 -0
  561. package/dist/models/ZBusiness.js +35 -0
  562. package/dist/models/index.d.ts +22 -0
  563. package/dist/models/index.js +22 -0
  564. package/dist/update.d.ts +2 -0
  565. package/dist/update.js +29 -0
  566. package/dist/utils.d.ts +167 -0
  567. package/dist/utils.js +719 -0
  568. package/dist/zalo.d.ts +41 -0
  569. package/dist/zalo.js +107 -0
  570. package/index.d.ts +2 -0
  571. package/package.json +85 -0
@@ -0,0 +1,61 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { ThreadType } from "../models/index.js";
3
+ import { apiFactory } from "../utils.js";
4
+ export const sendLinkFactory = apiFactory()((api, ctx, utils) => {
5
+ const serviceURL = {
6
+ [ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.chat[0]}/api/message/link`, {
7
+ nretry: 0,
8
+ }),
9
+ [ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/sendlink`, {
10
+ nretry: 0,
11
+ }),
12
+ };
13
+ /**
14
+ * Send link
15
+ *
16
+ * @param options Link and ttl
17
+ * @param threadId Thread ID
18
+ * @param type Thread type
19
+ *
20
+ * @throws {ZaloApiError}
21
+ */
22
+ return async function sendLink(options, threadId, type = ThreadType.User) {
23
+ var _a;
24
+ const res = await api.parseLink(options.link);
25
+ const params = {
26
+ msg: options.msg && options.msg.trim()
27
+ ? options.msg.includes(options.link)
28
+ ? options.msg
29
+ : options.msg + " " + options.link
30
+ : options.link,
31
+ href: res.data.href,
32
+ src: res.data.src,
33
+ title: res.data.title,
34
+ desc: res.data.desc,
35
+ thumb: res.data.thumb,
36
+ type: 2, // 0
37
+ media: JSON.stringify(res.data.media),
38
+ ttl: (_a = options.ttl) !== null && _a !== void 0 ? _a : 0,
39
+ clientId: Date.now(),
40
+ };
41
+ if (type == ThreadType.Group) {
42
+ params.grid = threadId;
43
+ params.imei = ctx.imei;
44
+ // params.mentionInfo = "[]"; @TODO: implement this
45
+ }
46
+ else {
47
+ params.toId = threadId;
48
+ params.mentionInfo = "";
49
+ }
50
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
51
+ if (!encryptedParams)
52
+ throw new ZaloApiError("Failed to encrypt params");
53
+ const response = await utils.request(serviceURL[type], {
54
+ method: "POST",
55
+ body: new URLSearchParams({
56
+ params: encryptedParams,
57
+ }),
58
+ });
59
+ return utils.resolve(response);
60
+ };
61
+ });
@@ -0,0 +1,99 @@
1
+ import { ThreadType, type TMessage, type AttachmentSource } from "../models/index.js";
2
+ export type SendMessageResult = {
3
+ msgId: number;
4
+ };
5
+ export type SendMessageResponse = {
6
+ message: SendMessageResult | null;
7
+ attachment: SendMessageResult[];
8
+ };
9
+ export type SendMessageQuote = {
10
+ content: TMessage["content"];
11
+ msgType: TMessage["msgType"];
12
+ propertyExt: TMessage["propertyExt"];
13
+ uidFrom: TMessage["uidFrom"];
14
+ msgId: TMessage["msgId"];
15
+ cliMsgId: TMessage["cliMsgId"];
16
+ ts: TMessage["ts"];
17
+ ttl: TMessage["ttl"];
18
+ };
19
+ export declare enum TextStyle {
20
+ Bold = "b",
21
+ Italic = "i",
22
+ Underline = "u",
23
+ StrikeThrough = "s",
24
+ Red = "c_db342e",
25
+ Orange = "c_f27806",
26
+ Yellow = "c_f7b503",
27
+ Green = "c_15a85f",
28
+ Small = "f_13",
29
+ Big = "f_18",
30
+ UnorderedList = "lst_1",
31
+ OrderedList = "lst_2",
32
+ Indent = "ind_$"
33
+ }
34
+ export type Style = {
35
+ start: number;
36
+ len: number;
37
+ st: Exclude<TextStyle, TextStyle.Indent>;
38
+ } | {
39
+ start: number;
40
+ len: number;
41
+ st: TextStyle.Indent;
42
+ /**
43
+ * Number of spaces used for indentation.
44
+ */
45
+ indentSize?: number;
46
+ };
47
+ export declare enum Urgency {
48
+ Default = 0,
49
+ Important = 1,
50
+ Urgent = 2
51
+ }
52
+ export type Mention = {
53
+ /**
54
+ * mention position
55
+ */
56
+ pos: number;
57
+ /**
58
+ * id of the mentioned user
59
+ */
60
+ uid: string;
61
+ /**
62
+ * length of the mention
63
+ */
64
+ len: number;
65
+ };
66
+ export type MessageContent = {
67
+ /**
68
+ * Text content of the message
69
+ */
70
+ msg: string;
71
+ /**
72
+ * Text styles
73
+ */
74
+ styles?: Style[];
75
+ /**
76
+ * Urgency of the message
77
+ */
78
+ urgency?: Urgency;
79
+ /**
80
+ * Quoted message (optional)
81
+ */
82
+ quote?: SendMessageQuote;
83
+ /**
84
+ * Mentions in the message (optional)
85
+ */
86
+ mentions?: Mention[];
87
+ /**
88
+ * Attachments in the message (optional)
89
+ */
90
+ attachments?: AttachmentSource | AttachmentSource[];
91
+ /**
92
+ * Time to live in milliseconds
93
+ */
94
+ ttl?: number;
95
+ };
96
+ export declare const sendMessageFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (message: MessageContent | string, threadId: string, type?: ThreadType) => Promise<{
97
+ message: SendMessageResult | null;
98
+ attachment: SendMessageResult[];
99
+ }>;
@@ -0,0 +1,452 @@
1
+ import FormData from "form-data";
2
+ import fs from "node:fs/promises";
3
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
4
+ import { ThreadType } from "../models/index.js";
5
+ import { apiFactory, getClientMessageType, getFileExtension, getFileName, getGifMetaData, getMd5LargeFileObject, removeUndefinedKeys, resolveResponse, } from "../utils.js";
6
+ const attachmentUrlType = {
7
+ image: "photo_original/send?",
8
+ gif: "gif?",
9
+ video: "asyncfile/msg?",
10
+ others: "asyncfile/msg?",
11
+ };
12
+ function prepareQMSGAttach(quote) {
13
+ const quoteData = quote;
14
+ if (typeof quoteData.content == "string")
15
+ return quoteData.propertyExt;
16
+ if (quoteData.msgType == "chat.todo")
17
+ return {
18
+ properties: {
19
+ color: 0,
20
+ size: 0,
21
+ type: 0,
22
+ subType: 0,
23
+ ext: '{"shouldParseLinkOrContact":0}',
24
+ },
25
+ };
26
+ return Object.assign(Object.assign({}, quoteData.content), { thumbUrl: quoteData.content.thumb, oriUrl: quoteData.content.href, normalUrl: quoteData.content.href });
27
+ }
28
+ function prepareQMSG(quote) {
29
+ const quoteData = quote;
30
+ if (quoteData.msgType == "chat.todo" && typeof quoteData.content == "object" && typeof quoteData.content.params == "string") {
31
+ return JSON.parse(quoteData.content.params).item.content;
32
+ }
33
+ return "";
34
+ }
35
+ export var TextStyle;
36
+ (function (TextStyle) {
37
+ TextStyle["Bold"] = "b";
38
+ TextStyle["Italic"] = "i";
39
+ TextStyle["Underline"] = "u";
40
+ TextStyle["StrikeThrough"] = "s";
41
+ TextStyle["Red"] = "c_db342e";
42
+ TextStyle["Orange"] = "c_f27806";
43
+ TextStyle["Yellow"] = "c_f7b503";
44
+ TextStyle["Green"] = "c_15a85f";
45
+ TextStyle["Small"] = "f_13";
46
+ TextStyle["Big"] = "f_18";
47
+ TextStyle["UnorderedList"] = "lst_1";
48
+ TextStyle["OrderedList"] = "lst_2";
49
+ TextStyle["Indent"] = "ind_$";
50
+ })(TextStyle || (TextStyle = {}));
51
+ export var Urgency;
52
+ (function (Urgency) {
53
+ Urgency[Urgency["Default"] = 0] = "Default";
54
+ Urgency[Urgency["Important"] = 1] = "Important";
55
+ Urgency[Urgency["Urgent"] = 2] = "Urgent";
56
+ })(Urgency || (Urgency = {}));
57
+ export const sendMessageFactory = apiFactory()((api, ctx, utils) => {
58
+ const serviceURLs = {
59
+ message: {
60
+ [ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.chat[0]}/api/message`, {
61
+ nretry: 0,
62
+ }),
63
+ [ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group`, {
64
+ nretry: 0,
65
+ }),
66
+ },
67
+ attachment: {
68
+ [ThreadType.User]: `${api.zpwServiceMap.file[0]}/api/message/`,
69
+ [ThreadType.Group]: `${api.zpwServiceMap.file[0]}/api/group/`,
70
+ },
71
+ };
72
+ const { sharefile } = ctx.settings.features;
73
+ function isExceedMaxFile(totalFile) {
74
+ return totalFile > sharefile.max_file;
75
+ }
76
+ function isExceedMaxFileSize(fileSize) {
77
+ return fileSize > sharefile.max_size_share_file_v3 * 1024 * 1024;
78
+ }
79
+ function getGroupLayoutId() {
80
+ return Date.now();
81
+ }
82
+ async function send(data) {
83
+ if (!Array.isArray(data))
84
+ data = [data];
85
+ const requests = [];
86
+ for (const each of data) {
87
+ requests.push((async () => {
88
+ const response = await utils.request(each.url, {
89
+ method: "POST",
90
+ body: each.body,
91
+ headers: each.headers,
92
+ });
93
+ return await resolveResponse(ctx, response);
94
+ })());
95
+ }
96
+ return await Promise.all(requests);
97
+ }
98
+ async function upthumb(source, url) {
99
+ const formData = new FormData();
100
+ const buffer = typeof source == "string" ? await fs.readFile(source) : source.data;
101
+ formData.append("fileContent", buffer, {
102
+ filename: "blob",
103
+ contentType: "image/png",
104
+ });
105
+ const params = {
106
+ clientId: Date.now(),
107
+ imei: ctx.imei,
108
+ };
109
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
110
+ if (!encryptedParams)
111
+ throw new ZaloApiError("Failed to encrypt message");
112
+ const response = await utils.request(utils.makeURL(url + "upthumb?", {
113
+ params: encryptedParams,
114
+ }), {
115
+ method: "POST",
116
+ headers: formData.getHeaders(),
117
+ body: formData.getBuffer(),
118
+ });
119
+ return await resolveResponse(ctx, response);
120
+ }
121
+ function handleMentions(type, msg, mentions) {
122
+ let totalMentionLen = 0;
123
+ const mentionsFinal = Array.isArray(mentions) && type == ThreadType.Group
124
+ ? mentions
125
+ .filter((m) => m.pos >= 0 && m.uid && m.len > 0)
126
+ .map((m) => {
127
+ totalMentionLen += m.len;
128
+ return {
129
+ pos: m.pos,
130
+ uid: m.uid,
131
+ len: m.len,
132
+ type: m.uid == "-1" ? 1 : 0,
133
+ };
134
+ })
135
+ : [];
136
+ if (totalMentionLen > msg.length) {
137
+ throw new ZaloApiError("Invalid mentions: total mention characters exceed message length");
138
+ }
139
+ return {
140
+ mentionsFinal,
141
+ msgFinal: msg,
142
+ };
143
+ }
144
+ function handleStyles(params, styles) {
145
+ if (styles)
146
+ Object.assign(params, {
147
+ textProperties: JSON.stringify({
148
+ styles: styles.map((e) => {
149
+ var _a;
150
+ const styleFinal = Object.assign(Object.assign({}, e), { indentSize: undefined, st: e.st == TextStyle.Indent
151
+ ? TextStyle.Indent.replace(/\$/g, `${(_a = e.indentSize) !== null && _a !== void 0 ? _a : 1}0`)
152
+ : e.st });
153
+ removeUndefinedKeys(styleFinal);
154
+ return styleFinal;
155
+ }),
156
+ ver: 0,
157
+ }),
158
+ });
159
+ }
160
+ function handleUrgency(params, urgency) {
161
+ if (urgency == Urgency.Important || urgency == Urgency.Urgent) {
162
+ Object.assign(params, { metaData: { urgency } });
163
+ }
164
+ }
165
+ async function handleMessage({ msg, styles, urgency, mentions, quote, ttl }, threadId, type) {
166
+ if (!msg || msg.length == 0)
167
+ throw new ZaloApiError("Missing message content");
168
+ const isGroupMessage = type == ThreadType.Group;
169
+ const { mentionsFinal, msgFinal } = handleMentions(type, msg, mentions);
170
+ msg = msgFinal;
171
+ if (quote) {
172
+ if (typeof quote.content != "string" && quote.msgType == "webchat") {
173
+ throw new ZaloApiError("This kind of `webchat` quote type is not available");
174
+ }
175
+ if (quote.msgType == "group.poll") {
176
+ throw new ZaloApiError("The `group.poll` quote type is not available");
177
+ }
178
+ }
179
+ const isMentionsValid = mentionsFinal.length > 0 && isGroupMessage;
180
+ const params = quote
181
+ ? {
182
+ toid: isGroupMessage ? undefined : threadId,
183
+ grid: isGroupMessage ? threadId : undefined,
184
+ message: msg,
185
+ clientId: Date.now(),
186
+ mentionInfo: isMentionsValid ? JSON.stringify(mentionsFinal) : undefined,
187
+ qmsgOwner: quote.uidFrom,
188
+ qmsgId: quote.msgId,
189
+ qmsgCliId: quote.cliMsgId,
190
+ qmsgType: getClientMessageType(quote.msgType),
191
+ qmsgTs: quote.ts,
192
+ qmsg: typeof quote.content == "string" ? quote.content : prepareQMSG(quote),
193
+ imei: isGroupMessage ? undefined : ctx.imei,
194
+ visibility: isGroupMessage ? 0 : undefined,
195
+ qmsgAttach: isGroupMessage ? JSON.stringify(prepareQMSGAttach(quote)) : undefined,
196
+ qmsgTTL: quote.ttl,
197
+ ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
198
+ }
199
+ : {
200
+ message: msg,
201
+ clientId: Date.now(),
202
+ mentionInfo: isMentionsValid ? JSON.stringify(mentionsFinal) : undefined,
203
+ imei: isGroupMessage ? undefined : ctx.imei,
204
+ ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
205
+ visibility: isGroupMessage ? 0 : undefined,
206
+ toid: isGroupMessage ? undefined : threadId,
207
+ grid: isGroupMessage ? threadId : undefined,
208
+ };
209
+ handleStyles(params, styles);
210
+ handleUrgency(params, urgency);
211
+ removeUndefinedKeys(params);
212
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
213
+ if (!encryptedParams)
214
+ throw new ZaloApiError("Failed to encrypt message");
215
+ const finalServiceUrl = new URL(serviceURLs.message[type]);
216
+ if (quote) {
217
+ finalServiceUrl.pathname = finalServiceUrl.pathname + "/quote";
218
+ }
219
+ else {
220
+ finalServiceUrl.pathname =
221
+ finalServiceUrl.pathname +
222
+ "/" +
223
+ (isGroupMessage ? (params.mentionInfo ? "mention" : "sendmsg") : "sms");
224
+ }
225
+ return {
226
+ url: finalServiceUrl.toString(),
227
+ body: new URLSearchParams({ params: encryptedParams }),
228
+ };
229
+ }
230
+ async function handleAttachment({ msg, attachments, mentions, quote, ttl, urgency }, threadId, type) {
231
+ if (!attachments)
232
+ throw new ZaloApiError("Missing attachments");
233
+ if (!Array.isArray(attachments))
234
+ attachments = [attachments];
235
+ if (attachments.length == 0)
236
+ throw new ZaloApiError("Missing attachments");
237
+ const firstSource = attachments[0];
238
+ const isFilePath = typeof firstSource == "string";
239
+ const firstExtFile = getFileExtension(isFilePath ? firstSource : firstSource.filename);
240
+ const isSingleFile = attachments.length == 1;
241
+ const isGroupMessage = type == ThreadType.Group;
242
+ const canBeDesc = isSingleFile && ["jpg", "jpeg", "png", "webp"].includes(firstExtFile);
243
+ const gifFiles = attachments.filter((e) => getFileExtension(typeof e == "string" ? e : e.filename) == "gif");
244
+ attachments = attachments.filter((e) => getFileExtension(typeof e == "string" ? e : e.filename) != "gif");
245
+ const uploadAttachment = attachments.length == 0 ? [] : await api.uploadAttachment(attachments, threadId, type);
246
+ const attachmentsData = [];
247
+ let indexInGroupLayout = 0;
248
+ const groupLayoutId = getGroupLayoutId().toString();
249
+ const { mentionsFinal, msgFinal } = handleMentions(type, msg, mentions);
250
+ msg = msgFinal;
251
+ const isMentionsValid = mentionsFinal.length > 0 && isGroupMessage && attachments.length == 1;
252
+ const isMultiFile = attachments.length > 1;
253
+ let clientId = Date.now();
254
+ for (const attachment of uploadAttachment) {
255
+ let data;
256
+ switch (attachment.fileType) {
257
+ case "image": {
258
+ data = {
259
+ fileType: attachment.fileType,
260
+ params: {
261
+ photoId: attachment.photoId,
262
+ clientId: (clientId++).toString(),
263
+ desc: msg,
264
+ width: attachment.width,
265
+ height: attachment.height,
266
+ toid: isGroupMessage ? undefined : String(threadId),
267
+ grid: isGroupMessage ? String(threadId) : undefined,
268
+ rawUrl: attachment.normalUrl,
269
+ hdUrl: attachment.hdUrl,
270
+ thumbUrl: attachment.thumbUrl,
271
+ oriUrl: isGroupMessage ? attachment.normalUrl : undefined,
272
+ normalUrl: isGroupMessage ? undefined : attachment.normalUrl,
273
+ hdSize: String(attachment.totalSize),
274
+ zsource: -1,
275
+ ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
276
+ jcp: '{"convertible":"jxl"}',
277
+ groupLayoutId: isMultiFile ? groupLayoutId : undefined,
278
+ isGroupLayout: isMultiFile ? 1 : undefined,
279
+ idInGroup: isMultiFile ? indexInGroupLayout++ : undefined,
280
+ totalItemInGroup: isMultiFile ? uploadAttachment.length : undefined,
281
+ extMsgProp: isMultiFile ? `{"groupMediaMsg":{"groupLayoutId":"${groupLayoutId}"}}` : undefined,
282
+ mentionInfo: isMentionsValid && canBeDesc && !quote ? JSON.stringify(mentionsFinal) : undefined,
283
+ },
284
+ body: new URLSearchParams(),
285
+ };
286
+ break;
287
+ }
288
+ case "video": {
289
+ data = {
290
+ fileType: attachment.fileType,
291
+ params: {
292
+ fileId: attachment.fileId,
293
+ checksum: attachment.checksum,
294
+ checksumSha: "",
295
+ extention: getFileExtension(attachment.fileName),
296
+ totalSize: attachment.totalSize,
297
+ fileName: attachment.fileName,
298
+ clientId: attachment.clientFileId,
299
+ fType: 1,
300
+ fileCount: 0,
301
+ fdata: "{}",
302
+ toid: isGroupMessage ? undefined : String(threadId),
303
+ grid: isGroupMessage ? String(threadId) : undefined,
304
+ fileUrl: attachment.fileUrl,
305
+ zsource: -1,
306
+ ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
307
+ },
308
+ body: new URLSearchParams(),
309
+ };
310
+ break;
311
+ }
312
+ case "others": {
313
+ data = {
314
+ fileType: attachment.fileType,
315
+ params: {
316
+ fileId: attachment.fileId,
317
+ checksum: attachment.checksum,
318
+ checksumSha: "",
319
+ extention: getFileExtension(attachment.fileName),
320
+ totalSize: attachment.totalSize,
321
+ fileName: attachment.fileName,
322
+ clientId: attachment.clientFileId,
323
+ fType: 1,
324
+ fileCount: 0,
325
+ fdata: "{}",
326
+ toid: isGroupMessage ? undefined : String(threadId),
327
+ grid: isGroupMessage ? String(threadId) : undefined,
328
+ fileUrl: attachment.fileUrl,
329
+ zsource: -1,
330
+ ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
331
+ },
332
+ body: new URLSearchParams(),
333
+ };
334
+ break;
335
+ }
336
+ }
337
+ handleUrgency(data.params, urgency);
338
+ removeUndefinedKeys(data.params);
339
+ const encryptedParams = utils.encodeAES(JSON.stringify(data.params));
340
+ if (!encryptedParams)
341
+ throw new ZaloApiError("Failed to encrypt message");
342
+ data.body.append("params", encryptedParams);
343
+ attachmentsData.push(data);
344
+ }
345
+ for (const gif of gifFiles) {
346
+ const isFilePath = typeof gif == "string";
347
+ const gifData = isFilePath ? await getGifMetaData(ctx, gif) : Object.assign(Object.assign({}, gif.metadata), { fileName: gif.filename });
348
+ if (isExceedMaxFileSize(gifData.totalSize))
349
+ throw new ZaloApiError(`File ${isFilePath ? getFileName(gif) : gif.filename} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
350
+ const _upthumb = await upthumb(gif, serviceURLs.attachment[ThreadType.User]);
351
+ const formData = new FormData();
352
+ formData.append("chunkContent", isFilePath ? await fs.readFile(gif) : gif.data, {
353
+ filename: isFilePath ? getFileName(gif) : gif.filename,
354
+ contentType: "application/octet-stream",
355
+ });
356
+ const params = {
357
+ clientId: Date.now().toString(),
358
+ fileName: gifData.fileName,
359
+ totalSize: gifData.totalSize,
360
+ width: gifData.width,
361
+ height: gifData.height,
362
+ msg: msg,
363
+ type: 1,
364
+ ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
365
+ visibility: isGroupMessage ? 0 : undefined,
366
+ toid: isGroupMessage ? undefined : threadId,
367
+ grid: isGroupMessage ? threadId : undefined,
368
+ thumb: _upthumb.url,
369
+ checksum: (await getMd5LargeFileObject(gif, gifData.totalSize)).data,
370
+ totalChunk: 1,
371
+ chunkId: 1,
372
+ };
373
+ handleUrgency(params, urgency);
374
+ removeUndefinedKeys(params);
375
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
376
+ if (!encryptedParams)
377
+ throw new ZaloApiError("Failed to encrypt message");
378
+ attachmentsData.push({
379
+ query: {
380
+ params: encryptedParams,
381
+ type: "1",
382
+ },
383
+ body: formData.getBuffer(),
384
+ headers: formData.getHeaders(),
385
+ fileType: "gif",
386
+ });
387
+ }
388
+ const responses = [];
389
+ for (const data of attachmentsData) {
390
+ responses.push({
391
+ url: utils.makeURL(serviceURLs.attachment[type] + attachmentUrlType[data.fileType], Object.assign({
392
+ nretry: "0",
393
+ }, data.query || {})),
394
+ body: data.body,
395
+ headers: data.fileType == "gif" ? data.headers : {},
396
+ });
397
+ }
398
+ return responses;
399
+ }
400
+ /**
401
+ * Send a message to a thread
402
+ *
403
+ * @param message Message content
404
+ * @param threadId group or user id
405
+ * @param type Message type (User or Group)
406
+ * @param quote Message or GroupMessage instance (optional), used for quoting
407
+ *
408
+ * @throws {ZaloApiError | ZaloApiMissingImageMetadataGetter}
409
+ */
410
+ return async function sendMessage(message, threadId, type = ThreadType.User) {
411
+ if (!message)
412
+ throw new ZaloApiError("Missing message content");
413
+ if (!threadId)
414
+ throw new ZaloApiError("Missing threadId");
415
+ if (typeof message == "string")
416
+ message = { msg: message };
417
+ let { msg, attachments, mentions } = message;
418
+ const { quote, ttl, styles, urgency } = message;
419
+ if (attachments && !Array.isArray(attachments)) {
420
+ attachments = [attachments];
421
+ }
422
+ if (!msg && (!attachments || (attachments && attachments.length == 0)))
423
+ throw new ZaloApiError("Missing message content");
424
+ if (attachments && isExceedMaxFile(attachments.length))
425
+ throw new ZaloApiError("Exceed maximum file of " + sharefile.max_file);
426
+ const responses = {
427
+ message: null,
428
+ attachment: [],
429
+ };
430
+ if (attachments && attachments.length > 0) {
431
+ const firstExtFile = getFileExtension(typeof attachments[0] == "string" ? attachments[0] : attachments[0].filename);
432
+ const isSingleFile = attachments.length == 1;
433
+ const canBeDesc = isSingleFile && ["jpg", "jpeg", "png", "webp"].includes(firstExtFile);
434
+ if ((!canBeDesc && msg.length > 0) || (msg.length > 0 && quote)) {
435
+ // send message and attachment separately
436
+ await handleMessage(message, threadId, type).then(async (data) => {
437
+ responses.message = (await send(data))[0];
438
+ });
439
+ msg = "";
440
+ mentions = undefined;
441
+ }
442
+ const handledData = await handleAttachment({ msg, mentions, attachments, quote, ttl, styles, urgency }, threadId, type);
443
+ responses.attachment = await send(handledData);
444
+ msg = "";
445
+ }
446
+ if (msg.length > 0) {
447
+ const handledData = await handleMessage(message, threadId, type);
448
+ responses.message = (await send(handledData))[0];
449
+ }
450
+ return responses;
451
+ };
452
+ });
@@ -0,0 +1,17 @@
1
+ import { ThreadType } from "../models/index.js";
2
+ export declare enum ReportReason {
3
+ Sensitive = 1,
4
+ Annoy = 2,
5
+ Fraud = 3,
6
+ Other = 0
7
+ }
8
+ export type SendReportOptions = {
9
+ reason: ReportReason.Other;
10
+ content: string;
11
+ } | {
12
+ reason: Exclude<ReportReason, ReportReason.Other>;
13
+ };
14
+ export type SendReportResponse = {
15
+ reportId: string;
16
+ };
17
+ export declare const sendReportFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (options: SendReportOptions, threadId: string, type?: ThreadType) => Promise<SendReportResponse>;
@@ -0,0 +1,53 @@
1
+ import { ZaloApiError } from "../Errors/ZaloApiError.js";
2
+ import { ThreadType } from "../models/index.js";
3
+ import { apiFactory, removeUndefinedKeys } from "../utils.js";
4
+ export var ReportReason;
5
+ (function (ReportReason) {
6
+ ReportReason[ReportReason["Sensitive"] = 1] = "Sensitive";
7
+ ReportReason[ReportReason["Annoy"] = 2] = "Annoy";
8
+ ReportReason[ReportReason["Fraud"] = 3] = "Fraud";
9
+ ReportReason[ReportReason["Other"] = 0] = "Other";
10
+ })(ReportReason || (ReportReason = {}));
11
+ export const sendReportFactory = apiFactory()((api, ctx, utils) => {
12
+ const serviceURL = {
13
+ [ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/report/abuse-v2`),
14
+ [ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/reportabuse`),
15
+ };
16
+ /**
17
+ * Send report to Zalo
18
+ *
19
+ * @param options Report options
20
+ * @param threadId The threadID to report
21
+ * @param type Thread type, default direct
22
+ *
23
+ * @throws {ZaloApiError}
24
+ *
25
+ */
26
+ return async function sendReport(options, threadId, type = ThreadType.User) {
27
+ const params = type == ThreadType.User
28
+ ? {
29
+ idTo: threadId,
30
+ objId: "person.profile",
31
+ reason: options.reason.toString(),
32
+ content: options.reason == ReportReason.Other ? options.content : undefined,
33
+ }
34
+ : {
35
+ uidTo: threadId,
36
+ type: 14,
37
+ reason: options.reason,
38
+ content: options.reason == ReportReason.Other ? options.content : "",
39
+ imei: ctx.imei,
40
+ };
41
+ removeUndefinedKeys(params);
42
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
43
+ if (!encryptedParams)
44
+ throw new ZaloApiError("Failed to encrypt params");
45
+ const response = await utils.request(serviceURL[type], {
46
+ method: "POST",
47
+ body: new URLSearchParams({
48
+ params: encryptedParams,
49
+ }),
50
+ });
51
+ return utils.resolve(response);
52
+ };
53
+ });